diff --git a/libraries/config/FormDisplay.class.php b/libraries/config/FormDisplay.class.php index 360fd7790b..81565fe564 100644 --- a/libraries/config/FormDisplay.class.php +++ b/libraries/config/FormDisplay.class.php @@ -213,23 +213,25 @@ class FormDisplay * * @return void */ - public function display($tabbed_form = false, $show_restore_default = false) + 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); $validators = PMA_Validator::getValidators($this->_configFile); - PMA_displayFormTop(); + $htmlOutput .= PMA_displayFormTop(); if ($tabbed_form) { $tabs = array(); foreach ($this->_forms as $form) { $tabs[$form->name] = PMA_lang("Form_$form->name"); } - PMA_displayTabsTop($tabs); + $htmlOutput .= PMA_displayTabsTop($tabs); } // validate only when we aren't displaying a "new server" form @@ -256,7 +258,7 @@ class FormDisplay : ''; $form_errors = isset($this->_errors[$form->name]) ? $this->_errors[$form->name] : null; - PMA_displayFieldsetTop( + $htmlOutput .= PMA_displayFieldsetTop( PMA_lang("Form_$form->name"), $form_desc, $form_errors, @@ -272,7 +274,7 @@ class FormDisplay ? !isset($this->_userprefsDisallow[$path]) : null; // display input - $this->_displayFieldInput( + $htmlOutput .= $this->_displayFieldInput( $form, $field, $path, @@ -287,13 +289,13 @@ class FormDisplay PMA_addJsValidate($translated_path, $validators[$path], $js); } } - PMA_displayFieldsetBottom(); + $htmlOutput .= PMA_displayFieldsetBottom(); } if ($tabbed_form) { - PMA_displayTabsBottom(); + $htmlOutput .= PMA_displayTabsBottom(); } - PMA_displayFormBottom(); + $htmlOutput .= PMA_displayFormBottom(); // if not already done, send strings used for validation to JavaScript if (! $js_lang_sent) { @@ -308,7 +310,9 @@ class FormDisplay $js[] = "$.extend(defaultValues, {\n\t" . implode(",\n\t", $js_default) . '})'; - PMA_displayJavascript($js); + $htmlOutput .= PMA_displayJavascript($js); + + return $htmlOutput; } /** @@ -384,7 +388,7 @@ class FormDisplay case 'group': // :group:end is changed to :group:end:{unique id} in Form class if (/*overload*/mb_substr($field, 7, 4) != 'end:') { - PMA_displayGroupHeader(/*overload*/mb_substr($field, 7)); + echo PMA_displayGroupHeader(/*overload*/mb_substr($field, 7)); } else { PMA_displayGroupFooter(); } @@ -436,7 +440,7 @@ class FormDisplay } $js_default[] = $js_line; - PMA_displayInput( + return PMA_displayInput( $translated_path, $name, $type, $value, $description, $value_is_default, $opts ); @@ -454,6 +458,8 @@ class FormDisplay return; } + $htmlOutput = ''; + foreach ($this->_errors as $system_path => $error_list) { if (isset($this->_systemPaths[$system_path])) { $path = $this->_systemPaths[$system_path]; @@ -461,8 +467,9 @@ class FormDisplay } else { $name = $GLOBALS["strConfigForm_$system_path"]; } - PMA_displayErrors($name, $error_list); + $htmlOutput .= PMA_displayErrors($name, $error_list); } + return $htmlOutput; } /** diff --git a/libraries/config/FormDisplay.tpl.php b/libraries/config/FormDisplay.tpl.php index 451cd675fe..096b6f7e53 100644 --- a/libraries/config/FormDisplay.tpl.php +++ b/libraries/config/FormDisplay.tpl.php @@ -25,18 +25,19 @@ function PMA_displayFormTop($action = null, $method = 'post', $hidden_fields = n if ($method != 'post') { $method = 'get'; } - echo '
'; - echo ''; + $htmlOutput .= ''; // we do validation on page refresh when browser remembers field values, // add a field with known value which will be used for checks if (! $has_check_page_refresh) { $has_check_page_refresh = true; - echo '' . "\n"; } - echo PMA_URL_getHiddenInputs('', '', 0, 'server') . "\n"; - echo PMA_getHiddenFields((array)$hidden_fields); + $htmlOutput .= PMA_URL_getHiddenInputs('', '', 0, 'server') . "\n"; + $htmlOutput .= PMA_getHiddenFields((array)$hidden_fields); + return $htmlOutput; } /** @@ -49,14 +50,15 @@ function PMA_displayFormTop($action = null, $method = 'post', $hidden_fields = n */ function PMA_displayTabsTop($tabs) { - echo ''; + $htmlOutput .= '
'; + $htmlOutput .= '
'; + return $htmlOutput; } @@ -82,20 +84,21 @@ function PMA_displayFieldsetTop($title = '', $description = '', $errors = null, $attr = $k . '="' . htmlspecialchars($attr) . '"'; } - echo '
'; - echo '' . $title . ''; + $htmlOutput = '
'; + $htmlOutput .= '' . $title . ''; if (!empty($description)) { - echo '

' . $description . '

'; + $htmlOutput .= '

' . $description . '

'; } // this must match with displayErrors() in scripts.js if (is_array($errors) && count($errors) > 0) { - echo '
'; + $htmlOutput .= '
'; foreach ($errors as $error) { - echo '
' . $error . '
'; + $htmlOutput .= '
' . $error . '
'; } - echo '
'; + $htmlOutput .= '
'; } - echo ''; + $htmlOutput .= '
'; + return $htmlOutput; } /** @@ -198,56 +201,56 @@ function PMA_displayInput($path, $name, $type, $value, $description = '', } $tr_class = $tr_class ? ' class="' . $tr_class . '"' : ''; - echo ''; - echo ''; - echo ''; + $htmlOutput .= ''; if ($is_setup_script && isset($opts['userprefs_allow'])) { - echo ''; + $htmlOutput .= '/>'; + $htmlOutput .= ''; } else if ($is_setup_script) { - echo ''; + $htmlOutput .= ''; } - echo ''; + $htmlOutput .= ''; + return $htmlOutput; } /** @@ -357,11 +361,12 @@ function PMA_displayGroupHeader($header_text) $colspan = defined('PMA_SETUP') ? 3 : 2; - echo ''; - echo ''; - echo ''; + $htmlOutput = ''; + $htmlOutput .= ''; + $htmlOutput .= ''; + return $htmlOutput; } /** @@ -387,16 +392,17 @@ function PMA_displayFieldsetBottom() if (defined('PMA_SETUP')) { $colspan++; } - echo ''; - echo ''; - echo ''; - echo '
'; - echo ''; + $htmlOutput = ''; + $htmlOutput .= ''; + $htmlOutput .= ''; if (! empty($opts['doc'])) { - echo ''; - echo ''; + $htmlOutput .= '' . $icons['help'] . ''; - echo "\n"; - echo ''; + $htmlOutput .= "\n"; + $htmlOutput .= ''; } if ($option_is_disabled) { - echo '' . __('Disabled') . ""; + $htmlOutput .= '">' . __('Disabled') . ""; } if (!empty($description)) { - echo '' . $description . ''; + $htmlOutput .= '' . $description . ''; } - echo ''; + $htmlOutput .= ''; + $htmlOutput .= ''; switch ($type) { case 'text': - echo ''; break; case 'password': - echo ''; break; case 'short_text': - echo ''; break; case 'number_text': - echo ''; break; case 'checkbox': - echo ''; break; case 'select': - echo ''; $escape = !(isset($opts['values_escaped']) && $opts['values_escaped']); $values_disabled = isset($opts['values_disabled']) ? array_flip($opts['values_disabled']) : array(); @@ -271,19 +274,19 @@ function PMA_displayInput($path, $name, $type, $value, $description = '', $selected = is_bool($value) ? (int) $value === $opt_value_key : $opt_value_key === $value; - echo ''; + $htmlOutput .= '>' . $display . ''; } - echo ''; + $htmlOutput .= ''; break; case 'list': - echo ''; break; @@ -293,50 +296,51 @@ function PMA_displayInput($path, $name, $type, $value, $description = '', if (isset($opts['comment_warning']) && $opts['comment_warning']) { $class .= ' field-comment-warning'; } - echo 'i'; } if ($is_setup_script && isset($opts['userprefs_comment']) && $opts['userprefs_comment'] ) { - echo '' . $icons['tblops'] . ''; } if (isset($opts['setvalue']) && $opts['setvalue']) { - echo ''; } if (isset($opts['show_restore_default']) && $opts['show_restore_default']) { - echo ''; } // this must match with displayErrors() in scripts/config.js if ($has_errors) { - echo "\n
"; + $htmlOutput .= "\n
"; foreach ($opts['errors'] as $error) { - echo '
' . htmlspecialchars($error) . '
'; + $htmlOutput .= '
' . htmlspecialchars($error) . '
'; } - echo '
'; + $htmlOutput .= '
'; } - echo '
'; - echo ''; - echo '  
'; - echo $header_text; - echo '
'; + $htmlOutput .= $header_text; + $htmlOutput .= '
'; - echo ''; + $htmlOutput .= ''; - echo ''; - echo '
'; - echo '
'; + $htmlOutput .= ''; + $htmlOutput .= ''; + $htmlOutput .= ''; + $htmlOutput .= '
'; + return $htmlOutput; } /** @@ -406,8 +412,9 @@ function PMA_displayFieldsetBottom() */ function PMA_displayFieldsetBottomSimple() { - echo ''; - echo ''; + $htmlOutput = ''; + $htmlOutput .= ''; + return $htmlOutput; } /** @@ -417,7 +424,8 @@ function PMA_displayFieldsetBottomSimple() */ function PMA_displayTabsBottom() { - echo "
\n"; + $htmlOutput = "\n"; + return $htmlOutput; } /** @@ -427,7 +435,8 @@ function PMA_displayTabsBottom() */ function PMA_displayFormBottom() { - echo "
\n"; + $htmlOutput = "\n"; + return $htmlOutput; } /** @@ -466,9 +475,10 @@ function PMA_displayJavascript($js_array) if (empty($js_array)) { return; } - echo '' . "\n"; + $htmlOutput = '' . "\n"; + return $htmlOutput; } /** @@ -481,11 +491,12 @@ function PMA_displayJavascript($js_array) */ function PMA_displayErrors($name, $error_list) { - echo '
'; - echo '
' . htmlspecialchars($name) . '
'; + $htmlOutput = '
'; + $htmlOutput .= '
' . htmlspecialchars($name) . '
'; foreach ($error_list as $error) { - echo '
' . htmlspecialchars($error) . '
'; + $htmlOutput .= '
' . htmlspecialchars($error) . '
'; } - echo '
'; + $htmlOutput .= '
'; + return $htmlOutput; } ?> diff --git a/prefs_forms.php b/prefs_forms.php index 1833d9dc27..2167dc54eb 100644 --- a/prefs_forms.php +++ b/prefs_forms.php @@ -84,8 +84,8 @@ if ($form_display->hasErrors()) { ?>
- displayErrors(); ?> + displayErrors(); ?>
display(true, true); +echo $form_display->getDisplay(true, true); diff --git a/prefs_manage.php b/prefs_manage.php index 778eecceb4..9bc28dd9cf 100644 --- a/prefs_manage.php +++ b/prefs_manage.php @@ -115,7 +115,7 @@ if (isset($_POST['submit_export']) ); $msg->display(); echo '
'; - $form_display->displayErrors(); + echo $form_display->displayErrors(); echo '
'; echo '
'; echo PMA_URL_getHiddenInputs() . "\n"; diff --git a/setup/frames/config.inc.php b/setup/frames/config.inc.php index f265160989..04778a04b8 100644 --- a/setup/frames/config.inc.php +++ b/setup/frames/config.inc.php @@ -23,10 +23,10 @@ $config_exists = false; PMA_checkConfigRw($config_readable, $config_writable, $config_exists); echo '

' . __('Configuration file') . '

'; -PMA_displayFormTop('config.php'); +echo PMA_displayFormTop('config.php'); echo ''; -PMA_displayFieldsetTop('config.inc.php', '', null, array('class' => 'simple')); +echo PMA_displayFieldsetTop('config.inc.php', '', null, array('class' => 'simple')); echo ''; echo ''; echo '