[PHPVortex-Commit] phpvortex TB_Base.class.php,1.7,1.8
Brought to you by:
nop144666
From: Thiago R. <nop...@us...> - 2004-10-04 21:14:56
|
Update of /cvsroot/phpvortex/phpvortex In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4252 Modified Files: TB_Base.class.php Log Message: Added the member function ShowForm() to TB_Base, and some small bug fixes Index: TB_Base.class.php =================================================================== RCS file: /cvsroot/phpvortex/phpvortex/TB_Base.class.php,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** TB_Base.class.php 4 Oct 2004 18:11:17 -0000 1.7 --- TB_Base.class.php 4 Oct 2004 21:14:45 -0000 1.8 *************** *** 10,13 **** --- 10,16 ---- */ + /** Require the global configuration file for access to the localized messages */ + require_once('conf/conf.php'); + /** * No Error *************** *** 109,118 **** /** * Array containing references to the fields to use in forms. ! * @var FT_Base */ var $fields_form = array(); /** ! * Array the current row of the table, for output, edit or search. * @var array */ --- 112,121 ---- /** * Array containing references to the fields to use in forms. ! * @var array */ var $fields_form = array(); /** ! * Array with the current row of the table, for output, edit or search. * @var array */ *************** *** 323,326 **** --- 326,330 ---- if (!empty($url)) echo "<a href='".str_replace('PKEY',$pkeys,$url)."'>"; $field->ShowPlain($row[$field->name_db]); + if (!empty($url)) echo '</a>'; echo "</td>\n"; } *************** *** 328,331 **** --- 332,336 ---- } echo "</tbody>\n</table></div>\n"; + return TRUE; } *************** *** 334,338 **** * * @param array $data Array containing the data to seek as 'field' => 'value'. ! * @return int Returns the number of pages in a list. */ function NumPages($data = NULL) --- 339,343 ---- * * @param array $data Array containing the data to seek as 'field' => 'value'. ! * @return int Returns the number of pages in a list or FALSE on error. */ function NumPages($data = NULL) *************** *** 358,361 **** --- 363,411 ---- return (int)ceil($row['cnt'] / $this->list_recspage); } + + /** + * Outputs a form for inserting/editing records. + * + * @param string $name The HTML FORM name. + * @param string $action Where to submit the data to. + * @param array $data Array containing the data to seek as 'field' => 'value'. + * @return bool Returns TRUE on success, FALSE on error. + */ + function ShowForm($name, $action, $data = NULL) + { + global $vortex_msgs; + if (!empty($data)) if (!$this->Seek($data)) return FALSE; + echo <<<END + <div class="div_form"> + <script language="javascript"> + function Submit_{$name}(frm) + { + var error = ''; + + END; + foreach ($this->fields_form as $field) { + $field->JSConsist(); + } + echo <<<END + + if (error != '') { + alert("{$vortex_msgs['consist_error']}\\n\\n"+error); + return false; + } + return true; + } + </script> + <table> + <form name="{$name}" action="{$action}" method="post" onSubmit="return Submit_{$name}(this);"> + <tbody> + END; + foreach ($this->fields as $field) if ($field->pkey) { + echo "<input type='hidden' name='{$field->name_db}' value='".(empty($this->data)?'-1':$this->data[$field->name_db])."'>\n"; + } + foreach ($this->fields_form as $field) { + $field->Show($this->data); + } + echo "</tbody>\n</form>\n</table></div>\n"; + } } |