Quick Search:

View

Revision:

Diff

Diff from 290 to:

Annotations

Annotate by Age | Author | Mixed | None
/fisheye/browse/osCommerce/branches/hpdl/oscommerce/includes/classes/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
7   Copyright (c) 2004 osCommerce
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() {
19     }
hpdl
228
20
hpdl
290
21     function contentModuleInitialize() {
22       global $osC_Services, $osC_Product;
hpdl
228
23
hpdl
290
24       if ($osC_Services->isStarted('recently_visited')) {
25         if (isset($osC_Product) && is_a($osC_Product, 'osC_Product')) {
26           $_SESSION['recently_visited']->setProduct($osC_Product->getID());
27         }
28       }
29     }
30
31     function getContentModule() {
32       return 'recently_visited.php';
33     }
34
hpdl
228
35    function setProduct($id) {
36      foreach ($this->visits['products'] as $key => $value) {
37       if ($this->visits['products'][$key]['products_id'] == $id) {
38        unset($this->visits['products'][$key]);
39        break;
40       }
41      }
42
43      if (sizeof($this->visits['products']) >= MAX_RECENTLY_VISITED_PRODUCTS+3) {
44       $keys = array_keys($this->visits['products']);
45       unset($this->visits['products'][$keys[0]]);
hpdl
290
46       $this->debug[] = 'unsetted ' . $keys[0];
hpdl
228
47      }
48
49      if (SERVICE_RECENTLY_VISITED_ORIGINAL_PAGE == 'True') {
50       $this->visits['products'][] = array('products_id' => $id,
51                                           'page_name' => basename($_SERVER['PHP_SELF']),
52                                           'get_params' => tep_array_to_string($_GET, array($osC_Session->name, 'action', 'products_id'))
53                                          );
54      } else {
55       $this->visits['products'][] = array('products_id' => $id);
56      }
57    }
58
59    function setCategory() {
60     if (!empty($_GET['cPath'])) {
61
62      $cpath = $_GET['cPath'];
63
64      foreach ($this->visits['categories'] as $key => $value) {
65       if ($this->visits['categories'][$key]['cpath'] == $cpath) {
66        unset($this->visits['categories'][$key]);
67        break;
68       }
69      }
70
71      if (sizeof($this->visits['categories']) >= MAX_RECENTLY_VISITED_CATEGORIES+3) {
72       $keys = array_keys($this->visits['categories']);
73       unset($this->visits['categories'][$keys[0]]);
74      }
75
76       $this->visits['categories'][] = array('cpath' => $cpath);
77
78     }
79    }
80
81    function setSearchQuery() {
82     if (!empty($_GET['keywords'])) {
83
84      $keywords = $_GET['keywords'];
85
86      foreach ($this->visits['searches'] as $key => $value) {
87       if ($this->visits['searches'][$key]['keywords'] == $keywords) {
88        unset($this->visits['searches'][$key]);
89        break;
90       }
91      }
92
93      if (sizeof($this->visits['searches']) >= MAX_RECENTLY_VISITED_SEARCHES+3) {
94       $keys = array_keys($this->visits['searches']);
95       unset($this->visits['searches'][$keys[0]]);
96      }
97      $this->visits['searches'][] = array('keywords' => $keywords,
98                                          'get_params' => tep_array_to_string($_GET, array($osC_Session->name, 'keywords')));
99     }
100    }
101
102  }
103 ?>
    \ No newline at end of file