Source for file textfield.php

Documentation is available at textfield.php

  1. <?php
  2. /**
  3. * the textfield widget primitive
  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. require_once 'inc/bb/configreader.php';
  17.  
  18. /** parent object */
  19. require_once 'field.php';
  20.  
  21. /**
  22. * The textfield widget primitive
  23. *
  24. * Designed for strings to be edited in a text field widget in the HTML form,
  25. * but is inherited for TimeField, IdField etc
  26. *
  27. @package    Bumblebee
  28. @subpackage FormsLibrary
  29. */
  30. class TextField extends Field {
  31.  
  32.   /**
  33.   *  Create a new field object, designed to be superclasses
  34.   *
  35.   * @param string $name   the name of the field (db name, and html field name
  36.   * @param string $longname  long name to be used in the label of the field in display
  37.   * @param string $description  used in the html title or longdesc for the field
  38.   */
  39.   function TextField($name$longname=''$description=''{
  40.     parent::Field($name$longname$description);
  41.     $this->valueCleaner = array($this'_textCleaner');
  42.   }
  43.  
  44.   function _textCleaner($value{
  45.     $value trim($value);
  46.  
  47.     if (issetSet($this->attr'float'false)) {
  48.       $conf ConfigReader::getInstance();
  49.       if ($conf->value('language''use_comma_floats'false)) {
  50.         $value commaFloat($value);
  51.         // also convert the original db value to a float so that the comparison will be numeric
  52.         $this->value = floatval($this->value);
  53.       }
  54.     }
  55.     return $value;
  56.   }
  57.  
  58.   function displayInTable($cols=3{
  59.     $t '';
  60.     if ($this->hidden{
  61.       $errorclass ($this->isValid ? '' 'class="inputerror"');
  62.       $t .= "<tr $errorclass><td>$this->longname</td>\n"
  63.           ."<td title='$this->description'>";
  64.       if ($this->editable{
  65.         $t .= $this->selectable();
  66.         else {
  67.         $t .= $this->selectedValue();
  68.       }
  69.       if ($this->duplicateName{
  70.         $t .= '<input type="hidden" name="'.$this->duplicateName.'" '
  71.               .'value="'.xssqw($this->getValue()).'" />';
  72.       }
  73.       $t .= "</td>\n";
  74.       for ($i=0$i<$cols-2$i++{
  75.         $t .= "<td></td>";
  76.       }
  77.       $t .= "</tr>";
  78.     else {
  79.       $t .= $this->hidden();
  80.     }
  81.     return $t;
  82.   }
  83.  
  84.   function selectedValue({
  85.     return xssqw($this->getValue()).$this->hidden();
  86.   }
  87.  
  88.   function selectable({
  89.     $value $this->getValue();
  90.     if ($value !== null && $value !== '' &&
  91.         issetSet($this->attr'float'false&& $precision issetSet($this->attr'precision'false)) {
  92.       $value numberFormatter($value$precision);
  93.     }
  94.     $t  '<input type="text" name="'.$this->namebase.$this->name.'" ';
  95.     $t .= 'title="'.$this->description.'" ';
  96.     $t .= 'value="'.xssqw($value).'" ';
  97.     $t .= (isset($this->attr['size']'size="'.$this->attr['size'].'" ' '');
  98.     $t .= (isset($this->attr['maxlength']'maxlength="'.$this->attr['maxlength'].'" ' '');
  99.     $t .= '/>';
  100.     return $t;
  101.   }
  102.  
  103.   function hidden({
  104.     return "<input type='hiddenname='$this->namebase$this->name"
  105.            ."value='".xssqw($this->getValue())."' />";
  106.   }
  107.  
  108. // class TextField
  109.  
  110.  
  111. ?>

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