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

Source for file HTMLRadioButton.class.php

Documentation is available at HTMLRadioButton.class.php

  1. <?php
  2. /**
  3.  * For including this file you have to define the constant "CLASSPATH".
  4.  * Because every include in the framework depends on the CLASSPATH definition.
  5.  * The CLASSPATH means the relative path to the folder that contains the
  6.  * framework GilliGan.
  7.  *
  8.  * @package forms
  9.  * @subpackage items
  10.  */
  11. if !defined"CLASSPATH" ) )
  12. {
  13.     echo "<h3>You have to define the constant CLASSPATH!</h3>\n";
  14.     echo "Example: define( 'CLASSPATH', '../path/to/classes/' );\n";
  15.     exit();
  16. }
  17.  
  18. /**
  19.  *
  20.  */
  21. require_onceCLASSPATH."forms/items/ABSTHTMLFormItem.class.php" );
  22.  
  23. /**
  24.  * Loading the javascript class for form features.
  25.  */
  26. include_once CLASSPATH."html/JavaScript.class.php";
  27.  
  28. /**
  29.  * Loading the javascript class for form features.
  30.  */
  31. include_once CLASSPATH."forms/HTMLLabel.class.php";
  32.  
  33. /**
  34.  * A class to generate checkboxes.
  35.  *
  36.  * @package    forms
  37.  * @subpackage items
  38.  * @version    0.1.0
  39.  * @author     Daniel Plücken <daniel@debakel.net>
  40.  * @license    http://www.gnu.org/copyleft/lesser.html
  41.  *              GNU Lesser General Public License
  42.  * @copyright  Copyright (C) 2007 Daniel Plücken <daniel@debakel.net>
  43.  *
  44.  *  This library is free software; you can redistribute it and/or
  45.  *  modify it under the terms of the GNU Lesser General Public
  46.  *  License as published by the Free Software Foundation; either
  47.  *  version 2.1 of the License.
  48.  *
  49.  *  This library is distributed in the hope that it will be useful,
  50.  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  51.  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  52.  *  GNU Lesser General Public License for more details.
  53.  *
  54.  *  You should have received a copy of the GNU Lesser General
  55.  *  Public License along with this library; if not, write to the
  56.  *  Free Software Foundation, Inc., 59 Temple Place, Suite 330,
  57.  *  Boston, MA 02111-1307 USA
  58.  */
  59. {
  60.     /**
  61.      * @var    integer $value 
  62.      * @access public
  63.      */
  64.     var $value = 1;
  65.     /**
  66.      * @var    boolean $checked 
  67.      * @access public
  68.      */
  69.     var $checked = false;
  70.  
  71.  
  72.  
  73.    /**
  74.     * Constructor
  75.     *
  76.     * @version 1.0
  77.     * @since   0.1.0
  78.     * @author  Daniel Plücken <daniel@debakel.net>
  79.     * @access  public
  80.     * @param   string  $name 
  81.     * @param   string  $checked 
  82.     * @param   string  $label 
  83.     * @return  HTMLCheckBox 
  84.     */
  85.    function HTMLRadioButton(
  86.                               $name,
  87.                               $checked false,
  88.                               $label   ""
  89.                            )
  90.    {
  91.         $this->name    = $name;
  92.         $this->id      = $name;
  93.         $this->checked = is_bool$checked )
  94.                          ? $checked
  95.                          : !empty$checked )
  96.                            ? true
  97.                            : false;
  98.  
  99.         if !empty$label ) )
  100.         {
  101.             $this->label_obj = new HTMLLabel$label );
  102.             $this->label_obj->form_item_obj =$this;
  103.         }
  104.    }
  105.  
  106.  
  107.  
  108.    /**
  109.     * Sets this radio button checked.
  110.     *
  111.     * @version 1.0
  112.     * @since   0.1.0
  113.     * @author  Daniel Plücken <daniel@debakel.net>
  114.     * @access  public
  115.     * @param   boolean $boolean 
  116.     * @return  string 
  117.     */
  118.    function setChecked$boolean true )
  119.    $this->checked = !empty$boolean true false}
  120.  
  121.  
  122.  
  123.    /**
  124.     * Sets the label of this checkbox.
  125.     *
  126.     * @version 1.0
  127.     * @since   0.1.0
  128.     * @author  Daniel Plücken <daniel@debakel.net>
  129.     * @access  public
  130.     * @param   mixed  $mixed 
  131.     * @return  string 
  132.     */
  133.    function setLabel$mixed )
  134.    {
  135.      if is_object$mixed ) )
  136.         $this->label_obj = $mixed;
  137.      else
  138.      {
  139.         if is_object$this->label_obj ) )
  140.            $this->label_obj->setBody$mixed );
  141.         else
  142.         {
  143.            $this->label_obj = new HTMLLabel$mixed );
  144.            $this->label_obj->form_item_obj =$this;
  145.         }
  146.      }
  147.    }
  148.  
  149.  
  150.  
  151.    /**
  152.     * Returns an if-order of a javascript to check whether this item is NOT
  153.     * filled
  154.     *
  155.     * @version 1.0
  156.     * @since   0.1.0
  157.     * @author  Daniel Plücken <daniel@debakel.net>
  158.     * @access  public
  159.     * @return  string 
  160.     */
  161.    function getChangeOrder()
  162.    return $this->mouseup}
  163.  
  164.  
  165.  
  166.    /**
  167.     * Returns an if-order of a javascript to check whether this item is NOT
  168.     * filled
  169.     *
  170.     * @version 1.0
  171.     * @since   0.1.0
  172.     * @author  Daniel Plücken <daniel@debakel.net>
  173.     * @access  public
  174.     * @return  string 
  175.     */
  176.    function getCheckOrder()
  177.    {
  178.       $out "document.".$this->parentform->name
  179.                     .".".$this->name.".checked != true";
  180.  
  181.       return $out;
  182.    }
  183.  
  184.  
  185.  
  186.    /**
  187.     * Returns if the checkbox is declared is checked.
  188.     *
  189.     * @version 1.0
  190.     * @since   0.1.0
  191.     * @author  Daniel Plücken <daniel@debakel.net>
  192.     * @access  public
  193.     * @return  boolean 
  194.     */
  195.    function getChecked()
  196.    return $this->checked}
  197.  
  198.  
  199.  
  200.    /**
  201.     * Sets the mouseUp-Attribute of the radio button.
  202.     *
  203.     * @version 1.0
  204.     * @since   0.1.0
  205.     * @author  Daniel Plücken <daniel@debakel.net>
  206.     * @access  public
  207.     * @param   string $formname 
  208.     * @return  string 
  209.     */
  210.    function setChangeOrder$string )
  211.    $this->mouseup = $string}
  212.  
  213.  
  214.  
  215.    /**
  216.     * Returns a generated string based on the attributes of this object.
  217.     *
  218.     * @version 1.0
  219.     * @since   0.1.0
  220.     * @author  Daniel Plücken <daniel@debakel.net>
  221.     * @access  public
  222.     * @return  string 
  223.     */
  224.    function get$forminput "" )
  225.    {
  226.       $this->idExists$this->idtrue );
  227.  
  228.       $out  "<!--\r\n"
  229.              ."--><input type=\"radio\"\r\n"
  230.              ."          name=\"".$this->name."\"\r\n"
  231.              ."          id=\"".$this->id."\"\r\n"
  232.              ."          value=\"".$this->value."\"\r\n";
  233.  
  234.       $out .= !empty$this->style_class )
  235.               ? "          class=\"".$this->style_class."\"\r\n"
  236.               : "";
  237.       $out .= !empty$this->freestyle )
  238.               ? "          style=\"".$this->freestyle."\"\r\n"
  239.               : "";
  240.       $out .= !empty$this->blur )
  241.               ? "          onBlur=\"".$this->blur."\"\r\n"
  242.               : "";
  243.       $out .= !empty$this->focus )
  244.               ? "          onFocus=\"".$this->focus."\"\r\n"
  245.               : "";
  246.       $out .= !empty$this->click )
  247.               ? "          onClick=\"".$this->click."\"\r\n"
  248.               : "";
  249.       $out .= !empty$this->mouseup )
  250.               ? "          onMouseup=\"".$this->mouseup."\"\r\n"
  251.               : "";
  252.       $out .= !empty$this->mouseover )
  253.               ? "          onMouseover=\"".$this->mouseover."\"\r\n"
  254.               : "";
  255.       $out .= !empty$this->mouseout )
  256.               ? "          onMouseout=\"".$this->mouseout."\"\r\n"
  257.               : "";
  258.       $out .= !empty$this->mousemove )
  259.               ? "          onMousemove=\"".$this->mousemove."\"\r\n"
  260.               : "";
  261.  
  262.       if (
  263.            $forminput == "POST"
  264.         || $forminput == "GET"
  265.         || $forminput == "REQUEST"
  266.          )
  267.          $out .= "<?php if ( \x24_".$forminput."['".$this->name."'] ) "
  268.                          ."echo ' checked'; ?>";
  269.       else
  270.          $out .= $this->checked
  271.                  ? "          checked=\"checked\"\r\n"
  272.                  : "";
  273.  
  274.       $out .= (
  275.                  $this->enabled
  276.               && $this->manipulateable
  277.               )
  278.               ? ""
  279.               : "          disabled=\"disabled\"\r\n";
  280.       $out .= "   />".(
  281.                          is_object$this->label_obj )
  282.                          ? $this->label_obj->get()
  283.                          : ""
  284.                       );
  285.  
  286.       return $out;
  287.    }
  288. // End of class HTMLRadioButton
  289. ?>

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