/**
  * Test for PMA_displayFieldsetTop()
  *
  * @return void
  */
 public function testDisplayFieldsetTop()
 {
     $attributes = array('name' => 'attrname');
     $errors = array('e1', 'e2');
     $result = PMA_displayFieldsetTop("TitleTest", "DescTest", $errors, $attributes);
     $this->assertContains('<fieldset class="optbox" name="attrname">', $result);
     $this->assertContains('<legend>', $result);
     $this->assertContains('<p>', $result);
     $this->assertContains('<dl class="errors">', $result);
     $this->assertContains('<dd>', $result);
     $this->assertContains('<table width="100%" cellspacing="0">', $result);
 }
 /**
  * Test for PMA_displayFieldsetTop()
  *
  * @return void
  */
 public function testDisplayFieldsetTop()
 {
     $attributes = array('name' => 'attrname');
     $errors = array('e1', 'e2');
     ob_start();
     PMA_displayFieldsetTop("TitleTest", "DescTest", $errors, $attributes);
     $result = ob_get_clean();
     $this->assertTag(PMA_getTagArray('<fieldset class="optbox" name="attrname">'), $result);
     $this->assertTag(PMA_getTagArray('<legend>', array('content' => 'TitleTest', 'parent' => array('tag' => 'fieldset'))), $result);
     $this->assertTag(PMA_getTagArray('<p>', array('content' => 'DescTest')), $result);
     $this->assertTag(PMA_getTagArray('<dl class="errors">'), $result);
     $this->assertTag(PMA_getTagArray('<dd>', array('content' => 'e1', 'parent' => array('tag' => 'dl'))), $result);
     $this->assertTag(PMA_getTagArray('<dd>', array('content' => 'e2', 'parent' => array('tag' => 'dl'))), $result);
     $this->assertTag(PMA_getTagArray('<table width="100%" cellspacing="0">'), $result);
 }
Exemple #3
0
 /**
  * Outputs HTML for the forms under the menu tab
  *
  * @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
  * @param bool  $show_buttons         whether show submit and reset button
  *
  * @return string $htmlOutput
  */
 private function _displayForms($show_restore_default, array &$js_default, array &$js, $show_buttons)
 {
     $htmlOutput = '';
     $validators = Validator::getValidators($this->_configFile);
     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;
         $htmlOutput .= PMA_displayFieldsetTop(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->_systemPaths);
             $translated_path = $this->_translatedPaths[$work_path];
             // always true/false for user preferences display
             // otherwise null
             $userprefs_allow = isset($this->_userprefsKeys[$path]) ? !isset($this->_userprefsDisallow[$path]) : null;
             // display input
             $htmlOutput .= $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])) {
                 PMA_addJsValidate($translated_path, $validators[$path], $js);
             }
         }
         $htmlOutput .= PMA_displayFieldsetBottom($show_buttons);
     }
     return $htmlOutput;
 }
Exemple #4
0
    exit;
}
/**
 * Core libraries.
 */
require_once './libraries/config/FormDisplay.class.php';
require_once './setup/lib/index.lib.php';
require_once './setup/lib/ConfigGenerator.class.php';
$config_readable = false;
$config_writable = false;
$config_exists = false;
PMA_checkConfigRw($config_readable, $config_writable, $config_exists);
echo '<h2>' . __('Configuration file') . '</h2>';
PMA_displayFormTop('config.php');
echo '<input type="hidden" name="eol" value="' . htmlspecialchars(PMA_ifSetOr($_GET['eol'], 'unix')) . '" />';
PMA_displayFieldsetTop('config.inc.php', '', null, array('class' => 'simple'));
echo '<tr>';
echo '<td>';
echo '<textarea cols="50" rows="20" name="textconfig" ' . 'id="textconfig" spellcheck="false">';
echo htmlspecialchars(ConfigGenerator::getConfigFile($GLOBALS['ConfigFile']));
echo '</textarea>';
echo '</td>';
echo '</tr>';
echo '<tr>';
echo '<td class="lastrow" style="text-align: left">';
echo '<input type="submit" name="submit_download" value="' . __('Download') . '" class="green" />';
echo '<input type="submit" name="submit_save" value="' . __('Save') . '"';
if (!$config_writable) {
    echo ' disabled="disabled"';
}
echo '/>';
 /**
  * Outputs HTML for forms
  *
  * @param bool $tabbed_form
  * @param bool $show_restore_default whether show "restore default" button
  *                                   besides the input field
  *
  * @return void
  */
 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();
     PMA_displayFormTop();
     if ($tabbed_form) {
         $tabs = array();
         foreach ($this->_forms as $form) {
             $tabs[$form->name] = PMA_lang("Form_{$form->name}");
         }
         PMA_displayTabsTop($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;
         PMA_displayFieldsetTop(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->_systemPaths);
             $translated_path = $this->_translatedPaths[$work_path];
             // always true/false for user preferences display
             // otherwise null
             $userprefs_allow = isset($this->_userprefsKeys[$path]) ? !isset($this->_userprefsDisallow[$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])) {
                 PMA_addJsValidate($translated_path, $validators[$path], $js);
             }
         }
         PMA_displayFieldsetBottom();
     }
     if ($tabbed_form) {
         PMA_displayTabsBottom();
     }
     PMA_displayFormBottom();
     // if not already done, send strings used for valdiation to JavaScript
     if (!$js_lang_sent) {
         $js_lang_sent = true;
         $js_lang = array();
         foreach ($this->_jsLangStrings 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) . '})';
     PMA_displayJavascript($js);
 }