Quick Search:

View

Revision:

Diff

Diff from 5 to:

Annotations

Annotate by Age | Author | Mixed | None
/fisheye/browse/osCommerce/branches/hpdl/oscommerce/includes/classes/navigation_history.php

Annotated File View

hpdl
1
1 <?php
2 /*
3   $Id: navigation_history.php 5 2005-01-31 01:40:15Z hpdl $
4
5   osCommerce, Open Source E-Commerce Solutions
6   http://www.oscommerce.com
7
8   Copyright (c) 2003 osCommerce
9
10   Released under the GNU General Public License
11 */
12
13   class navigationHistory {
14     var $path, $snapshot, $set_global;
15
16     function navigationHistory() {
17       $this->reset();
18
19       $this->setGlobal();
20     }
21
22     function reset() {
23       $this->path = array();
24       $this->snapshot = array();
25     }
26
27     function add_current_page() {
28       if (PHP_VERSION < 4.1) {
29         global $_SERVER;
30       }
31
32       global $request_type, $cPath;
33
34       if ($this->set_global) {
35         global $_GET, $_POST;
36       }
37
38       $set = 'true';
39       for ($i=0, $n=sizeof($this->path); $i<$n; $i++) {
40         if ($this->path[$i]['page'] == basename($_SERVER['PHP_SELF'])) {
41           if (isset($cPath)) {
42             if (!isset($this->path[$i]['get']['cPath'])) {
43               continue;
44             } else {
45               if ($this->path[$i]['get']['cPath'] == $cPath) {
46                 array_splice($this->path, ($i+1));
47                 $set = 'false';
48                 break;
49               } else {
50                 $old_cPath = explode('_', $this->path[$i]['get']['cPath']);
51                 $new_cPath = explode('_', $cPath);
52
53                 for ($j=0, $n2=sizeof($old_cPath); $j<$n2; $j++) {
54                   if ($old_cPath[$j] != $new_cPath[$j]) {
55                     array_splice($this->path, ($i));
56                     $set = 'true';
57                     break 2;
58                   }
59                 }
60               }
61             }
62           } else {
63             array_splice($this->path, $i);
64             $set = 'true';
65             break;
66           }
67         }
68       }
69
70       if ($set == 'true') {
71         $this->path[] = array('page' => basename($_SERVER['PHP_SELF']),
72                               'mode' => $request_type,
73                               'get' => $_GET,
74                               'post' => $_POST);
75       }
76     }
77
78     function remove_current_page() {
79       if (PHP_VERSION < 4.1) {
80         global $_SERVER;
81       }
82
83       $last_entry_position = sizeof($this->path) - 1;
84       if ($this->path[$last_entry_position]['page'] == basename($_SERVER['PHP_SELF'])) {
85         unset($this->path[$last_entry_position]);
86       }
87     }
88
89     function set_snapshot($page = '') {
90       if (PHP_VERSION < 4.1) {
91         global $_SERVER;
92       }
93
94       global $request_type;
95
96       if ($this->set_global) {
97         global $_GET, $_POST;
98       }
99
100       if (is_array($page)) {
101         $this->snapshot = array('page' => $page['page'],
102                                 'mode' => $page['mode'],
103                                 'get' => $page['get'],
104                                 'post' => $page['post']);
105       } else {
106         $this->snapshot = array('page' => basename($_SERVER['PHP_SELF']),
107                                 'mode' => $request_type,
108                                 'get' => $_GET,
109                                 'post' => $_POST);
110       }
111     }
112
113     function clear_snapshot() {
114       $this->snapshot = array();
115     }
116
117     function set_path_as_snapshot($history = 0) {
118       $pos = (sizeof($this->path)-1-$history);
119       $this->snapshot = array('page' => $this->path[$pos]['page'],
120                               'mode' => $this->path[$pos]['mode'],
121                               'get' => $this->path[$pos]['get'],
122                               'post' => $this->path[$pos]['post']);
123     }
124
125     function setGlobal() {
126       $this->set_global = (PHP_VERSION < 4.1) ? true : false;
127     }
128
129     function debug() {
130       global $osC_Session;
131
132       for ($i=0, $n=sizeof($this->path); $i<$n; $i++) {
133         echo $this->path[$i]['page'] . '?';
134         while (list($key, $value) = each($this->path[$i]['get'])) {
135           echo $key . '=' . $value . '&';
136         }
137         if (sizeof($this->path[$i]['post']) > 0) {
138           echo '<br>';
139           while (list($key, $value) = each($this->path[$i]['post'])) {
140             echo '&nbsp;&nbsp;<b>' . $key . '=' . $value . '</b><br>';
141           }
142         }
143         echo '<br>';
144       }
145
146       if (sizeof($this->snapshot) > 0) {
147         echo '<br><br>';
148
149         echo $this->snapshot['mode'] . ' ' . $this->snapshot['page'] . '?' . tep_array_to_string($this->snapshot['get'], array($osC_Session->name)) . '<br>';
150       }
151     }
152   }
153 ?>