[ Index ]

PHP Cross Reference of Limb3

title

Body

[close]

/wact/src/widgets/ -> widgets.inc.php (source)

   1  <?php
   2  /*
   3   * Limb PHP Framework
   4   *
   5   * @link http://limb-project.com 
   6   * @copyright  Copyright &copy; 2004-2007 BIT(http://bit-creative.com)
   7   * @license    LGPL http://www.gnu.org/copyleft/lesser.html 
   8   */
   9  
  10  /**

  11  * Widgets are runtime components which have no compile time template tag.

  12  * They can be created and added by the PHP script controlling the template.

  13  */
  14  
  15  
  16  /**
  17   * Allows plain text to be added
  18   * Widgets are runtime components which have no compile time template tag.
  19   * They can be created and added by the PHP script controlling the template.
  20   * @package wact
  21   * @version $Id: widgets.inc.php 5945 2007-06-06 08:31:43Z pachanga $
  22   */
  23  class WactTextWidget extends WactRuntimeComponent
  24  {
  25    /**

  26    * Text to add

  27    * @var string

  28    */
  29    var $text;
  30  
  31    /**

  32    * Constructs TextComponent

  33    * @param string text to add

  34    */
  35    function __construct($text)
  36    {
  37      $this->text = $text;
  38    }
  39  
  40    /**

  41    * Override parent method to prevent use of children

  42    * @return void

  43    */
  44    function addChild()
  45    {
  46        // Should we kick an error message here?

  47    }
  48  
  49    /**

  50    * Outputs the text Widget.

  51    * @return void

  52    * @access public

  53    */
  54    function render()
  55    {
  56      echo ( htmlspecialchars($this->text, ENT_NOQUOTES) );
  57    }
  58  }
  59  
  60  /**
  61   * Allows a tag to be created, which cannot contain children e.g. img
  62   * @package wact
  63   * @version $Id: widgets.inc.php 5945 2007-06-06 08:31:43Z pachanga $
  64   */
  65  class WactTagWidget extends WactRuntimeTagComponent
  66  {
  67    /**

  68    * Name of the tag

  69    * @var string

  70    */
  71    var $tag;
  72  
  73    /**

  74    * Whether the tag is closing or not

  75    * @var boolean

  76    */
  77    var $closing = true;
  78  
  79    /**

  80    * Constructs TagWidget

  81    * @param string name of tag

  82    * @param boolean whether tag is closing

  83    */
  84    function __construct($tag,$closing=true)
  85    {
  86      $this->tag = htmlspecialchars($tag,ENT_QUOTES);
  87      $this->closing = $closing;
  88    }
  89  
  90    /**

  91    * Override parent method to prevent use of children

  92    * @return void

  93    * @access public

  94    */
  95    function addChild()
  96    {
  97      // Should we kick an error message here?

  98    }
  99  
 100    /**

 101    * Outputs the tag

 102    * @return void

 103    * @access public

 104    */
 105    function render()
 106    {
 107      echo ( '<'.$this->tag );
 108      echo ( $this->renderAttributes());
 109      if ( $this->closing )
 110        echo ( '/>' );
 111      else
 112        echo ( '>' );
 113    }
 114  }
 115  
 116  /**
 117   * Allows a tag to be created, which can contain children
 118   * @package wact
 119   * @version $Id: widgets.inc.php 5945 2007-06-06 08:31:43Z pachanga $
 120   */
 121  class WactTagContainerWidget extends WactRuntimeTagComponent
 122  {
 123    /**

 124    * Name of the tag

 125    * @var string

 126    */
 127    var $tag;
 128  
 129    /**

 130    * Constructs TagContainerWidget

 131    * @param string name of tag

 132    * @param boolean whether tag is closing

 133    */
 134    function __construct($tag)
 135    {
 136      $this->tag = htmlspecialchars($tag, ENT_QUOTES);
 137    }
 138  
 139    /**

 140    * Outputs the tag, rendering any child components as well

 141    * @return void

 142    */
 143    function render()
 144    {
 145      echo ( '<'.$this->tag );
 146      echo ( $this->renderAttributes().'>');
 147      parent :: render();
 148      echo ( '</'.$this->tag.'>' );
 149    }
 150  }
 151  ?>


Generated: Mon Dec 1 03:56:46 2008 Cross-referenced by PHPXref 0.7