Fix #12327: Show as PHP No longer works

Fix output of show_as_php. Don't show the links that are not required
or that may not work as expected

Signed-off-by: Deven Bansod <devenbansod.bits@gmail.com>
This commit is contained in:
Deven Bansod 2016-09-27 13:47:31 +05:30
parent a1c27b957c
commit 96eba72fa6
4 changed files with 35 additions and 8 deletions

View File

@ -1164,6 +1164,8 @@ class Util
if (! empty($GLOBALS['show_as_php'])) {
$query_base = '$sql = \'' . $query_base;
$query_base = '<code class="php"><pre>' . "\n"
. $query_base;
} elseif (isset($query_base)) {
$query_base = self::formatSql($query_base);
}
@ -1234,7 +1236,9 @@ class Util
// even if the query is big and was truncated, offer the chance
// to edit it (unless it's enormous, see linkOrButton() )
if (! empty($cfg['SQLQuery']['Edit'])) {
if (! empty($cfg['SQLQuery']['Edit'])
&& empty($GLOBALS['show_as_php'])
) {
$edit_link .= PMA_URL_getCommon($url_params) . '#querybox';
$edit_link = ' ['
. self::linkOrButton($edit_link, __('Edit'))
@ -1307,7 +1311,8 @@ class Util
//Clean up the end of the PHP
if (! empty($GLOBALS['show_as_php'])) {
$retval .= '\';';
$retval .= '\';' . "\n"
. '</pre></code>';
}
$retval .= '</div>';
@ -1333,7 +1338,10 @@ class Util
/**
* TODO: Should we have $cfg['SQLQuery']['InlineEdit']?
*/
if (! empty($cfg['SQLQuery']['Edit']) && ! $query_too_big) {
if (! empty($cfg['SQLQuery']['Edit'])
&& ! $query_too_big
&& empty($GLOBALS['show_as_php'])
) {
$inline_edit_link = ' ['
. self::linkOrButton(
'#',

View File

@ -1433,6 +1433,10 @@ function PMA_getQueryResponseForNoResultsReturned($analyzed_sql_results, $db,
}
$html_output = '';
$html_message = PMA\libraries\Util::getMessage(
$message, $GLOBALS['sql_query'], 'success'
);
$html_output .= $html_message;
if (!isset($GLOBALS['show_as_php'])) {
if (! empty($GLOBALS['reload'])) {
@ -1440,11 +1444,6 @@ function PMA_getQueryResponseForNoResultsReturned($analyzed_sql_results, $db,
$extra_data['db'] = $GLOBALS['db'];
}
$html_message = PMA\libraries\Util::getMessage(
$message, $GLOBALS['sql_query'], 'success'
);
$html_output .= $html_message;
// For ajax requests add message and sql_query as JSON
if (empty($_REQUEST['ajax_page_request'])) {
$extra_data['message'] = $message;

View File

@ -1355,6 +1355,16 @@ label.desc sup {
position: absolute;
}
code.php {
display: block;
padding-left: 0.3em;
margin-top: 0;
margin-bottom: 0;
max-height: 10em;
overflow: auto;
direction: ltr;
}
code.sql,
div.sqlvalidate {
display: block;

View File

@ -1786,6 +1786,16 @@ label.desc sup {
position: absolute;
}
code.php {
display: block;
padding-left: 1em;
margin-top: 0;
margin-bottom: 0;
max-height: 10em;
overflow: auto;
direction: ltr;
}
code.sql,
div.sqlvalidate {
display: block;