function MyQuickForm($formName = "", $method = "post", $action = '', $target = '', $attributes = null, $trackSubmit = false) { HTML_QuickForm::HTML_QuickForm($formName, $method, $action, $target, $attributes, $trackSubmit); $this->name = $formName; $this->addElement('hidden', '__qf_token_' . $this->name, $this->name . "EMPTY"); $this->registerRule('prevent_from_reload', 'callback', 'cbFormShouldOnlyBeSubmittedOnce'); $this->addRule('__qf_token_' . $formName, "Form was already sent", 'prevent_from_reload'); $this->registerRule('cbAltSelectOneNeeded', 'callback', 'cbAltSelectOneNeeded', $this); }
function __construct($action = '') { if (empty($action)) { $action = Piwik_Url::getCurrentQueryString(); } parent::HTML_QuickForm('form', 'POST', $action); $this->registerRule('checkEmail', 'function', 'Piwik_Form_isValidEmailString'); $this->registerRule('fieldHaveSameValue', 'function', 'Piwik_Form_fieldHaveSameValue'); $this->init(); }
function Dataface_SearchForm($tablename, $db = '', $query = '', $fields = null) { $widgetTypes = array(); $this->tablename = $tablename; $this->db = $db; $this->_query = is_array($query) ? $query : array(); if (!isset($this->_query['-cursor'])) { $this->_query['-cursor'] = 0; } $this->_resultSet =& Dataface_QueryTool::loadResult($tablename, $db, $this->_query); parent::HTML_QuickForm($tablename, 'post'); // Get column information directly from the database $this->tablename = preg_replace('/ /', '', $this->tablename); $this->_table =& Dataface_Table::loadTable($this->tablename, $this->db); $this->_fields = array(); if (!isset($fields)) { $fields = array_keys($this->_table->fields(false, true)); foreach ($this->_table->relationships() as $relationship) { if (@$relationship->_schema['visibility'] and @$relationship->_schema['visibility']['find'] == 'hidden') { continue; } $rfields = $relationship->fields(true); $fkeys = $relationship->getForeignKeyValues(); $removedKeys = array(); foreach ($fkeys as $fkeyTable => $fkey) { foreach (array_keys($fkey) as $fkeyKey) { $removedKeys[] = $fkeyTable . '.' . $fkeyKey; } } $rfields = array_diff($rfields, $removedKeys); foreach ($rfields as $rfield) { list($rtable, $rfield) = explode('.', $rfield); $fields[] = $relationship->getName() . '.' . $rfield; } unset($rfields); unset($relationship); } } $this->_fields = array(); foreach ($fields as $fieldname) { $this->_fields[$fieldname] =& $this->_table->getField($fieldname); } }
function Form(&$template, $action = null) { if (is_null($action)) { $action = Request::getCurrentUrl(); } parent::HTML_QuickForm('form_phpmv', 'POST', $action); $this->tpl =& $template; $this->init(); }
function Dataface_DeleteForm($tablename, $db, $query) { $this->_tablename = $tablename; $this->_table =& Dataface_Table::loadTable($tablename); $this->_db = $db; $this->_query = $query; $this->_isBuilt = false; if (!isset($this->_query['-cursor'])) { $this->_query['-cursor'] = 0; } parent::HTML_QuickForm('deleteForm'); }
/** * @param $tablename The name of the table upon which this form is based. - or a Dataface_Record object to edit. * @type string | Dataface_Record * * @param $db DB handle for the current database connection. * @type resource * * @param $query Associative array of query parameters to dictate which record is loaded for editing. * @type array([String]->[String]) * * @param $new Flag to indicate whether this form is creating a new record or editing an existing one. * @type boolean * * @param $fieldnames An optional array of field names to include in the form. * @type array(string) * */ function Dataface_QuickForm($tablename, $db = '', $query = '', $formname = '', $new = false, $fieldnames = null, $lang = null) { $app =& Dataface_Application::getInstance(); $this->app =& $app; $appQuery =& $app->getQuery(); if (!isset($lang) && !isset($this->_lang)) { $this->_lang = $app->_conf['lang']; } else { if (isset($lang)) { $this->_lang = $lang; } } if (is_a($tablename, 'Dataface_Record')) { if (!$this->formSubmitted()) { $this->_record =& $tablename; $this->tablename = $this->_record->_table->tablename; $this->_table =& $this->_record->_table; unset($tablename); $tablename = $this->tablename; } else { $this->_record =& Dataface_QuickForm::getRecord(); $this->tablename = $tablename; $this->_table =& Dataface_Table::loadTable($this->tablename); } } else { if (!$new) { if ($tablename == $appQuery['-table']) { $this->_record =& Dataface_QuickForm::getRecord(); } else { if ($query) { $this->_record =& df_get_record($tablename, $query); } } if (!$this->_record) { $this->_record = new Dataface_Record($tablename, array()); } $this->tablename = $tablename; $this->_table =& Dataface_Table::loadTable($this->tablename); //$tablename = $this->tablename; } else { $this->tablename = $tablename; $this->_table =& Dataface_Table::loadTable($this->tablename, $this->db); $this->_record = new Dataface_Record($this->tablename, array()); } } $this->_new = $new; if (!$formname) { if ($new) { $formname = "new_" . $tablename . "_record_form"; } else { $formname = "existing_" . $tablename . "_record_form"; } } if (!$db) { $db = $app->db(); } $this->db = $db; $this->_query = is_array($query) ? $query : array(); // The cursor tells us which record in the dataset we will be editing. if (!isset($this->_query['-cursor'])) { $this->_query['-cursor'] = 0; } // Load the results of the query. $this->_resultSet =& Dataface_QueryTool::loadResult($tablename, $db, $this->_query); parent::HTML_QuickForm($formname, 'post', df_absolute_url($_SERVER['PHP_SELF']), '', array('accept-charset' => $app->_conf['ie']), self::$TRACK_SUBMIT); $this->setJsWarnings(df_translate('quickform.warning.prefix', $this->_jsPrefix), df_translate('quickform.warning.postfix', $this->_jsPostfix)); //$this->_fields =& $this->_table->fields(false,false,true); $this->_fields =& $this->_table->formFields(false, true); if (@$appQuery['-xf-hide-fields']) { $hiddenFields = explode(' ', $appQuery['-xf-hide-fields']); $css = array(); foreach ($hiddenFields as $f) { if (isset($this->_fields[$f])) { $css[] = "#{$f}_form_row { display:none;}"; // $this->_fields[$f]['widget']['type'] = 'hidden'; // $fieldDef =& Dataface_Table::loadTable($this->_fields[$f]['tablename'])->getField($f); // $fieldDef['widget']['type'] = 'hidden'; // unset($fieldDef); // //$field =& } } if ($css) { $app->addHeadContent('<style type="text/css">' . implode('', $css) . '</style>'); } } //$this->_record = new Dataface_Record($this->_table->tablename, array()); $this->_renderer = new HTML_QuickForm_Renderer_Dataface($this); //$this->defaultRenderer(); $this->_renderer->setFormTemplate($this->getFormTemplate()); $this->_requiredNote = ''; if (is_array($fieldnames)) { /* * $fieldnames were specified in the parameters. We will use the provided * field names but we must make sure that the fields exist. */ $this->_fieldnames = array(); foreach ($fieldnames as $fieldname) { if (isset($this->_fields[$fieldname])) { $this->_fieldnames[] = $fieldname; } } } //$this->_build(); }
/** * @param $tablename The name of the table upon which this form is based. - or a Dataface_Record object to edit. * @type string | Dataface_Record * * @param $db DB handle for the current database connection. * @type resource * * @param $query Associative array of query parameters to dictate which record is loaded for editing. * @type array([String]->[String]) * * @param $new Flag to indicate whether this form is creating a new record or editing an existing one. * @type boolean * * @param $fieldnames An optional array of field names to include in the form. * @type array(string) * */ function Dataface_QuickForm($tablename, $db = '', $query = '', $formname = '', $new = false, $fieldnames = null, $lang = null) { $app =& Dataface_Application::getInstance(); $this->app =& $app; $appQuery =& $app->getQuery(); if (!isset($lang) && !isset($this->_lang)) { $this->_lang = $app->_conf['lang']; } else { if (isset($lang)) { $this->_lang = $lang; } } if (is_a($tablename, 'Dataface_Record')) { if (!$this->formSubmitted()) { $this->_record =& $tablename; $this->tablename = $this->_record->_table->tablename; $this->_table =& $this->_record->_table; unset($tablename); $tablename = $this->tablename; } else { $this->_record =& Dataface_QuickForm::getRecord(); $this->tablename = $tablename; $this->_table =& Dataface_Table::loadTable($this->tablename); } } else { if (!$new) { if ($tablename == $appQuery['-table']) { $this->_record =& Dataface_QuickForm::getRecord(); } else { if ($query) { $this->_record =& df_get_record($tablename, $query); } } if (!$this->_record) { $this->_record = new Dataface_Record($tablename, array()); } $this->tablename = $tablename; $this->_table =& Dataface_Table::loadTable($this->tablename); //$tablename = $this->tablename; } else { $this->tablename = $tablename; $this->_table =& Dataface_Table::loadTable($this->tablename, $this->db); $this->_record = new Dataface_Record($this->tablename, array()); } } $this->_new = $new; if (!$formname) { if ($new) { $formname = "new_" . $tablename . "_record_form"; } else { $formname = "existing_" . $tablename . "_record_form"; } } if (!$db and defined('DATAFACE_DB_HANDLE')) { $db = DATAFACE_DB_HANDLE; } else { $db = $app->_db; } $this->db = $db; $this->_query = is_array($query) ? $query : array(); // The cursor tells us which record in the dataset we will be editing. if (!isset($this->_query['-cursor'])) { $this->_query['-cursor'] = 0; } // Load the results of the query. $this->_resultSet =& Dataface_QueryTool::loadResult($tablename, $db, $this->_query); parent::HTML_QuickForm($formname, 'post', df_absolute_url($_SERVER['PHP_SELF']), '', array('accept-charset' => $app->_conf['ie']), true); //$this->_fields =& $this->_table->fields(false,false,true); $this->_fields =& $this->_table->formFields(false, true); //$this->_record = new Dataface_Record($this->_table->tablename, array()); $this->_renderer = new HTML_QuickForm_Renderer_Dataface($this); //$this->defaultRenderer(); $this->_renderer->setFormTemplate($this->getFormTemplate()); $this->_requiredNote = ''; if (is_array($fieldnames)) { /* * $fieldnames were specified in the parameters. We will use the provided * field names but we must make sure that the fields exist. */ $this->_fieldnames = array(); foreach ($fieldnames as $fieldname) { if (isset($this->_fields[$fieldname])) { $this->_fieldnames[] = $fieldname; } } } //$this->_build(); }
/** * Class constructor * @param string $formName Form's name. * @param string $method (optional)Form's method defaults to 'POST' * @param string $action (optional)Form's action * @param string $target (optional)Form's target defaults to '_self' * @param mixed $attributes (optional)Extra attributes for <form> tag * @param bool $trackSubmit (optional)Whether to track if the form was submitted by adding a special hidden field * @access public */ function HTML_QuickForm_vLab($formName = '', $method = 'post', $action = '', $target = '', $attributes = null, $trackSubmit = false) { HTML_QuickForm::HTML_QuickForm($formName, $method, $action, $target, $attributes, $trackSubmit); }
/** * * The Constructor * * Classname and id are specific to HTML_QuickForm_Propel * * The other parameters are needed to construct the parent QuickForm Class. * * @param string className * @param string id * @param string formName * @param string method * @param string action * @param string target * @param array attributes * @param boolean trackSubmit * */ public function __construct($className = null, $id = null, $formName = 'HTML_QuickForm_Propel', $method = 'post', $action = '', $target = '_self', $attributes = null, $trackSubmit = false) { $this->setClassName($className); $this->setPeerName($className . 'Peer'); // Is this always true ? $this->setId($id); parent::HTML_QuickForm($formName, $method, $action, $target, $attributes, $trackSubmit); // set the default column policy $this->setColumnMode(HTML_QUICKFORM_PROPEL_ALL_COLUMNS); }