[PHPVortex-Commit] phpvortex FT_Hidden.class.php,NONE,1.1 FT_PKey.class.php,NONE,1.1
Brought to you by:
nop144666
|
From: Thiago R. <nop...@us...> - 2004-10-07 21:19:55
|
Update of /cvsroot/phpvortex/phpvortex In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1498 Added Files: FT_Hidden.class.php FT_PKey.class.php Log Message: Added FT_Hidden and FT_PKey --- NEW FILE: FT_PKey.class.php --- <?php /** * File for class FT_PKey. * * @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_Hidden.class.php'); /** * Database field, auto-incrementing numeric Primary Key. * * @package Vortex * @subpackage DB */ class FT_PKey extends FT_Hidden { /** * Is the field a Primary Key? * * @var bool */ var $pkey = TRUE; /** * Is the field required(obligatory)? * * @var bool */ var $required = TRUE; /** * Default value of the field. * * @var string */ var $default = '-1'; /** * Format the field for database insertion. * * @param string $field The data from the field to be formated. * @return string Returns the formated field. */ function ConsistFormat(&$field) { return (string)((int)$field); } } ?> --- NEW FILE: FT_Hidden.class.php --- <?php /** * File for class FT_Hidden. * * @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, Hidden. * * @package Vortex * @subpackage DB */ class FT_Hidden extends FT_Base { /** * Output the field as a HTML Form or just for display. * * @param array $data Array containing the field values as 'field' => 'value'. * @param bool $form Show field as a INPUT object? */ function Show(&$data, $form = TRUE) { if (empty($data) || !isset($data[$this->name_db])) { $value = $this->default; } else { $value = $data[$this->name_db]; } if ($form) { $this->ShowForm($value); } else { $this->ShowPlain($value); } } /** * Output the field as a HTML Form. * * @param string $value Value to load the control with. */ function ShowForm($value) { echo "<input type='hidden' name='{$this->name_form}' value='$value' />"; } /** * 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; } } ?> |