Move libraries/navigation/nodes classes into a namespace.

Signed-off-by: Hugues Peccatte <hugues.peccatte@gmail.com>
This commit is contained in:
Hugues Peccatte 2015-09-04 23:31:32 +02:00
parent 8db5465556
commit 78a803a8c8
44 changed files with 712 additions and 618 deletions

View File

@ -7,7 +7,14 @@
*/
namespace PMA\libraries\navigation;
use PMA\libraries\navigation\nodes\Node;
use PMA\libraries\navigation\nodes\NodeDatabase;
use PMA\libraries\navigation\nodes\NodeTable;
use PMA\libraries\navigation\nodes\NodeTableContainer;
use PMA\libraries\navigation\nodes\NodeViewContainer;
use PMA\libraries\RecentFavoriteTable;
use PMA\libraries\Response;
use PMA\libraries\Util;
/**
* Displays a collapsible of database objects in the navigation frame
@ -137,7 +144,7 @@ class NavigationTree
$this->_searchClause2 = $_REQUEST['searchClause2'];
}
// Initialise the tree by creating a root node
$node = NodeFactory::getInstance('Node_Database_Container', 'root');
$node = NodeFactory::getInstance('PMA\libraries\navigation\nodes\NodeDatabaseContainer', 'root');
$this->_tree = $node;
if ($GLOBALS['cfg']['NavigationTreeEnableGrouping']
&& $GLOBALS['cfg']['ShowDatabasesNavigationAsTree']
@ -178,7 +185,7 @@ class NavigationTree
$query,
(int)$GLOBALS['cfg']['FirstLevelNavigationItems'],
(int)$GLOBALS['cfg']['FirstLevelNavigationItems'],
PMA\libraries\Util::sqlAddSlashes($GLOBALS['db'])
Util::sqlAddSlashes($GLOBALS['db'])
)
);
@ -275,7 +282,7 @@ class NavigationTree
);
$hiddenCounts = $this->_tree->getNavigationHidingData();
foreach ($data as $db) {
$node = NodeFactory::getInstance('Node_Database', $db);
$node = NodeFactory::getInstance('PMA\libraries\navigation\nodes\NodeDatabase', $db);
if (isset($hiddenCounts[$db])) {
$node->setHiddenCount($hiddenCounts[$db]);
}
@ -328,7 +335,7 @@ class NavigationTree
}
array_shift($path); // remove 'root'
/* @var $db Node_Database */
/* @var $db NodeDatabase */
$db = $this->_tree->getChild($path[0]);
$retval = $db;
@ -367,31 +374,31 @@ class NavigationTree
switch ($container->real_name) {
case 'events':
$node = NodeFactory::getInstance(
'Node_Event',
'PMA\libraries\navigation\nodes\NodeEvent',
$item
);
break;
case 'functions':
$node = NodeFactory::getInstance(
'Node_Function',
'PMA\libraries\navigation\nodes\NodeFunction',
$item
);
break;
case 'procedures':
$node = NodeFactory::getInstance(
'Node_Procedure',
'PMA\libraries\navigation\nodes\NodeProcedure',
$item
);
break;
case 'tables':
$node = NodeFactory::getInstance(
'Node_Table',
'PMA\libraries\navigation\nodes\NodeTable',
$item
);
break;
case 'views':
$node = NodeFactory::getInstance(
'Node_View',
'PMA\libraries\navigation\nodes\NodeView',
$item
);
break;
@ -417,7 +424,7 @@ class NavigationTree
return $retval;
}
/* @var $table Node_Table */
/* @var $table NodeTable */
$table = $container->getChild($path[0], true);
if ($table === false) {
if (!$db->getPresence('tables', $path[0])) {
@ -425,7 +432,7 @@ class NavigationTree
}
$node = NodeFactory::getInstance(
'Node_Table',
'PMA\libraries\navigation\nodes\NodeTable',
$path[0]
);
if ($type2 == $container->real_name) {
@ -458,19 +465,19 @@ class NavigationTree
switch ($container->real_name) {
case 'indexes':
$node = NodeFactory::getInstance(
'Node_Index',
'PMA\libraries\navigation\nodes\NodeIndex',
$item
);
break;
case 'columns':
$node = NodeFactory::getInstance(
'Node_Column',
'PMA\libraries\navigation\nodes\NodeColumn',
$item
);
break;
case 'triggers':
$node = NodeFactory::getInstance(
'Node_Trigger',
'PMA\libraries\navigation\nodes\NodeTrigger',
$item
);
break;
@ -495,7 +502,7 @@ class NavigationTree
* References to existing children are returned
* if this function is called twice on the same node
*
* @param Node_Table $table The table node, new containers will be
* @param NodeTable $table The table node, new containers will be
* attached to this node
* @param int $pos2 The position for the pagination of
* the branch at the second level of the tree
@ -512,17 +519,17 @@ class NavigationTree
if ($table->hasChildren(true) == 0) {
if ($table->getPresence('columns')) {
$retval['columns'] = NodeFactory::getInstance(
'Node_Column_Container'
'PMA\libraries\navigation\nodes\NodeColumn_Container'
);
}
if ($table->getPresence('indexes')) {
$retval['indexes'] = NodeFactory::getInstance(
'Node_Index_Container'
'PMA\libraries\navigation\nodes\NodeIndex_Container'
);
}
if ($table->getPresence('triggers')) {
$retval['triggers'] = NodeFactory::getInstance(
'Node_Trigger_Container'
'PMA\libraries\navigation\nodes\NodeTrigger_Container'
);
}
// Add all new Nodes to the tree
@ -551,7 +558,7 @@ class NavigationTree
* References to existing children are returned
* if this function is called twice on the same node
*
* @param Node_Database $db The database node, new containers will be
* @param NodeDatabase $db The database node, new containers will be
* attached to this node
* @param string $type The type of item being paginated on
* the second level of the tree
@ -594,27 +601,27 @@ class NavigationTree
if ($db->hasChildren(true) == 0) {
if (!in_array('tables', $hidden) && $db->getPresence('tables')) {
$retval['tables'] = NodeFactory::getInstance(
'Node_Table_Container'
'PMA\libraries\navigation\nodes\NodeTable_Container'
);
}
if (!in_array('views', $hidden) && $db->getPresence('views')) {
$retval['views'] = NodeFactory::getInstance(
'Node_View_Container'
'PMA\libraries\navigation\nodes\NodeView_Container'
);
}
if (!in_array('functions', $hidden) && $db->getPresence('functions')) {
$retval['functions'] = NodeFactory::getInstance(
'Node_Function_Container'
'PMA\libraries\navigation\nodes\NodeFunction_Container'
);
}
if (!in_array('procedures', $hidden) && $db->getPresence('procedures')) {
$retval['procedures'] = NodeFactory::getInstance(
'Node_Procedure_Container'
'PMA\libraries\navigation\nodes\NodeProcedure_Container'
);
}
if (!in_array('events', $hidden) && $db->getPresence('events')) {
$retval['events'] = NodeFactory::getInstance(
'Node_Event_Container'
'PMA\libraries\navigation\nodes\NodeEvent_Container'
);
}
// Add all new Nodes to the tree
@ -760,13 +767,13 @@ class NavigationTree
);
$groups[$key]->separator = $node->separator;
$groups[$key]->separator_depth = $node->separator_depth - 1;
$groups[$key]->icon = PMA\libraries\Util::getImage(
$groups[$key]->icon = Util::getImage(
'b_group.png'
);
$groups[$key]->pos2 = $node->pos2;
$groups[$key]->pos3 = $node->pos3;
if ($node instanceof Node_Table_Container
|| $node instanceof Node_View_Container
if ($node instanceof NodeTableContainer
|| $node instanceof NodeViewContainer
) {
$tblGroup = '&amp;tbl_group=' . urlencode($key);
$groups[$key]->links = array(
@ -806,7 +813,7 @@ class NavigationTree
)
);
if ($new_child instanceof Node_Database
if ($new_child instanceof NodeDatabase
&& $child->getHiddenCount() > 0
) {
$new_child->setHiddenCount($child->getHiddenCount());
@ -948,7 +955,7 @@ class NavigationTree
),
$results
);
PMA\libraries\Response::getInstance()
Response::getInstance()
->addJSON(
'results',
$results
@ -1247,7 +1254,7 @@ class NavigationTree
$this->_tree->is_group = false;
$retval .= '<div id="pma_navigation_select_database">';
// Provide for pagination in database select
$retval .= PMA\libraries\Util::getListNavigator(
$retval .= Util::getListNavigator(
$this->_tree->getPresence('databases', ''),
$this->_pos,
array('server' => $GLOBALS['server']),
@ -1431,7 +1438,7 @@ class NavigationTree
$retval = '<!-- CONTROLS START -->';
$retval .= '<li id="navigation_controls_outer">';
$retval .= '<div id="navigation_controls">';
$retval .= PMA\libraries\Util::getNavigationLink(
$retval .= Util::getNavigationLink(
'#',
$showText,
__('Collapse all'),
@ -1445,7 +1452,7 @@ class NavigationTree
$syncImage = 's_link.png';
$title = __('Unlink from main panel');
}
$retval .= PMA\libraries\Util::getNavigationLink(
$retval .= Util::getNavigationLink(
'#',
$showText,
$title,
@ -1472,7 +1479,7 @@ class NavigationTree
{
$retval = '';
if ($node === $this->_tree) {
$retval .= PMA\libraries\Util::getListNavigator(
$retval .= Util::getListNavigator(
$this->_tree->getPresence('databases', $this->_searchClause),
$this->_pos,
array('server' => $GLOBALS['server']),
@ -1506,7 +1513,7 @@ class NavigationTree
$node->real_name,
$this->_searchClause2
);
$retval .= PMA\libraries\Util::getListNavigator(
$retval .= Util::getListNavigator(
$num,
$pos,
$_url_params,

View File

@ -7,9 +7,7 @@
*/
namespace PMA\libraries\navigation;
use Node;
require_once 'libraries/navigation/Nodes/Node.class.php';
use PMA\libraries\navigation\nodes\Node;
/**
* Node factory - instantiates Node objects or objects derived from the Node class
@ -23,7 +21,7 @@ class NodeFactory
* that contain various Node classes
* @access private
*/
private static $_path = 'libraries/navigation/Nodes/%s.class.php';
private static $_path = 'libraries/navigation/nodes/%s.php';
/**
* Sanitizes the name of a Node class
@ -34,12 +32,12 @@ class NodeFactory
*/
private static function _sanitizeClass($class)
{
if ($class !== 'Node' && !preg_match('@^Node_\w+(_\w+)?$@', $class)) {
$class = 'Node';
if ($class !== 'PMA\libraries\navigation\nodes\Node' && !preg_match('@^Node\w+(_\w+)?$@', $class)) {
$class = 'PMA\libraries\navigation\nodes\Node';
trigger_error(
sprintf(
/* l10n: The word "Node" must not be translated here */
__('Invalid class name "%1$s", using default of "Node"'),
__('Invalid class name "%1$s", using default of "PMA\libraries\navigation\nodes\Node"'),
$class
),
E_USER_ERROR
@ -62,12 +60,12 @@ class NodeFactory
{
$path = sprintf(self::$_path, $class);
if (!is_readable($path)) {
$class = 'Node';
$class = 'PMA\libraries\navigation\nodes\Node';
trigger_error(
sprintf(
__('Could not include class "%1$s", file "%2$s" not found'),
$class,
'Nodes/' . $class . '.class.php'
'Nodes/' . $class . '.php'
),
E_USER_ERROR
);
@ -88,14 +86,12 @@ class NodeFactory
* @return mixed
*/
public static function getInstance(
$class = 'Node',
$class = 'PMA\libraries\navigation\nodes\Node',
$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

@ -5,7 +5,11 @@
*
* @package PhpMyAdmin-Navigation
*/
if (! defined('PHPMYADMIN')) {
namespace PMA\libraries\navigation\nodes;
use PMA\libraries\Util;
if (!defined('PHPMYADMIN')) {
exit;
}
@ -20,97 +24,80 @@ class Node
* @var int Defines a possible node type
*/
const CONTAINER = 0;
/**
* @var int Defines a possible node type
*/
const OBJECT = 1;
/**
* @var string A non-unique identifier for the node
* This may be trimmed when grouping nodes
*/
public $name = "";
/**
* @var string A non-unique identifier for the node
* This will never change after being assigned
*/
public $real_name = "";
/**
* @var int May be one of CONTAINER or OBJECT
*/
public $type = Node::OBJECT;
/**
* @var bool Whether this object has been created while grouping nodes
* Only relevant if the node is of type CONTAINER
*/
public $is_group;
/**
* @var bool Whether to add a "display: none;" CSS
* rule to the node when rendering it
*/
public $visible = false;
/**
* @var Node A reference to the parent object of
* this node, NULL for the root node.
*/
public $parent;
/**
* @var Node[] An array of Node objects that are
* direct children of this node
*/
public $children = array();
/**
* @var Mixed A string used to group nodes, or an array of strings
* Only relevant if the node is of type CONTAINER
*/
public $separator = '';
/**
* @var int How many time to recursively apply the grouping function
* Only relevant if the node is of type CONTAINER
*/
public $separator_depth = 1;
/**
* @var string An IMG tag, used when rendering the node
*/
public $icon;
/**
* @var Array An array of A tags, used when rendering the node
* The indexes in the array may be 'icon' and 'text'
*/
public $links;
/**
* @var string HTML title
*/
public $title;
/**
* @var string Extra CSS classes for the node
*/
public $classes = '';
/**
* @var bool Whether this node is a link for creating new objects
*/
public $isNew = false;
/**
* @var int The position for the pagination of
* the branch at the second level of the tree
*/
public $pos2 = 0;
/**
* @var int The position for the pagination of
* the branch at the third level of the tree
@ -127,8 +114,8 @@ class Node
*/
public function __construct($name, $type = Node::OBJECT, $is_group = false)
{
if (! empty($name)) {
$this->name = $name;
if (!empty($name)) {
$this->name = $name;
$this->real_name = $name;
}
if ($type === Node::CONTAINER) {
@ -147,7 +134,7 @@ class Node
public function addChild($child)
{
$this->children[] = $child;
$child->parent = $this;
$child->parent = $this;
}
/**
@ -175,6 +162,7 @@ class Node
}
}
}
return false;
}
@ -222,6 +210,7 @@ class Node
}
$parent = $parent->parent;
}
return $parents;
}
@ -265,6 +254,7 @@ class Node
}
}
}
return $retval;
}
@ -281,9 +271,10 @@ class Node
public function hasSiblings()
{
$retval = false;
$paths = $this->getPaths();
$paths = $this->getPaths();
if (count($paths['aPath_clean']) > 3) {
$retval = true;
return $retval;
}
@ -295,6 +286,7 @@ class Node
break;
}
}
return $retval;
}
@ -313,6 +305,7 @@ class Node
$retval += $child->numChildren();
}
}
return $retval;
}
@ -324,35 +317,35 @@ class Node
*/
public function getPaths()
{
$aPath = array();
$aPath = array();
$aPath_clean = array();
foreach ($this->parents(true, true, false) as $parent) {
$aPath[] = base64_encode($parent->real_name);
$aPath[] = base64_encode($parent->real_name);
$aPath_clean[] = $parent->real_name;
}
$aPath = implode('.', array_reverse($aPath));
$aPath = implode('.', array_reverse($aPath));
$aPath_clean = array_reverse($aPath_clean);
$vPath = array();
$vPath = array();
$vPath_clean = array();
foreach ($this->parents(true, true, true) as $parent) {
$vPath[] = base64_encode($parent->name);
$vPath[] = base64_encode($parent->name);
$vPath_clean[] = $parent->name;
}
$vPath = implode('.', array_reverse($vPath));
$vPath = implode('.', array_reverse($vPath));
$vPath_clean = array_reverse($vPath_clean);
return array(
'aPath' => $aPath,
'aPath' => $aPath,
'aPath_clean' => $aPath_clean,
'vPath' => $vPath,
'vPath_clean' => $vPath_clean
'vPath' => $vPath,
'vPath_clean' => $vPath_clean,
);
}
/**
* Returns the names of children of type $type present inside this container
* This method is overridden by the Node_Database and Node_Table classes
* This method is overridden by the PMA\libraries\navigation\nodes\NodeDatabase and PMA\libraries\navigation\nodes\NodeTable classes
*
* @param string $type The type of item we are looking for
* ('tables', 'views', etc)
@ -368,14 +361,15 @@ class Node
|| !$GLOBALS['cfg']['ShowDatabasesNavigationAsTree']
) {
if (isset($GLOBALS['cfg']['Server']['DisableIS'])
&& ! $GLOBALS['cfg']['Server']['DisableIS']
&& !$GLOBALS['cfg']['Server']['DisableIS']
) {
$query = "SELECT `SCHEMA_NAME` ";
$query = "SELECT `SCHEMA_NAME` ";
$query .= "FROM `INFORMATION_SCHEMA`.`SCHEMATA` ";
$query .= $this->_getWhereClause('SCHEMA_NAME', $searchClause);
$query .= "ORDER BY `SCHEMA_NAME` ";
$query .= "LIMIT $pos, $maxItems";
$retval = $GLOBALS['dbi']->fetchResult($query);
return $retval;
}
@ -430,14 +424,15 @@ class Node
}
}
sort($retval);
return $retval;
}
$dbSeparator = $GLOBALS['cfg']['NavigationTreeDbSeparator'];
if (isset($GLOBALS['cfg']['Server']['DisableIS'])
&& ! $GLOBALS['cfg']['Server']['DisableIS']
&& !$GLOBALS['cfg']['Server']['DisableIS']
) {
$query = "SELECT `SCHEMA_NAME` ";
$query = "SELECT `SCHEMA_NAME` ";
$query .= "FROM `INFORMATION_SCHEMA`.`SCHEMATA`, ";
$query .= "(";
$query .= "SELECT DB_first_level ";
@ -457,6 +452,7 @@ class Node
$query .= "'$dbSeparator')) ";
$query .= "ORDER BY SCHEMA_NAME ASC";
$retval = $GLOBALS['dbi']->fetchResult($query);
return $retval;
}
@ -487,11 +483,13 @@ class Node
$subClauses = array();
foreach ($prefixes as $prefix) {
$subClauses[] = " LOCATE('"
. PMA\libraries\Util::sqlAddSlashes($prefix) . $dbSeparator . "', "
. Util::sqlAddSlashes($prefix) . $dbSeparator
. "', "
. "CONCAT(`Database`, '" . $dbSeparator . "')) = 1 ";
}
$query .= implode("OR", $subClauses) . ")";
$retval = $GLOBALS['dbi']->fetchResult($query);
return $retval;
}
@ -538,9 +536,9 @@ class Node
foreach ($prefixes as $prefix) {
$starts_with = strpos(
$arr[0] . $dbSeparator,
$prefix . $dbSeparator
) === 0;
$arr[0] . $dbSeparator,
$prefix . $dbSeparator
) === 0;
if ($starts_with) {
$retval[] = $arr[0];
break;
@ -555,7 +553,7 @@ class Node
/**
* Returns the number of children of type $type present inside this container
* This method is overridden by the Node_Database and Node_Table classes
* This method is overridden by the PMA\libraries\navigation\nodes\NodeDatabase and PMA\libraries\navigation\nodes\NodeTable classes
*
* @param string $type The type of item we are looking for
* ('tables', 'views', etc)
@ -569,12 +567,13 @@ class Node
|| !$GLOBALS['cfg']['ShowDatabasesNavigationAsTree']
) {
if (isset($GLOBALS['cfg']['Server']['DisableIS'])
&& ! $GLOBALS['cfg']['Server']['DisableIS']
&& !$GLOBALS['cfg']['Server']['DisableIS']
) {
$query = "SELECT COUNT(*) ";
$query .= "FROM INFORMATION_SCHEMA.SCHEMATA ";
$query .= $this->_getWhereClause('SCHEMA_NAME', $searchClause);
$retval = (int)$GLOBALS['dbi']->fetchValue($query);
return $retval;
}
@ -584,6 +583,7 @@ class Node
$retval = $GLOBALS['dbi']->numRows(
$GLOBALS['dbi']->tryQuery($query)
);
return $retval;
}
@ -594,11 +594,12 @@ class Node
$GLOBALS['dbi']->tryQuery($query)
);
}
return $retval;
}
$dbSeparator = $GLOBALS['cfg']['NavigationTreeDbSeparator'];
if (! $GLOBALS['cfg']['Server']['DisableIS']) {
if (!$GLOBALS['cfg']['Server']['DisableIS']) {
$query = "SELECT COUNT(*) ";
$query .= "FROM ( ";
$query .= "SELECT DISTINCT SUBSTRING_INDEX(SCHEMA_NAME, ";
@ -608,6 +609,7 @@ class Node
$query .= $this->_getWhereClause('SCHEMA_NAME', $searchClause);
$query .= ") t ";
$retval = (int)$GLOBALS['dbi']->fetchValue($query);
return $retval;
}
@ -632,6 +634,7 @@ class Node
}
}
$retval = count($prefixMap);
return $retval;
}
@ -662,11 +665,12 @@ class Node
*/
private function _isHideDb($db)
{
if (! empty($GLOBALS['cfg']['Server']['hide_db'])
if (!empty($GLOBALS['cfg']['Server']['hide_db'])
&& preg_match('/' . $GLOBALS['cfg']['Server']['hide_db'] . '/', $db)
) {
return true;
}
return false;
}
@ -682,16 +686,17 @@ class Node
*/
private function _getDatabasesToSearch($searchClause)
{
if (! empty($searchClause)) {
if (!empty($searchClause)) {
$databases = array(
"%" . PMA\libraries\Util::sqlAddSlashes($searchClause, true) . "%"
"%" . Util::sqlAddSlashes($searchClause, true) . "%",
);
} elseif (! empty($GLOBALS['cfg']['Server']['only_db'])) {
} elseif (!empty($GLOBALS['cfg']['Server']['only_db'])) {
$databases = $GLOBALS['cfg']['Server']['only_db'];
} elseif (! empty($GLOBALS['dbs_to_test'])) {
} elseif (!empty($GLOBALS['dbs_to_test'])) {
$databases = $GLOBALS['dbs_to_test'];
}
sort($databases);
return $databases;
}
@ -707,33 +712,37 @@ class Node
private function _getWhereClause($columnName, $searchClause = '')
{
$whereClause = "WHERE TRUE ";
if (! empty($searchClause)) {
$whereClause .= "AND " . PMA\libraries\Util::backquote($columnName) . " LIKE '%";
$whereClause .= PMA\libraries\Util::sqlAddSlashes(
$searchClause, true
if (!empty($searchClause)) {
$whereClause .= "AND " . Util::backquote($columnName)
. " LIKE '%";
$whereClause .= Util::sqlAddSlashes(
$searchClause,
true
);
$whereClause .= "%' ";
}
if (! empty($GLOBALS['cfg']['Server']['hide_db'])) {
$whereClause .= "AND " . PMA\libraries\Util::backquote($columnName)
if (!empty($GLOBALS['cfg']['Server']['hide_db'])) {
$whereClause .= "AND " . Util::backquote($columnName)
. " NOT REGEXP '" . $GLOBALS['cfg']['Server']['hide_db'] . "' ";
}
if (! empty($GLOBALS['cfg']['Server']['only_db'])) {
if (!empty($GLOBALS['cfg']['Server']['only_db'])) {
if (is_string($GLOBALS['cfg']['Server']['only_db'])) {
$GLOBALS['cfg']['Server']['only_db'] = array(
$GLOBALS['cfg']['Server']['only_db']
$GLOBALS['cfg']['Server']['only_db'],
);
}
$whereClause .= "AND (";
$subClauses = array();
foreach ($GLOBALS['cfg']['Server']['only_db'] as $each_only_db) {
$subClauses[] = " " . PMA\libraries\Util::backquote($columnName) . " LIKE '"
$subClauses[] = " " . Util::backquote($columnName)
. " LIKE '"
. $each_only_db . "' ";
}
$whereClause .= implode("OR", $subClauses) . ")";
}
return $whereClause;
}
@ -756,7 +765,7 @@ class Node
*/
public function getCssClasses($match)
{
if (! $GLOBALS['cfg']['NavigationTreeEnableExpansion']
if (!$GLOBALS['cfg']['NavigationTreeEnableExpansion']
) {
return '';
}
@ -782,14 +791,15 @@ class Node
*/
public function getIcon($match)
{
if (! $GLOBALS['cfg']['NavigationTreeEnableExpansion']
if (!$GLOBALS['cfg']['NavigationTreeEnableExpansion']
) {
return '';
} elseif ($match && ! $this->is_group) {
} elseif ($match && !$this->is_group) {
$this->visible = true;
return PMA\libraries\Util::getImage('b_minus.png');
return Util::getImage('b_minus.png');
} else {
return PMA\libraries\Util::getImage('b_plus.png', __('Expand/Collapse'));
return Util::getImage('b_plus.png', __('Expand/Collapse'));
}
}
@ -802,17 +812,26 @@ class Node
{
$cfgRelation = PMA_getRelationsParam();
if ($cfgRelation['navwork']) {
$navTable = PMA\libraries\Util::backquote($cfgRelation['db'])
. "." . PMA\libraries\Util::backquote($cfgRelation['navigationhiding']);
$navTable = Util::backquote($cfgRelation['db'])
. "." . Util::backquote(
$cfgRelation['navigationhiding']
);
$sqlQuery = "SELECT `db_name`, COUNT(*) AS `count` FROM " . $navTable
. " WHERE `username`='"
. PMA\libraries\Util::sqlAddSlashes($GLOBALS['cfg']['Server']['user']) . "'"
. " GROUP BY `db_name`";
. " WHERE `username`='"
. Util::sqlAddSlashes(
$GLOBALS['cfg']['Server']['user']
) . "'"
. " GROUP BY `db_name`";
$counts = $GLOBALS['dbi']->fetchResult(
$sqlQuery, 'db_name', 'count', $GLOBALS['controllink']
$sqlQuery,
'db_name',
'count',
$GLOBALS['controllink']
);
return $counts;
}
return null;
}
}

View File

@ -5,7 +5,11 @@
*
* @package PhpMyAdmin-Navigation
*/
if (! defined('PHPMYADMIN')) {
namespace PMA\libraries\navigation\nodes;
use PMA;
if (!defined('PHPMYADMIN')) {
exit;
}
@ -14,7 +18,7 @@ if (! defined('PHPMYADMIN')) {
*
* @package PhpMyAdmin-Navigation
*/
class Node_Column extends Node
class NodeColumn extends Node
{
/**
* Initialises the class
@ -27,17 +31,17 @@ class Node_Column extends Node
public function __construct($name, $type = Node::OBJECT, $is_group = false)
{
parent::__construct($name, $type, $is_group);
$this->icon = PMA\libraries\Util::getImage('pause.png', __('Column'));
$this->icon = PMA\libraries\Util::getImage('pause.png', __('Column'));
$this->links = array(
'text' => 'tbl_structure.php?server=' . $GLOBALS['server']
. '&amp;db=%3$s&amp;table=%2$s&amp;field=%1$s'
. '&amp;change_column=1'
. '&amp;token=' . $_SESSION[' PMA_token '],
'icon' => 'tbl_structure.php?server=' . $GLOBALS['server']
. '&amp;db=%3$s&amp;table=%2$s&amp;field=%1$s'
. '&amp;change_column=1'
. '&amp;token=' . $_SESSION[' PMA_token '],
'title' => __('Structure')
'text' => 'tbl_structure.php?server=' . $GLOBALS['server']
. '&amp;db=%3$s&amp;table=%2$s&amp;field=%1$s'
. '&amp;change_column=1'
. '&amp;token=' . $_SESSION[' PMA_token '],
'icon' => 'tbl_structure.php?server=' . $GLOBALS['server']
. '&amp;db=%3$s&amp;table=%2$s&amp;field=%1$s'
. '&amp;change_column=1'
. '&amp;token=' . $_SESSION[' PMA_token '],
'title' => __('Structure'),
);
}
}

View File

@ -5,9 +5,13 @@
*
* @package PhpMyAdmin-Navigation
*/
use PMA\libraries\navigation\NodeFactory;
namespace PMA\libraries\navigation\nodes;
if (! defined('PHPMYADMIN')) {
use PMA;
use PMA\libraries\navigation\NodeFactory;
use PMA\libraries\Util;
if (!defined('PHPMYADMIN')) {
exit;
}
@ -16,7 +20,7 @@ if (! defined('PHPMYADMIN')) {
*
* @package PhpMyAdmin-Navigation
*/
class Node_Column_Container extends Node
class NodeColumnContainer extends Node
{
/**
* Initialises the class
@ -24,30 +28,33 @@ class Node_Column_Container extends Node
public function __construct()
{
parent::__construct(__('Columns'), Node::CONTAINER);
$this->icon = PMA\libraries\Util::getImage('pause.png', __('Columns'));
$this->icon = Util::getImage('pause.png', __('Columns'));
$this->links = array(
'text' => 'tbl_structure.php?server=' . $GLOBALS['server']
. '&amp;db=%2$s&amp;table=%1$s'
. '&amp;token=' . $_SESSION[' PMA_token '],
. '&amp;db=%2$s&amp;table=%1$s'
. '&amp;token=' . $_SESSION[' PMA_token '],
'icon' => 'tbl_structure.php?server=' . $GLOBALS['server']
. '&amp;db=%2$s&amp;table=%1$s'
. '&amp;token=' . $_SESSION[' PMA_token '],
. '&amp;db=%2$s&amp;table=%1$s'
. '&amp;token=' . $_SESSION[' PMA_token '],
);
$this->real_name = 'columns';
$new_label = _pgettext('Create new column', 'New');
$new = NodeFactory::getInstance('Node', $new_label);
$new = NodeFactory::getInstance(
'PMA\libraries\navigation\nodes\Node',
$new_label
);
$new->isNew = true;
$new->icon = PMA\libraries\Util::getImage('b_column_add.png', $new_label);
$new->icon = Util::getImage('b_column_add.png', $new_label);
$new->links = array(
'text' => 'tbl_addfield.php?server=' . $GLOBALS['server']
. '&amp;db=%3$s&amp;table=%2$s'
. '&amp;field_where=last&after_field='
. '&amp;token=' . $_SESSION[' PMA_token '],
. '&amp;db=%3$s&amp;table=%2$s'
. '&amp;field_where=last&after_field='
. '&amp;token=' . $_SESSION[' PMA_token '],
'icon' => 'tbl_addfield.php?server=' . $GLOBALS['server']
. '&amp;db=%3$s&amp;table=%2$s'
. '&amp;field_where=last&after_field='
. '&amp;token=' . $_SESSION[' PMA_token '],
. '&amp;db=%3$s&amp;table=%2$s'
. '&amp;field_where=last&after_field='
. '&amp;token=' . $_SESSION[' PMA_token '],
);
$new->classes = 'new_column italics';
$this->addChild($new);

View File

@ -5,16 +5,16 @@
*
* @package PhpMyAdmin-Navigation
*/
if (! defined('PHPMYADMIN')) {
exit;
}
namespace PMA\libraries\navigation\nodes;
use PMA\libraries\Util;
/**
* Represents a database node in the navigation tree
*
* @package PhpMyAdmin-Navigation
*/
class Node_Database extends Node
class NodeDatabase extends Node
{
/**
* The number of hidden items in this database
@ -34,28 +34,30 @@ class Node_Database extends Node
public function __construct($name, $type = Node::OBJECT, $is_group = false)
{
parent::__construct($name, $type, $is_group);
$this->icon = PMA\libraries\Util::getImage(
$this->icon = Util::getImage(
's_db.png',
__('Database operations')
);
$script_name = PMA\libraries\Util::getScriptNameForOption(
$GLOBALS['cfg']['DefaultTabDatabase'], 'database'
$script_name = Util::getScriptNameForOption(
$GLOBALS['cfg']['DefaultTabDatabase'],
'database'
);
$this->links = array(
'text' => $script_name
. '?server=' . $GLOBALS['server']
. '&amp;db=%1$s&amp;token=' . $_SESSION[' PMA_token '],
'icon' => 'db_operations.php?server=' . $GLOBALS['server']
. '&amp;db=%1$s&amp;token=' . $_SESSION[' PMA_token '],
'title' => __('Structure')
'text' => $script_name
. '?server=' . $GLOBALS['server']
. '&amp;db=%1$s&amp;token=' . $_SESSION[' PMA_token '],
'icon' => 'db_operations.php?server=' . $GLOBALS['server']
. '&amp;db=%1$s&amp;token=' . $_SESSION[' PMA_token '],
'title' => __('Structure'),
);
$this->classes = 'database';
}
/**
* Returns the number of children of type $type present inside this container
* This method is overridden by the Node_Database and Node_Table classes
* This method is overridden by the PMA\libraries\navigation\nodes\NodeDatabase
* and PMA\libraries\navigation\nodes\NodeTable classes
*
* @param string $type The type of item we are looking for
* ('tables', 'views', etc)
@ -88,6 +90,7 @@ class Node_Database extends Node
default:
break;
}
return $retval;
}
@ -104,16 +107,16 @@ class Node_Database extends Node
*/
private function _getTableOrViewCount($which, $searchClause, $singleItem)
{
$db = $this->real_name;
$db = $this->real_name;
if ($which == 'tables') {
$condition = '=';
} else {
$condition = '!=';
}
if (! $GLOBALS['cfg']['Server']['DisableIS'] || PMA_DRIZZLE) {
$db = PMA\libraries\Util::sqlAddSlashes($db);
$query = "SELECT COUNT(*) ";
if (!$GLOBALS['cfg']['Server']['DisableIS'] || PMA_DRIZZLE) {
$db = Util::sqlAddSlashes($db);
$query = "SELECT COUNT(*) ";
$query .= "FROM `INFORMATION_SCHEMA`.`TABLES` ";
$query .= "WHERE `TABLE_SCHEMA`='$db' ";
if (PMA_DRIZZLE) {
@ -121,25 +124,30 @@ class Node_Database extends Node
} else {
$query .= "AND `TABLE_TYPE`" . $condition . "'BASE TABLE' ";
}
if (! empty($searchClause)) {
if (!empty($searchClause)) {
$query .= "AND " . $this->_getWhereClauseForSearch(
$searchClause, $singleItem, 'TABLE_NAME'
);
$searchClause,
$singleItem,
'TABLE_NAME'
);
}
$retval = (int)$GLOBALS['dbi']->fetchValue($query);
} else {
$query = "SHOW FULL TABLES FROM ";
$query .= PMA\libraries\Util::backquote($db);
$query = "SHOW FULL TABLES FROM ";
$query .= Util::backquote($db);
$query .= " WHERE `Table_type`" . $condition . "'BASE TABLE' ";
if (! empty($searchClause)) {
if (!empty($searchClause)) {
$query .= "AND " . $this->_getWhereClauseForSearch(
$searchClause, $singleItem, 'Tables_in_' . $db
);
$searchClause,
$singleItem,
'Tables_in_' . $db
);
}
$retval = $GLOBALS['dbi']->numRows(
$GLOBALS['dbi']->tryQuery($query)
);
}
return $retval;
}
@ -156,7 +164,9 @@ class Node_Database extends Node
private function _getTableCount($searchClause, $singleItem)
{
return $this->_getTableOrViewCount(
'tables', $searchClause, $singleItem
'tables',
$searchClause,
$singleItem
);
}
@ -173,7 +183,9 @@ class Node_Database extends Node
private function _getViewCount($searchClause, $singleItem)
{
return $this->_getTableOrViewCount(
'views', $searchClause, $singleItem
'views',
$searchClause,
$singleItem
);
}
@ -189,32 +201,37 @@ class Node_Database extends Node
*/
private function _getProcedureCount($searchClause, $singleItem)
{
$db = $this->real_name;
if (! $GLOBALS['cfg']['Server']['DisableIS']) {
$db = PMA\libraries\Util::sqlAddSlashes($db);
$query = "SELECT COUNT(*) ";
$db = $this->real_name;
if (!$GLOBALS['cfg']['Server']['DisableIS']) {
$db = Util::sqlAddSlashes($db);
$query = "SELECT COUNT(*) ";
$query .= "FROM `INFORMATION_SCHEMA`.`ROUTINES` ";
$query .= "WHERE `ROUTINE_SCHEMA` "
. PMA\libraries\Util::getCollateForIS() . "='$db'";
. Util::getCollateForIS() . "='$db'";
$query .= "AND `ROUTINE_TYPE`='PROCEDURE' ";
if (! empty($searchClause)) {
if (!empty($searchClause)) {
$query .= "AND " . $this->_getWhereClauseForSearch(
$searchClause, $singleItem, 'ROUTINE_NAME'
);
$searchClause,
$singleItem,
'ROUTINE_NAME'
);
}
$retval = (int)$GLOBALS['dbi']->fetchValue($query);
} else {
$db = PMA\libraries\Util::sqlAddSlashes($db);
$db = Util::sqlAddSlashes($db);
$query = "SHOW PROCEDURE STATUS WHERE `Db`='$db' ";
if (! empty($searchClause)) {
if (!empty($searchClause)) {
$query .= "AND " . $this->_getWhereClauseForSearch(
$searchClause, $singleItem, 'Name'
);
$searchClause,
$singleItem,
'Name'
);
}
$retval = $GLOBALS['dbi']->numRows(
$GLOBALS['dbi']->tryQuery($query)
);
}
return $retval;
}
@ -230,32 +247,37 @@ class Node_Database extends Node
*/
private function _getFunctionCount($searchClause, $singleItem)
{
$db = $this->real_name;
if (! $GLOBALS['cfg']['Server']['DisableIS']) {
$db = PMA\libraries\Util::sqlAddSlashes($db);
$query = "SELECT COUNT(*) ";
$db = $this->real_name;
if (!$GLOBALS['cfg']['Server']['DisableIS']) {
$db = Util::sqlAddSlashes($db);
$query = "SELECT COUNT(*) ";
$query .= "FROM `INFORMATION_SCHEMA`.`ROUTINES` ";
$query .= "WHERE `ROUTINE_SCHEMA` "
. PMA\libraries\Util::getCollateForIS() . "='$db' ";
. Util::getCollateForIS() . "='$db' ";
$query .= "AND `ROUTINE_TYPE`='FUNCTION' ";
if (! empty($searchClause)) {
if (!empty($searchClause)) {
$query .= "AND " . $this->_getWhereClauseForSearch(
$searchClause, $singleItem, 'ROUTINE_NAME'
);
$searchClause,
$singleItem,
'ROUTINE_NAME'
);
}
$retval = (int)$GLOBALS['dbi']->fetchValue($query);
} else {
$db = PMA\libraries\Util::sqlAddSlashes($db);
$db = Util::sqlAddSlashes($db);
$query = "SHOW FUNCTION STATUS WHERE `Db`='$db' ";
if (! empty($searchClause)) {
if (!empty($searchClause)) {
$query .= "AND " . $this->_getWhereClauseForSearch(
$searchClause, $singleItem, 'Name'
);
$searchClause,
$singleItem,
'Name'
);
}
$retval = $GLOBALS['dbi']->numRows(
$GLOBALS['dbi']->tryQuery($query)
);
}
return $retval;
}
@ -271,31 +293,36 @@ class Node_Database extends Node
*/
private function _getEventCount($searchClause, $singleItem)
{
$db = $this->real_name;
if (! $GLOBALS['cfg']['Server']['DisableIS']) {
$db = PMA\libraries\Util::sqlAddSlashes($db);
$query = "SELECT COUNT(*) ";
$db = $this->real_name;
if (!$GLOBALS['cfg']['Server']['DisableIS']) {
$db = Util::sqlAddSlashes($db);
$query = "SELECT COUNT(*) ";
$query .= "FROM `INFORMATION_SCHEMA`.`EVENTS` ";
$query .= "WHERE `EVENT_SCHEMA` "
. PMA\libraries\Util::getCollateForIS() . "='$db' ";
if (! empty($searchClause)) {
. Util::getCollateForIS() . "='$db' ";
if (!empty($searchClause)) {
$query .= "AND " . $this->_getWhereClauseForSearch(
$searchClause, $singleItem, 'EVENT_NAME'
);
$searchClause,
$singleItem,
'EVENT_NAME'
);
}
$retval = (int)$GLOBALS['dbi']->fetchValue($query);
} else {
$db = PMA\libraries\Util::backquote($db);
$db = Util::backquote($db);
$query = "SHOW EVENTS FROM $db ";
if (! empty($searchClause)) {
if (!empty($searchClause)) {
$query .= "WHERE " . $this->_getWhereClauseForSearch(
$searchClause, $singleItem, 'Name'
);
$searchClause,
$singleItem,
'Name'
);
}
$retval = $GLOBALS['dbi']->numRows(
$GLOBALS['dbi']->tryQuery($query)
);
}
return $retval;
}
@ -309,22 +336,27 @@ class Node_Database extends Node
* @return string WHERE clause for searching
*/
private function _getWhereClauseForSearch(
$searchClause, $singleItem, $columnName
$searchClause,
$singleItem,
$columnName
) {
$query = '';
if ($singleItem) {
$query .= PMA\libraries\Util::backquote($columnName) . " = ";
$query .= "'" . PMA\libraries\Util::sqlAddSlashes($searchClause) . "'";
$query .= Util::backquote($columnName) . " = ";
$query .= "'" . Util::sqlAddSlashes($searchClause) . "'";
} else {
$query .= PMA\libraries\Util::backquote($columnName) . " LIKE ";
$query .= "'%" . PMA\libraries\Util::sqlAddSlashes($searchClause, true) . "%'";
$query .= Util::backquote($columnName) . " LIKE ";
$query .= "'%" . Util::sqlAddSlashes($searchClause, true)
. "%'";
}
return $query;
}
/**
* Returns the names of children of type $type present inside this container
* This method is overridden by the Node_Database and Node_Table classes
* This method is overridden by the PMA\libraries\navigation\nodes\NodeDatabase
* and PMA\libraries\navigation\nodes\NodeTable classes
*
* @param string $type The type of item we are looking for
* ('tables', 'views', etc)
@ -335,7 +367,7 @@ class Node_Database extends Node
*/
public function getData($type, $pos, $searchClause = '')
{
$retval = array();
$retval = array();
switch ($type) {
case 'tables':
$retval = $this->_getTables($pos, $searchClause);
@ -385,12 +417,13 @@ class Node_Database extends Node
if (empty($cfgRelation['navigationhiding'])) {
return array();
}
$navTable = PMA\libraries\Util::backquote($cfgRelation['db'])
. "." . PMA\libraries\Util::backquote($cfgRelation['navigationhiding']);
$navTable = Util::backquote($cfgRelation['db'])
. "." . Util::backquote($cfgRelation['navigationhiding']);
$sqlQuery = "SELECT `item_name` FROM " . $navTable
. " WHERE `username`='" . $cfgRelation['user'] . "'"
. " AND `item_type`='" . $type
. "'" . " AND `db_name`='" . PMA\libraries\Util::sqlAddSlashes($db) . "'";
. "'" . " AND `db_name`='" . Util::sqlAddSlashes($db)
. "'";
$result = PMA_queryAsControlUser($sqlQuery, false);
$hiddenItems = array();
if ($result) {
@ -399,6 +432,7 @@ class Node_Database extends Node
}
}
$GLOBALS['dbi']->freeResult($result);
return $hiddenItems;
}
@ -419,11 +453,11 @@ class Node_Database extends Node
$condition = '!=';
}
$maxItems = $GLOBALS['cfg']['MaxNavigationItems'];
$retval = array();
$db = $this->real_name;
if (! $GLOBALS['cfg']['Server']['DisableIS'] || PMA_DRIZZLE) {
$escdDb = PMA\libraries\Util::sqlAddSlashes($db);
$query = "SELECT `TABLE_NAME` AS `name` ";
$retval = array();
$db = $this->real_name;
if (!$GLOBALS['cfg']['Server']['DisableIS'] || PMA_DRIZZLE) {
$escdDb = Util::sqlAddSlashes($db);
$query = "SELECT `TABLE_NAME` AS `name` ";
$query .= "FROM `INFORMATION_SCHEMA`.`TABLES` ";
$query .= "WHERE `TABLE_SCHEMA`='$escdDb' ";
if (PMA_DRIZZLE) {
@ -431,10 +465,11 @@ class Node_Database extends Node
} else {
$query .= "AND `TABLE_TYPE`" . $condition . "'BASE TABLE' ";
}
if (! empty($searchClause)) {
if (!empty($searchClause)) {
$query .= "AND `TABLE_NAME` LIKE '%";
$query .= PMA\libraries\Util::sqlAddSlashes(
$searchClause, true
$query .= Util::sqlAddSlashes(
$searchClause,
true
);
$query .= "%'";
}
@ -442,16 +477,17 @@ class Node_Database extends Node
$query .= "LIMIT " . intval($pos) . ", $maxItems";
$retval = $GLOBALS['dbi']->fetchResult($query);
} else {
$query = " SHOW FULL TABLES FROM ";
$query .= PMA\libraries\Util::backquote($db);
$query = " SHOW FULL TABLES FROM ";
$query .= Util::backquote($db);
$query .= " WHERE `Table_type`" . $condition . "'BASE TABLE' ";
if (! empty($searchClause)) {
$query .= "AND " . PMA\libraries\Util::backquote(
"Tables_in_" . $db
);
$query .= " LIKE '%" . PMA\libraries\Util::sqlAddSlashes(
$searchClause, true
);
if (!empty($searchClause)) {
$query .= "AND " . Util::backquote(
"Tables_in_" . $db
);
$query .= " LIKE '%" . Util::sqlAddSlashes(
$searchClause,
true
);
$query .= "%'";
}
$handle = $GLOBALS['dbi']->tryQuery($query);
@ -469,6 +505,7 @@ class Node_Database extends Node
}
}
}
return $retval;
}
@ -510,19 +547,20 @@ class Node_Database extends Node
private function _getRoutines($routineType, $pos, $searchClause)
{
$maxItems = $GLOBALS['cfg']['MaxNavigationItems'];
$retval = array();
$db = $this->real_name;
if (! $GLOBALS['cfg']['Server']['DisableIS']) {
$escdDb = PMA\libraries\Util::sqlAddSlashes($db);
$query = "SELECT `ROUTINE_NAME` AS `name` ";
$retval = array();
$db = $this->real_name;
if (!$GLOBALS['cfg']['Server']['DisableIS']) {
$escdDb = Util::sqlAddSlashes($db);
$query = "SELECT `ROUTINE_NAME` AS `name` ";
$query .= "FROM `INFORMATION_SCHEMA`.`ROUTINES` ";
$query .= "WHERE `ROUTINE_SCHEMA` "
. PMA\libraries\Util::getCollateForIS() . "='$escdDb'";
. Util::getCollateForIS() . "='$escdDb'";
$query .= "AND `ROUTINE_TYPE`='" . $routineType . "' ";
if (! empty($searchClause)) {
if (!empty($searchClause)) {
$query .= "AND `ROUTINE_NAME` LIKE '%";
$query .= PMA\libraries\Util::sqlAddSlashes(
$searchClause, true
$query .= Util::sqlAddSlashes(
$searchClause,
true
);
$query .= "%'";
}
@ -530,12 +568,13 @@ class Node_Database extends Node
$query .= "LIMIT " . intval($pos) . ", $maxItems";
$retval = $GLOBALS['dbi']->fetchResult($query);
} else {
$escdDb = PMA\libraries\Util::sqlAddSlashes($db);
$query = "SHOW " . $routineType . " STATUS WHERE `Db`='$escdDb' ";
if (! empty($searchClause)) {
$escdDb = Util::sqlAddSlashes($db);
$query = "SHOW " . $routineType . " STATUS WHERE `Db`='$escdDb' ";
if (!empty($searchClause)) {
$query .= "AND `Name` LIKE '%";
$query .= PMA\libraries\Util::sqlAddSlashes(
$searchClause, true
$query .= Util::sqlAddSlashes(
$searchClause,
true
);
$query .= "%'";
}
@ -554,6 +593,7 @@ class Node_Database extends Node
}
}
}
return $retval;
}
@ -594,18 +634,19 @@ class Node_Database extends Node
private function _getEvents($pos, $searchClause)
{
$maxItems = $GLOBALS['cfg']['MaxNavigationItems'];
$retval = array();
$db = $this->real_name;
if (! $GLOBALS['cfg']['Server']['DisableIS']) {
$escdDb = PMA\libraries\Util::sqlAddSlashes($db);
$query = "SELECT `EVENT_NAME` AS `name` ";
$retval = array();
$db = $this->real_name;
if (!$GLOBALS['cfg']['Server']['DisableIS']) {
$escdDb = Util::sqlAddSlashes($db);
$query = "SELECT `EVENT_NAME` AS `name` ";
$query .= "FROM `INFORMATION_SCHEMA`.`EVENTS` ";
$query .= "WHERE `EVENT_SCHEMA` "
. PMA\libraries\Util::getCollateForIS() . "='$escdDb' ";
if (! empty($searchClause)) {
. Util::getCollateForIS() . "='$escdDb' ";
if (!empty($searchClause)) {
$query .= "AND `EVENT_NAME` LIKE '%";
$query .= PMA\libraries\Util::sqlAddSlashes(
$searchClause, true
$query .= Util::sqlAddSlashes(
$searchClause,
true
);
$query .= "%'";
}
@ -613,12 +654,13 @@ class Node_Database extends Node
$query .= "LIMIT " . intval($pos) . ", $maxItems";
$retval = $GLOBALS['dbi']->fetchResult($query);
} else {
$escdDb = PMA\libraries\Util::backquote($db);
$query = "SHOW EVENTS FROM $escdDb ";
if (! empty($searchClause)) {
$escdDb = Util::backquote($db);
$query = "SHOW EVENTS FROM $escdDb ";
if (!empty($searchClause)) {
$query .= "WHERE `Name` LIKE '%";
$query .= PMA\libraries\Util::sqlAddSlashes(
$searchClause, true
$query .= Util::sqlAddSlashes(
$searchClause,
true
);
$query .= "%'";
}
@ -637,6 +679,7 @@ class Node_Database extends Node
}
}
}
return $retval;
}
@ -657,13 +700,14 @@ class Node_Database extends Node
. '&showUnhideDialog=true'
. '&dbName=' . urldecode($this->real_name) . '"'
. ' class="showUnhide ajax">'
. PMA\libraries\Util::getImage(
'lightbulb.png', __('Show hidden items')
. Util::getImage(
'lightbulb.png',
__('Show hidden items')
)
. '</a></span>';
}
}
return $ret;
}

View File

@ -5,9 +5,9 @@
*
* @package PhpMyAdmin-Navigation
*/
if (! defined('PHPMYADMIN')) {
exit;
}
namespace PMA\libraries\navigation\nodes;
use PMA;
/**
* Represents a node that is a child of a database node
@ -16,7 +16,7 @@ if (! defined('PHPMYADMIN')) {
*
* @package PhpMyAdmin-Navigation
*/
abstract class Node_DatabaseChild extends Node
abstract class NodeDatabaseChild extends Node
{
/**
* Returns the type of the item represented by the node.
@ -35,9 +35,9 @@ abstract class Node_DatabaseChild extends Node
$ret = '';
$cfgRelation = PMA_getRelationsParam();
if ($cfgRelation['navwork']) {
$db = $this->realParent()->real_name;
$db = $this->realParent()->real_name;
$item = $this->real_name;
$ret = '<span class="navItemControls">'
$ret = '<span class="navItemControls">'
. '<a href="navigation.php'
. PMA_URL_getCommon()
. '&hideNavItem=true'
@ -48,6 +48,7 @@ abstract class Node_DatabaseChild extends Node
. PMA\libraries\Util::getImage('lightbulb_off.png', __('Hide'))
. '</a></span>';
}
return $ret;
}
}

View File

@ -5,18 +5,14 @@
*
* @package PhpMyAdmin-Navigation
*/
if (! defined('PHPMYADMIN')) {
exit;
}
require_once 'libraries/navigation/nodes/Node_DatabaseChild.class.php';
namespace PMA\libraries\navigation\nodes;
/**
* Represents container node that carries children of a database
*
* @package PhpMyAdmin-Navigation
*/
abstract class Node_DatabaseChild_Container extends Node_DatabaseChild
abstract class NodeDatabaseChildContainer extends NodeDatabaseChild
{
/**
* Initialises the class by setting the common variables
@ -30,7 +26,7 @@ abstract class Node_DatabaseChild_Container extends Node_DatabaseChild
if ($GLOBALS['cfg']['NavigationTreeEnableGrouping']) {
$this->separator = $GLOBALS['cfg']['NavigationTreeTableSeparator'];
$this->separator_depth = (int)(
$GLOBALS['cfg']['NavigationTreeTableLevel']
$GLOBALS['cfg']['NavigationTreeTableLevel']
);
}
}

View File

@ -5,11 +5,10 @@
*
* @package PhpMyAdmin-Navigation
*/
use PMA\libraries\navigation\NodeFactory;
namespace PMA\libraries\navigation\nodes;
if (! defined('PHPMYADMIN')) {
exit;
}
use PMA;
use PMA\libraries\navigation\NodeFactory;
require_once './libraries/check_user_privileges.lib.php';
@ -18,7 +17,7 @@ require_once './libraries/check_user_privileges.lib.php';
*
* @package PhpMyAdmin-Navigation
*/
class Node_Database_Container extends Node
class NodeDatabaseContainer extends Node
{
/**
* Initialises the class
@ -32,16 +31,17 @@ class Node_Database_Container extends Node
if ($GLOBALS['is_create_db_priv']
&& $GLOBALS['cfg']['ShowCreateDb'] !== false
) {
$new = NodeFactory::getInstance(
'Node', _pgettext('Create new database', 'New')
$new = NodeFactory::getInstance(
'PMA\libraries\navigation\nodes\Node',
_pgettext('Create new database', 'New')
);
$new->isNew = true;
$new->icon = PMA\libraries\Util::getImage('b_newdb.png', '');
$new->icon = PMA\libraries\Util::getImage('b_newdb.png', '');
$new->links = array(
'text' => 'server_databases.php?server=' . $GLOBALS['server']
. '&amp;token=' . $_SESSION[' PMA_token '],
. '&amp;token=' . $_SESSION[' PMA_token '],
'icon' => 'server_databases.php?server=' . $GLOBALS['server']
. '&amp;token=' . $_SESSION[' PMA_token '],
. '&amp;token=' . $_SESSION[' PMA_token '],
);
$new->classes = 'new_database italics';
$this->addChild($new);

View File

@ -5,18 +5,20 @@
*
* @package PhpMyAdmin-Navigation
*/
if (! defined('PHPMYADMIN')) {
namespace PMA\libraries\navigation\nodes;
use PMA;
if (!defined('PHPMYADMIN')) {
exit;
}
require_once 'libraries/navigation/nodes/Node_DatabaseChild.class.php';
/**
* Represents a event node in the navigation tree
*
* @package PhpMyAdmin-Navigation
*/
class Node_Event extends Node_DatabaseChild
class NodeEvent extends NodeDatabaseChild
{
/**
* Initialises the class
@ -29,14 +31,14 @@ class Node_Event extends Node_DatabaseChild
public function __construct($name, $type = Node::OBJECT, $is_group = false)
{
parent::__construct($name, $type, $is_group);
$this->icon = PMA\libraries\Util::getImage('b_events.png');
$this->icon = PMA\libraries\Util::getImage('b_events.png');
$this->links = array(
'text' => 'db_events.php?server=' . $GLOBALS['server']
. '&amp;db=%2$s&amp;item_name=%1$s&amp;edit_item=1'
. '&amp;token=' . $_SESSION[' PMA_token '],
. '&amp;db=%2$s&amp;item_name=%1$s&amp;edit_item=1'
. '&amp;token=' . $_SESSION[' PMA_token '],
'icon' => 'db_events.php?server=' . $GLOBALS['server']
. '&amp;db=%2$s&amp;item_name=%1$s&amp;export_item=1'
. '&amp;token=' . $_SESSION[' PMA_token ']
. '&amp;db=%2$s&amp;item_name=%1$s&amp;export_item=1'
. '&amp;token=' . $_SESSION[' PMA_token '],
);
$this->classes = 'event';
}

View File

@ -5,20 +5,17 @@
*
* @package PhpMyAdmin-Navigation
*/
namespace PMA\libraries\navigation\nodes;
use PMA;
use PMA\libraries\navigation\NodeFactory;
if (! defined('PHPMYADMIN')) {
exit;
}
require_once 'libraries/navigation/nodes/Node_DatabaseChild_Container.class.php';
/**
* Represents a container for events nodes in the navigation tree
*
* @package PhpMyAdmin-Navigation
*/
class Node_Event_Container extends Node_DatabaseChild_Container
class NodeEventContainer extends NodeDatabaseChildContainer
{
/**
* Initialises the class
@ -26,27 +23,28 @@ class Node_Event_Container extends Node_DatabaseChild_Container
public function __construct()
{
parent::__construct(__('Events'), Node::CONTAINER);
$this->icon = PMA\libraries\Util::getImage('b_events.png', '');
$this->icon = PMA\libraries\Util::getImage('b_events.png', '');
$this->links = array(
'text' => 'db_events.php?server=' . $GLOBALS['server']
. '&amp;db=%1$s&amp;token=' . $_SESSION[' PMA_token '],
. '&amp;db=%1$s&amp;token=' . $_SESSION[' PMA_token '],
'icon' => 'db_events.php?server=' . $GLOBALS['server']
. '&amp;db=%1$s&amp;token=' . $_SESSION[' PMA_token '],
. '&amp;db=%1$s&amp;token=' . $_SESSION[' PMA_token '],
);
$this->real_name = 'events';
$new = NodeFactory::getInstance(
'Node', _pgettext('Create new event', 'New')
$new = NodeFactory::getInstance(
'PMA\libraries\navigation\nodes\Node',
_pgettext('Create new event', 'New')
);
$new->isNew = true;
$new->icon = PMA\libraries\Util::getImage('b_event_add.png', '');
$new->icon = PMA\libraries\Util::getImage('b_event_add.png', '');
$new->links = array(
'text' => 'db_events.php?server=' . $GLOBALS['server']
. '&amp;db=%2$s&amp;token=' . $_SESSION[' PMA_token ']
. '&add_item=1',
. '&amp;db=%2$s&amp;token=' . $_SESSION[' PMA_token ']
. '&add_item=1',
'icon' => 'db_events.php?server=' . $GLOBALS['server']
. '&amp;db=%2$s&amp;token=' . $_SESSION[' PMA_token ']
. '&add_item=1',
. '&amp;db=%2$s&amp;token=' . $_SESSION[' PMA_token ']
. '&add_item=1',
);
$new->classes = 'new_event italics';
$this->addChild($new);

View File

@ -5,18 +5,16 @@
*
* @package PhpMyAdmin-Navigation
*/
if (! defined('PHPMYADMIN')) {
exit;
}
namespace PMA\libraries\navigation\nodes;
require_once 'libraries/navigation/nodes/Node_DatabaseChild.class.php';
use PMA;
/**
* Represents a function node in the navigation tree
*
* @package PhpMyAdmin-Navigation
*/
class Node_Function extends Node_DatabaseChild
class NodeFunction extends NodeDatabaseChild
{
/**
* Initialises the class
@ -29,14 +27,14 @@ class Node_Function extends Node_DatabaseChild
public function __construct($name, $type = Node::OBJECT, $is_group = false)
{
parent::__construct($name, $type, $is_group);
$this->icon = PMA\libraries\Util::getImage('b_routines.png', __('Function'));
$this->icon = PMA\libraries\Util::getImage('b_routines.png', __('Function'));
$this->links = array(
'text' => 'db_routines.php?server=' . $GLOBALS['server']
. '&amp;db=%2$s&amp;item_name=%1$s&amp;item_type=FUNCTION'
. '&amp;edit_item=1&amp;token=' . $_SESSION[' PMA_token '],
. '&amp;db=%2$s&amp;item_name=%1$s&amp;item_type=FUNCTION'
. '&amp;edit_item=1&amp;token=' . $_SESSION[' PMA_token '],
'icon' => 'db_routines.php?server=' . $GLOBALS['server']
. '&amp;db=%2$s&amp;item_name=%1$s&amp;item_type=FUNCTION'
. '&amp;execute_dialog=1&amp;token=' . $_SESSION[' PMA_token ']
. '&amp;db=%2$s&amp;item_name=%1$s&amp;item_type=FUNCTION'
. '&amp;execute_dialog=1&amp;token=' . $_SESSION[' PMA_token '],
);
$this->classes = 'function';
}

View File

@ -5,20 +5,17 @@
*
* @package PhpMyAdmin-Navigation
*/
namespace PMA\libraries\navigation\nodes;
use PMA;
use PMA\libraries\navigation\NodeFactory;
if (! defined('PHPMYADMIN')) {
exit;
}
require_once 'libraries/navigation/nodes/Node_DatabaseChild_Container.class.php';
/**
* Represents a container for functions nodes in the navigation tree
*
* @package PhpMyAdmin-Navigation
*/
class Node_Function_Container extends Node_DatabaseChild_Container
class NodeFunctionContainer extends NodeDatabaseChildContainer
{
/**
* Initialises the class
@ -26,28 +23,34 @@ class Node_Function_Container extends Node_DatabaseChild_Container
public function __construct()
{
parent::__construct(__('Functions'), Node::CONTAINER);
$this->icon = PMA\libraries\Util::getImage('b_routines.png', __('Functions'));
$this->icon = PMA\libraries\Util::getImage(
'b_routines.png',
__('Functions')
);
$this->links = array(
'text' => 'db_routines.php?server=' . $GLOBALS['server']
. '&amp;db=%1$s&amp;token=' . $_SESSION[' PMA_token ']
. '&amp;type=FUNCTION',
. '&amp;db=%1$s&amp;token=' . $_SESSION[' PMA_token ']
. '&amp;type=FUNCTION',
'icon' => 'db_routines.php?server=' . $GLOBALS['server']
. '&amp;db=%1$s&amp;token=' . $_SESSION[' PMA_token ']
. '&amp;type=FUNCTION',
. '&amp;db=%1$s&amp;token=' . $_SESSION[' PMA_token ']
. '&amp;type=FUNCTION',
);
$this->real_name = 'functions';
$new_label = _pgettext('Create new function', 'New');
$new = NodeFactory::getInstance('Node', $new_label);
$new = NodeFactory::getInstance(
'PMA\libraries\navigation\nodes\Node',
$new_label
);
$new->isNew = true;
$new->icon = PMA\libraries\Util::getImage('b_routine_add.png', $new_label);
$new->icon = PMA\libraries\Util::getImage('b_routine_add.png', $new_label);
$new->links = array(
'text' => 'db_routines.php?server=' . $GLOBALS['server']
. '&amp;db=%2$s&amp;token=' . $_SESSION[' PMA_token ']
. '&add_item=1&amp;item_type=FUNCTION',
. '&amp;db=%2$s&amp;token=' . $_SESSION[' PMA_token ']
. '&add_item=1&amp;item_type=FUNCTION',
'icon' => 'db_routines.php?server=' . $GLOBALS['server']
. '&amp;db=%2$s&amp;token=' . $_SESSION[' PMA_token ']
. '&add_item=1&amp;item_type=FUNCTION',
. '&amp;db=%2$s&amp;token=' . $_SESSION[' PMA_token ']
. '&add_item=1&amp;item_type=FUNCTION',
);
$new->classes = 'new_function italics';
$this->addChild($new);

View File

@ -5,16 +5,16 @@
*
* @package PhpMyAdmin-Navigation
*/
if (! defined('PHPMYADMIN')) {
exit;
}
namespace PMA\libraries\navigation\nodes;
use PMA;
/**
* Represents a index node in the navigation tree
*
* @package PhpMyAdmin-Navigation
*/
class Node_Index extends Node
class NodeIndex extends Node
{
/**
* Initialises the class
@ -27,14 +27,14 @@ class Node_Index extends Node
public function __construct($name, $type = Node::OBJECT, $is_group = false)
{
parent::__construct($name, $type, $is_group);
$this->icon = PMA\libraries\Util::getImage('b_index.png', __('Index'));
$this->icon = PMA\libraries\Util::getImage('b_index.png', __('Index'));
$this->links = array(
'text' => 'tbl_indexes.php?server=' . $GLOBALS['server']
. '&amp;db=%3$s&amp;table=%2$s&amp;index=%1$s'
. '&amp;token=' . $_SESSION[' PMA_token '],
. '&amp;db=%3$s&amp;table=%2$s&amp;index=%1$s'
. '&amp;token=' . $_SESSION[' PMA_token '],
'icon' => 'tbl_indexes.php?server=' . $GLOBALS['server']
. '&amp;db=%3$s&amp;table=%2$s&amp;index=%1$s'
. '&amp;token=' . $_SESSION[' PMA_token ']
. '&amp;db=%3$s&amp;table=%2$s&amp;index=%1$s'
. '&amp;token=' . $_SESSION[' PMA_token '],
);
$this->classes = 'index';
}

View File

@ -5,18 +5,17 @@
*
* @package PhpMyAdmin-Navigation
*/
use PMA\libraries\navigation\NodeFactory;
namespace PMA\libraries\navigation\nodes;
if (! defined('PHPMYADMIN')) {
exit;
}
use PMA;
use PMA\libraries\navigation\NodeFactory;
/**
* Represents a container for index nodes in the navigation tree
*
* @package PhpMyAdmin-Navigation
*/
class Node_Index_Container extends Node
class NodeIndexContainer extends Node
{
/**
* Initialises the class
@ -24,30 +23,33 @@ class Node_Index_Container extends Node
public function __construct()
{
parent::__construct(__('Indexes'), Node::CONTAINER);
$this->icon = PMA\libraries\Util::getImage('b_index.png', __('Indexes'));
$this->icon = PMA\libraries\Util::getImage('b_index.png', __('Indexes'));
$this->links = array(
'text' => 'tbl_structure.php?server=' . $GLOBALS['server']
. '&amp;db=%2$s&amp;table=%1$s'
. '&amp;token=' . $_SESSION[' PMA_token '],
. '&amp;db=%2$s&amp;table=%1$s'
. '&amp;token=' . $_SESSION[' PMA_token '],
'icon' => 'tbl_structure.php?server=' . $GLOBALS['server']
. '&amp;db=%2$s&amp;table=%1$s'
. '&amp;token=' . $_SESSION[' PMA_token '],
. '&amp;db=%2$s&amp;table=%1$s'
. '&amp;token=' . $_SESSION[' PMA_token '],
);
$this->real_name = 'indexes';
$new_label = _pgettext('Create new index', 'New');
$new = NodeFactory::getInstance('Node', $new_label);
$new = NodeFactory::getInstance(
'PMA\libraries\navigation\nodes\Node',
$new_label
);
$new->isNew = true;
$new->icon = PMA\libraries\Util::getImage('b_index_add.png', $new_label);
$new->icon = PMA\libraries\Util::getImage('b_index_add.png', $new_label);
$new->links = array(
'text' => 'tbl_indexes.php?server=' . $GLOBALS['server']
. '&amp;create_index=1&amp;added_fields=2'
. '&amp;db=%3$s&amp;table=%2$s&amp;token='
. $_SESSION[' PMA_token '],
. '&amp;create_index=1&amp;added_fields=2'
. '&amp;db=%3$s&amp;table=%2$s&amp;token='
. $_SESSION[' PMA_token '],
'icon' => 'tbl_indexes.php?server=' . $GLOBALS['server']
. '&amp;create_index=1&amp;added_fields=2'
. '&amp;db=%3$s&amp;table=%2$s&amp;token='
. $_SESSION[' PMA_token '],
. '&amp;create_index=1&amp;added_fields=2'
. '&amp;db=%3$s&amp;table=%2$s&amp;token='
. $_SESSION[' PMA_token '],
);
$new->classes = 'new_index italics';
$this->addChild($new);

View File

@ -5,18 +5,16 @@
*
* @package PhpMyAdmin-Navigation
*/
if (! defined('PHPMYADMIN')) {
exit;
}
namespace PMA\libraries\navigation\nodes;
require_once 'libraries/navigation/nodes/Node_DatabaseChild.class.php';
use PMA;
/**
* Represents a procedure node in the navigation tree
*
* @package PhpMyAdmin-Navigation
*/
class Node_Procedure extends Node_DatabaseChild
class NodeProcedure extends NodeDatabaseChild
{
/**
* Initialises the class
@ -29,14 +27,17 @@ class Node_Procedure extends Node_DatabaseChild
public function __construct($name, $type = Node::OBJECT, $is_group = false)
{
parent::__construct($name, $type, $is_group);
$this->icon = PMA\libraries\Util::getImage('b_routines.png', __('Procedure'));
$this->icon = PMA\libraries\Util::getImage(
'b_routines.png',
__('Procedure')
);
$this->links = array(
'text' => 'db_routines.php?server=' . $GLOBALS['server']
. '&amp;db=%2$s&amp;item_name=%1$s&amp;item_type=PROCEDURE'
. '&amp;edit_item=1&amp;token=' . $_SESSION[' PMA_token '],
. '&amp;db=%2$s&amp;item_name=%1$s&amp;item_type=PROCEDURE'
. '&amp;edit_item=1&amp;token=' . $_SESSION[' PMA_token '],
'icon' => 'db_routines.php?server=' . $GLOBALS['server']
. '&amp;db=%2$s&amp;item_name=%1$s&amp;item_type=PROCEDURE'
. '&amp;execute_dialog=1&amp;token=' . $_SESSION[' PMA_token ']
. '&amp;db=%2$s&amp;item_name=%1$s&amp;item_type=PROCEDURE'
. '&amp;execute_dialog=1&amp;token=' . $_SESSION[' PMA_token '],
);
$this->classes = 'procedure';
}

View File

@ -5,20 +5,17 @@
*
* @package PhpMyAdmin-Navigation
*/
namespace PMA\libraries\navigation\nodes;
use PMA;
use PMA\libraries\navigation\NodeFactory;
if (! defined('PHPMYADMIN')) {
exit;
}
require_once 'libraries/navigation/nodes/Node_DatabaseChild_Container.class.php';
/**
* Represents a container for procedure nodes in the navigation tree
*
* @package PhpMyAdmin-Navigation
*/
class Node_Procedure_Container extends Node_DatabaseChild_Container
class NodeProcedureContainer extends NodeDatabaseChildContainer
{
/**
* Initialises the class
@ -26,28 +23,34 @@ class Node_Procedure_Container extends Node_DatabaseChild_Container
public function __construct()
{
parent::__construct(__('Procedures'), Node::CONTAINER);
$this->icon = PMA\libraries\Util::getImage('b_routines.png', __('Procedures'));
$this->icon = PMA\libraries\Util::getImage(
'b_routines.png',
__('Procedures')
);
$this->links = array(
'text' => 'db_routines.php?server=' . $GLOBALS['server']
. '&amp;db=%1$s&amp;token=' . $_SESSION[' PMA_token ']
. '&amp;type=PROCEDURE',
. '&amp;db=%1$s&amp;token=' . $_SESSION[' PMA_token ']
. '&amp;type=PROCEDURE',
'icon' => 'db_routines.php?server=' . $GLOBALS['server']
. '&amp;db=%1$s&amp;token=' . $_SESSION[' PMA_token ']
. '&amp;type=PROCEDURE',
. '&amp;db=%1$s&amp;token=' . $_SESSION[' PMA_token ']
. '&amp;type=PROCEDURE',
);
$this->real_name = 'procedures';
$new_label = _pgettext('Create new procedure', 'New');
$new = NodeFactory::getInstance('Node', $new_label);
$new = NodeFactory::getInstance(
'PMA\libraries\navigation\nodes\Node',
$new_label
);
$new->isNew = true;
$new->icon = PMA\libraries\Util::getImage('b_routine_add.png', $new_label);
$new->icon = PMA\libraries\Util::getImage('b_routine_add.png', $new_label);
$new->links = array(
'text' => 'db_routines.php?server=' . $GLOBALS['server']
. '&amp;db=%2$s&amp;token=' . $_SESSION[' PMA_token ']
. '&add_item=1',
. '&amp;db=%2$s&amp;token=' . $_SESSION[' PMA_token ']
. '&add_item=1',
'icon' => 'db_routines.php?server=' . $GLOBALS['server']
. '&amp;db=%2$s&amp;token=' . $_SESSION[' PMA_token ']
. '&add_item=1',
. '&amp;db=%2$s&amp;token=' . $_SESSION[' PMA_token ']
. '&add_item=1',
);
$new->classes = 'new_procedure italics';
$this->addChild($new);

View File

@ -5,18 +5,16 @@
*
* @package PhpMyAdmin-Navigation
*/
if (! defined('PHPMYADMIN')) {
exit;
}
namespace PMA\libraries\navigation\nodes;
require_once 'libraries/navigation/nodes/Node_DatabaseChild.class.php';
use PMA\libraries\Util;
/**
* Represents a columns node in the navigation tree
*
* @package PhpMyAdmin-Navigation
*/
class Node_Table extends Node_DatabaseChild
class NodeTable extends NodeDatabaseChild
{
/**
* Initialises the class
@ -31,50 +29,56 @@ class Node_Table extends Node_DatabaseChild
parent::__construct($name, $type, $is_group);
$this->icon = array();
$this->_addIcon(
PMA\libraries\Util::getScriptNameForOption(
$GLOBALS['cfg']['NavigationTreeDefaultTabTable'], 'table'
Util::getScriptNameForOption(
$GLOBALS['cfg']['NavigationTreeDefaultTabTable'],
'table'
)
);
$this->_addIcon(
PMA\libraries\Util::getScriptNameForOption(
$GLOBALS['cfg']['NavigationTreeDefaultTabTable2'], 'table'
Util::getScriptNameForOption(
$GLOBALS['cfg']['NavigationTreeDefaultTabTable2'],
'table'
)
);
$title = PMA\libraries\Util::getTitleForTarget(
$title = Util::getTitleForTarget(
$GLOBALS['cfg']['DefaultTabTable']
);
$this->title = $title;
$script_name = PMA\libraries\Util::getScriptNameForOption(
$GLOBALS['cfg']['DefaultTabTable'], 'table'
$script_name = Util::getScriptNameForOption(
$GLOBALS['cfg']['DefaultTabTable'],
'table'
);
$this->links = array(
'text' => $script_name
. '?server=' . $GLOBALS['server']
. '&amp;db=%2$s&amp;table=%1$s'
. '&amp;pos=0&amp;token=' . $_SESSION[' PMA_token '],
'icon' => array(
PMA\libraries\Util::getScriptNameForOption(
$GLOBALS['cfg']['NavigationTreeDefaultTabTable'], 'table'
'text' => $script_name
. '?server=' . $GLOBALS['server']
. '&amp;db=%2$s&amp;table=%1$s'
. '&amp;pos=0&amp;token=' . $_SESSION[' PMA_token '],
'icon' => array(
Util::getScriptNameForOption(
$GLOBALS['cfg']['NavigationTreeDefaultTabTable'],
'table'
)
. '?server=' . $GLOBALS['server']
. '&amp;db=%2$s&amp;table=%1$s&amp;token='
. $_SESSION[' PMA_token '],
PMA\libraries\Util::getScriptNameForOption(
$GLOBALS['cfg']['NavigationTreeDefaultTabTable2'], 'table'
Util::getScriptNameForOption(
$GLOBALS['cfg']['NavigationTreeDefaultTabTable2'],
'table'
)
. '?server=' . $GLOBALS['server']
. '&amp;db=%2$s&amp;table=%1$s&amp;token='
. $_SESSION[' PMA_token ']
. $_SESSION[' PMA_token '],
),
'title' => $this->title
'title' => $this->title,
);
$this->classes = 'table';
}
/**
* Returns the number of children of type $type present inside this container
* This method is overridden by the Node_Database and Node_Table classes
* This method is overridden by the PMA\libraries\navigation\nodes\NodeDatabase
* and PMA\libraries\navigation\nodes\NodeTable classes
*
* @param string $type The type of item we are looking for
* ('columns' or 'indexes')
@ -85,50 +89,50 @@ class Node_Table extends Node_DatabaseChild
public function getPresence($type = '', $searchClause = '')
{
$retval = 0;
$db = $this->realParent()->real_name;
$table = $this->real_name;
$db = $this->realParent()->real_name;
$table = $this->real_name;
switch ($type) {
case 'columns':
if (! $GLOBALS['cfg']['Server']['DisableIS']) {
$db = PMA\libraries\Util::sqlAddSlashes($db);
$table = PMA\libraries\Util::sqlAddSlashes($table);
$query = "SELECT COUNT(*) ";
if (!$GLOBALS['cfg']['Server']['DisableIS']) {
$db = Util::sqlAddSlashes($db);
$table = Util::sqlAddSlashes($table);
$query = "SELECT COUNT(*) ";
$query .= "FROM `INFORMATION_SCHEMA`.`COLUMNS` ";
$query .= "WHERE `TABLE_NAME`='$table' ";
$query .= "AND `TABLE_SCHEMA`='$db'";
$retval = (int)$GLOBALS['dbi']->fetchValue($query);
} else {
$db = PMA\libraries\Util::backquote($db);
$table = PMA\libraries\Util::backquote($table);
$query = "SHOW COLUMNS FROM $table FROM $db";
$db = Util::backquote($db);
$table = Util::backquote($table);
$query = "SHOW COLUMNS FROM $table FROM $db";
$retval = (int)$GLOBALS['dbi']->numRows(
$GLOBALS['dbi']->tryQuery($query)
);
}
break;
case 'indexes':
$db = PMA\libraries\Util::backquote($db);
$table = PMA\libraries\Util::backquote($table);
$query = "SHOW INDEXES FROM $table FROM $db";
$db = Util::backquote($db);
$table = Util::backquote($table);
$query = "SHOW INDEXES FROM $table FROM $db";
$retval = (int)$GLOBALS['dbi']->numRows(
$GLOBALS['dbi']->tryQuery($query)
);
break;
case 'triggers':
if (! $GLOBALS['cfg']['Server']['DisableIS']) {
$db = PMA\libraries\Util::sqlAddSlashes($db);
$table = PMA\libraries\Util::sqlAddSlashes($table);
$query = "SELECT COUNT(*) ";
if (!$GLOBALS['cfg']['Server']['DisableIS']) {
$db = Util::sqlAddSlashes($db);
$table = Util::sqlAddSlashes($table);
$query = "SELECT COUNT(*) ";
$query .= "FROM `INFORMATION_SCHEMA`.`TRIGGERS` ";
$query .= "WHERE `EVENT_OBJECT_SCHEMA` "
. PMA\libraries\Util::getCollateForIS() . "='$db' ";
. Util::getCollateForIS() . "='$db' ";
$query .= "AND `EVENT_OBJECT_TABLE` "
. PMA\libraries\Util::getCollateForIS() . "='$table'";
. Util::getCollateForIS() . "='$table'";
$retval = (int)$GLOBALS['dbi']->fetchValue($query);
} else {
$db = PMA\libraries\Util::backquote($db);
$table = PMA\libraries\Util::sqlAddSlashes($table);
$query = "SHOW TRIGGERS FROM $db WHERE `Table` = '$table'";
$db = Util::backquote($db);
$table = Util::sqlAddSlashes($table);
$query = "SHOW TRIGGERS FROM $db WHERE `Table` = '$table'";
$retval = (int)$GLOBALS['dbi']->numRows(
$GLOBALS['dbi']->tryQuery($query)
);
@ -137,12 +141,14 @@ class Node_Table extends Node_DatabaseChild
default:
break;
}
return $retval;
}
/**
* Returns the names of children of type $type present inside this container
* This method is overridden by the Node_Database and Node_Table classes
* This method is overridden by the PMA\libraries\navigation\nodes\NodeDatabase
* and PMA\libraries\navigation\nodes\NodeTable classes
*
* @param string $type The type of item we are looking for
* ('tables', 'views', etc)
@ -154,15 +160,15 @@ class Node_Table extends Node_DatabaseChild
public function getData($type, $pos, $searchClause = '')
{
$maxItems = $GLOBALS['cfg']['MaxNavigationItems'];
$retval = array();
$db = $this->realParent()->real_name;
$table = $this->real_name;
$retval = array();
$db = $this->realParent()->real_name;
$table = $this->real_name;
switch ($type) {
case 'columns':
if (! $GLOBALS['cfg']['Server']['DisableIS']) {
$db = PMA\libraries\Util::sqlAddSlashes($db);
$table = PMA\libraries\Util::sqlAddSlashes($table);
$query = "SELECT `COLUMN_NAME` AS `name` ";
if (!$GLOBALS['cfg']['Server']['DisableIS']) {
$db = Util::sqlAddSlashes($db);
$table = Util::sqlAddSlashes($table);
$query = "SELECT `COLUMN_NAME` AS `name` ";
$query .= "FROM `INFORMATION_SCHEMA`.`COLUMNS` ";
$query .= "WHERE `TABLE_NAME`='$table' ";
$query .= "AND `TABLE_SCHEMA`='$db' ";
@ -172,9 +178,9 @@ class Node_Table extends Node_DatabaseChild
break;
}
$db = PMA\libraries\Util::backquote($db);
$table = PMA\libraries\Util::backquote($table);
$query = "SHOW COLUMNS FROM $table FROM $db";
$db = Util::backquote($db);
$table = Util::backquote($table);
$query = "SHOW COLUMNS FROM $table FROM $db";
$handle = $GLOBALS['dbi']->tryQuery($query);
if ($handle === false) {
break;
@ -193,9 +199,9 @@ class Node_Table extends Node_DatabaseChild
}
break;
case 'indexes':
$db = PMA\libraries\Util::backquote($db);
$table = PMA\libraries\Util::backquote($table);
$query = "SHOW INDEXES FROM $table FROM $db";
$db = Util::backquote($db);
$table = Util::backquote($table);
$query = "SHOW INDEXES FROM $table FROM $db";
$handle = $GLOBALS['dbi']->tryQuery($query);
if ($handle === false) {
break;
@ -214,24 +220,24 @@ class Node_Table extends Node_DatabaseChild
}
break;
case 'triggers':
if (! $GLOBALS['cfg']['Server']['DisableIS']) {
$db = PMA\libraries\Util::sqlAddSlashes($db);
$table = PMA\libraries\Util::sqlAddSlashes($table);
$query = "SELECT `TRIGGER_NAME` AS `name` ";
if (!$GLOBALS['cfg']['Server']['DisableIS']) {
$db = Util::sqlAddSlashes($db);
$table = Util::sqlAddSlashes($table);
$query = "SELECT `TRIGGER_NAME` AS `name` ";
$query .= "FROM `INFORMATION_SCHEMA`.`TRIGGERS` ";
$query .= "WHERE `EVENT_OBJECT_SCHEMA` "
. PMA\libraries\Util::getCollateForIS() . "='$db' ";
. Util::getCollateForIS() . "='$db' ";
$query .= "AND `EVENT_OBJECT_TABLE` "
. PMA\libraries\Util::getCollateForIS() . "='$table' ";
. Util::getCollateForIS() . "='$table' ";
$query .= "ORDER BY `TRIGGER_NAME` ASC ";
$query .= "LIMIT " . intval($pos) . ", $maxItems";
$retval = $GLOBALS['dbi']->fetchResult($query);
break;
}
$db = PMA\libraries\Util::backquote($db);
$table = PMA\libraries\Util::sqlAddSlashes($table);
$query = "SHOW TRIGGERS FROM $db WHERE `Table` = '$table'";
$db = Util::backquote($db);
$table = Util::sqlAddSlashes($table);
$query = "SHOW TRIGGERS FROM $db WHERE `Table` = '$table'";
$handle = $GLOBALS['dbi']->tryQuery($query);
if ($handle === false) {
break;
@ -252,6 +258,7 @@ class Node_Table extends Node_DatabaseChild
default:
break;
}
return $retval;
}
@ -280,19 +287,31 @@ class Node_Table extends Node_DatabaseChild
switch ($page) {
case 'tbl_structure.php':
$this->icon[] = PMA\libraries\Util::getImage('b_props.png', __('Structure'));
$this->icon[] = Util::getImage(
'b_props.png',
__('Structure')
);
break;
case 'tbl_select.php':
$this->icon[] = PMA\libraries\Util::getImage('b_search.png', __('Search'));
$this->icon[] = Util::getImage(
'b_search.png',
__('Search')
);
break;
case 'tbl_change.php':
$this->icon[] = PMA\libraries\Util::getImage('b_insrow.png', __('Insert'));
$this->icon[] = Util::getImage(
'b_insrow.png',
__('Insert')
);
break;
case 'tbl_sql.php':
$this->icon[] = PMA\libraries\Util::getImage('b_sql.png', __('SQL'));
$this->icon[] = Util::getImage('b_sql.png', __('SQL'));
break;
case 'sql.php':
$this->icon[] = PMA\libraries\Util::getImage('b_browse.png', __('Browse'));
$this->icon[] = Util::getImage(
'b_browse.png',
__('Browse')
);
break;
}
}

View File

@ -5,20 +5,17 @@
*
* @package PhpMyAdmin-Navigation
*/
namespace PMA\libraries\navigation\nodes;
use PMA;
use PMA\libraries\navigation\NodeFactory;
if (! defined('PHPMYADMIN')) {
exit;
}
require_once 'libraries/navigation/nodes/Node_DatabaseChild_Container.class.php';
/**
* Represents a container for table nodes in the navigation tree
*
* @package PhpMyAdmin-Navigation
*/
class Node_Table_Container extends Node_DatabaseChild_Container
class NodeTableContainer extends NodeDatabaseChildContainer
{
/**
* Initialises the class
@ -26,27 +23,30 @@ class Node_Table_Container extends Node_DatabaseChild_Container
public function __construct()
{
parent::__construct(__('Tables'), Node::CONTAINER);
$this->icon = PMA\libraries\Util::getImage('b_browse.png', __('Tables'));
$this->icon = PMA\libraries\Util::getImage('b_browse.png', __('Tables'));
$this->links = array(
'text' => 'db_structure.php?server=' . $GLOBALS['server']
. '&amp;db=%1$s&amp;tbl_type=table'
. '&amp;token=' . $_SESSION[' PMA_token '],
. '&amp;db=%1$s&amp;tbl_type=table'
. '&amp;token=' . $_SESSION[' PMA_token '],
'icon' => 'db_structure.php?server=' . $GLOBALS['server']
. '&amp;db=%1$s&amp;tbl_type=table'
. '&amp;token=' . $_SESSION[' PMA_token '],
. '&amp;db=%1$s&amp;tbl_type=table'
. '&amp;token=' . $_SESSION[' PMA_token '],
);
$this->real_name = 'tables';
$this->classes = 'tableContainer subContainer';
$this->classes = 'tableContainer subContainer';
$new_label = _pgettext('Create new table', 'New');
$new = NodeFactory::getInstance('Node', $new_label);
$new = NodeFactory::getInstance(
'PMA\libraries\navigation\nodes\Node',
$new_label
);
$new->isNew = true;
$new->icon = PMA\libraries\Util::getImage('b_table_add.png', $new_label);
$new->icon = PMA\libraries\Util::getImage('b_table_add.png', $new_label);
$new->links = array(
'text' => 'tbl_create.php?server=' . $GLOBALS['server']
. '&amp;db=%2$s&amp;token=' . $_SESSION[' PMA_token '],
. '&amp;db=%2$s&amp;token=' . $_SESSION[' PMA_token '],
'icon' => 'tbl_create.php?server=' . $GLOBALS['server']
. '&amp;db=%2$s&amp;token=' . $_SESSION[' PMA_token '],
. '&amp;db=%2$s&amp;token=' . $_SESSION[' PMA_token '],
);
$new->classes = 'new_table italics';
$this->addChild($new);

View File

@ -5,16 +5,16 @@
*
* @package PhpMyAdmin-Navigation
*/
if (! defined('PHPMYADMIN')) {
exit;
}
namespace PMA\libraries\navigation\nodes;
use PMA;
/**
* Represents a trigger node in the navigation tree
*
* @package PhpMyAdmin-Navigation
*/
class Node_Trigger extends Node
class NodeTrigger extends Node
{
/**
* Initialises the class
@ -27,14 +27,14 @@ class Node_Trigger extends Node
public function __construct($name, $type = Node::OBJECT, $is_group = false)
{
parent::__construct($name, $type, $is_group);
$this->icon = PMA\libraries\Util::getImage('b_triggers.png');
$this->icon = PMA\libraries\Util::getImage('b_triggers.png');
$this->links = array(
'text' => 'db_triggers.php?server=' . $GLOBALS['server']
. '&amp;db=%3$s&amp;item_name=%1$s&amp;edit_item=1'
. '&amp;token=' . $_SESSION[' PMA_token '],
. '&amp;db=%3$s&amp;item_name=%1$s&amp;edit_item=1'
. '&amp;token=' . $_SESSION[' PMA_token '],
'icon' => 'db_triggers.php?server=' . $GLOBALS['server']
. '&amp;db=%3$s&amp;item_name=%1$s&amp;export_item=1'
. '&amp;token=' . $_SESSION[' PMA_token ']
. '&amp;db=%3$s&amp;item_name=%1$s&amp;export_item=1'
. '&amp;token=' . $_SESSION[' PMA_token '],
);
$this->classes = 'trigger';
}

View File

@ -5,18 +5,17 @@
*
* @package PhpMyAdmin-Navigation
*/
use PMA\libraries\navigation\NodeFactory;
namespace PMA\libraries\navigation\nodes;
if (! defined('PHPMYADMIN')) {
exit;
}
use PMA;
use PMA\libraries\navigation\NodeFactory;
/**
* Represents a container for trigger nodes in the navigation tree
*
* @package PhpMyAdmin-Navigation
*/
class Node_Trigger_Container extends Node
class NodeTriggerContainer extends Node
{
/**
* Initialises the class
@ -24,33 +23,33 @@ class Node_Trigger_Container extends Node
public function __construct()
{
parent::__construct(__('Triggers'), Node::CONTAINER);
$this->icon = PMA\libraries\Util::getImage('b_triggers.png');
$this->icon = PMA\libraries\Util::getImage('b_triggers.png');
$this->links = array(
'text' => 'db_triggers.php?server=' . $GLOBALS['server']
. '&amp;db=%2$s&amp;table=%1$s&amp;token='
. $_SESSION[' PMA_token '],
. '&amp;db=%2$s&amp;table=%1$s&amp;token='
. $_SESSION[' PMA_token '],
'icon' => 'db_triggers.php?server=' . $GLOBALS['server']
. '&amp;db=%2$s&amp;table=%1$s&amp;token='
. $_SESSION[' PMA_token ']
. '&amp;db=%2$s&amp;table=%1$s&amp;token='
. $_SESSION[' PMA_token '],
);
$this->real_name = 'triggers';
$new = NodeFactory::getInstance(
'Node', _pgettext('Create new trigger', 'New')
$new = NodeFactory::getInstance(
'PMA\libraries\navigation\nodes\Node',
_pgettext('Create new trigger', 'New')
);
$new->isNew = true;
$new->icon = PMA\libraries\Util::getImage('b_trigger_add.png', '');
$new->icon = PMA\libraries\Util::getImage('b_trigger_add.png', '');
$new->links = array(
'text' => 'db_triggers.php?server=' . $GLOBALS['server']
. '&amp;db=%3$s&amp;token=' . $_SESSION[' PMA_token ']
. '&amp;add_item=1',
. '&amp;db=%3$s&amp;token=' . $_SESSION[' PMA_token ']
. '&amp;add_item=1',
'icon' => 'db_triggers.php?server=' . $GLOBALS['server']
. '&amp;db=%3$s&amp;token=' . $_SESSION[' PMA_token ']
. '&amp;add_item=1',
. '&amp;db=%3$s&amp;token=' . $_SESSION[' PMA_token ']
. '&amp;add_item=1',
);
$new->classes = 'new_trigger italics';
$this->addChild($new);
}
}

View File

@ -5,18 +5,16 @@
*
* @package PhpMyAdmin-Navigation
*/
if (! defined('PHPMYADMIN')) {
exit;
}
namespace PMA\libraries\navigation\nodes;
require_once 'libraries/navigation/nodes/Node_DatabaseChild.class.php';
use PMA;
/**
* Represents a view node in the navigation tree
*
* @package PhpMyAdmin-Navigation
*/
class Node_View extends Node_DatabaseChild
class NodeView extends NodeDatabaseChild
{
/**
* Initialises the class
@ -29,14 +27,14 @@ class Node_View extends Node_DatabaseChild
public function __construct($name, $type = Node::OBJECT, $is_group = false)
{
parent::__construct($name, $type, $is_group);
$this->icon = PMA\libraries\Util::getImage('b_props.png', __('View'));
$this->icon = PMA\libraries\Util::getImage('b_props.png', __('View'));
$this->links = array(
'text' => 'sql.php?server=' . $GLOBALS['server']
. '&amp;db=%2$s&amp;table=%1$s&amp;pos=0'
. '&amp;token=' . $_SESSION[' PMA_token '],
. '&amp;db=%2$s&amp;table=%1$s&amp;pos=0'
. '&amp;token=' . $_SESSION[' PMA_token '],
'icon' => 'tbl_structure.php?server=' . $GLOBALS['server']
. '&amp;db=%2$s&amp;table=%1$s'
. '&amp;token=' . $_SESSION[' PMA_token ']
. '&amp;db=%2$s&amp;table=%1$s'
. '&amp;token=' . $_SESSION[' PMA_token '],
);
$this->classes = 'view';
}

View File

@ -5,20 +5,17 @@
*
* @package PhpMyAdmin-Navigation
*/
namespace PMA\libraries\navigation\nodes;
use PMA;
use PMA\libraries\navigation\NodeFactory;
if (! defined('PHPMYADMIN')) {
exit;
}
require_once 'libraries/navigation/nodes/Node_DatabaseChild_Container.class.php';
/**
* Represents a container for view nodes in the navigation tree
*
* @package PhpMyAdmin-Navigation
*/
class Node_View_Container extends Node_DatabaseChild_Container
class NodeViewContainer extends NodeDatabaseChildContainer
{
/**
* Initialises the class
@ -26,27 +23,30 @@ class Node_View_Container extends Node_DatabaseChild_Container
public function __construct()
{
parent::__construct(__('Views'), Node::CONTAINER);
$this->icon = PMA\libraries\Util::getImage('b_views.png', __('Views'));
$this->icon = PMA\libraries\Util::getImage('b_views.png', __('Views'));
$this->links = array(
'text' => 'db_structure.php?server=' . $GLOBALS['server']
. '&amp;db=%1$s&amp;tbl_type=view'
. '&amp;token=' . $_SESSION[' PMA_token '],
. '&amp;db=%1$s&amp;tbl_type=view'
. '&amp;token=' . $_SESSION[' PMA_token '],
'icon' => 'db_structure.php?server=' . $GLOBALS['server']
. '&amp;db=%1$s&amp;tbl_type=view'
. '&amp;token=' . $_SESSION[' PMA_token '],
. '&amp;db=%1$s&amp;tbl_type=view'
. '&amp;token=' . $_SESSION[' PMA_token '],
);
$this->classes = 'viewContainer subContainer';
$this->classes = 'viewContainer subContainer';
$this->real_name = 'views';
$new_label = _pgettext('Create new view', 'New');
$new = NodeFactory::getInstance('Node', $new_label);
$new = NodeFactory::getInstance(
'PMA\libraries\navigation\nodes\Node',
$new_label
);
$new->isNew = true;
$new->icon = PMA\libraries\Util::getImage('b_view_add.png', $new_label);
$new->icon = PMA\libraries\Util::getImage('b_view_add.png', $new_label);
$new->links = array(
'text' => 'view_create.php?server=' . $GLOBALS['server']
. '&amp;db=%2$s&amp;token=' . $_SESSION[' PMA_token '],
. '&amp;db=%2$s&amp;token=' . $_SESSION[' PMA_token '],
'icon' => 'view_create.php?server=' . $GLOBALS['server']
. '&amp;db=%2$s&amp;token=' . $_SESSION[' PMA_token '],
. '&amp;db=%2$s&amp;token=' . $_SESSION[' PMA_token '],
);
$new->classes = 'new_view italics';
$this->addChild($new);

View File

@ -16,7 +16,6 @@ require_once 'libraries/common.inc.php';
require_once 'libraries/tbl_common.inc.php';
require_once 'libraries/tbl_info.inc.php';
use PMA\DI;
use PMA\libraries\controllers\table\TableSearchController;
$container = \PMA\libraries\di\Container::getDefaultContainer();

View File

@ -7,6 +7,7 @@
*/
use PMA\libraries\navigation\NodeFactory;
use PMA\libraries\navigation\nodes\Node;
use PMA\libraries\Theme;
require_once 'libraries/navigation/NodeFactory.php';
@ -52,7 +53,7 @@ class NodeFactory_Test extends PHPUnit_Framework_TestCase
*/
public function testDefaultContainer()
{
$node = NodeFactory::getInstance('Node', 'default', Node::CONTAINER);
$node = NodeFactory::getInstance('PMA\libraries\navigation\nodes\Node', 'default', Node::CONTAINER);
$this->assertEquals('default', $node->name);
$this->assertEquals(Node::CONTAINER, $node->type);
$this->assertEquals(false, $node->is_group);
@ -66,7 +67,7 @@ class NodeFactory_Test extends PHPUnit_Framework_TestCase
public function testGroupContainer()
{
$node = NodeFactory::getInstance(
'Node', 'default', Node::CONTAINER, true
'PMA\libraries\navigation\nodes\Node', 'default', Node::CONTAINER, true
);
$this->assertEquals('default', $node->name);
$this->assertEquals(Node::CONTAINER, $node->type);
@ -81,7 +82,7 @@ class NodeFactory_Test extends PHPUnit_Framework_TestCase
public function testFileError()
{
$this->setExpectedException('PHPUnit_Framework_Error');
NodeFactory::getInstance('Node_DoesNotExist');
NodeFactory::getInstance('NodeDoesNotExist');
}
/**

View File

@ -1,7 +1,7 @@
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
* Tests for Node_Column_Container class
* Tests for PMA\libraries\navigation\nodes\NodeColumnContainer class
*
* @package PhpMyAdmin-test
*/
@ -15,7 +15,7 @@ require_once 'libraries/navigation/NodeFactory.php';
require_once 'libraries/php-gettext/gettext.inc';
/**
* Tests for Node_Column_Container class
* Tests for PMA\libraries\navigation\nodes\NodeColumnContainer class
*
* @package PhpMyAdmin-test
*/
@ -39,7 +39,7 @@ class Node_Column_Container_Test extends PHPUnit_Framework_TestCase
*/
public function testConstructor()
{
$parent = NodeFactory::getInstance('Node_Column_Container');
$parent = NodeFactory::getInstance('PMA\libraries\navigation\nodes\NodeColumn_Container');
$this->assertArrayHasKey(
'text',
$parent->links

View File

@ -1,7 +1,7 @@
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
* Tests for Node_Column class
* Tests for PMA\libraries\navigation\nodes\NodeColumn class
*
* @package PhpMyAdmin-test
*/
@ -15,7 +15,7 @@ require_once 'libraries/navigation/NodeFactory.php';
require_once 'libraries/php-gettext/gettext.inc';
/**
* Tests for Node_Column class
* Tests for PMA\libraries\navigation\nodes\NodeColumn class
*
* @package PhpMyAdmin-test
*/
@ -39,7 +39,7 @@ class Node_Column_Test extends PHPUnit_Framework_TestCase
*/
public function testConstructor()
{
$parent = NodeFactory::getInstance('Node_Column');
$parent = NodeFactory::getInstance('PMA\libraries\navigation\nodes\NodeColumn');
$this->assertArrayHasKey(
'text',
$parent->links

View File

@ -1,32 +1,28 @@
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
* Test for Node_DatabaseChild
* Test for PMA\libraries\navigation\nodes\NodeDatabaseChild
*
* @package PhpMyAdmin-test
*/
use PMA\libraries\navigation\NodeFactory;
use PMA\libraries\navigation\nodes\NodeDatabaseChild;
use PMA\libraries\Theme;
require_once 'libraries/url_generating.lib.php';
require_once 'libraries/relation.lib.php';
require_once 'libraries/navigation/nodes/Node.class.php';
require_once 'libraries/navigation/nodes/Node_DatabaseChild.class.php';
require_once 'libraries/navigation/NodeFactory.php';
require_once 'libraries/php-gettext/gettext.inc';
/**
* Tests for Node_DatabaseChild class
* Tests for PMA\libraries\navigation\nodes\NodeDatabaseChild class
*
* @package PhpMyAdmin-test
*/
class Node_DatabaseChildTest extends PHPUnit_Framework_TestCase
{
/**
* @var Node_DatabaseChild
* @var NodeDatabaseChild
*/
protected $object;
@ -47,7 +43,7 @@ class Node_DatabaseChildTest extends PHPUnit_Framework_TestCase
$_SESSION['relation'][1]['PMA_VERSION'] = PMA_VERSION;
$_SESSION['relation'][1]['navwork'] = true;
$this->object = $this->getMockForAbstractClass(
'Node_DatabaseChild', array('child')
'PMA\libraries\navigation\nodes\NodeDatabaseChild', array('child')
);
}
@ -70,7 +66,7 @@ class Node_DatabaseChildTest extends PHPUnit_Framework_TestCase
*/
public function testGetHtmlForControlButtons()
{
$parent = NodeFactory::getInstance('Node_Database', 'parent');
$parent = NodeFactory::getInstance('PMA\libraries\navigation\nodes\NodeDatabase', 'parent');
$parent->addChild($this->object);
$this->object->expects($this->once())
->method('getItemType')

View File

@ -1,7 +1,7 @@
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
* Tests for Node_Database class
* Tests for PMA\libraries\navigation\nodes\NodeDatabase class
*
* @package PhpMyAdmin-test
*/
@ -15,7 +15,7 @@ require_once 'libraries/navigation/NodeFactory.php';
require_once 'libraries/php-gettext/gettext.inc';
/**
* Tests for Node_Database class
* Tests for PMA\libraries\navigation\nodes\NodeDatabase class
*
* @package PhpMyAdmin-test
*/
@ -45,7 +45,7 @@ class Node_Database_Test extends PHPUnit_Framework_TestCase
*/
public function testConstructor()
{
$parent = NodeFactory::getInstance('Node_Database');
$parent = NodeFactory::getInstance('PMA\libraries\navigation\nodes\NodeDatabase');
$this->assertArrayHasKey(
'text',
$parent->links
@ -64,7 +64,7 @@ class Node_Database_Test extends PHPUnit_Framework_TestCase
*/
public function testGetPresence()
{
$parent = NodeFactory::getInstance('Node_Database');
$parent = NodeFactory::getInstance('PMA\libraries\navigation\nodes\NodeDatabase');
$this->assertEquals(
2,
$parent->getPresence('tables')
@ -94,7 +94,7 @@ class Node_Database_Test extends PHPUnit_Framework_TestCase
*/
public function testGetData()
{
$parent = NodeFactory::getInstance('Node_Database');
$parent = NodeFactory::getInstance('PMA\libraries\navigation\nodes\NodeDatabase');
$tables = $parent->getData('tables', 0);
$this->assertContains(
@ -130,7 +130,7 @@ class Node_Database_Test extends PHPUnit_Framework_TestCase
*/
public function testHiddenCount()
{
$parent = NodeFactory::getInstance('Node_Database');
$parent = NodeFactory::getInstance('PMA\libraries\navigation\nodes\NodeDatabase');
$parent->setHiddenCount(3);
$this->assertEquals(

View File

@ -1,7 +1,7 @@
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
* Tests for Node_Event_Container class
* Tests for PMA\libraries\navigation\nodes\NodeEventContainer class
*
* @package PhpMyAdmin-test
*/
@ -15,7 +15,7 @@ require_once 'libraries/navigation/NodeFactory.php';
require_once 'libraries/php-gettext/gettext.inc';
/**
* Tests for Node_Event_Container class
* Tests for PMA\libraries\navigation\nodes\NodeEventContainer class
*
* @package PhpMyAdmin-test
*/
@ -39,7 +39,7 @@ class Node_Event_Container_Test extends PHPUnit_Framework_TestCase
*/
public function testConstructor()
{
$parent = NodeFactory::getInstance('Node_Event_Container');
$parent = NodeFactory::getInstance('PMA\libraries\navigation\nodes\NodeEvent_Container');
$this->assertArrayHasKey(
'text',
$parent->links

View File

@ -1,7 +1,7 @@
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
* Tests for Node_Event class
* Tests for PMA\libraries\navigation\nodes\NodeEvent class
*
* @package PhpMyAdmin-test
*/
@ -14,7 +14,7 @@ require_once 'libraries/navigation/NodeFactory.php';
/**
* Tests for Node_Event class
* Tests for PMA\libraries\navigation\nodes\NodeEvent class
*
* @package PhpMyAdmin-test
*/
@ -38,7 +38,7 @@ class Node_Event_Test extends PHPUnit_Framework_TestCase
*/
public function testConstructor()
{
$parent = NodeFactory::getInstance('Node_Event');
$parent = NodeFactory::getInstance('PMA\libraries\navigation\nodes\NodeEvent');
$this->assertArrayHasKey(
'text',
$parent->links

View File

@ -1,7 +1,7 @@
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
* Tests for Node_Function_Container class
* Tests for PMA\libraries\navigation\nodes\NodeFunctionContainer class
*
* @package PhpMyAdmin-test
*/
@ -15,7 +15,7 @@ require_once 'libraries/navigation/NodeFactory.php';
require_once 'libraries/php-gettext/gettext.inc';
/**
* Tests for Node_Function_Container class
* Tests for PMA\libraries\navigation\nodes\NodeFunctionContainer class
*
* @package PhpMyAdmin-test
*/
@ -39,7 +39,7 @@ class Node_Function_Container_Test extends PHPUnit_Framework_TestCase
*/
public function testConstructor()
{
$parent = NodeFactory::getInstance('Node_Function_Container');
$parent = NodeFactory::getInstance('PMA\libraries\navigation\nodes\NodeFunction_Container');
$this->assertArrayHasKey(
'text',
$parent->links

View File

@ -1,7 +1,7 @@
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
* Tests for Node_Function class
* Tests for PMA\libraries\navigation\nodes\NodeFunction class
*
* @package PhpMyAdmin-test
*/
@ -15,7 +15,7 @@ require_once 'libraries/navigation/NodeFactory.php';
require_once 'libraries/php-gettext/gettext.inc';
/**
* Tests for Node_Function class
* Tests for PMA\libraries\navigation\nodes\NodeFunction class
*
* @package PhpMyAdmin-test
*/
@ -39,7 +39,7 @@ class Node_Function_Test extends PHPUnit_Framework_TestCase
*/
public function testConstructor()
{
$parent = NodeFactory::getInstance('Node_Function');
$parent = NodeFactory::getInstance('PMA\libraries\navigation\nodes\NodeFunction');
$this->assertArrayHasKey(
'text',
$parent->links

View File

@ -1,7 +1,7 @@
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
* Tests for Node_Index_Container class
* Tests for PMA\libraries\navigation\nodes\NodeIndexContainer class
*
* @package PhpMyAdmin-test
*/
@ -15,7 +15,7 @@ require_once 'libraries/navigation/NodeFactory.php';
require_once 'libraries/php-gettext/gettext.inc';
/**
* Tests for Node_Index_Container class
* Tests for PMA\libraries\navigation\nodes\NodeIndexContainer class
*
* @package PhpMyAdmin-test
*/
@ -39,7 +39,7 @@ class Node_Index_Container_Test extends PHPUnit_Framework_TestCase
*/
public function testConstructor()
{
$parent = NodeFactory::getInstance('Node_Index_Container');
$parent = NodeFactory::getInstance('PMA\libraries\navigation\nodes\NodeIndex_Container');
$this->assertArrayHasKey(
'text',
$parent->links

View File

@ -1,7 +1,7 @@
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
* Tests for Node_Index class
* Tests for PMA\libraries\navigation\nodes\NodeIndex class
*
* @package PhpMyAdmin-test
*/
@ -15,7 +15,7 @@ require_once 'libraries/navigation/NodeFactory.php';
require_once 'libraries/php-gettext/gettext.inc';
/**
* Tests for Node_Index class
* Tests for PMA\libraries\navigation\nodes\NodeIndex class
*
* @package PhpMyAdmin-test
*/
@ -39,7 +39,7 @@ class Node_Index_Test extends PHPUnit_Framework_TestCase
*/
public function testConstructor()
{
$parent = NodeFactory::getInstance('Node_Index');
$parent = NodeFactory::getInstance('PMA\libraries\navigation\nodes\NodeIndex');
$this->assertArrayHasKey(
'text',
$parent->links

View File

@ -1,7 +1,7 @@
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
* Tests for Node_Procedure_Container class
* Tests for PMA\libraries\navigation\nodes\NodeProcedureContainer class
*
* @package PhpMyAdmin-test
*/
@ -15,7 +15,7 @@ require_once 'libraries/navigation/NodeFactory.php';
require_once 'libraries/php-gettext/gettext.inc';
/**
* Tests for Node_Procedure_Container class
* Tests for PMA\libraries\navigation\nodes\NodeProcedureContainer class
*
* @package PhpMyAdmin-test
*/
@ -39,7 +39,7 @@ class Node_Procedure_Container_Test extends PHPUnit_Framework_TestCase
*/
public function testConstructor()
{
$parent = NodeFactory::getInstance('Node_Procedure_Container');
$parent = NodeFactory::getInstance('PMA\libraries\navigation\nodes\NodeProcedure_Container');
$this->assertArrayHasKey(
'text',
$parent->links

View File

@ -1,7 +1,7 @@
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
* Tests for Node_Procedure class
* Tests for PMA\libraries\navigation\nodes\NodeProcedure class
*
* @package PhpMyAdmin-test
*/
@ -15,7 +15,7 @@ require_once 'libraries/navigation/NodeFactory.php';
require_once 'libraries/php-gettext/gettext.inc';
/**
* Tests for Node_Procedure class
* Tests for PMA\libraries\navigation\nodes\NodeProcedure class
*
* @package PhpMyAdmin-test
*/
@ -39,7 +39,7 @@ class Node_Procedure_Test extends PHPUnit_Framework_TestCase
*/
public function testConstructor()
{
$parent = NodeFactory::getInstance('Node_Procedure');
$parent = NodeFactory::getInstance('PMA\libraries\navigation\nodes\NodeProcedure');
$this->assertArrayHasKey(
'text',
$parent->links

View File

@ -1,7 +1,7 @@
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
* Tests for Node_Table_Container class
* Tests for PMA\libraries\navigation\nodes\NodeTableContainer class
*
* @package PhpMyAdmin-test
*/
@ -15,7 +15,7 @@ require_once 'libraries/navigation/NodeFactory.php';
require_once 'libraries/php-gettext/gettext.inc';
/**
* Tests for Node_Table_Container class
* Tests for PMA\libraries\navigation\nodes\NodeTableContainer class
*
* @package PhpMyAdmin-test
*/
@ -44,7 +44,7 @@ class Node_Table_Container_Test extends PHPUnit_Framework_TestCase
*/
public function testConstructor()
{
$parent = NodeFactory::getInstance('Node_Table_Container');
$parent = NodeFactory::getInstance('PMA\libraries\navigation\nodes\NodeTable_Container');
$this->assertArrayHasKey(
'text',
$parent->links

View File

@ -1,7 +1,7 @@
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
* Tests for Node_Table class
* Tests for PMA\libraries\navigation\nodes\NodeTable class
*
* @package PhpMyAdmin-test
*/
@ -15,7 +15,7 @@ require_once 'libraries/navigation/NodeFactory.php';
require_once 'libraries/php-gettext/gettext.inc';
/**
* Tests for Node_Table class
* Tests for PMA\libraries\navigation\nodes\NodeTable class
*
* @package PhpMyAdmin-test
*/
@ -48,7 +48,7 @@ class Node_Table_Test extends PHPUnit_Framework_TestCase
*/
public function testConstructor()
{
$parent = NodeFactory::getInstance('Node_Table');
$parent = NodeFactory::getInstance('PMA\libraries\navigation\nodes\NodeTable');
$this->assertArrayHasKey(
'text',
$parent->links
@ -72,7 +72,7 @@ class Node_Table_Test extends PHPUnit_Framework_TestCase
public function testIcon($target, $imageName)
{
$GLOBALS['cfg']['NavigationTreeDefaultTabTable'] = $target;
$node = NodeFactory::getInstance('Node_Table');
$node = NodeFactory::getInstance('PMA\libraries\navigation\nodes\NodeTable');
$this->assertContains($imageName, $node->icon[0]);
}

View File

@ -1,7 +1,7 @@
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
* Tests for Node_Trigger class
* Tests for PMA\libraries\navigation\nodes\NodeTrigger class
*
* @package PhpMyAdmin-test
*/
@ -15,7 +15,7 @@ require_once 'libraries/navigation/NodeFactory.php';
require_once 'libraries/php-gettext/gettext.inc';
/**
* Tests for Node_Trigger class
* Tests for PMA\libraries\navigation\nodes\NodeTrigger class
*
* @package PhpMyAdmin-test
*/
@ -40,7 +40,7 @@ class Node_Trigger_Container_Test extends PHPUnit_Framework_TestCase
*/
public function testConstructor()
{
$parent = NodeFactory::getInstance('Node_Trigger_Container');
$parent = NodeFactory::getInstance('PMA\libraries\navigation\nodes\NodeTrigger_Container');
$this->assertArrayHasKey(
'text',
$parent->links

View File

@ -1,7 +1,7 @@
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
* Tests for Node_Trigger class
* Tests for PMA\libraries\navigation\nodes\NodeTrigger class
*
* @package PhpMyAdmin-test
*/
@ -14,7 +14,7 @@ require_once 'libraries/navigation/NodeFactory.php';
/**
* Tests for Node_Trigger class
* Tests for PMA\libraries\navigation\nodes\NodeTrigger class
*
* @package PhpMyAdmin-test
*/
@ -39,7 +39,7 @@ class Node_Trigger_Test extends PHPUnit_Framework_TestCase
*/
public function testConstructor()
{
$parent = NodeFactory::getInstance('Node_Trigger');
$parent = NodeFactory::getInstance('PMA\libraries\navigation\nodes\NodeTrigger');
$this->assertArrayHasKey(
'text',
$parent->links

View File

@ -1,7 +1,7 @@
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
* Tests for Node_View_Container class
* Tests for PMA\libraries\navigation\nodes\NodeViewContainer class
*
* @package PhpMyAdmin-test
*/
@ -15,7 +15,7 @@ require_once 'libraries/navigation/NodeFactory.php';
require_once 'libraries/php-gettext/gettext.inc';
/**
* Tests for Node_View_Container class
* Tests for PMA\libraries\navigation\nodes\NodeViewContainer class
*
* @package PhpMyAdmin-test
*/
@ -44,7 +44,7 @@ class Node_View_Container_Test extends PHPUnit_Framework_TestCase
*/
public function testConstructor()
{
$parent = NodeFactory::getInstance('Node_View_Container');
$parent = NodeFactory::getInstance('PMA\libraries\navigation\nodes\NodeView_Container');
$this->assertArrayHasKey(
'text',
$parent->links

View File

@ -1,7 +1,7 @@
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
* Tests for Node_View class
* Tests for PMA\libraries\navigation\nodes\NodeView class
*
* @package PhpMyAdmin-test
*/
@ -15,7 +15,7 @@ require_once 'libraries/navigation/NodeFactory.php';
require_once 'libraries/php-gettext/gettext.inc';
/**
* Tests for Node_View class
* Tests for PMA\libraries\navigation\nodes\NodeView class
*
* @package PhpMyAdmin-test
*/
@ -40,7 +40,7 @@ class Node_View_Test extends PHPUnit_Framework_TestCase
*/
public function testConstructor()
{
$parent = NodeFactory::getInstance('Node_View');
$parent = NodeFactory::getInstance('PMA\libraries\navigation\nodes\NodeView');
$this->assertArrayHasKey(
'text',
$parent->links

View File

@ -7,6 +7,7 @@
*/
use PMA\libraries\navigation\NodeFactory;
use PMA\libraries\navigation\nodes\Node;
use PMA\libraries\Theme;
require_once 'libraries/navigation/NodeFactory.php';
@ -40,8 +41,8 @@ class Node_Test extends PHPUnit_Framework_TestCase
*/
public function testAddNode()
{
$parent = NodeFactory::getInstance('Node', 'parent');
$child = NodeFactory::getInstance('Node', 'child');
$parent = NodeFactory::getInstance('PMA\libraries\navigation\nodes\Node', 'parent');
$child = NodeFactory::getInstance('PMA\libraries\navigation\nodes\Node', 'child');
$parent->addChild($child);
$this->assertEquals(
$parent->getChild($child->name),
@ -60,7 +61,7 @@ class Node_Test extends PHPUnit_Framework_TestCase
*/
public function testGetChildError()
{
$parent = NodeFactory::getInstance('Node', 'parent');
$parent = NodeFactory::getInstance('PMA\libraries\navigation\nodes\Node', 'parent');
$this->assertEquals(
$parent->getChild("foo"),
false
@ -78,8 +79,8 @@ class Node_Test extends PHPUnit_Framework_TestCase
*/
public function testRemoveNode()
{
$parent = NodeFactory::getInstance('Node', 'parent');
$child = NodeFactory::getInstance('Node', 'child');
$parent = NodeFactory::getInstance('PMA\libraries\navigation\nodes\Node', 'parent');
$child = NodeFactory::getInstance('PMA\libraries\navigation\nodes\Node', 'child');
$parent->addChild($child);
$this->assertEquals(
$parent->getChild($child->name),
@ -101,7 +102,7 @@ class Node_Test extends PHPUnit_Framework_TestCase
{
$parent = NodeFactory::getInstance();
$empty_container = NodeFactory::getInstance(
'Node', 'empty', Node::CONTAINER
'PMA\libraries\navigation\nodes\Node', 'empty', Node::CONTAINER
);
$child = NodeFactory::getInstance();
// test with no children
@ -155,7 +156,7 @@ class Node_Test extends PHPUnit_Framework_TestCase
$this->assertEquals($parent->numChildren(), 1);
// add a container, this one doesn't count wither
$container = NodeFactory::getInstance(
'Node', 'default', Node::CONTAINER
'PMA\libraries\navigation\nodes\Node', 'default', Node::CONTAINER
);
$parent->addChild($container);
$this->assertEquals($parent->numChildren(), 1);
@ -239,7 +240,7 @@ class Node_Test extends PHPUnit_Framework_TestCase
$firstChild = NodeFactory::getInstance();
$parent->addChild($firstChild);
$secondChild = NodeFactory::getInstance(
'Node', 'default', Node::CONTAINER
'PMA\libraries\navigation\nodes\Node', 'default', Node::CONTAINER
);
$parent->addChild($secondChild);
// Empty Node::CONTAINER type node should not be considered in hasSiblings()
@ -283,7 +284,7 @@ class Node_Test extends PHPUnit_Framework_TestCase
public function testGetWhereClause()
{
$method = new ReflectionMethod(
'Node', '_getWhereClause'
'PMA\libraries\navigation\nodes\Node', '_getWhereClause'
);
$method->setAccessible(true);