Various coding style changes

This commit is contained in:
Madhura Jayaratne 2012-08-31 14:37:46 +05:30
parent 5b56ea6e75
commit 8ce541068c
6 changed files with 99 additions and 58 deletions

View File

@ -61,11 +61,11 @@ if ($num_tables == 0 && count($data['ddlog']) == 0) {
// Prepare statement to get HEAD version
$all_tables_query = ' SELECT table_name, MAX(version) as version FROM ' .
$common_functions->backquote($GLOBALS['cfg']['Server']['pmadb']) . '.' .
$common_functions->backquote($GLOBALS['cfg']['Server']['tracking']) .
' WHERE db_name = \'' . $common_functions->sqlAddSlashes($_REQUEST['db']) . '\' ' .
' GROUP BY table_name' .
' ORDER BY table_name ASC';
$common_functions->backquote($GLOBALS['cfg']['Server']['pmadb']) . '.' .
$common_functions->backquote($GLOBALS['cfg']['Server']['tracking']) .
' WHERE db_name = \'' . $common_functions->sqlAddSlashes($_REQUEST['db']) . '\' ' .
' GROUP BY table_name' .
' ORDER BY table_name ASC';
$all_tables_result = PMA_queryAsControlUser($all_tables_query);
@ -95,7 +95,10 @@ if (PMA_DBI_num_rows($all_tables_result) > 0) {
$drop_image_or_text = '';
if (true == $GLOBALS['cfg']['PropertiesIconic']) {
$drop_image_or_text .= $common_functions->getImage('b_drop.png', __('Delete tracking data for this table'));
$drop_image_or_text .= $common_functions->getImage(
'b_drop.png',
__('Delete tracking data for this table')
);
}
if ('both' === $GLOBALS['cfg']['PropertiesIconic']
|| false === $GLOBALS['cfg']['PropertiesIconic']
@ -124,7 +127,8 @@ if (PMA_DBI_num_rows($all_tables_result) > 0) {
$tmp_link = 'tbl_tracking.php?' . $url_query . '&table='
. htmlspecialchars($version_data['table_name']);
$delete_link = 'db_tracking.php?' . $url_query . '&table='
. htmlspecialchars($version_data['table_name']) . '&delete_tracking=true&amp';
. htmlspecialchars($version_data['table_name'])
. '&delete_tracking=true&amp';
?>
<tr class="noclick <?php echo $style;?>">
<td><?php echo htmlspecialchars($version_data['db_name']);?></td>
@ -161,12 +165,20 @@ $table_list = $common_functions->getTableList($GLOBALS['db']);
// For each table try to get the tracking version
foreach ($table_list as $key => $value) {
// If $value is a table group.
if (array_key_exists(('is' . $sep . 'group'), $value) && $value['is' . $sep . 'group']) {
if (array_key_exists(('is' . $sep . 'group'), $value)
&& $value['is' . $sep . 'group']
) {
foreach ($value as $temp_table) {
// If $temp_table is a table with the value for 'Name' is set,
// rather than a propery of the table group.
if (is_array($temp_table) && array_key_exists('Name', $temp_table)) {
if (PMA_Tracker::getVersion($GLOBALS['db'], $temp_table['Name']) == -1) {
if (is_array($temp_table)
&& array_key_exists('Name', $temp_table)
) {
$tracking_version = PMA_Tracker::getVersion(
$GLOBALS['db'],
$temp_table['Name']
);
if ($tracking_version == -1) {
$my_tables[] = $temp_table['Name'];
}
}
@ -200,7 +212,8 @@ if (isset($my_tables)) {
if (PMA_Tracker::getVersion($GLOBALS['db'], $tablename) == -1) {
$my_link = '<a href="tbl_tracking.php?' . $url_query
. '&amp;table=' . htmlspecialchars($tablename) .'">';
$my_link .= $common_functions->getIcon('eye.png', __('Track table')) . '</a>';
$my_link .= $common_functions->getIcon('eye.png', __('Track table'));
$my_link .= '</a>'
?>
<tr class="noclick <?php echo $style;?>">
<td><?php echo htmlspecialchars($tablename);?></td>
@ -224,7 +237,8 @@ if (isset($my_tables)) {
if (count($data['ddlog']) > 0) {
$log = '';
foreach ($data['ddlog'] as $entry) {
$log .= '# ' . $entry['date'] . ' ' . $entry['username'] . "\n" . $entry['statement'] . "\n";
$log .= '# ' . $entry['date'] . ' ' . $entry['username'] . "\n"
. $entry['statement'] . "\n";
}
echo $common_functions->getMessage(__('Database Log'), $log);
}

View File

@ -71,8 +71,8 @@ class PMA_Footer
private function _addDefaultScripts()
{
if (empty($GLOBALS['error_message'])) {
$this->_scripts->addCode("
$(function() {
$this->_scripts->addCode(
"$(function() {
// updates current settings
if (window.parent.setAll) {
window.parent.setAll(
@ -84,24 +84,24 @@ class PMA_Footer
'" . PMA_escapeJsString($_SESSION[' PMA_token ']) . "'
);
}
});
");
});"
);
if (! empty($GLOBALS['reload'])) {
$this->_scripts->addCode("
// refresh navigation frame content
$this->_scripts->addCode(
"// refresh navigation frame content
if (window.parent.refreshNavigation) {
window.parent.refreshNavigation();
}
");
}"
);
} else if (isset($_GET['reload_left_frame'])
&& $_GET['reload_left_frame'] == '1'
) {
// reload left frame (used by user preferences)
$this->_scripts->addCode("
if (window.parent && window.parent.frame_navigation) {
$this->_scripts->addCode(
"if (window.parent && window.parent.frame_navigation) {
window.parent.frame_navigation.location.reload();
}
");
}"
);
}
// set current db, table and sql query in the querywindow
@ -109,28 +109,28 @@ class PMA_Footer
if (isset($GLOBALS['sql_query']) && strlen($GLOBALS['sql_query']) > $GLOBALS['cfg']['MaxCharactersInDisplayedSQL']) {
$query = PMA_escapeJsString($GLOBALS['sql_query']);
}
$this->_scripts->addCode("
if (window.parent.reload_querywindow) {
$this->_scripts->addCode(
"if (window.parent.reload_querywindow) {
window.parent.reload_querywindow(
'" . PMA_escapeJsString(PMA_ifSetOr($GLOBALS['db'], '')) . "',
'" . PMA_escapeJsString(PMA_ifSetOr($GLOBALS['table'], '')) . "',
'" . $query . "'
);
}
");
}"
);
if (! empty($GLOBALS['focus_querywindow'])) {
// set focus to the querywindow
$this->_scripts->addCode("
if (parent.querywindow && !parent.querywindow.closed
$this->_scripts->addCode(
"if (parent.querywindow && !parent.querywindow.closed
&& parent.querywindow.location
) {
self.focus();
}
");
}"
);
}
$this->_scripts->addCode("
if (window.parent.frame_content) {
$this->_scripts->addCode(
"if (window.parent.frame_content) {
// reset content frame name, as querywindow needs
// to set a unique name before submitting form data,
// and navigation frame needs the original name
@ -144,8 +144,8 @@ class PMA_Footer
}
//window.parent.frame_content.setAttribute('name', 'frame_content');
//window.parent.frame_content.setAttribute('id', 'frame_content');
}
");
}"
);
}
}
@ -309,11 +309,11 @@ class PMA_Footer
) {
$url_params['target'] = basename(PMA_getenv('SCRIPT_NAME'));
$url = PMA_generate_common_url($url_params, 'text', '');
$this->_scripts->addCode("
// Store current location in hash part
$this->_scripts->addCode(
"// Store current location in hash part
// of URL to allow direct bookmarking
setURLHash('$url');
");
setURLHash('$url');"
);
$retval .= $this->_getSelfLink($url_params);
}
$retval .= $this->_getDebugMessage();

View File

@ -13,9 +13,10 @@ if (! defined('PHPMYADMIN')) {
/**
* This class implements the SplSubject interface
*
* @link http://php.net/manual/en/class.splsubject.php
* @todo implement all methods
* @package PhpMyAdmin
* @link http://php.net/manual/en/class.splsubject.php
*
*/
class PluginManager implements SplSubject
{

View File

@ -16,8 +16,8 @@ require_once "PluginManager.class.php";
/**
* This class implements the SplObserver interface
*
* @link http://php.net/manual/en/class.splobserver.php
* @package PhpMyAdmin
* @link http://php.net/manual/en/class.splobserver.php
*/
abstract class PluginObserver implements SplObserver
{
@ -43,7 +43,7 @@ abstract class PluginObserver implements SplObserver
* This method is called when any PluginManager to which the observer
* is attached calls PluginManager::notify()
*
* TODO Declare this function abstract, removing its body,
* TODO Declare this function abstract, removing its body,
* as soon as we drop support for PHP 5.2.x.
* See bug #3538655.
*
@ -59,10 +59,10 @@ abstract class PluginObserver implements SplObserver
);
}
/* ~~~~~~~~~~~~~~~~~~~~ Getters and Setters ~~~~~~~~~~~~~~~~~~~~ */
/**
* Gets the PluginManager instance that contains the list with all the
* plugins that attached to it

View File

@ -82,11 +82,16 @@ if (isset($GLOBALS['sr_take_action'])) {
$_SESSION['replication']['sr_action_info'] = __('Unknown error');
// Attempt to connect to the new master server
$link_to_master = PMA_replication_connect_to_master($sr['username'], $sr['pma_pw'], $sr['hostname'], $sr['port']);
$link_to_master = PMA_replication_connect_to_master(
$sr['username'], $sr['pma_pw'], $sr['hostname'], $sr['port']
);
if (! $link_to_master) {
$_SESSION['replication']['sr_action_status'] = 'error';
$_SESSION['replication']['sr_action_info'] = sprintf(__('Unable to connect to master %s.'), htmlspecialchars($sr['hostname']));
$_SESSION['replication']['sr_action_info'] = sprintf(
__('Unable to connect to master %s.'),
htmlspecialchars($sr['hostname'])
);
} else {
// Read the current master position
$position = PMA_replication_slave_bin_log_master($link_to_master);
@ -102,7 +107,10 @@ if (isset($GLOBALS['sr_take_action'])) {
$_SESSION['replication']['sr_action_info'] = __('Unable to change master');
} else {
$_SESSION['replication']['sr_action_status'] = 'success';
$_SESSION['replication']['sr_action_info'] = sprintf(__('Master server changed successfully to %s'), htmlspecialchars($sr['hostname']));
$_SESSION['replication']['sr_action_info'] = sprintf(
__('Master server changed successfully to %s'),
htmlspecialchars($sr['hostname'])
);
}
}
}
@ -112,7 +120,10 @@ if (isset($GLOBALS['sr_take_action'])) {
PMA_DBI_try_query("RESET SLAVE;");
PMA_replication_slave_control("START");
} else {
PMA_replication_slave_control($GLOBALS['sr_slave_action'], $GLOBALS['sr_slave_control_parm']);
PMA_replication_slave_control(
$GLOBALS['sr_slave_action'],
$GLOBALS['sr_slave_control_parm']
);
}
$refresh = true;
@ -127,11 +138,18 @@ if (isset($GLOBALS['sr_take_action'])) {
} elseif (isset($GLOBALS['sl_sync'])) {
// TODO username, host and port could be read from 'show slave status',
// when asked for a password this might work in more situations then just after changing master (where the master password is stored in session)
$src_link = PMA_replication_connect_to_master($_SESSION['replication']['m_username'], $_SESSION['replication']['m_password'], $_SESSION['replication']['m_hostname'], $_SESSION['replication']['m_port']);
// when asked for a password this might work in more situations then just
// after changing master (where the master password is stored in session)
$src_link = PMA_replication_connect_to_master(
$_SESSION['replication']['m_username'],
$_SESSION['replication']['m_password'],
$_SESSION['replication']['m_hostname'],
$_SESSION['replication']['m_port']
);
$trg_link = null; // using null to indicate the current PMA server
$data = PMA_DBI_fetch_result('SHOW MASTER STATUS', null, null, $src_link); // let's find out, which databases are replicated
// let's find out, which databases are replicated
$data = PMA_DBI_fetch_result('SHOW MASTER STATUS', null, null, $src_link);
$do_db = array();
$ignore_db = array();
@ -155,11 +173,17 @@ if (isset($GLOBALS['sr_take_action'])) {
}
$dblist[] = $tmp_row[0];
PMA_DBI_query('CREATE DATABASE IF NOT EXISTS '.$common_functions->backquote($tmp_row[0]), $trg_link);
PMA_DBI_query(
'CREATE DATABASE IF NOT EXISTS ' . $common_functions->backquote($tmp_row[0]),
$trg_link
);
} else {
if (array_search($tmp_row[0], $do_db) !== false) {
$dblist[] = $tmp_row[0];
PMA_DBI_query('CREATE DATABASE IF NOT EXISTS '. $common_functions->backquote($tmp_row[0]), $trg_link);
PMA_DBI_query(
'CREATE DATABASE IF NOT EXISTS ' . $common_functions->backquote($tmp_row[0]),
$trg_link
);
}
}
} // end while
@ -193,7 +217,9 @@ echo __('Replication');
echo ' </h2>';
// Display error messages
if (isset($_SESSION['replication']['sr_action_status']) && isset($_SESSION['replication']['sr_action_info'])) {
if (isset($_SESSION['replication']['sr_action_status'])
&& isset($_SESSION['replication']['sr_action_info'])
) {
if ($_SESSION['replication']['sr_action_status'] == 'error') {
PMA_Message::error($_SESSION['replication']['sr_action_info'])->display();
$_SESSION['replication']['sr_action_status'] = 'unknown';
@ -221,7 +247,8 @@ if ($server_master_status) {
$_url_params['mr_adduser'] = true;
$_url_params['repl_clear_scr'] = true;
echo ' <li><a href="' . PMA_generate_common_url($_url_params) . '" id="master_addslaveuser_href">' . __('Add slave replication user') . '</a></li>';
echo ' <li><a href="' . PMA_generate_common_url($_url_params) . '" id="master_addslaveuser_href">';
echo __('Add slave replication user') . '</a></li>';
}
// Display 'Add replication slave user' form

View File

@ -166,8 +166,7 @@ if (isset($_REQUEST['ajax_request']) && $_REQUEST['ajax_request'] == true) {
// Retrieve all required status variables
if (count($statusVars)) {
$statusVarValues = PMA_DBI_fetch_result(
"SHOW GLOBAL STATUS
WHERE Variable_name='" . implode("' OR Variable_name='", $statusVars) . "'", 0, 1
"SHOW GLOBAL STATUS WHERE Variable_name='" . implode("' OR Variable_name='", $statusVars) . "'", 0, 1
);
} else {
$statusVarValues = array();