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

Source for file Item.php

Documentation is available at Item.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 Form
  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: Item.php 27 2007-07-19 18:47:54Z lfrost $
  25.  */
  26.  
  27. /**
  28.  * Required classes.
  29.  *
  30.  * @ignore
  31.  */
  32. Zend_Loader::loadClass('Cnz_Html_Element');
  33.  
  34. /**
  35.  * HTML Form Item class
  36.  *
  37.  * Abstract base class for form elements.
  38.  *
  39.  * @category   Cnz
  40.  * @package    Cnz_Html
  41.  * @subpackage Form
  42.  */
  43. abstract class Cnz_Html_Form_Item extends Cnz_Html_Element
  44. {
  45.     /**#@+ @var string */
  46.     protected $label    = NULL;
  47.     protected $initial    = NULL;
  48.     /**#@-*/
  49.  
  50.     /* Getters/Setters ===================================================*/
  51.  
  52.     /** @return string Label */
  53.     public function getLabel()
  54.     {
  55.         return $this->label;
  56.     }
  57.  
  58.     /* Methods ===========================================================*/
  59.  
  60.     /**
  61.      * Option fields:
  62.      *   initial  Initial value for this field
  63.      *
  64.      * Configuration fields:
  65.      *   label    Label for this field
  66.      *   initial  Initial value for this field
  67.      *
  68.      * @param  array       $options Options
  69.      * @param  Zend_Config $config  Configuration
  70.      */
  71.     public function __construct(array $options array()Zend_Config $config NULL)
  72.     {
  73.         parent::__construct($options);
  74.         if (isset($config->label)) $this->label = $config->label;
  75.         if (isset($config->initial)) $this->initial = $config->initial;
  76.         if (isset($options['initial'])) $this->initial = $options['initial'];
  77.         return;
  78.     }
  79.  
  80.     /**
  81.      * This function returns a string formatted for display or submission by
  82.      * mail.
  83.      *
  84.      * @param  array  $data Form data
  85.      * @return string 
  86.      */
  87.     public function submitString(array $data NULL)
  88.     {
  89.         return sprintf('%-24s : %s'$this->labelisset($data[$this->name]htmlentities($data[$this->name]''"\n";
  90.     }
  91. }

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