diff --git a/db_create.php b/db_create.php index d3e5062414..0dff8e4553 100644 --- a/db_create.php +++ b/db_create.php @@ -85,7 +85,7 @@ if (! $result) { * @global array $GLOBALS['extra_data'] * @name $extra_data */ - $extra_data['sql_query'] = PMA_showMessage(null, $sql_query, 'success'); + $extra_data['sql_query'] = PMA_getMessage(null, $sql_query, 'success'); //Construct the html for the new database, so that it can be appended to // the list of databases on server_databases.php diff --git a/db_operations.php b/db_operations.php index 46bc62ca7a..5a04bde59c 100644 --- a/db_operations.php +++ b/db_operations.php @@ -341,7 +341,7 @@ if (strlen($db) && (! empty($db_rename) || ! empty($db_copy))) { */ if ( $GLOBALS['is_ajax_request'] == true) { $extra_data['newname'] = $newname; - $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); }; } @@ -375,7 +375,7 @@ if (empty($is_info)) { echo "\n"; if (isset($message)) { - PMA_showMessage($message, $sql_query); + echo PMA_getMessage($message, $sql_query); unset($message); } } @@ -523,7 +523,7 @@ echo __('Remove database'); 'structure' => __('Structure only'), 'data' => __('Structure and data'), 'dataonly' => __('Data only')); - PMA_displayHtmlRadio('what', $choices, 'data', true); + echo PMA_getRadioFields('what', $choices, 'data', true); unset($choices); ?> diff --git a/db_tracking.php b/db_tracking.php index 4077f75748..e151977baf 100644 --- a/db_tracking.php +++ b/db_tracking.php @@ -225,7 +225,7 @@ if (count($data['ddlog']) > 0) { foreach ($data['ddlog'] as $entry) { $log .= '# ' . $entry['date'] . ' ' . $entry['username'] . "\n" . $entry['statement'] . "\n"; } - PMA_showMessage(__('Database Log'), $log); + echo PMA_getMessage(__('Database Log'), $log); } /** diff --git a/js/db_operations.js b/js/db_operations.js index c9c0289232..170ff1ec0e 100644 --- a/js/db_operations.js +++ b/js/db_operations.js @@ -60,7 +60,7 @@ $(function() { .end() .after(data.sql_query); - //Remove the empty notice div generated due to a NULL query passed to PMA_showMessage() + //Remove the empty notice div generated due to a NULL query passed to PMA_getMessage() var $notice_class = $("#floating_menubar").next("div").find('.notice'); if ($notice_class.text() == '') { $notice_class.remove(); diff --git a/js/server_privileges.js b/js/server_privileges.js index 050ec45d79..fa2cc53119 100644 --- a/js/server_privileges.js +++ b/js/server_privileges.js @@ -188,7 +188,7 @@ $(function() { .end() .after(data.sql_query); - //Remove the empty notice div generated due to a NULL query passed to PMA_showMessage() + //Remove the empty notice div generated due to a NULL query passed to PMA_getMessage() var $notice_class = $("#floating_menubar").next("div").find('.notice'); if ($notice_class.text() == '') { $notice_class.remove(); diff --git a/js/tbl_change.js b/js/tbl_change.js index 05132d3664..04c5247fac 100644 --- a/js/tbl_change.js +++ b/js/tbl_change.js @@ -345,7 +345,7 @@ $(function() { .end() .after(data.sql_query); - //Remove the empty notice div generated due to a NULL query passed to PMA_showMessage() + //Remove the empty notice div generated due to a NULL query passed to PMA_getMessage() var $notice_class = $("#floating_menubar").next("div").find('.notice'); if ($notice_class.text() == '') { $notice_class.remove(); diff --git a/libraries/Menu.class.php b/libraries/Menu.class.php index 92c64d23b1..4d4f5d668f 100644 --- a/libraries/Menu.class.php +++ b/libraries/Menu.class.php @@ -89,7 +89,7 @@ class PMA_Menu echo $this->_getBreadcrumbs(); echo $this->_getMenu(); if (! empty($GLOBALS['message'])) { - PMA_showMessage($GLOBALS['message']); + echo PMA_getMessage($GLOBALS['message']); unset($GLOBALS['message']); } } diff --git a/libraries/common.lib.php b/libraries/common.lib.php index d9de2abee9..db1d425950 100644 --- a/libraries/common.lib.php +++ b/libraries/common.lib.php @@ -972,7 +972,7 @@ function PMA_reloadNavigation($jsonly = false) } /** - * displays the message and the query + * Prepare the message and the query * usually the message is the result of the query executed * * @param string $message the message to display @@ -984,7 +984,7 @@ function PMA_reloadNavigation($jsonly = false) * * @access public */ -function PMA_showMessage( +function PMA_getMessage( $message, $sql_query = null, $type = 'notice', @@ -1331,17 +1331,9 @@ 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; - } -} // end of the 'PMA_showMessage()' function + return $retval; + +} // end of the 'PMA_getMessage()' function /** * Verifies if current MySQL server supports profiling @@ -1382,12 +1374,14 @@ function PMA_getProfilingForm($sql_query) { $retval = ''; if (PMA_profilingSupported()) { + $retval .= '
' . "\n"; $retval .= PMA_generate_common_hidden_inputs($GLOBALS['db'], $GLOBALS['table']); $retval .= '' . "\n"; $retval .= '' . "\n"; $retval .= PMA_getCheckbox('profiling', __('Profiling'), isset($_SESSION['profiling']), true); $retval .= '
' . "\n"; + } return $retval; } @@ -2262,33 +2256,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 '' @@ -2599,14 +2592,14 @@ function PMA_externalBug($functionality, $component, $minimum_version, $bugref) } /** - * Returns an HTML checkbox + * Returns a HTML checkbox * * @param string $html_field_name the checkbox HTML field * @param string $label label for checkbox * @param boolean $checked is it initially checked? * @param boolean $onclick should it submit the form on click? * - * @return string HTML for the checkbox + * @return string HTML for the checkbox */ function PMA_getCheckbox($html_field_name, $label, $checked, $onclick) { @@ -2615,10 +2608,11 @@ function PMA_getCheckbox($html_field_name, $label, $checked, $onclick) . $html_field_name . '"' . ($checked ? ' checked="checked"' : '') . ($onclick ? ' class="autosubmit"' : '') . ' />'; + } /** - * Generates and echoes a set of radio HTML fields + * Generates a set of radio HTML fields * * @param string $html_field_name the radio HTML field * @param array $choices the choices values and labels @@ -2627,33 +2621,39 @@ function PMA_getCheckbox($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 set of html radio fiels */ -function PMA_displayHtmlRadio($html_field_name, $choices, $checked_choice = '', +function PMA_getRadioFields($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; + } /** @@ -2666,11 +2666,11 @@ function PMA_displayHtmlRadio($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_generateHtmlDropdown($select_name, $choices, $active_choice, $id) +function PMA_getDropdown($select_name, $choices, $active_choice, $id) { $result = ' - - - - value="" /> - - -' + . '
' + . 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 +300,18 @@ function PMA_displayTableNavigationOneButton($caption, $title, $pos, $html_sql_q * * @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,69 +323,61 @@ function PMA_displayTableNavigation($pos_next, $pos_prev, $sql_query, */ $is_innodb = (isset($showtable['Type']) && $showtable['Type'] == 'InnoDB'); - ?> - - - - - - ' + . '' + . ''; + // Move to the beginning or to the previous page if ($_SESSION['tmp_user_values']['pos'] - && $_SESSION['tmp_user_values']['max_rows'] != 'all' + && ($_SESSION['tmp_user_values']['max_rows'] != 'all') ) { - PMA_displayTableNavigationOneButton( - '<<', _pgettext('First page', 'Begin'), 0, $html_sql_query - ); - PMA_displayTableNavigationOneButton( - '<', _pgettext('Previous page', 'Previous'), $pos_prev, - $html_sql_query - ); + + $table_navigation_html .= PMA_getMoveBackwardButtonsForTableNavigation( + $html_sql_query, $pos_prev + ); } // end move back $nbTotalPage = 1; //page redirection // (unless we are showing all records) - if ('all' != $_SESSION['tmp_user_values']['max_rows']) { //if1 + if ($_SESSION['tmp_user_values']['max_rows'] != 'all') { //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 // Display the "Show all" button if allowed @@ -385,148 +385,261 @@ function PMA_displayTableNavigation($pos_next, $pos_prev, $sql_query, && ($GLOBALS['cfg']['ShowAll'] || ($GLOBALS['cfg']['MaxRows'] * 5 >= $unlim_num_rows)) ) { - echo "\n"; - ?> - - = $_SESSION['tmp_user_values']['max_rows'] - && $_SESSION['tmp_user_values']['max_rows'] != 'all' + if ((($_SESSION['tmp_user_values']['pos'] + $_SESSION['tmp_user_values']['max_rows']) + < $unlim_num_rows) + && ($num_rows >= $_SESSION['tmp_user_values']['max_rows']) + && ($_SESSION['tmp_user_values']['max_rows'] != 'all') ) { - // display the Next button - PMA_displayTableNavigationOneButton( + + $table_navigation_html .= PMA_getMoveFarwardButtonsForTableNavigation( + $html_sql_query, $pos_next, $is_innodb, + $unlim_num_rows, $num_rows + ); + + } // end move toward + + // show separator if pagination happen + if ($nbTotalPage > 1) { + $table_navigation_html .= ''; + } + + $table_navigation_html .= '' + . ''; + + // if displaying a VIEW, $unlim_num_rows could be zero because + // of $cfg['MaxExactCountViews']; in this case, avoid passing + // the 5th parameter to checkFormElementInRange() + // (this means we can't validate the upper limit + $table_navigation_html .= '' + . '' + . '' + . ''; + + return $table_navigation_html; + +} // end of the 'PMA_getTableNavigation()' function + + +/** + * Prepare move backward buttons - previous and first + * + * @param string $html_sql_query the sql encoded by html special characters + * @param integer $pos_prev the offset for the "previous" page + * + * @return string html content + * + * @see PMA_getTableNavigation() + */ +function PMA_getMoveBackwardButtonsForTableNavigation($html_sql_query, $pos_prev) +{ + return PMA_getTableNavigationButton( + '<<', _pgettext('First page', 'Begin'), 0, $html_sql_query + ) + . PMA_getTableNavigationButton( + '<', _pgettext('Previous page', 'Previous'), $pos_prev, + $html_sql_query + ); +} + + +/** + * Prepare Show All button for table navigation + * + * @param string $db the database name + * @param string $table the table name + * @param string $html_sql_query the sql encoded by html special characters + * @param string $goto the URL to go back in case of errors + * + * @return string html content + * + * @see PMA_getTableNavigation() + */ +function PMA_getShowAllButtonForTableNavigation($db, $table, $html_sql_query, $goto) +{ + return "\n" + . '' + . '
' + . PMA_generate_common_hidden_inputs($db, $table) + . '' + . '' + . '' + . '' + . '' + . '
' + . ''; +} + + +/** + * Prepare move farward buttons - next and last + * + * @param string $html_sql_query the sql encoded by html special characters + * @param integer $pos_prev the offset for the "previous" page + * @param boolean $is_innodb whether its InnoDB or not + * @param integer $unlim_num_rows the total number of rows returned by the + * @param integer $num_rows the total number of rows returned by the + * + * @return string $buttons_html html content + * + * @see PMA_getTableNavigation() + */ +function PMA_getMoveFarwardButtonsForTableNavigation( + $html_sql_query, $pos_next, $is_innodb, $unlim_num_rows, $num_rows +) { + + // display the Next button + $buttons_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']) { - $input_for_real_end = ''; - // no backquote around this message - $onclick = ''; - } else { - $input_for_real_end = $onclick = ''; - } + // prepare some options for the End button + if ($is_innodb && $unlim_num_rows > $GLOBALS['cfg']['MaxExactCount']) { + $input_for_real_end = ''; + // no backquote around this message + $onclick = ''; + } else { + $input_for_real_end = $onclick = ''; + } - $onsubmit = 'onsubmit="return ' - . ($_SESSION['tmp_user_values']['pos'] - + $_SESSION['tmp_user_values']['max_rows'] < $unlim_num_rows - && $num_rows >= $_SESSION['tmp_user_values']['max_rows']) - ? 'true' - : 'false' . '"'; - // display the End button - PMA_displayTableNavigationOneButton( + $onsubmit = 'onsubmit="return ' + . ($_SESSION['tmp_user_values']['pos'] + + $_SESSION['tmp_user_values']['max_rows'] < $unlim_num_rows + && $num_rows >= $_SESSION['tmp_user_values']['max_rows']) + ? 'true' + : 'false' . '"'; + + // display the End button + $buttons_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 + $html_sql_query, $onsubmit, $input_for_real_end, $onclick ); - } // end move toward + + return $buttons_html; + +} - // show separator if pagination happen - if ($nbTotalPage > 1) { - echo ''; - } - ?> - -
- - -
- - -
- - -
- - - -
- - - - value=" :" /> - - - - - ' + . '' + . '' + . __('Start row') . ': ' . "\n" + . '' + . __('Number of rows') . ': ' . "\n" + . ''; + + if ($GLOBALS['cfg']['ShowDisplayDirection']) { + // Display mode (horizontal/vertical and repeat headers) + $additional_fields_html .= __('Mode') . ': ' . "\n"; + $choices = array( 'horizontal' => __('horizontal'), 'horizontalflipped' => __('horizontal (rotated headers)'), 'vertical' => __('vertical') ); - echo PMA_generateHtmlDropdown( + + $additional_fields_html .= PMA_getDropdown( 'disp_direction', $choices, $_SESSION['tmp_user_values']['disp_direction'], $id_for_direction_dropdown ); - unset($choices); - } + unset($choices); + } - printf( - __('Headers every %s rows'), - '' - ); - echo "\n"; - ?> -
- - - - - - ' + . __('rows') + . "\n"; + + return $additional_fields_html; + +} /** - * 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 +650,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 +663,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 = '' ) { @@ -561,6 +674,8 @@ function PMA_displayTableHeaders(&$is_display, &$fields_meta, $fields_cnt = 0, global $sql_query, $num_rows; global $vertical_display, $highlight_columns; + $table_headers_html = ''; + // required to generate sort links that will remember whether the // "Show all" button has been clicked $sql_md5 = md5($GLOBALS['sql_query']); @@ -573,6 +688,9 @@ function PMA_displayTableHeaders(&$is_display, &$fields_meta, $fields_cnt = 0, if ($analyzed_sql == '') { $analyzed_sql = array(); } + + $directionCondition = ($direction == 'horizontal') + || ($direction == 'horizontalflipped'); // can the result be sorted? if ($is_display['sort_lnk'] == '1') { @@ -591,9 +709,9 @@ function PMA_displayTableHeaders(&$is_display, &$fields_meta, $fields_cnt = 0, if (isset($analyzed_sql) && isset($analyzed_sql[0]) && isset($analyzed_sql[0]['querytype']) - && $analyzed_sql[0]['querytype'] == 'SELECT' + && ($analyzed_sql[0]['querytype'] == 'SELECT') && isset($analyzed_sql[0]['table_ref']) - && count($analyzed_sql[0]['table_ref']) == 1 + && (count($analyzed_sql[0]['table_ref']) == 1) ) { // grab indexes data: @@ -601,361 +719,135 @@ function PMA_displayTableHeaders(&$is_display, &$fields_meta, $fields_cnt = 0, // do we have any index? if ($indexes) { - - if ($direction == 'horizontal' - || $direction == 'horizontalflipped' - ) { - $span = $fields_cnt; - if ($is_display['edit_lnk'] != 'nn') { - $span++; - } - if ($is_display['del_lnk'] != 'nn') { - $span++; - } - if ($is_display['del_lnk'] != 'kp' - && $is_display['del_lnk'] != 'nn' - ) { - $span++; - } - } else { - $span = $num_rows + floor( - $num_rows / $_SESSION['tmp_user_values']['repeat_cells'] - ) + 1; - } - - echo '
' . "\n"; - echo PMA_generate_common_hidden_inputs($db, $table); - echo __('Sort by key') - . ': ' . "\n"; - echo '
' . "\n"; + $table_headers_html .= PMA_getSortByKeyDropDown( + $db, $table, $indexes, $sort_expression, + $unsorted_sql_query + ); } } } - // Output data needed for grid editing - echo ''; - echo '
'; - echo PMA_generate_common_hidden_inputs($db, $table); - echo '
'; + $table_headers_html .= '' + . '
' + . PMA_generate_common_hidden_inputs($db, $table) + . '
'; + // Output data needed for column reordering and show/hide column - if (PMA_isSelect()) { - // generate the column order, if it is set - $pmatable = new PMA_Table($GLOBALS['table'], $GLOBALS['db']); - $col_order = $pmatable->getUiProp(PMA_Table::PROP_COLUMN_ORDER); - if ($col_order) { - echo ''; - } - $col_visib = $pmatable->getUiProp(PMA_Table::PROP_COLUMN_VISIB); - if ($col_visib) { - echo ''; - } - // generate table create time - if (! PMA_Table::isView($GLOBALS['table'], $GLOBALS['db'])) { - echo ''; - } + if (PMA_isSelect()) { + $table_headers_html .= PMA_getDataForResettingColumnOrder(); } - $vertical_display['emptypre'] = 0; $vertical_display['emptyafter'] = 0; $vertical_display['textbtn'] = ''; // Display options (if we are not in print view) - if (! (isset($GLOBALS['printview']) && $GLOBALS['printview'] == '1')) { - echo '
'; - $url_params = array( - 'db' => $db, - 'table' => $table, - 'sql_query' => $sql_query, - 'goto' => $goto, - 'display_options_form' => 1 - ); - echo PMA_generate_common_hidden_inputs($url_params); - echo '
'; - PMA_generateSliderEffect('displayoptions', __('Options')); - echo '
'; - - echo '
'; - $choices = array( - 'P' => __('Partial texts'), - 'F' => __('Full texts') - ); - PMA_displayHtmlRadio( - 'display_text', $choices, - $_SESSION['tmp_user_values']['display_text'] - ); - echo '
'; - + if (! (isset($GLOBALS['printview']) && ($GLOBALS['printview'] == '1'))) { + + $table_headers_html .= PMA_getOptionsBlock($db, $table, $sql_query, $goto); + // prepare full/partial text button or link - $url_params_full_text = array( - 'db' => $db, - 'table' => $table, - 'sql_query' => $sql_query, - 'goto' => $goto, - 'full_text_button' => 1 - ); - - if ($_SESSION['tmp_user_values']['display_text']=='F') { - // currently in fulltext mode so show the opposite link - $tmp_image_file = $GLOBALS['pmaThemeImage'] . 's_partialtext.png'; - $tmp_txt = __('Partial texts'); - $url_params_full_text['display_text'] = 'P'; - } else { - $tmp_image_file = $GLOBALS['pmaThemeImage'] . 's_fulltext.png'; - $tmp_txt = __('Full texts'); - $url_params_full_text['display_text'] = 'F'; - } - - $tmp_image = ''
-            . $tmp_txt . ''; - $tmp_url = 'sql.php' . PMA_generate_common_url($url_params_full_text); - $full_or_partial_text_link - = PMA_linkOrButton($tmp_url, $tmp_image, array(), false); - unset($tmp_image_file, $tmp_txt, $tmp_url, $tmp_image); - - - if ($GLOBALS['cfgRelation']['relwork'] - && $GLOBALS['cfgRelation']['displaywork'] - ) { - echo '
'; - $choices = array( - 'K' => __('Relational key'), - 'D' => __('Relational display column') - ); - PMA_displayHtmlRadio( - 'relational_display', $choices, - $_SESSION['tmp_user_values']['relational_display'] - ); - echo '
'; - } - - echo '
'; - echo PMA_getCheckbox( - 'display_binary', __('Show binary contents'), - ! empty($_SESSION['tmp_user_values']['display_binary']), false - ); - echo '
'; - echo PMA_getCheckbox( - 'display_blob', __('Show BLOB contents'), - ! empty($_SESSION['tmp_user_values']['display_blob']), false - ); - echo '
'; - echo PMA_getCheckbox( - 'display_binary_as_hex', __('Show binary contents as HEX'), - ! empty($_SESSION['tmp_user_values']['display_binary_as_hex']), false - ); - echo '
'; - - // 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. - echo '
'; - echo PMA_getCheckbox( - 'hide_transformation', __('Hide browser transformation'), - ! empty($_SESSION['tmp_user_values']['hide_transformation']), false - ); - echo '
'; - - if (! PMA_DRIZZLE) { - echo '
'; - $choices = array( - 'GEOM' => __('Geometry'), - 'WKT' => __('Well Known Text'), - 'WKB' => __('Well Known Binary') - ); - PMA_displayHtmlRadio( - 'geometry_display', $choices, - $_SESSION['tmp_user_values']['geometry_display'] - ); - echo '
'; - } - - echo '
'; - echo '
'; - - echo '
'; - echo ''; - echo '
'; - echo ''; - echo '
'; + $full_or_partial_text_link = PMA_getFullOrPartialTextButtonOrLink( + $db, $table, $sql_query, $goto + ); } // 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"; - } - - echo '' . "\n"; - if ($direction == 'horizontal' - || $direction == 'horizontalflipped' - ) { - echo '' . "\n"; - } - + $table_headers_html .= PMA_getFormForMultiRowOperations( + $db, $table, $is_display['del_lnk'] + ); + // 1. Displays the full/partial text button (part 1)... - if ($direction == 'horizontal' - || $direction == 'horizontalflipped' - ) { - $colspan = ($is_display['edit_lnk'] != 'nn' - && $is_display['del_lnk'] != 'nn') - ? ' colspan="4"' - : ''; + if ($directionCondition) { + + $table_headers_html .= '' . "\n"; + + $colspan = (($is_display['edit_lnk'] != 'nn') + && ($is_display['del_lnk'] != 'nn')) + ? ' colspan="4"' + : ''; + } else { - $rowspan = ($is_display['edit_lnk'] != 'nn' - && $is_display['del_lnk'] != 'nn') - ? ' rowspan="4"' - : ''; + $rowspan = (($is_display['edit_lnk'] != 'nn') + && ($is_display['del_lnk'] != 'nn')) + ? ' rowspan="4"' + : ''; } // ... before the result table - if (($is_display['edit_lnk'] == 'nn' && $is_display['del_lnk'] == 'nn') - && $is_display['text_btn'] == '1' + if ((($is_display['edit_lnk'] == 'nn') && ($is_display['del_lnk'] == 'nn')) + && ($is_display['text_btn'] == '1') ) { - $vertical_display['emptypre'] = ($is_display['edit_lnk'] != 'nn' - && $is_display['del_lnk'] != 'nn') ? 4 : 0; - if ($direction == 'horizontal' - || $direction == 'horizontalflipped' - ) { - ?> - - - - ' + . '' + . ''; + // end horizontal/horizontalflipped mode } else { - ?> - - - - ' + . '' + . ''; + } // end vertical mode - } elseif (($GLOBALS['cfg']['RowActionLinks'] == 'left' - || $GLOBALS['cfg']['RowActionLinks'] == 'both') - && $is_display['text_btn'] == '1' + } elseif ((($GLOBALS['cfg']['RowActionLinks'] == 'left') + || ($GLOBALS['cfg']['RowActionLinks'] == 'both')) + && ($is_display['text_btn'] == '1') ) { // ... at the left column of the result table header if possible // and required - $vertical_display['emptypre'] = ($is_display['edit_lnk'] != 'nn' - && $is_display['del_lnk'] != 'nn') ? 4 : 0; - if ($direction == 'horizontal' - || $direction == 'horizontalflipped' - ) { - ?> - - ' + . $full_or_partial_text_link . ''; // end horizontal/horizontalflipped mode + } else { + $vertical_display['textbtn'] = ' ' . "\n"; } // end vertical mode - } elseif (($GLOBALS['cfg']['RowActionLinks'] == 'left' - || $GLOBALS['cfg']['RowActionLinks'] == 'both') - && ($is_display['edit_lnk'] != 'nn' || $is_display['del_lnk'] != 'nn')) { + } elseif ((($GLOBALS['cfg']['RowActionLinks'] == 'left') + || ($GLOBALS['cfg']['RowActionLinks'] == 'both')) + && (($is_display['edit_lnk'] != 'nn') || ($is_display['del_lnk'] != 'nn')) + ) { // ... elseif no button, displays empty(ies) col(s) if required - $vertical_display['emptypre'] = ($is_display['edit_lnk'] != 'nn' - && $is_display['del_lnk'] != 'nn') ? 4 : 0; - if ($direction == 'horizontal' - || $direction == 'horizontalflipped' - ) { - ?> - > - '; + // end horizontal/horizontalfipped mode } else { $vertical_display['textbtn'] = ' ' . "\n"; } // end vertical mode - } elseif ($GLOBALS['cfg']['RowActionLinks'] == 'none' - && ($direction == 'horizontal' - || $direction == 'horizontalflipped') + } elseif (($GLOBALS['cfg']['RowActionLinks'] == 'none') + && ($directionCondition) ) { // ... 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 @@ -967,7 +859,7 @@ function PMA_displayTableHeaders(&$is_display, &$fields_meta, $fields_cnt = 0, // Do not show comments, if using horizontalflipped mode, // because of space usage if ($GLOBALS['cfg']['ShowBrowseComments'] - && $direction != 'horizontalflipped' + && ($direction != 'horizontalflipped') ) { $comments_map = array(); if (isset($analyzed_sql[0]) && is_array($analyzed_sql[0])) { @@ -1000,49 +892,30 @@ function PMA_displayTableHeaders(&$is_display, &$fields_meta, $fields_cnt = 0, && is_array($analyzed_sql[0]['where_clause_identifiers']) ) { foreach ($analyzed_sql[0]['where_clause_identifiers'] - as $wci_nr => $wci) { + as $wci_nr => $wci + ) { $highlight_columns[$wci] = 'true'; } } } - if (PMA_isSelect()) { - // prepare to get the column order, if available - $pmatable = new PMA_Table($GLOBALS['table'], $GLOBALS['db']); - $col_order = $pmatable->getUiProp(PMA_Table::PROP_COLUMN_ORDER); - $col_visib = $pmatable->getUiProp(PMA_Table::PROP_COLUMN_VISIB); - } else { - $col_order = false; - $col_visib = false; - } - + list($col_order, $col_visib) = PMA_getColumnParams(); + for ($j = 0; $j < $fields_cnt; $j++) { + // assign $i with appropriate column order $i = $col_order ? $col_order[$j] : $j; + // See if this column should get highlight because it's used in the // where-query. - if (isset($highlight_columns[$fields_meta[$i]->name]) - || isset($highlight_columns[PMA_backquote($fields_meta[$i]->name)]) - ) { - $condition_field = true; - } else { - $condition_field = false; - } - + $condition_field = (isset($highlight_columns[$fields_meta[$i]->name]) + || isset($highlight_columns[PMA_backquote($fields_meta[$i]->name)])) + ? true + : false; + // 2.0 Prepare comment-HTML-wrappers for each row, if defined/enabled. - if (isset($comments_map) - && isset($comments_map[$fields_meta[$i]->table]) - && isset($comments_map[$fields_meta[$i]->table][$fields_meta[$i]->name]) - ) { - $comments = '' - . htmlspecialchars( - $comments_map[$fields_meta[$i]->table][$fields_meta[$i]->name] - ) - . ''; - } else { - $comments = ''; - } - + $comments = PMA_getCommentForRow($comments_map, $fields_meta[$i]); + // 2.1 Results can be sorted if ($is_display['sort_lnk'] == '1') { @@ -1051,12 +924,11 @@ function PMA_displayTableHeaders(&$is_display, &$fields_meta, $fields_cnt = 0, // isn't aliased, or in queries like // SELECT `1`.`master_field` , `2`.`master_field` // FROM `PMA_relation` AS `1` , `PMA_relation` AS `2` - - if (isset($fields_meta[$i]->table) && strlen($fields_meta[$i]->table)) { - $sort_tbl = PMA_backquote($fields_meta[$i]->table) . '.'; - } else { - $sort_tbl = ''; - } + + $sort_tbl = (isset($fields_meta[$i]->table) + && strlen($fields_meta[$i]->table)) + ? PMA_backquote($fields_meta[$i]->table) . '.' + : ''; // 2.1.2 Checks if the current column is used to sort the // results @@ -1070,47 +942,23 @@ function PMA_displayTableHeaders(&$is_display, &$fields_meta, $fields_cnt = 0, $name_to_use_in_sort = $fields_meta[$i]->orgname; $is_orgname = true; } + // $name_to_use_in_sort might contain a space due to // formatting of function expressions like "COUNT(name )" // so we remove the space in this situation $name_to_use_in_sort = str_replace(' )', ')', $name_to_use_in_sort); - if (empty($sort_expression)) { - $is_in_sort = false; - } else { - // Field name may be preceded by a space, or any number - // of characters followed by a dot (tablename.fieldname) - // so do a direct comparison for the sort expression; - // this avoids problems with queries like - // "SELECT id, count(id)..." and clicking to sort - // on id or on count(id). - // Another query to test this: - // SELECT p.*, FROM_UNIXTIME(p.temps) FROM mytable AS p - // (and try clicking on each column's header twice) - if (! empty($sort_tbl) - && strpos($sort_expression_nodirection, $sort_tbl) === false - && strpos($sort_expression_nodirection, '(') === false - ) { - $new_sort_expression_nodirection = $sort_tbl - . $sort_expression_nodirection; - } else { - $new_sort_expression_nodirection = $sort_expression_nodirection; - } - - $is_in_sort = false; - $sort_name = str_replace('`', '', $sort_tbl) . $name_to_use_in_sort; - if ($sort_name == str_replace('`', '', $new_sort_expression_nodirection) - || $sort_name == str_replace('`', '', $sort_expression_nodirection) - ) { - $is_in_sort = true; - } - } + $is_in_sort = PMA_isInSorted( + $sort_expression, $sort_expression_nodirection, + $sort_tbl, $name_to_use_in_sort + ); + // 2.1.3 Check the field name for a bracket. // If it contains one, it's probably a function column // like 'COUNT(`field`)' // It still might be a column name of a view. See bug #3383711 // Check is_orgname. - if (strpos($name_to_use_in_sort, '(') !== false && ! $is_orgname) { + if ((strpos($name_to_use_in_sort, '(') !== false) && ! $is_orgname) { $sort_order = "\n" . 'ORDER BY ' . $name_to_use_in_sort . ' '; } else { $sort_order = "\n" . 'ORDER BY ' . $sort_tbl @@ -1120,40 +968,12 @@ function PMA_displayTableHeaders(&$is_display, &$fields_meta, $fields_cnt = 0, unset($is_orgname); // 2.1.4 Do define the sorting URL - if (! $is_in_sort) { - // patch #455484 ("Smart" order) - $GLOBALS['cfg']['Order'] = strtoupper($GLOBALS['cfg']['Order']); - if ($GLOBALS['cfg']['Order'] === 'SMART') { - $sort_order .= (preg_match( - '@time|date@i', - $fields_meta[$i]->type - )) ? 'DESC' : 'ASC'; - } else { - $sort_order .= $GLOBALS['cfg']['Order']; - } - $order_img = ''; - } elseif ('DESC' == $sort_direction) { - $sort_order .= ' ASC'; - $order_img = ' ' . PMA_getImage( - 's_desc.png', __('Descending'), - array('class' => "soimg$i", 'title' => '') + + list($sort_order, $order_img) = PMA_getSortingUrlParams( + $is_in_sort, $sort_direction, $fields_meta[$i], + $sort_order, $i ); - $order_img .= ' ' . PMA_getImage( - 's_asc.png', __('Ascending'), - array('class' => "soimg$i hide", 'title' => '') - ); - } else { - $sort_order .= ' DESC'; - $order_img = ' ' . PMA_getImage( - 's_asc.png', __('Ascending'), - array('class' => "soimg$i", 'title' => '') - ); - $order_img .= ' ' . PMA_getImage( - 's_desc.png', __('Descending'), - array('class' => "soimg$i hide", 'title' => '') - ); - } - + if (preg_match('@(.*)([[:space:]](LIMIT (.*)|PROCEDURE (.*)|FOR UPDATE|' . 'LOCK IN SHARE MODE))@is', $unsorted_sql_query, $regs3) ) { @@ -1161,6 +981,7 @@ function PMA_displayTableHeaders(&$is_display, &$fields_meta, $fields_cnt = 0, } else { $sorted_sql_query = $unsorted_sql_query . $sort_order; } + $_url_params = array( 'db' => $db, 'table' => $table, @@ -1170,70 +991,18 @@ function PMA_displayTableHeaders(&$is_display, &$fields_meta, $fields_cnt = 0, $order_url = 'sql.php' . PMA_generate_common_url($_url_params); // 2.1.5 Displays the sorting URL - // enable sort order swapping for image - $order_link_params = array(); - if (isset($order_img) && $order_img!='') { - if (strstr($order_img, 'asc')) { - $order_link_params['onmouseover'] = "$('.soimg$i').toggle()"; - $order_link_params['onmouseout'] = "$('.soimg$i').toggle()"; - } elseif (strstr($order_img, 'desc')) { - $order_link_params['onmouseover'] = "$('.soimg$i').toggle()"; - $order_link_params['onmouseout'] = "$('.soimg$i').toggle()"; - } - } - if ($GLOBALS['cfg']['HeaderFlipType'] == 'auto') { - if (PMA_USR_BROWSER_AGENT == 'IE') { - $GLOBALS['cfg']['HeaderFlipType'] = 'css'; - } else { - $GLOBALS['cfg']['HeaderFlipType'] = 'fake'; - } - } - if ($direction == 'horizontalflipped' - && $GLOBALS['cfg']['HeaderFlipType'] == 'css' - ) { - $order_link_params['style'] = 'direction: ltr; writing-mode: tb-rl;'; - } - $order_link_params['title'] = __('Sort'); - $order_link_content = ($direction - == 'horizontalflipped' - && $GLOBALS['cfg']['HeaderFlipType'] == 'fake' - ? PMA_flipstring( - htmlspecialchars($fields_meta[$i]->name), - "
\n" - ) - : htmlspecialchars($fields_meta[$i]->name)); - $order_link = PMA_linkOrButton( - $order_url, $order_link_content . $order_img, - $order_link_params, false, true - ); + // enable sort order swapping for image + $order_link = PMA_getSortOrderLink( + $order_img, $i, $direction, $fields_meta[$i], $order_url + ); - if ($direction == 'horizontal' - || $direction == 'horizontalflipped' - ) { - echo '' . $order_link . $comments . ''; + if ($directionCondition) { + $table_headers_html .= PMA_getDraggableClassForSortableColumns( + $col_visib, $col_visib[$j], $condition_field, + $direction, $fields_meta[$i], $order_link, $comments + ); } + $vertical_display['desc'][] = ' '; + + if ($directionCondition) { + $table_headers_html .= PMA_getDraggableClassForNonSortableColumns( + $col_visib, $col_visib[$j], $condition_field, + $direction, $fields_meta[$i], $comments + ); } + $vertical_display['desc'][] = ' - ' . $full_or_partial_text_link + . ''; + // end horizontal/horizontalflipped mode } else { $vertical_display['textbtn'] = ' - - ' + . ''; + } + + return $table_headers_html; + +} // end of the 'PMA_getTableHeaders()' function + + +/** + * Prepare sort by key dropdown - html code segment + * + * @param string $db the database name + * @param string $table the table name + * @param array $indexes the indexes of the table for sort criteria + * @param string $sort_expression the sort expression + * @param string $unsorted_sql_query the unsorted sql query + * + * @return string $drop_down_html html content + * + * @see PMA_getTableHeaders() + */ +function PMA_getSortByKeyDropDown( + $db, $table, $indexes, $sort_expression, $unsorted_sql_query +) { + + $drop_down_html = ''; + + $drop_down_html .= '' . "\n" + . PMA_generate_common_hidden_inputs($db, $table) + . __('Sort by key') + . ': ' . "\n" + . '' . "\n"; + + return $drop_down_html; + +} + + +/** + * Prepare data for column restoring and show/hide + * + * @return string $data_html html content + * + * @see PMA_getTableHeaders() + */ +function PMA_getDataForResettingColumnOrder() +{ + + $data_html = ''; + + // generate the column order, if it is set + $pmatable = new PMA_Table($GLOBALS['table'], $GLOBALS['db']); + $col_order = $pmatable->getUiProp(PMA_Table::PROP_COLUMN_ORDER); + + if ($col_order) { + $data_html .= ''; + } + + $col_visib = $pmatable->getUiProp(PMA_Table::PROP_COLUMN_VISIB); + + if ($col_visib) { + $data_html .= ''; + } + + // generate table create time + if (! PMA_Table::isView($GLOBALS['table'], $GLOBALS['db'])) { + $data_html .= ''; + } + + return $data_html; + +} + + +/** + * Prepare option fields block + * + * @param string $db the database name + * @param string $table the table name + * @param string $sql_query the SQL query + * @param string $goto the URL to go back in case of errors + * + * @return string $options_html html content + * + * @see PMA_getTableHeaders() + */ +function PMA_getOptionsBlock($db, $table, $sql_query, $goto) +{ + + $options_html = ''; + + $options_html .= ' $db, + 'table' => $table, + 'sql_query' => $sql_query, + 'goto' => $goto, + 'display_options_form' => 1 + ); + + $options_html .= PMA_generate_common_hidden_inputs($url_params) + . '
' + . PMA_getDivForSliderEffect('displayoptions', __('Options')) + . '
'; + + $options_html .= '
'; + $choices = array( + 'P' => __('Partial texts'), + 'F' => __('Full texts') + ); + + $options_html .= PMA_getRadioFields( + 'display_text', $choices, + $_SESSION['tmp_user_values']['display_text'] + ) + . '
'; + + if ($GLOBALS['cfgRelation']['relwork'] + && $GLOBALS['cfgRelation']['displaywork'] + ) { + $options_html .= '
'; + $choices = array( + 'K' => __('Relational key'), + 'D' => __('Relational display column') + ); + + $options_html .= PMA_getRadioFields( + 'relational_display', $choices, + $_SESSION['tmp_user_values']['relational_display'] + ) + . '
'; + } + + $options_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 + ) + . '
'; + + // 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. + $options_html .= '
' + . PMA_getCheckbox( + 'hide_transformation', __('Hide browser transformation'), + ! empty($_SESSION['tmp_user_values']['hide_transformation']), false + ) + . '
'; + + if (! PMA_DRIZZLE) { + $options_html .= '
'; + $choices = array( + 'GEOM' => __('Geometry'), + 'WKT' => __('Well Known Text'), + 'WKB' => __('Well Known Binary') + ); + + $options_html .= PMA_getRadioFields( + 'geometry_display', $choices, + $_SESSION['tmp_user_values']['geometry_display'] + ) + . '
'; + } + + $options_html .= '
' + . '
'; + + $options_html .= '
' + . '' + . '
' + . '' + . ''; + + return $options_html; + +} + + +/** + * Get full/partial text button or link + * + * @param string $db the database name + * @param string $table the table name + * @param string $sql_query the SQL query + * @param string $goto the URL to go back in case of errors + * + * @return string html content + * + * @see PMA_getTableHeaders() + */ +function PMA_getFullOrPartialTextButtonOrLink($db, $table, $sql_query, $goto) +{ + + $url_params_full_text = array( + 'db' => $db, + 'table' => $table, + 'sql_query' => $sql_query, + 'goto' => $goto, + 'full_text_button' => 1 + ); + + if ($_SESSION['tmp_user_values']['display_text'] == 'F') { + // currently in fulltext mode so show the opposite link + $tmp_image_file = $GLOBALS['pmaThemeImage'] . 's_partialtext.png'; + $tmp_txt = __('Partial texts'); + $url_params_full_text['display_text'] = 'P'; + } else { + $tmp_image_file = $GLOBALS['pmaThemeImage'] . 's_fulltext.png'; + $tmp_txt = __('Full texts'); + $url_params_full_text['display_text'] = 'F'; + } + + $tmp_image = ''
+                 . $tmp_txt . ''; + $tmp_url = 'sql.php' . PMA_generate_common_url($url_params_full_text); + + return PMA_linkOrButton($tmp_url, $tmp_image, array(), false); + +} + + +/** + * Prepare html form for multi row operations + * + * @param string $db the database name + * @param string $table the table name + * @param string $del_lnk the delete link of current row + * + * @return string $form_html html content + * + * @see PMA_getTableHeaders() + */ +function PMA_getFormForMultiRowOperations($db, $table, $del_lnk) +{ + + $form_html = ''; + + if (($del_lnk == 'dr') || ($del_lnk == 'kp')) { + + $form_html .= '' . "\n"; + } + + $form_html .= '
>' . "\n" . ' ' . "\n" . ' '; - if ($direction == 'horizontalflipped' - && $GLOBALS['cfg']['HeaderFlipType'] == 'fake' - ) { - echo PMA_flipstring( - htmlspecialchars($fields_meta[$i]->name), '
' - ); - } else { - echo htmlspecialchars($fields_meta[$i]->name); - } - echo "\n" . $comments . '
- > - -> - '; + // end horizontal/horizontalflipped mode } else { $vertical_display['textbtn'] = ' ' . "\n"; } // end vertical mode } - if ($direction == 'horizontal' - || $direction == 'horizontalflipped' - ) { - ?> -
' . "\n"; + + return $form_html; + +} + + +/** + * Get comment for row + * + * @param array $comments_map comments array + * @param array $fields_meta set of field properties + * + * @return string $comment html content + * + * @see PMA_getTableHeaders() + */ +function PMA_getCommentForRow($comments_map, $fields_meta) +{ + $comments = ''; + if (isset($comments_map) + && isset($comments_map[$fields_meta->table]) + && isset($comments_map[$fields_meta->table][$fields_meta->name]) + ) { + $comments = '' + . htmlspecialchars( + $comments_map[$fields_meta->table][$fields_meta->name] + ) + . ''; + } + return $comments; +} + + +/** + * Check whether the column is sorted + * + * @param string $sort_expression sort expression + * @param string $sort_expression_nodirection sort expression without direction + * @param string $sort_tbl the table name + * @param string $name_to_use_in_sort the sorting column name + * + * @return boolean $is_in_sort the column sorted or not + * + * @see PMA_getTableHeaders() + */ +function PMA_isInSorted( + $sort_expression, $sort_expression_nodirection, $sort_tbl, + $name_to_use_in_sort +) { + + if (empty($sort_expression)) { + $is_in_sort = false; + } else { + // Field name may be preceded by a space, or any number + // of characters followed by a dot (tablename.fieldname) + // so do a direct comparison for the sort expression; + // this avoids problems with queries like + // "SELECT id, count(id)..." and clicking to sort + // on id or on count(id). + // Another query to test this: + // SELECT p.*, FROM_UNIXTIME(p.temps) FROM mytable AS p + // (and try clicking on each column's header twice) + if (! empty($sort_tbl) + && (strpos($sort_expression_nodirection, $sort_tbl) === false) + && (strpos($sort_expression_nodirection, '(') === false) + ) { + $new_sort_expression_nodirection = $sort_tbl + . $sort_expression_nodirection; + } else { + $new_sort_expression_nodirection = $sort_expression_nodirection; + } + + $is_in_sort = false; + $sort_name = str_replace('`', '', $sort_tbl) . $name_to_use_in_sort; + + if (($sort_name == str_replace('`', '', $new_sort_expression_nodirection)) + || ($sort_name == str_replace('`', '', $sort_expression_nodirection)) + ) { + $is_in_sort = true; + } + } + + return $is_in_sort; + +} + + +/** + * Get sort url paramaeters - sort order and order image + * + * @param boolean $is_in_sort the column sorted or not + * @param string $sort_direction the sort direction + * @param array $fields_meta set of field properties + * @param string $sort_order the sorting order + * @param integer $column_index the index of the column + * + * @return array 2 element array - $sort_order, $order_img + * + * @see PMA_getTableHeaders() + */ +function PMA_getSortingUrlParams( + $is_in_sort, $sort_direction, $fields_meta, $sort_order, $column_index +) { + + if (! $is_in_sort) { + + // patch #455484 ("Smart" order) + $GLOBALS['cfg']['Order'] = strtoupper($GLOBALS['cfg']['Order']); + + if ($GLOBALS['cfg']['Order'] === 'SMART') { + $sort_order .= (preg_match( + '@time|date@i', + $fields_meta->type + )) ? 'DESC' : 'ASC'; + } else { + $sort_order .= $GLOBALS['cfg']['Order']; + } + $order_img = ''; + + } elseif ($sort_direction == 'DESC') { + + $sort_order .= ' ASC'; + $order_img = ' ' . PMA_getImage( + 's_desc.png', __('Descending'), + array('class' => "soimg$column_index", 'title' => '') + ); + + $order_img .= ' ' . PMA_getImage( + 's_asc.png', __('Ascending'), + array('class' => "soimg$column_index hide", 'title' => '') + ); + + } else { + + $sort_order .= ' DESC'; + $order_img = ' ' . PMA_getImage( + 's_asc.png', __('Ascending'), + array('class' => "soimg$column_index", 'title' => '') + ); + + $order_img .= ' ' . PMA_getImage( + 's_desc.png', __('Descending'), + array('class' => "soimg$column_index hide", 'title' => '') + ); + } + + return array($sort_order, $order_img); + +} + + +/** + * Get sort order link + * + * @param string $order_img the sort order image + * @param integer $col_index the index of the column + * @param string $direction the display direction + * @param array $fields_meta set of field properties + * @param string $order_url the url for sort + * + * @return string the sort order link + * + * @see PMA_getTableHeaders() + */ +function PMA_getSortOrderLink( + $order_img, $col_index, $direction, $fields_meta, $order_url +) { + + $order_link_params = array(); + + if (isset($order_img) && ($order_img != '')) { + if (strstr($order_img, 'asc')) { + $order_link_params['onmouseover'] = "$('.soimg$col_index').toggle()"; + $order_link_params['onmouseout'] = "$('.soimg$col_index').toggle()"; + } elseif (strstr($order_img, 'desc')) { + $order_link_params['onmouseover'] = "$('.soimg$col_index').toggle()"; + $order_link_params['onmouseout'] = "$('.soimg$col_index').toggle()"; + } + } + + if ($GLOBALS['cfg']['HeaderFlipType'] == 'auto') { + + $GLOBALS['cfg']['HeaderFlipType'] + = (PMA_USR_BROWSER_AGENT == 'IE') ? 'css' : 'fake'; + } + + if ($direction == 'horizontalflipped' + && $GLOBALS['cfg']['HeaderFlipType'] == 'css' + ) { + $order_link_params['style'] = 'direction: ltr; writing-mode: tb-rl;'; + } + + $order_link_params['title'] = __('Sort'); + + $order_link_content = (($direction == 'horizontalflipped') + && ($GLOBALS['cfg']['HeaderFlipType'] == 'fake')) + ? PMA_flipstring( + htmlspecialchars($fields_meta->name), + "
\n" + ) + : htmlspecialchars($fields_meta->name); + + return PMA_linkOrButton( + $order_url, $order_link_content . $order_img, + $order_link_params, false, true + ); + +} + + +/** + * Prepare columns to draggable effect for sortable columns + * + * @param boolean $col_visib the column is visible (false) + * array the column is not visible (string array) + * @param string $col_visib_j element of $col_visib array + * @param boolean $condition_field whether to add CSS class condition + * @param string $direction the display direction + * @param array $fields_meta set of field properties + * @param string $order_link the order link + * @param string $comments the comment for the column + * + * @return string $draggable_html html content + * + * @see PMA_getTableHeaders() + */ +function PMA_getDraggableClassForSortableColumns( + $col_visib, $col_visib_j, $condition_field, $direction, $fields_meta, + $order_link, $comments +) { + + $draggable_html = 'name) + . '">' . $order_link . $comments . ''; + + return $draggable_html; + +} + + +/** + * Prepare columns to draggable effect for non sortable columns + * + * @param boolean $col_visib the column is visible (false) + * array the column is not visible (string array) + * @param string $col_visib_j element of $col_visib array + * @param boolean $condition_field whether to add CSS class condition + * @param string $direction the display direction + * @param array $fields_meta set of field properties + * @param string $comments the comment for the column + * + * @return string $draggable_html html content + * + * @see PMA_getTableHeaders() + */ +function PMA_getDraggableClassForNonSortableColumns( + $col_visib, $col_visib_j, $condition_field, + $direction, $fields_meta, $comments +) { + + $draggable_html = 'name) . '">'; + + if (($direction == 'horizontalflipped') + && ($GLOBALS['cfg']['HeaderFlipType'] == 'fake') + ) { + + $draggable_html .= PMA_flipstring( + htmlspecialchars($fields_meta->name), '
' + ); + + } else { + $draggable_html .= htmlspecialchars($fields_meta->name); + } + + $draggable_html .= "\n" . $comments . ''; + + return $draggable_html; + +} /** @@ -1367,6 +1763,7 @@ function PMA_buildValueDisplay($class, $condition_field, $value) . '">' . $value . ''; } + /** * Prepares the display for a null value * @@ -1380,12 +1777,14 @@ function PMA_buildValueDisplay($class, $condition_field, $value) function PMA_buildNullDisplay($class, $condition_field, $meta, $align = '') { // the null class is needed for grid editing - return '
'; + return ''; } + /** * Prepares the display for an empty value * @@ -1398,13 +1797,14 @@ function PMA_buildNullDisplay($class, $condition_field, $meta, $align = '') */ function PMA_buildEmptyDisplay($class, $condition_field, $meta, $align = '') { - $nowrap = ' nowrap'; - return ''; + return ''; } + /** * Adds the relavant classes. * @@ -1421,6 +1821,7 @@ function PMA_buildEmptyDisplay($class, $condition_field, $meta, $align = '') function PMA_addClass($class, $condition_field, $meta, $nowrap, $is_field_truncated = false, $transform_function = '', $default_function = '' ) { + // Define classes to be added to this data field based on the type of data $enum_class = ''; if (strpos($meta->flags, 'enum') !== false) { @@ -1442,23 +1843,24 @@ 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 + * Prepare the body of the results table * - * @param integer &$dt_result the link id associated to the query - * which results have to be displayed - * @param array &$is_display which elements to display - * @param array $map the list of relations - * @param array $analyzed_sql the analyzed query + * @param integer &$dt_result the link id associated to the query + * which results have to be displayed + * @param array &$is_display which elements to display + * @param array $map the list of relations + * @param array $analyzed_sql the analyzed query * - * @return boolean always true + * @return string $table_body_html html content * * @global string $db the database name * @global string $table the table name @@ -1466,49 +1868,35 @@ function PMA_addClass($class, $condition_field, $meta, $nowrap, * @global string $sql_query the SQL query * @global array $fields_meta the list of fields properties * @global integer $fields_cnt the total number of fields returned by - * the SQL query + * the SQL query * @global array $vertical_display informations used with vertical display - * mode + * mode * @global array $highlight_columns column names to highlight * @global array $row current row data * * @access private * - * @see PMA_displayTable() + * @see PMA_getTable() */ -function PMA_displayTableBody(&$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; global $vertical_display, $highlight_columns; global $row; // mostly because of browser transformations, // to make the row-data accessible in a plugin - $url_sql_query = $sql_query; + $table_body_html = ''; // query without conditions to shorten URLs when needed, 200 is just // guess, it should depend on remaining URL length - - if (isset($analyzed_sql) - && isset($analyzed_sql[0]) - && isset($analyzed_sql[0]['querytype']) - && $analyzed_sql[0]['querytype'] == 'SELECT' - && strlen($sql_query) > 200 - ) { - - $url_sql_query = 'SELECT '; - if (isset($analyzed_sql[0]['queryflags']['distinct'])) { - $url_sql_query .= ' DISTINCT '; - } - $url_sql_query .= $analyzed_sql[0]['select_expr_clause']; - if (!empty($analyzed_sql[0]['from_clause'])) { - $url_sql_query .= ' FROM ' . $analyzed_sql[0]['from_clause']; - } - } - + $url_sql_query = PMA_getUrlSqlQuery($analyzed_sql, $sql_query); + if (! is_array($map)) { $map = array(); } + $row_no = 0; $vertical_display['edit'] = array(); $vertical_display['copy'] = array(); @@ -1519,14 +1907,7 @@ function PMA_displayTableBody(&$dt_result, &$is_display, $map, $analyzed_sql) $grid_edit_class = 'grid_edit'; // prepare to get the column order, if available - if (PMA_isSelect()) { - $pmatable = new PMA_Table($GLOBALS['table'], $GLOBALS['db']); - $col_order = $pmatable->getUiProp(PMA_Table::PROP_COLUMN_ORDER); - $col_visib = $pmatable->getUiProp(PMA_Table::PROP_COLUMN_VISIB); - } else { - $col_order = false; - $col_visib = false; - } + list($col_order, $col_visib) = PMA_getColumnParams(); // Correction University of Virginia 19991216 in the while below // Previous code assumed that all tables have keys, specifically that @@ -1541,43 +1922,24 @@ function PMA_displayTableBody(&$dt_result, &$is_display, $map, $analyzed_sql) // delete/edit options correctly for tables without keys. $odd_row = true; + $directionCondition = ($_SESSION['tmp_user_values']['disp_direction'] == 'horizontal') + || ($_SESSION['tmp_user_values']['disp_direction'] == 'horizontalflipped'); + while ($row = PMA_DBI_fetch_row($dt_result)) { + // "vertical display" mode stuff - if ($row_no != 0 && $_SESSION['tmp_user_values']['repeat_cells'] != 0 - && !($row_no % $_SESSION['tmp_user_values']['repeat_cells']) - && ($_SESSION['tmp_user_values']['disp_direction'] == 'horizontal' - || $_SESSION['tmp_user_values']['disp_direction'] == 'horizontalflipped') - ) { - echo '' . "\n"; - if ($vertical_display['emptypre'] > 0) { - echo ' ' . "\n"; - } else if ($GLOBALS['cfg']['RowActionLinks'] == 'none') { - echo ' ' . "\n"; - } - - foreach ($vertical_display['desc'] as $val) { - echo $val; - } - - if ($vertical_display['emptyafter'] > 0) { - echo ' ' . "\n"; - } - echo '' . "\n"; - } // end if + $table_body_html .= PMA_getVerticalDisplaySupportSegments( + $vertical_display, $row_no, $directionCondition + ); $alternating_color_class = ($odd_row ? 'odd' : 'even'); $odd_row = ! $odd_row; - if ($_SESSION['tmp_user_values']['disp_direction'] == 'horizontal' - || $_SESSION['tmp_user_values']['disp_direction'] == 'horizontalflipped' - ) { + if ($directionCondition) { // pointer code part - echo ''; + $table_body_html .= ''; } - // 1. Prepares the row // 1.1 Results from a "SELECT" statement -> builds the // WHERE clause to use in links (a unique key if possible) @@ -1592,7 +1954,7 @@ function PMA_displayTableBody(&$dt_result, &$is_display, $map, $analyzed_sql) // 1.2 Defines the URLs for the modify/delete link(s) - if ($is_display['edit_lnk'] != 'nn' || $is_display['del_lnk'] != 'nn') { + if (($is_display['edit_lnk'] != 'nn') || ($is_display['del_lnk'] != 'nn')) { // We need to copy the value // or else the == 'both' check will always return true @@ -1604,120 +1966,57 @@ function PMA_displayTableBody(&$dt_result, &$is_display, $map, $analyzed_sql) // 1.2.1 Modify link(s) if ($is_display['edit_lnk'] == 'ur') { // update row case - $_url_params = array( - 'db' => $db, - 'table' => $table, - 'where_clause' => $where_clause, - 'clause_is_unique' => $clause_is_unique, - '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_str = PMA_getIcon('b_edit.png', __('Edit')); - $copy_str = PMA_getIcon('b_insrow.png', __('Copy')); - - // Class definitions required for grid editing jQuery scripts - $edit_anchor_class = "edit_row_anchor"; - if ( $clause_is_unique == 0) { - $edit_anchor_class .= ' nonunique'; - } + + list($edit_url, $copy_url, $edit_str, $copy_str, $edit_anchor_class) + = PMA_getModifiedLinks( + $db, $table, $where_clause, + $clause_is_unique, $url_sql_query + ); + } // end if (1.2.1) // 1.2.2 Delete/Kill link(s) - if ($is_display['del_lnk'] == 'dr') { // delete row case - $_url_params = array( - 'db' => $db, - 'table' => $table, - 'sql_query' => $url_sql_query, - 'message_to_show' => __('The row has been deleted'), - 'goto' => (empty($goto) ? 'tbl_sql.php' : $goto), - ); - $lnk_goto = 'sql.php' . PMA_generate_common_url($_url_params, 'text'); - - $del_query = 'DELETE FROM ' . PMA_backquote($db) . '.' - . PMA_backquote($table) - . ' WHERE ' . $where_clause . - ($clause_is_unique - ? '' - : ' LIMIT 1'); - - $_url_params = array( - 'db' => $db, - 'table' => $table, - 'sql_query' => $del_query, - 'message_to_show' => __('The row has been deleted'), - 'goto' => $lnk_goto, - ); - $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'); - $del_str = PMA_getIcon('b_drop.png', __('Delete')); - } elseif ($is_display['del_lnk'] == 'kp') { // kill process case - - $_url_params = array( - 'db' => $db, - 'table' => $table, - 'sql_query' => $url_sql_query, - 'goto' => 'main.php', - ); - $lnk_goto = 'sql.php' . PMA_generate_common_url( - $_url_params, 'text' - ); - - $_url_params = array( - 'db' => 'mysql', - 'sql_query' => 'KILL ' . $row[0], - 'goto' => $lnk_goto, - ); - $del_url = 'sql.php' . PMA_generate_common_url($_url_params); - $del_query = 'KILL ' . $row[0]; - $js_conf = 'KILL ' . $row[0]; - $del_str = PMA_getIcon('b_drop.png', __('Kill')); + if (($is_display['del_lnk'] == 'dr') || ($is_display['del_lnk'] == 'kp')) { + + list($del_query, $del_url, $del_str, $js_conf) + = PMA_getDeleteAndKillLinks( + $db, $table, $where_clause, $clause_is_unique, + $url_sql_query, $goto, $is_display['del_lnk'] + ); + } // end if (1.2.2) // 1.3 Displays the links at left if required - if (($GLOBALS['cfg']['RowActionLinks'] == 'left' - || $GLOBALS['cfg']['RowActionLinks'] == 'both') - && ($_SESSION['tmp_user_values']['disp_direction'] == 'horizontal' - || $_SESSION['tmp_user_values']['disp_direction'] == 'horizontalflipped') + if ((($GLOBALS['cfg']['RowActionLinks'] == 'left') + || ($GLOBALS['cfg']['RowActionLinks'] == 'both')) + && $directionCondition ) { - 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_getPlacedLinks( + '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') + && $directionCondition ) { - 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_getPlacedLinks( + '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) // 2. Displays the rows' values for ($j = 0; $j < $fields_cnt; ++$j) { + // assign $i with appropriate column order $i = $col_order ? $col_order[$j] : $j; @@ -1726,50 +2025,29 @@ function PMA_displayTableBody(&$dt_result, &$is_display, $map, $analyzed_sql) $relation_class = isset($map[$meta->name]) ? 'relation' : ''; $hide_class = ($col_visib && !$col_visib[$j] // hide per - '; } // end if // 4. Gather links of del_urls and edit_urls in an array for later @@ -2150,171 +2206,126 @@ function PMA_displayTableBody(&$dt_result, &$is_display, $map, $analyzed_sql) $vertical_display['delete'][$row_no] = ''; $vertical_display['row_delete'][$row_no] = ''; } + $vertical_class = ' row_' . $row_no; if ($GLOBALS['cfg']['BrowsePointerEnable'] == true) { $vertical_class .= ' vpointer'; } + if ($GLOBALS['cfg']['BrowseMarkerEnable'] == true) { $vertical_class .= ' vmarker'; } - 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 - ); + if (!empty($del_url) && ($is_display['del_lnk'] != 'kp')) { + + $vertical_display['row_delete'][$row_no] .= PMA_getCheckboxForMultiRowSubmissions( + $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 - ); + + $vertical_display['edit'][$row_no] .= PMA_getEditLink( + $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 - ); + + $vertical_display['copy'][$row_no] .= PMA_getCopyLink( + $copy_url, $copy_str, $where_clause, $where_clause_html, + $alternating_color_class . $vertical_class + ); + } else { unset($vertical_display['copy'][$row_no]); } if (isset($del_url)) { + if (! isset($js_conf)) { $js_conf = ''; } - $vertical_display['delete'][$row_no] .= PMA_generateDeleteLink( - $del_url, $del_str, $js_conf, - $alternating_color_class . $vertical_class - ); + + $vertical_display['delete'][$row_no] .= PMA_getDeleteLink( + $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' - || $_SESSION['tmp_user_values']['disp_direction'] == 'horizontalflipped') - ? "\n" - : ''); + $table_body_html .= $directionCondition ? "\n" : ''; $row_no++; + } // end while - - // this is needed by PMA_displayTable() to generate the proper param - // in the multi-edit and multi-delete form - return $clause_is_unique; -} // end of the 'PMA_displayTableBody()' function + + return $table_body_html; + +} // end of the 'PMA_getTableBody()' function /** - * Do display the result table with the vertical direction mode. - * - * @return boolean always true - * - * @global array $vertical_display the information to display - * - * @access private - * - * @see PMA_displayTable() + * Get url sql query without conditions to shorten URLs + * + * @param array $analyzed_sql analyzed query + * @param string $sql_query the SQL query + * + * @return string $url_sql analyzed sql query + * + * @see PMA_getTableBody() */ -function PMA_displayVerticalTable() +function PMA_getUrlSqlQuery($analyzed_sql, $sql_query) { - global $vertical_display; - - // Displays "multi row delete" link at top if required - if ($GLOBALS['cfg']['RowActionLinks'] != 'right' - && is_array($vertical_display['row_delete']) - && (count($vertical_display['row_delete']) > 0 - || !empty($vertical_display['textbtn'])) + + if (isset($analyzed_sql) + && isset($analyzed_sql[0]) + && isset($analyzed_sql[0]['querytype']) + && ($analyzed_sql[0]['querytype'] == 'SELECT') + && (strlen($sql_query) > 200) ) { - echo '' . "\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"; - } - echo $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); - $cell_displayed++; - } // end while - echo '' . "\n"; - } // end if - // Displays "edit" link at top if required - if (($GLOBALS['cfg']['RowActionLinks'] == 'left' - || $GLOBALS['cfg']['RowActionLinks'] == 'both') - && is_array($vertical_display['edit']) - && (count($vertical_display['edit']) > 0 - || !empty($vertical_display['textbtn'])) - ) { - echo '' . "\n"; - if (! is_array($vertical_display['row_delete'])) { - echo $vertical_display['textbtn']; + $url_sql_query = 'SELECT '; + if (isset($analyzed_sql[0]['queryflags']['distinct'])) { + $url_sql_query .= ' DISTINCT '; } - foreach ($vertical_display['edit'] as $val) { - echo $val; - } // end while - echo '' . "\n"; - } // end if - - // Displays "copy" link at top if required - if (($GLOBALS['cfg']['RowActionLinks'] == 'left' - || $GLOBALS['cfg']['RowActionLinks'] == 'both') - && is_array($vertical_display['copy']) - && (count($vertical_display['copy']) > 0 - || !empty($vertical_display['textbtn'])) - ) { - echo '' . "\n"; - if (! is_array($vertical_display['row_delete'])) { - echo $vertical_display['textbtn']; + + $url_sql_query .= $analyzed_sql[0]['select_expr_clause']; + if (!empty($analyzed_sql[0]['from_clause'])) { + $url_sql_query .= ' FROM ' . $analyzed_sql[0]['from_clause']; } - foreach ($vertical_display['copy'] as $val) { - echo $val; - } // end while - echo '' . "\n"; - } // end if + + return $url_sql_query; + } + + return $sql_query; + +} - // Displays "delete" link at top if required - if (($GLOBALS['cfg']['RowActionLinks'] == 'left' - || $GLOBALS['cfg']['RowActionLinks'] == 'both') - && is_array($vertical_display['delete']) - && (count($vertical_display['delete']) > 0 - || !empty($vertical_display['textbtn'])) - ) { - echo '' . "\n"; - if (! is_array($vertical_display['edit']) - && ! is_array($vertical_display['row_delete']) - ) { - echo $vertical_display['textbtn']; - } - foreach ($vertical_display['delete'] as $val) { - echo $val; - } // end while - echo '' . "\n"; - } // end if +/** + * Get column order and column visibility + * + * @return array 2 element array - $col_order, $col_visib + * + * @see PMA_getTableBody() + */ +function PMA_getColumnParams() +{ if (PMA_isSelect()) { - // prepare to get the column order, if available $pmatable = new PMA_Table($GLOBALS['table'], $GLOBALS['db']); $col_order = $pmatable->getUiProp(PMA_Table::PROP_COLUMN_ORDER); $col_visib = $pmatable->getUiProp(PMA_Table::PROP_COLUMN_VISIB); @@ -2322,114 +2333,935 @@ function PMA_displayVerticalTable() $col_order = false; $col_visib = false; } + + return array($col_order, $col_visib); +} - // Displays data + +/** + * Prepare vertical display mode necessay HTML stuff + * + * @param array $vertical_display informations used with vertical + * display mode + * @param integer $row_no the index of current row + * @param boolean $directionCondition the directional condition + * + * @return string $vertical_disp_html html content + * + * @see PMA_getTableBody() + */ +function PMA_getVerticalDisplaySupportSegments( + $vertical_display, $row_no, $directionCondition +) { + + $support_html = ''; + + if ((($row_no != 0) && ($_SESSION['tmp_user_values']['repeat_cells'] != 0)) + && !($row_no % $_SESSION['tmp_user_values']['repeat_cells']) + && $directionCondition + ) { + + $support_html .= '' . "\n"; + + if ($vertical_display['emptypre'] > 0) { + + $support_html .= ' ' . "\n"; + + } else if ($GLOBALS['cfg']['RowActionLinks'] == 'none') { + $support_html .= ' ' . "\n"; + } + + foreach ($vertical_display['desc'] as $val) { + $support_html .= $val; + } + + if ($vertical_display['emptyafter'] > 0) { + $support_html .= ' ' . "\n"; + } + $support_html .= '' . "\n"; + } // end if + + return $support_html; + +} + + +/** + * Get modified links + * + * @param string $db the database name + * @param string $table the table name + * @param string $where_clause the where clause of the sql + * @param boolean $clause_is_unique the unique condition of clause + * @param string $url_sql_query the analyzed sql query + * + * @return array 5 element array - $edit_url, $copy_url, + * $edit_str, $copy_str, $edit_anchor_class + * + * @see PMA_getTableBody() + */ +function PMA_getModifiedLinks( + $db, $table, $where_clause, $clause_is_unique, $url_sql_query +) { + + $_url_params = array( + 'db' => $db, + 'table' => $table, + 'where_clause' => $where_clause, + 'clause_is_unique' => $clause_is_unique, + '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_str = PMA_getIcon('b_edit.png', __('Edit')); + $copy_str = PMA_getIcon('b_insrow.png', __('Copy')); + + // Class definitions required for grid editing jQuery scripts + $edit_anchor_class = "edit_row_anchor"; + if ( $clause_is_unique == 0) { + $edit_anchor_class .= ' nonunique'; + } + + return array($edit_url, $copy_url, $edit_str, $copy_str, $edit_anchor_class); + +} + + +/** + * Get delete and kill links + * + * @param string $db the database name + * @param string $table the table name + * @param string $where_clause the where clause of the sql + * @param boolean $clause_is_unique the unique condition of clause + * @param string $url_sql_query the analyzed sql query + * @param string $goto the URL to go back in case of errors + * @param string $del_lnk the delete link of current row + * + * @return array 4 element array - $del_query, + * $del_url, $del_str, $js_conf + * + * @see PMA_getTableBody() + */ +function PMA_getDeleteAndKillLinks( + $db, $table, $where_clause, $clause_is_unique, $url_sql_query, $goto, $del_lnk +) { + + if ($del_lnk == 'dr') { // delete row case + + $_url_params = array( + 'db' => $db, + 'table' => $table, + 'sql_query' => $url_sql_query, + 'message_to_show' => __('The row has been deleted'), + 'goto' => (empty($goto) ? 'tbl_sql.php' : $goto), + ); + + $lnk_goto = 'sql.php' . PMA_generate_common_url($_url_params, 'text'); + + $del_query = 'DELETE FROM ' . PMA_backquote($db) . '.' + . PMA_backquote($table) + . ' WHERE ' . $where_clause . + ($clause_is_unique ? '' : ' LIMIT 1'); + + $_url_params = array( + 'db' => $db, + 'table' => $table, + 'sql_query' => $del_query, + 'message_to_show' => __('The row has been deleted'), + 'goto' => $lnk_goto, + ); + $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'); + + $del_str = PMA_getIcon('b_drop.png', __('Delete')); + + } elseif ($del_lnk == 'kp') { // kill process case + + $_url_params = array( + 'db' => $db, + 'table' => $table, + 'sql_query' => $url_sql_query, + 'goto' => 'main.php', + ); + + $lnk_goto = 'sql.php' + . PMA_generate_common_url( + $_url_params, 'text' + ); + + $_url_params = array( + 'db' => 'mysql', + 'sql_query' => 'KILL ' . $row[0], + 'goto' => $lnk_goto, + ); + + $del_url = 'sql.php' . PMA_generate_common_url($_url_params); + $del_query = 'KILL ' . $row[0]; + $js_conf = 'KILL ' . $row[0]; + $del_str = PMA_getIcon('b_drop.png', __('Kill')); + } + + return array($del_query, $del_url, $del_str, $js_conf); + +} + + +/** + * Prepare placed links + * + * @param string $dir the direction of links should place + * @param string $del_url the url for delete row + * @param array $is_display which elements to display + * @param integer $row_no the index of current row + * @param string $where_clause the where clause of the sql + * @param string $where_clause_html the html encoded where clause + * @param array $condition_array array of keys (primary, unique, condition) + * @param string $del_query the query for delete row + * @param string $dir_letter the letter denoted the direction + * @param string $edit_url the url for edit row + * @param string $copy_url the url for copy row + * @param string $edit_anchor_class the class for html element for edit + * @param string $edit_str the label for edit row + * @param string $copy_str the label for copy row + * @param string $del_str the label for delete row + * @param string $js_conf text for the JS confirmation + * + * @return string html content + * + * @see PMA_getTableBody() + */ +function PMA_getPlacedLinks( + $dir, $del_url, $is_display, $row_no, $where_clause, $where_clause_html, + $condition_array, $del_query, $dir_letter, $edit_url, $copy_url, + $edit_anchor_class, $edit_str, $copy_str, $del_str, $js_conf +) { + + if (! isset($js_conf)) { + $js_conf = ''; + } + + return PMA_getCheckboxAndLinks( + $dir, $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 + ); + +} + + +/** + * Get resetted class for inline edit columns + * + * @param string $grid_edit_class the class for all editable columns + * @param string $not_null_class the class for not null columns + * @param string $relation_class the class for relations in a column + * @param string $hide_class the class for visibility of a column + * @param string $field_type_class the class related to type of the field + * @param integer $row_no the row index + * + * @return string $class the resetted class + * + * @see PMA_getTableBody() + */ +function PMA_getResettedClassForInlineEdit( + $grid_edit_class, $not_null_class, $relation_class, + $hide_class, $field_type_class, $row_no +) { + + $class = 'data ' . $grid_edit_class . ' ' . $not_null_class . ' ' + . $relation_class . ' ' . $hide_class . ' ' . $field_type_class; + + if (($_SESSION['tmp_user_values']['disp_direction'] == 'vertical') + && (! isset($GLOBALS['printview']) || ($GLOBALS['printview'] != '1')) + ) { + // the row number corresponds to a data row, not HTML table row + $class .= ' row_' . $row_no; + if ($GLOBALS['cfg']['BrowsePointerEnable'] == true) { + $class .= ' vpointer'; + } + + if ($GLOBALS['cfg']['BrowseMarkerEnable'] == true) { + $class .= ' vmarker'; + } + } + + return $class; + +} + + +/** + * Get class for datetime related fields + * + * @param string $type the type of the column field + * + * @return string $field_type_class the class for the column + * + * @see PMA_getTableBody() + */ +function PMA_getClassForDateTimeRelatedFields($type) +{ + if ((substr($type, 0, 9) == 'timestamp') || ($type == 'datetime')) { + $field_type_class = 'datetimefield'; + } else if ($type == 'date') { + $field_type_class = 'datefield'; + } else { + $field_type_class = ''; + } + return $field_type_class; +} + + +/** + * Prepare data cell for numeric type fields + * + * @param string $column the relavent column in data row + * @param string $class the html class for column + * @param boolean $condition_field the column should highlighted or not + * @param object $meta the meta-information about this field + * @param array $map the list of relations + * @param boolean $is_field_truncated the condition for blob data replacements + * @param array $analyzed_sql the analyzed query + * @param string $transform_function the name of transformation function + * @param string $default_function the default transformation function + * @param string $transform_options the transformation parameters + * + * @return string $cell the prepared cell, html content + * + * @see PMA_getTableBody() + */ +function PMA_getDataCellForNumericFeilds( + $column, $class, $condition_field, $meta, $map, $is_field_truncated, + $analyzed_sql, $transform_function, $default_function, $transform_options +) { + + if (! isset($column) || is_null($column)) { + + $cell = PMA_buildNullDisplay( + 'right '.$class, $condition_field, $meta, '' + ); + + } elseif ($column != '') { + + $nowrap = ' nowrap'; + $where_comparison = ' = ' . $column; + + $cell = '' . "\n"; + if ($GLOBALS['cfg']['RowActionLinks'] == 'none') { + // if we are not showing the RowActionLinks, then we need to show + // the Multi-Row-Action checkboxes + $vertical_table_html .= '' . "\n"; + } + + $vertical_table_html .= $vertical_display['textbtn'] + . PMA_getCheckBoxesForMultipleRowOperations( + $vertical_display, '_left' + ) + . '' . "\n"; + } // end if + + // Prepares "edit" link at top if required + if ((($GLOBALS['cfg']['RowActionLinks'] == 'left') + || ($GLOBALS['cfg']['RowActionLinks'] == 'both')) + && is_array($vertical_display['edit']) + && ((count($vertical_display['edit']) > 0) + || !empty($vertical_display['textbtn'])) + ) { + $vertical_table_html .= PMA_getOperationLinksForVerticleTable( + $vertical_display ,'edit' + ); + } // end if + + // Prepares "copy" link at top if required + if ((($GLOBALS['cfg']['RowActionLinks'] == 'left') + || ($GLOBALS['cfg']['RowActionLinks'] == 'both')) + && is_array($vertical_display['copy']) + && ((count($vertical_display['copy']) > 0) + || !empty($vertical_display['textbtn'])) + ) { + $vertical_table_html .= PMA_getOperationLinksForVerticleTable( + $vertical_display ,'copy' + ); + } // end if + + // Prepares "delete" link at top if required + if ((($GLOBALS['cfg']['RowActionLinks'] == 'left') + || ($GLOBALS['cfg']['RowActionLinks'] == 'both')) + && is_array($vertical_display['delete']) + && ((count($vertical_display['delete']) > 0) + || !empty($vertical_display['textbtn'])) + ) { + $vertical_table_html .= PMA_getOperationLinksForVerticleTable( + $vertical_display, 'delete' + ); + } // end if + + list($col_order, $col_visib) = PMA_getColumnParams(); + + // Prepares data foreach ($vertical_display['desc'] AS $j => $val) { + // 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) { + if (($cell_displayed != 0) && ($_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 - if (($GLOBALS['cfg']['RowActionLinks'] == 'right' - || $GLOBALS['cfg']['RowActionLinks'] == 'both') + // Prepares "multi row delete" link at bottom if required + if ((($GLOBALS['cfg']['RowActionLinks'] == 'right') + || ($GLOBALS['cfg']['RowActionLinks'] == 'both')) && is_array($vertical_display['row_delete']) - && (count($vertical_display['row_delete']) > 0 + && ((count($vertical_display['row_delete']) > 0) || !empty($vertical_display['textbtn'])) ) { - echo '' . "\n"; - echo $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); - $cell_displayed++; - } // end while - echo '' . "\n"; + + $vertical_table_html .= '' . "\n" . $vertical_display['textbtn'] + . PMA_getCheckBoxesForMultipleRowOperations( + $vertical_display, '_right' + ) + . '' . "\n"; } // end if - // Displays "edit" link at bottom if required - if (($GLOBALS['cfg']['RowActionLinks'] == 'right' - || $GLOBALS['cfg']['RowActionLinks'] == 'both') + // Prepares "edit" link at bottom if required + if ((($GLOBALS['cfg']['RowActionLinks'] == 'right') + || ($GLOBALS['cfg']['RowActionLinks'] == 'both')) && is_array($vertical_display['edit']) - && (count($vertical_display['edit']) > 0 + && ((count($vertical_display['edit']) > 0) || !empty($vertical_display['textbtn'])) ) { - echo '' . "\n"; - if (! is_array($vertical_display['row_delete'])) { - echo $vertical_display['textbtn']; - } - foreach ($vertical_display['edit'] as $val) { - echo $val; - } // end while - echo '' . "\n"; + $vertical_table_html .= PMA_getOperationLinksForVerticleTable( + $vertical_display, 'edit' + ); } // end if - // Displays "copy" link at bottom if required - if (($GLOBALS['cfg']['RowActionLinks'] == 'right' - || $GLOBALS['cfg']['RowActionLinks'] == 'both') + // Prepares "copy" link at bottom if required + if ((($GLOBALS['cfg']['RowActionLinks'] == 'right') + || ($GLOBALS['cfg']['RowActionLinks'] == 'both')) && is_array($vertical_display['copy']) - && (count($vertical_display['copy']) > 0 + && ((count($vertical_display['copy']) > 0) || !empty($vertical_display['textbtn'])) ) { - echo '' . "\n"; - if (! is_array($vertical_display['row_delete'])) { - echo $vertical_display['textbtn']; - } - foreach ($vertical_display['copy'] as $val) { - echo $val; - } // end while - echo '' . "\n"; + $vertical_table_html .= PMA_getOperationLinksForVerticleTable( + $vertical_display, 'copy' + ); } // end if - // Displays "delete" link at bottom if required - if (($GLOBALS['cfg']['RowActionLinks'] == 'right' - || $GLOBALS['cfg']['RowActionLinks'] == 'both') + // Prepares "delete" link at bottom if required + if ((($GLOBALS['cfg']['RowActionLinks'] == 'right') + || ($GLOBALS['cfg']['RowActionLinks'] == 'both')) && is_array($vertical_display['delete']) - && (count($vertical_display['delete']) > 0 + && ((count($vertical_display['delete']) > 0) || !empty($vertical_display['textbtn'])) ) { - echo '' . "\n"; - if (! is_array($vertical_display['edit']) - && ! is_array($vertical_display['row_delete']) - ) { - echo $vertical_display['textbtn']; - } - foreach ($vertical_display['delete'] as $val) { - echo $val; - } // end while - echo '' . "\n"; + $vertical_table_html .= PMA_getOperationLinksForVerticleTable( + $vertical_display, 'delete' + ); } - return true; -} // end of the 'PMA_displayVerticalTable' function + return $vertical_table_html; + +} // end of the 'PMA_getVerticalTable' function + + +/** + * Prepare edit, copy and delete links for verticle table + * + * @param array $vertical_display the information to display + * @param string $operation edit/copy/delete + * + * @return string $links_html html content + * + * @see PMA_getVerticalTable() + */ +function PMA_getOperationLinksForVerticleTable($vertical_display, $operation) +{ + + $link_html = '' . "\n"; + + if (! is_array($vertical_display['row_delete'])) { + + if (($operation == 'edit') || ($operation == 'copy')) { + $link_html .= $vertical_display['textbtn']; + + } elseif ($operation == 'delete') { + + if (! is_array($vertical_display['edit'])) { + $link_html .= $vertical_display['textbtn']; + } + } + } + + foreach ($vertical_display[$operation] as $val) { + $link_html .= $val; + } // end while + + $link_html .= '' . "\n"; + + return $link_html; + +} + + +/** + * Get checkboxes for multiple row data operations + * + * @param array $vertical_display the information to display + * @param string $dir _left / _right + * + * @return $checkBoxes_html html content + * + * @see PMA_getVerticalTable() + */ +function PMA_getCheckBoxesForMultipleRowOperations($vertical_display, $dir) { + + $checkBoxes_html = ''; + $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']) + ) { + + $checkBoxes_html .= '' . "\n"; + + } + + $checkBoxes_html .= str_replace('[%_PMA_CHECKBOX_DIR_%]', $dir, $val); + $cell_displayed++; + } // end while + + return $checkBoxes_html; + +} + /** * Checks the posted options for viewing query resutls @@ -2442,16 +3274,18 @@ 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']; @@ -2473,8 +3307,8 @@ function PMA_displayTable_checkConfigParams() // as this is a form value, the type is always string so we cannot // use PMA_isValid($_REQUEST['session_max_rows'], 'integer') if ((PMA_isValid($_REQUEST['session_max_rows'], 'numeric') - && (int) $_REQUEST['session_max_rows'] == $_REQUEST['session_max_rows']) - || $_REQUEST['session_max_rows'] == 'all' + && ((int) $_REQUEST['session_max_rows'] == $_REQUEST['session_max_rows'])) + || ($_REQUEST['session_max_rows'] == 'all') ) { $_SESSION['tmp_user_values']['query'][$sql_md5]['max_rows'] = $_REQUEST['session_max_rows']; @@ -2542,7 +3376,7 @@ function PMA_displayTable_checkConfigParams() } else { // display_binary_as_hex config option if (isset($GLOBALS['cfg']['DisplayBinaryAsHex']) - && true === $GLOBALS['cfg']['DisplayBinaryAsHex'] + && ($GLOBALS['cfg']['DisplayBinaryAsHex'] === true) ) { $_SESSION['tmp_user_values']['query'][$sql_md5]['display_binary_as_hex'] = true; @@ -2610,16 +3444,20 @@ function PMA_displayTable_checkConfigParams() = $_SESSION['tmp_user_values']['query'][$sql_md5]['repeat_cells']; $_SESSION['tmp_user_values']['disp_direction'] = $_SESSION['tmp_user_values']['query'][$sql_md5]['disp_direction']; + } + /** - * 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 @@ -2641,22 +3479,25 @@ 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_getTableBody(), 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 @@ -2668,15 +3509,15 @@ function PMA_displayTable(&$dt_result, &$the_disp_mode, $analyzed_sql) && ! isset($analyzed_sql[0]['queryflags']['union']) && ! isset($analyzed_sql[0]['table_ref'][1]['table_name']) && (empty($analyzed_sql[0]['where_clause']) - || $analyzed_sql[0]['where_clause'] == '1 ') + || ($analyzed_sql[0]['where_clause'] == '1 ')) ) { // "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 = ''; @@ -2691,189 +3532,50 @@ function PMA_displayTable(&$dt_result, &$the_disp_mode, $analyzed_sql) // 1.2 Defines offsets for the next and previous pages if ($is_display['nav_bar'] == '1') { - if ($_SESSION['tmp_user_values']['max_rows'] == 'all') { - $pos_next = 0; - $pos_prev = 0; - } else { - $pos_next = $_SESSION['tmp_user_values']['pos'] - + $_SESSION['tmp_user_values']['max_rows']; - $pos_prev = $_SESSION['tmp_user_values']['pos'] - - $_SESSION['tmp_user_values']['max_rows']; - if ($pos_prev < 0) { - $pos_prev = 0; - } - } + list($pos_next, $pos_prev) = PMA_getOffsets(); } // end if // 1.3 Find the sort expression - // we need $sort_expression and $sort_expression_nodirection - // 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']) - ); - /** - * Get rid of ASC|DESC - */ - preg_match('@(.*)([[:space:]]*(ASC|DESC))@si', $sort_expression, $matches); - $sort_expression_nodirection = isset($matches[1]) - ? trim($matches[1]) - : $sort_expression; - $sort_direction = isset($matches[2]) ? trim($matches[2]) : ''; - unset($matches); - } else { - $sort_expression = $sort_expression_nodirection = $sort_direction = ''; - } - + // even if there are many table references + list($sort_expression, $sort_expression_nodirection, $sort_direction) + = PMA_getSortParams($analyzed_sql[0]['order_by_clause']); + + // 1.4 Prepares display of first and last value of the sorted column - if (! empty($sort_expression_nodirection)) { - if (strpos($sort_expression_nodirection, '.') === false) { - $sort_table = $table; - $sort_column = $sort_expression_nodirection; - } else { - list($sort_table, $sort_column) - = explode('.', $sort_expression_nodirection); - } - $sort_table = PMA_unQuote($sort_table); - $sort_column = PMA_unQuote($sort_column); - // find the sorted column index in row result - // (this might be a multi-table query) - $sorted_column_index = false; - foreach ($fields_meta as $key => $meta) { - if ($meta->table == $sort_table && $meta->name == $sort_column) { - $sorted_column_index = $key; - break; - } - } - if ($sorted_column_index !== false) { - // fetch first row of the result set - $row = PMA_DBI_fetch_row($dt_result); - // initializing default arguments - $default_function = 'PMA_mimeDefaultFunction'; - $transform_function = $default_function; - $transform_options = array(); - // 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 - ); - } else { - $column_for_first_row = $row[$sorted_column_index]; - } - $column_for_first_row = strtoupper( - 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 - ); - } 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() - PMA_DBI_data_seek($dt_result, 0); - // we could also use here $sort_expression_nodirection - $sorted_column_message = ' [' . htmlspecialchars($sort_column) - . ': ' . htmlspecialchars($column_for_first_row) . ' - ' - . htmlspecialchars($column_for_last_row) . ']'; - unset($row, $column_for_first_row, $column_for_last_row, $meta, - $default_function, $transform_function, $transform_options); - } - unset($sorted_column_index, $sort_table, $sort_column); - } - - // 2. ----- Displays the top of the page ----- - - // 2.1 Displays 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'); - } else { - $selectstring = ''; - } - - if (! empty($analyzed_sql[0]['limit_clause'])) { - $limit_data = PMA_analyzeLimitClause($analyzed_sql[0]['limit_clause']); - $first_shown_rec = $limit_data['start']; - if ($limit_data['length'] < $total) { - $last_shown_rec = $limit_data['start'] + $limit_data['length'] - 1; - } else { - $last_shown_rec = $limit_data['start'] + $total - 1; - } - } elseif ($_SESSION['tmp_user_values']['max_rows'] == 'all' - || $pos_next > $total) { - $first_shown_rec = $_SESSION['tmp_user_values']['pos']; - $last_shown_rec = $total - 1; - } else { - $first_shown_rec = $_SESSION['tmp_user_values']['pos']; - $last_shown_rec = $pos_next - 1; - } - - if (PMA_Table::isView($db, $table) - && $total == $GLOBALS['cfg']['MaxExactCountViews'] - ) { - $message = PMA_Message::notice( - __('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); - } else { - $message_view_warning = false; - } - - $message = PMA_Message::success(__('Showing rows')); - $message->addMessage($first_shown_rec); - if ($message_view_warning) { - $message->addMessage('...', ' - '); - $message->addMessage($message_view_warning); - $message->addMessage('('); - } else { - $message->addMessage($last_shown_rec, ' - '); - $message->addMessage(' ('); - $message->addMessage($pre_count . PMA_formatNumber($total, 0)); - $message->addString(__('total')); - if (!empty($after_count)) { - $message->addMessage($after_count); - } - $message->addMessage($selectstring, ''); - $message->addMessage(', ', ''); - } - - $messagge_qt = PMA_Message::notice(__('Query took %01.4f sec') . ')'); - $messagge_qt->addParam($GLOBALS['querytime']); - - $message->addMessage($messagge_qt, ''); - if (isset($sorted_column_message)) { - $message->addMessage($sorted_column_message, ''); - } - - PMA_showMessage($message, $sql_query, 'success'); - - } elseif (! isset($GLOBALS['printview']) || $GLOBALS['printview'] != '1') { - PMA_showMessage( - __('Your SQL query has been executed successfully'), - $sql_query, 'success' + $sorted_column_message = PMA_getSortedColumnMessage( + $dt_result, $fields_meta, $num_rows, + $sort_expression_nodirection, $table ); + + + // 2. ----- Prepare to display the top of the page ----- + + // 2.1 Prepares a messages with position informations + if (($is_display['nav_bar'] == '1') && isset($pos_next)) { + + $message = PMA_setMessageInformation( + $db, $table, $sorted_column_message, + $analyzed_sql[0]['limit_clause'], $unlim_num_rows, + $total, $pos_next, $pre_count, $after_count + ); + + $table_html .= PMA_getMessage($message, $sql_query, 'success'); + + } elseif (! isset($GLOBALS['printview']) || ($GLOBALS['printview'] != '1')) { + + $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' + && ($analyzed_sql[0]['query_type'] == 'SELECT') ) { // table does not always contain a real table name, // for example in MySQL 5.0.x, the query SHOW STATUS @@ -2882,15 +3584,18 @@ function PMA_displayTable(&$dt_result, &$the_disp_mode, $analyzed_sql) } else { $table = ''; } + } - 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"; - } elseif (! isset($GLOBALS['printview']) || $GLOBALS['printview'] != '1') { - echo "\n" . '

' . "\n"; + if (($is_display['nav_bar'] == '1') && empty($analyzed_sql[0]['limit_clause'])) { + + $table_html .= PMA_getTableNavigation( + $pos_next, $pos_prev, $sql_query, 'top_direction_dropdown' + ) + . "\n"; + + } elseif (! isset($GLOBALS['printview']) || ($GLOBALS['printview'] != '1')) { + $table_html .= "\n" . '

' . "\n"; } // 2b ----- Get field references from Database ----- @@ -2904,16 +3609,20 @@ function PMA_displayTable(&$dt_result, &$the_disp_mode, $analyzed_sql) if (isset($analyzed_sql[0]['table_ref']) && is_array($analyzed_sql[0]['table_ref']) ) { + foreach ($analyzed_sql[0]['table_ref'] as $table_ref_position => $table_ref) { $target[] = $analyzed_sql[0]['table_ref'][$table_ref_position]['table_true_name']; } + } + $tabs = '(\'' . join('\',\'', $target) . '\')'; if (! strlen($table)) { $exist_rel = false; } else { + // To be able to later display a link to the related table, // we verify both types of relations: either those that are // native foreign keys or those defined in the phpMyAdmin @@ -2921,133 +3630,495 @@ function PMA_displayTable(&$dt_result, &$the_disp_mode, $analyzed_sql) // to use the "column to display" notion (for example show // the name related to a numeric id). $exist_rel = PMA_getForeigners($db, $table, '', 'both'); + 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 = ''; + $table_html .= PMA_getTableBody( + $dt_result, $is_display, $map, $analyzed_sql + ); + // vertical output case if ($_SESSION['tmp_user_values']['disp_direction'] == 'vertical') { - PMA_displayVerticalTable(); + $table_html .= PMA_getVerticalTable(); } // end if + unset($vertical_display); - echo '' . "\n"; - ?> -
NULLNULL
' - . "\n".'  ' - . "\n" . '  
only if the display dir is not vertical - && $_SESSION['tmp_user_values']['disp_direction'] != 'vertical') + && ($_SESSION['tmp_user_values']['disp_direction'] != 'vertical')) ? 'hide' : ''; + // handle datetime-related class, for grid editing - if (substr($meta->type, 0, 9) == 'timestamp' - || $meta->type == 'datetime' - ) { - $field_type_class = 'datetimefield'; - } else if ($meta->type == 'date') { - $field_type_class = 'datefield'; - } else { - $field_type_class = ''; - } + $field_type_class = PMA_getClassForDateTimeRelatedFields($meta->type); + $pointer = $i; $is_field_truncated = false; //If the previous column had blob data, we need to reset the class // to $inline_edit_class - $class = 'data ' . $grid_edit_class . ' ' . $not_null_class . ' ' - . $relation_class . ' ' . $hide_class . ' ' . $field_type_class; - //' ' . $alternating_color_class . + $class = PMA_getResettedClassForInlineEdit( + $grid_edit_class, $not_null_class, $relation_class, + $hide_class, $field_type_class, $row_no + ); // See if this column should get highlight because it's used in the // where-query. - if (isset($highlight_columns) + $condition_field = (isset($highlight_columns) && (isset($highlight_columns[$meta->name]) - || isset($highlight_columns[PMA_backquote($meta->name)])) - ) { - $condition_field = true; - } else { - $condition_field = false; - } - - if ($_SESSION['tmp_user_values']['disp_direction'] == 'vertical' - && (! isset($GLOBALS['printview']) || ($GLOBALS['printview'] != '1')) - ) { - // the row number corresponds to a data row, not HTML table row - $class .= ' row_' . $row_no; - if ($GLOBALS['cfg']['BrowsePointerEnable'] == true) { - $class .= ' vpointer'; - } - if ($GLOBALS['cfg']['BrowseMarkerEnable'] == true) { - $class .= ' vmarker'; - } - }// end if + || isset($highlight_columns[PMA_backquote($meta->name)]))) + ? true + : false; // Wrap MIME-transformations. [MIME] $default_function = 'PMA_mimeDefaultFunction'; // default_function @@ -1779,33 +2057,40 @@ function PMA_displayTableBody(&$dt_result, &$is_display, $map, $analyzed_sql) if ($GLOBALS['cfgRelation']['mimework'] && $GLOBALS['cfg']['BrowseMIME'] ) { + if (isset($GLOBALS['mime_map'][$meta->name]['mimetype']) && isset($GLOBALS['mime_map'][$meta->name]['transformation']) && !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; if (function_exists('PMA_transformation_' . $transformfunction_name)) { + $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 @@ -1822,8 +2107,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) { @@ -1832,280 +2116,58 @@ function PMA_displayTableBody(&$dt_result, &$is_display, $map, $analyzed_sql) // with self-join queries, for example), using $meta->name // will show both fields NULL even if only one is NULL, // so use the $pointer - - if (! isset($row[$i]) || is_null($row[$i])) { - $vertical_display['data'][$row_no][$i] = PMA_buildNullDisplay( - 'right '.$class, $condition_field, $meta, '' + + $vertical_display['data'][$row_no][$i] + = PMA_getDataCellForNumericFeilds( + $row[$i], $class, $condition_field, $meta, + $analyzed_sql, $transform_function, $map, + $default_function, $transform_options, $is_field_truncated ); - } elseif ($row[$i] != '') { - - $nowrap = ' nowrap'; - $where_comparison = ' = ' . $row[$i]; - - $vertical_display['data'][$row_no][$i] = 'type, 'BLOB')) { + // PMA_mysql_fetch_fields returns BLOB in place of // TEXT fields type so we have to ensure it's really a BLOB $field_flags = PMA_DBI_field_flags($dt_result, $i); - - if (stristr($field_flags, 'BINARY')) { - // remove 'grid_edit' from $class as we can't edit binary data. - $class = str_replace('grid_edit', '', $class); - - if (! isset($row[$i]) || is_null($row[$i])) { - $vertical_display['data'][$row_no][$i] - = 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 - ); - - $vertical_display['data'][$row_no][$i] = PMA_buildValueDisplay( - $class, $condition_field, $blobtext - ); - unset($blobtext); - } - // not binary: - } else { - if (! isset($row[$i]) || is_null($row[$i])) { - $vertical_display['data'][$row_no][$i] - = PMA_buildNullDisplay($class, $condition_field, $meta); - } elseif ($row[$i] != '') { - // if a transform function for blob is set, none of these - // replacements will be made - 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'] - ) . '...'; - $is_field_truncated = true; - } - // displays all space characters, 4 space - // characters for tabulations and / - $row[$i] = $default_function != $transform_function - ? $transform_function($row[$i], $transform_options, $meta) - : $default_function($row[$i], array(), $meta); - - if ($is_field_truncated) { - $class .= ' truncated'; - } - - $vertical_display['data'][$row_no][$i] = PMA_buildValueDisplay( - $class, $condition_field, $row[$i] - ); - } else { - $vertical_display['data'][$row_no][$i] - = PMA_buildEmptyDisplay($class, $condition_field, $meta); - } - } + + $vertical_display['data'][$row_no][$i] + = PMA_getDataCellForBlobField( + $row[$i], $class, $meta, $_url_params, $field_flags, + $transform_function, $default_function, + $transform_options, $condition_field, $is_field_truncated + ); + // g e o m e t r y } elseif ($meta->type == 'geometry') { // Remove 'grid_edit' from $class as we do not allow to inline-edit // geometry data. $class = str_replace('grid_edit', '', $class); - - if (! isset($row[$i]) || is_null($row[$i])) { - $vertical_display['data'][$row_no][$i] - = PMA_buildNullDisplay($class, $condition_field, $meta); - } elseif ($row[$i] != '') { - // 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 - ); - $vertical_display['data'][$row_no][$i] = PMA_buildValueDisplay( - $class, $condition_field, $geometry_text - ); - - // Display in Well Known Text(WKT) format. - } elseif ('WKT' == $_SESSION['tmp_user_values']['geometry_display']) { - $where_comparison = ' = ' . $row[$i]; - - // Convert to WKT format - $wktval = PMA_asWKT($row[$i]); - - if (PMA_strlen($wktval) > $GLOBALS['cfg']['LimitChars'] - && $_SESSION['tmp_user_values']['display_text'] == 'P' - ) { - $wktval = PMA_substr( - $wktval, 0, $GLOBALS['cfg']['LimitChars'] - ) . '...'; - $is_field_truncated = true; - } - - $vertical_display['data'][$row_no][$i] = ' $GLOBALS['cfg']['LimitChars'] - && $_SESSION['tmp_user_values']['display_text'] == 'P' - ) { - $wkbval = PMA_substr( - $wkbval, 0, $GLOBALS['cfg']['LimitChars'] - ) . '...'; - $is_field_truncated = true; - } - - $vertical_display['data'][$row_no][$i] = ' $GLOBALS['cfg']['LimitChars'] - && $_SESSION['tmp_user_values']['display_text'] == 'P' - && !strpos($transform_function, 'link') === true - ) { - $row[$i] = PMA_substr( - $row[$i], 0, $GLOBALS['cfg']['LimitChars'] - ) . '...'; - $is_field_truncated = true; - } - - // displays special characters from binaries - $field_flags = PMA_DBI_field_flags($dt_result, $i); - $formatted = false; - if (isset($meta->_type) && $meta->_type === MYSQLI_TYPE_BIT) { - $row[$i] = PMA_printableBitValue( - $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 - } elseif (stristr($field_flags, 'BINARY') - && $meta->type == 'string' - && !(isset($GLOBALS['is_analyse']) && $GLOBALS['is_analyse']) - ) { - if ($_SESSION['tmp_user_values']['display_binary']) { - // user asked to see the real contents of BINARY - // fields - if ($_SESSION['tmp_user_values']['display_binary_as_hex'] - && PMA_containsNonPrintableAscii($row[$i]) - ) { - $row[$i] = bin2hex($row[$i]); - } else { - $row[$i] = htmlspecialchars( - PMA_replaceBinaryContents($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 - ); - $formatted = true; - } - } - - if ($formatted) { - $vertical_display['data'][$row_no][$i] = PMA_buildValueDisplay( - $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_nowrap($transform_options) - : false); - - // do not wrap if date field type - $nowrap = ((preg_match('@DATE|TIME@i', $meta->type) - || $bool_nowrap) - ? ' nowrap' - : ''); - $where_comparison = ' = \'' . PMA_sqlAddSlashes($row[$i]) - . '\''; - $vertical_display['data'][$row_no][$i] = ' -
' + . "\n".'  ' + . "\n" . '  
$GLOBALS['cfg']['LimitChars']) + && ($_SESSION['tmp_user_values']['display_text'] == 'P') + ) { + $column = PMA_substr($column, 0, $GLOBALS['cfg']['LimitChars']) + . '...'; + $is_field_truncated = true; + } + + // displays all space characters, 4 space + // characters for tabulations and / + $column = ($default_function != $transform_function) + ? $transform_function($column, $transform_options, $meta) + : $default_function($column, array(), $meta); + + if ($is_field_truncated) { + $class .= ' truncated'; + } + + $cell = PMA_buildValueDisplay($class, $condition_field, $column); + + } else { + $cell = PMA_buildEmptyDisplay($class, $condition_field, $meta); + } + } + + return $cell; + +} + + +/** + * Get data cell for geometry type fields + * + * @param string $column the relavent column in data row + * @param string $class the html class for column + * @param object $meta the meta-information about this field + * @param array $map the list of relations + * @param array $_url_params the parameters for generate url + * @param boolean $condition_field the column should highlighted or not + * @param string $transform_function the name of transformation function + * @param string $default_function the default transformation function + * @param string $transform_options the transformation parameters + * @param boolean $is_field_truncated the condition for blob data replacements + * @param array $analyzed_sql the analyzed query + * + * @return string $cell the prepared data cell, html content + * + * @see PMA_getTableBody() + */ +function PMA_getDataCellForGeometryFields( + $column, $class, $meta, $map, $_url_params, $condition_field, + $transform_function, $default_function, $transform_options, + $is_field_truncated, $analyzed_sql +) { + + if (! isset($column) || is_null($column)) { + + $cell = PMA_buildNullDisplay($class, $condition_field, $meta); + + } elseif ($column != '') { + + // Display as [GEOMETRY - (size)] + if ($_SESSION['tmp_user_values']['geometry_display'] == 'GEOM') { + + $geometry_text = PMA_handleNonPrintableContents( + 'GEOMETRY', (isset($column) ? $column : ''), + $transform_function, $transform_options, + $default_function, $meta + ); + + $cell = PMA_buildValueDisplay( + $class, $condition_field, $geometry_text + ); + + // Prepare in Well Known Text(WKT) format. + } elseif ($_SESSION['tmp_user_values']['geometry_display'] == 'WKT') { + + $where_comparison = ' = ' . $column; + + // Convert to WKT format + $wktval = PMA_asWKT($column); + + if ((PMA_strlen($wktval) > $GLOBALS['cfg']['LimitChars']) + && ($_SESSION['tmp_user_values']['display_text'] == 'P') + ) { + $wktval = PMA_substr($wktval, 0, $GLOBALS['cfg']['LimitChars']) + . '...'; + $is_field_truncated = true; + } + + $cell = ' $GLOBALS['cfg']['LimitChars']) + && ($_SESSION['tmp_user_values']['display_text'] == 'P') + ) { + $wkbval = PMA_substr($wkbval, 0, $GLOBALS['cfg']['LimitChars']) + . '...'; + $is_field_truncated = true; + } + + $cell = ' $GLOBALS['cfg']['LimitChars'] + && ($_SESSION['tmp_user_values']['display_text'] == 'P') + && !strpos($transform_function, 'link') === true + ) { + $column = PMA_substr($column, 0, $GLOBALS['cfg']['LimitChars']) + . '...'; + $is_field_truncated = true; + } + + // displays special characters from binaries + $field_flags = PMA_DBI_field_flags($dt_result, $col_index); + $formatted = false; + + if (isset($meta->_type) && $meta->_type === MYSQLI_TYPE_BIT) { + + $column = PMA_printableBitValue( + $column, $meta->length + ); + + // some results of PROCEDURE ANALYSE() are reported as + // being BINARY but they are quite readable, + // so don't treat them as BINARY + } elseif (stristr($field_flags, 'BINARY') + && ($meta->type == 'string') + && !(isset($GLOBALS['is_analyse']) && $GLOBALS['is_analyse']) + ) { + + if ($_SESSION['tmp_user_values']['display_binary']) { + + // user asked to see the real contents of BINARY + // fields + if ($_SESSION['tmp_user_values']['display_binary_as_hex'] + && PMA_containsNonPrintableAscii($column) + ) { + $column = bin2hex($column); + } else { + $column = htmlspecialchars( + PMA_replaceBinaryContents($column) + ); + } + + } else { + // we show the BINARY message and field's size + // (or maybe use a transformation) + $column = PMA_handleNonPrintableContents( + 'BINARY', $column, $transform_function, + $transform_options, $default_function, + $meta, $_url_params + ); + $formatted = true; + } + } + + if ($formatted) { + + $cell = PMA_buildValueDisplay( + $class, $condition_field, $column + ); + + } else { + + // transform functions may enable no-wrapping: + $function_nowrap = $transform_function . '_nowrap'; + + $bool_nowrap = (($default_function != $transform_function) + && 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) ? ' nowrap' : ''; + + $where_comparison = ' = \'' . PMA_sqlAddSlashes($column) + . '\''; + + $cell = ' 0) + || !empty($vertical_display['textbtn'])) + ) { + + $vertical_table_html .= '
- - ' . "\n" + . ''; + + // 4. ----- Prepares the link for multi-fields edit and delete if ($is_display['del_lnk'] == 'dr' && $is_display['del_lnk'] != 'kp') { - $delete_text = $is_display['del_lnk'] == 'dr' ? __('Delete') : __('Kill'); + $table_html .= PMA_getMultiRowOperationLinks( + $dt_result, $fields_cnt, $fields_meta, $num_rows, $analyzed_sql, + $db, $table, $sql_query, $goto, $is_display['del_lnk'] + ); - $_url_params = array( - 'db' => $db, - 'table' => $table, - 'sql_query' => $sql_query, - 'goto' => $goto, - ); - $uncheckall_url = 'sql.php' . PMA_generate_common_url($_url_params); + } - $_url_params['checkall'] = '1'; - $checkall_url = 'sql.php' . PMA_generate_common_url($_url_params); + // 5. ----- Get the navigation bar at the bottom if required ----- - if ($_SESSION['tmp_user_values']['disp_direction'] == 'vertical') { - $checkall_params['onclick'] - = 'if (setCheckboxes(\'resultsForm\', true)) return false;'; - $uncheckall_params['onclick'] - = 'if (setCheckboxes(\'resultsForm\', false)) return false;'; - } else { - $checkall_params['onclick'] - = 'if (markAllRows(\'resultsForm\')) return false;'; - $uncheckall_params['onclick'] - = 'if (unMarkAllRows(\'resultsForm\')) return false;'; + if ($is_display['nav_bar'] == '1' && empty($analyzed_sql[0]['limit_clause'])) { + + $table_html .= '
' . "\n"; + $table_html .= PMA_getTableNavigation( + $pos_next, $pos_prev, $sql_query, 'bottom_direction_dropdown' + ); + + } elseif (! isset($GLOBALS['printview']) || $GLOBALS['printview'] != '1') { + $table_html .= "\n" . '

' . "\n"; + } + + // 6. ----- Prepare "Query results operations" + if (! isset($GLOBALS['printview']) || $GLOBALS['printview'] != '1') { + $table_html .= PMA_getResultsOperations($the_disp_mode, $analyzed_sql); + } + + return $table_html; + +} // end of the 'PMA_getTable()' function + + +/** + * Get offsets for next page and previous page + * + * @return array array with two elements - $pos_next, $pos_prev + * + * @see PMA_getTable() + */ +function PMA_getOffsets() +{ + + if ($_SESSION['tmp_user_values']['max_rows'] == 'all') { + $pos_next = 0; + $pos_prev = 0; + } else { + + $pos_next = $_SESSION['tmp_user_values']['pos'] + + $_SESSION['tmp_user_values']['max_rows']; + + $pos_prev = $_SESSION['tmp_user_values']['pos'] + - $_SESSION['tmp_user_values']['max_rows']; + + if ($pos_prev < 0) { + $pos_prev = 0; } - $checkall_link = PMA_linkOrButton( + } + + return array($pos_next, $pos_prev); + +} + + +/** + * Get sort parameters + * + * @param string $order_by_clause + * + * @return array 3 element array: $sort_expression, + * $sort_expression_nodirection, $sort_direction + * + * @see PMA_getTable() + */ +function PMA_getSortParams($order_by_clause) +{ + + if (! empty($order_by_clause)) { + + $sort_expression = trim( + str_replace(' ', ' ', $order_by_clause) + ); + /** + * Get rid of ASC|DESC + */ + preg_match('@(.*)([[:space:]]*(ASC|DESC))@si', $sort_expression, $matches); + + $sort_expression_nodirection = isset($matches[1]) + ? trim($matches[1]) + : $sort_expression; + + $sort_direction = isset($matches[2]) ? trim($matches[2]) : ''; + unset($matches); + + } else { + $sort_expression = $sort_expression_nodirection = $sort_direction = ''; + } + + return array($sort_expression, $sort_expression_nodirection, $sort_direction); + +} + + +/** + * Prepare sorted column message + * + * @param integer &$dt_result the link id associated to the query + * which results have to be displayed + * @param array $fields_meta the list of fields properties + * @param integer $num_rows the total number of rows returned + * by the SQL query + * @param string $sort_expression_nodirection sort expression without direction + * @param string $table the table name + * + * @return string html content + * null if not found sorted column + * + * @see PMA_getTable() + */ +function PMA_getSortedColumnMessage(&$dt_result, $fields_meta, + $num_rows, $sort_expression_nodirection, $table +) { + + if (! empty($sort_expression_nodirection)) { + + if (strpos($sort_expression_nodirection, '.') === false) { + $sort_table = $table; + $sort_column = $sort_expression_nodirection; + } else { + list($sort_table, $sort_column) + = explode('.', $sort_expression_nodirection); + } + + $sort_table = PMA_unQuote($sort_table); + $sort_column = PMA_unQuote($sort_column); + + // find the sorted column index in row result + // (this might be a multi-table query) + $sorted_column_index = false; + + foreach ($fields_meta as $key => $meta) { + if (($meta->table == $sort_table) && ($meta->name == $sort_column)) { + $sorted_column_index = $key; + break; + } + } + + if ($sorted_column_index !== false) { + + // fetch first row of the result set + $row = PMA_DBI_fetch_row($dt_result); + + // initializing default arguments + $default_function = 'PMA_mimeDefaultFunction'; + $transform_function = $default_function; + $transform_options = array(); + + // 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_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']) + ); + + // 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_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_getTableBody() + PMA_DBI_data_seek($dt_result, 0); + + // we could also use here $sort_expression_nodirection + return ' [' . htmlspecialchars($sort_column) + . ': ' . htmlspecialchars($column_for_first_row) . ' - ' + . htmlspecialchars($column_for_last_row) . ']'; + } + } + + return null; + +} + + +/** + * Set the content need to be show in message + * + * @param string $db the database name + * @param string $table the table name + * @param string $sorted_column_message the message for sorted column + * @param string $limit_clause the limit clause of analyzed query + * @param integer $unlim_num_rows the total number of rows returned by + * the SQL query without any appended + * "LIMIT" clause programmatically + * @param integer $total the total number of rows returned by + * the SQL query without any + * programmatically appended LIMIT clause + * @param integer $pos_next the offset for next page + * @param string $pre_count the string renders before row count + * @param string $after_count the string renders after row count + * + * @return PMA_Message $message an object of PMA_Message + * + * @see PMA_getTable() + */ +function PMA_setMessageInformation( + $db, $table, $sorted_column_message, $limit_clause, $unlim_num_rows, + $total, $pos_next, $pre_count, $after_count +) { + + if (isset($unlim_num_rows) && ($unlim_num_rows != $total)) { + $selectstring = ', ' . $unlim_num_rows . ' ' . __('in query'); + } else { + $selectstring = ''; + } + + if (! empty($limit_clause)) { + + $limit_data = PMA_analyzeLimitClause($limit_clause); + $first_shown_rec = $limit_data['start']; + + if ($limit_data['length'] < $total) { + $last_shown_rec = $limit_data['start'] + $limit_data['length'] - 1; + } else { + $last_shown_rec = $limit_data['start'] + $total - 1; + } + + } elseif (($_SESSION['tmp_user_values']['max_rows'] == 'all') + || ($pos_next > $total) + ) { + + $first_shown_rec = $_SESSION['tmp_user_values']['pos']; + $last_shown_rec = $total - 1; + + } else { + + $first_shown_rec = $_SESSION['tmp_user_values']['pos']; + $last_shown_rec = $pos_next - 1; + + } + + if (PMA_Table::isView($db, $table) + && ($total == $GLOBALS['cfg']['MaxExactCountViews']) + ) { + + $message = PMA_Message::notice( + __('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); + + } else { + $message_view_warning = false; + } + + $message = PMA_Message::success(__('Showing rows')); + $message->addMessage($first_shown_rec); + + if ($message_view_warning) { + + $message->addMessage('...', ' - '); + $message->addMessage($message_view_warning); + $message->addMessage('('); + + } else { + + $message->addMessage($last_shown_rec, ' - '); + $message->addMessage(' ('); + $message->addMessage($pre_count . PMA_formatNumber($total, 0)); + $message->addString(__('total')); + + if (!empty($after_count)) { + $message->addMessage($after_count); + } + + $message->addMessage($selectstring, ''); + $message->addMessage(', ', ''); + + } + + $messagge_qt = PMA_Message::notice(__('Query took %01.4f sec') . ')'); + $messagge_qt->addParam($GLOBALS['querytime']); + + $message->addMessage($messagge_qt, ''); + if (! is_null($sorted_column_message)) { + $message->addMessage($sorted_column_message, ''); + } + + return $message; + +} + + +/** + * Prepare multi field edit/delete links + * + * @param integer &$dt_result the link id associated to the query + * which results have to be displayed + * @param integer $fields_cnt the total number of fields returned by + * the SQL query + * @param array $fields_meta the list of fields properties + * @param integer $num_rows the total number of rows returned + * by the SQL query + * @param array $analyzed_sql the analyzed query + * @param string $db the database name + * @param string $table the table name + * @param string $sql_query the current SQL query + * @param string $goto the URL to go back in case of errors + * @param string $del_link the display element - 'del_link' + * + * @return string $links_html html content + * + * @see PMA_getTable() + */ +function PMA_getMultiRowOperationLinks( + &$dt_result, $fields_cnt, $fields_meta, $num_rows, $analyzed_sql, + $db, $table, $sql_query, $goto, $del_link +) { + + $links_html = ''; + $delete_text = ($del_link == 'dr') ? __('Delete') : __('Kill'); + + $_url_params = array( + 'db' => $db, + 'table' => $table, + 'sql_query' => $sql_query, + 'goto' => $goto, + ); + $uncheckall_url = 'sql.php' . PMA_generate_common_url($_url_params); + + $_url_params['checkall'] = '1'; + $checkall_url = 'sql.php' . PMA_generate_common_url($_url_params); + + if ($_SESSION['tmp_user_values']['disp_direction'] == 'vertical') { + + $checkall_params['onclick'] + = 'if (setCheckboxes(\'resultsForm\', true)) return false;'; + $uncheckall_params['onclick'] + = 'if (setCheckboxes(\'resultsForm\', false)) return false;'; + + } else { + + $checkall_params['onclick'] + = 'if (markAllRows(\'resultsForm\')) return false;'; + $uncheckall_params['onclick'] + = 'if (unMarkAllRows(\'resultsForm\')) return false;'; + + } + + $checkall_link = PMA_linkOrButton( $checkall_url, __('Check All'), $checkall_params, false ); - $uncheckall_link = PMA_linkOrButton( + + $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( + if ($_SESSION['tmp_user_values']['disp_direction'] != 'vertical') { + + $links_html .= '' . __('With selected:') . ''; + } + + $links_html .= $checkall_link . "\n" + . ' / ' . "\n" + . $uncheckall_link . "\n" + . '' . __('With selected:') . '' . "\n"; + + $links_html .= PMA_getButtonOrImage( 'submit_mult', 'mult_submit', 'submit_mult_change', __('Change'), 'b_edit.png', 'edit' ); - PMA_buttonOrImage( + + $links_html .= PMA_getButtonOrImage( '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( + + if (isset($analyzed_sql[0]) && $analyzed_sql[0]['querytype'] == 'SELECT') { + $links_html .= PMA_getButtonOrImage( 'submit_mult', 'mult_submit', 'submit_mult_export', __('Export'), 'b_tblexport.png', 'export' ); - } - echo "\n"; - - echo '' . "\n"; - - if (! empty($GLOBALS['url_query'])) { - echo '' . "\n"; - } - - echo '' . "\n"; - - echo '' . "\n"; } - // 5. ----- Displays the navigation bar at the bottom if required ----- + $links_html .= "\n"; - 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' - ); - } elseif (! isset($GLOBALS['printview']) || $GLOBALS['printview'] != '1') { - echo "\n" . '

' . "\n"; + $links_html .= '' . "\n"; + + if (! empty($GLOBALS['url_query'])) { + $links_html .= '' . "\n"; } - // 6. ----- Displays "Query results operations" - if (! isset($GLOBALS['printview']) || $GLOBALS['printview'] != '1') { - PMA_displayResultsOperations($the_disp_mode, $analyzed_sql); - } -} // end of the 'PMA_displayTable()' function + // 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); + + // reset to first row for the loop in PMA_getTableBody() + PMA_DBI_data_seek($dt_result, 0); + + $links_html .= '' . "\n"; + + $links_html .= '' . "\n"; + + return $links_html; + +} + /** * replace some html-unfriendly stuff @@ -3065,12 +4136,15 @@ function PMA_mimeDefaultFunction($buffer) return $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 @@ -3080,25 +4154,27 @@ 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_getTableBody(), 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; + $results_operations_html = ''; $header_shown = false; $header = '
' . __('Query results operations') . ''; - if ($the_disp_mode[6] == '1' || $the_disp_mode[9] == '1') { + if (($the_disp_mode[6] == '1') || ($the_disp_mode[9] == '1')) { // Displays "printable view" link if required if ($the_disp_mode[9] == '1') { if (!$header_shown) { - echo $header; + $results_operations_html .= $header; $header_shown = true; } @@ -3110,21 +4186,25 @@ 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" @@ -3138,19 +4218,22 @@ function PMA_displayResultsOperations($the_disp_mode, $analyzed_sql) // (most probably PROCEDURE ANALYSE()) it makes no sense to // display the Export link). if (isset($analyzed_sql[0]) - && $analyzed_sql[0]['querytype'] == 'SELECT' + && ($analyzed_sql[0]['querytype'] == 'SELECT') && ! isset($printview) && ! isset($analyzed_sql[0]['queryflags']['procedure']) ) { + if (isset($analyzed_sql[0]['table_ref'][0]['table_true_name']) && ! isset($analyzed_sql[0]['table_ref'][1]['table_true_name']) ) { $_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; /** @@ -3169,20 +4252,22 @@ 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"; + // prepare chart + $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 + // prepare GIS chart $geometry_found = false; // If atleast one geometry field is found foreach ($fields_meta as $meta) { @@ -3191,12 +4276,14 @@ function PMA_displayResultsOperations($the_disp_mode, $analyzed_sql) break; } } + 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"; } } @@ -3209,23 +4296,32 @@ 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 .= '
'; } + + return $results_operations_html; + } + /** * Verifies what to do with non-printable contents (binary or BLOB) * in Browse mode. @@ -3240,27 +4336,37 @@ 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; + if (is_null($content)) { + $result .= ' - NULL'; $size = 0; + } elseif (isset($content)) { + $size = strlen($content); $display_size = PMA_formatByteDown($size, 3, 1); $result .= ' - '. $display_size[0] . ' ' . $display_size[1]; + } + $result .= ']'; if (strpos($transform_function, 'octetstream')) { $result = $content; } + if ($size > 0) { + if ($default_function != $transform_function) { $result = $transform_function($result, $transform_options, $meta); } else { + $result = $default_function($result, array(), $meta); if (stristr($meta->type, 'BLOB') && $_SESSION['tmp_user_values']['display_blob'] @@ -3268,6 +4374,7 @@ function PMA_handle_non_printable_contents($category, $content, $transform_funct // in this case, restart from the original $content $result = htmlspecialchars(PMA_replaceBinaryContents($content)); } + /* Create link to download */ if (count($url_params) > 0) { $result = ''; + $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']) ) { + foreach ($analyzed_sql[0]['select_expr'] - as $select_expr_position => $select_expr) { + as $select_expr_position => $select_expr + ) { + $alias = $analyzed_sql[0]['select_expr'][$select_expr_position]['alias']; + if (isset($alias) && strlen($alias)) { $true_column = $analyzed_sql[0]['select_expr'][$select_expr_position]['column']; + if ($alias == $meta->name) { // this change in the parameter does not matter // outside of the function $meta->name = $true_column; } // end if + } // end if } // end foreach } // end if if (isset($map[$meta->name])) { + // Field to display from the foreign table? if (isset($map[$meta->name][2]) && strlen($map[$meta->name][2])) { + $dispsql = 'SELECT ' . PMA_backquote($map[$meta->name][2]) . ' FROM ' . PMA_backquote($map[$meta->name][3]) . '.' . PMA_backquote($map[$meta->name][0]) . ' WHERE ' . PMA_backquote($map[$meta->name][1]) . $where_comparison; + $dispresult = PMA_DBI_try_query($dispsql, null, PMA_DBI_QUERY_STORE); + if ($dispresult && PMA_DBI_num_rows($dispresult) > 0) { list($dispval) = PMA_DBI_fetch_row($dispresult, 0); } else { $dispval = __('Link not found'); } + @PMA_DBI_free_result($dispresult); + } else { $dispval = ''; } // end if... else... if (isset($GLOBALS['printview']) && $GLOBALS['printview'] == '1') { + $result .= ($transform_function != $default_function ? $transform_function($data, $transform_options, $meta) : $transform_function($data, array(), $meta)) . ' [->' . $dispval . ']'; + } else { - if ('K' == $_SESSION['tmp_user_values']['relational_display']) { + if ($_SESSION['tmp_user_values']['relational_display'] == 'K') { + // user chose "relational key" in the display options, so // the title contains the display field $title = (! empty($dispval))? ' title="' . htmlspecialchars($dispval) . '"' : ''; + } else { $title = ' title="' . htmlspecialchars($data) . '"'; } @@ -3370,6 +4499,7 @@ function PMA_prepare_row_data($class, $condition_field, $analyzed_sql, $meta, $m . ' WHERE ' . PMA_backquote($map[$meta->name][1]) . $where_comparison, ); + $result .= ''; @@ -3378,7 +4508,8 @@ function PMA_prepare_row_data($class, $condition_field, $analyzed_sql, $meta, $m // not on the display field $result .= $transform_function($data, $transform_options, $meta); } else { - if ('D' == $_SESSION['tmp_user_values']['relational_display']) { + + if ($_SESSION['tmp_user_values']['relational_display'] == 'D') { // user chose "relational display field" in the // display options, so show display field in the cell $result .= $transform_function($dispval, array(), $meta); @@ -3386,13 +4517,15 @@ function PMA_prepare_row_data($class, $condition_field, $analyzed_sql, $meta, $m // otherwise display data in the cell $result .= $transform_function($data, array(), $meta); } + } $result .= ''; } + } else { - $result .= ($transform_function != $default_function + $result .= ($transform_function != $default_function) ? $transform_function($data, $transform_options, $meta) - : $transform_function($data, array(), $meta)); + : $transform_function($data, array(), $meta); } // create hidden field if results from structure table @@ -3420,10 +4553,12 @@ function PMA_prepare_row_data($class, $condition_field, $analyzed_sql, $meta, $m $result .= '' . "\n"; return $result; + } + /** - * 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 @@ -3437,33 +4572,40 @@ 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 = ''; + if (! empty($del_url) && $is_display['del_lnk'] != 'kp') { - $ret .= '' - . '' - . ' '; + . '' + . '' + . ' '; } + return $ret; + } + /** - * Generates an Edit link + * Prepares an Edit link * * @param string $edit_url edit url * @param string $class css classes for td element @@ -3473,11 +4615,13 @@ 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 = ''; if (! empty($edit_url)) { + $ret .= '' . PMA_linkOrButton($edit_url, $edit_str, array(), false); /* @@ -3490,11 +4634,14 @@ function PMA_generateEditLink($edit_url, $class, $edit_str, $where_clause, } $ret .= ''; } + return $ret; + } + /** - * Generates an Copy link + * Prepares an Copy link * * @param string $copy_url copy url * @param string $copy_str text for the copy link @@ -3504,17 +4651,21 @@ 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 = ''; if (! empty($copy_url)) { + $ret .= '' . PMA_linkOrButton($copy_url, $copy_str, array(), false); + /* * Where clause for selecting this row uniquely is provided as * a hidden input. Used by jQuery scripts for handling grid editing @@ -3525,11 +4676,14 @@ function PMA_generateCopyLink($copy_url, $copy_str, $where_clause, } $ret .= ''; } + return $ret; + } + /** - * Generates a Delete link + * Prepares a Delete link * * @param string $del_url delete url * @param string $del_str text for the delete link @@ -3538,23 +4692,29 @@ 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)) { + $ret .= '' . PMA_linkOrButton($del_url, $del_str, $js_conf, false) . ''; } + return $ret; + } + /** - * 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 @@ -3576,49 +4736,56 @@ 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( - $del_url, $is_display, $row_no, $where_clause_html, $condition_array, - $del_query, $id_suffix = '_left', '', '', '' - ); + + $ret .= PMA_getCheckboxForMultiRowSubmissions( + $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, '' - ); + $ret .= PMA_getEditLink( + $edit_url, $class, $edit_str, $where_clause, $where_clause_html, '' + ); - $ret .= PMA_generateCopyLink( - $copy_url, $copy_str, $where_clause, $where_clause_html, '' - ); + $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( - $copy_url, $copy_str, $where_clause, $where_clause_html, '' - ); + $ret .= PMA_getCopyLink( + $copy_url, $copy_str, $where_clause, $where_clause_html, '' + ); - $ret .= PMA_generateEditLink( - $edit_url, $class, $edit_str, $where_clause, $where_clause_html, '' - ); + $ret .= PMA_getEditLink( + $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', '', '', '' - ); + $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( - $del_url, $is_display, $row_no, $where_clause_html, $condition_array, - $del_query, $id_suffix = '_left', '', '', '' - ); + + $ret .= PMA_getCheckboxForMultiRowSubmissions( + $del_url, $is_display, $row_no, $where_clause_html, $condition_array, + $del_query, $id_suffix = '_left', '', '', '' + ); } + return $ret; + } ?> 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/libraries/schema/User_Schema.class.php b/libraries/schema/User_Schema.class.php index 6159107b09..b1ceb0ee9c 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_displayHtmlRadio('action_choose', $choices, '0', false); + echo PMA_getRadioFields('action_choose', $choices, '0', false); unset($choices); ?> 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/pmd_pdf.php b/pmd_pdf.php index e28567fa0f..a8fba19b9d 100644 --- a/pmd_pdf.php +++ b/pmd_pdf.php @@ -123,7 +123,7 @@ if (1 == count($choices)) { echo $choices['create_export']; echo ''; } else { - PMA_displayHtmlRadio('mode', $choices, $checked_choice = '', $line_break = true, $escape_label = false, $class = ''); + echo PMA_getRadioFields('mode', $choices, $checked_choice = '', $line_break = true, $escape_label = false, $class = ''); } echo '
'; echo ''; 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 7c2eb91879..23ae8977a1 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 '' . '
' @@ -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_displayHtmlRadio('mode', $choices, '4', true); + echo PMA_getRadioFields('mode', $choices, '4', true); unset($choices); echo ' ' . "\n" diff --git a/sql.php b/sql.php index 151dd46f97..9a33f315f7 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(); } @@ -960,7 +960,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; } @@ -987,7 +987,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)) { @@ -1047,7 +1047,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 b0f9c693a7..4d24a49469 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 934e066f28..053ea71f95 100644 --- a/tbl_alter.php +++ b/tbl_alter.php @@ -252,7 +252,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 92c728ad6e..5b42085dea 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 9ec83b39db..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_generateHtmlDropdown('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 ''; @@ -561,7 +561,7 @@ if (isset($possible_row_formats[$tbl_storage_engine])) { 'structure' => __('Structure only'), 'data' => __('Structure and data'), 'dataonly' => __('Data only')); - PMA_displayHtmlRadio('what', $choices, 'data', true); + echo PMA_getRadioFields('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_displayHtmlRadio('partition_operation', $choices, '', false); + echo PMA_getRadioFields('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_relation.php b/tbl_relation.php index 3501045c72..b990df4d14 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_select.php b/tbl_select.php index 611b124e53..22f3cc3817 100644 --- a/tbl_select.php +++ b/tbl_select.php @@ -173,7 +173,7 @@ echo PMA_generateHtmlTabs(PMA_tbl_getSubTabs(), $url_params, 'topmenu2');
@@ -223,7 +223,7 @@ echo PMA_generateHtmlTabs(PMA_tbl_getSubTabs(), $url_params, 'topmenu2'); 'ASC' => __('Ascending'), 'DESC' => __('Descending') ); - PMA_displayHtmlRadio('order', $choices, 'ASC', false, true, "formelement"); + echo PMA_getRadioFields('order', $choices, 'ASC', false, true, "formelement"); unset($choices); ?>
diff --git a/tbl_structure.php b/tbl_structure.php index 8611f39cc6..f60f2412dd 100644 --- a/tbl_structure.php +++ b/tbl_structure.php @@ -568,37 +568,37 @@ $checkall_url = 'tbl_structure.php?' . PMA_generate_common_url($db, $table); @@ -710,7 +710,7 @@ if (! $tbl_is_view && ! $db_is_information_schema) { 'first' => __('At Beginning of Table'), 'after' => sprintf(__('After %s'), '') ); - PMA_displayHtmlRadio('field_where', $choices, 'last', false); + echo PMA_getRadioFields('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_generateSliderEffect('indexes', __('Indexes')); + echo PMA_getDivForSliderEffect('indexes', __('Indexes')); /** * Display indexes */ diff --git a/tbl_tracking.php b/tbl_tracking.php index 8a8bf38c3e..b8b92f48c4 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_slider_effect_test.php b/test/libraries/common/PMA_generate_slider_effect_test.php deleted file mode 100644 index 3f69ebf3ed..0000000000 --- a/test/libraries/common/PMA_generate_slider_effect_test.php +++ /dev/null @@ -1,52 +0,0 @@ -expectOutputString('
'); - PMA_generateSliderEffect($id, $message); - } - - function testGenerateSliderEffectTestClosed() - { - global $cfg; - $cfg['InitialSlidersState'] = 'closed'; - - $id = "test_id"; - $message = "test_message"; - - $this->expectOutputString('