Skip to content

Commit

Permalink
Simplify how inline edit link is added.
Browse files Browse the repository at this point in the history
  • Loading branch information
madhuracj committed Jul 27, 2013
1 parent 2a28436 commit b31a9cd
Showing 1 changed file with 27 additions and 61 deletions.
88 changes: 27 additions & 61 deletions libraries/Util.class.php
Expand Up @@ -1342,43 +1342,41 @@ public static function getMessage(
}

$retval .= '<div class="tools">';
$retval .= '<form action="sql.php" method="post">';
$retval .= PMA_generate_common_hidden_inputs(
$GLOBALS['db'], $GLOBALS['table']
);
$retval .= '<input type="hidden" name="sql_query" value="'
. htmlspecialchars($sql_query) . '" />';

// avoid displaying a Profiling checkbox that could
// be checked, which would reexecute an INSERT, for example
if (! empty($refresh_link)) {
$retval .= self::getProfilingForm($sql_query);
}
// if needed, generate an invisible form that contains controls for the
// Inline link; this way, the behavior of the Inline link does not
// depend on the profiling support or on the refresh link
if (empty($refresh_link) || !self::profilingSupported()) {
$retval .= '<form action="sql.php" method="post">';
$retval .= PMA_generate_common_hidden_inputs(
$GLOBALS['db'], $GLOBALS['table']
if (! empty($refresh_link) && self::profilingSupported()) {
$retval .= '<input type="hidden" name="profiling_form" value="1" />';
$retval .= self::getCheckbox(
'profiling', __('Profiling'), isset($_SESSION['profiling']), true
);
$retval .= '<input type="hidden" name="sql_query" value="'
. htmlspecialchars($sql_query) . '" />';
$retval .= '</form>';
}
$retval .= '</form>';

// in the tools div, only display the Inline link when not in ajax
// mode because 1) it currently does not work and 2) we would
// have two similar mechanisms on the page for the same goal
if ($is_select || ($GLOBALS['is_ajax_request'] === false)
/**
* TODO: Should we have $cfg['SQLQuery']['InlineEdit']?
*/
if (! empty($cfg['SQLQuery']['Edit'])
&& $is_select
&& ! $query_too_big
) {
// see in js/functions.js the jQuery code attached to id inline_edit
// document.write conflicts with jQuery, hence used $().append()
$retval .= "<script type=\"text/javascript\">\n" .
"//<![CDATA[\n" .
"$('.tools form').last().after('[ <a href=\"#\" title=\"" .
PMA_escapeJsString(__('Inline edit of this query')) .
"\" class=\"inline_edit_sql\">" .
PMA_escapeJsString(_pgettext('Inline edit query', 'Inline')) .
"</a> ]');\n" .
"//]]>\n" .
"</script>";
$inline_edit_link = ' ['
. self::linkOrButton(
'#',
_pgettext('Inline edit query', 'Inline'),
array('class' => 'inline_edit_sql')
)
. ']';
} else {
$inline_edit_link = '';
}
$retval .= $edit_link . $explain_link . $php_link
$retval .= $inline_edit_link . $edit_link . $explain_link . $php_link
. $refresh_link . $validate_link;
$retval .= '</div>';
}
Expand Down Expand Up @@ -1417,38 +1415,6 @@ public static function profilingSupported()
return self::cacheGet('profiling_supported', true);
}

/**
* Returns HTML for the form with the Profiling checkbox
*
* @param string $sql_query sql query
*
* @return string HTML for the form with the Profiling checkbox
*
* @access public
*/
public static function getProfilingForm($sql_query)
{
$retval = '';
if (self::profilingSupported()) {

$retval .= '<form action="sql.php" method="post">' . "\n";
$retval .= PMA_generate_common_hidden_inputs(
$GLOBALS['db'], $GLOBALS['table']
);

$retval .= '<input type="hidden" name="sql_query" value="'
. htmlspecialchars($sql_query) . '" />' . "\n"
. '<input type="hidden" name="profiling_form" value="1" />' . "\n";

$retval .= self::getCheckbox(
'profiling', __('Profiling'), isset($_SESSION['profiling']), true
);
$retval .= ' </form>' . "\n";

}
return $retval;
}

/**
* Formats $value to byte view
*
Expand Down

0 comments on commit b31a9cd

Please sign in to comment.