diff --git a/libraries/Footer.class.php b/libraries/Footer.class.php index bfa3a28a8a..fb67a9627b 100644 --- a/libraries/Footer.class.php +++ b/libraries/Footer.class.php @@ -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) diff --git a/libraries/Header.class.php b/libraries/Header.class.php index 752c55a099..6f888c6bf7 100644 --- a/libraries/Header.class.php +++ b/libraries/Header.class.php @@ -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 = ''; + $params = array('ajax_request' => true, 'recent_table' => true); + $url = 'index.php' . PMA_generate_common_url($params); + $retval = ''; } else { $error = $tmp_result; $retval = $error->getDisplay(); diff --git a/libraries/Response.class.php b/libraries/Response.class.php index 6576a2c888..3dff922056 100644 --- a/libraries/Response.class.php +++ b/libraries/Response.class.php @@ -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); diff --git a/libraries/Scripts.class.php b/libraries/Scripts.class.php index ebfeb26f11..519ccfeaad 100644 --- a/libraries/Scripts.class.php +++ b/libraries/Scripts.class.php @@ -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 .= '});'; diff --git a/libraries/navigation/Navigation.class.php b/libraries/navigation/Navigation.class.php index e3994bf939..d140bbc33a 100644 --- a/libraries/navigation/Navigation.class.php +++ b/libraries/navigation/Navigation.class.php @@ -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 */ diff --git a/libraries/navigation/NavigationHeader.class.php b/libraries/navigation/NavigationHeader.class.php index 7b49242e4e..d2a1351e3a 100644 --- a/libraries/navigation/NavigationHeader.class.php +++ b/libraries/navigation/NavigationHeader.class.php @@ -138,15 +138,15 @@ class PMA_NavigationHeader $disableAjax = false, $linkTarget = '' ) { - $retval = ''; if ($showIcon) { diff --git a/libraries/navigation/NavigationTree.class.php b/libraries/navigation/NavigationTree.class.php index 6e610f5a0d..4c3a436114 100644 --- a/libraries/navigation/NavigationTree.class.php +++ b/libraries/navigation/NavigationTree.class.php @@ -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) { diff --git a/libraries/navigation/NodeFactory.class.php b/libraries/navigation/NodeFactory.class.php index a6d9beea06..f4e55a6847 100644 --- a/libraries/navigation/NodeFactory.class.php +++ b/libraries/navigation/NodeFactory.class.php @@ -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); diff --git a/libraries/navigation/Nodes/Node.class.php b/libraries/navigation/Nodes/Node.class.php index 3bcfbb3fd7..2a7846aa33 100644 --- a/libraries/navigation/Nodes/Node.class.php +++ b/libraries/navigation/Nodes/Node.class.php @@ -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( diff --git a/libraries/navigation/Nodes/Node_Column.class.php b/libraries/navigation/Nodes/Node_Column.class.php index 90a9261402..76dc239d35 100644 --- a/libraries/navigation/Nodes/Node_Column.class.php +++ b/libraries/navigation/Nodes/Node_Column.class.php @@ -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( diff --git a/libraries/navigation/Nodes/Node_Database.class.php b/libraries/navigation/Nodes/Node_Database.class.php index e3eff0f9a4..9640b415cb 100644 --- a/libraries/navigation/Nodes/Node_Database.class.php +++ b/libraries/navigation/Nodes/Node_Database.class.php @@ -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++; } diff --git a/libraries/navigation/Nodes/Node_Table.class.php b/libraries/navigation/Nodes/Node_Table.class.php index ce25a75f9a..da32f1d181 100644 --- a/libraries/navigation/Nodes/Node_Table.class.php +++ b/libraries/navigation/Nodes/Node_Table.class.php @@ -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));