home *** CD-ROM | disk | FTP | other *** search
/ Cricao de Sites - 650 Layouts Prontos / WebMasters.iso / Servidores / xampp-win32-1.6.7-installer.exe / php / PEAR / HTML / Menu / SigmaRenderer.php < prev    next >
Encoding:
PHP Script  |  2008-07-02  |  4.7 KB  |  136 lines

  1. <?php
  2. /**
  3.  * The renderer that uses HTML_Template_Sigma instance for menu output.
  4.  * 
  5.  * PHP versions 4 and 5
  6.  *
  7.  * LICENSE: This source file is subject to version 3.01 of the PHP license
  8.  * that is available through the world-wide-web at the following URI:
  9.  * http://www.php.net/license/3_01.txt If you did not receive a copy of
  10.  * the PHP License and are unable to obtain it through the web, please
  11.  * send a note to license@php.net so we can mail you a copy immediately.
  12.  *
  13.  * @category    HTML
  14.  * @package     HTML_Menu
  15.  * @author      Alexey Borzov <avb@php.net>
  16.  * @copyright   2001-2007 The PHP Group
  17.  * @license     http://www.php.net/license/3_01.txt PHP License 3.01
  18.  * @version     CVS: $Id: SigmaRenderer.php,v 1.3 2007/05/18 20:54:33 avb Exp $
  19.  * @link        http://pear.php.net/package/HTML_Menu
  20.  */
  21.  
  22. /**
  23.  * Abstract base class for HTML_Menu renderers
  24.  */ 
  25. require_once 'HTML/Menu/Renderer.php';
  26.  
  27. /**
  28.  * The renderer that uses HTML_Template_Sigma instance for menu output.
  29.  *
  30.  * @category    HTML
  31.  * @package     HTML_Menu
  32.  * @author      Alexey Borzov <avb@php.net>
  33.  * @version     Release: 2.1.4
  34.  */
  35. class HTML_Menu_SigmaRenderer extends HTML_Menu_Renderer
  36. {
  37.    /**#@+
  38.     * @access private
  39.     */
  40.    /**
  41.     * Template object used for output
  42.     * @var HTML_Template_Sigma
  43.     */
  44.     var $_tpl;
  45.  
  46.    /**
  47.     * Mapping from HTML_MENU_ENTRY_* constants to template block names
  48.     * @var array
  49.     */
  50.     var $_typeNames = array(
  51.         HTML_MENU_ENTRY_INACTIVE    => 'inactive',
  52.         HTML_MENU_ENTRY_ACTIVE      => 'active',
  53.         HTML_MENU_ENTRY_ACTIVEPATH  => 'activepath',
  54.         HTML_MENU_ENTRY_PREVIOUS    => 'previous',
  55.         HTML_MENU_ENTRY_NEXT        => 'next',
  56.         HTML_MENU_ENTRY_UPPER       => 'upper',
  57.         HTML_MENU_ENTRY_BREADCRUMB  => 'breadcrumb'
  58.     );
  59.  
  60.    /**
  61.     * Prefix for template blocks and placeholders
  62.     * @var string
  63.     */
  64.     var $_prefix;
  65.     /**#@-*/
  66.  
  67.    /**
  68.     * Class constructor.
  69.     * 
  70.     * Sets the template object to use and sets prefix for template blocks
  71.     * and placeholders. We use prefix to avoid name collisions with existing 
  72.     * template blocks and it is customisable to allow output of several menus 
  73.     * into one template.
  74.     *
  75.     * @access public
  76.     * @param  HTML_Template_Sigma   template object to use for output
  77.     * @param  string                prefix for template blocks and placeholders
  78.     */
  79.     function HTML_Menu_SigmaRenderer(&$tpl, $prefix = 'mu_')
  80.     {
  81.         $this->_tpl    =& $tpl;
  82.         $this->_prefix =  $prefix;
  83.     }
  84.  
  85.     function finishMenu($level)
  86.     {
  87.         if ('rows' == $this->_menuType && $this->_tpl->blockExists($this->_prefix . ($level + 1) . '_menu_loop')) {
  88.             $this->_tpl->parse($this->_prefix . ($level + 1) . '_menu_loop');
  89.         } elseif ($this->_tpl->blockExists($this->_prefix . 'menu_loop')) {
  90.             $this->_tpl->parse($this->_prefix . 'menu_loop');
  91.         }
  92.     }
  93.     
  94.     function finishRow($level)
  95.     {
  96.         if ('rows' == $this->_menuType && $this->_tpl->blockExists($this->_prefix . ($level + 1) . '_row_loop')) {
  97.             $this->_tpl->parse($this->_prefix . ($level + 1) . '_row_loop');
  98.         } elseif ($this->_tpl->blockExists($this->_prefix . 'row_loop')) {
  99.             $this->_tpl->parse($this->_prefix . 'row_loop');
  100.         }
  101.     }
  102.  
  103.     function renderEntry($node, $level, $type)
  104.     {
  105.         if (in_array($this->_menuType, array('tree', 'sitemap', 'rows'))
  106.             && $this->_tpl->blockExists($this->_prefix . ($level + 1) . '_' . $this->_typeNames[$type])) {
  107.  
  108.             $blockName = $this->_prefix . ($level + 1) . '_' . $this->_typeNames[$type];
  109.         } else {
  110.             $blockName = $this->_prefix . $this->_typeNames[$type];
  111.         }
  112.         if (('tree' == $this->_menuType || 'sitemap' == $this->_menuType) &&
  113.              $this->_tpl->blockExists($blockName . '_indent')) {
  114.  
  115.             for ($i = 0; $i < $level; $i++) {
  116.                 $this->_tpl->touchBlock($blockName . '_indent');
  117.                 $this->_tpl->parse($blockName . '_indent');
  118.             }
  119.         }
  120.         foreach ($node as $k => $v) {
  121.             if ('sub' != $k && $this->_tpl->placeholderExists($this->_prefix . $k, $blockName)) {
  122.                 $this->_tpl->setVariable($this->_prefix . $k, $v);
  123.             }
  124.         }
  125.         $this->_tpl->parse($blockName);
  126.         if ('rows' == $this->_menuType 
  127.             && $this->_tpl->blockExists($this->_prefix . ($level + 1) . '_entry_loop')) {
  128.             
  129.             $this->_tpl->parse($this->_prefix . ($level + 1) . '_entry_loop');
  130.         } else {
  131.             $this->_tpl->parse($this->_prefix . 'entry_loop');
  132.         }
  133.     }
  134. }
  135. ?>
  136.