Quick Search:

View

Revision:

Diff

Diff from 296 to:

Annotations

Annotate by Age | Author | Mixed | None
/fisheye/browse/osCommerce/branches/hpdl/oscommerce/includes/modules/content/recently_visited.php

Annotated File View

hpdl
228
1 <?php
2 /*
3
4   osCommerce, Open Source E-Commerce Solutions
5   http://www.oscommerce.com
6
hpdl
296
7   Copyright (c) 2005 osCommerce
hpdl
228
8
9   Released under the GNU General Public License
10 */
11
12   class osC_Recently_visited {
13
hpdl
290
14     var $visits = array();
hpdl
228
15
16 /* Class constructor */
17
hpdl
290
18     function osC_Recently_visited() {
hpdl
296
19       if (isset($_SESSION['osC_RecentlyVisited_data']) === false) {
20         $_SESSION['osC_RecentlyVisited_data'] = array();
21       }
22
23       $this->visits =& $_SESSION['osC_RecentlyVisited_data'];
hpdl
290
24     }
hpdl
228
25
hpdl
290
26     function contentModuleInitialize() {
hpdl
296
27       global $osC_Services, $osC_RecentlyVisited, $osC_Product;
hpdl
228
28
hpdl
290
29       if ($osC_Services->isStarted('recently_visited')) {
30         if (isset($osC_Product) && is_a($osC_Product, 'osC_Product')) {
hpdl
296
31           $osC_RecentlyVisited->setProduct($osC_Product->getID());
hpdl
290
32         }
33       }
34     }
35
36     function getContentModule() {
37       return 'recently_visited.php';
38     }
39
hpdl
228
40    function setProduct($id) {
41      foreach ($this->visits['products'] as $key => $value) {
42       if ($this->visits['products'][$key]['products_id'] == $id) {
43        unset($this->visits['products'][$key]);
44        break;
45       }
46      }
47
48      if (sizeof($this->visits['products']) >= MAX_RECENTLY_VISITED_PRODUCTS+3) {
49       $keys = array_keys($this->visits['products']);
50       unset($this->visits['products'][$keys[0]]);
hpdl
290
51       $this->debug[] = 'unsetted ' . $keys[0];
hpdl
228
52      }
53
54      if (SERVICE_RECENTLY_VISITED_ORIGINAL_PAGE == 'True') {
55       $this->visits['products'][] = array('products_id' => $id,
56                                           'page_name' => basename($_SERVER['PHP_SELF']),
57                                           'get_params' => tep_array_to_string($_GET, array($osC_Session->name, 'action', 'products_id'))
58                                          );
59      } else {
60       $this->visits['products'][] = array('products_id' => $id);
61      }
62    }
63
64    function setCategory() {
65     if (!empty($_GET['cPath'])) {
66
67      $cpath = $_GET['cPath'];
68
69      foreach ($this->visits['categories'] as $key => $value) {
70       if ($this->visits['categories'][$key]['cpath'] == $cpath) {
71        unset($this->visits['categories'][$key]);
72        break;
73       }
74      }
75
76      if (sizeof($this->visits['categories']) >= MAX_RECENTLY_VISITED_CATEGORIES+3) {
77       $keys = array_keys($this->visits['categories']);
78       unset($this->visits['categories'][$keys[0]]);
79      }
80
81       $this->visits['categories'][] = array('cpath' => $cpath);
82
83     }
84    }
85
86    function setSearchQuery() {
87     if (!empty($_GET['keywords'])) {
88
89      $keywords = $_GET['keywords'];
90
91      foreach ($this->visits['searches'] as $key => $value) {
92       if ($this->visits['searches'][$key]['keywords'] == $keywords) {
93        unset($this->visits['searches'][$key]);
94        break;
95       }
96      }
97
98      if (sizeof($this->visits['searches']) >= MAX_RECENTLY_VISITED_SEARCHES+3) {
99       $keys = array_keys($this->visits['searches']);
100       unset($this->visits['searches'][$keys[0]]);
101      }
102      $this->visits['searches'][] = array('keywords' => $keywords,
103                                          'get_params' => tep_array_to_string($_GET, array($osC_Session->name, 'keywords')));
104     }
105    }
106
107  }
108 ?>
    \ No newline at end of file