Quick Search:

View

Revision:

Diff

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