Example #1
0
 /**
  * Display the textbox.
  */
 function display($class = NULL, $size = NULL)
 {
     $maxlength = getRegexLength($this->regex, 16);
     if ($size == NULL) {
         $size = $maxlength == 0 ? INPUT_TEXTBOX_SIZE_MAX : $maxlength;
     }
     ensureIntInRange($size, INPUT_TEXTBOX_SIZE_MIN, INPUT_TEXTBOX_SIZE_MAX);
     if ($this->form->submitted() && ($this->required && !$this->wasSet || $this->wasSet && !$this->wasValid)) {
         $class = 'error';
     }
     $type = ' type="' . $this->type . '"';
     $name = ' name="' . $this->name . '"';
     $value = ' value="' . htmlentities($this->value) . '"';
     $size = ' size="' . $size . '"';
     $class = $class == NULL ? '' : ' class="' . $class . '"';
     $maxlength = $maxlength == 0 ? '' : ' maxlength="' . $maxlength . '"';
     $required = $this->required ? ' *' : '';
     echo '<input' . $type . $name . $value . $size . $maxlength . $class . ' />' . $required;
 }
Example #2
0
 /**
  * Display the textarea.
  *
  * <p> Called by templates to render text area form elements.
  *
  * @param string class CSS class assigned to text area
  * @param int width Number of columns for text area - CSS can substitute
  * @param int height Number of rows for text area
  */
 function display($class = NULL, $width = NULL, $height = NULL)
 {
     // If maxlength was given, use it. Otherwise, check if the regex specified
     // a maximum length,  and if that didn't use the max width * max height.
     $maxlength = $this->maxlength !== FALSE ? $this->maxlength : getRegexLength($this->regex, INPUT_TEXTAREA_WIDTH_MAX * INPUT_TEXTAREA_HEIGHT_MAX);
     if ($this->wasSet && !$this->wasValid) {
         $class .= ' error';
     }
     $name = 'name="' . $this->name . '" ';
     $id = 'id="' . $this->name . '" ';
     $value = 'value="' . htmlentities($this->value) . '" ';
     $class = $class == NULL ? '' : 'class="' . $class . '" ';
     // If we have no width, nor no CSS class to specify it for us
     if ($width == NULL && $class == '') {
         $width = $maxlength == 0 ? INPUT_TEXTAREA_WIDTH_MAX : (int) ($maxlength / 2);
     }
     // make sure the width in range, and wrap it with pretty cols=""
     ensureIntInRange($width, INPUT_TEXTAREA_WIDTH_MIN, INPUT_TEXTAREA_WIDTH_MAX);
     $width = $width == NULL ? '' : 'cols="' . $width . '" ';
     // A height HAS to be specified - no CSS out, here.
     if ($height == NULL) {
         $height = $maxlength == 0 ? INPUT_TEXTAREA_HEIGHT_MAX : (int) ($maxlength / 10);
     }
     // ensure that the height is in range, and wrap it with requisite rows=""
     ensureIntInRange($height, INPUT_TEXTAREA_HEIGHT_MIN, INPUT_TEXTAREA_HEIGHT_MAX);
     $height = 'rows="' . $height . '" ';
     // and finally, display it!
     echo '<textarea ' . $name . $id . $width . $height . $class . 'wrap="virtual" >' . "\n" . htmlentities($this->value) . "\n" . '</textarea>' . "\n";
 }