[ Index ]

PHP Cross Reference of osCMax 2.0.4

title

Body

[close]

/includes/classes/ -> navigation_history.php (source)

   1  <?php
   2  /*

   3  $Id: navigation_history.php 3 2006-05-27 04:59:07Z user $

   4  

   5    osCMax Power E-Commerce

   6    http://oscdox.com

   7  

   8    Copyright 2006 osCMax

   9  

  10    Released under the GNU General Public License

  11  */
  12  
  13    class navigationHistory {
  14      var $path, $snapshot;
  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 $PHP_SELF, $HTTP_GET_VARS, $HTTP_POST_VARS, $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($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($PHP_SELF),
  62                                'mode' => $request_type,
  63                                'get' => $this->filter_parameters($HTTP_GET_VARS),
  64                                'post' => $this->filter_parameters($HTTP_POST_VARS));
  65        }
  66      }
  67  
  68      function remove_current_page() {
  69        global $PHP_SELF;
  70  
  71        $last_entry_position = sizeof($this->path) - 1;
  72        if ($this->path[$last_entry_position]['page'] == basename($PHP_SELF)) {
  73          unset($this->path[$last_entry_position]);
  74        }
  75      }
  76  
  77      function set_snapshot($page = '') {
  78        global $PHP_SELF, $HTTP_GET_VARS, $HTTP_POST_VARS, $request_type;
  79  
  80        if (is_array($page)) {
  81          $this->snapshot = array('page' => $page['page'],
  82                                  'mode' => $page['mode'],
  83                                  'get' => $this->filter_parameters($page['get']),
  84                                  'post' => $this->filter_parameters($page['post']));
  85        } else {
  86          $this->snapshot = array('page' => basename($PHP_SELF),
  87                                  'mode' => $request_type,
  88                                  'get' => $this->filter_parameters($HTTP_GET_VARS),
  89                                  'post' => $this->filter_parameters($HTTP_POST_VARS));
  90        }
  91      }
  92  
  93      function clear_snapshot() {
  94        $this->snapshot = array();
  95      }
  96  
  97      function set_path_as_snapshot($history = 0) {
  98        $pos = (sizeof($this->path)-1-$history);
  99        $this->snapshot = array('page' => $this->path[$pos]['page'],
 100                                'mode' => $this->path[$pos]['mode'],
 101                                'get' => $this->path[$pos]['get'],
 102                                'post' => $this->path[$pos]['post']);
 103      }
 104  
 105      function debug() {
 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(tep_session_name())) . '<br>';
 124        }
 125      }
 126  
 127      function filter_parameters($parameters) {
 128        $clean = array();
 129  
 130        if (is_array($parameters)) {
 131          reset($parameters);
 132          while (list($key, $value) = each($parameters)) {
 133            if (strpos($key, '_nh-dns') < 1) {
 134              $clean[$key] = $value;
 135            }
 136          }
 137        }
 138  
 139        return $clean;
 140      }
 141  
 142      function unserialize($broken) {
 143        for(reset($broken);$kv=each($broken);) {
 144          $key=$kv['key'];
 145          if (gettype($this->$key)!="user function")
 146          $this->$key=$kv['value'];
 147        }
 148      }
 149    }
 150  ?>


Generated: Fri Jan 1 13:43:16 2010 Cross-referenced by PHPXref 0.7