visits =& $_SESSION['osC_RecentlyVisited_data']; } function contentModuleInitialize() { global $osC_Product, $osC_Category, $osC_Search; if (isset($osC_Product) && is_a($osC_Product, 'osC_Product')) { $this->setProduct($osC_Product->getID()); } if (SERVICE_RECENTLY_VISITED_SHOW_CATEGORIES == 'True') { if (isset($osC_Category) && is_a($osC_Category, 'osC_Category')) { $this->setCategory($osC_Category->getID()); } } if (SERVICE_RECENTLY_VISITED_SHOW_SEARCHES == 'True') { if (isset($osC_Search) && is_a($osC_Search, 'osC_Search')) { if ($osC_Search->hasKeywords()) { $this->setSearchQuery($osC_Search->getKeywords()); } } } } function getContentModule() { return 'recently_visited.php'; } function setProduct($id) { if (isset($this->visits['products'])) { foreach ($this->visits['products'] as $key => $value) { if ($value['id'] == $id) { unset($this->visits['products'][$key]); break; } } if (sizeof($this->visits['products']) > (MAX_RECENTLY_VISITED_PRODUCTS * 2)) { array_pop($this->visits['products']); } } else { $this->visits['products'] = array(); } array_unshift($this->visits['products'], array('id' => $id)); } function setCategory($id) { if (isset($this->visits['categories'])) { foreach ($this->visits['categories'] as $key => $value) { if ($value['id'] == $id) { unset($this->visits['categories'][$key]); break; } } if (sizeof($this->visits['categories']) > (MAX_RECENTLY_VISITED_CATEGORIES * 2)) { array_pop($this->visits['categories']); } } else { $this->visits['categories'] = array(); } array_unshift($this->visits['categories'], array('id' => $id)); } function setSearchQuery($keywords) { global $osC_Search; if (isset($this->visits['searches'])) { foreach ($this->visits['searches'] as $key => $value) { if ($value['keywords'] == $keywords) { unset($this->visits['searches'][$key]); break; } } if (sizeof($this->visits['searches']) > (MAX_RECENTLY_VISITED_SEARCHES * 2)) { array_pop($this->visits['searches']); } } else { $this->visits['searches'] = array(); } array_unshift($this->visits['searches'], array('keywords' => $keywords, 'results' => $osC_Search->getNumberOfResults() )); } function hasHistory() { if ($this->hasProducts() || $this->hasCategories() || $this->hasSearches()) { return true; } return false; } 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)) { $counter = 0; foreach ($this->visits['products'] as $k => $v) { $counter++; $cpath = tep_get_product_path($this->visits['products'][$k]['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]['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]['id']); $Qproduct->execute(); if (SERVICE_RECENTLY_VISITED_SHOW_PRICE == 'True') { if ( ($osC_Services->isStarted('specials')) && ($new_price = $osC_Specials->getPrice($this->visits['products'][$k]['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]['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 ($counter == MAX_RECENTLY_VISITED_PRODUCTS) { break; } } } return $history; } 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)) { $osC_CategoryTree = new osC_CategoryTree(); $counter = 0; foreach ($this->visits['categories'] as $k => $v) { $counter++; $cpath = $osC_CategoryTree->buildBreadcrumb($this->visits['categories'][$k]['id']); $parts = explode("_", $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' => $cpath ); if ($counter == MAX_RECENTLY_VISITED_CATEGORIES) { break; } } } 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)) { $counter = 0; foreach ($this->visits['searches'] as $k => $v) { $counter++; $history[] = array('keywords' => $this->visits['searches'][$k]['keywords'], 'results' => $this->visits['searches'][$k]['results'] ); if ($counter == MAX_RECENTLY_VISITED_SEARCHES) { break; } } } return $history; } } ?>