[PHPVortex-Commit] phpvortex FT_Text.class.php,NONE,1.1
Brought to you by:
nop144666
From: Thiago R. <nop...@us...> - 2004-09-29 19:37:28
|
Update of /cvsroot/phpvortex/phpvortex In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10063 Added Files: FT_Text.class.php Log Message: Added the class FT_Text --- NEW FILE: FT_Text.class.php --- <?php /** * File for class FT_Text. * * @package Vortex * @subpackage DB * @author Thiago Ramon Gonçalves Montoya * @copyright Copyright 2004, Thiago Ramon Gonçalves Montoya * @license http://opensource.org/licenses/lgpl-license.php GNU Lesser General Public License */ /** Require the base class */ require_once('FT_Base.class.php'); /** * Database field, Text type. * * @package Vortex * @subpackage DB */ class FT_Text extends FT_Base { /** * Maximum size of the field. Use -1 for unlimited. * * @var int */ var $size = -1; /** * Number of rows in the text field. * * @var int */ var $rows = 1; /** * Number of columns in the field. Use -1 to ignore. * * @var int */ var $cols = -1; /** * Output the field as a HTML Form. * * @param string $value Value to load the control with. */ function ShowForm($value) { if ($this->rows > 1) { echo "<textarea name='{$this->name_form}' rows='{$this->rows}'".(($this->cols > 0)?" cols='{$this->cols}'":'').">$value</textarea>"; } else { echo "<input type='text' name='{$this->name_form}' value='$value'".(($this->size > 0)?" maxlength='{$this->size}'":'').'>'; } } /** * Output the field as plain text. * * @param string $value Value to load the control with. */ function ShowPlain($value) { echo nl2br($value); } /** * Output the field consistency testing in JavaScript. */ function JSConsist() { if ($this->required) { echo <<<END if (frm.{$this->name_form}.value == "") errors += " * {$this->label}"; END; } } /** * Test the field consistency. * * @param string $field The data from the field to be tested. * @return bool Returns TRUE if the field is consistent, FALSE otherwise. */ function ConsistTest(&$field) { if ($this->required && empty($field)) return FALSE; return TRUE; } } ?> |