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

Source for file Template.php

Documentation is available at Template.php

  1. <?php
  2. /**
  3.  * CNZ Framework
  4.  *
  5.  * A Framework for Creating and Using Complex Web Elements
  6.  *
  7.  * The purpose of this framework is to provide a library of high-level objects
  8.  * to facilitate common HTML coding tasks, such as menus, tables, and forms.
  9.  * The intent is to reduce repetitive HTML coding as much as possible, replacing
  10.  * it with a combination of configuration files and style sheets with
  11.  * standardized naming conventions.
  12.  *
  13.  * This framework is built on and requires the
  14.  * {@link http://framework.zend.com/ Zend Framework}.
  15.  *
  16.  * @category   Cnz
  17.  * @package    Cnz_Html
  18.  * @subpackage Template
  19.  *
  20.  * @author    Lyle Frost <lfrost@cnz.com>
  21.  * @copyright Copyright (c) 2006-2007 Citadel Network <{@link http://www.citadelnetwork.com/}>
  22.  * @filesource
  23.  * @license   http://www.citadelnetwork.com/license/cnzframework New BSD License
  24.  * @version   $Id: Template.php 27 2007-07-19 18:47:54Z lfrost $
  25.  */
  26.  
  27. /**
  28.  * Required classes.
  29.  *
  30.  * @ignore
  31.  */
  32. Zend_Loader::loadClass('Zend_Config');
  33. Zend_Loader::loadClass('Zend_Config_Ini');
  34. Zend_Loader::loadClass('Cnz_Html_Element');
  35.  
  36. /**
  37.  * HTML Template class
  38.  *
  39.  * This is a template for creating new CNZ Framework classes.
  40.  *
  41.  * Example INI (defaults shown as comments):
  42.  *
  43.  * <pre><samp>
  44.  * [HtmlTemplate]
  45.  * foo     = "This is a template."
  46.  * fooFlag = on
  47.  * fooList = abc,def
  48.  * </samp></pre>
  49.  *
  50.  * @category   Cnz
  51.  * @package    Cnz_Html
  52.  * @subpackage Template
  53.  */
  54. {
  55.     const    HAS_CONFIG    = true;
  56.  
  57.     /**#@+ @var array */
  58.     private $fooArray    NULL;
  59.     /**#@-*/
  60.  
  61.     /**#@+ @var boolean */
  62.     private $fooFlag    NULL;
  63.     /**#@-*/
  64.  
  65.     /**#@+ @var string */
  66.     private    $foo        NULL;
  67.     /**#@-*/
  68.  
  69.     /* Getters/Setters ===================================================*/
  70.  
  71.     /** @return string Foo */
  72.     public function getFoo()
  73.     {
  74.         return $this->foo;
  75.     }
  76.  
  77.     /**
  78.      * @param string New foo
  79.      * @return void 
  80.      */
  81.     public function setFoo($foo)
  82.     {
  83.         $this->foo $foo;
  84.         return;
  85.     }
  86.  
  87.     /* Methods ===========================================================*/
  88.  
  89.     /**
  90.      * Option fields:
  91.       *   foo
  92.      *
  93.      * Configuration fields:
  94.       *   foo
  95.       *   fooFlag
  96.       *   fooList
  97.      *
  98.      * @param  array $options Options
  99.      */
  100.     public function __construct(array $options array())
  101.     {
  102.         parent::__construct($options);
  103.  
  104.         // Process options.
  105.         if (isset($options['foo'])) $this->foo $options['foo'];
  106.         elseif (isset($this->config->foo)) $this->foo $this->config->foo;
  107.  
  108.         // Process configuration.
  109.         if (isset($this->config->fooFlag)) $this->fooFlag Cnz_Html::configFlag($this->config->fooFlag);
  110.         if (isset($this->config->fooList)) $this->fooArray Cnz_Html::listToArray($this->config->fooList);
  111.  
  112.         return;
  113.     }
  114.  
  115.     /**
  116.      * @param  string $style Value for outermost style attribute
  117.      * @return void 
  118.      */
  119.     public function display($style NULL)
  120.     {
  121.         $is Cnz_Html::getIndentString();
  122.         $indent Cnz_Html::indentGenerate();
  123.  
  124.         // REPLACE <div> WITH APPROPRIATE CONTAINER TAG
  125.         echo $indent'<div class = "'$this->genStyles()'"';
  126.         if (!empty($style)) echo ' style = "'$style'"';
  127.         echo '>'"\n";
  128.         Cnz_Html::indentInc();
  129.         $indent Cnz_Html::indentGenerate();
  130.  
  131.         // INSERT DISPLAY CODE HERE
  132.         echo '<p class = "'$this->genStyles()'">'$foo'</p>'"\n";
  133.  
  134.         Cnz_Html::indentDec();
  135.         $indent Cnz_Html::indentGenerate();
  136.         echo $indent'</div>'"\n";
  137.  
  138.         return;
  139.     }
  140. }

Documentation generated on Thu, 19 Jul 2007 15:02:17 -0400 by phpDocumentor 1.4.0RC2