phpcs fixes

This commit is contained in:
Rouslan Placella 2012-08-18 16:18:46 +02:00
parent bb2d1f13de
commit 483dab2feb
12 changed files with 124 additions and 59 deletions

View File

@ -98,6 +98,8 @@ class PMA_Footer
/**
* Returns the url of the current page
*
* @param mixed $encoding See PMA_generate_common_url()
*
* @return string
*/
public function getSelfUrl($encoding = null)

View File

@ -185,6 +185,12 @@ class PMA_Header
$this->_scripts->addCode($this->getJsParamsCode());
}
/**
* Returns, as an array, a list of parameters
* used on the client side
*
* @return array
*/
public function getJsParams()
{
return array(
@ -210,7 +216,12 @@ class PMA_Header
);
}
/**
* Returns, as a string, a list of parameters
* used on the client side
*
* @return string
*/
public function getJsParamsCode()
{
$params = $this->getJsParams();
@ -588,9 +599,10 @@ class PMA_Header
if ($this->_menuEnabled && strlen($table) && $GLOBALS['cfg']['NumRecentTables'] > 0) {
$tmp_result = PMA_RecentTable::getInstance()->add($db, $table);
if ($tmp_result === true) {
$params = array('ajax_request' => true, 'recent_table' => true);
$url = 'index.php' . PMA_generate_common_url($params);
$retval = '<a class="hide" id="update_recent_tables" href="' . $url . '"></a>';
$params = array('ajax_request' => true, 'recent_table' => true);
$url = 'index.php' . PMA_generate_common_url($params);
$retval = '<a class="hide" id="update_recent_tables"';
$retval .= ' href="' . $url . '"></a>';
} else {
$error = $tmp_result;
$retval = $error->getDisplay();

View File

@ -110,7 +110,9 @@ class PMA_Response
if (isset($_REQUEST['ajax_request']) && $_REQUEST['ajax_request'] == true) {
$this->_isAjax = true;
}
if (isset($_REQUEST['ajax_page_request']) && $_REQUEST['ajax_page_request'] == true) {
if (isset($_REQUEST['ajax_page_request'])
&& $_REQUEST['ajax_page_request'] == true
) {
$this->_isAjaxPage = true;
}
$this->_header->setAjax($this->_isAjax);

View File

@ -98,8 +98,8 @@ class PMA_Scripts
{
$hash = md5($filename);
if (empty($this->_files[$hash])) {
$has_onload = $this->eventBlacklist($filename);
$timestamp = null;
$has_onload = $this->_eventBlacklist($filename);
$timestamp = null;
if (strpos($filename, '?') === false) {
$timestamp = filemtime('js/' . $filename);
}
@ -115,11 +115,12 @@ class PMA_Scripts
/**
* Determines whether to fire up an onload event for a file
*
* @param string $filename
* @param string $filename The name of the file to be checked
* against the blacklist
*
* @return int 1 to fire up the event, 0 not to
*/
private function eventBlacklist($filename)
private function _eventBlacklist($filename)
{
if ( strpos($filename, 'jquery') !== false
|| strpos($filename, 'codemirror') !== false
@ -215,7 +216,9 @@ class PMA_Scripts
$code = '$(function() {';
foreach ($this->_files as $file) {
if ($file['has_onload']) {
$code .= 'AJAX.fireOnload("' . PMA_escapeJsString($file['filename']) . '");';
$code .= 'AJAX.fireOnload("';
$code .= PMA_escapeJsString($file['filename']);
$code .= '");';
}
}
$code .= '});';

View File

@ -22,8 +22,7 @@ require_once 'libraries/navigation/NavigationTree.class.php';
class PMA_Navigation
{
/**
* Initialises the class, handles incoming requests
* and fires up rendering of the output
* Initialises the class
*
* @return void
*/

View File

@ -138,15 +138,15 @@ class PMA_NavigationHeader
$disableAjax = false,
$linkTarget = ''
) {
$retval = '<a href="' . $link . '"';
$retval = '<a href="' . $link . '"';
if (! empty($linkId)) {
$retval .= ' id="' . $linkId . '"';
$retval .= ' id="' . $linkId . '"';
}
if (! empty($linkTarget)) {
$retval .= ' target="' . $linkTarget . '"';
$retval .= ' target="' . $linkTarget . '"';
}
if ($disableAjax) {
$retval .= ' class="disableAjax"';
$retval .= ' class="disableAjax"';
}
$retval .= ' title="' . $text . '">';
if ($showIcon) {

View File

@ -205,7 +205,12 @@ class PMA_NavigationTree
$retval = $this->_tree;
// Add all databases unconditionally
foreach ($this->_tree->getData('databases', $this->_pos, $this->_searchClause) as $db) {
$data = $this->_tree->getData(
'databases',
$this->_pos,
$this->_searchClause
);
foreach ($data as $db) {
$node = PMA_NodeFactory::getInstance('Node_Database', $db);
$this->_tree->addChild($node);
}
@ -279,19 +284,34 @@ class PMA_NavigationTree
foreach ($dbData as $item) {
switch ($container->real_name) {
case 'events':
$node = PMA_NodeFactory::getInstance('Node_Event', $item);
$node = PMA_NodeFactory::getInstance(
'Node_Event',
$item
);
break;
case 'functions':
$node = PMA_NodeFactory::getInstance('Node_Function', $item);
$node = PMA_NodeFactory::getInstance(
'Node_Function',
$item
);
break;
case 'procedures':
$node = PMA_NodeFactory::getInstance('Node_Procedure', $item);
$node = PMA_NodeFactory::getInstance(
'Node_Procedure',
$item
);
break;
case 'tables':
$node = PMA_NodeFactory::getInstance('Node_Table', $item);
$node = PMA_NodeFactory::getInstance(
'Node_Table',
$item
);
break;
case 'views':
$node = PMA_NodeFactory::getInstance('Node_View', $item);
$node = PMA_NodeFactory::getInstance(
'Node_View',
$item
);
break;
default:
break;
@ -333,14 +353,22 @@ class PMA_NavigationTree
foreach ($tableData as $item) {
switch ($container->real_name) {
case 'indexes':
$node = PMA_NodeFactory::getInstance('Node_Index', $item);
$node = PMA_NodeFactory::getInstance(
'Node_Index',
$item
);
break;
case 'columns':
$node = PMA_NodeFactory::getInstance('Node_Column', $item);
$node = PMA_NodeFactory::getInstance(
'Node_Column',
$item
);
break;
case 'triggers':
$node = PMA_NodeFactory::getInstance('Node_Trigger', $item);
$node = PMA_NodeFactory::getInstance(
'Node_Trigger',
$item
);
break;
default:
break;
@ -383,13 +411,19 @@ class PMA_NavigationTree
$retval = array();
if ($table->hasChildren(true) == 0) {
if ($table->getPresence('columns')) {
$retval['columns'] = PMA_NodeFactory::getInstance('Node_Column_Container');
$retval['columns'] = PMA_NodeFactory::getInstance(
'Node_Column_Container'
);
}
if ($table->getPresence('indexes')) {
$retval['indexes'] = PMA_NodeFactory::getInstance('Node_Index_Container');
$retval['indexes'] = PMA_NodeFactory::getInstance(
'Node_Index_Container'
);
}
if ($table->getPresence('triggers')) {
$retval['triggers'] = PMA_NodeFactory::getInstance('Node_Trigger_Container');
$retval['triggers'] = PMA_NodeFactory::getInstance(
'Node_Trigger_Container'
);
}
// Add all new Nodes to the tree
foreach ($retval as $node) {
@ -430,19 +464,29 @@ class PMA_NavigationTree
$retval = array();
if ($db->hasChildren(true) == 0) {
if ($db->getPresence('tables')) {
$retval['tables'] = PMA_NodeFactory::getInstance('Node_Table_Container');
$retval['tables'] = PMA_NodeFactory::getInstance(
'Node_Table_Container'
);
}
if ($db->getPresence('views')) {
$retval['views'] = PMA_NodeFactory::getInstance('Node_View_Container');
$retval['views'] = PMA_NodeFactory::getInstance(
'Node_View_Container'
);
}
if ($db->getPresence('functions')) {
$retval['functions'] = PMA_NodeFactory::getInstance('Node_Function_Container');
$retval['functions'] = PMA_NodeFactory::getInstance(
'Node_Function_Container'
);
}
if ($db->getPresence('procedures')) {
$retval['procedures'] = PMA_NodeFactory::getInstance('Node_Procedure_Container');
$retval['procedures'] = PMA_NodeFactory::getInstance(
'Node_Procedure_Container'
);
}
if ($db->getPresence('events')) {
$retval['events'] = PMA_NodeFactory::getInstance('Node_Event_Container');
$retval['events'] = PMA_NodeFactory::getInstance(
'Node_Event_Container'
);
}
// Add all new Nodes to the tree
foreach ($retval as $node) {

View File

@ -87,7 +87,8 @@ class PMA_NodeFactory
$name = 'default',
$type = Node::OBJECT,
$is_group = false
) {
)
{
$class = self::_sanitizeClass($class);
include_once sprintf(self::$_path, $class);
return new $class($name, $type, $is_group);

View File

@ -414,7 +414,7 @@ class Node
}
$retval = (int)PMA_DBI_fetch_value($query);
} else {
$query = "SHOW DATABASES ";
$query = "SHOW DATABASES ";
if (! empty($searchClause)) {
$query .= "LIKE '%";
$query .= $this->_commonFunctions->sqlAddSlashes(

View File

@ -48,10 +48,10 @@ class Node_Column extends Node
*/
public function getComment()
{
$db = $this->_commonFunctions->sqlAddSlashes(
$db = $this->_commonFunctions->sqlAddSlashes(
$this->realParent()->realParent()->real_name
);
$table = $this->_commonFunctions->sqlAddSlashes(
$table = $this->_commonFunctions->sqlAddSlashes(
$this->realParent()->real_name
);
$column = $this->_commonFunctions->sqlAddSlashes(

View File

@ -215,8 +215,9 @@ class Node_Database extends Node
*/
public function getData($type, $pos, $searchClause = '')
{
$retval = array();
$db = $this->real_name;
$maxItems = $GLOBALS['cfg']['MaxNavigationItems'];
$retval = array();
$db = $this->real_name;
switch ($type) {
case 'tables':
if (! $GLOBALS['cfg']['Servers'][$GLOBALS['server']]['DisableIS']) {
@ -233,7 +234,7 @@ class Node_Database extends Node
$query .= "%'";
}
$query .= "ORDER BY `TABLE_NAME` ASC ";
$query .= "LIMIT $pos, {$GLOBALS['cfg']['MaxNavigationItems']}";
$query .= "LIMIT $pos, $maxItems";
$retval = PMA_DBI_fetch_result($query);
} else {
$query = " SHOW FULL TABLES FROM ";
@ -252,7 +253,7 @@ class Node_Database extends Node
if ($handle !== false) {
$count = 0;
while ($arr = PMA_DBI_fetch_array($handle)) {
if ($pos <= 0 && $count < $GLOBALS['cfg']['MaxNavigationItems']) {
if ($pos <= 0 && $count < $maxItems) {
$retval[] = $arr[0];
$count++;
}
@ -276,7 +277,7 @@ class Node_Database extends Node
$query .= "%'";
}
$query .= "ORDER BY `TABLE_NAME` ASC ";
$query .= "LIMIT $pos, {$GLOBALS['cfg']['MaxNavigationItems']}";
$query .= "LIMIT $pos, $maxItems";
$retval = PMA_DBI_fetch_result($query);
} else {
$query = "SHOW FULL TABLES FROM ";
@ -295,7 +296,7 @@ class Node_Database extends Node
if ($handle !== false) {
$count = 0;
while ($arr = PMA_DBI_fetch_array($handle)) {
if ($pos <= 0 && $count < $GLOBALS['cfg']['MaxNavigationItems']) {
if ($pos <= 0 && $count < $maxItems) {
$retval[] = $arr[0];
$count++;
}
@ -319,7 +320,7 @@ class Node_Database extends Node
$query .= "%'";
}
$query .= "ORDER BY `ROUTINE_NAME` ASC ";
$query .= "LIMIT $pos, {$GLOBALS['cfg']['MaxNavigationItems']}";
$query .= "LIMIT $pos, $maxItems";
$retval = PMA_DBI_fetch_result($query);
} else {
$db = $this->_commonFunctions->sqlAddSlashes($db);
@ -335,7 +336,7 @@ class Node_Database extends Node
if ($handle !== false) {
$count = 0;
while ($arr = PMA_DBI_fetch_array($handle)) {
if ($pos <= 0 && $count < $GLOBALS['cfg']['MaxNavigationItems']) {
if ($pos <= 0 && $count < $maxItems) {
$retval[] = $arr['Name'];
$count++;
}
@ -359,7 +360,7 @@ class Node_Database extends Node
$query .= "%'";
}
$query .= "ORDER BY `ROUTINE_NAME` ASC ";
$query .= "LIMIT $pos, {$GLOBALS['cfg']['MaxNavigationItems']}";
$query .= "LIMIT $pos, $maxItems";
$retval = PMA_DBI_fetch_result($query);
} else {
$db = $this->_commonFunctions->sqlAddSlashes($db);
@ -375,7 +376,7 @@ class Node_Database extends Node
if ($handle !== false) {
$count = 0;
while ($arr = PMA_DBI_fetch_array($handle)) {
if ($pos <= 0 && $count < $GLOBALS['cfg']['MaxNavigationItems']) {
if ($pos <= 0 && $count < $maxItems) {
$retval[] = $arr['Name'];
$count++;
}
@ -398,7 +399,7 @@ class Node_Database extends Node
$query .= "%'";
}
$query .= "ORDER BY `EVENT_NAME` ASC ";
$query .= "LIMIT $pos, {$GLOBALS['cfg']['MaxNavigationItems']}";
$query .= "LIMIT $pos, $maxItems";
$retval = PMA_DBI_fetch_result($query);
} else {
$db = $this->_commonFunctions->backquote($db);
@ -414,7 +415,7 @@ class Node_Database extends Node
if ($handle !== false) {
$count = 0;
while ($arr = PMA_DBI_fetch_array($handle)) {
if ($pos <= 0 && $count < $GLOBALS['cfg']['MaxNavigationItems']) {
if ($pos <= 0 && $count < $maxItems) {
$retval[] = $arr['Name'];
$count++;
}

View File

@ -113,9 +113,10 @@ class Node_Table extends Node
*/
public function getData($type, $pos, $searchClause = '')
{
$retval = array();
$db = $this->realParent()->real_name;
$table = $this->real_name;
$maxItems = $GLOBALS['cfg']['MaxNavigationItems'];
$retval = array();
$db = $this->realParent()->real_name;
$table = $this->real_name;
switch ($type) {
case 'columns':
if (! $GLOBALS['cfg']['Servers'][$GLOBALS['server']]['DisableIS']) {
@ -126,7 +127,7 @@ class Node_Table extends Node
$query .= "WHERE `TABLE_NAME`='$table' ";
$query .= "AND `TABLE_SCHEMA`='$db' ";
$query .= "ORDER BY `COLUMN_NAME` ASC ";
$query .= "LIMIT $pos, {$GLOBALS['cfg']['MaxNavigationItems']}";
$query .= "LIMIT $pos, $maxItems";
$retval = PMA_DBI_fetch_result($query);
} else {
$db = $this->_commonFunctions->backquote($db);
@ -136,7 +137,7 @@ class Node_Table extends Node
if ($handle !== false) {
$count = 0;
while ($arr = PMA_DBI_fetch_array($handle)) {
if ($pos <= 0 && $count < $GLOBALS['cfg']['MaxNavigationItems']) {
if ($pos <= 0 && $count < $maxItems) {
$retval[] = $arr['Field'];
$count++;
}
@ -154,7 +155,7 @@ class Node_Table extends Node
$count = 0;
while ($arr = PMA_DBI_fetch_array($handle)) {
if (! in_array($arr['Key_name'], $retval)) {
if ($pos <= 0 && $count < $GLOBALS['cfg']['MaxNavigationItems']) {
if ($pos <= 0 && $count < $maxItems) {
$retval[] = $arr['Key_name'];
$count++;
}
@ -172,7 +173,7 @@ class Node_Table extends Node
$query .= "WHERE `EVENT_OBJECT_SCHEMA`='$db' ";
$query .= "AND `EVENT_OBJECT_TABLE`='$table' ";
$query .= "ORDER BY `TRIGGER_NAME` ASC ";
$query .= "LIMIT $pos, {$GLOBALS['cfg']['MaxNavigationItems']}";
$query .= "LIMIT $pos, $maxItems";
$retval = PMA_DBI_fetch_result($query);
} else {
$db = $this->_commonFunctions->backquote($db);
@ -182,7 +183,7 @@ class Node_Table extends Node
if ($handle !== false) {
$count = 0;
while ($arr = PMA_DBI_fetch_array($handle)) {
if ($pos <= 0 && $count < $GLOBALS['cfg']['MaxNavigationItems']) {
if ($pos <= 0 && $count < $maxItems) {
$retval[] = $arr['Trigger'];
$count++;
}
@ -215,7 +216,7 @@ class Node_Table extends Node
$query .= "AND `TABLE_NAME`='$table' ";
$retval = PMA_DBI_fetch_value($query);
} else {
$db = $this->_commonFunctions->backquote($db);
$db = $this->_commonFunctions->backquote($db);
$query = "SHOW TABLE STATUS FROM $db ";
$query .= "WHERE Name = '$table'";
$arr = PMA_DBI_fetch_assoc(PMA_DBI_try_query($query));