Source for file checkbox.php

Documentation is available at checkbox.php

  1. <?php
  2. /**
  3. * a checkbox object
  4. *
  5. @author    Stuart Prescott
  6. @copyright  Copyright Stuart Prescott
  7. @license    http://opensource.org/licenses/gpl-license.php GNU Public License
  8. @version    $Id$
  9. @package    Bumblebee
  10. @subpackage FormsLibrary
  11. */
  12.  
  13. /** Load ancillary functions */
  14. require_once 'inc/typeinfo.php';
  15.  
  16. /** field parent object */
  17. require_once 'field.php';
  18.  
  19. /**
  20. * a checkbox object
  21. *
  22. @package    Bumblebee
  23. @subpackage FormsLibrary
  24. */
  25. class CheckBox extends Field {
  26.  
  27.   /**
  28.   *  Create a new checkbox object
  29.   *
  30.   * @param string $name   the name of the field (db name, and html field name
  31.   * @param string $longname  long name to be used in the label of the field in display
  32.   * @param string $description  used in the html title or longdesc for the field
  33.   */
  34.   function CheckBox($name$longname=''$description=''{
  35.     parent::Field($name$longname$description);
  36.     $this->useNullValues = 1;
  37.   }
  38.  
  39.   function update($data{
  40.     if (parent::update($data)) {
  41.       $this->log("CHECKBOX $this->name$this->value$this->ovalue");
  42.       $this->value = ($this->value ? 0);
  43.       $this->ovalue = ($this->ovalue ? 0);
  44.       $this->log("CHECKBOX $this->name$this->value$this->ovalue");
  45.       $this->changed = ($this->value != $this->ovalue);
  46.     }
  47.     return $this->changed;
  48.   }
  49.  
  50.   function displayInTable($cols=3{
  51.     $errorclass ($this->isValid ? '' "class='inputerror'");
  52.     $t "<tr $errorclass><td>$this->longname</td>\n"
  53.         ."<td title='$this->description'>";
  54.     if ($this->editable{
  55.       $t .= $this->selectable();
  56.     else {
  57.       $t .= xssqw($this->value);
  58.       $t .= "<input type='hiddenname='$this->namebase$this->name"
  59.            ."value='".xssqw($this->value)."' />";
  60.     }
  61.     $t .= "</td>\n";
  62.     for ($i=0$i<$cols-2$i++{
  63.       $t .= '<td></td>';
  64.     }
  65.     $t .= '</tr>';
  66.     return $t;
  67.   }
  68.  
  69.   function selectable({
  70.     $t  "<input type='checkboxname='$this->namebase$this->name"
  71.          ."value='1' ";
  72.     $t .= (($this->getValue()) 'checked="1"' '');
  73.     $t .= '/>';
  74.     return $t;
  75.   }
  76.  
  77. // class CheckBox
  78.  
  79. ?>

Documentation generated on Tue, 06 Mar 2007 10:01:01 +0000 by phpDocumentor 1.3.0