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

Source for file HTMLLabel.class.php

Documentation is available at HTMLLabel.class.php

  1. <?php
  2. /**
  3.  * Note: If you include a html form, you don't need to include any form item
  4.  * classes! They will be all included.
  5.  *
  6.  * For including this file you have to define the constant "CLASSPATH".
  7.  * Because every include in the framework depends on the CLASSPATH definition.
  8.  * The CLASSPATH means the relative path to the folder that contains the
  9.  * framework GilliGan.
  10.  *
  11.  * @package forms
  12.  */
  13. if !defined"CLASSPATH" ) )
  14. {
  15.    echo "<h3>You have to define the constant CLASSPATH!</h3>\n";
  16.    echo "Example: define( 'CLASSPATH', '../path/to/classes/' );\n";
  17.    exit();
  18. }
  19.  
  20. /**
  21.  * Including the basic class for html-tags.
  22.  */
  23. require_onceCLASSPATH."html/ABSTHTMLTag.class.php" );
  24.  
  25. /**
  26.  * Creating HTML-Label-Tags
  27.  *
  28.  * @package    forms
  29.  * @version    0.1.2
  30.  * @since      0.9.1.5
  31.  * @author     Daniel Plücken <daniel@debakel.net>
  32.  * @license    http://www.gnu.org/copyleft/lesser.html
  33.  *              GNU Lesser General Public License
  34.  * @copyright  Copyright (C) 2006 Daniel Plücken <daniel@debakel.net>
  35.  *
  36.  *  This library is free software; you can redistribute it and/or
  37.  *  modify it under the terms of the GNU Lesser General Public
  38.  *  License as published by the Free Software Foundation; either
  39.  *  version 2.1 of the License.
  40.  *
  41.  *  This library is distributed in the hope that it will be useful,
  42.  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  43.  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  44.  *  GNU Lesser General Public License for more details.
  45.  *
  46.  *  You should have received a copy of the GNU Lesser General
  47.  *  Public License along with this library; if not, write to the
  48.  *  Free Software Foundation, Inc., 59 Temple Place, Suite 330,
  49.  *  Boston, MA 02111-1307 USA
  50.  */
  51. class HTMLLabel extends ABSTHTMLTag
  52. {
  53.   /**
  54.    * Reference back to the form item this label stnds for.
  55.    *
  56.    * @access private
  57.    * @var    ABSTHTMLFormItem $form_item_obj 
  58.    */
  59.   var $form_item_obj = null;
  60.   /**
  61.    * The content of this label.
  62.    *
  63.    * @access public
  64.    * @var    string $str_body 
  65.    */
  66.   var $str_body = "";
  67.  
  68.  
  69.  
  70.   /**
  71.    * Constructor
  72.    *
  73.    * @version 1.0
  74.    * @since   0.1.0
  75.    * @author  Daniel Plücken <daniel@debakel.net>
  76.    * @access  public
  77.    * @param   string           $str_body 
  78.    * @param   string           $str_style_class 
  79.    * @return  HTMLLabel 
  80.    */
  81.   function HTMLLabel$str_body$str_style_class "" )
  82.   {
  83.     $this->str_body = $str_body;
  84.  
  85.     if !empty$str_style_class ) )
  86.        $this->setStyle$str_style_class );
  87.   }
  88.  
  89.  
  90.  
  91.   /**
  92.    * Sets the body of this HTML-Object.
  93.    *
  94.    * @version 1.0
  95.    * @since   0.1.2
  96.    * @author  Daniel Plücken <daniel@debakel.net>
  97.    * @access  public
  98.    *
  99.    * @return  void 
  100.    */
  101.   function setBody$string )
  102.   $thi->str_body $string}
  103.  
  104.  
  105.  
  106.   /**
  107.    * Adds this label to a specified form item.
  108.    *
  109.    * @version 1.0
  110.    * @since   0.1.0
  111.    * @author  Daniel Plücken <daniel@debakel.net>
  112.    * @access  public
  113.    * @param   ABSTHTMLFormItem $form_item_obj 
  114.    * @return  void 
  115.    */
  116.   function addToFormItem&$form_item_obj )
  117.   {
  118.     if (
  119.          !function_exists"is_a" )
  120.       && (
  121.            get_class$form_item_obj == "absthtmlformitem"
  122.         || get_parent_class$form_item_obj == "absthtmlformitem"
  123.          )
  124.        )
  125.     {
  126.        $form_item_obj->label_obj =$this;
  127.        $this->form_item_obj =$form_item_obj;
  128.     }
  129.     else
  130.     if (
  131.          function_exists"is_a" )
  132.       && (
  133.            is_a$form_item_obj"ABSTHTMLFormItem" )
  134.         || is_subclass_of$form_item_obj"absthtmlformitem" )
  135.          )
  136.        )
  137.      {
  138.        $form_item_obj->label_obj =$this;
  139.        $this->form_item_obj =$form_item_obj;
  140.      }
  141.   }
  142.  
  143.  
  144.  
  145.   /**
  146.    * Returns a generated string based on the Attributes of this HTML-Object.
  147.    *
  148.    * @version 1.1
  149.    * @since   0.1.0
  150.    * @author  Daniel Plücken <daniel@debakel.net>
  151.    * @access  public
  152.    * @return  string 
  153.    */
  154.   function get()
  155.   {
  156.     return "<!--\r\n\r\n-->"
  157.           ."<label\r\n".(
  158.                       is_object$this->form_item_obj )
  159.                       ? "          for=\"".$this->form_item_obj->id."\"\r\n"
  160.                       : ""
  161.                            )
  162.                           .(
  163.                       !empty$this->id )
  164.                       ? "          id=\"".$this->id."\"\r\n"
  165.                       : ""
  166.                            )
  167.                           .(
  168.                       !empty$this->name )
  169.                       ? "          name=\"".$this->name."\"\r\n"
  170.                       : ""
  171.                            )
  172.                           .(
  173.                       !empty$this->style_class )
  174.                       ? "          class=\"".$this->style_class."\"\r\n"
  175.                       : ""
  176.                            )
  177.                           .(
  178.                       !empty$this->freestyle )
  179.                       ? "          style=\"".$this->freestyle."\"\r\n"
  180.                       : ""
  181.                         )."   ><!--\r\n-->"
  182.            .$this->str_body."<!--\r\n--></label>";
  183.   }
  184. // End of class HTMLLabel
  185. ?>

Documentation generated on Thu, 05 Jun 2008 19:12:31 +0200 by phpDocumentor 1.4.1