From 004f4f5258a0820975e2da9fa02a6d3ba6622368 Mon Sep 17 00:00:00 2001 From: Chanaka Indrajith Date: Tue, 8 May 2012 22:19:40 +0530 Subject: [PATCH 01/17] Render HTML content in PMA_displayTableHeaders() function at once, in display_tbl.lib.php file --- db_operations.php | 2 +- db_search.php | 2 +- libraries/common.lib.php | 58 ++-- libraries/display_tbl.lib.php | 321 +++++++++--------- libraries/schema/User_Schema.class.php | 2 +- pmd_pdf.php | 2 +- server_privileges.php | 8 +- tbl_operations.php | 4 +- tbl_select.php | 4 +- tbl_structure.php | 4 +- .../PMA_generate_slider_effect_test.php | 8 +- 11 files changed, 214 insertions(+), 201 deletions(-) diff --git a/db_operations.php b/db_operations.php index d76225f4cc..526e1ebba5 100644 --- a/db_operations.php +++ b/db_operations.php @@ -523,7 +523,7 @@ echo __('Remove database'); 'structure' => __('Structure only'), 'data' => __('Structure and data'), 'dataonly' => __('Data only')); - PMA_display_html_radio('what', $choices, 'data', true); + echo PMA_display_html_radio('what', $choices, 'data', true); unset($choices); ?> diff --git a/libraries/common.lib.php b/libraries/common.lib.php index e908d9e1a5..3ed339fed7 100644 --- a/libraries/common.lib.php +++ b/libraries/common.lib.php @@ -1402,7 +1402,7 @@ function PMA_profilingCheckbox($sql_query) echo PMA_generate_common_hidden_inputs($GLOBALS['db'], $GLOBALS['table']); echo '' . "\n"; echo '' . "\n"; - PMA_display_html_checkbox('profiling', __('Profiling'), isset($_SESSION['profiling']), true); + echo PMA_display_html_checkbox('profiling', __('Profiling'), isset($_SESSION['profiling']), true); echo ' ' . "\n"; } } @@ -2624,15 +2624,15 @@ function PMA_externalBug($functionality, $component, $minimum_version, $bugref) * @param boolean $checked is it initially checked? * @param boolean $onclick should it submit the form on click? * - * @return void + * @return string html content */ function PMA_display_html_checkbox($html_field_name, $label, $checked, $onclick) { - echo ''; + return ''; } /** @@ -2645,33 +2645,39 @@ function PMA_display_html_checkbox($html_field_name, $label, $checked, $onclick) * @param boolean $escape_label whether to use htmlspecialchars() on label * @param string $class enclose each choice with a div of this class * - * @return void + * @return string html content */ function PMA_display_html_radio($html_field_name, $choices, $checked_choice = '', $line_break = true, $escape_label = true, $class='' ) { + + $radio_html = ''; + foreach ($choices as $choice_value => $choice_label) { if (! empty($class)) { - echo '
'; + $radio_html .= '
'; } $html_field_id = $html_field_name . '_' . $choice_value; - echo '' . "\n"; - echo ''; + $radio_html .= ' />' . "\n" + . ''; if ($line_break) { - echo '
'; + $radio_html .= '
'; } if (! empty($class)) { - echo '
'; + $radio_html .= '
'; } - echo "\n"; + $radio_html .= "\n"; } + + return $radio_html; + } /** @@ -2711,12 +2717,14 @@ function PMA_generate_html_dropdown($select_name, $choices, $active_choice, $id) * * @param string $id the id of the
on which to apply the effect * @param string $message the message to show as a link + * + * @return string html content + * */ -function PMA_generate_slider_effect($id, $message) +function PMA_getDivForSliderEffect($id, $message) { if ($GLOBALS['cfg']['InitialSlidersState'] == 'disabled') { - echo '
'; - return; + return '
'; } /** * Bad hack on the next line. document.write() conflicts with jQuery, @@ -2726,9 +2734,11 @@ function PMA_generate_slider_effect($id, $message) * method maybe by using an additional param, the id of the div to * append to */ - ?> -'; - echo ''; + $table_headers_html .= '
' + . '' + . '
' + . '
' + . ''; } // Start of form for multi-rows edit/delete/export if ($is_display['del_lnk'] == 'dr' || $is_display['del_lnk'] == 'kp') { - echo '
' . "\n"; - echo PMA_generate_common_hidden_inputs($db, $table, 1); - echo '' . "\n"; + $table_headers_html .= '>' . "\n" + . PMA_generate_common_hidden_inputs($db, $table, 1) + . '' . "\n"; } - echo '' . "\n"; + $table_headers_html .= '">' . "\n"; if ($direction == 'horizontal' || $direction == 'horizontalflipped' ) { - echo '' . "\n"; + $table_headers_html .= '' . "\n"; } // 1. Displays the full/partial text button (part 1)... @@ -891,19 +893,19 @@ function PMA_displayTableHeaders(&$is_display, &$fields_meta, $fields_cnt = 0, if ($direction == 'horizontal' || $direction == 'horizontalflipped' ) { - ?> - - - - ' + . '' + . ''; + // end horizontal/horizontalflipped mode } else { - ?> - - - - ' + . '' + . ''; + } // end vertical mode } elseif (($GLOBALS['cfg']['RowActionLinks'] == 'left' @@ -918,10 +920,10 @@ function PMA_displayTableHeaders(&$is_display, &$fields_meta, $fields_cnt = 0, if ($direction == 'horizontal' || $direction == 'horizontalflipped' ) { - ?> - - ' + . $full_or_partial_text_link . ''; + // end horizontal/horizontalflipped mode } else { $vertical_display['textbtn'] @@ -940,9 +942,9 @@ function PMA_displayTableHeaders(&$is_display, &$fields_meta, $fields_cnt = 0, if ($direction == 'horizontal' || $direction == 'horizontalflipped' ) { - ?> - > - '; + // end horizontal/horizontalfipped mode } else { $vertical_display['textbtn'] = ' ' . "\n"; @@ -955,7 +957,7 @@ function PMA_displayTableHeaders(&$is_display, &$fields_meta, $fields_cnt = 0, // ... elseif display an empty column if the actions links are disabled to // match the rest of the table - echo ''; + $table_headers_html .= ''; } // 2. Displays the fields' name @@ -1210,7 +1212,7 @@ function PMA_displayTableHeaders(&$is_display, &$fields_meta, $fields_cnt = 0, if ($direction == 'horizontal' || $direction == 'horizontalflipped' ) { - echo '' . $order_link . $comments . ''; + $table_headers_html .= '" data-column="' . htmlspecialchars($fields_meta[$i]->name) + . '">' . $order_link . $comments . ''; } $vertical_display['desc'][] = ' '; + $table_headers_html .= "\n" . $comments . ''; } $vertical_display['desc'][] = ' - ' . $full_or_partial_text_link + . ''; + // end horizontal/horizontalflipped mode } else { $vertical_display['textbtn'] = ' - - ' + . ''; + } + + // render all HTML content related to table headers + echo $table_headers_html; return true; } // end of the 'PMA_displayTableHeaders()' function diff --git a/libraries/schema/User_Schema.class.php b/libraries/schema/User_Schema.class.php index fa4637ffb8..63cbe09bb6 100644 --- a/libraries/schema/User_Schema.class.php +++ b/libraries/schema/User_Schema.class.php @@ -199,7 +199,7 @@ class PMA_User_Schema '0' => __('Edit'), '1' => __('Delete') ); - PMA_display_html_radio('action_choose', $choices, '0', false); + echo PMA_display_html_radio('action_choose', $choices, '0', false); unset($choices); ?> diff --git a/pmd_pdf.php b/pmd_pdf.php index 8aba3afe04..9d5b61806a 100644 --- a/pmd_pdf.php +++ b/pmd_pdf.php @@ -123,7 +123,7 @@ if (1 == count($choices)) { echo $choices['create_export']; echo ''; } else { - PMA_display_html_radio('mode', $choices, $checked_choice = '', $line_break = true, $escape_label = false, $class = ''); + echo PMA_display_html_radio('mode', $choices, $checked_choice = '', $line_break = true, $escape_label = false, $class = ''); } echo '
'; echo ''; diff --git a/server_privileges.php b/server_privileges.php index 2c2c48bc28..76c040b437 100644 --- a/server_privileges.php +++ b/server_privileges.php @@ -2364,7 +2364,7 @@ if (empty($_REQUEST['adduser']) && (! isset($checkprivs) || ! strlen($checkprivs '1' => __('... delete the old one from the user tables.'), '2' => __('... revoke all active privileges from the old one and delete it afterwards.'), '3' => __('... delete the old one from the user tables and reload the privileges afterwards.')); - PMA_display_html_radio('mode', $choices, '4', true); + echo PMA_display_html_radio('mode', $choices, '4', true); unset($choices); echo ' ' . "\n" @@ -2388,13 +2388,13 @@ if (empty($_REQUEST['adduser']) && (! isset($checkprivs) || ! strlen($checkprivs echo '
' . "\n" . '' . __('Database for user') . '' . "\n"; - PMA_display_html_checkbox('createdb-1', __('Create database with same name and grant all privileges'), false, false); + echo PMA_display_html_checkbox('createdb-1', __('Create database with same name and grant all privileges'), false, false); echo '
' . "\n"; - PMA_display_html_checkbox('createdb-2', __('Grant all privileges on wildcard name (username\\_%)'), false, false); + echo PMA_display_html_checkbox('createdb-2', __('Grant all privileges on wildcard name (username\\_%)'), false, false); echo '
' . "\n"; if (! empty($dbname) ) { - PMA_display_html_checkbox('createdb-3', sprintf(__('Grant all privileges on database "%s"'), htmlspecialchars($dbname)), true, false); + echo PMA_display_html_checkbox('createdb-3', sprintf(__('Grant all privileges on database "%s"'), htmlspecialchars($dbname)), true, false); echo '' . "\n"; echo '
' . "\n"; } diff --git a/tbl_operations.php b/tbl_operations.php index bc4d55ca2b..2d51245d34 100644 --- a/tbl_operations.php +++ b/tbl_operations.php @@ -561,7 +561,7 @@ if (isset($possible_row_formats[$tbl_storage_engine])) { 'structure' => __('Structure only'), 'data' => __('Structure and data'), 'dataonly' => __('Data only')); - PMA_display_html_radio('what', $choices, 'data', true); + echo PMA_display_html_radio('what', $choices, 'data', true); unset($choices); ?> @@ -779,7 +779,7 @@ if (! (isset($db_is_information_schema) && $db_is_information_schema)) { 'OPTIMIZE' => __('Optimize'), 'REBUILD' => __('Rebuild'), 'REPAIR' => __('Repair')); - PMA_display_html_radio('partition_operation', $choices, '', false); + echo PMA_display_html_radio('partition_operation', $choices, '', false); unset($choices); echo PMA_showMySQLDocu('partitioning_maintenance', 'partitioning_maintenance'); // I'm not sure of the best way to display that; this link does diff --git a/tbl_select.php b/tbl_select.php index 5109479086..8ce4abe6f1 100644 --- a/tbl_select.php +++ b/tbl_select.php @@ -173,7 +173,7 @@ echo PMA_generate_html_tabs(PMA_tbl_getSubTabs(), $url_params, '', 'topmenu2');
@@ -223,7 +223,7 @@ echo PMA_generate_html_tabs(PMA_tbl_getSubTabs(), $url_params, '', 'topmenu2'); 'ASC' => __('Ascending'), 'DESC' => __('Descending') ); - PMA_display_html_radio('order', $choices, 'ASC', false, true, "formelement"); + echo PMA_display_html_radio('order', $choices, 'ASC', false, true, "formelement"); unset($choices); ?>
diff --git a/tbl_structure.php b/tbl_structure.php index e8e1e07a40..f9cff79394 100644 --- a/tbl_structure.php +++ b/tbl_structure.php @@ -710,7 +710,7 @@ if (! $tbl_is_view && ! $db_is_information_schema) { 'first' => __('At Beginning of Table'), 'after' => sprintf(__('After %s'), '') ); - PMA_display_html_radio('field_where', $choices, 'last', false); + echo PMA_display_html_radio('field_where', $choices, 'last', false); echo $column_selector; unset($column_selector, $choices); ?> @@ -730,7 +730,7 @@ if (! $tbl_is_view && ! $db_is_information_schema && 'ARCHIVE' != $tbl_storage_engine ) { - PMA_generate_slider_effect('indexes', __('Indexes')); + echo PMA_getDivForSliderEffect('indexes', __('Indexes')); /** * Display indexes */ diff --git a/test/libraries/common/PMA_generate_slider_effect_test.php b/test/libraries/common/PMA_generate_slider_effect_test.php index e46880ffb7..40d22c2e1e 100644 --- a/test/libraries/common/PMA_generate_slider_effect_test.php +++ b/test/libraries/common/PMA_generate_slider_effect_test.php @@ -1,7 +1,7 @@ expectOutputString('
' . "\n" . ' '); - PMA_generate_slider_effect($id, $message); + PMA_getDivForSliderEffect($id, $message); } function testGenerateSliderEffectTestClosed() @@ -35,7 +35,7 @@ class PMA_generate_slider_effect_test extends PHPUnit_Framework_TestCase $message = "test_message"; $this->expectOutputString(''; } $table_headers_html .= '
' - . PMA_getCheckbox( - 'display_binary', __('Show binary contents'), - ! empty($_SESSION['tmp_user_values']['display_binary']), false - ) - . '
' - . PMA_getCheckbox( - 'display_blob', __('Show BLOB contents'), - ! empty($_SESSION['tmp_user_values']['display_blob']), false - ) - . '
' - . PMA_getCheckbox( - 'display_binary_as_hex', __('Show binary contents as HEX'), - ! empty($_SESSION['tmp_user_values']['display_binary_as_hex']), false - ) - . '
'; + . PMA_getCheckbox( + 'display_binary', __('Show binary contents'), + ! empty($_SESSION['tmp_user_values']['display_binary']), false + ) + . '
' + . PMA_getCheckbox( + 'display_blob', __('Show BLOB contents'), + ! empty($_SESSION['tmp_user_values']['display_blob']), false + ) + . '
' + . PMA_getCheckbox( + 'display_binary_as_hex', __('Show binary contents as HEX'), + ! empty($_SESSION['tmp_user_values']['display_binary_as_hex']), false + ) + . '
'; // I would have preferred to name this "display_transformation". // This is the only way I found to be able to keep this setting sticky // per SQL query, and at the same time have a default that displays // the transformations. $table_headers_html .= '
' - . PMA_getCheckbox( - 'hide_transformation', __('Hide browser transformation'), - ! empty($_SESSION['tmp_user_values']['hide_transformation']), false - ) - . '
'; + . PMA_getCheckbox( + 'hide_transformation', __('Hide browser transformation'), + ! empty($_SESSION['tmp_user_values']['hide_transformation']), false + ) + . ''; if (! PMA_DRIZZLE) { $table_headers_html .= '
'; @@ -829,33 +831,33 @@ function PMA_displayTableHeaders(&$is_display, &$fields_meta, $fields_cnt = 0, 'WKB' => __('Well Known Binary') ); $table_headers_html .= PMA_getRadioFields( - 'geometry_display', $choices, - $_SESSION['tmp_user_values']['geometry_display'] - ) - . '
'; + 'geometry_display', $choices, + $_SESSION['tmp_user_values']['geometry_display'] + ) + . ''; } $table_headers_html .= '
' - . ''; + . ''; $table_headers_html .= '
' - . '' - . '
' - . '' - . ''; + . '' + . '' + . '' + . ''; } // Start of form for multi-rows edit/delete/export if ($is_display['del_lnk'] == 'dr' || $is_display['del_lnk'] == 'kp') { $table_headers_html .= '' . "\n"; + . PMA_generate_common_hidden_inputs($db, $table, 1) + . '' . "\n"; } $table_headers_html .= '
>'; + $table_headers_html .= ' data-column="' . htmlspecialchars($fields_meta[$i]->name) + . '">'; if ($direction == 'horizontalflipped' && $GLOBALS['cfg']['HeaderFlipType'] == 'fake' ) { - echo PMA_flipstring( - htmlspecialchars($fields_meta[$i]->name), '
' - ); + $table_headers_html .= PMA_flipstring( + htmlspecialchars($fields_meta[$i]->name), '
' + ); } else { - echo htmlspecialchars($fields_meta[$i]->name); + $table_headers_html .= htmlspecialchars($fields_meta[$i]->name); } - echo "\n" . $comments . '
- > - -> - '; + // end horizontal/horizontalflipped mode } else { $vertical_display['textbtn'] = ' ' . "\n"; @@ -1342,11 +1342,14 @@ function PMA_displayTableHeaders(&$is_display, &$fields_meta, $fields_cnt = 0, if ($direction == 'horizontal' || $direction == 'horizontalflipped' ) { - ?> -
' - . '' - . ''; + . '' + . ''; // end horizontal/horizontalflipped mode } else { $table_headers_html .= '' - . '' - . ''; + . '' + . ''; } // end vertical mode @@ -922,7 +924,7 @@ function PMA_displayTableHeaders(&$is_display, &$fields_meta, $fields_cnt = 0, ) { $table_headers_html .= ''; + . $full_or_partial_text_link . ''; // end horizontal/horizontalflipped mode } else { @@ -1234,7 +1236,7 @@ function PMA_displayTableHeaders(&$is_display, &$fields_meta, $fields_cnt = 0, $table_headers_html .= ' vbottom'; } $table_headers_html .= '" data-column="' . htmlspecialchars($fields_meta[$i]->name) - . '">' . $order_link . $comments . ''; + . '">' . $order_link . $comments . ''; } $vertical_display['desc'][] = ' '; + . ''; // end horizontal/horizontalflipped mode } else { @@ -1331,7 +1333,7 @@ function PMA_displayTableHeaders(&$is_display, &$fields_meta, $fields_cnt = 0, || $direction == 'horizontalflipped' ) { $table_headers_html .= "\n" - . ''; + . ''; // end horizontal/horizontalflipped mode } else { @@ -1344,7 +1346,7 @@ function PMA_displayTableHeaders(&$is_display, &$fields_meta, $fields_cnt = 0, ) { $table_headers_html .= '' - . ''; + . ''; } From e8a35a14cd7e1d870a501246394a70e8cedee385 Mon Sep 17 00:00:00 2001 From: Chanaka Indrajith Date: Thu, 10 May 2012 10:24:32 +0530 Subject: [PATCH 03/17] Some modifications including reduce echo renderings in PMA_displayVerticalTable function in display_tbl.lib.php file --- libraries/display_tbl.lib.php | 200 ++++++++++++++++++---------------- 1 file changed, 104 insertions(+), 96 deletions(-) diff --git a/libraries/display_tbl.lib.php b/libraries/display_tbl.lib.php index dd935c2983..31ca9e0b9e 100644 --- a/libraries/display_tbl.lib.php +++ b/libraries/display_tbl.lib.php @@ -238,7 +238,7 @@ function PMA_isSelect() * * @see PMA_displayTableNavigation() */ -function PMA_displayTableNavigationOneButton($caption, $title, $pos, $html_sql_query, +function PMA_displayTableNavigationButton($caption, $title, $pos, $html_sql_query, $onsubmit = '', $input_for_real_end = '', $onclick = '' ) { global $db, $table, $goto; @@ -271,7 +271,7 @@ function PMA_displayTableNavigationOneButton($caption, $title, $pos, $html_sql_q NULL'; + return ''; } /** @@ -1404,10 +1405,11 @@ function PMA_buildNullDisplay($class, $condition_field, $meta, $align = '') function PMA_buildEmptyDisplay($class, $condition_field, $meta, $align = '') { $nowrap = ' nowrap'; - return ''; + return ''; } /** @@ -1447,12 +1449,10 @@ function PMA_addClass($class, $condition_field, $meta, $nowrap, $mime_type_class = ' ' . preg_replace('/\//', '_', $meta->mimetype); } - $result = $class . ($condition_field ? ' condition' : '') . $nowrap - . ' ' . ($is_field_truncated ? ' truncated' : '') - . ($transform_function != $default_function ? ' transformed' : '') - . $enum_class . $set_class . $bit_class . $mime_type_class; - - return $result; + return $class . ($condition_field ? ' condition' : '') . $nowrap + . ' ' . ($is_field_truncated ? ' truncated' : '') + . ($transform_function != $default_function ? ' transformed' : '') + . $enum_class . $set_class . $bit_class . $mime_type_class; } /** * Displays the body of the results table @@ -1489,7 +1489,7 @@ function PMA_displayTableBody(&$dt_result, &$is_display, $map, $analyzed_sql) global $row; // mostly because of browser transformations, // to make the row-data accessible in a plugin - $url_sql_query = $sql_query; + $url_sql_query = $sql_query; // query without conditions to shorten URLs when needed, 200 is just // guess, it should depend on remaining URL length @@ -2233,6 +2233,8 @@ function PMA_displayTableBody(&$dt_result, &$is_display, $map, $analyzed_sql) function PMA_displayVerticalTable() { global $vertical_display; + + $vertical_table_html = ''; // Displays "multi row delete" link at top if required if ($GLOBALS['cfg']['RowActionLinks'] != 'right' @@ -2240,29 +2242,29 @@ function PMA_displayVerticalTable() && (count($vertical_display['row_delete']) > 0 || !empty($vertical_display['textbtn'])) ) { - echo '' . "\n"; + $vertical_table_html .= '' . "\n"; if ($GLOBALS['cfg']['RowActionLinks'] == 'none') { // if we are not showing the RowActionLinks, then we need to show // the Multi-Row-Action checkboxes - echo '' . "\n"; + $vertical_table_html .= '' . "\n"; } - echo $vertical_display['textbtn']; + $vertical_table_html .= $vertical_display['textbtn']; $cell_displayed = 0; foreach ($vertical_display['row_delete'] as $val) { if (($cell_displayed != 0) && ($_SESSION['tmp_user_values']['repeat_cells'] != 0) && !($cell_displayed % $_SESSION['tmp_user_values']['repeat_cells']) ) { - echo '' . "\n"; } - echo str_replace('[%_PMA_CHECKBOX_DIR_%]', '_left', $val); + $vertical_table_html .= str_replace('[%_PMA_CHECKBOX_DIR_%]', '_left', $val); $cell_displayed++; } // end while - echo '' . "\n"; + $vertical_table_html .= '' . "\n"; } // end if // Displays "edit" link at top if required @@ -2272,14 +2274,14 @@ function PMA_displayVerticalTable() && (count($vertical_display['edit']) > 0 || !empty($vertical_display['textbtn'])) ) { - echo '' . "\n"; + $vertical_table_html .= '' . "\n"; if (! is_array($vertical_display['row_delete'])) { - echo $vertical_display['textbtn']; + $vertical_table_html .= $vertical_display['textbtn']; } foreach ($vertical_display['edit'] as $val) { - echo $val; + $vertical_table_html .= $val; } // end while - echo '' . "\n"; + $vertical_table_html .= '' . "\n"; } // end if // Displays "copy" link at top if required @@ -2289,14 +2291,14 @@ function PMA_displayVerticalTable() && (count($vertical_display['copy']) > 0 || !empty($vertical_display['textbtn'])) ) { - echo '' . "\n"; + $vertical_table_html .= '' . "\n"; if (! is_array($vertical_display['row_delete'])) { - echo $vertical_display['textbtn']; + $vertical_table_html .= $vertical_display['textbtn']; } foreach ($vertical_display['copy'] as $val) { - echo $val; + $vertical_table_html .= $val; } // end while - echo '' . "\n"; + $vertical_table_html .= '' . "\n"; } // end if // Displays "delete" link at top if required @@ -2306,16 +2308,16 @@ function PMA_displayVerticalTable() && (count($vertical_display['delete']) > 0 || !empty($vertical_display['textbtn'])) ) { - echo '' . "\n"; + $vertical_table_html .= '' . "\n"; if (! is_array($vertical_display['edit']) && ! is_array($vertical_display['row_delete']) ) { - echo $vertical_display['textbtn']; + $vertical_table_html .= $vertical_display['textbtn']; } foreach ($vertical_display['delete'] as $val) { - echo $val; + $vertical_table_html .= $val; } // end while - echo '' . "\n"; + $vertical_table_html .= '' . "\n"; } // end if if (PMA_isSelect()) { @@ -2333,9 +2335,9 @@ function PMA_displayVerticalTable() // assign appropriate key with current column order $key = $col_order ? $col_order[$j] : $j; - echo '' . "\n"; - echo $val; + $vertical_table_html .= '' . "\n" + . $val; $cell_displayed = 0; foreach ($vertical_display['rowdata'][$key] as $subval) { @@ -2343,14 +2345,14 @@ function PMA_displayVerticalTable() && ($_SESSION['tmp_user_values']['repeat_cells'] != 0) && !($cell_displayed % $_SESSION['tmp_user_values']['repeat_cells']) ) { - echo $val; + $vertical_table_html .= $val; } - echo $subval; + $vertical_table_html .= $subval; $cell_displayed++; } // end while - echo '' . "\n"; + $vertical_table_html .= '' . "\n"; } // end while // Displays "multi row delete" link at bottom if required @@ -2360,24 +2362,24 @@ function PMA_displayVerticalTable() && (count($vertical_display['row_delete']) > 0 || !empty($vertical_display['textbtn'])) ) { - echo '' . "\n"; - echo $vertical_display['textbtn']; + $vertical_table_html .= '' . "\n" . $vertical_display['textbtn']; $cell_displayed = 0; foreach ($vertical_display['row_delete'] as $val) { if (($cell_displayed != 0) && ($_SESSION['tmp_user_values']['repeat_cells'] != 0) && !($cell_displayed % $_SESSION['tmp_user_values']['repeat_cells']) ) { - echo '' . "\n"; } - echo str_replace('[%_PMA_CHECKBOX_DIR_%]', '_right', $val); + $vertical_table_html .= str_replace('[%_PMA_CHECKBOX_DIR_%]', '_right', $val); $cell_displayed++; } // end while - echo '' . "\n"; + $vertical_table_html .= '' . "\n"; } // end if // Displays "edit" link at bottom if required @@ -2387,14 +2389,14 @@ function PMA_displayVerticalTable() && (count($vertical_display['edit']) > 0 || !empty($vertical_display['textbtn'])) ) { - echo '' . "\n"; + $vertical_table_html .= '' . "\n"; if (! is_array($vertical_display['row_delete'])) { - echo $vertical_display['textbtn']; + $vertical_table_html .= $vertical_display['textbtn']; } foreach ($vertical_display['edit'] as $val) { - echo $val; + $vertical_table_html .= $val; } // end while - echo '' . "\n"; + $vertical_table_html .= '' . "\n"; } // end if // Displays "copy" link at bottom if required @@ -2404,14 +2406,14 @@ function PMA_displayVerticalTable() && (count($vertical_display['copy']) > 0 || !empty($vertical_display['textbtn'])) ) { - echo '' . "\n"; + $vertical_table_html .= '' . "\n"; if (! is_array($vertical_display['row_delete'])) { - echo $vertical_display['textbtn']; + $vertical_table_html .= $vertical_display['textbtn']; } foreach ($vertical_display['copy'] as $val) { - echo $val; + $vertical_table_html .= $val; } // end while - echo '' . "\n"; + $vertical_table_html .= '' . "\n"; } // end if // Displays "delete" link at bottom if required @@ -2421,17 +2423,20 @@ function PMA_displayVerticalTable() && (count($vertical_display['delete']) > 0 || !empty($vertical_display['textbtn'])) ) { - echo '' . "\n"; + $vertical_table_html .= '' . "\n"; if (! is_array($vertical_display['edit']) && ! is_array($vertical_display['row_delete']) ) { - echo $vertical_display['textbtn']; + $vertical_table_html .= $vertical_display['textbtn']; } foreach ($vertical_display['delete'] as $val) { - echo $val; + $vertical_table_html .= $val; } // end while - echo '' . "\n"; + $vertical_table_html .= '' . "\n"; } + + // render HTML content of verticle table + echo $vertical_table_html; return true; } // end of the 'PMA_displayVerticalTable' function @@ -3308,10 +3313,12 @@ function PMA_prepare_row_data($class, $condition_field, $analyzed_sql, $meta, $m ) { global $db; - $result = ' class="' . PMA_addClass( - $class, $condition_field, $meta, $nowrap, - $is_field_truncated, $transform_function, $default_function - ) . '">'; + $result = ' class="' + . PMA_addClass( + $class, $condition_field, $meta, $nowrap, + $is_field_truncated, $transform_function, $default_function + ) + . '">'; if (isset($analyzed_sql[0]['select_expr']) && is_array($analyzed_sql[0]['select_expr']) @@ -3453,16 +3460,17 @@ function PMA_generateCheckboxForMulti($del_url, $is_display, $row_no, $ret .= 'class="' . $class . '"'; } $ret .= ' class="center">' - . '' - . '' - . ' '; + . '' + . '' + . ' '; } return $ret; } @@ -3589,17 +3597,17 @@ function PMA_generateCheckboxAndLinks($position, $del_url, $is_display, $row_no, if ($position == 'left') { $ret .= PMA_generateCheckboxForMulti( - $del_url, $is_display, $row_no, $where_clause_html, $condition_array, - $del_query, $id_suffix = '_left', '', '', '' - ); + $del_url, $is_display, $row_no, $where_clause_html, $condition_array, + $del_query, $id_suffix = '_left', '', '', '' + ); $ret .= PMA_generateEditLink( - $edit_url, $class, $edit_str, $where_clause, $where_clause_html, '' - ); + $edit_url, $class, $edit_str, $where_clause, $where_clause_html, '' + ); $ret .= PMA_generateCopyLink( - $copy_url, $copy_str, $where_clause, $where_clause_html, '' - ); + $copy_url, $copy_str, $where_clause, $where_clause_html, '' + ); $ret .= PMA_generateDeleteLink($del_url, $del_str, $js_conf, '', ''); @@ -3607,22 +3615,22 @@ function PMA_generateCheckboxAndLinks($position, $del_url, $is_display, $row_no, $ret .= PMA_generateDeleteLink($del_url, $del_str, $js_conf, '', ''); $ret .= PMA_generateCopyLink( - $copy_url, $copy_str, $where_clause, $where_clause_html, '' - ); + $copy_url, $copy_str, $where_clause, $where_clause_html, '' + ); $ret .= PMA_generateEditLink( - $edit_url, $class, $edit_str, $where_clause, $where_clause_html, '' - ); + $edit_url, $class, $edit_str, $where_clause, $where_clause_html, '' + ); $ret .= PMA_generateCheckboxForMulti( - $del_url, $is_display, $row_no, $where_clause_html, $condition_array, - $del_query, $id_suffix = '_right', '', '', '' - ); + $del_url, $is_display, $row_no, $where_clause_html, $condition_array, + $del_query, $id_suffix = '_right', '', '', '' + ); } else { // $position == 'none' $ret .= PMA_generateCheckboxForMulti( - $del_url, $is_display, $row_no, $where_clause_html, $condition_array, - $del_query, $id_suffix = '_left', '', '', '' - ); + $del_url, $is_display, $row_no, $where_clause_html, $condition_array, + $del_query, $id_suffix = '_left', '', '', '' + ); } return $ret; } From 29cc2fab386d5cdb2796736679aa55033f2164bc Mon Sep 17 00:00:00 2001 From: Chanaka Indrajith Date: Thu, 10 May 2012 12:35:28 +0530 Subject: [PATCH 04/17] Some modifications to PMA_displayTableBody function in display_tbl.lib.php to reduce echo renderings --- libraries/display_tbl.lib.php | 248 +++++++++++++++++----------------- 1 file changed, 125 insertions(+), 123 deletions(-) diff --git a/libraries/display_tbl.lib.php b/libraries/display_tbl.lib.php index 31ca9e0b9e..cc7bc35d76 100644 --- a/libraries/display_tbl.lib.php +++ b/libraries/display_tbl.lib.php @@ -1489,6 +1489,7 @@ function PMA_displayTableBody(&$dt_result, &$is_display, $map, $analyzed_sql) global $row; // mostly because of browser transformations, // to make the row-data accessible in a plugin + $table_body_html = ''; $url_sql_query = $sql_query; // query without conditions to shorten URLs when needed, 200 is just @@ -1553,23 +1554,23 @@ function PMA_displayTableBody(&$dt_result, &$is_display, $map, $analyzed_sql) && ($_SESSION['tmp_user_values']['disp_direction'] == 'horizontal' || $_SESSION['tmp_user_values']['disp_direction'] == 'horizontalflipped') ) { - echo '' . "\n"; + $table_body_html .= '' . "\n"; if ($vertical_display['emptypre'] > 0) { - echo ' ' . "\n"; + $table_body_html .= ' ' . "\n"; } else if ($GLOBALS['cfg']['RowActionLinks'] == 'none') { - echo ' ' . "\n"; + $table_body_html .= ' ' . "\n"; } foreach ($vertical_display['desc'] as $val) { - echo $val; + $table_body_html .= $val; } if ($vertical_display['emptyafter'] > 0) { - echo ' ' . "\n"; + $table_body_html .= ' ' . "\n"; } - echo '' . "\n"; + $table_body_html .= '' . "\n"; } // end if $alternating_color_class = ($odd_row ? 'odd' : 'even'); @@ -1579,7 +1580,7 @@ function PMA_displayTableBody(&$dt_result, &$is_display, $map, $analyzed_sql) || $_SESSION['tmp_user_values']['disp_direction'] == 'horizontalflipped' ) { // pointer code part - echo ''; + $table_body_html .= ''; } @@ -1617,12 +1618,16 @@ function PMA_displayTableBody(&$dt_result, &$is_display, $map, $analyzed_sql) 'sql_query' => $url_sql_query, 'goto' => 'sql.php', ); - $edit_url = 'tbl_change.php' . PMA_generate_common_url( - $_url_params + array('default_action' => 'update') - ); - $copy_url = 'tbl_change.php' . PMA_generate_common_url( - $_url_params + array('default_action' => 'insert') - ); + + $edit_url = 'tbl_change.php' + . PMA_generate_common_url( + $_url_params + array('default_action' => 'update') + ); + + $copy_url = 'tbl_change.php' + . PMA_generate_common_url( + $_url_params + array('default_action' => 'insert') + ); $edit_str = PMA_getIcon('b_edit.png', __('Edit')); $copy_str = PMA_getIcon('b_insrow.png', __('Copy')); @@ -1662,9 +1667,9 @@ function PMA_displayTableBody(&$dt_result, &$is_display, $map, $analyzed_sql) $del_url = 'sql.php' . PMA_generate_common_url($_url_params); $js_conf = 'DELETE FROM ' . PMA_jsFormat($db) . '.' - . PMA_jsFormat($table) - . ' WHERE ' . PMA_jsFormat($where_clause, false) - . ($clause_is_unique ? '' : ' LIMIT 1'); + . PMA_jsFormat($table) + . ' WHERE ' . PMA_jsFormat($where_clause, false) + . ($clause_is_unique ? '' : ' LIMIT 1'); $del_str = PMA_getIcon('b_drop.png', __('Delete')); } elseif ($is_display['del_lnk'] == 'kp') { // kill process case @@ -1674,9 +1679,10 @@ function PMA_displayTableBody(&$dt_result, &$is_display, $map, $analyzed_sql) 'sql_query' => $url_sql_query, 'goto' => 'main.php', ); - $lnk_goto = 'sql.php' . PMA_generate_common_url( - $_url_params, 'text' - ); + $lnk_goto = 'sql.php' + . PMA_generate_common_url( + $_url_params, 'text' + ); $_url_params = array( 'db' => 'mysql', @@ -1698,12 +1704,12 @@ function PMA_displayTableBody(&$dt_result, &$is_display, $map, $analyzed_sql) if (! isset($js_conf)) { $js_conf = ''; } - echo PMA_generateCheckboxAndLinks( - 'left', $del_url, $is_display, - $row_no, $where_clause, $where_clause_html, $condition_array, - $del_query, 'l', $edit_url, $copy_url, $edit_anchor_class, - $edit_str, $copy_str, $del_str, $js_conf - ); + $table_body_html .= PMA_generateCheckboxAndLinks( + 'left', $del_url, $is_display, + $row_no, $where_clause, $where_clause_html, $condition_array, + $del_query, 'l', $edit_url, $copy_url, $edit_anchor_class, + $edit_str, $copy_str, $del_str, $js_conf + ); } elseif (($GLOBALS['cfg']['RowActionLinks'] == 'none') && ($_SESSION['tmp_user_values']['disp_direction'] == 'horizontal' || $_SESSION['tmp_user_values']['disp_direction'] == 'horizontalflipped') @@ -1711,12 +1717,12 @@ function PMA_displayTableBody(&$dt_result, &$is_display, $map, $analyzed_sql) if (! isset($js_conf)) { $js_conf = ''; } - echo PMA_generateCheckboxAndLinks( - 'none', $del_url, $is_display, - $row_no, $where_clause, $where_clause_html, $condition_array, - $del_query, 'l', $edit_url, $copy_url, $edit_anchor_class, - $edit_str, $copy_str, $del_str, $js_conf - ); + $table_body_html .= PMA_generateCheckboxAndLinks( + 'none', $del_url, $is_display, + $row_no, $where_clause, $where_clause_html, $condition_array, + $del_query, 'l', $edit_url, $copy_url, $edit_anchor_class, + $edit_str, $copy_str, $del_str, $js_conf + ); } // end if (1.3) } // end if (1) @@ -1789,13 +1795,13 @@ function PMA_displayTableBody(&$dt_result, &$is_display, $map, $analyzed_sql) && !empty($GLOBALS['mime_map'][$meta->name]['transformation']) ) { $include_file = PMA_securePath( - $GLOBALS['mime_map'][$meta->name]['transformation'] - ); - if (file_exists('./libraries/transformations/' . $include_file)) { - $transformfunction_name = str_replace( - '.inc.php', '', $GLOBALS['mime_map'][$meta->name]['transformation'] ); + if (file_exists('./libraries/transformations/' . $include_file)) { + $transformfunction_name = str_replace( + '.inc.php', '', + $GLOBALS['mime_map'][$meta->name]['transformation'] + ); include_once './libraries/transformations/' . $include_file; @@ -1803,14 +1809,14 @@ function PMA_displayTableBody(&$dt_result, &$is_display, $map, $analyzed_sql) $transform_function = 'PMA_transformation_' . $transformfunction_name; $transform_options = PMA_transformation_getOptions( - isset($GLOBALS['mime_map'][$meta->name]['transformation_options']) - ? $GLOBALS['mime_map'][$meta->name]['transformation_options'] - : '' - ); + isset($GLOBALS['mime_map'][$meta->name]['transformation_options']) + ? $GLOBALS['mime_map'][$meta->name]['transformation_options'] + : '' + ); $meta->mimetype = str_replace( - '_', '/', - $GLOBALS['mime_map'][$meta->name]['mimetype'] - ); + '_', '/', + $GLOBALS['mime_map'][$meta->name]['mimetype'] + ); } } // end if file_exists } // end if transformation is set @@ -1827,8 +1833,7 @@ function PMA_displayTableBody(&$dt_result, &$is_display, $map, $analyzed_sql) $_url_params['sql_query'] = $url_sql_query; } - $transform_options['wrapper_link'] - = PMA_generate_common_url($_url_params); + $transform_options['wrapper_link'] = PMA_generate_common_url($_url_params); // n u m e r i c if ($meta->numeric == 1) { @@ -1840,8 +1845,8 @@ function PMA_displayTableBody(&$dt_result, &$is_display, $map, $analyzed_sql) if (! isset($row[$i]) || is_null($row[$i])) { $vertical_display['data'][$row_no][$i] = PMA_buildNullDisplay( - 'right '.$class, $condition_field, $meta, '' - ); + 'right '.$class, $condition_field, $meta, '' + ); } elseif ($row[$i] != '') { $nowrap = ' nowrap'; @@ -1857,8 +1862,8 @@ function PMA_displayTableBody(&$dt_result, &$is_display, $map, $analyzed_sql) ); } else { $vertical_display['data'][$row_no][$i] = PMA_buildEmptyDisplay( - 'right '.$class, $condition_field, $meta, '' - ); + 'right '.$class, $condition_field, $meta, '' + ); } // b l o b @@ -1876,14 +1881,14 @@ function PMA_displayTableBody(&$dt_result, &$is_display, $map, $analyzed_sql) = PMA_buildNullDisplay($class, $condition_field, $meta); } else { $blobtext = PMA_handle_non_printable_contents( - 'BLOB', (isset($row[$i]) ? $row[$i] : ''), - $transform_function, $transform_options, - $default_function, $meta, $_url_params - ); + 'BLOB', (isset($row[$i]) ? $row[$i] : ''), + $transform_function, $transform_options, + $default_function, $meta, $_url_params + ); $vertical_display['data'][$row_no][$i] = PMA_buildValueDisplay( - $class, $condition_field, $blobtext - ); + $class, $condition_field, $blobtext + ); unset($blobtext); } // not binary: @@ -1897,14 +1902,13 @@ function PMA_displayTableBody(&$dt_result, &$is_display, $map, $analyzed_sql) if (PMA_strlen($row[$i]) > $GLOBALS['cfg']['LimitChars'] && $_SESSION['tmp_user_values']['display_text'] == 'P' ) { - $row[$i] = PMA_substr( - $row[$i], 0, $GLOBALS['cfg']['LimitChars'] - ) . '...'; + $row[$i] = PMA_substr($row[$i], 0, $GLOBALS['cfg']['LimitChars']) + . '...'; $is_field_truncated = true; } // displays all space characters, 4 space // characters for tabulations and / - $row[$i] = $default_function != $transform_function + $row[$i] = ($default_function != $transform_function) ? $transform_function($row[$i], $transform_options, $meta) : $default_function($row[$i], array(), $meta); @@ -1913,8 +1917,8 @@ function PMA_displayTableBody(&$dt_result, &$is_display, $map, $analyzed_sql) } $vertical_display['data'][$row_no][$i] = PMA_buildValueDisplay( - $class, $condition_field, $row[$i] - ); + $class, $condition_field, $row[$i] + ); } else { $vertical_display['data'][$row_no][$i] = PMA_buildEmptyDisplay($class, $condition_field, $meta); @@ -1934,13 +1938,13 @@ function PMA_displayTableBody(&$dt_result, &$is_display, $map, $analyzed_sql) // Display as [GEOMETRY - (size)] if ('GEOM' == $_SESSION['tmp_user_values']['geometry_display']) { $geometry_text = PMA_handle_non_printable_contents( - 'GEOMETRY', (isset($row[$i]) ? $row[$i] : ''), - $transform_function, $transform_options, - $default_function, $meta - ); + 'GEOMETRY', (isset($row[$i]) ? $row[$i] : ''), + $transform_function, $transform_options, + $default_function, $meta + ); $vertical_display['data'][$row_no][$i] = PMA_buildValueDisplay( - $class, $condition_field, $geometry_text - ); + $class, $condition_field, $geometry_text + ); // Display in Well Known Text(WKT) format. } elseif ('WKT' == $_SESSION['tmp_user_values']['geometry_display']) { @@ -1952,9 +1956,8 @@ function PMA_displayTableBody(&$dt_result, &$is_display, $map, $analyzed_sql) if (PMA_strlen($wktval) > $GLOBALS['cfg']['LimitChars'] && $_SESSION['tmp_user_values']['display_text'] == 'P' ) { - $wktval = PMA_substr( - $wktval, 0, $GLOBALS['cfg']['LimitChars'] - ) . '...'; + $wktval = PMA_substr($wktval, 0, $GLOBALS['cfg']['LimitChars']) + . '...'; $is_field_truncated = true; } @@ -1977,16 +1980,15 @@ function PMA_displayTableBody(&$dt_result, &$is_display, $map, $analyzed_sql) $wkbval = PMA_substr(bin2hex($row[$i]), 8); } else { $wkbval = htmlspecialchars( - PMA_replace_binary_contents($row[$i]) - ); + PMA_replace_binary_contents($row[$i]) + ); } if (PMA_strlen($wkbval) > $GLOBALS['cfg']['LimitChars'] && $_SESSION['tmp_user_values']['display_text'] == 'P' ) { - $wkbval = PMA_substr( - $wkbval, 0, $GLOBALS['cfg']['LimitChars'] - ) . '...'; + $wkbval = PMA_substr($wkbval, 0, $GLOBALS['cfg']['LimitChars']) + . '...'; $is_field_truncated = true; } @@ -2000,10 +2002,10 @@ function PMA_displayTableBody(&$dt_result, &$is_display, $map, $analyzed_sql) ); } else { $wkbval = PMA_handle_non_printable_contents( - 'BINARY', $row[$i], $transform_function, - $transform_options, $default_function, $meta, - $_url_params - ); + 'BINARY', $row[$i], $transform_function, + $transform_options, $default_function, $meta, + $_url_params + ); $vertical_display['data'][$row_no][$i] = PMA_buildValueDisplay($class, $condition_field, $wkbval); } @@ -2028,9 +2030,8 @@ function PMA_displayTableBody(&$dt_result, &$is_display, $map, $analyzed_sql) && $_SESSION['tmp_user_values']['display_text'] == 'P' && !strpos($transform_function, 'link') === true ) { - $row[$i] = PMA_substr( - $row[$i], 0, $GLOBALS['cfg']['LimitChars'] - ) . '...'; + $row[$i] = PMA_substr($row[$i], 0, $GLOBALS['cfg']['LimitChars']) + . '...'; $is_field_truncated = true; } @@ -2039,8 +2040,8 @@ function PMA_displayTableBody(&$dt_result, &$is_display, $map, $analyzed_sql) $formatted = false; if (isset($meta->_type) && $meta->_type === MYSQLI_TYPE_BIT) { $row[$i] = PMA_printable_bit_value( - $row[$i], $meta->length - ); + $row[$i], $meta->length + ); // some results of PROCEDURE ANALYSE() are reported as // being BINARY but they are quite readable, // so don't treat them as BINARY @@ -2057,36 +2058,36 @@ function PMA_displayTableBody(&$dt_result, &$is_display, $map, $analyzed_sql) $row[$i] = bin2hex($row[$i]); } else { $row[$i] = htmlspecialchars( - PMA_replace_binary_contents($row[$i]) - ); + PMA_replace_binary_contents($row[$i]) + ); } } else { // we show the BINARY message and field's size // (or maybe use a transformation) $row[$i] = PMA_handle_non_printable_contents( - 'BINARY', $row[$i], $transform_function, - $transform_options, $default_function, - $meta, $_url_params - ); + 'BINARY', $row[$i], $transform_function, + $transform_options, $default_function, + $meta, $_url_params + ); $formatted = true; } } if ($formatted) { $vertical_display['data'][$row_no][$i] = PMA_buildValueDisplay( - $class, $condition_field, $row[$i] - ); + $class, $condition_field, $row[$i] + ); } else { // transform functions may enable no-wrapping: $function_nowrap = $transform_function . '_nowrap'; $bool_nowrap = (($default_function != $transform_function - && function_exists($function_nowrap)) + && function_exists($function_nowrap)) ? $function_nowrap($transform_options) : false); // do not wrap if date field type $nowrap = ((preg_match('@DATE|TIME@i', $meta->type) - || $bool_nowrap) + || $bool_nowrap) ? ' nowrap' : ''); $where_comparison = ' = \'' . PMA_sqlAddSlashes($row[$i]) @@ -2110,7 +2111,7 @@ function PMA_displayTableBody(&$dt_result, &$is_display, $map, $analyzed_sql) if ($_SESSION['tmp_user_values']['disp_direction'] == 'horizontal' || $_SESSION['tmp_user_values']['disp_direction'] == 'horizontalflipped' ) { - echo $vertical_display['data'][$row_no][$i]; + $table_body_html .= $vertical_display['data'][$row_no][$i]; } if (isset($vertical_display['rowdata'][$i][$row_no])) { @@ -2131,20 +2132,18 @@ function PMA_displayTableBody(&$dt_result, &$is_display, $map, $analyzed_sql) if (! isset($js_conf)) { $js_conf = ''; } - echo PMA_generateCheckboxAndLinks( - 'right', $del_url, $is_display, - $row_no, $where_clause, $where_clause_html, $condition_array, - $del_query, 'r', $edit_url, $copy_url, $edit_anchor_class, $edit_str, - $copy_str, $del_str, $js_conf - ); + $table_body_html .= PMA_generateCheckboxAndLinks( + 'right', $del_url, $is_display, + $row_no, $where_clause, $where_clause_html, $condition_array, + $del_query, 'r', $edit_url, $copy_url, $edit_anchor_class, $edit_str, + $copy_str, $del_str, $js_conf + ); } // end if (3) if ($_SESSION['tmp_user_values']['disp_direction'] == 'horizontal' || $_SESSION['tmp_user_values']['disp_direction'] == 'horizontalflipped' ) { - ?> - - '; } // end if // 4. Gather links of del_urls and edit_urls in an array for later @@ -2165,31 +2164,31 @@ function PMA_displayTableBody(&$dt_result, &$is_display, $map, $analyzed_sql) if (!empty($del_url) && $is_display['del_lnk'] != 'kp') { $vertical_display['row_delete'][$row_no] .= PMA_generateCheckboxForMulti( - $del_url, $is_display, $row_no, $where_clause_html, $condition_array, - $del_query, '[%_PMA_CHECKBOX_DIR_%]', - $alternating_color_class . $vertical_class - ); + $del_url, $is_display, $row_no, $where_clause_html, $condition_array, + $del_query, '[%_PMA_CHECKBOX_DIR_%]', + $alternating_color_class . $vertical_class + ); } else { unset($vertical_display['row_delete'][$row_no]); } if (isset($edit_url)) { $vertical_display['edit'][$row_no] .= PMA_generateEditLink( - $edit_url, - $alternating_color_class . ' ' . $edit_anchor_class - . $vertical_class, $edit_str, - $where_clause, - $where_clause_html - ); + $edit_url, + $alternating_color_class . ' ' . $edit_anchor_class + . $vertical_class, $edit_str, + $where_clause, + $where_clause_html + ); } else { unset($vertical_display['edit'][$row_no]); } if (isset($copy_url)) { $vertical_display['copy'][$row_no] .= PMA_generateCopyLink( - $copy_url, $copy_str, $where_clause, $where_clause_html, - $alternating_color_class . $vertical_class - ); + $copy_url, $copy_str, $where_clause, $where_clause_html, + $alternating_color_class . $vertical_class + ); } else { unset($vertical_display['copy'][$row_no]); } @@ -2199,20 +2198,23 @@ function PMA_displayTableBody(&$dt_result, &$is_display, $map, $analyzed_sql) $js_conf = ''; } $vertical_display['delete'][$row_no] .= PMA_generateDeleteLink( - $del_url, $del_str, $js_conf, - $alternating_color_class . $vertical_class - ); + $del_url, $del_str, $js_conf, + $alternating_color_class . $vertical_class + ); } else { unset($vertical_display['delete'][$row_no]); } - echo (($_SESSION['tmp_user_values']['disp_direction'] == 'horizontal' + $table_body_html .= (($_SESSION['tmp_user_values']['disp_direction'] == 'horizontal' || $_SESSION['tmp_user_values']['disp_direction'] == 'horizontalflipped') ? "\n" : ''); $row_no++; } // end while + // render the html content of table body + echo $table_body_html; + // this is needed by PMA_displayTable() to generate the proper param // in the multi-edit and multi-delete form return $clause_is_unique; From 57723b6b764d08f0d0cf0decd97540869acbff98 Mon Sep 17 00:00:00 2001 From: Chanaka Indrajith Date: Thu, 10 May 2012 18:04:26 +0530 Subject: [PATCH 05/17] Reduce HTML echo renderings in PMA_displayResultsOperations function --- libraries/display_tbl.lib.php | 85 ++++++++++++++++++++--------------- 1 file changed, 48 insertions(+), 37 deletions(-) diff --git a/libraries/display_tbl.lib.php b/libraries/display_tbl.lib.php index cc7bc35d76..10806345c0 100644 --- a/libraries/display_tbl.lib.php +++ b/libraries/display_tbl.lib.php @@ -3102,6 +3102,7 @@ function PMA_displayResultsOperations($the_disp_mode, $analyzed_sql) { global $db, $table, $sql_query, $unlim_num_rows, $fields_meta; + $results_operations_html = ''; $header_shown = false; $header = '
' . __('Query results operations') . ''; @@ -3110,7 +3111,7 @@ function PMA_displayResultsOperations($the_disp_mode, $analyzed_sql) if ($the_disp_mode[9] == '1') { if (!$header_shown) { - echo $header; + $results_operations_html .= $header; $header_shown = true; } @@ -3122,21 +3123,23 @@ function PMA_displayResultsOperations($the_disp_mode, $analyzed_sql) ); $url_query = PMA_generate_common_url($_url_params); - echo PMA_linkOrButton( - 'sql.php' . $url_query, - PMA_getIcon('b_print.png', __('Print view'), true), - '', true, true, 'print_view' - ) . "\n"; + $results_operations_html .= PMA_linkOrButton( + 'sql.php' . $url_query, + PMA_getIcon('b_print.png', __('Print view'), true), + '', true, true, 'print_view' + ) + . "\n"; if ($_SESSION['tmp_user_values']['display_text']) { $_url_params['display_text'] = 'F'; - echo PMA_linkOrButton( - 'sql.php' . PMA_generate_common_url($_url_params), - PMA_getIcon( - 'b_print.png', __('Print view (with full texts)'), true - ), - '', true, true, 'print_view' - ) . "\n"; + $results_operations_html .= PMA_linkOrButton( + 'sql.php' . PMA_generate_common_url($_url_params), + PMA_getIcon( + 'b_print.png', __('Print view (with full texts)'), true + ), + '', true, true, 'print_view' + ) + . "\n"; unset($_url_params['display_text']); } } // end displays "printable view" @@ -3160,7 +3163,7 @@ function PMA_displayResultsOperations($the_disp_mode, $analyzed_sql) $_url_params['single_table'] = 'true'; } if (!$header_shown) { - echo $header; + $results_operations_html .= $header; $header_shown = true; } $_url_params['unlim_num_rows'] = $unlim_num_rows; @@ -3181,18 +3184,20 @@ function PMA_displayResultsOperations($the_disp_mode, $analyzed_sql) } } - echo PMA_linkOrButton( - 'tbl_export.php' . PMA_generate_common_url($_url_params), - PMA_getIcon('b_tblexport.png', __('Export'), true), - '', true, true, '' - ) . "\n"; + $results_operations_html .= PMA_linkOrButton( + 'tbl_export.php' . PMA_generate_common_url($_url_params), + PMA_getIcon('b_tblexport.png', __('Export'), true), + '', true, true, '' + ) + . "\n"; // show chart - echo PMA_linkOrButton( - 'tbl_chart.php' . PMA_generate_common_url($_url_params), - PMA_getIcon('b_chart.png', __('Display chart'), true), - '', true, true, '' - ) . "\n"; + $results_operations_html .= PMA_linkOrButton( + 'tbl_chart.php' . PMA_generate_common_url($_url_params), + PMA_getIcon('b_chart.png', __('Display chart'), true), + '', true, true, '' + ) + . "\n"; // show GIS chart $geometry_found = false; @@ -3204,11 +3209,12 @@ function PMA_displayResultsOperations($the_disp_mode, $analyzed_sql) } } if ($geometry_found) { - echo PMA_linkOrButton( - 'tbl_gis_visualization.php' . PMA_generate_common_url($_url_params), - PMA_getIcon('b_globe.gif', __('Visualize GIS data'), true), - '', true, true, '' - ) . "\n"; + $results_operations_html .= PMA_linkOrButton( + 'tbl_gis_visualization.php' . PMA_generate_common_url($_url_params), + PMA_getIcon('b_globe.gif', __('Visualize GIS data'), true), + '', true, true, '' + ) + . "\n"; } } @@ -3221,21 +3227,26 @@ function PMA_displayResultsOperations($the_disp_mode, $analyzed_sql) * Note: we don't display a Create view link if we found a PROCEDURE clause */ if (!$header_shown) { - echo $header; + $results_operations_html .= $header; $header_shown = true; } if (!PMA_DRIZZLE && !isset($analyzed_sql[0]['queryflags']['procedure'])) { $ajax_class = $GLOBALS['cfg']['AjaxEnable'] ? ' ajax' : ''; - echo ""; - echo PMA_linkOrButton( - 'view_create.php' . $url_query, - PMA_getIcon('b_views.png', __('Create view'), true), - '', true, true, '' - ) . "\n"; + $results_operations_html .= '' + . PMA_linkOrButton( + 'view_create.php' . $url_query, + PMA_getIcon('b_views.png', __('Create view'), true), + '', true, true, '' + ) + . '' . "\n"; } if ($header_shown) { - echo '

'; + $results_operations_html .= '
'; } + + // render HTML content of results operations + echo $results_operations_html; + } /** From 61360750cacb245ef61b62f0134788af7bd8295b Mon Sep 17 00:00:00 2001 From: Chanaka Indrajith Date: Fri, 11 May 2012 11:53:45 +0530 Subject: [PATCH 06/17] Modified some functions in common.lib.php file --- libraries/common.lib.php | 31 +++++++++++-------------------- 1 file changed, 11 insertions(+), 20 deletions(-) diff --git a/libraries/common.lib.php b/libraries/common.lib.php index f532d770d6..556fc1787d 100644 --- a/libraries/common.lib.php +++ b/libraries/common.lib.php @@ -1335,16 +1335,8 @@ function PMA_showMessage( $retval .= '
'; } - // If we are in an Ajax request, we have most probably been called in - // PMA_ajaxResponse(). Hence, collect the buffer contents and return it - // to PMA_ajaxResponse(), which will encode it for JSON. - if ($GLOBALS['is_ajax_request'] == true - && ! isset($GLOBALS['buffer_message']) - ) { - return $retval; - } else { - echo $retval; - } + return $retval; + } // end of the 'PMA_showMessage()' function /** @@ -2267,33 +2259,32 @@ function PMA_getUniqueCondition($handle, $fields_cnt, $fields_meta, $row, * @param string $image image to display * @param string $value value * - * @return void + * @return string html content * * @access public */ -function PMA_buttonOrImage($button_name, $button_class, $image_name, $text, +function PMA_getButtonOrImage($button_name, $button_class, $image_name, $text, $image, $value = '' ) { if ($value == '') { $value = $text; } if (false === $GLOBALS['cfg']['PropertiesIconic']) { - echo ' ' . "\n"; - return; + return ' ' . "\n"; } /* Opera has trouble with */ /* IE has trouble with ' . "\n"; } else { - echo '' @@ -2678,11 +2669,11 @@ function PMA_getRadioFields($html_field_name, $choices, $checked_choice = '', * case the dropdown is present more than once * on the page * - * @return string + * @return string html content * * @todo support titles */ -function PMA_generate_html_dropdown($select_name, $choices, $active_choice, $id) +function PMA_getDropdown($select_name, $choices, $active_choice, $id) { $result = '
-' + . '' + . PMA_generate_common_hidden_inputs($db, $table) + . '' + . '' + . '' + . $input_for_real_end + . '' + . '' + . ''; + +} // end function PMA_getTableNavigationButton() /** - * Displays a navigation bar to browse among the results of a SQL query + * Get a navigation bar to browse among the results of a SQL query * * @param integer $pos_next the offset for the "next" page * @param integer $pos_prev the offset for the "previous" page * @param string $sql_query the URL-encoded query * @param string $id_for_direction_dropdown the id for the direction dropdown * - * @return void + * @return string html content * * @global string $db the database name * @global string $table the table name @@ -295,15 +293,17 @@ function PMA_displayTableNavigationButton($caption, $title, $pos, $html_sql_quer * * @access private * - * @see PMA_displayTable() + * @see PMA_getTable() */ -function PMA_displayTableNavigation($pos_next, $pos_prev, $sql_query, +function PMA_getTableNavigation($pos_next, $pos_prev, $sql_query, $id_for_direction_dropdown ) { global $db, $table, $goto; global $num_rows, $unlim_num_rows; global $is_innodb; global $showtable; + + $table_navigation_html = ''; // here, using htmlentities() would cause problems if the query // contains accented characters @@ -315,24 +315,22 @@ function PMA_displayTableNavigation($pos_next, $pos_prev, $sql_query, */ $is_innodb = (isset($showtable['Type']) && $showtable['Type'] == 'InnoDB'); - ?> - - -
' - . $full_or_partial_text_link . '' . $full_or_partial_text_link - . '' . $full_or_partial_text_link + . '
NULL
' - . "\n".'  ' + . "\n".'  ' - . "\n" . '  ' + . "\n" . '  
-
> - - - - - - value="" /> -
-
- - - ' + . '' + . ''; + // Move to the beginning or to the previous page if ($_SESSION['tmp_user_values']['pos'] && $_SESSION['tmp_user_values']['max_rows'] != 'all' ) { - PMA_displayTableNavigationButton( - '<<', _pgettext('First page', 'Begin'), 0, $html_sql_query - ); - PMA_displayTableNavigationButton( - '<', _pgettext('Previous page', 'Previous'), $pos_prev, - $html_sql_query - ); + $table_navigation_html .= PMA_getTableNavigationButton( + '<<', _pgettext('First page', 'Begin'), 0, $html_sql_query + ); + $table_navigation_html .= PMA_getTableNavigationButton( + '<', _pgettext('Previous page', 'Previous'), $pos_prev, + $html_sql_query + ); } // end move back @@ -341,18 +339,17 @@ function PMA_displayTableNavigation($pos_next, $pos_prev, $sql_query, // (unless we are showing all records) if ('all' != $_SESSION['tmp_user_values']['max_rows']) { //if1 $pageNow = @floor( - $_SESSION['tmp_user_values']['pos'] - / $_SESSION['tmp_user_values']['max_rows'] - ) + 1; + $_SESSION['tmp_user_values']['pos'] + / $_SESSION['tmp_user_values']['max_rows'] + ) + 1; $nbTotalPage = @ceil( - $unlim_num_rows - / $_SESSION['tmp_user_values']['max_rows'] - ); + $unlim_num_rows + / $_SESSION['tmp_user_values']['max_rows'] + ); if ($nbTotalPage > 1) { //if2 - ?> - - ' + . ''; + } //_if2 } //_if1 @@ -385,21 +378,19 @@ function PMA_displayTableNavigation($pos_next, $pos_prev, $sql_query, && ($GLOBALS['cfg']['ShowAll'] || ($GLOBALS['cfg']['MaxRows'] * 5 >= $unlim_num_rows)) ) { - echo "\n"; - ?> - - ' + . '' + . PMA_generate_common_hidden_inputs($db, $table) + . '' + . '' + . '' + . '' + . '' + . '' + . ''; + } // end show all // Move to the next page or to the last one @@ -408,12 +399,12 @@ function PMA_displayTableNavigation($pos_next, $pos_prev, $sql_query, && $_SESSION['tmp_user_values']['max_rows'] != 'all' ) { // display the Next button - PMA_displayTableNavigationButton( - '>', - _pgettext('Next page', 'Next'), - $pos_next, - $html_sql_query - ); + $table_navigation_html .= PMA_getTableNavigationButton( + '>', + _pgettext('Next page', 'Next'), + $pos_next, + $html_sql_query + ); // prepare some options for the End button if ($is_innodb && $unlim_num_rows > $GLOBALS['cfg']['MaxExactCount']) { @@ -432,101 +423,111 @@ function PMA_displayTableNavigation($pos_next, $pos_prev, $sql_query, ? 'true' : 'false' . '"'; // display the End button - PMA_displayTableNavigationButton( - '>>', - _pgettext('Last page', 'End'), - @((ceil($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 - ); + $table_navigation_html .= PMA_getTableNavigationButton( + '>>', + _pgettext('Last page', 'End'), + @((ceil($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 + ); } // end move toward // show separator if pagination happen if ($nbTotalPage > 1) { - echo ''; + $table_navigation_html .= ''; } - ?> - - + + $table_navigation_html .= '' + . ''; - - - - - + $table_navigation_html .= __('Headers every') + . ' ' + . __('rows') + . "\n"; - ' + . '' + . '' + . '' + . ''; + + return $table_navigation_html; + +} // end of the 'PMA_getTableNavigation()' function /** - * Displays the headers of the results table + * Get the headers of the results table * * @param array &$is_display which elements to display * @param array &$fields_meta the list of fields properties @@ -537,7 +538,7 @@ function PMA_displayTableNavigation($pos_next, $pos_prev, $sql_query, * @param string $sort_expression_nodirection sort expression without direction * @param string $sort_direction sort direction * - * @return boolean $clause_is_unique + * @return string html content * * @global string $db the database name * @global string $table the table name @@ -550,9 +551,9 @@ function PMA_displayTableNavigation($pos_next, $pos_prev, $sql_query, * * @access private * - * @see PMA_displayTable() + * @see PMA_getTable() */ -function PMA_displayTableHeaders(&$is_display, &$fields_meta, $fields_cnt = 0, +function PMA_getTableHeaders(&$is_display, &$fields_meta, $fields_cnt = 0, $analyzed_sql = '', $sort_expression = '', $sort_expression_nodirection = '', $sort_direction = '' ) { @@ -1350,11 +1351,8 @@ function PMA_displayTableHeaders(&$is_display, &$fields_meta, $fields_cnt = 0, } - // render all HTML content related to table headers - echo $table_headers_html; - - return true; -} // end of the 'PMA_displayTableHeaders()' function + return $table_headers_html; +} // end of the 'PMA_getTableHeaders()' function /** @@ -1404,10 +1402,9 @@ function PMA_buildNullDisplay($class, $condition_field, $meta, $align = '') */ function PMA_buildEmptyDisplay($class, $condition_field, $meta, $align = '') { - $nowrap = ' nowrap'; return ''; } @@ -1455,7 +1452,7 @@ function PMA_addClass($class, $condition_field, $meta, $nowrap, . $enum_class . $set_class . $bit_class . $mime_type_class; } /** - * Displays the body of the results table + * Prepare the body of the results table * * @param integer &$dt_result the link id associated to the query * which results have to be displayed @@ -1463,7 +1460,7 @@ function PMA_addClass($class, $condition_field, $meta, $nowrap, * @param array $map the list of relations * @param array $analyzed_sql the analyzed query * - * @return boolean always true + * @return array ($table_body_html, $clause_is_unique) * * @global string $db the database name * @global string $table the table name @@ -1479,9 +1476,9 @@ function PMA_addClass($class, $condition_field, $meta, $nowrap, * * @access private * - * @see PMA_displayTable() + * @see PMA_getTable() */ -function PMA_displayTableBody(&$dt_result, &$is_display, $map, $analyzed_sql) +function PMA_getTableBodyParams(&$dt_result, &$is_display, $map, $analyzed_sql) { global $db, $table, $goto; global $sql_query, $fields_meta, $fields_cnt; @@ -1704,7 +1701,7 @@ function PMA_displayTableBody(&$dt_result, &$is_display, $map, $analyzed_sql) if (! isset($js_conf)) { $js_conf = ''; } - $table_body_html .= PMA_generateCheckboxAndLinks( + $table_body_html .= PMA_getCheckboxAndLinks( 'left', $del_url, $is_display, $row_no, $where_clause, $where_clause_html, $condition_array, $del_query, 'l', $edit_url, $copy_url, $edit_anchor_class, @@ -1717,7 +1714,7 @@ function PMA_displayTableBody(&$dt_result, &$is_display, $map, $analyzed_sql) if (! isset($js_conf)) { $js_conf = ''; } - $table_body_html .= PMA_generateCheckboxAndLinks( + $table_body_html .= PMA_getCheckboxAndLinks( 'none', $del_url, $is_display, $row_no, $where_clause, $where_clause_html, $condition_array, $del_query, 'l', $edit_url, $copy_url, $edit_anchor_class, @@ -1853,7 +1850,7 @@ function PMA_displayTableBody(&$dt_result, &$is_display, $map, $analyzed_sql) $where_comparison = ' = ' . $row[$i]; $vertical_display['data'][$row_no][$i] = ' 0 @@ -2269,7 +2263,7 @@ function PMA_displayVerticalTable() $vertical_table_html .= '' . "\n"; } // end if - // Displays "edit" link at top if required + // Prepares "edit" link at top if required if (($GLOBALS['cfg']['RowActionLinks'] == 'left' || $GLOBALS['cfg']['RowActionLinks'] == 'both') && is_array($vertical_display['edit']) @@ -2286,7 +2280,7 @@ function PMA_displayVerticalTable() $vertical_table_html .= '' . "\n"; } // end if - // Displays "copy" link at top if required + // Prepares "copy" link at top if required if (($GLOBALS['cfg']['RowActionLinks'] == 'left' || $GLOBALS['cfg']['RowActionLinks'] == 'both') && is_array($vertical_display['copy']) @@ -2303,7 +2297,7 @@ function PMA_displayVerticalTable() $vertical_table_html .= '' . "\n"; } // end if - // Displays "delete" link at top if required + // Prepares "delete" link at top if required if (($GLOBALS['cfg']['RowActionLinks'] == 'left' || $GLOBALS['cfg']['RowActionLinks'] == 'both') && is_array($vertical_display['delete']) @@ -2332,7 +2326,7 @@ function PMA_displayVerticalTable() $col_visib = false; } - // Displays data + // Prepares data foreach ($vertical_display['desc'] AS $j => $val) { // assign appropriate key with current column order $key = $col_order ? $col_order[$j] : $j; @@ -2357,7 +2351,7 @@ function PMA_displayVerticalTable() $vertical_table_html .= '' . "\n"; } // end while - // Displays "multi row delete" link at bottom if required + // Prepares "multi row delete" link at bottom if required if (($GLOBALS['cfg']['RowActionLinks'] == 'right' || $GLOBALS['cfg']['RowActionLinks'] == 'both') && is_array($vertical_display['row_delete']) @@ -2384,7 +2378,7 @@ function PMA_displayVerticalTable() $vertical_table_html .= '' . "\n"; } // end if - // Displays "edit" link at bottom if required + // Prepares "edit" link at bottom if required if (($GLOBALS['cfg']['RowActionLinks'] == 'right' || $GLOBALS['cfg']['RowActionLinks'] == 'both') && is_array($vertical_display['edit']) @@ -2401,7 +2395,7 @@ function PMA_displayVerticalTable() $vertical_table_html .= '' . "\n"; } // end if - // Displays "copy" link at bottom if required + // Prepares "copy" link at bottom if required if (($GLOBALS['cfg']['RowActionLinks'] == 'right' || $GLOBALS['cfg']['RowActionLinks'] == 'both') && is_array($vertical_display['copy']) @@ -2418,7 +2412,7 @@ function PMA_displayVerticalTable() $vertical_table_html .= '' . "\n"; } // end if - // Displays "delete" link at bottom if required + // Prepares "delete" link at bottom if required if (($GLOBALS['cfg']['RowActionLinks'] == 'right' || $GLOBALS['cfg']['RowActionLinks'] == 'both') && is_array($vertical_display['delete']) @@ -2436,12 +2430,9 @@ function PMA_displayVerticalTable() } // end while $vertical_table_html .= '' . "\n"; } - - // render HTML content of verticle table - echo $vertical_table_html; - return true; -} // end of the 'PMA_displayVerticalTable' function + return $vertical_table_html; +} // end of the 'PMA_getVerticalTable' function /** * Checks the posted options for viewing query resutls @@ -2454,16 +2445,16 @@ function PMA_displayVerticalTable() * * @return void */ -function PMA_displayTable_checkConfigParams() +function PMA_setConfigParamsForDisplayTable() { $sql_md5 = md5($GLOBALS['sql_query']); $_SESSION['tmp_user_values']['query'][$sql_md5]['sql'] = $GLOBALS['sql_query']; $valid_disp_dir = PMA_isValid( - $_REQUEST['disp_direction'], - array('horizontal', 'vertical', 'horizontalflipped') - ); + $_REQUEST['disp_direction'], + array('horizontal', 'vertical', 'horizontalflipped') + ); if ($valid_disp_dir) { $_SESSION['tmp_user_values']['query'][$sql_md5]['disp_direction'] = $_REQUEST['disp_direction']; @@ -2625,13 +2616,15 @@ function PMA_displayTable_checkConfigParams() } /** - * Displays a table of results returned by a SQL query. + * Prepare a table of results returned by a SQL query. * This function is called by the "sql.php" script. * * @param integer &$dt_result the link id associated to the query * which results have to be displayed * @param array &$the_disp_mode the display mode * @param array $analyzed_sql the analyzed query + * + * @return sting Generated HTML content for resulted table * * @global string $db the database name * @global string $table the table name @@ -2653,22 +2646,24 @@ function PMA_displayTable_checkConfigParams() * * @access private * - * @see PMA_showMessage(), PMA_setDisplayMode(), - * PMA_displayTableNavigation(), PMA_displayTableHeaders(), - * PMA_displayTableBody(), PMA_displayResultsOperations() + * @see PMA_getMessage(), PMA_setDisplayMode(), + * PMA_getTableNavigation(), PMA_getTableHeaders(), + * PMA_getTableBodyParams(), PMA_getResultsOperations() * * @return void */ -function PMA_displayTable(&$dt_result, &$the_disp_mode, $analyzed_sql) +function PMA_getTable(&$dt_result, &$the_disp_mode, $analyzed_sql) { global $db, $table, $goto; global $sql_query, $num_rows, $unlim_num_rows, $fields_meta, $fields_cnt; global $vertical_display, $highlight_columns; global $cfgRelation; global $showtable; + + $table_html = ''; // why was this called here? (already called from sql.php) - //PMA_displayTable_checkConfigParams(); + //PMA_setConfigParamsForDisplayTable(); /** * @todo move this to a central place @@ -2685,10 +2680,10 @@ function PMA_displayTable(&$dt_result, &$the_disp_mode, $analyzed_sql) // "j u s t b r o w s i n g" $pre_count = '~'; $after_count = PMA_showHint( - PMA_sanitize( - __('May be approximate. See [a@./Documentation.html#faq3_11@Documentation]FAQ 3.11[/a]') - ) - ); + PMA_sanitize( + __('May be approximate. See [a@./Documentation.html#faq3_11@Documentation]FAQ 3.11[/a]') + ) + ); } else { $pre_count = ''; $after_count = ''; @@ -2723,8 +2718,8 @@ function PMA_displayTable(&$dt_result, &$the_disp_mode, $analyzed_sql) // even if there are many table references if (! empty($analyzed_sql[0]['order_by_clause'])) { $sort_expression = trim( - str_replace(' ', ' ', $analyzed_sql[0]['order_by_clause']) - ); + str_replace(' ', ' ', $analyzed_sql[0]['order_by_clause']) + ); /** * Get rid of ASC|DESC */ @@ -2769,33 +2764,33 @@ function PMA_displayTable(&$dt_result, &$the_disp_mode, $analyzed_sql) // check for non printable sorted row data $meta = $fields_meta[$sorted_column_index]; if (stristr($meta->type, 'BLOB') || $meta->type == 'geometry') { - $column_for_first_row = PMA_handle_non_printable_contents( - $meta->type, $row[$sorted_column_index], $transform_function, - $transform_options, $default_function, $meta, null - ); + $column_for_first_row = PMA_handleNonPrintableContents( + $meta->type, $row[$sorted_column_index], $transform_function, + $transform_options, $default_function, $meta, null + ); } else { $column_for_first_row = $row[$sorted_column_index]; } $column_for_first_row = strtoupper( - substr($column_for_first_row, 0, $GLOBALS['cfg']['LimitChars']) - ); + substr($column_for_first_row, 0, $GLOBALS['cfg']['LimitChars']) + ); // fetch last row of the result set PMA_DBI_data_seek($dt_result, $num_rows - 1); $row = PMA_DBI_fetch_row($dt_result); // check for non printable sorted row data $meta = $fields_meta[$sorted_column_index]; if (stristr($meta->type, 'BLOB') || $meta->type == 'geometry') { - $column_for_last_row = PMA_handle_non_printable_contents( - $meta->type, $row[$sorted_column_index], $transform_function, - $transform_options, $default_function, $meta, null - ); + $column_for_last_row = PMA_handleNonPrintableContents( + $meta->type, $row[$sorted_column_index], $transform_function, + $transform_options, $default_function, $meta, null + ); } else { $column_for_last_row = $row[$sorted_column_index]; } $column_for_last_row = strtoupper( - substr($column_for_last_row, 0, $GLOBALS['cfg']['LimitChars']) - ); - // reset to first row for the loop in PMA_displayTableBody() + substr($column_for_last_row, 0, $GLOBALS['cfg']['LimitChars']) + ); + // reset to first row for the loop in PMA_getTableBodyParams() PMA_DBI_data_seek($dt_result, 0); // we could also use here $sort_expression_nodirection $sorted_column_message = ' [' . htmlspecialchars($sort_column) @@ -2807,9 +2802,9 @@ function PMA_displayTable(&$dt_result, &$the_disp_mode, $analyzed_sql) unset($sorted_column_index, $sort_table, $sort_column); } - // 2. ----- Displays the top of the page ----- + // 2. ----- Prepare to display the top of the page ----- - // 2.1 Displays a messages with position informations + // 2.1 Prepares a messages with position informations if ($is_display['nav_bar'] == '1' && isset($pos_next)) { if (isset($unlim_num_rows) && $unlim_num_rows != $total) { $selectstring = ', ' . $unlim_num_rows . ' ' . __('in query'); @@ -2838,8 +2833,8 @@ function PMA_displayTable(&$dt_result, &$the_disp_mode, $analyzed_sql) && $total == $GLOBALS['cfg']['MaxExactCountViews'] ) { $message = PMA_Message::notice( - __('This view has at least this number of rows. Please refer to %sdocumentation%s.') - ); + __('This view has at least this number of rows. Please refer to %sdocumentation%s.') + ); $message->addParam('[a@./Documentation.html#cfg_MaxExactCount@_blank]'); $message->addParam('[/a]'); $message_view_warning = PMA_showHint($message); @@ -2873,16 +2868,16 @@ function PMA_displayTable(&$dt_result, &$the_disp_mode, $analyzed_sql) $message->addMessage($sorted_column_message, ''); } - PMA_showMessage($message, $sql_query, 'success'); + $table_html .= PMA_getMessage($message, $sql_query, 'success'); } elseif (! isset($GLOBALS['printview']) || $GLOBALS['printview'] != '1') { - PMA_showMessage( - __('Your SQL query has been executed successfully'), - $sql_query, 'success' - ); + $table_html .= PMA_getMessage( + __('Your SQL query has been executed successfully'), + $sql_query, 'success' + ); } - // 2.3 Displays the navigation bars + // 2.3 Prepare the navigation bars if (! strlen($table)) { if (isset($analyzed_sql[0]['query_type']) && $analyzed_sql[0]['query_type'] == 'SELECT' @@ -2897,12 +2892,12 @@ function PMA_displayTable(&$dt_result, &$the_disp_mode, $analyzed_sql) } if ($is_display['nav_bar'] == '1' && empty($analyzed_sql[0]['limit_clause'])) { - PMA_displayTableNavigation( - $pos_next, $pos_prev, $sql_query, 'top_direction_dropdown' - ); - echo "\n"; + $table_html .= PMA_getTableNavigation( + $pos_next, $pos_prev, $sql_query, 'top_direction_dropdown' + ) + . "\n"; } elseif (! isset($GLOBALS['printview']) || $GLOBALS['printview'] != '1') { - echo "\n" . '

' . "\n"; + $table_html .= "\n" . '

' . "\n"; } // 2b ----- Get field references from Database ----- @@ -2936,40 +2931,42 @@ function PMA_displayTable(&$dt_result, &$the_disp_mode, $analyzed_sql) if ($exist_rel) { foreach ($exist_rel as $master_field => $rel) { $display_field = PMA_getDisplayField( - $rel['foreign_db'], $rel['foreign_table'] - ); + $rel['foreign_db'], $rel['foreign_table'] + ); $map[$master_field] = array( - $rel['foreign_table'], - $rel['foreign_field'], - $display_field, - $rel['foreign_db'] - ); + $rel['foreign_table'], + $rel['foreign_field'], + $display_field, + $rel['foreign_db'] + ); } // end while } // end if } // end if // end 2b - // 3. ----- Displays the results table ----- - PMA_displayTableHeaders( - $is_display, $fields_meta, $fields_cnt, $analyzed_sql, - $sort_expression, $sort_expression_nodirection, $sort_direction - ); - $url_query = ''; - echo '' . "\n"; - $clause_is_unique = PMA_displayTableBody( - $dt_result, $is_display, $map, $analyzed_sql - ); + // 3. ----- Prepare the results table ----- + $table_html .= PMA_getTableHeaders( + $is_display, $fields_meta, $fields_cnt, $analyzed_sql, + $sort_expression, $sort_expression_nodirection, $sort_direction + ) + . '' . "\n"; + + $url_query = ''; + list($table_body_html, $clause_is_unique) = PMA_getTableBodyParams( + $dt_result, $is_display, $map, $analyzed_sql + ); + + $table_html .= $table_body_html; + // vertical output case if ($_SESSION['tmp_user_values']['disp_direction'] == 'vertical') { - PMA_displayVerticalTable(); + $table_html .= PMA_getVerticalTable(); } // end if unset($vertical_display); - echo '' . "\n"; - ?> - - - ' . "\n" + . ''; + + // 4. ----- Prepares the link for multi-fields edit and delete if ($is_display['del_lnk'] == 'dr' && $is_display['del_lnk'] != 'kp') { @@ -2998,68 +2995,71 @@ function PMA_displayTable(&$dt_result, &$the_disp_mode, $analyzed_sql) = 'if (unMarkAllRows(\'resultsForm\')) return false;'; } $checkall_link = PMA_linkOrButton( - $checkall_url, __('Check All'), $checkall_params, false - ); - $uncheckall_link = PMA_linkOrButton( - $uncheckall_url, __('Uncheck All'), $uncheckall_params, false - ); - if ($_SESSION['tmp_user_values']['disp_direction'] != 'vertical') { - echo '' . __('With selected:') . ''; - } - echo $checkall_link . "\n" - .' / ' . "\n" - .$uncheckall_link . "\n" - .'' . __('With selected:') . '' . "\n"; - - PMA_buttonOrImage( - 'submit_mult', 'mult_submit', 'submit_mult_change', - __('Change'), 'b_edit.png', 'edit' - ); - PMA_buttonOrImage( - 'submit_mult', 'mult_submit', 'submit_mult_delete', - $delete_text, 'b_drop.png', 'delete' - ); - if (isset($analyzed_sql[0]) && $analyzed_sql[0]['querytype'] == 'SELECT') { - PMA_buttonOrImage( - 'submit_mult', 'mult_submit', 'submit_mult_export', - __('Export'), 'b_tblexport.png', 'export' + $checkall_url, __('Check All'), $checkall_params, false ); + $uncheckall_link = PMA_linkOrButton( + $uncheckall_url, __('Uncheck All'), $uncheckall_params, false + ); + if ($_SESSION['tmp_user_values']['disp_direction'] != 'vertical') { + $table_html .= '' . __('With selected:') . ''; } - echo "\n"; + $table_html .= $checkall_link . "\n" + . ' / ' . "\n" + . $uncheckall_link . "\n" + . '' . __('With selected:') . '' . "\n"; - echo '' . "\n"; if (! empty($GLOBALS['url_query'])) { - echo '' . "\n"; } - echo '' . "\n"; - echo '' . "\n"; + $table_html .= '' . "\n"; } - // 5. ----- Displays the navigation bar at the bottom if required ----- + // 5. ----- Get the navigation bar at the bottom if required ----- if ($is_display['nav_bar'] == '1' && empty($analyzed_sql[0]['limit_clause'])) { - echo '
' . "\n"; - PMA_displayTableNavigation( - $pos_next, $pos_prev, $sql_query, 'bottom_direction_dropdown' - ); + $table_html .= '
' . "\n"; + $table_html .= PMA_getTableNavigation( + $pos_next, $pos_prev, $sql_query, 'bottom_direction_dropdown' + ); } elseif (! isset($GLOBALS['printview']) || $GLOBALS['printview'] != '1') { - echo "\n" . '

' . "\n"; + $table_html .= "\n" . '

' . "\n"; } - // 6. ----- Displays "Query results operations" + // 6. ----- Prepare "Query results operations" if (! isset($GLOBALS['printview']) || $GLOBALS['printview'] != '1') { - PMA_displayResultsOperations($the_disp_mode, $analyzed_sql); + $table_html .= PMA_getResultsOperations($the_disp_mode, $analyzed_sql); } -} // end of the 'PMA_displayTable()' function + + return $table_html; + +} // end of the 'PMA_getTable()' function /** * replace some html-unfriendly stuff @@ -3078,11 +3078,13 @@ function PMA_mimeDefaultFunction($buffer) } /** - * Displays operations that are available on results. + * Get operations that are available on results. * - * @param array $the_disp_mode the display mode - * @param array $analyzed_sql the analyzed query + * @param array $the_disp_mode the display mode + * @param array $analyzed_sql the analyzed query * + * @return string html content + * * @global string $db the database name * @global string $table the table name * @global string $sql_query the current SQL query @@ -3092,13 +3094,13 @@ function PMA_mimeDefaultFunction($buffer) * * @access private * - * @see PMA_showMessage(), PMA_setDisplayMode(), - * PMA_displayTableNavigation(), PMA_displayTableHeaders(), - * PMA_displayTableBody(), PMA_displayResultsOperations() + * @see PMA_getMessage(), PMA_setDisplayMode(), + * PMA_getTableNavigation(), PMA_getTableHeaders(), + * PMA_getTableBodyParams(), PMA_getResultsOperations() * * @return void */ -function PMA_displayResultsOperations($the_disp_mode, $analyzed_sql) +function PMA_getResultsOperations($the_disp_mode, $analyzed_sql) { global $db, $table, $sql_query, $unlim_num_rows, $fields_meta; @@ -3191,7 +3193,7 @@ function PMA_displayResultsOperations($the_disp_mode, $analyzed_sql) ) . "\n"; - // show chart + // prepare chart $results_operations_html .= PMA_linkOrButton( 'tbl_chart.php' . PMA_generate_common_url($_url_params), PMA_getIcon('b_chart.png', __('Display chart'), true), @@ -3199,7 +3201,7 @@ function PMA_displayResultsOperations($the_disp_mode, $analyzed_sql) ) . "\n"; - // show GIS chart + // prepare GIS chart $geometry_found = false; // If atleast one geometry field is found foreach ($fields_meta as $meta) { @@ -3244,9 +3246,7 @@ function PMA_displayResultsOperations($the_disp_mode, $analyzed_sql) $results_operations_html .= '
'; } - // render HTML content of results operations - echo $results_operations_html; - + return $results_operations_html; } /** @@ -3263,7 +3263,7 @@ function PMA_displayResultsOperations($the_disp_mode, $analyzed_sql) * * @return mixed string or float */ -function PMA_handle_non_printable_contents($category, $content, $transform_function, +function PMA_handleNonPrintableContents($category, $content, $transform_function, $transform_options, $default_function, $meta, $url_params = array() ) { $result = '[' . $category; @@ -3320,7 +3320,7 @@ function PMA_handle_non_printable_contents($category, $content, $transform_funct * * @return string formatted data */ -function PMA_prepare_row_data($class, $condition_field, $analyzed_sql, $meta, $map, +function PMA_getRowData($class, $condition_field, $analyzed_sql, $meta, $map, $data, $transform_function, $default_function, $nowrap, $where_comparison, $transform_options, $is_field_truncated ) { @@ -3448,7 +3448,7 @@ function PMA_prepare_row_data($class, $condition_field, $analyzed_sql, $meta, $m } /** - * Generates a checkbox for multi-row submits + * Prepares a checkbox for multi-row submits * * @param string $del_url delete url * @param array $is_display array with explicit indexes for all @@ -3463,7 +3463,7 @@ function PMA_prepare_row_data($class, $condition_field, $analyzed_sql, $meta, $m * @return string the generated HTML */ -function PMA_generateCheckboxForMulti($del_url, $is_display, $row_no, +function PMA_getCheckboxForMultiRowSubmissions($del_url, $is_display, $row_no, $where_clause_html, $condition_array, $del_query, $id_suffix, $class ) { $ret = ''; @@ -3489,7 +3489,7 @@ function PMA_generateCheckboxForMulti($del_url, $is_display, $row_no, } /** - * Generates an Edit link + * Prepares an Edit link * * @param string $edit_url edit url * @param string $class css classes for td element @@ -3499,7 +3499,7 @@ function PMA_generateCheckboxForMulti($del_url, $is_display, $row_no, * * @return string the generated HTML */ -function PMA_generateEditLink($edit_url, $class, $edit_str, $where_clause, +function PMA_getEditLink($edit_url, $class, $edit_str, $where_clause, $where_clause_html ) { $ret = ''; @@ -3520,7 +3520,7 @@ function PMA_generateEditLink($edit_url, $class, $edit_str, $where_clause, } /** - * Generates an Copy link + * Prepares an Copy link * * @param string $copy_url copy url * @param string $copy_str text for the copy link @@ -3530,7 +3530,7 @@ function PMA_generateEditLink($edit_url, $class, $edit_str, $where_clause, * * @return string the generated HTML */ -function PMA_generateCopyLink($copy_url, $copy_str, $where_clause, +function PMA_getCopyLink($copy_url, $copy_str, $where_clause, $where_clause_html, $class ) { $ret = ''; @@ -3555,7 +3555,7 @@ function PMA_generateCopyLink($copy_url, $copy_str, $where_clause, } /** - * Generates a Delete link + * Prepares a Delete link * * @param string $del_url delete url * @param string $del_str text for the delete link @@ -3564,7 +3564,7 @@ function PMA_generateCopyLink($copy_url, $copy_str, $where_clause, * * @return string the generated HTML */ -function PMA_generateDeleteLink($del_url, $del_str, $js_conf, $class) +function PMA_getDeleteLink($del_url, $del_str, $js_conf, $class) { $ret = ''; if (! empty($del_url)) { @@ -3580,7 +3580,7 @@ function PMA_generateDeleteLink($del_url, $del_str, $js_conf, $class) } /** - * Generates checkbox and links at some position (left or right) + * Prepare checkbox and links at some position (left or right) * (only called for horizontal mode) * * @param string $position the position of the checkbox and links @@ -3602,45 +3602,45 @@ function PMA_generateDeleteLink($del_url, $del_str, $js_conf, $class) * * @return string the generated HTML */ -function PMA_generateCheckboxAndLinks($position, $del_url, $is_display, $row_no, +function PMA_getCheckboxAndLinks($position, $del_url, $is_display, $row_no, $where_clause, $where_clause_html, $condition_array, $del_query, $id_suffix, $edit_url, $copy_url, $class, $edit_str, $copy_str, $del_str, $js_conf ) { $ret = ''; if ($position == 'left') { - $ret .= PMA_generateCheckboxForMulti( + $ret .= PMA_getCheckboxForMultiRowSubmissions( $del_url, $is_display, $row_no, $where_clause_html, $condition_array, $del_query, $id_suffix = '_left', '', '', '' ); - $ret .= PMA_generateEditLink( + $ret .= PMA_getEditLink( $edit_url, $class, $edit_str, $where_clause, $where_clause_html, '' ); - $ret .= PMA_generateCopyLink( + $ret .= PMA_getCopyLink( $copy_url, $copy_str, $where_clause, $where_clause_html, '' ); - $ret .= PMA_generateDeleteLink($del_url, $del_str, $js_conf, '', ''); + $ret .= PMA_getDeleteLink($del_url, $del_str, $js_conf, '', ''); } elseif ($position == 'right') { - $ret .= PMA_generateDeleteLink($del_url, $del_str, $js_conf, '', ''); + $ret .= PMA_getDeleteLink($del_url, $del_str, $js_conf, '', ''); - $ret .= PMA_generateCopyLink( + $ret .= PMA_getCopyLink( $copy_url, $copy_str, $where_clause, $where_clause_html, '' ); - $ret .= PMA_generateEditLink( + $ret .= PMA_getEditLink( $edit_url, $class, $edit_str, $where_clause, $where_clause_html, '' ); - $ret .= PMA_generateCheckboxForMulti( + $ret .= PMA_getCheckboxForMultiRowSubmissions( $del_url, $is_display, $row_no, $where_clause_html, $condition_array, $del_query, $id_suffix = '_right', '', '', '' ); } else { // $position == 'none' - $ret .= PMA_generateCheckboxForMulti( + $ret .= PMA_getCheckboxForMultiRowSubmissions( $del_url, $is_display, $row_no, $where_clause_html, $condition_array, $del_query, $id_suffix = '_left', '', '', '' ); diff --git a/libraries/rte/rte_events.lib.php b/libraries/rte/rte_events.lib.php index 9d315f8b39..de8bbf5e03 100644 --- a/libraries/rte/rte_events.lib.php +++ b/libraries/rte/rte_events.lib.php @@ -146,7 +146,7 @@ function PMA_EVN_handleEditor() $message->addString(''); } - $output = PMA_showMessage($message, $sql_query); + $output = PMA_getMessage($message, $sql_query); if ($GLOBALS['is_ajax_request']) { $extra_data = array(); if ($message->isSuccess()) { diff --git a/libraries/rte/rte_routines.lib.php b/libraries/rte/rte_routines.lib.php index 07e10e87f9..69cda0d833 100644 --- a/libraries/rte/rte_routines.lib.php +++ b/libraries/rte/rte_routines.lib.php @@ -299,7 +299,7 @@ function PMA_RTN_handleEditor() $message->addString(''); } - $output = PMA_showMessage($message, $sql_query); + $output = PMA_getMessage($message, $sql_query); if ($GLOBALS['is_ajax_request']) { $extra_data = array(); if ($message->isSuccess()) { diff --git a/libraries/rte/rte_triggers.lib.php b/libraries/rte/rte_triggers.lib.php index 1683ddf6c2..11a4592bb5 100644 --- a/libraries/rte/rte_triggers.lib.php +++ b/libraries/rte/rte_triggers.lib.php @@ -119,7 +119,7 @@ function PMA_TRI_handleEditor() $message->addString(''); } - $output = PMA_showMessage($message, $sql_query); + $output = PMA_getMessage($message, $sql_query); if ($GLOBALS['is_ajax_request']) { $extra_data = array(); if ($message->isSuccess()) { diff --git a/main.php b/main.php index a5735825a4..9dc61bdf67 100644 --- a/main.php +++ b/main.php @@ -30,7 +30,7 @@ require_once 'libraries/header.inc.php'; // Any message to display? if (! empty($message)) { - PMA_showMessage($message); + echo PMA_getMessage($message); unset($message); } diff --git a/server_binlog.php b/server_binlog.php index 1b21133643..679674bc57 100644 --- a/server_binlog.php +++ b/server_binlog.php @@ -106,7 +106,7 @@ if (count($binary_logs) > 1) { echo ''; } -PMA_showMessage(PMA_Message::success()); +echo PMA_getMessage(PMA_Message::success()); /** * Displays the page diff --git a/server_databases.php b/server_databases.php index e3a032764b..143e1f1c39 100644 --- a/server_databases.php +++ b/server_databases.php @@ -293,7 +293,7 @@ if ($databases_count > 0) { . '' . "\n" . ' ' . __('Uncheck All') . '' . "\n" . '' . __('With selected:') . '' . "\n"; - PMA_buttonOrImage('drop_selected_dbs', 'mult_submit' . ($cfg['AjaxEnable'] ? ' ajax' : ''), 'drop_selected_dbs', __('Drop'), 'b_deltbl.png'); + echo PMA_getButtonOrImage('drop_selected_dbs', 'mult_submit' . ($cfg['AjaxEnable'] ? ' ajax' : ''), 'drop_selected_dbs', __('Drop'), 'b_deltbl.png'); } if (empty($dbstats)) { diff --git a/server_privileges.php b/server_privileges.php index cc2dde43ad..10a1d0f481 100644 --- a/server_privileges.php +++ b/server_privileges.php @@ -1580,7 +1580,7 @@ $link_export_all = '' . "\n" .'' . __('With selected:') . '' . "\n"; - PMA_buttonOrImage( - 'submit_mult', 'mult_submit', 'submit_mult_export', - __('Export'), 'b_tblexport.png', 'export' - ); + echo PMA_getButtonOrImage( + 'submit_mult', 'mult_submit', 'submit_mult_export', + __('Export'), 'b_tblexport.png', 'export' + ); echo ''; echo '
' . '
' diff --git a/sql.php b/sql.php index 53b5a9276d..498d7f3caa 100644 --- a/sql.php +++ b/sql.php @@ -293,7 +293,7 @@ if (! defined('PMA_CHK_DROP') } // end if require_once 'libraries/display_tbl.lib.php'; -PMA_displayTable_checkConfigParams(); +PMA_setConfigParamsForDisplayTable(); /** * Need to find the real end of rows? @@ -817,7 +817,7 @@ if ((0 == $num_rows && 0 == $unlim_num_rows) || $is_affected) { if ($GLOBALS['is_ajax_request'] == true) { if ($cfg['ShowSQL']) { - $extra_data['sql_query'] = PMA_showMessage($message, $GLOBALS['sql_query'], 'success'); + $extra_data['sql_query'] = PMA_getMessage($message, $GLOBALS['sql_query'], 'success'); } if (isset($GLOBALS['reload']) && $GLOBALS['reload'] == 1) { $extra_data['reload'] = 1; @@ -898,9 +898,9 @@ if ((0 == $num_rows && 0 == $unlim_num_rows) || $is_affected) { if (isset($message)) { $message = PMA_Message::success($message); - echo PMA_showMessage($message, $GLOBALS['sql_query'], 'success'); + echo PMA_getMessage($message, $GLOBALS['sql_query'], 'success'); } - PMA_displayTable($result, $disp_mode, $analyzed_sql); + echo PMA_getTable($result, $disp_mode, $analyzed_sql); exit(); } @@ -931,7 +931,7 @@ if ((0 == $num_rows && 0 == $unlim_num_rows) || $is_affected) { } } else { include_once 'libraries/header.inc.php'; - //we don't need to buffer the output in PMA_showMessage here. + //we don't need to buffer the output in PMA_getMessage here. //set a global variable and check against it in the function $GLOBALS['buffer_message'] = false; } @@ -958,7 +958,7 @@ if ((0 == $num_rows && 0 == $unlim_num_rows) || $is_affected) { // Display previous update query (from tbl_replace) if (isset($disp_query) && $cfg['ShowSQL'] == true) { - PMA_showMessage($disp_message, $disp_query, 'success'); + echo PMA_getMessage($disp_message, $disp_query, 'success'); } if (isset($profiling_results)) { @@ -1018,7 +1018,7 @@ $(makeProfilingChart); $message->display(); } - PMA_displayTable($result, $disp_mode, $analyzed_sql); + echo PMA_getTable($result, $disp_mode, $analyzed_sql); PMA_DBI_free_result($result); // BEGIN INDEX CHECK See if indexes should be checked. diff --git a/tbl_addfield.php b/tbl_addfield.php index ff7db7c9d4..c84eff11fa 100644 --- a/tbl_addfield.php +++ b/tbl_addfield.php @@ -191,7 +191,7 @@ if (isset($_REQUEST['do_save_data'])) { $message->addParam($table); if ( $GLOBALS['is_ajax_request'] == true) { - $extra_data['sql_query'] = PMA_showMessage(null, $sql_query); + $extra_data['sql_query'] = PMA_getMessage(null, $sql_query); PMA_ajaxResponse($message, $message->isSuccess(), $extra_data); } diff --git a/tbl_alter.php b/tbl_alter.php index 3bd39f075f..ef8a7f2d3b 100644 --- a/tbl_alter.php +++ b/tbl_alter.php @@ -254,7 +254,7 @@ if (isset($_REQUEST['do_save_data'])) { } if ( $_REQUEST['ajax_request'] == true) { - $extra_data['sql_query'] = PMA_showMessage(null, $sql_query); + $extra_data['sql_query'] = PMA_getMessage(null, $sql_query); PMA_ajaxResponse($message, $message->isSuccess(), $extra_data); } diff --git a/tbl_change.php b/tbl_change.php index d6b46b51a4..54c89cdc48 100644 --- a/tbl_change.php +++ b/tbl_change.php @@ -133,7 +133,7 @@ if (! empty($disp_message)) { if (! isset($disp_query)) { $disp_query = null; } - PMA_showMessage($disp_message, $disp_query); + echo PMA_getMessage($disp_message, $disp_query); } /** @@ -176,7 +176,7 @@ if (isset($where_clause)) { // No row returned if (! $rows[$key_id]) { unset($rows[$key_id], $where_clause_array[$key_id]); - PMA_showMessage(__('MySQL returned an empty result set (i.e. zero rows).'), $local_query); + echo PMA_getMessage(__('MySQL returned an empty result set (i.e. zero rows).'), $local_query); echo "\n"; include 'libraries/footer.inc.php'; } else { // end if (no row returned) diff --git a/tbl_export.php b/tbl_export.php index 7e3d4ed727..57e2364e6d 100644 --- a/tbl_export.php +++ b/tbl_export.php @@ -76,7 +76,7 @@ if (! empty($sql_query)) { // Just crop LIMIT clause $sql_query = $analyzed_sql[0]['section_before_limit'] . $analyzed_sql[0]['section_after_limit']; } - PMA_showMessage(PMA_Message::success()); + echo PMA_getMessage(PMA_Message::success()); } $export_type = 'table'; diff --git a/tbl_indexes.php b/tbl_indexes.php index 020210f9f5..af268a61ae 100644 --- a/tbl_indexes.php +++ b/tbl_indexes.php @@ -107,7 +107,7 @@ if (isset($_REQUEST['do_save_data'])) { if ( $GLOBALS['is_ajax_request'] == true) { $extra_data['index_table'] = PMA_Index::getView($table, $db); - $extra_data['sql_query'] = PMA_showMessage(null, $sql_query); + $extra_data['sql_query'] = PMA_getMessage(null, $sql_query); PMA_ajaxResponse($message, $message->isSuccess(), $extra_data); } diff --git a/tbl_move_copy.php b/tbl_move_copy.php index 1d966daca9..6779754a59 100644 --- a/tbl_move_copy.php +++ b/tbl_move_copy.php @@ -69,7 +69,7 @@ if (PMA_isValid($_REQUEST['new_name'])) { } if ( $_REQUEST['ajax_request'] == true) { - $extra_data['sql_query'] = PMA_showMessage(null, $sql_query); + $extra_data['sql_query'] = PMA_getMessage(null, $sql_query); $extra_data['db'] = $GLOBALS['db']; PMA_ajaxResponse($message, $message->isSuccess(), $extra_data); } diff --git a/tbl_operations.php b/tbl_operations.php index f654fc65cb..9baa8c5d2a 100644 --- a/tbl_operations.php +++ b/tbl_operations.php @@ -232,7 +232,7 @@ if (isset($result) && empty($message_to_show)) { // $result should exist, regardless of $_message $_type = $result ? 'success' : 'error'; if (isset($_REQUEST['ajax_request']) && $_REQUEST['ajax_request'] == true) { - $extra_data['sql_query'] = PMA_showMessage(null, $sql_query); + $extra_data['sql_query'] = PMA_getMessage(null, $sql_query); PMA_ajaxResponse($_message, $_message->isSuccess(), $extra_data); } } @@ -246,7 +246,7 @@ if (isset($result) && empty($message_to_show)) { unset($warning_messages); } - PMA_showMessage($_message, $sql_query, $_type); + echo PMA_getMessage($_message, $sql_query, $_type); unset($_message, $_type); } @@ -520,7 +520,7 @@ if (isset($possible_row_formats[$tbl_storage_engine])) { $current_row_format = strtoupper($showtable['Row_format']); echo ''; echo ''; - echo PMA_generate_html_dropdown('new_row_format', $possible_row_formats[$tbl_storage_engine], $current_row_format, 'new_row_format'); + echo PMA_getDropdown('new_row_format', $possible_row_formats[$tbl_storage_engine], $current_row_format, 'new_row_format'); unset($possible_row_formats, $current_row_format); echo ''; echo ''; diff --git a/tbl_relation.php b/tbl_relation.php index e640687cc5..a82f23f3d0 100644 --- a/tbl_relation.php +++ b/tbl_relation.php @@ -181,7 +181,7 @@ if (isset($destination) && $cfgRelation['relwork']) { // (for now, one index name only; we keep the definitions if the // foreign db is not the same) // I use $sql_query to be able to display directly the query via -// PMA_showMessage() +// PMA_getMessage() if (isset($_REQUEST['destination_foreign'])) { $display_query = ''; @@ -285,9 +285,9 @@ if (isset($_REQUEST['destination_foreign'])) { } // end foreach if (!empty($display_query)) { if ($seen_error) { - PMA_showMessage(__('Error'), null, 'error'); + echo PMA_getMessage(__('Error'), null, 'error'); } else { - PMA_showMessage(__('Your SQL query has been executed successfully'), null, 'success'); + echo PMA_getMessage(__('Your SQL query has been executed successfully'), null, 'success'); } } } // end if isset($destination_foreign) diff --git a/tbl_replace.php b/tbl_replace.php index f7e0f9e263..e24eeeddcc 100644 --- a/tbl_replace.php +++ b/tbl_replace.php @@ -544,7 +544,7 @@ if ($GLOBALS['is_ajax_request'] == true) { /**Get the total row count of the table*/ $extra_data['row_count'] = PMA_Table::countRecords($_REQUEST['db'], $_REQUEST['table']); - $extra_data['sql_query'] = PMA_showMessage($message, $GLOBALS['display_query']); + $extra_data['sql_query'] = PMA_getMessage($message, $GLOBALS['display_query']); PMA_ajaxResponse($message, $message->isSuccess(), $extra_data); } diff --git a/tbl_structure.php b/tbl_structure.php index ebe727d099..870c4480f1 100644 --- a/tbl_structure.php +++ b/tbl_structure.php @@ -568,37 +568,37 @@ $checkall_url = 'tbl_structure.php?' . PMA_generate_common_url($db, $table); diff --git a/tbl_tracking.php b/tbl_tracking.php index 4740d135b2..1fd887e8d1 100644 --- a/tbl_tracking.php +++ b/tbl_tracking.php @@ -289,7 +289,7 @@ if (isset($_REQUEST['snapshot'])) { $drop_create_statements .= $data['ddlog'][1]['statement']; } // Print SQL code - PMA_showMessage(sprintf(__('Version %s snapshot (SQL code)'), htmlspecialchars($_REQUEST['version'])), $drop_create_statements); + echo PMA_getMessage(sprintf(__('Version %s snapshot (SQL code)'), htmlspecialchars($_REQUEST['version'])), $drop_create_statements); // Unserialize snapshot $temp = unserialize($data['schema_snapshot']); diff --git a/test/libraries/common/PMA_generate_html_dropdown_test.php b/test/libraries/common/PMA_generate_html_dropdown_test.php index c31ed5e928..ef7a6f3614 100644 --- a/test/libraries/common/PMA_generate_html_dropdown_test.php +++ b/test/libraries/common/PMA_generate_html_dropdown_test.php @@ -23,7 +23,7 @@ class PMA_generate_html_dropdown_test extends PHPUnit_Framework_TestCase $result = ''; - $this->assertEquals($result, PMA_generate_html_dropdown($name, $choices, $active_choice, $id)); + $this->assertEquals($result, PMA_getDropdown($name, $choices, $active_choice, $id)); } function testGenerateHtmlDropdown() @@ -43,7 +43,7 @@ class PMA_generate_html_dropdown_test extends PHPUnit_Framework_TestCase } $result .= ''; - $this->assertEquals($result, PMA_generate_html_dropdown($name, $choices, $active_choice, $id)); + $this->assertEquals($result, PMA_getDropdown($name, $choices, $active_choice, $id)); } function testGenerateHtmlDropdownWithActive() @@ -63,6 +63,6 @@ class PMA_generate_html_dropdown_test extends PHPUnit_Framework_TestCase } $result .= ''; - $this->assertEquals($result, PMA_generate_html_dropdown($name, $choices, $active_choice, $id)); + $this->assertEquals($result, PMA_getDropdown($name, $choices, $active_choice, $id)); } } \ No newline at end of file diff --git a/test/libraries/common/PMA_showMessage_test_disabled.php b/test/libraries/common/PMA_showMessage_test_disabled.php index 7aed63527b..2b25cfc80d 100644 --- a/test/libraries/common/PMA_showMessage_test_disabled.php +++ b/test/libraries/common/PMA_showMessage_test_disabled.php @@ -1,7 +1,7 @@
" ); - echo PMA_showMessage("msg"); + echo PMA_getMessage("msg"); - //$this->assertEquals("",PMA_showMessage("msg")); + //$this->assertEquals("",PMA_getMessage("msg")); $this->assertTrue(true); } } \ No newline at end of file diff --git a/user_password.php b/user_password.php index f1b632c889..8a9937eb00 100644 --- a/user_password.php +++ b/user_password.php @@ -82,7 +82,7 @@ function PMA_getChangePassMessage($change_password_message, $sql_query = '') if ($change_password_message['error']) { PMA_ajaxResponse($change_password_message['msg'], false); } else { - $extra_data['sql_query'] = PMA_showMessage($change_password_message['msg'], $sql_query, 'success'); + $extra_data['sql_query'] = PMA_getMessage($change_password_message['msg'], $sql_query, 'success'); PMA_ajaxResponse($change_password_message['msg'], true, $extra_data); } } @@ -205,7 +205,7 @@ function PMA_changePassDisplayPage($message, $sql_query, $_url_params) { include_once './libraries/header.inc.php'; echo '

' . __('Change password') . '

' . "\n\n"; - PMA_showMessage($message, $sql_query, 'success'); + echo PMA_getMessage($message, $sql_query, 'success'); echo '
'. "\n" .''.__('Back').''; include './libraries/footer.inc.php'; diff --git a/view_create.php b/view_create.php index 385890c2f5..2808144638 100644 --- a/view_create.php +++ b/view_create.php @@ -68,7 +68,7 @@ if (isset($_REQUEST['createview'])) { include './' . $cfg['DefaultTabDatabase']; exit(); } else { - PMA_ajaxResponse(PMA_showMessage(PMA_Message::success(), $sql_query), 1); + PMA_ajaxResponse(PMA_getMessage(PMA_Message::success(), $sql_query), 1); } } else { if ($GLOBALS['is_ajax_request'] != true) { diff --git a/view_operations.php b/view_operations.php index 45a74b7ebf..2f2ab4c1ac 100644 --- a/view_operations.php +++ b/view_operations.php @@ -62,7 +62,7 @@ if (isset($result)) { $_message->isError(true); unset($warning_messages); } - PMA_showMessage($_message, $sql_query, $_type, $is_view = true); + echo PMA_getMessage($_message, $sql_query, $_type, $is_view = true); unset($_message, $_type); } From 40d0ada69bed5856d75d6b67bb3fc0a1e1df943c Mon Sep 17 00:00:00 2001 From: Chanaka Indrajith Date: Sat, 12 May 2012 09:39:05 +0530 Subject: [PATCH 08/17] Modified the function PMA_displayTableBody --- libraries/display_tbl.lib.php | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/libraries/display_tbl.lib.php b/libraries/display_tbl.lib.php index 8a777ac267..52ad83e074 100644 --- a/libraries/display_tbl.lib.php +++ b/libraries/display_tbl.lib.php @@ -1460,7 +1460,7 @@ function PMA_addClass($class, $condition_field, $meta, $nowrap, * @param array $map the list of relations * @param array $analyzed_sql the analyzed query * - * @return array ($table_body_html, $clause_is_unique) + * @return string html content * * @global string $db the database name * @global string $table the table name @@ -1478,7 +1478,7 @@ function PMA_addClass($class, $condition_field, $meta, $nowrap, * * @see PMA_getTable() */ -function PMA_getTableBodyParams(&$dt_result, &$is_display, $map, $analyzed_sql) +function PMA_getTableBody(&$dt_result, &$is_display, $map, $analyzed_sql) { global $db, $table, $goto; global $sql_query, $fields_meta, $fields_cnt; @@ -2208,11 +2208,9 @@ function PMA_getTableBodyParams(&$dt_result, &$is_display, $map, $analyzed_sql) : ''); $row_no++; } // end while - - // $clause_is_unique is needed by PMA_getTable() to generate the proper param - // in the multi-edit and multi-delete form - return array($table_body_html, $clause_is_unique); -} // end of the 'PMA_getTableBodyParams()' function + + return $table_body_html; +} // end of the 'PMA_getTableBody()' function /** @@ -2648,7 +2646,7 @@ function PMA_setConfigParamsForDisplayTable() * * @see PMA_getMessage(), PMA_setDisplayMode(), * PMA_getTableNavigation(), PMA_getTableHeaders(), - * PMA_getTableBodyParams(), PMA_getResultsOperations() + * PMA_getTableBody(), PMA_getResultsOperations() * * @return void */ @@ -2777,6 +2775,12 @@ function PMA_getTable(&$dt_result, &$the_disp_mode, $analyzed_sql) // fetch last row of the result set PMA_DBI_data_seek($dt_result, $num_rows - 1); $row = PMA_DBI_fetch_row($dt_result); + + // $clause_is_unique is needed by PMA_getTable() to generate the proper param + // in the multi-edit and multi-delete form + list($where_clause, $clause_is_unique, $condition_array) + = PMA_getUniqueCondition($dt_result, $fields_cnt, $fields_meta, $row); + // check for non printable sorted row data $meta = $fields_meta[$sorted_column_index]; if (stristr($meta->type, 'BLOB') || $meta->type == 'geometry') { @@ -2790,7 +2794,7 @@ function PMA_getTable(&$dt_result, &$the_disp_mode, $analyzed_sql) $column_for_last_row = strtoupper( substr($column_for_last_row, 0, $GLOBALS['cfg']['LimitChars']) ); - // reset to first row for the loop in PMA_getTableBodyParams() + // reset to first row for the loop in PMA_getTableBody() PMA_DBI_data_seek($dt_result, 0); // we could also use here $sort_expression_nodirection $sorted_column_message = ' [' . htmlspecialchars($sort_column) @@ -2952,12 +2956,10 @@ function PMA_getTable(&$dt_result, &$the_disp_mode, $analyzed_sql) . '' . "\n"; $url_query = ''; - list($table_body_html, $clause_is_unique) = PMA_getTableBodyParams( + $table_html .= PMA_getTableBody( $dt_result, $is_display, $map, $analyzed_sql ); - $table_html .= $table_body_html; - // vertical output case if ($_SESSION['tmp_user_values']['disp_direction'] == 'vertical') { $table_html .= PMA_getVerticalTable(); @@ -3096,7 +3098,7 @@ function PMA_mimeDefaultFunction($buffer) * * @see PMA_getMessage(), PMA_setDisplayMode(), * PMA_getTableNavigation(), PMA_getTableHeaders(), - * PMA_getTableBodyParams(), PMA_getResultsOperations() + * PMA_getTableBody(), PMA_getResultsOperations() * * @return void */ From 30d57ff2d4df0a5e5ea6f3eeae9a091f08e09681 Mon Sep 17 00:00:00 2001 From: Chanaka Indrajith Date: Mon, 14 May 2012 17:46:17 +0530 Subject: [PATCH 09/17] Improved some test cases for modified functions in common.lib.php --- .../common/PMA_getDivForSliderEffect_test.php | 19 +++++--- ...down_test.php => PMA_getDropdown_test.php} | 0 .../common/PMA_getRadioFields_test.php | 48 ++++++++++++------- 3 files changed, 45 insertions(+), 22 deletions(-) rename test/libraries/common/{PMA_GetDropdown_test.php => PMA_getDropdown_test.php} (100%) diff --git a/test/libraries/common/PMA_getDivForSliderEffect_test.php b/test/libraries/common/PMA_getDivForSliderEffect_test.php index 79cb68c6cd..3b5d03ff95 100644 --- a/test/libraries/common/PMA_getDivForSliderEffect_test.php +++ b/test/libraries/common/PMA_getDivForSliderEffect_test.php @@ -22,8 +22,10 @@ class PMA_GetDivForSliderEffectTest extends PHPUnit_Framework_TestCase $id = "test_id"; $message = "test_message"; - $this->expectOutputString('
'); - PMA_getDivForSliderEffect($id, $message); + $this->assertEquals( + PMA_getDivForSliderEffect($id, $message), + '
' + ); } function testGetDivForSliderEffectTestClosed() @@ -34,8 +36,11 @@ class PMA_GetDivForSliderEffectTest extends PHPUnit_Framework_TestCase $id = "test_id"; $message = "test_message"; - $this->expectOutputString('