diff --git a/libraries/sql.lib.php b/libraries/sql.lib.php
index 734a03e2a1..1146cdf9f9 100644
--- a/libraries/sql.lib.php
+++ b/libraries/sql.lib.php
@@ -1795,4 +1795,40 @@ function PMA_sendResponseOrGetHtmlForTableMaintenance($disp_mode, $db, $message,
exit();
}
}
+
+
+/**
+ * Function to get html for the sql query results div
+ *
+ * @param string $previous_update_query_html html for the previously executed query
+ * @param string $profiling_chart_html html for profiling
+ * @param object $missing_unique_column_msg message for the missing unique column
+ * @param object $bookmark_created_msg message for bookmark creation
+ * @param string $table_html html for the table for displaying sql
+ * results
+ * @param string $index_problems_html html for displaying errors in indexes
+ * @param string $print_button_html html for the print button in printview
+ *
+ * @return string $html_output
+ */
+function PMA_getHtmlForSqlQueryResults($previous_update_query_html,
+ $profiling_chart_html, $missing_unique_column_msg, $bookmark_created_msg,
+ $table_html, $index_problems_html, $print_button_html
+) {
+ //begin the sqlqueryresults div here. container div
+ $html_output = '
';
+ $html_output .= isset($previous_update_query_html)
+ ? $previous_update_query_html : '';
+ $html_output .= isset($profiling_chart_html) ? $profiling_chart_html : '';
+ $html_output .= isset($missing_unique_column_msg)
+ ? $missing_unique_column_msg->getDisplay() : '';
+ $html_output .= isset($bookmark_created_msg)
+ ? $bookmark_created_msg->getDisplay() : '';
+ $html_output .= $table_html;
+ $html_output .= isset($index_problems_html) ? $index_problems_html : '';
+ $html_output .= isset($print_button_html) ? $print_button_html : '';
+ $html_output .= '
'; // end sqlqueryresults div
+
+ return $html_output;
+}
?>
diff --git a/sql.php b/sql.php
index 7d7cce1a28..692d6eec90 100644
--- a/sql.php
+++ b/sql.php
@@ -281,19 +281,29 @@ if ((0 == $num_rows && 0 == $unlim_num_rows) || $is_affected) {
//set a global variable and check against it in the function
$GLOBALS['buffer_message'] = false;
}
-
+
+ // Displays the results in a table
+ if (empty($disp_mode)) {
+ // see the "PMA_setDisplayMode()" function in
+ // libraries/DisplayResults.class.php
+ $disp_mode = 'urdr111101';
+ }
+
if (strlen($db)) {
$cfgRelation = PMA_getRelationsParam();
}
- //begin the sqlqueryresults div here. container div
- $html_output .= 'isSystemSchema($db) || !$editable)) {
$disp_mode = 'nnnn110111';
- $msg = PMA_message::notice(
+ $missing_unique_column_msg = PMA_message::notice(
__(
'Table %s does not contain a unique column.'
. ' Grid edit, checkbox, Edit, Copy and Delete features'
. ' are not available.'
)
);
- $msg->addParam($table);
- $html_output .= $msg->getDisplay();
+ $missing_unique_column_msg->addParam($table);
+ } else {
+ $missing_unique_column_msg = null;
}
-
+
if (isset($_GET['label'])) {
- $msg = PMA_message::success(__('Bookmark %s created'));
- $msg->addParam($_GET['label']);
- $html_output .= $msg->getDisplay();
+ $bookmark_created_msg = PMA_message::success(__('Bookmark %s created'));
+ $bookmark_created_msg->addParam($_GET['label']);
+ } else {
+ $bookmark_created_msg = null;
}
if (! empty($sql_data) && ($sql_data['valid_queries'] > 1) || $is_procedure) {
-
$_SESSION['is_multi_query'] = true;
- $html_output .= getTableHtmlForMultipleQueries(
+ $table_html = getTableHtmlForMultipleQueries(
$displayResultsObject, $db, $sql_data, $goto,
$pmaThemeImage, $text_dir, $printview, $url_query,
$disp_mode, $sql_limit_to_append, $editable
@@ -363,35 +366,38 @@ if ((0 == $num_rows && 0 == $unlim_num_rows) || $is_affected) {
$printview, $url_query, $editable
);
- $html_output .= $displayResultsObject->getTable(
+ $table_html = $displayResultsObject->getTable(
$result, $disp_mode, $analyzed_sql
);
$GLOBALS['dbi']->freeResult($result);
}
-
+
// BEGIN INDEX CHECK See if indexes should be checked.
if (isset($query_type)
&& $query_type == 'check_tbl'
&& isset($selected)
&& is_array($selected)
) {
+ $index_problems_html = '';
foreach ($selected as $idx => $tbl_name) {
$check = PMA_Index::findDuplicates($tbl_name, $db);
if (! empty($check)) {
- $html_output .= sprintf(
+ $index_problems_html .= sprintf(
__('Problems with indexes of table `%s`'), $tbl_name
);
- $html_output .= $check;
+ $index_problems_html .= $check;
}
}
- } // End INDEX CHECK
-
+ } else {
+ $index_problems_html = null;
+ }
+
// Bookmark support if required
if ($disp_mode[7] == '1'
&& (! empty($cfg['Bookmark']) && empty($_GET['id_bookmark']))
&& ! empty($sql_query)
) {
- $html_output .= "\n";
+ $bookmark_support_html = "\n";
$goto = 'sql.php?'
. PMA_generate_common_url($db, $table)
. '&sql_query=' . urlencode($sql_query)
@@ -399,17 +405,26 @@ if ((0 == $num_rows && 0 == $unlim_num_rows) || $is_affected) {
$bkm_sql_query = urlencode(
isset($complete_query) ? $complete_query : $sql_query
);
- $html_output .= PMA_getHtmlForBookmark(
+ $bookmark_support_html .= PMA_getHtmlForBookmark(
$db, $goto, $bkm_sql_query, $cfg['Bookmark']['user']
);
- } // end bookmark support
+ } else {
+ $bookmark_support_html = null;
+ }
// Do print the page if required
if (isset($_REQUEST['printview']) && $_REQUEST['printview'] == '1') {
- $html_output .= PMA_Util::getButton();
- } // end print case
- $html_output .= '
'; // end sqlqueryresults div
+ $print_button_html = PMA_Util::getButton();
+ } else {
+ $print_button_html = null;
+ }
+
+ $html_output .= PMA_getHtmlForSqlQueryResults($previous_update_query_html,
+ $profiling_chart_html, $missing_unique_column_msg, $bookmark_created_msg,
+ $table_html, $index_problems_html, $print_button_html
+ );
+
$response->addHTML($html_output);
+
} // end rows returned
-
?>