diff options
-rw-r--r-- | libraries/DisplayResults.class.php | 18 | ||||
-rw-r--r-- | libraries/Scripts.class.php | 71 | ||||
-rw-r--r-- | setup/frames/form.inc.php | 2 | ||||
-rw-r--r-- | setup/frames/servers.inc.php | 2 | ||||
-rw-r--r-- | setup/lib/form_processing.lib.php | 94 | ||||
-rw-r--r-- | test/libraries/PMA_Form_Processing_test.php | 6 |
6 files changed, 106 insertions, 87 deletions
diff --git a/libraries/DisplayResults.class.php b/libraries/DisplayResults.class.php index 6695dca96b..4ca3e04845 100644 --- a/libraries/DisplayResults.class.php +++ b/libraries/DisplayResults.class.php @@ -5594,17 +5594,19 @@ class PMA_DisplayResults $alias = $analyzed_sql[0]['select_expr'] [$select_expr_position]['alias']; - if (isset($alias) && strlen($alias)) { - $true_column = $analyzed_sql[0]['select_expr'] - [$select_expr_position]['column']; + if (!isset($alias) || !strlen($alias)) { + continue; + } // end if - if ($alias == $meta->name) { - // this change in the parameter does not matter - // outside of the function - $meta->name = $true_column; - } // end if + $true_column = $analyzed_sql[0]['select_expr'] + [$select_expr_position]['column']; + if ($alias == $meta->name) { + // this change in the parameter does not matter + // outside of the function + $meta->name = $true_column; } // end if + } // end foreach } // end if diff --git a/libraries/Scripts.class.php b/libraries/Scripts.class.php index 965b90b6d2..957ffedf9c 100644 --- a/libraries/Scripts.class.php +++ b/libraries/Scripts.class.php @@ -52,25 +52,25 @@ class PMA_Scripts { $dynamic_scripts = ""; foreach ($files as $value) { - if (strpos($value['filename'], "?") === false) { - $include = true; - if ($value['conditional_ie'] !== false - && PMA_USR_BROWSER_AGENT === 'IE' - ) { - if ($value['conditional_ie'] === true) { - $include = true; - } else if ($value['conditional_ie'] == PMA_USR_BROWSER_VER) { - $include = true; - } else { - $include = false; - } - } - if ($include) { - $scripts[] = "scripts[]=" . $value['filename']; - } - } else { + if (strpos($value['filename'], "?") !== false) { $dynamic_scripts .= "<script type='text/javascript' src='js/" . $value['filename'] . "'></script>"; + continue; + } + $include = true; + if ($value['conditional_ie'] !== false + && PMA_USR_BROWSER_AGENT === 'IE' + ) { + if ($value['conditional_ie'] === true) { + $include = true; + } else if ($value['conditional_ie'] == PMA_USR_BROWSER_VER) { + $include = true; + } else { + $include = false; + } + } + if ($include) { + $scripts[] = "scripts[]=" . $value['filename']; } } $static_scripts = sprintf( @@ -106,14 +106,16 @@ class PMA_Scripts public function addFile($filename, $conditional_ie = false) { $hash = md5($filename); - if (empty($this->_files[$hash])) { - $has_onload = $this->_eventBlacklist($filename); - $this->_files[$hash] = array( - 'has_onload' => $has_onload, - 'filename' => $filename, - 'conditional_ie' => $conditional_ie - ); + if (!empty($this->_files[$hash])) { + return; } + + $has_onload = $this->_eventBlacklist($filename); + $this->_files[$hash] = array( + 'has_onload' => $has_onload, + 'filename' => $filename, + 'conditional_ie' => $conditional_ie + ); } /** @@ -135,9 +137,9 @@ class PMA_Scripts || strpos($filename, 'cross_framing_protection.js') !== false ) { return 0; - } else { - return 1; } + + return 1; } /** @@ -180,13 +182,16 @@ class PMA_Scripts { $retval = array(); foreach ($this->_files as $file) { - if (strpos($file['filename'], "?") === false) { - if (! $file['conditional_ie'] || PMA_USR_BROWSER_AGENT == 'IE') { - $retval[] = array( - 'name' => $file['filename'], - 'fire' => $file['has_onload'] - ); - } + //If filename contains a "?", continue. + if (strpos($file['filename'], "?") !== false) { + continue; + } + + if (! $file['conditional_ie'] || PMA_USR_BROWSER_AGENT == 'IE') { + $retval[] = array( + 'name' => $file['filename'], + 'fire' => $file['has_onload'] + ); } } return $retval; diff --git a/setup/frames/form.inc.php b/setup/frames/form.inc.php index c747e06ef3..ac9d00b395 100644 --- a/setup/frames/form.inc.php +++ b/setup/frames/form.inc.php @@ -32,5 +32,5 @@ $form_display = new FormDisplay($GLOBALS['ConfigFile']); foreach ($forms[$formset_id] as $form_name => $form) { $form_display->registerForm($form_name, $form); } -process_formset($form_display); +PMA_process_formset($form_display); ?> diff --git a/setup/frames/servers.inc.php b/setup/frames/servers.inc.php index 10c02ac9cd..133f87a0a3 100644 --- a/setup/frames/servers.inc.php +++ b/setup/frames/servers.inc.php @@ -46,5 +46,5 @@ $form_display = new FormDisplay($cf); foreach ($forms['Servers'] as $form_name => $form) { $form_display->registerForm($form_name, $form, $id); } -process_formset($form_display); +PMA_process_formset($form_display); ?> diff --git a/setup/lib/form_processing.lib.php b/setup/lib/form_processing.lib.php index 9ca3b5317a..8b9e825722 100644 --- a/setup/lib/form_processing.lib.php +++ b/setup/lib/form_processing.lib.php @@ -9,59 +9,71 @@ /** * Processes forms registered in $form_display, handles error correction * - * @param FormDisplay $form_display + * @param FormDisplay $form_display Form to display * * @return void */ -function process_formset(FormDisplay $form_display) +function PMA_process_formset(FormDisplay $form_display) { if (filter_input(INPUT_GET, 'mode') == 'revert') { // revert erroneous fields to their default values $form_display->fixErrors(); - // drop post data - header('HTTP/1.1 303 See Other'); - header('Location: index.php'); - - if (!defined('TESTSUITE')) { - exit; - } + PMA_generateHeader303(); } + if (!$form_display->process(false)) { // handle form view and failed POST $form_display->display(true, true); - } else { - // check for form errors - if ($form_display->hasErrors()) { - // form has errors, show warning - $separator = PMA_URL_getArgSeparator('html'); - $page = filter_input(INPUT_GET, 'page'); - $formset = filter_input(INPUT_GET, 'formset'); - $formset = $formset ? "{$separator}formset=$formset" : ''; - $id = filter_input(INPUT_GET, 'id', FILTER_VALIDATE_INT); - if ($id === null && $page == 'servers') { - // we've just added a new server, get it's id - $id = $form_display->getConfigFile()->getServerCount(); - } - $id = $id ? "{$separator}id=$id" : ''; + return; + } + + // check for form errors + if (!$form_display->hasErrors()) { + PMA_generateHeader303(); + return; + } + + // form has errors, show warning + $separator = PMA_URL_getArgSeparator('html'); + $page = filter_input(INPUT_GET, 'page'); + $formset = filter_input(INPUT_GET, 'formset'); + $formset = $formset ? "{$separator}formset=$formset" : ''; + $id = filter_input(INPUT_GET, 'id', FILTER_VALIDATE_INT); + if ($id === null && $page == 'servers') { + // we've just added a new server, get it's id + $id = $form_display->getConfigFile()->getServerCount(); + } + $id = $id ? "{$separator}id=$id" : ''; + ?> + <div class="error"> + <h4><?php echo __('Warning') ?></h4> + <?php echo __('Submitted form contains errors') ?><br /> + <a href="?page=<?php echo $page . $formset . $id . $separator ?>mode=revert"> + <?php echo __('Try to revert erroneous fields to their default values') ?> - <div class="error"> - <h4><?php echo __('Warning') ?></h4> - <?php echo __('Submitted form contains errors') ?><br /> - <a href="?page=<?php echo $page . $formset . $id . $separator ?>mode=revert"><?php echo __('Try to revert erroneous fields to their default values') ?></a> - </div> - <?php $form_display->displayErrors() ?> - <a class="btn" href="index.php"><?php echo __('Ignore errors') ?></a> - - <a class="btn" href="?page=<?php echo $page . $formset . $id . $separator ?>mode=edit"><?php echo __('Show form') ?></a> - <?php - } else { - // drop post data - header('HTTP/1.1 303 See Other'); - header('Location: index.php'); - if (!defined('TESTSUITE')) { - exit; - } - } + </a> + </div> + <?php $form_display->displayErrors() ?> + <a class="btn" href="index.php"><?php echo __('Ignore errors') ?></a> + + <a class="btn" href="?page=<?php echo $page . $formset . $id + . $separator ?>mode=edit"><?php echo __('Show form') ?></a> + <?php +} + +/** + * Generate header for 303 + * + * @return void + */ +function PMA_generateHeader303() +{ + // drop post data + header('HTTP/1.1 303 See Other'); + header('Location: index.php'); + + if (!defined('TESTSUITE')) { + exit; } } ?> diff --git a/test/libraries/PMA_Form_Processing_test.php b/test/libraries/PMA_Form_Processing_test.php index 2a2eaadb5a..0b6f608603 100644 --- a/test/libraries/PMA_Form_Processing_test.php +++ b/test/libraries/PMA_Form_Processing_test.php @@ -50,7 +50,7 @@ class PMA_From_Processing_Test extends PHPUnit_Framework_TestCase ->method('display') ->with(true, true); - process_formset($formDisplay); + PMA_process_formset($formDisplay); // case 2 $formDisplay = $this->getMockBuilder('FormDisplay') @@ -69,7 +69,7 @@ class PMA_From_Processing_Test extends PHPUnit_Framework_TestCase ->will($this->returnValue(true)); ob_start(); - process_formset($formDisplay); + PMA_process_formset($formDisplay); $result = ob_get_clean(); $this->assertContains( @@ -108,7 +108,7 @@ class PMA_From_Processing_Test extends PHPUnit_Framework_TestCase ->with() ->will($this->returnValue(false)); - process_formset($formDisplay); + PMA_process_formset($formDisplay); $this->assertEquals( array('HTTP/1.1 303 See Other', 'Location: index.php'), |