Quick Search:

Mode

Context

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

Other Diffs

Ignore

Blank Lines Whitespace:

Diff

1497
 
1670
 
1670
 
breadcrumb.php
_> 11 <?php
  22 /*
<> 3 -  $Id: breadcrumb.php 1497 2007-03-29 13:40:05Z hpdl $
   3+  $Id: breadcrumb.php 1670 2007-07-20 21:11:18Z hpdl $
44 
  55   osCommerce, Open Source E-Commerce Solutions
  66   http://www.oscommerce.com
  77 
<> 8 -  Copyright (c) 2006 osCommerce
   8+  Copyright (c) 2007 osCommerce
99 
  1010   This program is free software; you can redistribute it and/or modify
  1111   it under the terms of the GNU General Public License v2 (1991)
  1212   as published by the Free Software Foundation.
  1313 */
  1414 
<> 15 -  class breadcrumb {
  16 -    var $_trail;
   15+/**
   16+ * The osC_Breadcrumb class handles the breadcrumb navigation path
   17+ */
1718 
<> 18 -    function breadcrumb() {
  19 -      $this->reset();
  20 -    }
   19+  class osC_Breadcrumb {
2120 
<> 22 -    function reset() {
  23 -      $this->_trail = array();
   21+/**
   22+ * An array containing the breadcrumb navigation path
   23+ *
   24+ * @var array
   25+ * @access private
   26+ */
   27+
   28+    private $_path = array();
   29+
   30+/**
   31+ * Resets the breadcrumb navigation path
   32+ *
   33+ * @access public
   34+ */
   35+
   36+    public function reset() {
   37+      $this->_path = array();
2438     }
  2539 
<> 26 -    function add($title, $link = '') {
  27 -      $this->_trail[] = array('title' => $title, 'link' => $link);
   40+/**
   41+ * Adds an entry to the breadcrumb navigation path
   42+ *
   43+ * @param string $title The title of the breadcrumb navigation entry
   44+ * @param string $link The link of the breadcrumb navigation entry
   45+ * @access public
   46+ */
   47+
   48+    public function add($title, $link = null) {
   49+      $this->_path[] = array('title' => $title,
   50+                             'link' => $link);
2851     }
  2952 
<> 30 -    function trail($separator = ' - ') {
   53+/**
   54+ * Returns the breadcrumb navigation path with the entries separated by $separator
   55+ *
   56+ * @param string $separator The string value to separate the breadcrumb navigation path entries with
   57+ * @access public
   58+ * @return string
   59+ */
   60+
   61+    public function getPath($separator = ' - ') {
3162       $trail_string = '';
  3263 
<> 33 -      for ($i=0, $n=sizeof($this->_trail); $i<$n; $i++) {
  34 -        if (isset($this->_trail[$i]['link']) && !empty($this->_trail[$i]['link'])) {
  35 -          $trail_string .= osc_link_object($this->_trail[$i]['link'], $this->_trail[$i]['title']);
   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']);
3672         } else {
<> 37 -          $trail_string .= $this->_trail[$i]['title'];
   73+          $trail_string .= $entry['title'];
3874         }
  3975 
<> 40 -        if (($i+1) < $n) $trail_string .= $separator;
   76+        if ( $counter < $trail_size ) {
   77+          $trail_string .= $separator;
   78+        }
4179       }
  4280 
  4381       return $trail_string;
  4482     }
<>  83+
   84+/**
   85+ * Returns the breadcrumb navigation path array
   86+ *
   87+ * @access public
   88+ * @return array
   89+ */
   90+
   91+    public function getArray() {
   92+      return $this->_path;
   93+    }
<_ 4594   }
  4695 ?>