From 004f4f5258a0820975e2da9fa02a6d3ba6622368 Mon Sep 17 00:00:00 2001 From: Chanaka Indrajith Date: Tue, 8 May 2012 22:19:40 +0530 Subject: [PATCH] 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 .= ' 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' ) { - ?> -