Skip to content

Commit

Permalink
Refactor
Browse files Browse the repository at this point in the history
Signed-off-by: Marc Delisle <marc@infomarc.info>
  • Loading branch information
lem9 committed May 15, 2015
1 parent 5efe4d0 commit 4bdd483
Showing 1 changed file with 62 additions and 40 deletions.
102 changes: 62 additions & 40 deletions libraries/config/FormDisplay.class.php
Expand Up @@ -205,52 +205,22 @@ private function _validate()
}

/**
* Outputs HTML for forms
* Outputs HTML for the forms under the menu tab
*
* @param bool $tabbed_form if true, use a form with tabs
* @param bool $show_restore_default whether show "restore default" button
* besides the input field
* @param bool $show_restore_default whether to show "restore default"
* button besides the input field
* @param array &$js_default stores JavaScript code
* to be displayed
* @param array &$js will be updated with javascript code
*
* @return void
* @return $htmlOutput
*/
public function getDisplay($tabbed_form = false, $show_restore_default = false)
{
static $js_lang_sent = false;

private function _displayForms(
$show_restore_default, array &$js_default, array &$js
) {
$htmlOutput = '';

$js = array();
$js_default = array();
$tabbed_form = $tabbed_form && (count($this->_forms) > 1);
$validators = PMA_Validator::getValidators($this->_configFile);

$htmlOutput .= PMA_displayFormTop();

if ($tabbed_form) {
$tabs = array();
foreach ($this->_forms as $form) {
$tabs[$form->name] = PMA_lang("Form_$form->name");
}
$htmlOutput .= PMA_displayTabsTop($tabs);
}

// validate 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"])
Expand Down Expand Up @@ -291,6 +261,58 @@ public function getDisplay($tabbed_form = false, $show_restore_default = false)
}
$htmlOutput .= PMA_displayFieldsetBottom();
}
return $htmlOutput;
}

/**
* Outputs HTML for forms
*
* @param bool $tabbed_form if true, use a form with tabs
* @param bool $show_restore_default whether show "restore default" button
* besides the input field
*
* @return void
*/
public function getDisplay($tabbed_form = false, $show_restore_default = false)
{
static $js_lang_sent = false;

$htmlOutput = '';

$js = array();
$js_default = array();
$tabbed_form = $tabbed_form && (count($this->_forms) > 1);

$htmlOutput .= PMA_displayFormTop();

if ($tabbed_form) {
$tabs = array();
foreach ($this->_forms as $form) {
$tabs[$form->name] = PMA_lang("Form_$form->name");
}
$htmlOutput .= PMA_displayTabsTop($tabs);
}

// validate 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
$htmlOutput .= $this->_displayForms(
$show_restore_default, $js_default, $js
);

if ($tabbed_form) {
$htmlOutput .= PMA_displayTabsBottom();
Expand Down

0 comments on commit 4bdd483

Please sign in to comment.