visits =& $_SESSION['osC_RecentlyVisited_data']; } function contentModuleInitialize() { global $osC_Product; if (isset($osC_Product) && is_a($osC_Product, 'osC_Product')) { $this->setProduct($osC_Product->getID()); } if (SERVICE_RECENTLY_VISITED_SHOW_CATEGORIES == 'True') { $this->setCategory(); } if (SERVICE_RECENTLY_VISITED_SHOW_SEARCHES == 'True') { $this->setSearchQuery(); } } function getContentModule() { return 'recently_visited.php'; } function setProduct($id) { foreach ($this->visits['products'] as $key => $value) { if ($this->visits['products'][$key]['products_id'] == $id) { unset($this->visits['products'][$key]); break; } } if (sizeof($this->visits['products']) >= MAX_RECENTLY_VISITED_PRODUCTS+3) { $keys = array_keys($this->visits['products']); unset($this->visits['products'][$keys[0]]); $this->debug[] = 'unsetted ' . $keys[0]; } if (SERVICE_RECENTLY_VISITED_ORIGINAL_PAGE == 'True') { $this->visits['products'][] = array('products_id' => $id, 'page_name' => basename($_SERVER['PHP_SELF']), 'get_params' => tep_array_to_string($_GET, array($osC_Session->name, 'action', 'products_id')) ); } else { $this->visits['products'][] = array('products_id' => $id); } } function setCategory() { if (!empty($_GET['cPath'])) { $cpath = $_GET['cPath']; foreach ($this->visits['categories'] as $key => $value) { if ($this->visits['categories'][$key]['cpath'] == $cpath) { unset($this->visits['categories'][$key]); break; } } if (sizeof($this->visits['categories']) >= MAX_RECENTLY_VISITED_CATEGORIES+3) { $keys = array_keys($this->visits['categories']); unset($this->visits['categories'][$keys[0]]); } $this->visits['categories'][] = array('cpath' => $cpath); } } function setSearchQuery() { if (!empty($_GET['keywords'])) { $keywords = $_GET['keywords']; foreach ($this->visits['searches'] as $key => $value) { if ($this->visits['searches'][$key]['keywords'] == $keywords) { unset($this->visits['searches'][$key]); break; } } if (sizeof($this->visits['searches']) >= MAX_RECENTLY_VISITED_SEARCHES+3) { $keys = array_keys($this->visits['searches']); unset($this->visits['searches'][$keys[0]]); } $this->visits['searches'][] = array('keywords' => $keywords, 'get_params' => tep_array_to_string($_GET, array($osC_Session->name, 'keywords'))); } } function hasCategories() { if (isset($this->visits['categories']) && (empty($this->visits['categories']) === false)) { return true; } return false; } function getCategories() { global $osC_Database; $history = array(); if (isset($this->visits['categories']) && (empty($this->visits['categories']) === false)) { foreach ($this->visits['categories'] as $k => $v) { $parts = explode("_", $this->visits['categories'][$k]['cpath']); if (sizeof($parts) > 1) { $Qpcategory = $osC_Database->query('select categories_name, categories_id from :table_categories_description where categories_id = :categories_id and language_id = :language_id'); $Qpcategory->bindTable(':table_categories_description', TABLE_CATEGORIES_DESCRIPTION); $Qpcategory->bindInt(':categories_id', $parts[0]); $Qpcategory->bindInt(':language_id', $_SESSION['languages_id']); $Qpcategory->execute(); $Qcategory = $osC_Database->query('select categories_name from :table_categories_description where categories_id = :categories_id and language_id = :language_id'); $Qcategory->bindTable(':table_categories_description', TABLE_CATEGORIES_DESCRIPTION); $Qcategory->bindInt(':categories_id', $parts[sizeof($parts)-1]); $Qcategory->bindInt(':language_id', $_SESSION['languages_id']); $Qcategory->execute(); } else { $Qpcategory = false; $Qcategory = $osC_Database->query('select categories_name from :table_categories_description where categories_id = :categories_id and language_id = :language_id'); $Qcategory->bindTable(':table_categories_description', TABLE_CATEGORIES_DESCRIPTION); $Qcategory->bindInt(':categories_id', $parts[0]); $Qcategory->bindInt(':language_id', $_SESSION['languages_id']); $Qcategory->execute(); } $history[] = array('parents_name' => ($Qpcategory) ? $Qpcategory->value('categories_name') : '', 'parents_id' => ($Qpcategory) ? $Qpcategory->value('categories_id') : '', 'category_name' => $Qcategory->value('categories_name'), 'category_id' => $this->visits['categories'][$k]['cpath'] ); } if (empty($history) === false) { krsort($history); $history = array_slice($history, 0, MAX_RECENTLY_VISITED_CATEGORIES); } } return $history; } function hasProducts() { if (isset($this->visits['products']) && (empty($this->visits['products']) === false)) { return true; } return false; } function getProducts() { global $osC_Database, $osC_Services, $osC_Currencies, $osC_Specials; $history = array(); if (isset($this->visits['products']) && (empty($this->visits['products']) === false)) { foreach ($this->visits['products'] as $k => $v) { $cpath = tep_get_product_path($this->visits['products'][$k]['products_id']); $parts = explode("_", $cpath); $cat_id = $parts[sizeof($parts)-1]; $Qcategory = $osC_Database->query('select categories_name from :table_categories_description where categories_id = :categories_id and language_id = :language_id'); $Qcategory->bindTable(':table_categories_description', TABLE_CATEGORIES_DESCRIPTION); $Qcategory->bindInt(':categories_id', $cat_id); $Qcategory->bindInt(':language_id', $_SESSION['languages_id']); $Qcategory->execute(); $products_name = tep_get_products_name($this->visits['products'][$k]['products_id']); if ( (SERVICE_RECENTLY_VISITED_SHOW_IMAGE == 'True') or (SERVICE_RECENTLY_VISITED_SHOW_PRICE == 'True') ) { $Qproduct = $osC_Database->query('select products_price, products_tax_class_id, products_image from :table_products where products_status = 1 and products_id = :products_id'); $Qproduct->bindTable(':table_products', TABLE_PRODUCTS); $Qproduct->bindInt(':products_id', $this->visits['products'][$k]['products_id']); $Qproduct->execute(); if (SERVICE_RECENTLY_VISITED_SHOW_PRICE == 'True') { if ( ($osC_Services->isStarted('specials')) && ($new_price = $osC_Specials->getPrice($this->visits['products'][$k]['products_id'])) ) { $products_price = '' . $osC_Currencies->displayPrice($Qproduct->value('products_price'), $Qproduct->valueInt('products_tax_class_id')) . ' ' . $osC_Currencies->displayPrice($new_price, $Qproduct->valueInt('products_tax_class_id')) . ''; } else { $products_price = $osC_Currencies->displayPrice($Qproduct->value('products_price'), $Qproduct->valueInt('products_tax_class_id')); } } } $history[] = array('name' => $products_name, 'page' => ($this->visits['products'][$k]['page_name']) ? $this->visits['products'][$k]['page_name'] : FILENAME_DEFAULT, 'id' => $this->visits['products'][$k]['products_id'], 'get_params' => $this->visits['products'][$k]['get_params'], 'price' => (SERVICE_RECENTLY_VISITED_SHOW_PRICE == 'True') ? $products_price : '', 'image' => (SERVICE_RECENTLY_VISITED_SHOW_IMAGE == 'True') ? $Qproduct->value('products_image') : '', 'category_name' => $Qcategory->value('categories_name'), 'category_path' => $cpath ); } if (empty($history) === false) { krsort($history); $history = array_slice($history, 0, MAX_RECENTLY_VISITED_PRODUCTS); } } return $history; } function hasSearches() { if (isset($this->visits['searches']) && (empty($this->visits['searches']) === false)) { return true; } return false; } function getSearches() { $history = array(); if (isset($this->visits['searches']) && (empty($this->visits['searches']) === false)) { foreach ($this->visits['searches'] as $k => $v) { $history[] = array('keywords' => $this->visits['searches'][$k]['keywords'], 'parents_id' => ($Qpcategory) ? $Qpcategory->value('categories_id') : '', 'get_params' => $this->visits['searches'][$k]['get_params'] ); } if (empty($history) === false) { krsort($history); $history = array_slice($history, 0, MAX_RECENTLY_VISITED_SEARCHES); } } return $history; } } ?>