HTML_Menu
[ class tree: HTML_Menu ] [ index: HTML_Menu ] [ all elements ]

Source for file SigmaRenderer.php

Documentation is available at SigmaRenderer.php

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

Documentation generated on Mon, 11 Mar 2019 10:16:40 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.