[PHPVortex-Commit] phpvortex FT_ListArray.class.php,NONE,1.1 FT_List.class.php,1.1,1.2
Brought to you by:
nop144666
From: Thiago R. <nop...@us...> - 2004-10-20 20:10:30
|
Update of /cvsroot/phpvortex/phpvortex In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28008 Modified Files: FT_List.class.php Added Files: FT_ListArray.class.php Log Message: Added the FT_ListArray array and made some small changes to FT_List Index: FT_List.class.php =================================================================== RCS file: /cvsroot/phpvortex/phpvortex/FT_List.class.php,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** FT_List.class.php 13 Oct 2004 18:48:24 -0000 1.1 --- FT_List.class.php 20 Oct 2004 20:10:18 -0000 1.2 *************** *** 52,55 **** --- 52,57 ---- * Field to order by in the table. * + * Default: {@link $rel_label} + * * @var string */ *************** *** 57,60 **** --- 59,74 ---- /** + * Constructor: Load all parameters into member variables. + * + * @param DB_Base $db Database where the field is. + * @param array $opts Parameters for the object, as 'var' => 'value'. + */ + function FT_List(&$db, $opts = array()) + { + parent::FT_Base($db, $opts); + is_null($this->rel_order) and $this->rel_order = $this->rel_label; + } + + /** * Output the field as a HTML Form. * --- NEW FILE: FT_ListArray.class.php --- <?php /** * File for class FT_ListArray. * * @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, List (<select>) with contents in a array. * * @package Vortex * @subpackage DB */ class FT_ListArray extends FT_Base { /** * Default value of the field. * * @var string */ var $default = '-1'; /** * Array to get the list from. * * List itens as 'key' => 'label' * * @var array */ var $list_array = array(); /** * Output the field as a HTML Form. * * @param string $value Value to load the control with. */ function ShowForm($value) { global $vortex_msgs; echo "<select name='{$this->name_form}'>\n"; echo "\t<option value='-1'".((-1 == $value)?' selected':'').">{$vortex_msgs['list_default']}</option>\n"; foreach ($this->list_array as $key => $label) { echo "\t<option value='$key'".(($key == $value)?' selected':'').">$label</option>\n"; } echo "</select>\n"; } /** * Output the field as plain text. * * @param string $value Value to load the control with. */ function ShowPlain($value) { echo $this->list_array[$value]; } /** * Output the field consistency testing in JavaScript. */ function JSConsist() { if ($this->required) { echo <<<END if (frm.{$this->name_form}.selectedIndex < 1) errors += " * {$this->label}\\n"; 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) || ($field < 0))) return FALSE; return TRUE; } /** * 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); } } ?> |