/** * Outputs HTML for forms * * @uses ConfigFile::getInstance() * @uses ConfigFile::get() * @uses display_fieldset_bottom() * @uses display_fieldset_top() * @uses display_form_bottom() * @uses display_form_top() * @uses display_js() * @uses display_tabs_bottom() * @uses display_tabs_top() * @uses js_validate() * @uses PMA_config_get_validators() * @uses PMA_jsFormat() * @uses PMA_lang() * @param bool $tabbed_form * @param bool $show_restore_default whether show "restore default" button besides the input field */ public function display($tabbed_form = false, $show_restore_default = false) { static $js_lang_sent = false; $js = array(); $js_default = array(); $tabbed_form = $tabbed_form && count($this->forms) > 1; $validators = PMA_config_get_validators(); display_form_top(); if ($tabbed_form) { $tabs = array(); foreach ($this->forms as $form) { $tabs[$form->name] = PMA_lang("Form_{$form->name}"); } display_tabs_top($tabs); } // valdiate only when we aren't displaying a "new server" form $is_new_server = false; foreach ($this->forms as $form) { /* @var $form Form */ if ($form->index === 0) { $is_new_server = true; break; } } if (!$is_new_server) { $this->_validate(); } // user preferences $this->_loadUserprefsInfo(); // display forms foreach ($this->forms as $form) { /* @var $form Form */ $form_desc = isset($GLOBALS["strConfigForm_{$form->name}_desc"]) ? PMA_lang("Form_{$form->name}_desc") : ''; $form_errors = isset($this->errors[$form->name]) ? $this->errors[$form->name] : null; display_fieldset_top(PMA_lang("Form_{$form->name}"), $form_desc, $form_errors, array('id' => $form->name)); foreach ($form->fields as $field => $path) { $work_path = array_search($path, $this->system_paths); $translated_path = $this->translated_paths[$work_path]; // always true/false for user preferences display // otherwise null $userprefs_allow = isset($this->userprefs_keys[$path]) ? !isset($this->userprefs_disallow[$path]) : null; // display input $this->_displayFieldInput($form, $field, $path, $work_path, $translated_path, $show_restore_default, $userprefs_allow, $js_default); // register JS validators for this field if (isset($validators[$path])) { js_validate($translated_path, $validators[$path], $js); } } display_fieldset_bottom(); } if ($tabbed_form) { display_tabs_bottom(); } display_form_bottom(); // if not already done, send strings used for valdiation to JavaScript if (!$js_lang_sent) { $js_lang_sent = true; $js_lang = array(); foreach ($this->js_lang_strings as $strName => $strValue) { $js_lang[] = "'{$strName}': '" . PMA_jsFormat($strValue, false) . '\''; } $js[] = "\$.extend(PMA_messages, {\n\t" . implode(",\n\t", $js_lang) . '})'; } $js[] = "\$.extend(defaultValues, {\n\t" . implode(",\n\t", $js_default) . '})'; display_js($js); }
/** * Outputs HTML for forms * * @param bool $tabbed_form * @param bool $show_restore_default whether show "restore default" button besides the input field */ public function display($tabbed_form = false, $show_restore_default = false) { static $js_lang_sent = false; $js = array(); $js_default = array(); $tabbed_form = $tabbed_form && count($this->forms) > 1; $validators = ConfigFile::getInstance()->getDbEntry('_validators'); display_form_top(); if ($tabbed_form) { $tabs = array(); foreach ($this->forms as $form) { $tabs[$form->name] = PMA_lang("Form_{$form->name}"); } display_tabs_top($tabs); } // valdiate only when we aren't displaying a "new server" form $is_new_server = false; foreach ($this->forms as $form) { /* @var $form Form */ if ($form->index === 0) { $is_new_server = true; break; } } if (!$is_new_server) { $this->_validate(); } // display forms foreach ($this->forms as $form) { /* @var $form Form */ $form_desc = isset($GLOBALS["strSetupForm_{$form->name}_desc"]) ? PMA_lang("Form_{$form->name}_desc") : ''; $form_errors = isset($this->errors[$form->name]) ? $this->errors[$form->name] : null; display_fieldset_top(PMA_lang("Form_{$form->name}"), $form_desc, $form_errors, array('id' => $form->name)); foreach ($form->fields as $field => $path) { $work_path = array_search($path, $this->system_paths); $translated_path = $this->translated_paths[$work_path]; // display input $this->_displayFieldInput($form, $field, $path, $work_path, $translated_path, $show_restore_default, $js_default); // register JS validators for this field if (isset($validators[$path])) { js_validate($translated_path, $validators[$path], $js); } } display_fieldset_bottom(); } if ($tabbed_form) { display_tabs_bottom(); } display_form_bottom(); // if not already done, send strings used for valdiation to JavaScript if (!$js_lang_sent) { $js_lang_sent = true; $js_lang = array(); foreach ($this->js_lang_strings as $str) { $lang = isset($GLOBALS["strSetup{$str}"]) ? $GLOBALS["strSetup{$str}"] : filter_input($GLOBALS["str{$str}"]); // null if not set $js_lang[] = "'{$str}': '" . PMA_jsFormat($lang, false) . '\''; } $js[] = '$extend(PMA_messages, {' . implode(",\n\t", $js_lang) . '})'; } $js[] = '$extend(defaultValues, {' . implode(",\n\t", $js_default) . '})'; display_js($js); }