From 60e33b5a59ee02c430a34f9e30d5d566f60f5d8d Mon Sep 17 00:00:00 2001 From: Chanaka Indrajith Date: Sat, 29 Mar 2014 22:41:43 +0530 Subject: [PATCH 1/4] Fixed some code violations Signed-off-by: Chanaka Indrajith --- libraries/DisplayResults.class.php | 54 +++++++++++++++++------------- 1 file changed, 31 insertions(+), 23 deletions(-) diff --git a/libraries/DisplayResults.class.php b/libraries/DisplayResults.class.php index 72bb9b7dd5..18c633f055 100644 --- a/libraries/DisplayResults.class.php +++ b/libraries/DisplayResults.class.php @@ -1907,14 +1907,16 @@ class PMA_DisplayResults /** * Prepare parameters and html for sorted table header fields * - * @param array $fields_meta set of field properties * @param array $sort_expression sort expression * @param array $sort_expression_nodirection sort expression without direction - * @param array $sort_direction sort direction - * @param string $name_to_use_in_sort The current column under consideration - * @param string $sort_tbl The name of the table to which the - * current column belongs to - * @param integer $column_index The index number to the current column + * @param string $sort_tbl The name of the table to which + * the current column belongs to + * @param string $name_to_use_in_sort The current column under + * consideration + * @param array $sort_direction sort direction + * @param array $fields_meta set of field properties + * @param integer $column_index The index number to current column + * * @return array 2 element array - $order_link, $sorted_header_html * * @access private @@ -1922,9 +1924,8 @@ class PMA_DisplayResults * @see _getTableHeaders() */ private function makeURL( - $sort_expression, $sort_expression_nodirection, - $sort_tbl, $name_to_use_in_sort, $sort_direction, $fields_meta, - $column_index + $sort_expression, $sort_expression_nodirection, $sort_tbl, + $name_to_use_in_sort, $sort_direction, $fields_meta, $column_index ) { $sort_order = ""; // Check if the current column is in the order by clause @@ -1970,8 +1971,8 @@ class PMA_DisplayResults // $name_to_use_in_sort might contain a space due to // formatting of function expressions like "COUNT(name )" // so we remove the space in this situation - $name_to_use_in_sort = str_replace(' )', ')', $name_to_use_in_sort); - $name_to_use_in_sort = str_replace('`','',$name_to_use_in_sort); + $name_to_use_in_sort = str_replace(' )', ')', $name_to_use_in_sort); + $name_to_use_in_sort = str_replace('`', '', $name_to_use_in_sort); // If this the first column name in the order by clause add // order by clause to the column name @@ -2006,7 +2007,7 @@ class PMA_DisplayResults } // remove the comma from the last column name in the newly // constructed clause - $sort_order = substr($sort_order,0,strlen($sort_order)-2); + $sort_order = substr($sort_order, 0, strlen($sort_order)-2); return array($sort_order, $order_img); } @@ -2032,7 +2033,7 @@ class PMA_DisplayResults $index_in_expression = 0; foreach ($sort_expression_nodirection as $index => $clause) { - if (strpos($clause,'.') !== false) { + if (strpos($clause, '.') !== false) { $fragments = explode('.', $clause); $clause2 = $fragments[0] . "." . str_replace('`', ``, $fragments[1]); } else { @@ -2062,7 +2063,8 @@ class PMA_DisplayResults $new_sort_expression_nodirection = $sort_tbl . $sort_expression_nodirection[$index_in_expression]; } else { - $new_sort_expression_nodirection = $sort_expression_nodirection[$index_in_expression]; + $new_sort_expression_nodirection + = $sort_expression_nodirection[$index_in_expression]; } //Back quotes are removed in next comparison, so remove them from value @@ -2092,8 +2094,9 @@ class PMA_DisplayResults * @param array $fields_meta set of field properties * @param array $sort_order the sorting order * @param integer $column_index the index of the column + * @param integer $index the index of sort direction array. * - * @return array 2 element array - $sort_order, $order_img + * @return array 2 element array - $sort_order, $order_img * * @access private * @@ -2101,10 +2104,10 @@ class PMA_DisplayResults */ private function _getSortingUrlParams( $is_in_sort, $sort_direction, $fields_meta, $sort_order, $column_index, $sort_tbl, $index - ) { + ) { - $index2 = $index + 1; - if (strtoupper(trim($sort_direction[$index])) == self::DESCENDING_SORT_DIR) { + $index2 = $index + 1; + if (strtoupper(trim($sort_direction[$index])) == self::DESCENDING_SORT_DIR) { $sort_number = "".$index2.""; $sort_order .= ' ASC'; @@ -4636,8 +4639,10 @@ class PMA_DisplayResults // 1.3 Find the sort expression // we need $sort_expression and $sort_expression_nodirection // even if there are many table references - list($sort_expression, $sort_expression_nodirection, $sort_direction,$number_of_columns) - = $this->_getSortParams($analyzed_sql[0]['order_by_clause']); + list( + $sort_expression, $sort_expression_nodirection, + $sort_direction,$number_of_columns + ) = $this->_getSortParams($analyzed_sql[0]['order_by_clause']); // 1.4 Prepares display of first and last value of the sorted column @@ -4845,16 +4850,19 @@ class PMA_DisplayResults * Get rid of ASC|DESC */ preg_match( - '@(.*)([[:space:]]*(ASC|DESC))@si', $sort_expression[$index], $matches + '@(.*)([[:space:]]*(ASC|DESC))@si', + $sort_expression[$index], $matches ); $sort_expression_nodirection[$index] = isset($matches[1]) ? trim($matches[1]) : $sort_expression[$index]; - $sort_direction[$index] = isset($matches[2]) ? trim($matches[2]) : ''; + $sort_direction[$index] + = isset($matches[2]) ? trim($matches[2]) : ''; } } else { - $sort_expression[0] = $sort_expression_nodirection[0] = $sort_direction[0] = ''; + $sort_expression[0] = $sort_expression_nodirection[0] + = $sort_direction[0] = ''; } return array($sort_expression, $sort_expression_nodirection, From 4071c6eaa66560de7d1f8f08ab2f8a6a5a4b8b8e Mon Sep 17 00:00:00 2001 From: Chanaka Indrajith Date: Sat, 29 Mar 2014 22:52:39 +0530 Subject: [PATCH 2/4] Remove unused parameters in _getSortingUrlParams() function Signed-off-by: Chanaka Indrajith --- libraries/DisplayResults.class.php | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/libraries/DisplayResults.class.php b/libraries/DisplayResults.class.php index 18c633f055..acb972adf4 100644 --- a/libraries/DisplayResults.class.php +++ b/libraries/DisplayResults.class.php @@ -1995,8 +1995,7 @@ class PMA_DisplayResults // We need to generate the arrow button and related html if ($current_name == $name_to_use_in_sort && $is_in_sort) { list($sort_order, $order_img) = $this->_getSortingUrlParams( - $is_in_sort, $sort_direction, $fields_meta, - $sort_order, $column_index, $sort_tbl_new, $index + $sort_direction, $sort_order, $column_index, $index ); } else { $sort_order .= strtoupper($sort_direction[$index]); @@ -2089,9 +2088,7 @@ class PMA_DisplayResults /** * Get sort url paramaeters - sort order and order image * - * @param boolean $is_in_sort the column sorted or not * @param array $sort_direction the sort direction - * @param array $fields_meta set of field properties * @param array $sort_order the sorting order * @param integer $column_index the index of the column * @param integer $index the index of sort direction array. @@ -2100,10 +2097,10 @@ class PMA_DisplayResults * * @access private * - * @see _getTableHeaders() + * @see makeURL() */ private function _getSortingUrlParams( - $is_in_sort, $sort_direction, $fields_meta, $sort_order, $column_index, $sort_tbl, $index + $sort_direction, $sort_order, $column_index, $index ) { $index2 = $index + 1; From d27bbe6f9d623e07391f7d3ef46ca0977e716a23 Mon Sep 17 00:00:00 2001 From: Chanaka Indrajith Date: Sat, 29 Mar 2014 23:04:14 +0530 Subject: [PATCH 3/4] Fixed naming convention for private method makeURL Signed-off-by: Chanaka Indrajith --- libraries/DisplayResults.class.php | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/libraries/DisplayResults.class.php b/libraries/DisplayResults.class.php index acb972adf4..7e2c5e3849 100644 --- a/libraries/DisplayResults.class.php +++ b/libraries/DisplayResults.class.php @@ -1864,10 +1864,9 @@ class PMA_DisplayResults // Generates the orderby clause part of the query which is part // of URL - list($sort_order, $order_img) = $this->makeUrl( - $sort_expression, $sort_expression_nodirection, - $sort_tbl, $name_to_use_in_sort, $sort_direction, $fields_meta, - $column_index + list($sort_order, $order_img) = $this->_makeUrl( + $sort_expression, $sort_expression_nodirection, $sort_tbl, + $name_to_use_in_sort, $sort_direction, $fields_meta, $column_index ); if (preg_match( @@ -1921,9 +1920,9 @@ class PMA_DisplayResults * * @access private * - * @see _getTableHeaders() + * @see _getOrderLinkAndSortedHeaderHtml() */ - private function makeURL( + private function _makeUrl( $sort_expression, $sort_expression_nodirection, $sort_tbl, $name_to_use_in_sort, $sort_direction, $fields_meta, $column_index ) { @@ -2097,7 +2096,7 @@ class PMA_DisplayResults * * @access private * - * @see makeURL() + * @see _makeUrl() */ private function _getSortingUrlParams( $sort_direction, $sort_order, $column_index, $index From a2caec9cc62e4f01f970ce1adb75de560b01f2c4 Mon Sep 17 00:00:00 2001 From: Chanaka Indrajith Date: Sun, 30 Mar 2014 00:10:31 +0530 Subject: [PATCH 4/4] Remove unused parameters Signed-off-by: Chanaka Indrajith --- libraries/DisplayResults.class.php | 28 ++++++++++------------------ 1 file changed, 10 insertions(+), 18 deletions(-) diff --git a/libraries/DisplayResults.class.php b/libraries/DisplayResults.class.php index 7e2c5e3849..1fa4c7701e 100644 --- a/libraries/DisplayResults.class.php +++ b/libraries/DisplayResults.class.php @@ -1829,8 +1829,6 @@ 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 * * @return array 2 element array - $order_link, $sorted_header_html * @@ -1841,8 +1839,7 @@ class PMA_DisplayResults private function _getOrderLinkAndSortedHeaderHtml( $fields_meta, $sort_expression, $sort_expression_nodirection, $column_index, $unsorted_sql_query, $session_max_rows, $direction, - $comments, $sort_direction, $directionCondition, $col_visib, - $col_visib_j, $condition_field, $is_last_field + $comments, $sort_direction, $directionCondition, $col_visib, $col_visib_j ) { $sorted_header_html = ''; @@ -1895,7 +1892,7 @@ class PMA_DisplayResults ); $sorted_header_html .= $this->_getDraggableClassForSortableColumns( - $col_visib, $col_visib_j, $condition_field, $direction, + $col_visib, $col_visib_j, $direction, $fields_meta, $order_link, $comments ); @@ -2201,14 +2198,13 @@ class PMA_DisplayResults /** * Prepare columns to draggable effect for sortable columns * - * @param boolean $col_visib the column is visible (false) - * array the column is not visible (string array) - * @param string $col_visib_j element of $col_visib array - * @param boolean $condition_field whether to add CSS class condition - * @param string $direction the display direction - * @param array $fields_meta set of field properties - * @param string $order_link the order link - * @param string $comments the comment for the column + * @param boolean $col_visib the column is visible (false) + * array the column is not visible (string array) + * @param string $col_visib_j element of $col_visib array + * @param string $direction the display direction + * @param array $fields_meta set of field properties + * @param string $order_link the order link + * @param string $comments the comment for the column * * @return string $draggable_html html content * @@ -2217,7 +2213,7 @@ class PMA_DisplayResults * @see _getTableHeaders() */ private function _getDraggableClassForSortableColumns( - $col_visib, $col_visib_j, $condition_field, $direction, $fields_meta, + $col_visib, $col_visib_j, $direction, $fields_meta, $order_link, $comments ) { @@ -2229,10 +2225,6 @@ class PMA_DisplayResults $th_class[] = 'hide'; } - if ($condition_field) { - $th_class[] = 'condition'; - } - $th_class[] = 'column_heading'; if ($GLOBALS['cfg']['BrowsePointerEnable'] == true) { $th_class[] = 'pointer';