Skip to content

Commit

Permalink
Return strings from functions, instead of using 'echo()'
Browse files Browse the repository at this point in the history
  • Loading branch information
roccivic committed May 8, 2012
1 parent 46ae483 commit dba26fd
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 17 deletions.
22 changes: 12 additions & 10 deletions libraries/common.lib.php
Expand Up @@ -1307,7 +1307,7 @@ function PMA_showMessage($message, $sql_query = null, $type = 'notice',
// avoid displaying a Profiling checkbox that could // avoid displaying a Profiling checkbox that could
// be checked, which would reexecute an INSERT, for example // be checked, which would reexecute an INSERT, for example
if (! empty($refresh_link)) { if (! empty($refresh_link)) {
PMA_profilingCheckbox($sql_query); echo PMA_getProfilingForm($sql_query);
} }
// if needed, generate an invisible form that contains controls for the // if needed, generate an invisible form that contains controls for the
// Inline link; this way, the behavior of the Inline link does not // Inline link; this way, the behavior of the Inline link does not
Expand Down Expand Up @@ -1395,16 +1395,18 @@ function PMA_profilingSupported()
* *
* @access public * @access public
*/ */
function PMA_profilingCheckbox($sql_query) function PMA_getProfilingForm($sql_query)
{ {
$retval = '';
if (PMA_profilingSupported()) { if (PMA_profilingSupported()) {
echo '<form action="sql.php" method="post">' . "\n"; $retval .= '<form action="sql.php" method="post">' . "\n";
echo PMA_generate_common_hidden_inputs($GLOBALS['db'], $GLOBALS['table']); $retval .= PMA_generate_common_hidden_inputs($GLOBALS['db'], $GLOBALS['table']);
echo '<input type="hidden" name="sql_query" value="' . htmlspecialchars($sql_query) . '" />' . "\n"; $retval .= '<input type="hidden" name="sql_query" value="' . htmlspecialchars($sql_query) . '" />' . "\n";
echo '<input type="hidden" name="profiling_form" value="1" />' . "\n"; $retval .= '<input type="hidden" name="profiling_form" value="1" />' . "\n";
PMA_display_html_checkbox('profiling', __('Profiling'), isset($_SESSION['profiling']), true); $retval .= PMA_getCheckbox('profiling', __('Profiling'), isset($_SESSION['profiling']), true);
echo ' </form>' . "\n"; $retval .= ' </form>' . "\n";
} }
return $retval;
} }


/** /**
Expand Down Expand Up @@ -2626,10 +2628,10 @@ function PMA_externalBug($functionality, $component, $minimum_version, $bugref)
* *
* @return void * @return void
*/ */
function PMA_display_html_checkbox($html_field_name, $label, $checked, $onclick) function PMA_getCheckbox($html_field_name, $label, $checked, $onclick)
{ {


echo '<input type="checkbox" name="' . $html_field_name . '" id="' return '<input type="checkbox" name="' . $html_field_name . '" id="'
. $html_field_name . '"' . ($checked ? ' checked="checked"' : '') . $html_field_name . '"' . ($checked ? ' checked="checked"' : '')
. ($onclick ? ' class="autosubmit"' : '') . ' /><label for="' . ($onclick ? ' class="autosubmit"' : '') . ' /><label for="'
. $html_field_name . '">' . $label . '</label>'; . $html_field_name . '">' . $label . '</label>';
Expand Down
8 changes: 4 additions & 4 deletions libraries/display_tbl.lib.php
Expand Up @@ -792,17 +792,17 @@ function PMA_displayTableHeaders(&$is_display, &$fields_meta, $fields_cnt = 0,
} }


echo '<div class="formelement">'; echo '<div class="formelement">';
PMA_display_html_checkbox( echo PMA_getCheckbox(
'display_binary', __('Show binary contents'), 'display_binary', __('Show binary contents'),
! empty($_SESSION['tmp_user_values']['display_binary']), false ! empty($_SESSION['tmp_user_values']['display_binary']), false
); );
echo '<br />'; echo '<br />';
PMA_display_html_checkbox( echo PMA_getCheckbox(
'display_blob', __('Show BLOB contents'), 'display_blob', __('Show BLOB contents'),
! empty($_SESSION['tmp_user_values']['display_blob']), false ! empty($_SESSION['tmp_user_values']['display_blob']), false
); );
echo '<br />'; echo '<br />';
PMA_display_html_checkbox( echo PMA_getCheckbox(
'display_binary_as_hex', __('Show binary contents as HEX'), 'display_binary_as_hex', __('Show binary contents as HEX'),
! empty($_SESSION['tmp_user_values']['display_binary_as_hex']), false ! empty($_SESSION['tmp_user_values']['display_binary_as_hex']), false
); );
Expand All @@ -813,7 +813,7 @@ function PMA_displayTableHeaders(&$is_display, &$fields_meta, $fields_cnt = 0,
// per SQL query, and at the same time have a default that displays // per SQL query, and at the same time have a default that displays
// the transformations. // the transformations.
echo '<div class="formelement">'; echo '<div class="formelement">';
PMA_display_html_checkbox( echo PMA_getCheckbox(
'hide_transformation', __('Hide browser transformation'), 'hide_transformation', __('Hide browser transformation'),
! empty($_SESSION['tmp_user_values']['hide_transformation']), false ! empty($_SESSION['tmp_user_values']['hide_transformation']), false
); );
Expand Down
6 changes: 3 additions & 3 deletions server_privileges.php
Expand Up @@ -2388,13 +2388,13 @@ function PMA_getGrants($user, $host)
echo '<fieldset id="fieldset_add_user_database">' . "\n" echo '<fieldset id="fieldset_add_user_database">' . "\n"
. '<legend>' . __('Database for user') . '</legend>' . "\n"; . '<legend>' . __('Database for user') . '</legend>' . "\n";


PMA_display_html_checkbox('createdb-1', __('Create database with same name and grant all privileges'), false, false); echo PMA_getCheckbox('createdb-1', __('Create database with same name and grant all privileges'), false, false);
echo '<br />' . "\n"; echo '<br />' . "\n";
PMA_display_html_checkbox('createdb-2', __('Grant all privileges on wildcard name (username\\_%)'), false, false); echo PMA_getCheckbox('createdb-2', __('Grant all privileges on wildcard name (username\\_%)'), false, false);
echo '<br />' . "\n"; echo '<br />' . "\n";


if (! empty($dbname) ) { if (! empty($dbname) ) {
PMA_display_html_checkbox('createdb-3', sprintf(__('Grant all privileges on database &quot;%s&quot;'), htmlspecialchars($dbname)), true, false); echo PMA_getCheckbox('createdb-3', sprintf(__('Grant all privileges on database &quot;%s&quot;'), htmlspecialchars($dbname)), true, false);
echo '<input type="hidden" name="dbname" value="' . htmlspecialchars($dbname) . '" />' . "\n"; echo '<input type="hidden" name="dbname" value="' . htmlspecialchars($dbname) . '" />' . "\n";
echo '<br />' . "\n"; echo '<br />' . "\n";
} }
Expand Down

0 comments on commit dba26fd

Please sign in to comment.