Support Joomla!

Joomla! 1.5 Documentation

Packages

Package: Joomla-Framework

Developer Network License

The Joomla! Developer Network content is © copyright 2006 by the individual contributors and can be used in accordance with the Creative Commons License, Attribution- NonCommercial- ShareAlike 2.5
Source code for file /joomla/application/pathway.php

Documentation is available at pathway.php

  1. <?php
  2. /**
  3. @version        $Id: pathway.php 6472 2007-02-03 10:47:26Z pasamio $
  4. @package        Joomla.Framework
  5. @subpackage    Application
  6. @copyright    Copyright (C) 2005 - 2007 Open Source Matters. All rights reserved.
  7. @license        GNU/GPL, see LICENSE.php
  8. *  Joomla! is free software. This version may have been modified pursuant
  9. *  to the GNU General Public License, and as distributed it includes or
  10. *  is derivative of works licensed under the GNU General Public License or
  11. *  other free or open source software licenses.
  12. *  See COPYRIGHT.php for copyright notices and details.
  13. */
  14.  
  15. // Check to ensure this file is within the rest of the framework
  16. defined('JPATH_BASE'or die();
  17.  
  18. jimport('joomla.filter.output');
  19.  
  20. /**
  21.  * Class to maintain a pathway.
  22.  *
  23.  * Main example of use so far is the mod_breadcrumbs module that keeps track of
  24.  * the user's navigated path within the Joomla application.
  25.  *
  26.  * @author        Louis Landry <[email protected]>
  27.  * @package     Joomla.Framework
  28.  * @subpackage    Application
  29.  * @since        1.5
  30.  */
  31. class JPathWay extends JObject
  32. {
  33.  
  34.     /**
  35.      * Array to hold the pathway item objects
  36.      * @access private
  37.      */
  38.     var $_pathway null;
  39.  
  40.     /**
  41.      * Integer number of items in the pathway
  42.      * @access private
  43.      */
  44.     var $_count 0;
  45.  
  46.     /**
  47.      * Class constructor
  48.      */
  49.     function __construct({
  50.     }
  51.  
  52.     /**
  53.      * Return the JPathWay items array
  54.      *
  55.      * @access public
  56.      * @param boolean $showHome True to show the home element of the JPathWay array
  57.      * @param boolean $showComponent True to show the component element of the JPathWay array
  58.      * @return array Array of pathway items
  59.      * @since 1.5
  60.      */
  61.     function getPathWay($showHome true$showComponent true)
  62.     {
  63.         $pw $this->_pathway;
  64.  
  65.         if ($showComponent == false{
  66.             unset($pw[1]);
  67.         }
  68.         if ($showHome == false{
  69.             unset($pw[0]);
  70.         }
  71.  
  72.         // Use array_values to reset the array keys numerically
  73.         return array_values($pw);
  74.     }
  75.  
  76.     /**
  77.      * Create and return an array of the pathway names.
  78.      *
  79.      * @access public
  80.      * @param boolean $showHome True to show the home element of the JPathWay array
  81.      * @param boolean $showComponent True to show the component element of the JPathWay array
  82.      * @return array Array of names of pathway items
  83.      * @since 1.5
  84.      */
  85.     function getPathWayNames($showHome true$showComponent true)
  86.     {
  87.         // Initialize variables
  88.         $names array (null);
  89.  
  90.         // Build the names array using just the names of each pathway item
  91.         foreach ($this->_pathway as $item{
  92.             $names[$item->name;
  93.         }
  94.  
  95.         if ($showComponent == false{
  96.             unset($names[1]);
  97.         }
  98.         if ($showHome == false{
  99.             unset($names[0]);
  100.         }
  101.  
  102.         //Use array_values to reset the array keys numerically
  103.         return array_values($names);
  104.     }
  105.  
  106.     /**
  107.      * Create and add an item to the pathway.
  108.      *
  109.      * @access public
  110.      * @param string $name 
  111.      * @param string $link 
  112.      * @return boolean True on success
  113.      * @since 1.5
  114.      */
  115.     function addItem($name$link='')
  116.     {
  117.         // Initalize variables
  118.         $ret false;
  119.  
  120.         if ($this->_pathway[$this->_makeItem($name$link)) {
  121.             $ret true;
  122.             $this->_count++;
  123.         }
  124.  
  125.         return $ret;
  126.     }
  127.  
  128.     /**
  129.      * Set item name.
  130.      *
  131.      * @access public
  132.      * @param integer $id 
  133.      * @param string $name 
  134.      * @return boolean True on success
  135.      * @since 1.5
  136.      */
  137.     function setItemName($id$name)
  138.     {
  139.         // Initalize variables
  140.         $ret false;
  141.  
  142.         if (isset($this->_pathway[$id])) {
  143.             $this->_pathway[$id]->name $name;
  144.             $ret true;
  145.         }
  146.  
  147.         return $ret;
  148.     }
  149.  
  150.     /**
  151.      * Create and return a new pathway object.
  152.      *
  153.      * @access private
  154.      * @param string $name Name of the item
  155.      * @param string $link Link to the item
  156.      * @return object Pathway item object
  157.      * @since 1.5
  158.      */
  159.     function _makeItem($name$link)
  160.     {
  161.         $item new stdClass();
  162.         $item->name JOutputFilter::ampReplace(html_entity_decode($name));
  163.         $item->link $link;
  164.  
  165.         return $item;
  166.     }
  167. }
  168. ?>

Documentation generated on Mon, 05 Mar 2007 21:13:55 +0000 by phpDocumentor 1.3.1