From 096a9c58f9af2250ee36f8032c60d9f5abc39625 Mon Sep 17 00:00:00 2001 From: Madhura Jayaratne Date: Tue, 10 Jul 2012 21:49:05 +0530 Subject: [PATCH 01/21] White space cleanup --- libraries/DisplayResults.class.php | 424 ++++++++++++++--------------- 1 file changed, 212 insertions(+), 212 deletions(-) diff --git a/libraries/DisplayResults.class.php b/libraries/DisplayResults.class.php index 6882a0dfe6..aa835b35e4 100644 --- a/libraries/DisplayResults.class.php +++ b/libraries/DisplayResults.class.php @@ -29,7 +29,7 @@ class PMA_DisplayResults const POSITION_RIGHT = 'right'; const POSITION_BOTH = 'both'; const POSITION_NONE = 'none'; - + const PLACE_TOP_DIRECTION_DROPDOWN = 'top_direction_dropdown'; const PLACE_BOTTOM_DIRECTION_DROPDOWN = 'bottom_direction_dropdown'; @@ -66,121 +66,121 @@ class PMA_DisplayResults const TABLE_TYPE_INNO_DB = 'InnoDB'; const ALL_ROWS = 'all'; const QUERY_TYPE_SELECT = 'SELECT'; - - + + // Declare global fields /** PMA_CommonFunctions object */ private $_common_functions; - + /** string Database name */ private $_db; - + /** string Table name */ private $_table; - + /** string the URL to go back in case of errors */ private $_goto; - + /** string the SQL query */ private $_sql_query; - + /** * integer the total number of rows returned by the SQL query without any * appended "LIMIT" clause programmatically */ private $_unlim_num_rows; - + /** array meta information about fields */ private $_fields_meta; - + /** boolean */ private $_is_count; - + /** integer */ private $_is_export; - + /** boolean */ private $_is_func; - + /** integer */ private $_is_analyse; - + /** integer the total number of rows returned by the SQL query */ private $_num_rows; - + /** array table definitions */ private $_showtable; - + /** array column names to highlight */ private $_highlight_columns; - + /** array informations used with vertical display mode */ private $_vertical_display; - + /** integer the total number of fields returned by the SQL query */ private $_fields_cnt; - + /** string */ private $_printview; - + /** double time taken for execute the SQL query */ private $_querytime; - + /** string path for theme images directory */ private $_pma_theme_image; - + /** string */ private $_text_dir; - + /** string URL query */ private $_url_query; - + /** boolean */ private $_is_maint; - + /** boolean */ private $_is_explain; - + /** boolean */ private $_is_show; - + /** array mime types information of fields */ private $_mime_map; - - + + /** * 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) { - + if (property_exists($this, $property)) { return $this->$property; } - + } - - + + /** * Set values for any property of this class - * + * * @param string $property name of the property * @param $value value to set */ public function __set($property, $value) { - + if (property_exists($this, $property)) { $this->$property = $value; } - + } - - + + /** * Get CommmonFunctions - * + * * @return CommonFunctions object */ public function getCommonFunctions() @@ -190,8 +190,8 @@ class PMA_DisplayResults } return $this->_common_functions; } - - + + /** * Constructor for PMA_DisplayResults class * @@ -209,33 +209,33 @@ class PMA_DisplayResults $this->__set('_goto', $goto); $this->__set('_sql_query', $sql_query); } - - + + /** * Set properties which were not initialized at the constructor - * + * * @param type $unlim_num_rows integer the total number of rows returned by * the SQL query without any appended * "LIMIT" clause programmatically * @param type $fields_meta array meta information about fields - * @param type $is_count boolean - * @param type $is_export integer - * @param type $is_func boolean - * @param type $is_analyse integer + * @param type $is_count boolean + * @param type $is_export integer + * @param type $is_func boolean + * @param type $is_analyse integer * @param type $num_rows integer total no. of rows returned by SQL query * @param type $fields_cnt integer total no.of fields returned by SQL query * @param type $querytime double time taken for execute the SQL query * @param type $pmaThemeImage string path for theme images directory - * @param type $text_dir string - * @param type $is_maint boolean - * @param type $is_explain boolean - * @param type $is_show boolean + * @param type $text_dir string + * @param type $is_maint boolean + * @param type $is_explain boolean + * @param type $is_show boolean * @param type $showtable array table definitions - * @param type $printview string + * @param type $printview string * @param type $url_query string URL query - * + * * @return void - * + * * @see sql.php */ public function processParams( @@ -243,7 +243,7 @@ class PMA_DisplayResults $is_analyse, $num_rows, $fields_cnt, $querytime, $pmaThemeImage, $text_dir, $is_maint, $is_explain, $is_show, $showtable, $printview, $url_query ) { - + $this->__set('_unlim_num_rows', $unlim_num_rows); $this->__set('_fields_meta', $fields_meta); $this->__set('_is_count', $is_count); @@ -261,7 +261,7 @@ class PMA_DisplayResults $this->__set('_showtable', $showtable); $this->__set('_printview', $printview); $this->__set('_url_query', $url_query); - + } @@ -322,7 +322,7 @@ class PMA_DisplayResults // 2. Display mode is not "false for all elements" -> updates the // display mode if ($the_disp_mode != 'nnnn000000') { - + if (isset($printview) && ($printview == '1')) { // 2.0 Print view -> set all elements to false! $do_display['edit_lnk'] = self::NO_EDIT_OR_DELETE; // no edit link @@ -333,7 +333,7 @@ class PMA_DisplayResults $do_display['bkm_form'] = (string) '0'; $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') ) { @@ -346,7 +346,7 @@ class PMA_DisplayResults $do_display['nav_bar'] = (string) '0'; $do_display['ins_row'] = (string) '0'; $do_display['bkm_form'] = (string) '1'; - + if ($this->__get ('_is_maint')) { $do_display['text_btn'] = (string) '1'; } else { @@ -387,21 +387,21 @@ class PMA_DisplayResults $do_display['bkm_form'] = (string) '1'; $do_display['text_btn'] = (string) '1'; $do_display['pview_lnk'] = (string) '1'; - + } else { // 2.3 Other statements (ie "SELECT" ones) -> updates // $do_display['edit_lnk'], $do_display['del_lnk'] and // $do_display['text_btn'] (keeps other default values) $prev_table = $fields_meta[0]->table; $do_display['text_btn'] = (string) '1'; - + for ($i = 0; $i < $this->__get('_fields_cnt'); $i++) { - + $is_link = ($do_display['edit_lnk'] != self::NO_EDIT_OR_DELETE) || ($do_display['del_lnk'] != self::NO_EDIT_OR_DELETE) || ($do_display['sort_lnk'] != '0') || ($do_display['ins_row'] != '0'); - + // 2.3.2 Displays edit/delete/sort/insert links? if ($is_link && (($fields_meta[$i]->table == '') @@ -420,11 +420,11 @@ class PMA_DisplayResults break; } } // end if (2.3.2) - + // 2.3.3 Always display print view link $do_display['pview_lnk'] = (string) '1'; $prev_table = $fields_meta[$i]->table; - + } // end for } // end if..elseif...else (2.1 -> 2.3) } // end if (2) @@ -469,7 +469,7 @@ class PMA_DisplayResults /** * Return true if we are executing a query in the form of * "SELECT * FROM ..." - * + * * @param array $analyzed_sql the analyzed query * * @return boolean @@ -958,9 +958,9 @@ class PMA_DisplayResults = $this->_getUnsortedSqlAndSortByKeyDropDown( $analyzed_sql, $sort_expression ); - - $table_headers_html .= $drop_down_html; - + + $table_headers_html .= $drop_down_html; + } // Output data needed for grid editing @@ -981,7 +981,7 @@ class PMA_DisplayResults $full_or_partial_text_link = null; $this->__set('_vertical_display', $vertical_display); - + // Display options (if we are not in print view) if (! (isset($printview) && ($printview == '1'))) { @@ -1002,7 +1002,7 @@ class PMA_DisplayResults = $this->_getFeildVisibilityParams( $directionCondition, $is_display, $full_or_partial_text_link ); - + $table_headers_html .= $button_html; // 2. Displays the fields' name @@ -1014,7 +1014,7 @@ class PMA_DisplayResults // Do not show comments, if using horizontalflipped mode, // because of space usage $comments_map = $this->_getTableCommentsArray($direction, $analyzed_sql); - + if ($GLOBALS['cfgRelation']['commwork'] && $GLOBALS['cfgRelation']['mimework'] && $GLOBALS['cfg']['BrowseMIME'] @@ -1027,7 +1027,7 @@ class PMA_DisplayResults // See if we have to highlight any header fields of a WHERE query. // Uses SQL-Parser results. $this->_setHighlightedColumnGlobalField($analyzed_sql); - + list($col_order, $col_visib) = $this->_getColumnParams($analyzed_sql); for ($j = 0; $j < $this->__get('_fields_cnt'); $j++) { @@ -1044,11 +1044,11 @@ class PMA_DisplayResults // 2.0 Prepare comment-HTML-wrappers for each row, if defined/enabled. $comments = $this->_getCommentForRow($comments_map, $fields_meta[$i]); - + $vertical_display = $this->__get('_vertical_display'); if ($is_display['sort_lnk'] == '1') { - + list($order_link, $sorted_headrer_html) = $this->_getOrderLinkAndSortedHeaderHtml( $fields_meta[$i], $sort_expression, @@ -1057,7 +1057,7 @@ class PMA_DisplayResults $sort_direction, $directionCondition, $col_visib, $col_visib[$j], $condition_field ); - + $table_headers_html .= $sorted_headrer_html; $vertical_display['desc'][] = ' name) . "\n" . $comments . ' '; } // end else (2.2) - + $this->__set('_vertical_display', $vertical_display); - + } // end for - + // Display column at rightside - checkboxes or empty column $table_headers_html .= $this->_getColumnAtRightSide( $is_display, $directionCondition, $full_or_partial_text_link, @@ -1103,26 +1103,26 @@ class PMA_DisplayResults return $table_headers_html; } // end of the '_getTableHeaders()' function - - + + /** * Prepare unsorted sql query and sort by key drop down - * + * * @param array $analyzed_sql the analyzed query * @param string $sort_expression sort expression - * + * * @return array two element array - $unsorted_sql_query, $drop_down_html - * + * * @access private - * + * * @see _getTableHeaders() */ private function _getUnsortedSqlAndSortByKeyDropDown( $analyzed_sql, $sort_expression ) { - + $drop_down_html = ''; - + // Just as fallback $unsorted_sql_query = $this->__get('_sql_query'); if (isset($analyzed_sql[0]['unsorted_query'])) { @@ -1153,12 +1153,12 @@ class PMA_DisplayResults ); } } - + return array($unsorted_sql_query, $drop_down_html); - + } // end of the '_getUnsortedSqlAndSortByKeyDropDown()' function - + /** * Prepare sort by key dropdown - html code segment * @@ -1246,31 +1246,31 @@ class PMA_DisplayResults return $drop_down_html; } // end of the '_getSortByKeyDropDown()' function - - + + /** * Set column span, row span and prepare html with full/partial * text button or link - * + * * @param boolean $directionCondition display direction horizontal or * horizontalflipped * @param array &$is_display which elements to display * @param string $full_or_partial_text_link full/partial link or text button - * + * * @return array 3 element array - $colspan, $rowspan, $button_html - * + * * @access private - * + * * @see _getTableHeaders() */ private function _getFeildVisibilityParams( $directionCondition, &$is_display, $full_or_partial_text_link ) { - + $button_html = ''; $colspan = $rowspan = null; $vertical_display = $this->__get('_vertical_display'); - + // 1. Displays the full/partial text button (part 1)... if ($directionCondition) { @@ -1368,33 +1368,33 @@ class PMA_DisplayResults // disabled to match the rest of the table $button_html .= ''; } - + $this->__set('_vertical_display', $vertical_display); - + return array($colspan, $rowspan, $button_html); - + } // end of the '_getFeildVisibilityParams()' function - - + + /** * Get table comments as array - * + * * @param boolean $directionCondition display direction horizontal * or horizontalflipped * @param array $analyzed_sql the analyzed query - * + * * @return array $comments_map table comments when condition true * null when condition falls - * + * * @access private - * + * * @see _getTableHeaders() */ private function _getTableCommentsArray($direction, $analyzed_sql) { - + $comments_map = null; - + if ($GLOBALS['cfg']['ShowBrowseComments'] && ($direction != self::DISP_DIR_HORIZONTAL_FLIPPED) ) { @@ -1407,26 +1407,26 @@ class PMA_DisplayResults } } } - + return $comments_map; - + } // end of the '_getTableCommentsArray()' function - - + + /** * Set global array for store highlighted header fields - * + * * @param array $analyzed_sql the analyzed query - * + * * @return void - * + * * @access private - * + * * @see _getTableHeaders() */ private function _setHighlightedColumnGlobalField($analyzed_sql) { - + $highlight_columns = array(); if (isset($analyzed_sql) && isset($analyzed_sql[0]) && isset($analyzed_sql[0]['where_clause_identifiers']) @@ -1443,11 +1443,11 @@ class PMA_DisplayResults } } } - + $this->__set('_highlight_columns', $highlight_columns); - + } // end of the '_setHighlightedColumnGlobalField()' function - + /** * Prepare data for column restoring and show/hide @@ -1725,11 +1725,11 @@ class PMA_DisplayResults } return $comments; } // end of the '_getCommentForRow()' function - - + + /** * Prepare parameters and html for sorted table header fields - * + * * @param array $fields_meta set of field properties * @param string $sort_expression sort expression * @param string $sort_expression_nodirection sort expression without direction @@ -1746,11 +1746,11 @@ class PMA_DisplayResults * @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 - * + * * @access private - * + * * @see _getTableHeaders() */ private function _getOrderLinkAndSortedHeaderHtml( @@ -1761,7 +1761,7 @@ class PMA_DisplayResults ) { $sorted_header_html = ''; - + // Checks if the table name is required; it's the case // for a query with a "JOIN" statement and if the column // isn't aliased, or in queries like @@ -1852,11 +1852,11 @@ class PMA_DisplayResults $fields_meta, $order_link, $comments ); } - + return array($order_link, $sorted_header_html); - + } // end of the '_getOrderLinkAndSortedHeaderHtml()' function - + /** * Check whether the column is sorted @@ -2168,31 +2168,31 @@ class PMA_DisplayResults } // end of the '_getDraggableClassForNonSortableColumns()' function - + /** * Prepare column to show at right side - check boxes or empty column - * + * * @param array &$is_display which elements to display * @param boolean $directionCondition display direction horizontal * or horizontalflipped * @param string $full_or_partial_text_link full/partial link or text button * @param string $colspan column span of table header * @param string $rowspan row span of table header - * + * * @return string html content - * + * * @access private - * + * * @see _getTableHeaders() */ private function _getColumnAtRightSide( &$is_display, $directionCondition, $full_or_partial_text_link, $colspan, $rowspan ) { - + $right_column_html = ''; $vertical_display = $this->__get('_vertical_display'); - + // Displays the needed checkboxes at the right // column of the result table header if possible and required... if ((($GLOBALS['cfg']['RowActionLinks'] == self::POSITION_RIGHT) @@ -2241,13 +2241,13 @@ class PMA_DisplayResults . '>' . "\n"; } // end vertical mode } - + $this->__set('_vertical_display', $vertical_display); - + return $right_column_html; - + } // end of the '_getColumnAtRightSide()' function - + /** * Prepares the display for a value @@ -2404,7 +2404,7 @@ class PMA_DisplayResults // query without conditions to shorten URLs when needed, 200 is just // guess, it should depend on remaining URL length $url_sql_query = $this->_getUrlSqlQuery($analyzed_sql); - + $vertical_display = $this->__get('_vertical_display'); if (! is_array($map)) { @@ -2417,7 +2417,7 @@ class PMA_DisplayResults $vertical_display['delete'] = array(); $vertical_display['data'] = array(); $vertical_display['row_delete'] = array(); - $this->__set('_vertical_display', $vertical_display); + $this->__set('_vertical_display', $vertical_display); // name of the class added to all grid editable elements $grid_edit_class = 'grid_edit'; @@ -2471,7 +2471,7 @@ class PMA_DisplayResults $dt_result, $this->__get('_fields_cnt'), $this->__get('_fields_meta'), $row ); $where_clause_html = urlencode($where_clause); - + // In print view these variable needs toinitialized $del_url = $del_query = $del_str = $edit_anchor_class = $edit_str = $js_conf = $copy_url = $copy_str = null; @@ -2548,7 +2548,7 @@ class PMA_DisplayResults $grid_edit_class, $col_visib, $where_clause, $url_sql_query, $analyzed_sql, $directionCondition ); - + // 3. Displays the modify/delete links on the right if required if ((($GLOBALS['cfg']['RowActionLinks'] == self::POSITION_RIGHT) || ($GLOBALS['cfg']['RowActionLinks'] == self::POSITION_BOTH)) @@ -2569,13 +2569,13 @@ class PMA_DisplayResults } // end if // 4. Gather links of del_urls and edit_urls in an array for later - // output + // output $this->_gatherLinksForLaterOutputs( $row_no, $is_display, $where_clause, $where_clause_html, $js_conf, $del_url, $del_query, $del_str, $edit_anchor_class, $edit_str, $copy_url, $copy_str, $alternating_color_class, $condition_array ); - + $table_body_html .= $directionCondition ? "\n" : ''; $row_no++; @@ -2584,11 +2584,11 @@ class PMA_DisplayResults return $table_body_html; } // end of the '_getTableBody()' function - - + + /** * Prepare rows - * + * * @param integer &$dt_result the link id associated to the query * which results have to be displayed * @param array $row current row data @@ -2605,9 +2605,9 @@ class PMA_DisplayResults * @param boolean $directionCondition the directional condition * * @return string $row_values_html html content - * + * * @access private - * + * * @see _getTableBody() */ private function _getRowValues( @@ -2615,16 +2615,16 @@ class PMA_DisplayResults $grid_edit_class, $col_visib, $where_clause, $url_sql_query, $analyzed_sql, $directionCondition ) { - + $row_values_html = ''; - + // Following variable are needed for use in isset/empty or // use with array indexes/safe use in foreach $sql_query = $this->__get('_sql_query'); $fields_meta = $this->__get('_fields_meta'); $highlight_columns = $this->__get('_highlight_columns'); $mime_map = $this->__get('_mime_map'); - + for ($j = 0; $j < $this->__get('_fields_cnt'); ++$j) { // assign $i with appropriate column order @@ -2721,7 +2721,7 @@ class PMA_DisplayResults = PMA_generate_common_url($_url_params); $vertical_display = $this->__get('_vertical_display'); - + if ($meta->numeric == 1) { // n u m e r i c @@ -2793,19 +2793,19 @@ class PMA_DisplayResults $vertical_display['rowdata'][$i][$row_no] = $vertical_display['data'][$row_no][$i]; } - + $this->__set('_vertical_display', $vertical_display); - + } // end for - + return $row_values_html; - + } // end of the '_getRowValues()' function - - + + /** * Gather delete/edit url links for further outputs - * + * * @param integer $row_no the index of current row * @param array $is_display which elements to display * @param string $where_clause where clause @@ -2819,13 +2819,13 @@ class PMA_DisplayResults * @param string $copy_url the url for copy row * @param string $copy_str the label for copy row * @param string $alternating_color_class class for display two colors in rows - * @param array $condition_array array of keys + * @param array $condition_array array of keys * (primary,unique,condition) - * + * * @return void - * + * * @access private - * + * * @see _getTableBody() */ private function _gatherLinksForLaterOutputs( @@ -2833,9 +2833,9 @@ class PMA_DisplayResults $del_url, $del_query, $del_str, $edit_anchor_class, $edit_str, $copy_url, $copy_str, $alternating_color_class, $condition_array ) { - + $vertical_display = $this->__get('_vertical_display'); - + if (! isset($vertical_display['edit'][$row_no])) { $vertical_display['edit'][$row_no] = ''; $vertical_display['copy'][$row_no] = ''; @@ -2907,11 +2907,11 @@ class PMA_DisplayResults } else { unset($vertical_display['delete'][$row_no]); } - + $this->__set('_vertical_display', $vertical_display); - + } // end of the '_gatherLinksForLaterOutputs()' function - + /** * Get url sql query without conditions to shorten URLs @@ -2954,7 +2954,7 @@ class PMA_DisplayResults /** * Get column order and column visibility - * + * * @param array $analyzed_sql the analyzed query * * @return array 2 element array - $col_order, $col_visib @@ -3108,7 +3108,7 @@ class PMA_DisplayResults ) { $goto = $this->__get('_goto'); - + if ($del_lnk == self::DELETE_ROW) { // delete row case $_url_params = array( @@ -3244,7 +3244,7 @@ class PMA_DisplayResults $grid_edit_class, $not_null_class, $relation_class, $hide_class, $field_type_class, $row_no ) { - + $printview = $this->__get('_printview'); $class = 'data ' . $grid_edit_class . ' ' . $not_null_class . ' ' @@ -3609,7 +3609,7 @@ class PMA_DisplayResults $transformation_plugin, $default_function, $transform_options, $is_field_truncated, $analyzed_sql, &$dt_result, $col_index ) { - + $is_analyse = $this->__get ('_is_analyse'); if (! isset($column) || is_null($column)) { @@ -3720,7 +3720,7 @@ class PMA_DisplayResults /** * Get the resulted table with the vertical direction mode. - * + * * @param array $analyzed_sql the analyzed query * * @return string html content @@ -4319,7 +4319,7 @@ class PMA_DisplayResults } } - + if (($is_display['nav_bar'] == '1') && empty($analyzed_sql[0]['limit_clause']) ) { @@ -4359,7 +4359,7 @@ class PMA_DisplayResults $exist_rel = false; } else { // This method set the values for $map array - $this->_setParamForLinkForiegnKeyRelatedTables($map); + $this->_setParamForLinkForiegnKeyRelatedTables($map); } // end if // end 2b @@ -4381,7 +4381,7 @@ class PMA_DisplayResults } // end if $this->__set('_vertical_display', null); - + $table_html .= '' . "\n" . ''; @@ -4408,7 +4408,7 @@ class PMA_DisplayResults } elseif (! isset($printview) || ($printview != '1')) { $table_html .= "\n" . '

' . "\n"; } - + // 6. ----- Prepare "Query results operations" if (! isset($printview) || ($printview != '1')) { @@ -4520,7 +4520,7 @@ class PMA_DisplayResults ) { $fields_meta = $this->__get('_fields_meta'); // To use array indexes - + if (! empty($sort_expression_nodirection)) { if (strpos($sort_expression_nodirection, '.') === false) { @@ -4637,7 +4637,7 @@ class PMA_DisplayResults $sorted_column_message, $limit_clause, $total, $pos_next, $pre_count, $after_count ) { - + $unlim_num_rows = $this->__get('_unlim_num_rows'); // To use in isset() if (isset($unlim_num_rows) && ($unlim_num_rows != $total)) { @@ -4730,21 +4730,21 @@ class PMA_DisplayResults } // end of the '_setMessageInformation()' function - + /** * Set the value of $map array for linking foreign key related tables - * + * * @param array $map the list of relations - * + * * @return void - * + * * @access private - * + * * @see getTable() */ private function _setParamForLinkForiegnKeyRelatedTables(&$map) { - + // To be able to later display a link to the related table, // we verify both types of relations: either those that are // native foreign keys or those defined in the phpMyAdmin @@ -4771,9 +4771,9 @@ class PMA_DisplayResults ); } // end while } // end if - + } // end of the '_setParamForLinkForiegnKeyRelatedTables()' function - + /** * Prepare multi field edit/delete links @@ -4867,44 +4867,44 @@ class PMA_DisplayResults } // end of the '_getMultiRowOperationLinks()' function - + /** * 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 - * + * * @return string html content of navigation bar - * + * * @access private - * + * * @see _getTable() */ private function _getPlacedTableNavigatoins( $pos_next, $pos_prev, $place, $empty_line, $is_innodb ) { - + $navigation_html = ''; - + if ($place == self::PLACE_BOTTOM_DIRECTION_DROPDOWN) { $navigation_html .= '
' . "\n"; } - + $navigation_html .= $this->_getTableNavigation( $pos_next, $pos_prev, 'top_direction_dropdown', $is_innodb ); - + if ($place == self::PLACE_TOP_DIRECTION_DROPDOWN) { $navigation_html .= "\n"; } - + return $navigation_html; - + } // end of the '_getPlacedTableNavigatoins()' function - + /** * Get operations that are available on results. @@ -5123,7 +5123,7 @@ class PMA_DisplayResults $category, $content, $transformation_plugin, $transform_options, $default_function, $meta, $url_params = array() ) { - + $result = '[' . $category; if (is_null($content)) { @@ -5218,7 +5218,7 @@ class PMA_DisplayResults $transformation_plugin, $default_function, $nowrap, $where_comparison, $transform_options, $is_field_truncated ) { - + $printview = $this->__get('_printview'); $result = '', $buffer); return $buffer; - } + } } ?> From 0fd8848073c9ce09a05d3615c023b3e176456dfa Mon Sep 17 00:00:00 2001 From: Madhura Jayaratne Date: Tue, 10 Jul 2012 21:50:57 +0530 Subject: [PATCH 02/21] Coding style fixes --- libraries/DisplayResults.class.php | 168 +++++++++++++++++------------ 1 file changed, 98 insertions(+), 70 deletions(-) diff --git a/libraries/DisplayResults.class.php b/libraries/DisplayResults.class.php index aa835b35e4..c64f0c5aac 100644 --- a/libraries/DisplayResults.class.php +++ b/libraries/DisplayResults.class.php @@ -152,14 +152,14 @@ 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; } - } @@ -168,13 +168,14 @@ class PMA_DisplayResults * * @param string $property name of the property * @param $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 +335,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 +348,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 +481,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); @@ -808,7 +809,9 @@ class PMA_DisplayResults ); // prepare some options for the End button - if ($is_innodb && $this->__get('_unlim_num_rows') > $GLOBALS['cfg']['MaxExactCount']) { + if ($is_innodb + && $this->__get('_unlim_num_rows') > $GLOBALS['cfg']['MaxExactCount'] + ) { $input_for_real_end = ''; // no backquote around this message @@ -908,11 +911,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 * @@ -1021,7 +1024,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 +1114,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 * @@ -1141,9 +1147,11 @@ class PMA_DisplayResults && isset($analyzed_sql[0]['table_ref']) && (count($analyzed_sql[0]['table_ref']) == 1) ) { - // 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) { @@ -1300,7 +1308,8 @@ class PMA_DisplayResults if ($directionCondition) { - $button_html .= '' + $button_html .= '' + . '' . '' . ''; @@ -1379,9 +1388,9 @@ class PMA_DisplayResults /** * Get table comments as array * - * @param boolean $directionCondition display direction horizontal - * or horizontalflipped - * @param array $analyzed_sql the analyzed query + * @param boolean $direction display direction, horizontal + * or horizontalflipped + * @param array $analyzed_sql the analyzed query * * @return array $comments_map table comments when condition true * null when condition falls @@ -1416,7 +1425,7 @@ class PMA_DisplayResults /** * Set global array for store highlighted header fields * - * @param array $analyzed_sql the analyzed query + * @param array $analyzed_sql the analyzed query * * @return void * @@ -1744,8 +1753,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 * @@ -1890,8 +1899,8 @@ class PMA_DisplayResults // SELECT p.*, FROM_UNIXTIME(p.temps) FROM mytable AS p // (and try clicking on each column's header twice) if (! empty($sort_tbl) - && (strpos($sort_expression_nodirection, $sort_tbl) === false) - && (strpos($sort_expression_nodirection, '(') === false) + && strpos($sort_expression_nodirection, $sort_tbl) === false + && strpos($sort_expression_nodirection, '(') === false ) { $new_sort_expression_nodirection = $sort_tbl . $sort_expression_nodirection; @@ -1902,8 +1911,8 @@ class PMA_DisplayResults $is_in_sort = false; $sort_name = str_replace('`', '', $sort_tbl) . $name_to_use_in_sort; - if (($sort_name == str_replace('`', '', $new_sort_expression_nodirection)) - || ($sort_name == str_replace('`', '', $sort_expression_nodirection)) + if ($sort_name == str_replace('`', '', $new_sort_expression_nodirection) + || $sort_name == str_replace('`', '', $sort_expression_nodirection) ) { $is_in_sort = true; } @@ -2468,7 +2477,10 @@ 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 +3622,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)) { @@ -3750,10 +3762,8 @@ class PMA_DisplayResults } $vertical_table_html .= $vertical_display['textbtn'] - . $this->_getCheckBoxesForMultipleRowOperations( - '_left' - ) - . '' . "\n"; + . $this->_getCheckBoxesForMultipleRowOperations('_left') + . '' . "\n"; } // end if // Prepares "edit" link at top if required @@ -3810,7 +3820,7 @@ class PMA_DisplayResults if (($cell_displayed != 0) && ($_SESSION['tmp_user_values']['repeat_cells'] != 0) - && !($cell_displayed % $_SESSION['tmp_user_values']['repeat_cells']) + && ! ($cell_displayed % $_SESSION['tmp_user_values']['repeat_cells']) ) { $vertical_table_html .= $val; } @@ -3881,16 +3891,16 @@ 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 + * @return string $links_html html content * * @access private * * @see _getVerticalTable() */ - private function _getOperationLinksForVerticleTable($operation) { - + private function _getOperationLinksForVerticleTable($operation) + { $link_html = '' . "\n"; $vertical_display = $this->__get('_vertical_display'); @@ -3921,7 +3931,7 @@ 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 * @@ -4245,10 +4255,7 @@ class PMA_DisplayResults $pre_count = '~'; $after_count = $this->getCommonFunctions()->showHint( PMA_sanitize( - __( - 'May be approximate. See [a@./Documentation.html' - . '#faq3_11@Documentation]FAQ 3.11[/a]' - ) + __('May be approximate. See [a@./Documentation.html#faq3_11@Documentation]FAQ 3.11[/a]') ) ); } else { @@ -4353,7 +4360,7 @@ class PMA_DisplayResults } - $tabs = '(\'' . join('\',\'', $target) . '\')'; + $tabs = '(\'' . join('\',\'', $target) . '\')'; if (! strlen($this->__get('_table'))) { $exist_rel = false; @@ -4734,7 +4741,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 * @@ -4827,7 +4834,9 @@ class PMA_DisplayResults $delete_text, 'b_drop.png', 'delete' ); - if (isset($analyzed_sql[0]) && $analyzed_sql[0]['querytype'] == self::QUERY_TYPE_SELECT) { + if (isset($analyzed_sql[0]) + && $analyzed_sql[0]['querytype'] == self::QUERY_TYPE_SELECT + ) { $links_html .= $this->getCommonFunctions()->getButtonOrImage( 'submit_mult', 'mult_submit', 'submit_mult_export', __('Export'), 'b_tblexport.png', 'export' @@ -4852,7 +4861,10 @@ class PMA_DisplayResults // in the multi-edit and multi-delete form 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 ); // reset to first row for the loop in _getTableBody() @@ -4871,11 +4883,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 * @@ -4950,7 +4962,10 @@ class PMA_DisplayResults $this->getCommonFunctions()->getIcon( 'b_print.png', __('Print view'), true ), - '', true, true, 'print_view' + '', + true, + true, + 'print_view' ) . "\n"; @@ -4965,7 +4980,10 @@ class PMA_DisplayResults 'b_print.png', __('Print view (with full texts)'), true ), - '', true, true, 'print_view' + '', + true, + true, + 'print_view' ) . "\n"; unset($_url_params['display_text']); @@ -4992,7 +5010,7 @@ class PMA_DisplayResults $_url_params['single_table'] = 'true'; } - if (!$header_shown) { + if (! $header_shown) { $results_operations_html .= $header; $header_shown = true; } @@ -5007,7 +5025,7 @@ class PMA_DisplayResults * first table of this database, so that tbl_export.php and * the script it calls do not fail */ - if (empty($_url_params['table']) && !empty($_url_params['db'])) { + if (empty($_url_params['table']) && ! empty($_url_params['db'])) { $_url_params['table'] = PMA_DBI_fetch_value("SHOW TABLES"); /* No result (probably no database selected) */ if ($_url_params['table'] === false) { @@ -5020,7 +5038,10 @@ class PMA_DisplayResults $this->getCommonFunctions()->getIcon( 'b_tblexport.png', __('Export'), true ), - '', true, true, '' + '', + true, + true, + '' ) . "\n"; @@ -5030,7 +5051,10 @@ class PMA_DisplayResults $this->getCommonFunctions()->getIcon( 'b_chart.png', __('Display chart'), true ), - '', true, true, '' + '', + true, + true, + '' ) . "\n"; @@ -5052,7 +5076,10 @@ class PMA_DisplayResults $this->getCommonFunctions()->getIcon( 'b_globe.gif', __('Visualize GIS data'), true ), - '', true, true, '' + '', + true, + true, + '' ) . "\n"; } @@ -5115,7 +5142,8 @@ class PMA_DisplayResults * * @access private * - * @see _getDataCellForBlobColumns(), _getDataCellForGeometryColumns(), + * @see _getDataCellForBlobColumns(), + * _getDataCellForGeometryColumns(), * _getDataCellForNonNumericAndNonBlobColumns(), * _getSortedColumnMessage() */ @@ -5257,7 +5285,7 @@ class PMA_DisplayResults // Field to display from the foreign table? if (isset($map[$meta->name][2]) && strlen($map[$meta->name][2])) { - $dispsql = 'SELECT ' + $dispsql = 'SELECT ' . $this->getCommonFunctions()->backquote($map[$meta->name][2]) . ' FROM ' . $this->getCommonFunctions()->backquote($map[$meta->name][3]) @@ -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 a3a366a35348769f2c51411c9a4e5e04b9a61375 Mon Sep 17 00:00:00 2001 From: Madhura Jayaratne Date: Tue, 10 Jul 2012 21:52:27 +0530 Subject: [PATCH 03/21] Wrap some long lines --- main.php | 211 +++++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 165 insertions(+), 46 deletions(-) diff --git a/main.php b/main.php index e158e29b27..a58a938b09 100644 --- a/main.php +++ b/main.php @@ -91,7 +91,7 @@ if ($server > 0 /** * Displays the mysql server related links */ - if ($server > 0 && !PMA_DRIZZLE) { + if ($server > 0 && ! PMA_DRIZZLE) { include_once 'libraries/check_user_privileges.lib.php'; // Logout for advanced authentication @@ -120,10 +120,22 @@ if ($server > 0 . ' ' . "\n" - . PMA_generateCharsetDropdownBox(PMA_CSDROPDOWN_COLLATION, 'collation_connection', 'select_collation_connection', $collation_connection, true, 4, true) + . PMA_generateCharsetDropdownBox( + PMA_CSDROPDOWN_COLLATION, + 'collation_connection', + 'select_collation_connection', + $collation_connection, + true, + 4, + true + ) . ' ' . "\n" . ' ' . "\n"; } // end of if ($server > 0 && !PMA_DRIZZLE) @@ -176,13 +188,22 @@ echo '
'; if ($server > 0 && $GLOBALS['cfg']['ShowServerInfo']) { - + echo '
'; echo '

' . __('Database server') . '

'; echo '
    ' . "\n"; - PMA_printListItem(__('Server') . ': ' . $server_info, 'li_server_info'); - PMA_printListItem(__('Software') . ': ' . $common_functions->getServerType(), 'li_server_type'); - PMA_printListItem(__('Software version') . ': ' . PMA_MYSQL_STR_VERSION . ' - ' . PMA_MYSQL_VERSION_COMMENT, 'li_server_version'); + PMA_printListItem( + __('Server') . ': ' . $server_info, + 'li_server_info' + ); + PMA_printListItem( + __('Software') . ': ' . $common_functions->getServerType(), + 'li_server_type' + ); + PMA_printListItem( + __('Software version') . ': ' . PMA_MYSQL_STR_VERSION . ' - ' . PMA_MYSQL_VERSION_COMMENT, + 'li_server_version' + ); PMA_printListItem( __('Protocol version') . ': ' . PMA_DBI_get_proto_info(), 'li_mysql_proto' @@ -221,16 +242,25 @@ if ($GLOBALS['cfg']['ShowServerInfo'] || $GLOBALS['cfg']['ShowPhpInfo']) { __('Database client version') . ': ' . $client_version_str, 'li_mysql_client_version' ); + + $php_ext_string = __('PHP extension') . ': ' + . $GLOBALS['cfg']['Server']['extension'] . ' ' + . $common_functions->showPHPDocu( + 'book.' . $GLOBALS['cfg']['Server']['extension'] . '.php' + ); PMA_printListItem( - __('PHP extension') . ': ' . $GLOBALS['cfg']['Server']['extension']. ' ' - . $common_functions->showPHPDocu('book.' . $GLOBALS['cfg']['Server']['extension'] . '.php'), + $php_ext_string, 'li_used_php_extension' ); } } if ($cfg['ShowPhpInfo']) { - PMA_printListItem(__('Show PHP information'), 'li_phpinfo', 'phpinfo.php?' . $common_url_query); + PMA_printListItem( + __('Show PHP information'), + 'li_phpinfo', + 'phpinfo.php?' . $common_url_query + ); } echo '
'; echo '
'; @@ -242,18 +272,64 @@ echo '
    '; $class = null; // We rely on CSP to allow access to http://www.phpmyadmin.net, but IE lacks // support here and does not allow request to http once using https. -if ($GLOBALS['cfg']['VersionCheck'] && (! $GLOBALS['PMA_Config']->get('is_https') || PMA_USR_BROWSER_AGENT != 'IE')) { +if ($GLOBALS['cfg']['VersionCheck'] + && (! $GLOBALS['PMA_Config']->get('is_https') || PMA_USR_BROWSER_AGENT != 'IE') +) { $class = 'jsversioncheck'; } -PMA_printListItem(__('Version information') . ': ' . PMA_VERSION, 'li_pma_version', null, null, null, null, $class); -PMA_printListItem(__('Documentation'), 'li_pma_docs', 'Documentation.html', null, '_blank'); -PMA_printListItem(__('Wiki'), 'li_pma_wiki', PMA_linkURL('http://wiki.phpmyadmin.net/'), null, '_blank'); +PMA_printListItem( + __('Version information') . ': ' . PMA_VERSION, + 'li_pma_version', + null, + null, + null, + null, + $class +); +PMA_printListItem( + __('Documentation'), + 'li_pma_docs', + 'Documentation.html', + null, + '_blank' +); +PMA_printListItem( + __('Wiki'), + 'li_pma_wiki', + PMA_linkURL('http://wiki.phpmyadmin.net/'), + null, + '_blank' +); // does not work if no target specified, don't know why -PMA_printListItem(__('Official Homepage'), 'li_pma_homepage', PMA_linkURL('http://www.phpMyAdmin.net/'), null, '_blank'); -PMA_printListItem(__('Contribute'), 'li_pma_contribute', PMA_linkURL('http://www.phpmyadmin.net/home_page/improve.php'), null, '_blank'); -PMA_printListItem(__('Get support'), 'li_pma_support', PMA_linkURL('http://www.phpmyadmin.net/home_page/support.php'), null, '_blank'); -PMA_printListItem(__('List of changes'), 'li_pma_changes', PMA_linkURL('changelog.php'), null, '_blank'); +PMA_printListItem( + __('Official Homepage'), + 'li_pma_homepage', + PMA_linkURL('http://www.phpMyAdmin.net/'), + null, + '_blank' +); +PMA_printListItem( + __('Contribute'), + 'li_pma_contribute', + PMA_linkURL('http://www.phpmyadmin.net/home_page/improve.php'), + null, + '_blank' +); +PMA_printListItem( + __('Get support'), + 'li_pma_support', + PMA_linkURL('http://www.phpmyadmin.net/home_page/support.php'), + null, + '_blank' +); +PMA_printListItem( + __('List of changes'), + 'li_pma_changes', + PMA_linkURL('changelog.php'), + null, + '_blank' +); ?>
@@ -278,7 +354,10 @@ if ($server != 0 && $cfg['Server']['user'] == 'root' && $cfg['Server']['password'] == '' ) { - trigger_error(__('Your configuration file contains settings (root with no password) that correspond to the default MySQL privileged account. Your MySQL server is running with this default, is open to intrusion, and you really should fix this security hole by setting a password for user \'root\'.'), E_USER_WARNING); + trigger_error( + __('Your configuration file contains settings (root with no password) that correspond to the default MySQL privileged account. Your MySQL server is running with this default, is open to intrusion, and you really should fix this security hole by setting a password for user \'root\'.'), + E_USER_WARNING + ); } /** @@ -286,7 +365,10 @@ if ($server != 0 * break it, see bug 1063821. */ if (@extension_loaded('mbstring') && @ini_get('mbstring.func_overload') > 1) { - trigger_error(__('You have enabled mbstring.func_overload in your PHP configuration. This option is incompatible with phpMyAdmin and might cause some data to be corrupted!'), E_USER_WARNING); + trigger_error( + __('You have enabled mbstring.func_overload in your PHP configuration. This option is incompatible with phpMyAdmin and might cause some data to be corrupted!'), + E_USER_WARNING + ); } /** @@ -294,7 +376,10 @@ if (@extension_loaded('mbstring') && @ini_get('mbstring.func_overload') > 1) { * to tell user something might be broken without it, see bug #1063149. */ if (! @extension_loaded('mbstring')) { - trigger_error(__('The mbstring PHP extension was not found and you seem to be using a multibyte charset. Without the mbstring extension phpMyAdmin is unable to split strings correctly and it may result in unexpected results.'), E_USER_WARNING); + trigger_error( + __('The mbstring PHP extension was not found and you seem to be using a multibyte charset. Without the mbstring extension phpMyAdmin is unable to split strings correctly and it may result in unexpected results.'), + E_USER_WARNING + ); } /** @@ -302,14 +387,22 @@ if (! @extension_loaded('mbstring')) { */ $gc_time = (int)@ini_get('session.gc_maxlifetime'); if ($gc_time < $GLOBALS['cfg']['LoginCookieValidity'] ) { - trigger_error(__('Your PHP parameter [a@http://php.net/manual/en/session.configuration.php#ini.session.gc-maxlifetime@_blank]session.gc_maxlifetime[/a] is lower than cookie validity configured in phpMyAdmin, because of this, your login will expire sooner than configured in phpMyAdmin.'), E_USER_WARNING); + trigger_error( + __('Your PHP parameter [a@http://php.net/manual/en/session.configuration.php#ini.session.gc-maxlifetime@_blank]session.gc_maxlifetime[/a] is lower than cookie validity configured in phpMyAdmin, because of this, your login will expire sooner than configured in phpMyAdmin.'), + E_USER_WARNING + ); } /** * Check whether LoginCookieValidity is limited by LoginCookieStore. */ -if ($GLOBALS['cfg']['LoginCookieStore'] != 0 && $GLOBALS['cfg']['LoginCookieStore'] < $GLOBALS['cfg']['LoginCookieValidity']) { - trigger_error(__('Login cookie store is lower than cookie validity configured in phpMyAdmin, because of this, your login will expire sooner than configured in phpMyAdmin.'), E_USER_WARNING); +if ($GLOBALS['cfg']['LoginCookieStore'] != 0 + && $GLOBALS['cfg']['LoginCookieStore'] < $GLOBALS['cfg']['LoginCookieValidity'] +) { + trigger_error( + __('Login cookie store is lower than cookie validity configured in phpMyAdmin, because of this, your login will expire sooner than configured in phpMyAdmin.'), + E_USER_WARNING + ); } /** @@ -318,7 +411,10 @@ if ($GLOBALS['cfg']['LoginCookieStore'] != 0 && $GLOBALS['cfg']['LoginCookieStor if (! empty($_SESSION['auto_blowfish_secret']) && empty($GLOBALS['cfg']['blowfish_secret']) ) { - trigger_error(__('The configuration file now needs a secret passphrase (blowfish_secret).'), E_USER_WARNING); + trigger_error( + __('The configuration file now needs a secret passphrase (blowfish_secret).'), + E_USER_WARNING + ); } /** @@ -326,14 +422,22 @@ if (! empty($_SESSION['auto_blowfish_secret']) * production environment. */ if (file_exists('config')) { - trigger_error(__('Directory [code]config[/code], which is used by the setup script, still exists in your phpMyAdmin directory. You should remove it once phpMyAdmin has been configured.'), E_USER_WARNING); + trigger_error( + __('Directory [code]config[/code], which is used by the setup script, still exists in your phpMyAdmin directory. You should remove it once phpMyAdmin has been configured.'), + E_USER_WARNING + ); } if ($server > 0) { $cfgRelation = PMA_getRelationsParam(); - if (! $cfgRelation['allworks'] && $cfg['PmaNoRelation_DisableWarning'] == false) { + if (! $cfgRelation['allworks'] + && $cfg['PmaNoRelation_DisableWarning'] == false + ) { $msg = PMA_Message::notice(__('The phpMyAdmin configuration storage is not completely configured, some extended features have been deactivated. To find out why click %shere%s.')); - $msg->addParam('
', false); + $msg->addParam( + '', + false + ); $msg->addParam('', false); /* Show error if user has configured something, notice elsewhere */ if (!empty($cfg['Servers'][$server]['pmadb'])) { @@ -346,14 +450,18 @@ if ($server > 0) { /** * Warning about different MySQL library and server version * (a difference on the third digit does not count). - * If someday there is a constant that we can check about mysqlnd, we can use it instead - * of strpos(). + * If someday there is a constant that we can check about mysqlnd, + * we can use it instead of strpos(). * If no default server is set, PMA_DBI_get_client_info() is not defined yet. - * Drizzle can speak MySQL protocol, so don't warn about version mismatch for Drizzle servers. + * Drizzle can speak MySQL protocol, so don't warn about version mismatch for + * Drizzle servers. */ if (function_exists('PMA_DBI_get_client_info') && !PMA_DRIZZLE) { $_client_info = PMA_DBI_get_client_info(); - if ($server > 0 && strpos($_client_info, 'mysqlnd') === false && substr(PMA_MYSQL_CLIENT_API, 0, 3) != substr(PMA_MYSQL_INT_VERSION, 0, 3)) { + if ($server > 0 + && strpos($_client_info, 'mysqlnd') === false + && substr(PMA_MYSQL_CLIENT_API, 0, 3) != substr(PMA_MYSQL_INT_VERSION, 0, 3) + ) { trigger_error( PMA_sanitize( sprintf( @@ -391,7 +499,9 @@ if ($cfg['SuhosinDisableWarning'] == false /** * Warning about mcrypt. */ -if (!function_exists('mcrypt_encrypt') && !$GLOBALS['cfg']['McryptDisableWarning']) { +if (! function_exists('mcrypt_encrypt') + && ! $GLOBALS['cfg']['McryptDisableWarning'] +) { PMA_warnMissingExtension('mcrypt'); } @@ -407,25 +517,34 @@ if (file_exists('libraries/language_stats.inc.php')) { * handling incomplete translations here and focus on english * speaking users. */ - if (isset($GLOBALS['language_stats'][$lang]) && $GLOBALS['language_stats'][$lang] < $cfg['TranslationWarningThreshold']) { - trigger_error('You are using an incomplete translation, please help to make it better by contributing.', E_USER_NOTICE); + if (isset($GLOBALS['language_stats'][$lang]) + && $GLOBALS['language_stats'][$lang] < $cfg['TranslationWarningThreshold'] + ) { + trigger_error( + 'You are using an incomplete translation, please help to make it better by contributing.', + E_USER_NOTICE + ); } } /** * prints list item for main page * - * @param string $name displayed text - * @param string $id id, used for css styles - * @param string $url make item as link with $url as target - * @param string $mysql_help_page display a link to MySQL's manual - * @param string $target special target for $url - * @param string $a_id id for the anchor, used for jQuery to hook in functions - * @param string $class class for the li element - * @param string $a_class class for the anchor element + * @param string $name displayed text + * @param string $id id, used for css styles + * @param string $url make item as link with $url as target + * @param string $mysql_help_page display a link to MySQL's manual + * @param string $target special target for $url + * @param string $a_id id for the anchor, + * used for jQuery to hook in functions + * @param string $class class for the li element + * @param string $a_class class for the anchor element + * + * @return void */ -function PMA_printListItem($name, $id = null, $url = null, $mysql_help_page = null, $target = null, $a_id = null, $class = null, $a_class = null) -{ +function PMA_printListItem($name, $id = null, $url = null, $mysql_help_page = null, + $target = null, $a_id = null, $class = null, $a_class = null +) { echo '
  • Date: Tue, 10 Jul 2012 12:36:27 -0400 Subject: [PATCH 04/21] Unused method: setCommonFunctions() --- libraries/DbSearch.class.php | 13 ---------- libraries/Menu.class.php | 14 ---------- libraries/Table.class.php | 14 ---------- libraries/TableSearch.class.php | 14 ---------- .../schema/Pdf_Relation_Schema.class.php | 26 ------------------- libraries/schema/User_Schema.class.php | 14 ---------- 6 files changed, 95 deletions(-) diff --git a/libraries/DbSearch.class.php b/libraries/DbSearch.class.php index 8e7f14cf0b..7c42982bbb 100644 --- a/libraries/DbSearch.class.php +++ b/libraries/DbSearch.class.php @@ -93,19 +93,6 @@ class PMA_DbSearch $this->_setSearchParams(); } - /** - * Set CommmonFunctions - * - * @param PMA_CommonFunctions $commonFunctions - * - * @return void - */ - public function setCommonFunctions(PMA_CommonFunctions $commonFunctions) - { - $this->_common_functions = $commonFunctions; - } - - /** * Get CommmonFunctions * diff --git a/libraries/Menu.class.php b/libraries/Menu.class.php index dc264560d5..d6de4af77e 100644 --- a/libraries/Menu.class.php +++ b/libraries/Menu.class.php @@ -40,20 +40,6 @@ class PMA_Menu private $_common_functions; - - /** - * Set CommmonFunctions - * - * @param PMA_CommonFunctions $commonFunctions - * - * @return void - */ - public function setCommonFunctions(PMA_CommonFunctions $commonFunctions) - { - $this->_common_functions = $commonFunctions; - } - - /** * Get CommmonFunctions * diff --git a/libraries/Table.class.php b/libraries/Table.class.php index 570a1519cb..891240a1bf 100644 --- a/libraries/Table.class.php +++ b/libraries/Table.class.php @@ -68,20 +68,6 @@ class PMA_Table private $_common_functions; - - /** - * Set CommmonFunctions - * - * @param PMA_CommonFunctions $commonFunctions - * - * @return void - */ - public function setCommonFunctions(PMA_CommonFunctions $commonFunctions) - { - $this->_common_functions = $commonFunctions; - } - - /** * Get CommmonFunctions * diff --git a/libraries/TableSearch.class.php b/libraries/TableSearch.class.php index 5c96dd6c0f..457e8d16af 100644 --- a/libraries/TableSearch.class.php +++ b/libraries/TableSearch.class.php @@ -83,20 +83,6 @@ class PMA_TableSearch private $_common_functions; - - /** - * Set CommmonFunctions - * - * @param PMA_CommonFunctions $commonFunctions - * - * @return void - */ - public function setCommonFunctions(PMA_CommonFunctions $commonFunctions) - { - $this->_common_functions = $commonFunctions; - } - - /** * Get CommmonFunctions * diff --git a/libraries/schema/Pdf_Relation_Schema.class.php b/libraries/schema/Pdf_Relation_Schema.class.php index 83bed4e08f..b93547bd07 100644 --- a/libraries/schema/Pdf_Relation_Schema.class.php +++ b/libraries/schema/Pdf_Relation_Schema.class.php @@ -37,19 +37,6 @@ class PMA_Schema_PDF extends PMA_PDF private $_ff = PMA_PDF_FONT; private $_common_functions; - /** - * Set CommmonFunctions - * - * @param PMA_CommonFunctions $commonFunctions - * - * @return void - */ - public function setCommonFunctions(PMA_CommonFunctions $commonFunctions) - { - $this->_common_functions = $commonFunctions; - } - - /** * Get CommmonFunctions * @@ -406,19 +393,6 @@ class Table_Stats private $_ff = PMA_PDF_FONT; private $_common_functions; - /** - * Set CommmonFunctions - * - * @param PMA_CommonFunctions $commonFunctions - * - * @return void - */ - public function setCommonFunctions(PMA_CommonFunctions $commonFunctions) - { - $this->_common_functions = $commonFunctions; - } - - /** * Get CommmonFunctions * diff --git a/libraries/schema/User_Schema.class.php b/libraries/schema/User_Schema.class.php index fb72734ac7..e66645b970 100644 --- a/libraries/schema/User_Schema.class.php +++ b/libraries/schema/User_Schema.class.php @@ -25,20 +25,6 @@ class PMA_User_Schema public $action; private $_common_functions; - - /** - * Set CommmonFunctions - * - * @param PMA_CommonFunctions $commonFunctions - * - * @return void - */ - public function setCommonFunctions(PMA_CommonFunctions $commonFunctions) - { - $this->_common_functions = $commonFunctions; - } - - /** * Get CommmonFunctions * From c8e96d0bf0fdf6fdd9017976b5d3e2569cf42106 Mon Sep 17 00:00:00 2001 From: Marc Delisle Date: Tue, 10 Jul 2012 12:47:58 -0400 Subject: [PATCH 05/21] Missing getCommonFunctions method in class --- libraries/schema/Pdf_Relation_Schema.class.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/libraries/schema/Pdf_Relation_Schema.class.php b/libraries/schema/Pdf_Relation_Schema.class.php index b93547bd07..42befe9998 100644 --- a/libraries/schema/Pdf_Relation_Schema.class.php +++ b/libraries/schema/Pdf_Relation_Schema.class.php @@ -860,6 +860,20 @@ class PMA_Pdf_Relation_Schema extends PMA_Export_Relation_Schema private $leftMargin = 10; private $rightMargin = 10; private $_tablewidth; + private $_common_functions; + + /** + * Get CommmonFunctions + * + * @return CommonFunctions object + */ + public function getCommonFunctions() + { + if (is_null($this->_common_functions)) { + $this->_common_functions = PMA_CommonFunctions::getInstance(); + } + return $this->_common_functions; + } /** * The "PMA_Pdf_Relation_Schema" constructor From c393fe1b795a7566bc869d597105724a89a02aac Mon Sep 17 00:00:00 2001 From: Madhura Jayaratne Date: Wed, 11 Jul 2012 11:48:33 +0530 Subject: [PATCH 06/21] $found_unique_key can be confusing --- libraries/insert_edit.lib.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/libraries/insert_edit.lib.php b/libraries/insert_edit.lib.php index 2f17f20db0..091300aa32 100644 --- a/libraries/insert_edit.lib.php +++ b/libraries/insert_edit.lib.php @@ -54,12 +54,11 @@ function PMA_getFormParametersForInsertForm($db, $table, $where_clauses, */ function PMA_getStuffForEditMode($where_clause, $table, $db) { - $found_unique_key = false; if (isset($where_clause)) { $where_clause_array = PMA_getWhereClauseArray($where_clause); list($whereClauses, $resultArray, $rowsArray, $found_unique_key) = PMA_analyzeWhereClauses( - $where_clause_array, $table, $db, $found_unique_key + $where_clause_array, $table, $db, false ); return array( false, $whereClauses, @@ -68,7 +67,7 @@ function PMA_getStuffForEditMode($where_clause, $table, $db) ); } else { list($results, $row) = PMA_loadFirstRowInEditMode($table, $db); - return array(true, null, $results, $row, null, $found_unique_key); + return array(true, null, $results, $row, null, false); } } From 5ec2b4deabe020a568da000b960293065315b084 Mon Sep 17 00:00:00 2001 From: Madhura Jayaratne Date: Wed, 11 Jul 2012 11:55:08 +0530 Subject: [PATCH 07/21] Shorten a long line --- libraries/insert_edit.lib.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libraries/insert_edit.lib.php b/libraries/insert_edit.lib.php index 091300aa32..4c4efd000d 100644 --- a/libraries/insert_edit.lib.php +++ b/libraries/insert_edit.lib.php @@ -107,12 +107,12 @@ function PMA_analyzeWhereClauses( $where_clauses = array(); foreach ($where_clause_array as $key_id => $where_clause) { - $local_query = 'SELECT * FROM ' + $local_query = 'SELECT * FROM ' . PMA_CommonFunctions::getInstance()->backquote($db) . '.' . PMA_CommonFunctions::getInstance()->backquote($table) . ' WHERE ' . $where_clause . ';'; - $result[$key_id] = PMA_DBI_query($local_query, null, PMA_DBI_QUERY_STORE); - $rows[$key_id] = PMA_DBI_fetch_assoc($result[$key_id]); + $result[$key_id] = PMA_DBI_query($local_query, null, PMA_DBI_QUERY_STORE); + $rows[$key_id] = PMA_DBI_fetch_assoc($result[$key_id]); $where_clauses[$key_id] = str_replace('\\', '\\\\', $where_clause); $found_unique_key = PMA_showEmptyResultMessageOrSetUniqueCondition( From f535769f4b7ae7f359e82c55e28a837569a21528 Mon Sep 17 00:00:00 2001 From: Madhura Jayaratne Date: Wed, 11 Jul 2012 12:22:38 +0530 Subject: [PATCH 08/21] Remove redundant space --- libraries/insert_edit.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/insert_edit.lib.php b/libraries/insert_edit.lib.php index 4c4efd000d..eec2abad4c 100644 --- a/libraries/insert_edit.lib.php +++ b/libraries/insert_edit.lib.php @@ -480,7 +480,7 @@ function PMA_getFunctionColumn($column, $is_upload, $column_name_appendix, || strstr($column['True_Type'], 'set') || in_array($column['pma_type'], $no_support_types) ) { - $html_output .= ' --' . "\n"; + $html_output .= '--' . "\n"; } else { $html_output .= '' . "\n"; From fb233ef327c3ca29c6afd1a57c86c3705855e379 Mon Sep 17 00:00:00 2001 From: Madhura Jayaratne Date: Wed, 11 Jul 2012 12:39:31 +0530 Subject: [PATCH 09/21] Proper spacing --- libraries/insert_edit.lib.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libraries/insert_edit.lib.php b/libraries/insert_edit.lib.php index eec2abad4c..20a90ea804 100644 --- a/libraries/insert_edit.lib.php +++ b/libraries/insert_edit.lib.php @@ -484,10 +484,10 @@ function PMA_getFunctionColumn($column, $is_upload, $column_name_appendix, } else { $html_output .= '' . "\n"; - $html_output .= ''; $html_output .= PMA_CommonFunctions::getInstance() ->getFunctionsForField($column, $insert_mode) . "\n"; From b72f93eac1d4cacae1e89012caae9b5cad842686 Mon Sep 17 00:00:00 2001 From: Madhura Jayaratne Date: Wed, 11 Jul 2012 12:55:07 +0530 Subject: [PATCH 10/21] Improve clarity --- libraries/insert_edit.lib.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/libraries/insert_edit.lib.php b/libraries/insert_edit.lib.php index 20a90ea804..65fa41cb9d 100644 --- a/libraries/insert_edit.lib.php +++ b/libraries/insert_edit.lib.php @@ -736,14 +736,18 @@ function PMA_getForeignLink($column, $backup_field, $column_name_appendix, list($db, $table) = $paramTableDbArray; $html_output = ''; $html_output .= $backup_field . "\n"; + $html_output .= ''; - $html_output .= '' - . ''; + + $html_output .= '' - . ' Date: Wed, 11 Jul 2012 13:07:42 +0530 Subject: [PATCH 12/21] Add missing tab index --- libraries/insert_edit.lib.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libraries/insert_edit.lib.php b/libraries/insert_edit.lib.php index 0a43a5f665..258da0d3b7 100644 --- a/libraries/insert_edit.lib.php +++ b/libraries/insert_edit.lib.php @@ -782,7 +782,8 @@ function PMA_dispRowForeignData($backup_field, $column_name_appendix, $html_output .= ''; + . ' id="field_' . $idindex . '_3">'; + $html_output .= PMA_foreignDropdown( + $foreignData['disp_row'], $foreignData['foreign_field'], + $foreignData['foreign_display'], $data, + $GLOBALS['cfg']['ForeignKeyMaxLimit'] + ); + $html_output .= ''; return $html_output; } From f1ec63a65e5a7c5682ea13bbcedbb5448521613b Mon Sep 17 00:00:00 2001 From: Madhura Jayaratne Date: Wed, 11 Jul 2012 13:17:18 +0530 Subject: [PATCH 15/21] spaces between operands --- libraries/insert_edit.lib.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libraries/insert_edit.lib.php b/libraries/insert_edit.lib.php index d0179f5fc2..297a5c9fb9 100644 --- a/libraries/insert_edit.lib.php +++ b/libraries/insert_edit.lib.php @@ -826,8 +826,8 @@ function PMA_getTextarea($column, $backup_field, $column_name_appendix, } elseif ($GLOBALS['cfg']['LongtextDoubleTextarea'] && strstr($column['pma_type'], 'longtext') ) { - $textAreaRows = $GLOBALS['cfg']['TextareaRows']*2; - $textareaCols = $GLOBALS['cfg']['TextareaCols']*2; + $textAreaRows = $GLOBALS['cfg']['TextareaRows'] * 2; + $textareaCols = $GLOBALS['cfg']['TextareaCols'] * 2; } $html_output = $backup_field . "\n" . ''; From e97a4978e5b975f9748620819224ce698fe16b2f Mon Sep 17 00:00:00 2001 From: Madhura Jayaratne Date: Wed, 11 Jul 2012 13:52:21 +0530 Subject: [PATCH 17/21] Fix indentation --- libraries/insert_edit.lib.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libraries/insert_edit.lib.php b/libraries/insert_edit.lib.php index f55d7e9fc8..c91f04e3a9 100644 --- a/libraries/insert_edit.lib.php +++ b/libraries/insert_edit.lib.php @@ -909,9 +909,9 @@ function PMA_getColumnEnumValues($column, $extracted_columnspec) // Removes automatic MySQL escape format $val = str_replace('\'\'', '\'', str_replace('\\\\', '\\', $val)); $column['values'][] = array( - 'plain' => $val, - 'html' => htmlspecialchars($val), - ); + 'plain' => $val, + 'html' => htmlspecialchars($val), + ); } return $column['values']; } From f186ab5c240f89e239fbdf59028b16fc6d5969e8 Mon Sep 17 00:00:00 2001 From: Madhura Jayaratne Date: Wed, 11 Jul 2012 14:06:27 +0530 Subject: [PATCH 18/21] Spaces between html attributes. Remove redundant space in html --- libraries/insert_edit.lib.php | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/libraries/insert_edit.lib.php b/libraries/insert_edit.lib.php index c91f04e3a9..697a7b66b8 100644 --- a/libraries/insert_edit.lib.php +++ b/libraries/insert_edit.lib.php @@ -935,14 +935,13 @@ function PMA_getDropDownDependingOnLength( $tabindex, $tabindex_for_value, $idindex, $data, $column_enum_values ) { $html_output = ''; $html_output .= ' '; list($html_out, $biggest_max_file_size) = PMA_getMaxUploadSize( $column, $biggest_max_file_size ); @@ -1176,10 +1176,10 @@ function PMA_getHTMLinput($column, $column_name_appendix, $special_chars, $the_class .= ' datetimefield'; } return ''; + . ' value="' . $special_chars . '" size="' . $fieldsize . '"' + . ' class="' . $the_class . '" ' . $unnullify_trigger + . ' tabindex="' . ($tabindex + $tabindex_for_value). '"' + . ' id="field_' . ($idindex) . '_3" />'; } /** From 9260e7685df6e09d9985e8ed5c6f253ea24ce12d Mon Sep 17 00:00:00 2001 From: Madhura Jayaratne Date: Wed, 11 Jul 2012 14:19:11 +0530 Subject: [PATCH 20/21] Coding style fixes --- libraries/insert_edit.lib.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/libraries/insert_edit.lib.php b/libraries/insert_edit.lib.php index 148dd2e726..601d4ea534 100644 --- a/libraries/insert_edit.lib.php +++ b/libraries/insert_edit.lib.php @@ -1231,7 +1231,8 @@ function PMA_getMaxUploadSize($column, $biggest_max_file_size) 'tinyblob' => '256', 'blob' => '65536', 'mediumblob' => '16777216', - 'longblob' => '4294967296'); // yeah, really + 'longblob' => '4294967296' // yeah, really + ); $this_field_max_size = $max_upload_size; // from PHP max if ($this_field_max_size > $max_field_sizes[$column['pma_type']]) { @@ -1396,13 +1397,13 @@ function PMA_getContinueInsertionForm($table, $db, $where_clause_array, $err_url if (isset($_REQUEST['where_clause'])) { foreach ($where_clause_array as $key_id => $where_clause) { - $html_output .= ''. "\n"; + $html_output .= ''. "\n"; } } $tmp = '