Source for file sidebar.php

Documentation is available at sidebar.php

  1. <?php
  2. /**
  3.  * @package     Joomla.Libraries
  4.  * @subpackage  HTML
  5.  *
  6.  * @copyright   Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
  7.  * @license     GNU General Public License version 2 or later; see LICENSE
  8.  */
  9.  
  10. defined('JPATH_BASE'or die;
  11.  
  12. /**
  13.  * Utility class to render a list view sidebar
  14.  *
  15.  * @package     Joomla.Libraries
  16.  * @subpackage  HTML
  17.  * @since       3.0
  18.  */
  19. abstract class JHtmlSidebar
  20. {
  21.     /**
  22.      * Menu entries
  23.      *
  24.      * @var    array 
  25.      * @since  3.0
  26.      */
  27.     protected static $entries array();
  28.  
  29.     /**
  30.      * Filters
  31.      *
  32.      * @var    array 
  33.      * @since  3.0
  34.      */
  35.     protected static $filters array();
  36.  
  37.     /**
  38.      * Value for the action attribute of the form.
  39.      *
  40.      * @var    string 
  41.      * @since  3.0
  42.      */
  43.     protected static $action '';
  44.  
  45.     /**
  46.      * Render the sidebar.
  47.      *
  48.      * @return  string  The necessary HTML to display the sidebar
  49.      *
  50.      * @since   3.0
  51.      */
  52.     public static function render()
  53.     {
  54.         // Collect display data
  55.         $data                 new stdClass;
  56.         $data->list           static::getEntries();
  57.         $data->filters        static::getFilters();
  58.         $data->action         static::getAction();
  59.         $data->displayMenu    count($data->list);
  60.         $data->displayFilters count($data->filters);
  61.         $data->hide           JFactory::getApplication()->input->getBool('hidemainmenu');
  62.  
  63.         // Create a layout object and ask it to render the sidebar
  64.         $layout      new JLayoutFile('joomla.sidebars.submenu');
  65.         $sidebarHtml $layout->render($data);
  66.  
  67.         return $sidebarHtml;
  68.     }
  69.  
  70.     /**
  71.      * Method to add a menu item to submenu.
  72.      *
  73.      * @param   string  $name    Name of the menu item.
  74.      * @param   string  $link    URL of the menu item.
  75.      * @param   bool    $active  True if the item is active, false otherwise.
  76.      *
  77.      * @return  void 
  78.      *
  79.      * @since   3.0
  80.      */
  81.     public static function addEntry($name$link ''$active false)
  82.     {
  83.         array_push(static::$entriesarray($name$link$active));
  84.     }
  85.  
  86.     /**
  87.      * Returns an array of all submenu entries
  88.      *
  89.      * @return  array 
  90.      *
  91.      * @since   3.0
  92.      */
  93.     public static function getEntries()
  94.     {
  95.         return static::$entries;
  96.     }
  97.  
  98.     /**
  99.      * Method to add a filter to the submenu
  100.      *
  101.      * @param   string  $label      Label for the menu item.
  102.      * @param   string  $name       Name for the filter. Also used as id.
  103.      * @param   string  $options    Options for the select field.
  104.      * @param   bool    $noDefault  Don't the label as the empty option
  105.      *
  106.      * @return  void 
  107.      *
  108.      * @since   3.0
  109.      */
  110.     public static function addFilter($label$name$options$noDefault false)
  111.     {
  112.         array_push(static::$filtersarray('label' => $label'name' => $name'options' => $options'noDefault' => $noDefault));
  113.     }
  114.  
  115.     /**
  116.      * Returns an array of all filters
  117.      *
  118.      * @return  array 
  119.      *
  120.      * @since   3.0
  121.      */
  122.     public static function getFilters()
  123.     {
  124.         return static::$filters;
  125.     }
  126.  
  127.     /**
  128.      * Set value for the action attribute of the filter form
  129.      *
  130.      * @param   string  $action  Value for the action attribute of the form
  131.      *
  132.      * @return  void 
  133.      *
  134.      * @since   3.0
  135.      */
  136.     public static function setAction($action)
  137.     {
  138.         static::$action $action;
  139.     }
  140.  
  141.     /**
  142. /**
  143.      * Get value for the action attribute of the filter form
  144.      *
  145.      * @return  string 
  146.      *
  147.      * @since   3.0
  148.      */
  149.     public static function getAction()
  150.     {
  151.         return static::$action;
  152.     }
  153. }

Documentation generated on Tue, 19 Nov 2013 15:12:59 +0100 by phpDocumentor 1.4.3