Quick Search:

Mode

Context

Displaying 3 lines of context. None | Less | More | Full

Other Diffs

Ignore

Blank Lines Whitespace:

Diff

1860
 
1861
 
1861
 
breadcrumb.php
_> 11 <?php
  22 /*
<> 3 -  $Id: breadcrumb.php 1860 2009-03-06 23:25:01Z hpdl $
   3+  $Id: breadcrumb.php 1861 2009-03-06 23:26:28Z hpdl $
44 
  55   osCommerce, Open Source E-Commerce Solutions
  66   http://www.oscommerce.com
     
 !
1616  * The osC_Breadcrumb class handles the breadcrumb navigation path
  1717  */
  1818 
<> 19 -  class osC_Breadcrumb {
   19+  class osC_Breadcrumb implements iterator {
2020 
  2121 /**
  2222  * An array containing the breadcrumb navigation path
     
 !
2828     private $_path = array();
  2929 
  3030 /**
<>  31+ * The string to separate the breadcrumb entries with
   32+ *
   33+ * @var string
   34+ * @access private
   35+ */
   36+
   37+    private $_separator = ' &raquo; ';
   38+
   39+/**
3140  * Resets the breadcrumb navigation path
  3241  *
  3342  * @access public
     
 !
4655  */
  4756 
  4857     public function add($title, $link = null) {
<> 49 -      $this->_path[] = array('title' => $title,
  50 -                             'link' => $link);
   58+      if ( !empty($link) ) {
   59+        $title = osc_link_object($link, $title);
   60+      }
   61+
   62+      $this->_path[] = $title;
5163     }
  5264 
  5365 /**
     
 !
5870  * @return string
  5971  */
  6072 
<> 61 -    public function getPath($separator = ' - ') {
  62 -      $trail_string = '';
  63 -
  64 -      $trail_size = sizeof($this->_path);
  65 -      $counter = 0;
  66 -
  67 -      foreach ( $this->_path as $entry ) {
  68 -        $counter++;
  69 -
  70 -        if ( !empty($entry['link']) ) {
  71 -          $trail_string .= osc_link_object($entry['link'], $entry['title']);
  72 -        } else {
  73 -          $trail_string .= $entry['title'];
  74 -        }
  75 -
  76 -        if ( $counter < $trail_size ) {
  77 -          $trail_string .= $separator;
  78 -        }
   73+    public function getPath($separator = null) {
   74+      if ( is_null($separator) ) {
   75+        $separator = $this->_separator;
7976       }
  8077 
<> 81 -      return $trail_string;
   78+      return implode($separator, $this->_path);
8279     }
  8380 
  8481 /**
     
 !
9188     public function getArray() {
  9289       return $this->_path;
  9390     }
<>  91+
   92+/**
   93+ * Returns the breadcrumb separator
   94+ *
   95+ * @access public
   96+ * @return string
   97+ */
   98+
   99+    public function getSeparator() {
   100+      return $this->_separator;
   101+    }
   102+
   103+/**
   104+ * Sets the breadcrumb string separator
   105+ *
   106+ * @param string $separator The string to separator breadcrumb entries with
   107+ * @access public
   108+ * @return string
   109+ */
   110+
   111+    public function setSeparator($separator) {
   112+      $this->_separator = $separator;
   113+    }
   114+
   115+/**
   116+ * Overloaded rewind iterator function
   117+ *
   118+ * @access public
   119+ */
   120+
   121+    public function rewind() {
   122+      return reset($this->_path);
   123+    }
   124+
   125+/**
   126+ * Overloaded current iterator function
   127+ *
   128+ * @access public
   129+ */
   130+
   131+    public function current() {
   132+      return current($this->_path);
   133+    }
   134+
   135+/**
   136+ * Overloaded key iterator function
   137+ *
   138+ * @access public
   139+ */
   140+
   141+    public function key() {
   142+      return key($this->_path);
   143+    }
   144+
   145+/**
   146+ * Overloaded next iterator function
   147+ *
   148+ * @access public
   149+ */
   150+
   151+    public function next() {
   152+      return next($this->_path);
   153+    }
   154+
   155+/**
   156+ * Overloaded valid iterator function
   157+ *
   158+ * @access public
   159+ */
   160+
   161+    public function valid() {
   162+      return ( current($this->_path) !== false );
   163+    }
<_ 94164   }
  95165 ?>