From a97b9b92d27f70f72f65fb896e1c2ee444d3d01a Mon Sep 17 00:00:00 2001 From: Chanaka Indrajith Date: Tue, 10 Jul 2012 21:56:48 +0530 Subject: [PATCH 1/2] Fix some code violations in PMA_DisplayResults class --- libraries/DisplayResults.class.php | 128 ++++++++++++++++++----------- 1 file changed, 78 insertions(+), 50 deletions(-) diff --git a/libraries/DisplayResults.class.php b/libraries/DisplayResults.class.php index 6882a0dfe6..26df14a636 100644 --- a/libraries/DisplayResults.class.php +++ b/libraries/DisplayResults.class.php @@ -152,9 +152,11 @@ class PMA_DisplayResults * Get any property of this class * * @param string $property name of the property + * * @return if property exist, value of the relavant property */ - public function __get($property) { + public function __get($property) + { if (property_exists($this, $property)) { return $this->$property; @@ -167,9 +169,12 @@ class PMA_DisplayResults * Set values for any property of this class * * @param string $property name of the property - * @param $value value to set + * @param type $value value to set + * + * @return void */ - public function __set($property, $value) { + public function __set($property, $value) + { if (property_exists($this, $property)) { $this->$property = $value; @@ -334,8 +339,8 @@ class PMA_DisplayResults $do_display['text_btn'] = (string) '0'; $do_display['pview_lnk'] = (string) '0'; - } elseif ($this->__get ('_is_count') || $this->__get ('_is_analyse') - || $this->__get ('_is_maint') || $this->__get ('_is_explain') + } elseif ($this->__get('_is_count') || $this->__get('_is_analyse') + || $this->__get('_is_maint') || $this->__get('_is_explain') ) { // 2.1 Statement is a "SELECT COUNT", a // "CHECK/ANALYZE/REPAIR/OPTIMIZE", an "EXPLAIN" one or @@ -347,14 +352,14 @@ class PMA_DisplayResults $do_display['ins_row'] = (string) '0'; $do_display['bkm_form'] = (string) '1'; - if ($this->__get ('_is_maint')) { + if ($this->__get('_is_maint')) { $do_display['text_btn'] = (string) '1'; } else { $do_display['text_btn'] = (string) '0'; } $do_display['pview_lnk'] = (string) '1'; - } elseif ($this->__get ('_is_show')) { + } elseif ($this->__get('_is_show')) { // 2.2 Statement is a "SHOW..." /** * 2.2.1 @@ -480,8 +485,8 @@ class PMA_DisplayResults */ private function _isSelect($analyzed_sql) { - return ! ($this->__get ('_is_count') || $this->__get('_is_export') - || $this->__get('_is_func') || $this->__get ('_is_analyse')) + return ! ($this->__get('_is_count') || $this->__get('_is_export') + || $this->__get('_is_func') || $this->__get('_is_analyse')) && (count($analyzed_sql[0]['select_expr']) == 0) && isset($analyzed_sql[0]['queryflags']['select_from']) && (count($analyzed_sql[0]['table_ref']) == 1); @@ -527,11 +532,14 @@ class PMA_DisplayResults return '' . '
' - . PMA_generate_common_hidden_inputs($this->__get('_db'), $this->__get('_table')) + . PMA_generate_common_hidden_inputs( + $this->__get('_db'), $this->__get('_table') + ) . '' . '' - . '' + . '' . $input_for_real_end . '' . '' - . PMA_generate_common_hidden_inputs($this->__get('_db'), $this->__get('_table')) + . PMA_generate_common_hidden_inputs( + $this->__get('_db'), $this->__get('_table') + ) . '' . '' . '' - . '' + . '' . '' . '
' . ''; @@ -819,7 +830,8 @@ class PMA_DisplayResults $onsubmit = 'onsubmit="return ' . ($_SESSION['tmp_user_values']['pos'] - + $_SESSION['tmp_user_values']['max_rows'] < $this->__get('_unlim_num_rows') + + $_SESSION['tmp_user_values']['max_rows'] + < $this->__get('_unlim_num_rows') && $this->__get('_num_rows') >= $_SESSION['tmp_user_values']['max_rows']) ? 'true' : 'false' . '"'; @@ -828,8 +840,10 @@ class PMA_DisplayResults $buttons_html .= $this->_getTableNavigationButton( '>>', _pgettext('Last page', 'End'), - @((ceil($this->__get('_unlim_num_rows') / $_SESSION['tmp_user_values']['max_rows'])- 1) - * $_SESSION['tmp_user_values']['max_rows']), + @((ceil( + $this->__get('_unlim_num_rows') + / $_SESSION['tmp_user_values']['max_rows'] + )- 1) * $_SESSION['tmp_user_values']['max_rows']), $html_sql_query, $onsubmit, $input_for_real_end, $onclick ); @@ -861,7 +875,8 @@ class PMA_DisplayResults $additional_fields_html .= '' - . '' + . '' . '' @@ -908,11 +923,11 @@ class PMA_DisplayResults /** * Get the headers of the results table * - * @param array &$is_display which elements to display - * @param array $analyzed_sql the analyzed query - * @param string $sort_expression sort expression - * @param string $sort_expression_nodirection sort expression without direction - * @param string $sort_direction sort direction + * @param array &$is_display which elements to display + * @param array $analyzed_sql the analyzed query + * @param string $sort_expression sort expression + * @param string $sort_expression_nodirection sort expression without direction + * @param string $sort_direction sort direction * * @return string html content * @@ -967,7 +982,9 @@ class PMA_DisplayResults $table_headers_html .= '' . '
' - . PMA_generate_common_hidden_inputs($this->__get('_db'), $this->__get('_table')) + . PMA_generate_common_hidden_inputs( + $this->__get('_db'), $this->__get('_table') + ) . '
'; // Output data needed for column reordering and show/hide column @@ -1021,7 +1038,10 @@ class PMA_DisplayResults && ! $_SESSION['tmp_user_values']['hide_transformation'] ) { include_once './libraries/transformations.lib.php'; - $this->__set('_mime_map', PMA_getMIME($this->__get('_db'), $this->__get('_table'))); + $this->__set( + '_mime_map', + PMA_getMIME($this->__get('_db'), $this->__get('_table')) + ); } // See if we have to highlight any header fields of a WHERE query. @@ -1108,8 +1128,8 @@ class PMA_DisplayResults /** * Prepare unsorted sql query and sort by key drop down * - * @param array $analyzed_sql the analyzed query - * @param string $sort_expression sort expression + * @param array $analyzed_sql the analyzed query + * @param string $sort_expression sort expression * * @return array two element array - $unsorted_sql_query, $drop_down_html * @@ -1143,7 +1163,9 @@ class PMA_DisplayResults ) { // grab indexes data: - $indexes = PMA_Index::getFromTable($this->__get('_table'), $this->__get('_db')); + $indexes = PMA_Index::getFromTable( + $this->__get('_table'), $this->__get('_db') + ); // do we have any index? if ($indexes) { @@ -1179,7 +1201,9 @@ class PMA_DisplayResults $drop_down_html = ''; $drop_down_html .= '
' . "\n" - . PMA_generate_common_hidden_inputs($this->__get('_db'), $this->__get('_table')) + . PMA_generate_common_hidden_inputs( + $this->__get('_db'), $this->__get('_table') + ) . __('Sort by key') . ': ' . "\n"; } @@ -1744,8 +1770,8 @@ class PMA_DisplayResults * @param boolean $col_visib column is visible(false) * array column isn't visible(string array) * @param string $col_visib_j element of $col_visib array - * @param boolean $condition_field whether the column is a part of the - * where clause + * @param boolean $condition_field whether the column is a part of + * the where clause * * @return array 2 element array - $order_link, $sorted_header_html * @@ -2468,7 +2494,8 @@ class PMA_DisplayResults */ list($where_clause, $clause_is_unique, $condition_array) = $this->getCommonFunctions()->getUniqueCondition( - $dt_result, $this->__get('_fields_cnt'), $this->__get('_fields_meta'), $row + $dt_result, $this->__get('_fields_cnt'), + $this->__get('_fields_meta'), $row ); $where_clause_html = urlencode($where_clause); @@ -3610,7 +3637,7 @@ class PMA_DisplayResults $is_field_truncated, $analyzed_sql, &$dt_result, $col_index ) { - $is_analyse = $this->__get ('_is_analyse'); + $is_analyse = $this->__get('_is_analyse'); if (! isset($column) || is_null($column)) { @@ -3881,7 +3908,7 @@ class PMA_DisplayResults /** * Prepare edit, copy and delete links for verticle table * - * @param string $operation edit/copy/delete + * @param string $operation edit/copy/delete * * @return string $links_html html content * @@ -3889,7 +3916,8 @@ class PMA_DisplayResults * * @see _getVerticalTable() */ - private function _getOperationLinksForVerticleTable($operation) { + private function _getOperationLinksForVerticleTable($operation) + { $link_html = '' . "\n"; $vertical_display = $this->__get('_vertical_display'); @@ -3921,9 +3949,9 @@ class PMA_DisplayResults /** * Get checkboxes for multiple row data operations * - * @param string $dir _left / _right + * @param string $dir _left/_right * - * @return $checkBoxes_html html content + * @return $checkBoxes_html html content * * @access private * @@ -4734,7 +4762,7 @@ class PMA_DisplayResults /** * Set the value of $map array for linking foreign key related tables * - * @param array $map the list of relations + * @param array &$map the list of relations * * @return void * @@ -4871,11 +4899,11 @@ class PMA_DisplayResults /** * Prepare table navigation bar at the top or bottom * - * @param integer $pos_next the offset for the "next" page - * @param integer $pos_prev the offset for the "previous" page - * @param string $place the place to show navigation - * @param string $empty_line empty line depend on the $place - * @param boolean $is_innodb whether its InnoDB or not + * @param integer $pos_next the offset for the "next" page + * @param integer $pos_prev the offset for the "previous" page + * @param string $place the place to show navigation + * @param string $empty_line empty line depend on the $place + * @param boolean $is_innodb whether its InnoDB or not * * @return string html content of navigation bar * @@ -5372,8 +5400,8 @@ class PMA_DisplayResults 'table' => $meta->orgtable, 'pos' => '0', 'sql_query' => 'SELECT * FROM ' - . $this->getCommonFunctions()->backquote($this->__get('_db')) . '.' - . $this->getCommonFunctions()->backquote($meta->orgtable) + . $this->getCommonFunctions()->backquote($this->__get('_db')) + . '.' . $this->getCommonFunctions()->backquote($meta->orgtable) . ' WHERE ' . $this->getCommonFunctions()->backquote($meta->orgname) . $where_comparison, From 65f24f0e363d62a1805e326a74577120bc05229b Mon Sep 17 00:00:00 2001 From: Chanaka Indrajith Date: Wed, 11 Jul 2012 21:09:33 +0530 Subject: [PATCH 2/2] Renamed the function processParams() in PMA_DisplayResults class, to setProperties() --- libraries/DisplayResults.class.php | 4 ++-- sql.php | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/libraries/DisplayResults.class.php b/libraries/DisplayResults.class.php index 26df14a636..cb0614934c 100644 --- a/libraries/DisplayResults.class.php +++ b/libraries/DisplayResults.class.php @@ -243,7 +243,7 @@ class PMA_DisplayResults * * @see sql.php */ - public function processParams( + public function setProperties( $unlim_num_rows, $fields_meta, $is_count, $is_export, $is_func, $is_analyse, $num_rows, $fields_cnt, $querytime, $pmaThemeImage, $text_dir, $is_maint, $is_explain, $is_show, $showtable, $printview, $url_query @@ -267,7 +267,7 @@ class PMA_DisplayResults $this->__set('_printview', $printview); $this->__set('_url_query', $url_query); - } + } // end of the 'setProperties()' function /** diff --git a/sql.php b/sql.php index 5932221a8e..65a50cf440 100644 --- a/sql.php +++ b/sql.php @@ -937,7 +937,7 @@ if ((0 == $num_rows && 0 == $unlim_num_rows) || $is_affected) { $printview = isset($printview) ? $printview : null; $url_query = isset($url_query) ? $url_query : null; - $displayResultsObject->processParams( + $displayResultsObject->setProperties( $unlim_num_rows, $fields_meta, $is_count, $is_export, $is_func, $is_analyse, $num_rows, $fields_cnt, $querytime, $pmaThemeImage, $text_dir, $is_maint, $is_explain, $is_show, $showtable, $printview, $url_query @@ -1097,7 +1097,7 @@ $(makeProfilingChart); $printview = isset($printview) ? $printview : null; $url_query = isset($url_query) ? $url_query : null; - $displayResultsObject->processParams( + $displayResultsObject->setProperties( $unlim_num_rows, $fields_meta, $is_count, $is_export, $is_func, $is_analyse, $num_rows, $fields_cnt, $querytime, $pmaThemeImage, $text_dir, $is_maint, $is_explain, $is_show, $showtable, $printview, $url_query