  |
9 | 9 | | Released under the GNU General Public License |
| |
10 | 10 | | */ |
| |
11 | 11 | | |
  |
12 | | - | class osC_Recently_visited { |
| |
| 12 | + | class osC_RecentlyVisited { |
|
13 | 13 | | |
| |
14 | 14 | | var $visits = array(); |
| |
15 | 15 | | |
| |
16 | 16 | | /* Class constructor */ |
| |
17 | 17 | | |
  |
18 | | - | function osC_Recently_visited() { |
| |
| 18 | + | function osC_RecentlyVisited() { |
|
19 | 19 | | if (isset($_SESSION['osC_RecentlyVisited_data']) === false) { |
| |
20 | 20 | | $_SESSION['osC_RecentlyVisited_data'] = array(); |
| |
21 | 21 | | } |
| |
|
|
 |
… |
|
24 | 24 | | } |
| |
25 | 25 | | |
| |
26 | 26 | | function contentModuleInitialize() { |
  |
27 | | - | global $osC_Services, $osC_RecentlyVisited, $osC_Product; |
| |
| 27 | + | global $osC_Product; |
|
28 | 28 | | |
  |
29 | | - | if ($osC_Services->isStarted('recently_visited')) { |
| |
30 | | - | if (isset($osC_Product) && is_a($osC_Product, 'osC_Product')) { |
| |
31 | | - | $osC_RecentlyVisited->setProduct($osC_Product->getID()); |
| |
32 | | - | } |
| |
| 29 | + | if (isset($osC_Product) && is_a($osC_Product, 'osC_Product')) { |
| |
| 30 | + | $this->setProduct($osC_Product->getID()); |
|
33 | 31 | | } |
  |
| 32 | + | |
| |
| 33 | + | if (SERVICE_RECENTLY_VISITED_SHOW_CATEGORIES == 'True') { |
| |
| 34 | + | $this->setCategory(); |
| |
| 35 | + | } |
| |
| 36 | + | |
| |
| 37 | + | if (SERVICE_RECENTLY_VISITED_SHOW_SEARCHES == 'True') { |
| |
| 38 | + | $this->setSearchQuery(); |
| |
| 39 | + | } |
|
34 | 40 | | } |
| |
35 | 41 | | |
| |
36 | 42 | | function getContentModule() { |
| |
|
|
 |
… |
|
104 | 110 | | } |
| |
105 | 111 | | } |
| |
106 | 112 | | |
  |
| 113 | + | function hasCategories() { |
| |
| 114 | + | if (isset($this->visits['categories']) && (empty($this->visits['categories']) === false)) { |
| |
| 115 | + | return true; |
| |
| 116 | + | } |
| |
| 117 | + | |
| |
| 118 | + | return false; |
| |
| 119 | + | } |
| |
| 120 | + | |
| |
| 121 | + | function getCategories() { |
| |
| 122 | + | global $osC_Database; |
| |
| 123 | + | |
| |
| 124 | + | $history = array(); |
| |
| 125 | + | |
| |
| 126 | + | if (isset($this->visits['categories']) && (empty($this->visits['categories']) === false)) { |
| |
| 127 | + | foreach ($this->visits['categories'] as $k => $v) { |
| |
| 128 | + | $parts = explode("_", $this->visits['categories'][$k]['cpath']); |
| |
| 129 | + | |
| |
| 130 | + | if (sizeof($parts) > 1) { |
| |
| 131 | + | $Qpcategory = $osC_Database->query('select categories_name, categories_id from :table_categories_description where categories_id = :categories_id and language_id = :language_id'); |
| |
| 132 | + | $Qpcategory->bindTable(':table_categories_description', TABLE_CATEGORIES_DESCRIPTION); |
| |
| 133 | + | $Qpcategory->bindInt(':categories_id', $parts[0]); |
| |
| 134 | + | $Qpcategory->bindInt(':language_id', $_SESSION['languages_id']); |
| |
| 135 | + | $Qpcategory->execute(); |
| |
| 136 | + | |
| |
| 137 | + | $Qcategory = $osC_Database->query('select categories_name from :table_categories_description where categories_id = :categories_id and language_id = :language_id'); |
| |
| 138 | + | $Qcategory->bindTable(':table_categories_description', TABLE_CATEGORIES_DESCRIPTION); |
| |
| 139 | + | $Qcategory->bindInt(':categories_id', $parts[sizeof($parts)-1]); |
| |
| 140 | + | $Qcategory->bindInt(':language_id', $_SESSION['languages_id']); |
| |
| 141 | + | $Qcategory->execute(); |
| |
| 142 | + | } else { |
| |
| 143 | + | $Qpcategory = false; |
| |
| 144 | + | |
| |
| 145 | + | $Qcategory = $osC_Database->query('select categories_name from :table_categories_description where categories_id = :categories_id and language_id = :language_id'); |
| |
| 146 | + | $Qcategory->bindTable(':table_categories_description', TABLE_CATEGORIES_DESCRIPTION); |
| |
| 147 | + | $Qcategory->bindInt(':categories_id', $parts[0]); |
| |
| 148 | + | $Qcategory->bindInt(':language_id', $_SESSION['languages_id']); |
| |
| 149 | + | $Qcategory->execute(); |
| |
| 150 | + | } |
| |
| 151 | + | |
| |
| 152 | + | $history[] = array('parents_name' => ($Qpcategory) ? $Qpcategory->value('categories_name') : '', |
| |
| 153 | + | 'parents_id' => ($Qpcategory) ? $Qpcategory->value('categories_id') : '', |
| |
| 154 | + | 'category_name' => $Qcategory->value('categories_name'), |
| |
| 155 | + | 'category_id' => $this->visits['categories'][$k]['cpath'] |
| |
| 156 | + | ); |
| |
| 157 | + | } |
| |
| 158 | + | |
| |
| 159 | + | if (empty($history) === false) { |
| |
| 160 | + | krsort($history); |
| |
| 161 | + | $history = array_slice($history, 0, MAX_RECENTLY_VISITED_CATEGORIES); |
| |
| 162 | + | } |
| |
| 163 | + | } |
| |
| 164 | + | |
| |
| 165 | + | return $history; |
| |
| 166 | + | } |
| |
| 167 | + | |
| |
| 168 | + | function hasProducts() { |
| |
| 169 | + | if (isset($this->visits['products']) && (empty($this->visits['products']) === false)) { |
| |
| 170 | + | return true; |
| |
| 171 | + | } |
| |
| 172 | + | |
| |
| 173 | + | return false; |
| |
| 174 | + | } |
| |
| 175 | + | |
| |
| 176 | + | function getProducts() { |
| |
| 177 | + | global $osC_Database, $osC_Services, $osC_Currencies, $osC_Specials; |
| |
| 178 | + | |
| |
| 179 | + | $history = array(); |
| |
| 180 | + | |
| |
| 181 | + | if (isset($this->visits['products']) && (empty($this->visits['products']) === false)) { |
| |
| 182 | + | foreach ($this->visits['products'] as $k => $v) { |
| |
| 183 | + | $cpath = tep_get_product_path($this->visits['products'][$k]['products_id']); |
| |
| 184 | + | $parts = explode("_", $cpath); |
| |
| 185 | + | $cat_id = $parts[sizeof($parts)-1]; |
| |
| 186 | + | |
| |
| 187 | + | $Qcategory = $osC_Database->query('select categories_name from :table_categories_description where categories_id = :categories_id and language_id = :language_id'); |
| |
| 188 | + | $Qcategory->bindTable(':table_categories_description', TABLE_CATEGORIES_DESCRIPTION); |
| |
| 189 | + | $Qcategory->bindInt(':categories_id', $cat_id); |
| |
| 190 | + | $Qcategory->bindInt(':language_id', $_SESSION['languages_id']); |
| |
| 191 | + | $Qcategory->execute(); |
| |
| 192 | + | |
| |
| 193 | + | $products_name = tep_get_products_name($this->visits['products'][$k]['products_id']); |
| |
| 194 | + | |
| |
| 195 | + | if ( (SERVICE_RECENTLY_VISITED_SHOW_IMAGE == 'True') or (SERVICE_RECENTLY_VISITED_SHOW_PRICE == 'True') ) { |
| |
| 196 | + | $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'); |
| |
| 197 | + | $Qproduct->bindTable(':table_products', TABLE_PRODUCTS); |
| |
| 198 | + | $Qproduct->bindInt(':products_id', $this->visits['products'][$k]['products_id']); |
| |
| 199 | + | $Qproduct->execute(); |
| |
| 200 | + | |
| |
| 201 | + | if (SERVICE_RECENTLY_VISITED_SHOW_PRICE == 'True') { |
| |
| 202 | + | if ( ($osC_Services->isStarted('specials')) && ($new_price = $osC_Specials->getPrice($this->visits['products'][$k]['products_id'])) ) { |
| |
| 203 | + | $products_price = '<s>' . $osC_Currencies->displayPrice($Qproduct->value('products_price'), $Qproduct->valueInt('products_tax_class_id')) . '</s> <span class="productSpecialPrice">' . $osC_Currencies->displayPrice($new_price, $Qproduct->valueInt('products_tax_class_id')) . '</span>'; |
| |
| 204 | + | } else { |
| |
| 205 | + | $products_price = $osC_Currencies->displayPrice($Qproduct->value('products_price'), $Qproduct->valueInt('products_tax_class_id')); |
| |
| 206 | + | } |
| |
| 207 | + | } |
| |
| 208 | + | } |
| |
| 209 | + | |
| |
| 210 | + | $history[] = array('name' => $products_name, |
| |
| 211 | + | 'page' => ($this->visits['products'][$k]['page_name']) ? $this->visits['products'][$k]['page_name'] : FILENAME_DEFAULT, |
| |
| 212 | + | 'id' => $this->visits['products'][$k]['products_id'], |
| |
| 213 | + | 'get_params' => $this->visits['products'][$k]['get_params'], |
| |
| 214 | + | 'price' => (SERVICE_RECENTLY_VISITED_SHOW_PRICE == 'True') ? $products_price : '', |
| |
| 215 | + | 'image' => (SERVICE_RECENTLY_VISITED_SHOW_IMAGE == 'True') ? $Qproduct->value('products_image') : '', |
| |
| 216 | + | 'category_name' => $Qcategory->value('categories_name'), |
| |
| 217 | + | 'category_path' => $cpath |
| |
| 218 | + | ); |
| |
| 219 | + | } |
| |
| 220 | + | |
| |
| 221 | + | if (empty($history) === false) { |
| |
| 222 | + | krsort($history); |
| |
| 223 | + | $history = array_slice($history, 0, MAX_RECENTLY_VISITED_PRODUCTS); |
| |
| 224 | + | } |
| |
| 225 | + | } |
| |
| 226 | + | |
| |
| 227 | + | return $history; |
| |
| 228 | + | } |
| |
| 229 | + | |
| |
| 230 | + | function hasSearches() { |
| |
| 231 | + | if (isset($this->visits['searches']) && (empty($this->visits['searches']) === false)) { |
| |
| 232 | + | return true; |
| |
| 233 | + | } |
| |
| 234 | + | |
| |
| 235 | + | return false; |
| |
| 236 | + | } |
| |
| 237 | + | |
| |
| 238 | + | function getSearches() { |
| |
| 239 | + | $history = array(); |
| |
| 240 | + | |
| |
| 241 | + | if (isset($this->visits['searches']) && (empty($this->visits['searches']) === false)) { |
| |
| 242 | + | foreach ($this->visits['searches'] as $k => $v) { |
| |
| 243 | + | $history[] = array('keywords' => $this->visits['searches'][$k]['keywords'], 'parents_id' => ($Qpcategory) ? $Qpcategory->value('categories_id') : '', |
| |
| 244 | + | 'get_params' => $this->visits['searches'][$k]['get_params'] |
| |
| 245 | + | ); |
| |
| 246 | + | } |
| |
| 247 | + | |
| |
| 248 | + | if (empty($history) === false) { |
| |
| 249 | + | krsort($history); |
| |
| 250 | + | $history = array_slice($history, 0, MAX_RECENTLY_VISITED_SEARCHES); |
| |
| 251 | + | } |
| |
| 252 | + | } |
| |
| 253 | + | |
| |
| 254 | + | return $history; |
| |
| 255 | + | } |
|
107 | 256 | | } |
  |
108 | | - | ?> |
| |
| 257 | + | ?> |