Update website
This commit is contained in:
parent
0a686aeb9a
commit
c4ffa0f6ee
4360 changed files with 1727 additions and 718385 deletions
|
@ -1,305 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* This class is responsible for instantiating
|
||||
* the various components of the navigation panel
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace PhpMyAdmin\Navigation;
|
||||
|
||||
use PhpMyAdmin\Config\PageSettings;
|
||||
use PhpMyAdmin\ConfigStorage\Relation;
|
||||
use PhpMyAdmin\DatabaseInterface;
|
||||
use PhpMyAdmin\ResponseRenderer;
|
||||
use PhpMyAdmin\Sanitize;
|
||||
use PhpMyAdmin\Server\Select;
|
||||
use PhpMyAdmin\Template;
|
||||
use PhpMyAdmin\Theme;
|
||||
use PhpMyAdmin\Url;
|
||||
use PhpMyAdmin\Util;
|
||||
|
||||
use function __;
|
||||
use function count;
|
||||
use function defined;
|
||||
use function file_exists;
|
||||
use function is_bool;
|
||||
use function parse_url;
|
||||
use function strpos;
|
||||
use function trim;
|
||||
|
||||
use const PHP_URL_HOST;
|
||||
|
||||
/**
|
||||
* The navigation panel - displays server, db and table selection tree
|
||||
*/
|
||||
class Navigation
|
||||
{
|
||||
/** @var Template */
|
||||
private $template;
|
||||
|
||||
/** @var Relation */
|
||||
private $relation;
|
||||
|
||||
/** @var DatabaseInterface */
|
||||
private $dbi;
|
||||
|
||||
/** @var NavigationTree */
|
||||
private $tree;
|
||||
|
||||
/**
|
||||
* @param Template $template Template instance
|
||||
* @param Relation $relation Relation instance
|
||||
* @param DatabaseInterface $dbi DatabaseInterface instance
|
||||
*/
|
||||
public function __construct($template, $relation, $dbi)
|
||||
{
|
||||
$this->template = $template;
|
||||
$this->relation = $relation;
|
||||
$this->dbi = $dbi;
|
||||
$this->tree = new NavigationTree($this->template, $this->dbi);
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders the navigation tree, or part of it
|
||||
*
|
||||
* @return string The navigation tree
|
||||
*/
|
||||
public function getDisplay(): string
|
||||
{
|
||||
global $cfg;
|
||||
|
||||
$logo = [
|
||||
'is_displayed' => $cfg['NavigationDisplayLogo'],
|
||||
'has_link' => false,
|
||||
'link' => '#',
|
||||
'attributes' => ' target="_blank" rel="noopener noreferrer"',
|
||||
'source' => '',
|
||||
];
|
||||
|
||||
$response = ResponseRenderer::getInstance();
|
||||
if (! $response->isAjax()) {
|
||||
$logo['source'] = $this->getLogoSource();
|
||||
$logo['has_link'] = (string) $cfg['NavigationLogoLink'] !== '';
|
||||
$logo['link'] = trim((string) $cfg['NavigationLogoLink']);
|
||||
if (! Sanitize::checkLink($logo['link'], true)) {
|
||||
$logo['link'] = 'index.php';
|
||||
}
|
||||
|
||||
if ($cfg['NavigationLogoLinkWindow'] === 'main') {
|
||||
if (empty(parse_url($logo['link'], PHP_URL_HOST))) {
|
||||
$hasStartChar = strpos($logo['link'], '?');
|
||||
$logo['link'] .= Url::getCommon(
|
||||
[],
|
||||
is_bool($hasStartChar) ? '?' : Url::getArgSeparator()
|
||||
);
|
||||
// Internal link detected
|
||||
$logo['attributes'] = '';
|
||||
} else {
|
||||
// External links having a domain name should not be considered
|
||||
// to be links that can use our internal ajax loading
|
||||
$logo['attributes'] = ' class="disableAjax"';
|
||||
}
|
||||
}
|
||||
|
||||
if ($cfg['NavigationDisplayServers'] && count($cfg['Servers']) > 1) {
|
||||
$serverSelect = Select::render(true, true);
|
||||
}
|
||||
|
||||
if (! defined('PMA_DISABLE_NAVI_SETTINGS')) {
|
||||
$pageSettings = new PageSettings('Navi', 'pma_navigation_settings');
|
||||
$response->addHTML($pageSettings->getErrorHTML());
|
||||
$navigationSettings = $pageSettings->getHTML();
|
||||
}
|
||||
}
|
||||
|
||||
if (! $response->isAjax() || ! empty($_POST['full']) || ! empty($_POST['reload'])) {
|
||||
if ($cfg['ShowDatabasesNavigationAsTree']) {
|
||||
// provide database tree in navigation
|
||||
$navRender = $this->tree->renderState();
|
||||
} else {
|
||||
// provide legacy pre-4.0 navigation
|
||||
$navRender = $this->tree->renderDbSelect();
|
||||
}
|
||||
} else {
|
||||
$navRender = $this->tree->renderPath();
|
||||
}
|
||||
|
||||
return $this->template->render('navigation/main', [
|
||||
'is_ajax' => $response->isAjax(),
|
||||
'logo' => $logo,
|
||||
'config_navigation_width' => $cfg['NavigationWidth'],
|
||||
'is_synced' => $cfg['NavigationLinkWithMainPanel'],
|
||||
'is_highlighted' => $cfg['NavigationTreePointerEnable'],
|
||||
'is_autoexpanded' => $cfg['NavigationTreeAutoexpandSingleDb'],
|
||||
'server' => $GLOBALS['server'],
|
||||
'auth_type' => $cfg['Server']['auth_type'],
|
||||
'is_servers_displayed' => $cfg['NavigationDisplayServers'],
|
||||
'servers' => $cfg['Servers'],
|
||||
'server_select' => $serverSelect ?? '',
|
||||
'navigation_tree' => $navRender,
|
||||
'is_navigation_settings_enabled' => ! defined('PMA_DISABLE_NAVI_SETTINGS'),
|
||||
'navigation_settings' => $navigationSettings ?? '',
|
||||
'is_drag_drop_import_enabled' => $cfg['enable_drag_drop_import'] === true,
|
||||
'is_mariadb' => $this->dbi->isMariaDB(),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add an item of navigation tree to the hidden items list in PMA database.
|
||||
*
|
||||
* @param string $itemName name of the navigation tree item
|
||||
* @param string $itemType type of the navigation tree item
|
||||
* @param string $dbName database name
|
||||
* @param string $tableName table name if applicable
|
||||
*/
|
||||
public function hideNavigationItem(
|
||||
$itemName,
|
||||
$itemType,
|
||||
$dbName,
|
||||
$tableName = null
|
||||
): void {
|
||||
$navigationItemsHidingFeature = $this->relation->getRelationParameters()->navigationItemsHidingFeature;
|
||||
if ($navigationItemsHidingFeature === null) {
|
||||
return;
|
||||
}
|
||||
|
||||
$navTable = Util::backquote($navigationItemsHidingFeature->database)
|
||||
. '.' . Util::backquote($navigationItemsHidingFeature->navigationHiding);
|
||||
$sqlQuery = 'INSERT INTO ' . $navTable
|
||||
. '(`username`, `item_name`, `item_type`, `db_name`, `table_name`)'
|
||||
. ' VALUES ('
|
||||
. "'" . $this->dbi->escapeString($GLOBALS['cfg']['Server']['user']) . "',"
|
||||
. "'" . $this->dbi->escapeString($itemName) . "',"
|
||||
. "'" . $this->dbi->escapeString($itemType) . "',"
|
||||
. "'" . $this->dbi->escapeString($dbName) . "',"
|
||||
. "'" . (! empty($tableName) ? $this->dbi->escapeString($tableName) : '' )
|
||||
. "')";
|
||||
$this->dbi->tryQueryAsControlUser($sqlQuery);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a hidden item of navigation tree from the
|
||||
* list of hidden items in PMA database.
|
||||
*
|
||||
* @param string $itemName name of the navigation tree item
|
||||
* @param string $itemType type of the navigation tree item
|
||||
* @param string $dbName database name
|
||||
* @param string $tableName table name if applicable
|
||||
*/
|
||||
public function unhideNavigationItem(
|
||||
$itemName,
|
||||
$itemType,
|
||||
$dbName,
|
||||
$tableName = null
|
||||
): void {
|
||||
$navigationItemsHidingFeature = $this->relation->getRelationParameters()->navigationItemsHidingFeature;
|
||||
if ($navigationItemsHidingFeature === null) {
|
||||
return;
|
||||
}
|
||||
|
||||
$navTable = Util::backquote($navigationItemsHidingFeature->database)
|
||||
. '.' . Util::backquote($navigationItemsHidingFeature->navigationHiding);
|
||||
$sqlQuery = 'DELETE FROM ' . $navTable
|
||||
. ' WHERE'
|
||||
. " `username`='"
|
||||
. $this->dbi->escapeString($GLOBALS['cfg']['Server']['user']) . "'"
|
||||
. " AND `item_name`='" . $this->dbi->escapeString($itemName) . "'"
|
||||
. " AND `item_type`='" . $this->dbi->escapeString($itemType) . "'"
|
||||
. " AND `db_name`='" . $this->dbi->escapeString($dbName) . "'"
|
||||
. (! empty($tableName)
|
||||
? " AND `table_name`='" . $this->dbi->escapeString($tableName) . "'"
|
||||
: ''
|
||||
);
|
||||
$this->dbi->tryQueryAsControlUser($sqlQuery);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns HTML for the dialog to show hidden navigation items.
|
||||
*
|
||||
* @param string $database database name
|
||||
* @param string $itemType type of the items to include
|
||||
* @param string $table table name
|
||||
*
|
||||
* @return string HTML for the dialog to show hidden navigation items
|
||||
*/
|
||||
public function getItemUnhideDialog($database, $itemType = null, $table = null)
|
||||
{
|
||||
$hidden = $this->getHiddenItems($database, $table);
|
||||
|
||||
$typeMap = [
|
||||
'group' => __('Groups:'),
|
||||
'event' => __('Events:'),
|
||||
'function' => __('Functions:'),
|
||||
'procedure' => __('Procedures:'),
|
||||
'table' => __('Tables:'),
|
||||
'view' => __('Views:'),
|
||||
];
|
||||
|
||||
return $this->template->render('navigation/item_unhide_dialog', [
|
||||
'database' => $database,
|
||||
'table' => $table,
|
||||
'hidden' => $hidden,
|
||||
'types' => $typeMap,
|
||||
'item_type' => $itemType,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $database Database name
|
||||
* @param string|null $table Table name
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
private function getHiddenItems(string $database, ?string $table): array
|
||||
{
|
||||
$navigationItemsHidingFeature = $this->relation->getRelationParameters()->navigationItemsHidingFeature;
|
||||
if ($navigationItemsHidingFeature === null) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$navTable = Util::backquote($navigationItemsHidingFeature->database)
|
||||
. '.' . Util::backquote($navigationItemsHidingFeature->navigationHiding);
|
||||
$sqlQuery = 'SELECT `item_name`, `item_type` FROM ' . $navTable
|
||||
. " WHERE `username`='"
|
||||
. $this->dbi->escapeString($GLOBALS['cfg']['Server']['user']) . "'"
|
||||
. " AND `db_name`='" . $this->dbi->escapeString($database) . "'"
|
||||
. " AND `table_name`='"
|
||||
. (! empty($table) ? $this->dbi->escapeString($table) : '') . "'";
|
||||
$result = $this->dbi->tryQueryAsControlUser($sqlQuery);
|
||||
|
||||
$hidden = [];
|
||||
if ($result) {
|
||||
foreach ($result as $row) {
|
||||
$type = $row['item_type'];
|
||||
if (! isset($hidden[$type])) {
|
||||
$hidden[$type] = [];
|
||||
}
|
||||
|
||||
$hidden[$type][] = $row['item_name'];
|
||||
}
|
||||
}
|
||||
|
||||
return $hidden;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string Logo source
|
||||
*/
|
||||
private function getLogoSource(): string
|
||||
{
|
||||
global $theme;
|
||||
|
||||
if ($theme instanceof Theme) {
|
||||
if (@file_exists($theme->getFsPath() . 'img/logo_left.png')) {
|
||||
return $theme->getPath() . '/img/logo_left.png';
|
||||
}
|
||||
|
||||
if (@file_exists($theme->getFsPath() . 'img/pma_logo2.png')) {
|
||||
return $theme->getPath() . '/img/pma_logo2.png';
|
||||
}
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load diff
|
@ -1,122 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* This class is responsible for creating Node objects
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace PhpMyAdmin\Navigation;
|
||||
|
||||
use PhpMyAdmin\Navigation\Nodes\Node;
|
||||
|
||||
use function __;
|
||||
use function class_exists;
|
||||
use function preg_match;
|
||||
use function sprintf;
|
||||
use function trigger_error;
|
||||
|
||||
use const E_USER_ERROR;
|
||||
|
||||
/**
|
||||
* Node factory - instantiates Node objects or objects derived from the Node class
|
||||
*/
|
||||
class NodeFactory
|
||||
{
|
||||
/** @var string */
|
||||
protected static $namespace = 'PhpMyAdmin\\Navigation\\Nodes\\%s';
|
||||
|
||||
/**
|
||||
* Sanitizes the name of a Node class
|
||||
*
|
||||
* @param string $class The class name to be sanitized
|
||||
*
|
||||
* @return string
|
||||
* @psalm-return class-string
|
||||
*/
|
||||
private static function sanitizeClass($class)
|
||||
{
|
||||
if (! preg_match('@^Node\w*$@', $class)) {
|
||||
$class = 'Node';
|
||||
trigger_error(
|
||||
sprintf(
|
||||
/* l10n: The word "Node" must not be translated here */
|
||||
__('Invalid class name "%1$s", using default of "Node"'),
|
||||
$class
|
||||
),
|
||||
E_USER_ERROR
|
||||
);
|
||||
}
|
||||
|
||||
return self::checkClass($class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a class exists and try to load it.
|
||||
* Will return the default class name back if the
|
||||
* file for some subclass is not available
|
||||
*
|
||||
* @param string $class The class name to check
|
||||
*
|
||||
* @return string
|
||||
* @psalm-return class-string
|
||||
*/
|
||||
private static function checkClass($class)
|
||||
{
|
||||
/** @var class-string $class */
|
||||
$class = sprintf(self::$namespace, $class);
|
||||
|
||||
if (! class_exists($class)) {
|
||||
/** @var class-string $class */
|
||||
$class = sprintf(self::$namespace, 'Node');
|
||||
trigger_error(
|
||||
sprintf(
|
||||
__('Could not load class "%1$s"'),
|
||||
$class
|
||||
),
|
||||
E_USER_ERROR
|
||||
);
|
||||
}
|
||||
|
||||
return $class;
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a Node object
|
||||
*
|
||||
* @param string $class The name of the class to instantiate
|
||||
* @param string|array $name An identifier for the new node
|
||||
* @param int $type Type of node, may be one of CONTAINER or OBJECT
|
||||
* @param bool $isGroup Whether this object has been created while grouping nodes
|
||||
*/
|
||||
public static function getInstance(
|
||||
$class = 'Node',
|
||||
$name = 'default',
|
||||
$type = Node::OBJECT,
|
||||
$isGroup = false
|
||||
): Node {
|
||||
$class = self::sanitizeClass($class);
|
||||
|
||||
/** @var Node $node */
|
||||
$node = new $class($name, $type, $isGroup);
|
||||
|
||||
return $node;
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a Node object that will be used only for "New db/table/etc.." objects
|
||||
*
|
||||
* @param string $name An identifier for the new node
|
||||
* @param string $classes Extra CSS classes for the node
|
||||
*/
|
||||
public static function getInstanceForNewNode(
|
||||
string $name,
|
||||
string $classes
|
||||
): Node {
|
||||
$node = new Node($name, Node::OBJECT, false);
|
||||
$node->title = $name;
|
||||
$node->isNew = true;
|
||||
$node->classes = $classes;
|
||||
|
||||
return $node;
|
||||
}
|
||||
}
|
|
@ -1,877 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Functionality for the navigation tree in the left frame
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace PhpMyAdmin\Navigation\Nodes;
|
||||
|
||||
use PhpMyAdmin\ConfigStorage\Relation;
|
||||
use PhpMyAdmin\DatabaseInterface;
|
||||
use PhpMyAdmin\Html\Generator;
|
||||
use PhpMyAdmin\Util;
|
||||
|
||||
use function __;
|
||||
use function array_keys;
|
||||
use function array_reverse;
|
||||
use function array_slice;
|
||||
use function base64_encode;
|
||||
use function count;
|
||||
use function implode;
|
||||
use function in_array;
|
||||
use function is_string;
|
||||
use function preg_match;
|
||||
use function sort;
|
||||
use function sprintf;
|
||||
use function strlen;
|
||||
use function strpos;
|
||||
use function strstr;
|
||||
|
||||
/**
|
||||
* The Node is the building block for the collapsible navigation tree
|
||||
*/
|
||||
class Node
|
||||
{
|
||||
public const CONTAINER = 0;
|
||||
public 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 $realName = '';
|
||||
/** @var int May be one of CONTAINER or OBJECT */
|
||||
public $type = self::OBJECT;
|
||||
/**
|
||||
* @var bool Whether this object has been created while grouping nodes
|
||||
* Only relevant if the node is of type CONTAINER
|
||||
*/
|
||||
public $isGroup = false;
|
||||
/**
|
||||
* @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 = [];
|
||||
/**
|
||||
* @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 $separatorDepth = 1;
|
||||
|
||||
/**
|
||||
* For the IMG tag, used when rendering the node.
|
||||
*
|
||||
* @var array<string, string>
|
||||
* @psalm-var array{image: string, title: string}
|
||||
*/
|
||||
public $icon = ['image' => '', 'title' => ''];
|
||||
|
||||
/**
|
||||
* An array of A tags, used when rendering the node.
|
||||
*
|
||||
* @var array<string, mixed>
|
||||
* @psalm-var array{
|
||||
* text: array{route: string, params: array<string, mixed>},
|
||||
* icon: array{route: string, params: array<string, mixed>},
|
||||
* second_icon?: array{route: string, params: array<string, mixed>},
|
||||
* title?: string
|
||||
* }
|
||||
*/
|
||||
public $links = [
|
||||
'text' => ['route' => '', 'params' => []],
|
||||
'icon' => ['route' => '', 'params' => []],
|
||||
];
|
||||
|
||||
/** @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
|
||||
*/
|
||||
public $pos3 = 0;
|
||||
|
||||
/** @var Relation */
|
||||
protected $relation;
|
||||
|
||||
/** @var string $displayName display name for the navigation tree */
|
||||
public $displayName;
|
||||
|
||||
/** @var string|null */
|
||||
public $urlParamName = null;
|
||||
|
||||
/**
|
||||
* Initialises the class by setting the mandatory variables
|
||||
*
|
||||
* @param string $name An identifier for the new node
|
||||
* @param int $type Type of node, may be one of CONTAINER or OBJECT
|
||||
* @param bool $isGroup Whether this object has been created
|
||||
* while grouping nodes
|
||||
*/
|
||||
public function __construct($name, $type = self::OBJECT, $isGroup = false)
|
||||
{
|
||||
global $dbi;
|
||||
|
||||
if (strlen((string) $name)) {
|
||||
$this->name = $name;
|
||||
$this->realName = $name;
|
||||
}
|
||||
|
||||
if ($type === self::CONTAINER) {
|
||||
$this->type = self::CONTAINER;
|
||||
}
|
||||
|
||||
$this->isGroup = (bool) $isGroup;
|
||||
$this->relation = new Relation($dbi);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a child node to this node
|
||||
*
|
||||
* @param Node $child A child node
|
||||
*/
|
||||
public function addChild($child): void
|
||||
{
|
||||
$this->children[] = $child;
|
||||
$child->parent = $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a child node given it's name
|
||||
*
|
||||
* @param string $name The name of requested child
|
||||
* @param bool $realName Whether to use the "realName"
|
||||
* instead of "name" in comparisons
|
||||
*
|
||||
* @return Node|null The requested child node or null,
|
||||
* if the requested node cannot be found
|
||||
*/
|
||||
public function getChild($name, $realName = false): ?Node
|
||||
{
|
||||
if ($realName) {
|
||||
foreach ($this->children as $child) {
|
||||
if ($child->realName == $name) {
|
||||
return $child;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
foreach ($this->children as $child) {
|
||||
if ($child->name == $name && $child->isNew === false) {
|
||||
return $child;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes a child node from this node
|
||||
*
|
||||
* @param string $name The name of child to be removed
|
||||
*/
|
||||
public function removeChild($name): void
|
||||
{
|
||||
foreach ($this->children as $key => $child) {
|
||||
if ($child->name == $name) {
|
||||
unset($this->children[$key]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the parents for a node
|
||||
*
|
||||
* @param bool $self Whether to include the Node itself in the results
|
||||
* @param bool $containers Whether to include nodes of type CONTAINER
|
||||
* @param bool $groups Whether to include nodes which have $group == true
|
||||
*
|
||||
* @return Node[] An array of parent Nodes
|
||||
*/
|
||||
public function parents($self = false, $containers = false, $groups = false): array
|
||||
{
|
||||
$parents = [];
|
||||
if ($self && ($this->type != self::CONTAINER || $containers) && (! $this->isGroup || $groups)) {
|
||||
$parents[] = $this;
|
||||
}
|
||||
|
||||
$parent = $this->parent;
|
||||
while ($parent !== null) {
|
||||
if (($parent->type != self::CONTAINER || $containers) && (! $parent->isGroup || $groups)) {
|
||||
$parents[] = $parent;
|
||||
}
|
||||
|
||||
$parent = $parent->parent;
|
||||
}
|
||||
|
||||
return $parents;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the actual parent of a node. If used twice on an index or columns
|
||||
* node, it will return the table and database nodes. The names of the returned
|
||||
* nodes can be used in SQL queries, etc...
|
||||
*
|
||||
* @return Node|false
|
||||
*/
|
||||
public function realParent()
|
||||
{
|
||||
$retval = $this->parents();
|
||||
if (count($retval) <= 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $retval[0];
|
||||
}
|
||||
|
||||
/**
|
||||
* This function checks if the node has children nodes associated with it
|
||||
*
|
||||
* @param bool $countEmptyContainers Whether to count empty child
|
||||
* containers as valid children
|
||||
*/
|
||||
public function hasChildren($countEmptyContainers = true): bool
|
||||
{
|
||||
$retval = false;
|
||||
if ($countEmptyContainers) {
|
||||
if (count($this->children)) {
|
||||
$retval = true;
|
||||
}
|
||||
} else {
|
||||
foreach ($this->children as $child) {
|
||||
if ($child->type == self::OBJECT || $child->hasChildren(false)) {
|
||||
$retval = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $retval;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the node has some siblings (other nodes on the same tree
|
||||
* level, in the same branch), false otherwise.
|
||||
* The only exception is for nodes on
|
||||
* the third level of the tree (columns and indexes), for which the function
|
||||
* always returns true. This is because we want to render the containers
|
||||
* for these nodes
|
||||
*/
|
||||
public function hasSiblings(): bool
|
||||
{
|
||||
$retval = false;
|
||||
$paths = $this->getPaths();
|
||||
if (count($paths['aPath_clean']) > 3) {
|
||||
return true;
|
||||
}
|
||||
|
||||
foreach ($this->parent->children as $child) {
|
||||
if ($child !== $this && ($child->type == self::OBJECT || $child->hasChildren(false))) {
|
||||
$retval = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return $retval;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of child nodes that a node has associated with it
|
||||
*
|
||||
* @return int The number of children nodes
|
||||
*/
|
||||
public function numChildren(): int
|
||||
{
|
||||
$retval = 0;
|
||||
foreach ($this->children as $child) {
|
||||
if ($child->type == self::OBJECT) {
|
||||
$retval++;
|
||||
} else {
|
||||
$retval += $child->numChildren();
|
||||
}
|
||||
}
|
||||
|
||||
return $retval;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the actual path and the virtual paths for a node
|
||||
* both as clean arrays and base64 encoded strings
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getPaths(): array
|
||||
{
|
||||
$aPath = [];
|
||||
$aPathClean = [];
|
||||
foreach ($this->parents(true, true, false) as $parent) {
|
||||
$aPath[] = base64_encode($parent->realName);
|
||||
$aPathClean[] = $parent->realName;
|
||||
}
|
||||
|
||||
$aPath = implode('.', array_reverse($aPath));
|
||||
$aPathClean = array_reverse($aPathClean);
|
||||
|
||||
$vPath = [];
|
||||
$vPathClean = [];
|
||||
foreach ($this->parents(true, true, true) as $parent) {
|
||||
$vPath[] = base64_encode((string) $parent->name);
|
||||
$vPathClean[] = $parent->name;
|
||||
}
|
||||
|
||||
$vPath = implode('.', array_reverse($vPath));
|
||||
$vPathClean = array_reverse($vPathClean);
|
||||
|
||||
return [
|
||||
'aPath' => $aPath,
|
||||
'aPath_clean' => $aPathClean,
|
||||
'vPath' => $vPath,
|
||||
'vPath_clean' => $vPathClean,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the names of children of type $type present inside this container
|
||||
* This method is overridden by the PhpMyAdmin\Navigation\Nodes\NodeDatabase
|
||||
* and PhpMyAdmin\Navigation\Nodes\NodeTable classes
|
||||
*
|
||||
* @param string $type The type of item we are looking for
|
||||
* ('tables', 'views', etc)
|
||||
* @param int $pos The offset of the list within the results
|
||||
* @param string $searchClause A string used to filter the results of the query
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getData($type, $pos, $searchClause = '')
|
||||
{
|
||||
if (isset($GLOBALS['cfg']['Server']['DisableIS']) && ! $GLOBALS['cfg']['Server']['DisableIS']) {
|
||||
return $this->getDataFromInfoSchema($pos, $searchClause);
|
||||
}
|
||||
|
||||
if ($GLOBALS['dbs_to_test'] === false) {
|
||||
return $this->getDataFromShowDatabases($pos, $searchClause);
|
||||
}
|
||||
|
||||
return $this->getDataFromShowDatabasesLike($pos, $searchClause);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of children of type $type present inside this container
|
||||
* This method is overridden by the PhpMyAdmin\Navigation\Nodes\NodeDatabase
|
||||
* and PhpMyAdmin\Navigation\Nodes\NodeTable classes
|
||||
*
|
||||
* @param string $type The type of item we are looking for
|
||||
* ('tables', 'views', etc)
|
||||
* @param string $searchClause A string used to filter the results of the query
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getPresence($type = '', $searchClause = '')
|
||||
{
|
||||
global $dbi;
|
||||
|
||||
if (! $GLOBALS['cfg']['NavigationTreeEnableGrouping'] || ! $GLOBALS['cfg']['ShowDatabasesNavigationAsTree']) {
|
||||
if (isset($GLOBALS['cfg']['Server']['DisableIS']) && ! $GLOBALS['cfg']['Server']['DisableIS']) {
|
||||
$query = 'SELECT COUNT(*) ';
|
||||
$query .= 'FROM INFORMATION_SCHEMA.SCHEMATA ';
|
||||
$query .= $this->getWhereClause('SCHEMA_NAME', $searchClause);
|
||||
|
||||
return (int) $dbi->fetchValue($query);
|
||||
}
|
||||
|
||||
if ($GLOBALS['dbs_to_test'] === false) {
|
||||
$query = 'SHOW DATABASES ';
|
||||
$query .= $this->getWhereClause('Database', $searchClause);
|
||||
|
||||
return (int) $dbi->queryAndGetNumRows($query);
|
||||
}
|
||||
|
||||
$retval = 0;
|
||||
foreach ($this->getDatabasesToSearch($searchClause) as $db) {
|
||||
$query = "SHOW DATABASES LIKE '" . $db . "'";
|
||||
$retval += (int) $dbi->queryAndGetNumRows($query);
|
||||
}
|
||||
|
||||
return $retval;
|
||||
}
|
||||
|
||||
$dbSeparator = $GLOBALS['cfg']['NavigationTreeDbSeparator'];
|
||||
if (! $GLOBALS['cfg']['Server']['DisableIS']) {
|
||||
$query = 'SELECT COUNT(*) ';
|
||||
$query .= 'FROM ( ';
|
||||
$query .= 'SELECT DISTINCT SUBSTRING_INDEX(SCHEMA_NAME, ';
|
||||
$query .= "'" . $dbSeparator . "', 1) ";
|
||||
$query .= 'DB_first_level ';
|
||||
$query .= 'FROM INFORMATION_SCHEMA.SCHEMATA ';
|
||||
$query .= $this->getWhereClause('SCHEMA_NAME', $searchClause);
|
||||
$query .= ') t ';
|
||||
|
||||
return (int) $dbi->fetchValue($query);
|
||||
}
|
||||
|
||||
if ($GLOBALS['dbs_to_test'] !== false) {
|
||||
$prefixMap = [];
|
||||
foreach ($this->getDatabasesToSearch($searchClause) as $db) {
|
||||
$query = "SHOW DATABASES LIKE '" . $db . "'";
|
||||
$handle = $dbi->tryQuery($query);
|
||||
if ($handle === false) {
|
||||
continue;
|
||||
}
|
||||
|
||||
while ($arr = $handle->fetchRow()) {
|
||||
if ($this->isHideDb($arr[0])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$prefix = strstr($arr[0], $dbSeparator, true);
|
||||
if ($prefix === false) {
|
||||
$prefix = $arr[0];
|
||||
}
|
||||
|
||||
$prefixMap[$prefix] = 1;
|
||||
}
|
||||
}
|
||||
|
||||
return count($prefixMap);
|
||||
}
|
||||
|
||||
$prefixMap = [];
|
||||
$query = 'SHOW DATABASES ';
|
||||
$query .= $this->getWhereClause('Database', $searchClause);
|
||||
$handle = $dbi->tryQuery($query);
|
||||
if ($handle !== false) {
|
||||
while ($arr = $handle->fetchRow()) {
|
||||
$prefix = strstr($arr[0], $dbSeparator, true);
|
||||
if ($prefix === false) {
|
||||
$prefix = $arr[0];
|
||||
}
|
||||
|
||||
$prefixMap[$prefix] = 1;
|
||||
}
|
||||
}
|
||||
|
||||
return count($prefixMap);
|
||||
}
|
||||
|
||||
/**
|
||||
* Detemines whether a given database should be hidden according to 'hide_db'
|
||||
*
|
||||
* @param string $db database name
|
||||
*/
|
||||
private function isHideDb($db): bool
|
||||
{
|
||||
return ! empty($GLOBALS['cfg']['Server']['hide_db'])
|
||||
&& preg_match('/' . $GLOBALS['cfg']['Server']['hide_db'] . '/', $db);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the list of databases for 'SHOW DATABASES LIKE' queries.
|
||||
* If a search clause is set it gets the highest priority while only_db gets
|
||||
* the next priority. In case both are empty list of databases determined by
|
||||
* GRANTs are used
|
||||
*
|
||||
* @param string $searchClause search clause
|
||||
*
|
||||
* @return array array of databases
|
||||
*/
|
||||
private function getDatabasesToSearch($searchClause)
|
||||
{
|
||||
global $dbi;
|
||||
|
||||
$databases = [];
|
||||
if (! empty($searchClause)) {
|
||||
$databases = [
|
||||
'%' . $dbi->escapeString($searchClause) . '%',
|
||||
];
|
||||
} elseif (! empty($GLOBALS['cfg']['Server']['only_db'])) {
|
||||
$databases = $GLOBALS['cfg']['Server']['only_db'];
|
||||
} elseif (! empty($GLOBALS['dbs_to_test'])) {
|
||||
$databases = $GLOBALS['dbs_to_test'];
|
||||
}
|
||||
|
||||
sort($databases);
|
||||
|
||||
return $databases;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the WHERE clause depending on the $searchClause parameter
|
||||
* and the hide_db directive
|
||||
*
|
||||
* @param string $columnName Column name of the column having database names
|
||||
* @param string $searchClause A string used to filter the results of the query
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function getWhereClause($columnName, $searchClause = '')
|
||||
{
|
||||
global $dbi;
|
||||
|
||||
$whereClause = 'WHERE TRUE ';
|
||||
if (! empty($searchClause)) {
|
||||
$whereClause .= 'AND ' . Util::backquote($columnName)
|
||||
. " LIKE '%";
|
||||
$whereClause .= $dbi->escapeString($searchClause);
|
||||
$whereClause .= "%' ";
|
||||
}
|
||||
|
||||
if (! empty($GLOBALS['cfg']['Server']['hide_db'])) {
|
||||
$whereClause .= 'AND ' . Util::backquote($columnName)
|
||||
. " NOT REGEXP '"
|
||||
. $dbi->escapeString($GLOBALS['cfg']['Server']['hide_db'])
|
||||
. "' ";
|
||||
}
|
||||
|
||||
if (! empty($GLOBALS['cfg']['Server']['only_db'])) {
|
||||
if (is_string($GLOBALS['cfg']['Server']['only_db'])) {
|
||||
$GLOBALS['cfg']['Server']['only_db'] = [
|
||||
$GLOBALS['cfg']['Server']['only_db'],
|
||||
];
|
||||
}
|
||||
|
||||
$whereClause .= 'AND (';
|
||||
$subClauses = [];
|
||||
foreach ($GLOBALS['cfg']['Server']['only_db'] as $eachOnlyDb) {
|
||||
$subClauses[] = ' ' . Util::backquote($columnName)
|
||||
. " LIKE '"
|
||||
. $dbi->escapeString($eachOnlyDb) . "' ";
|
||||
}
|
||||
|
||||
$whereClause .= implode('OR', $subClauses) . ') ';
|
||||
}
|
||||
|
||||
return $whereClause;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns HTML for control buttons displayed infront of a node
|
||||
*
|
||||
* @return string HTML for control buttons
|
||||
*/
|
||||
public function getHtmlForControlButtons(): string
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns CSS classes for a node
|
||||
*
|
||||
* @param bool $match Whether the node matched loaded tree
|
||||
*
|
||||
* @return string with html classes.
|
||||
*/
|
||||
public function getCssClasses($match): string
|
||||
{
|
||||
if (! $GLOBALS['cfg']['NavigationTreeEnableExpansion']) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$result = ['expander'];
|
||||
|
||||
if ($this->isGroup || $match) {
|
||||
$result[] = 'loaded';
|
||||
}
|
||||
|
||||
if ($this->type == self::CONTAINER) {
|
||||
$result[] = 'container';
|
||||
}
|
||||
|
||||
return implode(' ', $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns icon for the node
|
||||
*
|
||||
* @param bool $match Whether the node matched loaded tree
|
||||
*
|
||||
* @return string with image name
|
||||
*/
|
||||
public function getIcon($match): string
|
||||
{
|
||||
if (! $GLOBALS['cfg']['NavigationTreeEnableExpansion']) {
|
||||
return '';
|
||||
}
|
||||
|
||||
if ($match) {
|
||||
$this->visible = true;
|
||||
|
||||
return Generator::getImage('b_minus');
|
||||
}
|
||||
|
||||
return Generator::getImage('b_plus', __('Expand/Collapse'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the count of hidden elements for each database
|
||||
*
|
||||
* @return array|null array containing the count of hidden elements for each database
|
||||
*/
|
||||
public function getNavigationHidingData()
|
||||
{
|
||||
global $dbi;
|
||||
|
||||
$navigationItemsHidingFeature = $this->relation->getRelationParameters()->navigationItemsHidingFeature;
|
||||
if ($navigationItemsHidingFeature !== null) {
|
||||
$navTable = Util::backquote($navigationItemsHidingFeature->database)
|
||||
. '.' . Util::backquote($navigationItemsHidingFeature->navigationHiding);
|
||||
$sqlQuery = 'SELECT `db_name`, COUNT(*) AS `count` FROM ' . $navTable
|
||||
. " WHERE `username`='"
|
||||
. $dbi->escapeString($GLOBALS['cfg']['Server']['user']) . "'"
|
||||
. ' GROUP BY `db_name`';
|
||||
|
||||
return $dbi->fetchResult($sqlQuery, 'db_name', 'count', DatabaseInterface::CONNECT_CONTROL);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $pos The offset of the list within the results.
|
||||
* @param string $searchClause A string used to filter the results of the query.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
private function getDataFromInfoSchema($pos, $searchClause)
|
||||
{
|
||||
global $dbi, $cfg;
|
||||
|
||||
$maxItems = $cfg['FirstLevelNavigationItems'];
|
||||
if (! $cfg['NavigationTreeEnableGrouping'] || ! $cfg['ShowDatabasesNavigationAsTree']) {
|
||||
$query = sprintf(
|
||||
'SELECT `SCHEMA_NAME` FROM `INFORMATION_SCHEMA`.`SCHEMATA` %sORDER BY `SCHEMA_NAME` LIMIT %d, %d',
|
||||
$this->getWhereClause('SCHEMA_NAME', $searchClause),
|
||||
$pos,
|
||||
$maxItems
|
||||
);
|
||||
|
||||
return $dbi->fetchResult($query);
|
||||
}
|
||||
|
||||
$dbSeparator = $cfg['NavigationTreeDbSeparator'];
|
||||
$query = sprintf(
|
||||
'SELECT `SCHEMA_NAME` FROM `INFORMATION_SCHEMA`.`SCHEMATA`, (SELECT DB_first_level'
|
||||
. ' FROM ( SELECT DISTINCT SUBSTRING_INDEX(SCHEMA_NAME, \'%1$s\', 1) DB_first_level'
|
||||
. ' FROM INFORMATION_SCHEMA.SCHEMATA %2$s) t'
|
||||
. ' ORDER BY DB_first_level ASC LIMIT %3$d, %4$d) t2'
|
||||
. ' %2$sAND 1 = LOCATE(CONCAT(DB_first_level, \'%1$s\'),'
|
||||
. ' CONCAT(SCHEMA_NAME, \'%1$s\')) ORDER BY SCHEMA_NAME ASC',
|
||||
$dbi->escapeString($dbSeparator),
|
||||
$this->getWhereClause('SCHEMA_NAME', $searchClause),
|
||||
$pos,
|
||||
$maxItems
|
||||
);
|
||||
|
||||
return $dbi->fetchResult($query);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $pos The offset of the list within the results.
|
||||
* @param string $searchClause A string used to filter the results of the query.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
private function getDataFromShowDatabases($pos, $searchClause)
|
||||
{
|
||||
global $dbi, $cfg;
|
||||
|
||||
$maxItems = $cfg['FirstLevelNavigationItems'];
|
||||
if (! $cfg['NavigationTreeEnableGrouping'] || ! $cfg['ShowDatabasesNavigationAsTree']) {
|
||||
$handle = $dbi->tryQuery(sprintf(
|
||||
'SHOW DATABASES %s',
|
||||
$this->getWhereClause('Database', $searchClause)
|
||||
));
|
||||
if ($handle === false) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$count = 0;
|
||||
if (! $handle->seek($pos)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$retval = [];
|
||||
while ($arr = $handle->fetchRow()) {
|
||||
if ($count >= $maxItems) {
|
||||
break;
|
||||
}
|
||||
|
||||
$retval[] = $arr[0];
|
||||
$count++;
|
||||
}
|
||||
|
||||
return $retval;
|
||||
}
|
||||
|
||||
$dbSeparator = $cfg['NavigationTreeDbSeparator'];
|
||||
$handle = $dbi->tryQuery(sprintf(
|
||||
'SHOW DATABASES %s',
|
||||
$this->getWhereClause('Database', $searchClause)
|
||||
));
|
||||
$prefixes = [];
|
||||
if ($handle !== false) {
|
||||
$prefixMap = [];
|
||||
$total = $pos + $maxItems;
|
||||
while ($arr = $handle->fetchRow()) {
|
||||
$prefix = strstr($arr[0], $dbSeparator, true);
|
||||
if ($prefix === false) {
|
||||
$prefix = $arr[0];
|
||||
}
|
||||
|
||||
$prefixMap[$prefix] = 1;
|
||||
if (count($prefixMap) == $total) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$prefixes = array_slice(array_keys($prefixMap), (int) $pos);
|
||||
}
|
||||
|
||||
$subClauses = [];
|
||||
foreach ($prefixes as $prefix) {
|
||||
$subClauses[] = sprintf(
|
||||
' LOCATE(\'%1$s%2$s\', CONCAT(`Database`, \'%2$s\')) = 1 ',
|
||||
$dbi->escapeString((string) $prefix),
|
||||
$dbSeparator
|
||||
);
|
||||
}
|
||||
|
||||
$query = sprintf(
|
||||
'SHOW DATABASES %sAND (%s)',
|
||||
$this->getWhereClause('Database', $searchClause),
|
||||
implode('OR', $subClauses)
|
||||
);
|
||||
|
||||
return $dbi->fetchResult($query);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $pos The offset of the list within the results.
|
||||
* @param string $searchClause A string used to filter the results of the query.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
private function getDataFromShowDatabasesLike($pos, $searchClause)
|
||||
{
|
||||
global $dbi, $cfg;
|
||||
|
||||
$maxItems = $cfg['FirstLevelNavigationItems'];
|
||||
if (! $cfg['NavigationTreeEnableGrouping'] || ! $cfg['ShowDatabasesNavigationAsTree']) {
|
||||
$retval = [];
|
||||
$count = 0;
|
||||
foreach ($this->getDatabasesToSearch($searchClause) as $db) {
|
||||
$handle = $dbi->tryQuery(sprintf('SHOW DATABASES LIKE \'%s\'', $db));
|
||||
if ($handle === false) {
|
||||
continue;
|
||||
}
|
||||
|
||||
while ($arr = $handle->fetchRow()) {
|
||||
if ($this->isHideDb($arr[0])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (in_array($arr[0], $retval)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($pos <= 0 && $count < $maxItems) {
|
||||
$retval[] = $arr[0];
|
||||
$count++;
|
||||
}
|
||||
|
||||
$pos--;
|
||||
}
|
||||
}
|
||||
|
||||
sort($retval);
|
||||
|
||||
return $retval;
|
||||
}
|
||||
|
||||
$dbSeparator = $cfg['NavigationTreeDbSeparator'];
|
||||
$retval = [];
|
||||
$prefixMap = [];
|
||||
$total = $pos + $maxItems;
|
||||
foreach ($this->getDatabasesToSearch($searchClause) as $db) {
|
||||
$handle = $dbi->tryQuery(sprintf('SHOW DATABASES LIKE \'%s\'', $db));
|
||||
if ($handle === false) {
|
||||
continue;
|
||||
}
|
||||
|
||||
while ($arr = $handle->fetchRow()) {
|
||||
if ($this->isHideDb($arr[0])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$prefix = strstr($arr[0], $dbSeparator, true);
|
||||
if ($prefix === false) {
|
||||
$prefix = $arr[0];
|
||||
}
|
||||
|
||||
$prefixMap[$prefix] = 1;
|
||||
if (count($prefixMap) == $total) {
|
||||
break 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$prefixes = array_slice(array_keys($prefixMap), $pos);
|
||||
|
||||
foreach ($this->getDatabasesToSearch($searchClause) as $db) {
|
||||
$handle = $dbi->tryQuery(sprintf('SHOW DATABASES LIKE \'%s\'', $db));
|
||||
if ($handle === false) {
|
||||
continue;
|
||||
}
|
||||
|
||||
while ($arr = $handle->fetchRow()) {
|
||||
if ($this->isHideDb($arr[0])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (in_array($arr[0], $retval)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
foreach ($prefixes as $prefix) {
|
||||
$startsWith = strpos($arr[0] . $dbSeparator, $prefix . $dbSeparator) === 0;
|
||||
if ($startsWith) {
|
||||
$retval[] = $arr[0];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sort($retval);
|
||||
|
||||
return $retval;
|
||||
}
|
||||
}
|
|
@ -1,120 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Functionality for the navigation tree
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace PhpMyAdmin\Navigation\Nodes;
|
||||
|
||||
use function __;
|
||||
use function strlen;
|
||||
use function substr;
|
||||
|
||||
/**
|
||||
* Represents a columns node in the navigation tree
|
||||
*/
|
||||
class NodeColumn extends Node
|
||||
{
|
||||
/**
|
||||
* Initialises the class
|
||||
*
|
||||
* @param array $item array to identify the column node
|
||||
* @param int $type Type of node, may be one of CONTAINER or OBJECT
|
||||
* @param bool $isGroup Whether this object has been created
|
||||
* while grouping nodes
|
||||
*/
|
||||
public function __construct($item, $type = Node::OBJECT, $isGroup = false)
|
||||
{
|
||||
$this->displayName = $this->getDisplayName($item);
|
||||
|
||||
parent::__construct($item['name'], $type, $isGroup);
|
||||
$this->icon = ['image' => $this->getColumnIcon($item['key']), 'title' => __('Column')];
|
||||
$this->links = [
|
||||
'text' => [
|
||||
'route' => '/table/structure/change',
|
||||
'params' => ['change_column' => 1, 'db' => null, 'table' => null, 'field' => null],
|
||||
],
|
||||
'icon' => [
|
||||
'route' => '/table/structure/change',
|
||||
'params' => ['change_column' => 1, 'db' => null, 'table' => null, 'field' => null],
|
||||
],
|
||||
'title' => __('Structure'),
|
||||
];
|
||||
$this->urlParamName = 'field';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get customized Icon for columns in navigation tree
|
||||
*
|
||||
* @param string $key The key type - (primary, foreign etc.)
|
||||
*
|
||||
* @return string Icon name for required key.
|
||||
*/
|
||||
private function getColumnIcon($key)
|
||||
{
|
||||
switch ($key) {
|
||||
case 'PRI':
|
||||
$retval = 'b_primary';
|
||||
break;
|
||||
case 'UNI':
|
||||
$retval = 'bd_primary';
|
||||
break;
|
||||
default:
|
||||
$retval = 'pause';
|
||||
break;
|
||||
}
|
||||
|
||||
return $retval;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get displayable name for navigation tree (key_type, data_type, default)
|
||||
*
|
||||
* @param array<string, mixed> $item Item is array containing required info
|
||||
*
|
||||
* @return string Display name for navigation tree
|
||||
*/
|
||||
private function getDisplayName($item)
|
||||
{
|
||||
$retval = $item['name'];
|
||||
$flag = 0;
|
||||
foreach ($item as $key => $value) {
|
||||
if (empty($value) || $key === 'name') {
|
||||
continue;
|
||||
}
|
||||
|
||||
$flag == 0 ? $retval .= ' (' : $retval .= ', ';
|
||||
$flag = 1;
|
||||
$retval .= $this->getTruncateValue($key, $value);
|
||||
}
|
||||
|
||||
return $retval . ')';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get truncated value for display in node column view
|
||||
*
|
||||
* @param string $key key to identify default,datatype etc
|
||||
* @param string $value value corresponding to key
|
||||
*
|
||||
* @return string truncated value
|
||||
*/
|
||||
public function getTruncateValue($key, $value)
|
||||
{
|
||||
$retval = '';
|
||||
|
||||
switch ($key) {
|
||||
case 'default':
|
||||
strlen($value) > 6 ?
|
||||
$retval .= substr($value, 0, 6) . '...' :
|
||||
$retval = $value;
|
||||
break;
|
||||
default:
|
||||
$retval = $value;
|
||||
break;
|
||||
}
|
||||
|
||||
return $retval;
|
||||
}
|
||||
}
|
|
@ -1,48 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Functionality for the navigation tree
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace PhpMyAdmin\Navigation\Nodes;
|
||||
|
||||
use PhpMyAdmin\Navigation\NodeFactory;
|
||||
|
||||
use function __;
|
||||
use function _pgettext;
|
||||
|
||||
/**
|
||||
* Represents a container for column nodes in the navigation tree
|
||||
*/
|
||||
class NodeColumnContainer extends Node
|
||||
{
|
||||
/**
|
||||
* Initialises the class
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct(__('Columns'), Node::CONTAINER);
|
||||
$this->icon = ['image' => 'pause', 'title' => __('Columns')];
|
||||
$this->links = [
|
||||
'text' => ['route' => '/table/structure', 'params' => ['db' => null, 'table' => null]],
|
||||
'icon' => ['route' => '/table/structure', 'params' => ['db' => null, 'table' => null]],
|
||||
];
|
||||
$this->realName = 'columns';
|
||||
|
||||
$newLabel = _pgettext('Create new column', 'New');
|
||||
$new = NodeFactory::getInstanceForNewNode($newLabel, 'new_column italics');
|
||||
$new->icon = ['image' => 'b_column_add', 'title' => $newLabel];
|
||||
$new->links = [
|
||||
'text' => [
|
||||
'route' => '/table/add-field',
|
||||
'params' => ['field_where' => 'last', 'after_field' => '', 'db' => null, 'table' => null],
|
||||
],
|
||||
'icon' => [
|
||||
'route' => '/table/add-field',
|
||||
'params' => ['field_where' => 'last', 'after_field' => '', 'db' => null, 'table' => null],
|
||||
],
|
||||
];
|
||||
$this->addChild($new);
|
||||
}
|
||||
}
|
|
@ -1,692 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Functionality for the navigation tree
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace PhpMyAdmin\Navigation\Nodes;
|
||||
|
||||
use PhpMyAdmin\Html\Generator;
|
||||
use PhpMyAdmin\Url;
|
||||
use PhpMyAdmin\Util;
|
||||
|
||||
use function __;
|
||||
use function in_array;
|
||||
use function intval;
|
||||
use function substr;
|
||||
|
||||
/**
|
||||
* Represents a database node in the navigation tree
|
||||
*/
|
||||
class NodeDatabase extends Node
|
||||
{
|
||||
/**
|
||||
* The number of hidden items in this database
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $hiddenCount = 0;
|
||||
|
||||
/**
|
||||
* Initialises the class
|
||||
*
|
||||
* @param string $name An identifier for the new node
|
||||
* @param int $type Type of node, may be one of CONTAINER or OBJECT
|
||||
* @param bool $isGroup Whether this object has been created
|
||||
* while grouping nodes
|
||||
*/
|
||||
public function __construct($name, $type = Node::OBJECT, $isGroup = false)
|
||||
{
|
||||
parent::__construct($name, $type, $isGroup);
|
||||
$this->icon = ['image' => 's_db', 'title' => __('Database operations')];
|
||||
|
||||
$this->links = [
|
||||
'text' => [
|
||||
'route' => Util::getUrlForOption($GLOBALS['cfg']['DefaultTabDatabase'], 'database'),
|
||||
'params' => ['db' => null],
|
||||
],
|
||||
'icon' => ['route' => '/database/operations', 'params' => ['db' => null]],
|
||||
'title' => __('Structure'),
|
||||
];
|
||||
|
||||
$this->classes = 'database';
|
||||
$this->urlParamName = 'db';
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of children of type $type present inside this container
|
||||
* This method is overridden by the PhpMyAdmin\Navigation\Nodes\NodeDatabase
|
||||
* and PhpMyAdmin\Navigation\Nodes\NodeTable classes
|
||||
*
|
||||
* @param string $type The type of item we are looking for
|
||||
* ('tables', 'views', etc)
|
||||
* @param string $searchClause A string used to filter the results of
|
||||
* the query
|
||||
* @param bool $singleItem Whether to get presence of a single known
|
||||
* item or false in none
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getPresence($type = '', $searchClause = '', $singleItem = false)
|
||||
{
|
||||
$retval = 0;
|
||||
switch ($type) {
|
||||
case 'tables':
|
||||
$retval = $this->getTableCount($searchClause, $singleItem);
|
||||
break;
|
||||
case 'views':
|
||||
$retval = $this->getViewCount($searchClause, $singleItem);
|
||||
break;
|
||||
case 'procedures':
|
||||
$retval = $this->getProcedureCount($searchClause, $singleItem);
|
||||
break;
|
||||
case 'functions':
|
||||
$retval = $this->getFunctionCount($searchClause, $singleItem);
|
||||
break;
|
||||
case 'events':
|
||||
$retval = $this->getEventCount($searchClause, $singleItem);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return $retval;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of tables or views present inside this database
|
||||
*
|
||||
* @param string $which tables|views
|
||||
* @param string $searchClause A string used to filter the results of
|
||||
* the query
|
||||
* @param bool $singleItem Whether to get presence of a single known
|
||||
* item or false in none
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
private function getTableOrViewCount($which, $searchClause, $singleItem)
|
||||
{
|
||||
global $dbi;
|
||||
|
||||
$db = $this->realName;
|
||||
if ($which === 'tables') {
|
||||
$condition = 'IN';
|
||||
} else {
|
||||
$condition = 'NOT IN';
|
||||
}
|
||||
|
||||
if (! $GLOBALS['cfg']['Server']['DisableIS']) {
|
||||
$db = $dbi->escapeString($db);
|
||||
$query = 'SELECT COUNT(*) ';
|
||||
$query .= 'FROM `INFORMATION_SCHEMA`.`TABLES` ';
|
||||
$query .= "WHERE `TABLE_SCHEMA`='" . $db . "' ";
|
||||
$query .= 'AND `TABLE_TYPE` ' . $condition . "('BASE TABLE', 'SYSTEM VERSIONED') ";
|
||||
if (! empty($searchClause)) {
|
||||
$query .= 'AND ' . $this->getWhereClauseForSearch($searchClause, $singleItem, 'TABLE_NAME');
|
||||
}
|
||||
|
||||
$retval = (int) $dbi->fetchValue($query);
|
||||
} else {
|
||||
$query = 'SHOW FULL TABLES FROM ';
|
||||
$query .= Util::backquote($db);
|
||||
$query .= ' WHERE `Table_type` ' . $condition . "('BASE TABLE', 'SYSTEM VERSIONED') ";
|
||||
if (! empty($searchClause)) {
|
||||
$query .= 'AND ' . $this->getWhereClauseForSearch($searchClause, $singleItem, 'Tables_in_' . $db);
|
||||
}
|
||||
|
||||
$retval = $dbi->queryAndGetNumRows($query);
|
||||
}
|
||||
|
||||
return $retval;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of tables present inside this database
|
||||
*
|
||||
* @param string $searchClause A string used to filter the results of
|
||||
* the query
|
||||
* @param bool $singleItem Whether to get presence of a single known
|
||||
* item or false in none
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
private function getTableCount($searchClause, $singleItem)
|
||||
{
|
||||
return $this->getTableOrViewCount('tables', $searchClause, $singleItem);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of views present inside this database
|
||||
*
|
||||
* @param string $searchClause A string used to filter the results of
|
||||
* the query
|
||||
* @param bool $singleItem Whether to get presence of a single known
|
||||
* item or false in none
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
private function getViewCount($searchClause, $singleItem)
|
||||
{
|
||||
return $this->getTableOrViewCount('views', $searchClause, $singleItem);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of procedures present inside this database
|
||||
*
|
||||
* @param string $searchClause A string used to filter the results of
|
||||
* the query
|
||||
* @param bool $singleItem Whether to get presence of a single known
|
||||
* item or false in none
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
private function getProcedureCount($searchClause, $singleItem)
|
||||
{
|
||||
global $dbi;
|
||||
|
||||
$db = $this->realName;
|
||||
if (! $GLOBALS['cfg']['Server']['DisableIS']) {
|
||||
$db = $dbi->escapeString($db);
|
||||
$query = 'SELECT COUNT(*) ';
|
||||
$query .= 'FROM `INFORMATION_SCHEMA`.`ROUTINES` ';
|
||||
$query .= 'WHERE `ROUTINE_SCHEMA` '
|
||||
. Util::getCollateForIS() . "='" . $db . "'";
|
||||
$query .= "AND `ROUTINE_TYPE`='PROCEDURE' ";
|
||||
if (! empty($searchClause)) {
|
||||
$query .= 'AND ' . $this->getWhereClauseForSearch($searchClause, $singleItem, 'ROUTINE_NAME');
|
||||
}
|
||||
|
||||
$retval = (int) $dbi->fetchValue($query);
|
||||
} else {
|
||||
$db = $dbi->escapeString($db);
|
||||
$query = "SHOW PROCEDURE STATUS WHERE `Db`='" . $db . "' ";
|
||||
if (! empty($searchClause)) {
|
||||
$query .= 'AND ' . $this->getWhereClauseForSearch($searchClause, $singleItem, 'Name');
|
||||
}
|
||||
|
||||
$retval = $dbi->queryAndGetNumRows($query);
|
||||
}
|
||||
|
||||
return $retval;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of functions present inside this database
|
||||
*
|
||||
* @param string $searchClause A string used to filter the results of
|
||||
* the query
|
||||
* @param bool $singleItem Whether to get presence of a single known
|
||||
* item or false in none
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
private function getFunctionCount($searchClause, $singleItem)
|
||||
{
|
||||
global $dbi;
|
||||
|
||||
$db = $this->realName;
|
||||
if (! $GLOBALS['cfg']['Server']['DisableIS']) {
|
||||
$db = $dbi->escapeString($db);
|
||||
$query = 'SELECT COUNT(*) ';
|
||||
$query .= 'FROM `INFORMATION_SCHEMA`.`ROUTINES` ';
|
||||
$query .= 'WHERE `ROUTINE_SCHEMA` '
|
||||
. Util::getCollateForIS() . "='" . $db . "' ";
|
||||
$query .= "AND `ROUTINE_TYPE`='FUNCTION' ";
|
||||
if (! empty($searchClause)) {
|
||||
$query .= 'AND ' . $this->getWhereClauseForSearch($searchClause, $singleItem, 'ROUTINE_NAME');
|
||||
}
|
||||
|
||||
$retval = (int) $dbi->fetchValue($query);
|
||||
} else {
|
||||
$db = $dbi->escapeString($db);
|
||||
$query = "SHOW FUNCTION STATUS WHERE `Db`='" . $db . "' ";
|
||||
if (! empty($searchClause)) {
|
||||
$query .= 'AND ' . $this->getWhereClauseForSearch($searchClause, $singleItem, 'Name');
|
||||
}
|
||||
|
||||
$retval = $dbi->queryAndGetNumRows($query);
|
||||
}
|
||||
|
||||
return $retval;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of events present inside this database
|
||||
*
|
||||
* @param string $searchClause A string used to filter the results of
|
||||
* the query
|
||||
* @param bool $singleItem Whether to get presence of a single known
|
||||
* item or false in none
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
private function getEventCount($searchClause, $singleItem)
|
||||
{
|
||||
global $dbi;
|
||||
|
||||
$db = $this->realName;
|
||||
if (! $GLOBALS['cfg']['Server']['DisableIS']) {
|
||||
$db = $dbi->escapeString($db);
|
||||
$query = 'SELECT COUNT(*) ';
|
||||
$query .= 'FROM `INFORMATION_SCHEMA`.`EVENTS` ';
|
||||
$query .= 'WHERE `EVENT_SCHEMA` '
|
||||
. Util::getCollateForIS() . "='" . $db . "' ";
|
||||
if (! empty($searchClause)) {
|
||||
$query .= 'AND ' . $this->getWhereClauseForSearch($searchClause, $singleItem, 'EVENT_NAME');
|
||||
}
|
||||
|
||||
$retval = (int) $dbi->fetchValue($query);
|
||||
} else {
|
||||
$db = Util::backquote($db);
|
||||
$query = 'SHOW EVENTS FROM ' . $db . ' ';
|
||||
if (! empty($searchClause)) {
|
||||
$query .= 'WHERE ' . $this->getWhereClauseForSearch($searchClause, $singleItem, 'Name');
|
||||
}
|
||||
|
||||
$retval = $dbi->queryAndGetNumRows($query);
|
||||
}
|
||||
|
||||
return $retval;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the WHERE clause for searching inside a database
|
||||
*
|
||||
* @param string $searchClause A string used to filter the results of the query
|
||||
* @param bool $singleItem Whether to get presence of a single known item
|
||||
* @param string $columnName Name of the column in the result set to match
|
||||
*
|
||||
* @return string WHERE clause for searching
|
||||
*/
|
||||
private function getWhereClauseForSearch(
|
||||
$searchClause,
|
||||
$singleItem,
|
||||
$columnName
|
||||
) {
|
||||
global $dbi;
|
||||
|
||||
$query = '';
|
||||
if ($singleItem) {
|
||||
$query .= Util::backquote($columnName) . ' = ';
|
||||
$query .= "'" . $dbi->escapeString($searchClause) . "'";
|
||||
} else {
|
||||
$query .= Util::backquote($columnName) . ' LIKE ';
|
||||
$query .= "'%" . $dbi->escapeString($searchClause)
|
||||
. "%'";
|
||||
}
|
||||
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the names of children of type $type present inside this container
|
||||
* This method is overridden by the PhpMyAdmin\Navigation\Nodes\NodeDatabase
|
||||
* and PhpMyAdmin\Navigation\Nodes\NodeTable classes
|
||||
*
|
||||
* @param string $type The type of item we are looking for
|
||||
* ('tables', 'views', etc)
|
||||
* @param int $pos The offset of the list within the results
|
||||
* @param string $searchClause A string used to filter the results of the query
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getData($type, $pos, $searchClause = '')
|
||||
{
|
||||
$pos = (int) $pos;
|
||||
$retval = [];
|
||||
switch ($type) {
|
||||
case 'tables':
|
||||
$retval = $this->getTables($pos, $searchClause);
|
||||
break;
|
||||
case 'views':
|
||||
$retval = $this->getViews($pos, $searchClause);
|
||||
break;
|
||||
case 'procedures':
|
||||
$retval = $this->getProcedures($pos, $searchClause);
|
||||
break;
|
||||
case 'functions':
|
||||
$retval = $this->getFunctions($pos, $searchClause);
|
||||
break;
|
||||
case 'events':
|
||||
$retval = $this->getEvents($pos, $searchClause);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
// Remove hidden items so that they are not displayed in navigation tree
|
||||
$relationParameters = $this->relation->getRelationParameters();
|
||||
if ($relationParameters->navigationItemsHidingFeature !== null) {
|
||||
$hiddenItems = $this->getHiddenItems(substr($type, 0, -1));
|
||||
foreach ($retval as $key => $item) {
|
||||
if (! in_array($item, $hiddenItems)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
unset($retval[$key]);
|
||||
}
|
||||
}
|
||||
|
||||
return $retval;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return list of hidden items of given type
|
||||
*
|
||||
* @param string $type The type of items we are looking for
|
||||
* ('table', 'function', 'group', etc.)
|
||||
*
|
||||
* @return array Array containing hidden items of given type
|
||||
*/
|
||||
public function getHiddenItems($type)
|
||||
{
|
||||
global $dbi;
|
||||
|
||||
$db = $this->realName;
|
||||
$relationParameters = $this->relation->getRelationParameters();
|
||||
if ($relationParameters->navigationItemsHidingFeature === null || $relationParameters->user === null) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$navTable = Util::backquote($relationParameters->navigationItemsHidingFeature->database)
|
||||
. '.' . Util::backquote($relationParameters->navigationItemsHidingFeature->navigationHiding);
|
||||
$sqlQuery = 'SELECT `item_name` FROM ' . $navTable
|
||||
. " WHERE `username`='" . $relationParameters->user . "'"
|
||||
. " AND `item_type`='" . $type
|
||||
. "' AND `db_name`='" . $dbi->escapeString($db)
|
||||
. "'";
|
||||
$result = $dbi->tryQueryAsControlUser($sqlQuery);
|
||||
if ($result) {
|
||||
return $result->fetchAllColumn();
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the list of tables or views inside this database
|
||||
*
|
||||
* @param string $which tables|views
|
||||
* @param int $pos The offset of the list within the results
|
||||
* @param string $searchClause A string used to filter the results of the query
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
private function getTablesOrViews($which, int $pos, $searchClause)
|
||||
{
|
||||
global $dbi;
|
||||
|
||||
if ($which === 'tables') {
|
||||
$condition = 'IN';
|
||||
} else {
|
||||
$condition = 'NOT IN';
|
||||
}
|
||||
|
||||
$maxItems = $GLOBALS['cfg']['MaxNavigationItems'];
|
||||
$retval = [];
|
||||
$db = $this->realName;
|
||||
if (! $GLOBALS['cfg']['Server']['DisableIS']) {
|
||||
$escdDb = $dbi->escapeString($db);
|
||||
$query = 'SELECT `TABLE_NAME` AS `name` ';
|
||||
$query .= 'FROM `INFORMATION_SCHEMA`.`TABLES` ';
|
||||
$query .= "WHERE `TABLE_SCHEMA`='" . $escdDb . "' ";
|
||||
$query .= 'AND `TABLE_TYPE` ' . $condition . "('BASE TABLE', 'SYSTEM VERSIONED') ";
|
||||
if (! empty($searchClause)) {
|
||||
$query .= "AND `TABLE_NAME` LIKE '%";
|
||||
$query .= $dbi->escapeString($searchClause);
|
||||
$query .= "%'";
|
||||
}
|
||||
|
||||
$query .= 'ORDER BY `TABLE_NAME` ASC ';
|
||||
$query .= 'LIMIT ' . $pos . ', ' . $maxItems;
|
||||
$retval = $dbi->fetchResult($query);
|
||||
} else {
|
||||
$query = ' SHOW FULL TABLES FROM ';
|
||||
$query .= Util::backquote($db);
|
||||
$query .= ' WHERE `Table_type` ' . $condition . "('BASE TABLE', 'SYSTEM VERSIONED') ";
|
||||
if (! empty($searchClause)) {
|
||||
$query .= 'AND ' . Util::backquote('Tables_in_' . $db);
|
||||
$query .= " LIKE '%" . $dbi->escapeString($searchClause);
|
||||
$query .= "%'";
|
||||
}
|
||||
|
||||
$handle = $dbi->tryQuery($query);
|
||||
if ($handle !== false) {
|
||||
$count = 0;
|
||||
if ($handle->seek($pos)) {
|
||||
while ($arr = $handle->fetchRow()) {
|
||||
if ($count >= $maxItems) {
|
||||
break;
|
||||
}
|
||||
|
||||
$retval[] = $arr[0];
|
||||
$count++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $retval;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the list of tables inside this database
|
||||
*
|
||||
* @param int $pos The offset of the list within the results
|
||||
* @param string $searchClause A string used to filter the results of the query
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
private function getTables(int $pos, $searchClause)
|
||||
{
|
||||
return $this->getTablesOrViews('tables', $pos, $searchClause);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the list of views inside this database
|
||||
*
|
||||
* @param int $pos The offset of the list within the results
|
||||
* @param string $searchClause A string used to filter the results of the query
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
private function getViews(int $pos, $searchClause)
|
||||
{
|
||||
return $this->getTablesOrViews('views', $pos, $searchClause);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the list of procedures or functions inside this database
|
||||
*
|
||||
* @param string $routineType PROCEDURE|FUNCTION
|
||||
* @param int $pos The offset of the list within the results
|
||||
* @param string $searchClause A string used to filter the results of the query
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
private function getRoutines($routineType, $pos, $searchClause)
|
||||
{
|
||||
global $dbi;
|
||||
|
||||
$maxItems = $GLOBALS['cfg']['MaxNavigationItems'];
|
||||
$retval = [];
|
||||
$db = $this->realName;
|
||||
if (! $GLOBALS['cfg']['Server']['DisableIS']) {
|
||||
$escdDb = $dbi->escapeString($db);
|
||||
$query = 'SELECT `ROUTINE_NAME` AS `name` ';
|
||||
$query .= 'FROM `INFORMATION_SCHEMA`.`ROUTINES` ';
|
||||
$query .= 'WHERE `ROUTINE_SCHEMA` '
|
||||
. Util::getCollateForIS() . "='" . $escdDb . "'";
|
||||
$query .= "AND `ROUTINE_TYPE`='" . $routineType . "' ";
|
||||
if (! empty($searchClause)) {
|
||||
$query .= "AND `ROUTINE_NAME` LIKE '%";
|
||||
$query .= $dbi->escapeString($searchClause);
|
||||
$query .= "%'";
|
||||
}
|
||||
|
||||
$query .= 'ORDER BY `ROUTINE_NAME` ASC ';
|
||||
$query .= 'LIMIT ' . intval($pos) . ', ' . $maxItems;
|
||||
$retval = $dbi->fetchResult($query);
|
||||
} else {
|
||||
$escdDb = $dbi->escapeString($db);
|
||||
$query = 'SHOW ' . $routineType . " STATUS WHERE `Db`='" . $escdDb . "' ";
|
||||
if (! empty($searchClause)) {
|
||||
$query .= "AND `Name` LIKE '%";
|
||||
$query .= $dbi->escapeString($searchClause);
|
||||
$query .= "%'";
|
||||
}
|
||||
|
||||
$handle = $dbi->tryQuery($query);
|
||||
if ($handle !== false) {
|
||||
$count = 0;
|
||||
if ($handle->seek($pos)) {
|
||||
while ($arr = $handle->fetchAssoc()) {
|
||||
if ($count >= $maxItems) {
|
||||
break;
|
||||
}
|
||||
|
||||
$retval[] = $arr['Name'];
|
||||
$count++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $retval;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the list of procedures inside this database
|
||||
*
|
||||
* @param int $pos The offset of the list within the results
|
||||
* @param string $searchClause A string used to filter the results of the query
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
private function getProcedures($pos, $searchClause)
|
||||
{
|
||||
return $this->getRoutines('PROCEDURE', $pos, $searchClause);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the list of functions inside this database
|
||||
*
|
||||
* @param int $pos The offset of the list within the results
|
||||
* @param string $searchClause A string used to filter the results of the query
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
private function getFunctions($pos, $searchClause)
|
||||
{
|
||||
return $this->getRoutines('FUNCTION', $pos, $searchClause);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the list of events inside this database
|
||||
*
|
||||
* @param int $pos The offset of the list within the results
|
||||
* @param string $searchClause A string used to filter the results of the query
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
private function getEvents($pos, $searchClause)
|
||||
{
|
||||
global $dbi;
|
||||
|
||||
$maxItems = $GLOBALS['cfg']['MaxNavigationItems'];
|
||||
$retval = [];
|
||||
$db = $this->realName;
|
||||
if (! $GLOBALS['cfg']['Server']['DisableIS']) {
|
||||
$escdDb = $dbi->escapeString($db);
|
||||
$query = 'SELECT `EVENT_NAME` AS `name` ';
|
||||
$query .= 'FROM `INFORMATION_SCHEMA`.`EVENTS` ';
|
||||
$query .= 'WHERE `EVENT_SCHEMA` '
|
||||
. Util::getCollateForIS() . "='" . $escdDb . "' ";
|
||||
if (! empty($searchClause)) {
|
||||
$query .= "AND `EVENT_NAME` LIKE '%";
|
||||
$query .= $dbi->escapeString($searchClause);
|
||||
$query .= "%'";
|
||||
}
|
||||
|
||||
$query .= 'ORDER BY `EVENT_NAME` ASC ';
|
||||
$query .= 'LIMIT ' . intval($pos) . ', ' . $maxItems;
|
||||
$retval = $dbi->fetchResult($query);
|
||||
} else {
|
||||
$escdDb = Util::backquote($db);
|
||||
$query = 'SHOW EVENTS FROM ' . $escdDb . ' ';
|
||||
if (! empty($searchClause)) {
|
||||
$query .= "WHERE `Name` LIKE '%";
|
||||
$query .= $dbi->escapeString($searchClause);
|
||||
$query .= "%'";
|
||||
}
|
||||
|
||||
$handle = $dbi->tryQuery($query);
|
||||
if ($handle !== false) {
|
||||
$count = 0;
|
||||
if ($handle->seek($pos)) {
|
||||
while ($arr = $handle->fetchAssoc()) {
|
||||
if ($count >= $maxItems) {
|
||||
break;
|
||||
}
|
||||
|
||||
$retval[] = $arr['Name'];
|
||||
$count++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $retval;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns HTML for control buttons displayed infront of a node
|
||||
*
|
||||
* @return string HTML for control buttons
|
||||
*/
|
||||
public function getHtmlForControlButtons(): string
|
||||
{
|
||||
$ret = '';
|
||||
$relationParameters = $this->relation->getRelationParameters();
|
||||
if ($relationParameters->navigationItemsHidingFeature !== null) {
|
||||
if ($this->hiddenCount > 0) {
|
||||
$params = [
|
||||
'showUnhideDialog' => true,
|
||||
'dbName' => $this->realName,
|
||||
];
|
||||
$ret = '<span class="dbItemControls">'
|
||||
. '<a href="' . Url::getFromRoute('/navigation') . '" data-post="'
|
||||
. Url::getCommon($params, '', false) . '"'
|
||||
. ' class="showUnhide ajax">'
|
||||
. Generator::getImage(
|
||||
'show',
|
||||
__('Show hidden items')
|
||||
)
|
||||
. '</a></span>';
|
||||
}
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the number of hidden items in this database
|
||||
*
|
||||
* @param int $count hidden item count
|
||||
*/
|
||||
public function setHiddenCount($count): void
|
||||
{
|
||||
$this->hiddenCount = $count;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of hidden items in this database
|
||||
*
|
||||
* @return int hidden item count
|
||||
*/
|
||||
public function getHiddenCount()
|
||||
{
|
||||
return $this->hiddenCount;
|
||||
}
|
||||
}
|
|
@ -1,59 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Functionality for the navigation tree
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace PhpMyAdmin\Navigation\Nodes;
|
||||
|
||||
use PhpMyAdmin\Html\Generator;
|
||||
use PhpMyAdmin\Url;
|
||||
|
||||
use function __;
|
||||
|
||||
/**
|
||||
* Represents a node that is a child of a database node
|
||||
* This may either be a concrete child such as table or a container
|
||||
* such as table container
|
||||
*/
|
||||
abstract class NodeDatabaseChild extends Node
|
||||
{
|
||||
/**
|
||||
* Returns the type of the item represented by the node.
|
||||
*
|
||||
* @return string type of the item
|
||||
*/
|
||||
abstract protected function getItemType();
|
||||
|
||||
/**
|
||||
* Returns HTML for control buttons displayed infront of a node
|
||||
*
|
||||
* @return string HTML for control buttons
|
||||
*/
|
||||
public function getHtmlForControlButtons(): string
|
||||
{
|
||||
$ret = '';
|
||||
$relationParameters = $this->relation->getRelationParameters();
|
||||
if ($relationParameters->navigationItemsHidingFeature !== null) {
|
||||
$db = $this->realParent()->realName;
|
||||
$item = $this->realName;
|
||||
|
||||
$params = [
|
||||
'hideNavItem' => true,
|
||||
'itemType' => $this->getItemType(),
|
||||
'itemName' => $item,
|
||||
'dbName' => $db,
|
||||
];
|
||||
|
||||
$ret = '<span class="navItemControls">'
|
||||
. '<a href="' . Url::getFromRoute('/navigation') . '" data-post="'
|
||||
. Url::getCommon($params, '', false) . '"'
|
||||
. ' class="hideNavItem ajax">'
|
||||
. Generator::getImage('hide', __('Hide'))
|
||||
. '</a></span>';
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
}
|
|
@ -1,41 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Represents container node that carries children of a database
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace PhpMyAdmin\Navigation\Nodes;
|
||||
|
||||
/**
|
||||
* Represents container node that carries children of a database
|
||||
*/
|
||||
abstract class NodeDatabaseChildContainer extends NodeDatabaseChild
|
||||
{
|
||||
/**
|
||||
* Initialises the class by setting the common variables
|
||||
*
|
||||
* @param string $name An identifier for the new node
|
||||
* @param int $type Type of node, may be one of CONTAINER or OBJECT
|
||||
*/
|
||||
public function __construct($name, $type = Node::OBJECT)
|
||||
{
|
||||
parent::__construct($name, $type);
|
||||
if (! $GLOBALS['cfg']['NavigationTreeEnableGrouping']) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->separator = $GLOBALS['cfg']['NavigationTreeTableSeparator'];
|
||||
$this->separatorDepth = (int) $GLOBALS['cfg']['NavigationTreeTableLevel'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the type of the item represented by the node.
|
||||
*
|
||||
* @return string type of the item
|
||||
*/
|
||||
protected function getItemType()
|
||||
{
|
||||
return 'group';
|
||||
}
|
||||
}
|
|
@ -1,47 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Functionality for the navigation tree
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace PhpMyAdmin\Navigation\Nodes;
|
||||
|
||||
use PhpMyAdmin\CheckUserPrivileges;
|
||||
use PhpMyAdmin\Navigation\NodeFactory;
|
||||
|
||||
use function _pgettext;
|
||||
|
||||
/**
|
||||
* Represents a container for database nodes in the navigation tree
|
||||
*/
|
||||
class NodeDatabaseContainer extends Node
|
||||
{
|
||||
/**
|
||||
* Initialises the class
|
||||
*
|
||||
* @param string $name An identifier for the new node
|
||||
*/
|
||||
public function __construct($name)
|
||||
{
|
||||
global $dbi;
|
||||
|
||||
$checkUserPrivileges = new CheckUserPrivileges($dbi);
|
||||
$checkUserPrivileges->getPrivileges();
|
||||
|
||||
parent::__construct($name, Node::CONTAINER);
|
||||
|
||||
if (! $GLOBALS['is_create_db_priv'] || $GLOBALS['cfg']['ShowCreateDb'] === false) {
|
||||
return;
|
||||
}
|
||||
|
||||
$newLabel = _pgettext('Create new database', 'New');
|
||||
$new = NodeFactory::getInstanceForNewNode($newLabel, 'new_database italics');
|
||||
$new->icon = ['image' => 'b_newdb', 'title' => $newLabel];
|
||||
$new->links = [
|
||||
'text' => ['route' => '/server/databases', 'params' => []],
|
||||
'icon' => ['route' => '/server/databases', 'params' => []],
|
||||
];
|
||||
$this->addChild($new);
|
||||
}
|
||||
}
|
|
@ -1,52 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Functionality for the navigation tree
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace PhpMyAdmin\Navigation\Nodes;
|
||||
|
||||
use function __;
|
||||
|
||||
/**
|
||||
* Represents a event node in the navigation tree
|
||||
*/
|
||||
class NodeEvent extends NodeDatabaseChild
|
||||
{
|
||||
/**
|
||||
* Initialises the class
|
||||
*
|
||||
* @param string $name An identifier for the new node
|
||||
* @param int $type Type of node, may be one of CONTAINER or OBJECT
|
||||
* @param bool $isGroup Whether this object has been created
|
||||
* while grouping nodes
|
||||
*/
|
||||
public function __construct($name, $type = Node::OBJECT, $isGroup = false)
|
||||
{
|
||||
parent::__construct($name, $type, $isGroup);
|
||||
$this->icon = ['image' => 'b_events', 'title' => __('Event')];
|
||||
$this->links = [
|
||||
'text' => [
|
||||
'route' => '/database/events',
|
||||
'params' => ['edit_item' => 1, 'db' => null, 'item_name' => null],
|
||||
],
|
||||
'icon' => [
|
||||
'route' => '/database/events',
|
||||
'params' => ['export_item' => 1, 'db' => null, 'item_name' => null],
|
||||
],
|
||||
];
|
||||
$this->classes = 'event';
|
||||
$this->urlParamName = 'item_name';
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the type of the item represented by the node.
|
||||
*
|
||||
* @return string type of the item
|
||||
*/
|
||||
protected function getItemType()
|
||||
{
|
||||
return 'event';
|
||||
}
|
||||
}
|
|
@ -1,42 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Functionality for the navigation tree
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace PhpMyAdmin\Navigation\Nodes;
|
||||
|
||||
use PhpMyAdmin\Navigation\NodeFactory;
|
||||
|
||||
use function __;
|
||||
use function _pgettext;
|
||||
|
||||
/**
|
||||
* Represents a container for events nodes in the navigation tree
|
||||
*/
|
||||
class NodeEventContainer extends NodeDatabaseChildContainer
|
||||
{
|
||||
/**
|
||||
* Initialises the class
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct(__('Events'), Node::CONTAINER);
|
||||
$this->icon = ['image' => 'b_events', 'title' => __('Events')];
|
||||
$this->links = [
|
||||
'text' => ['route' => '/database/events', 'params' => ['db' => null]],
|
||||
'icon' => ['route' => '/database/events', 'params' => ['db' => null]],
|
||||
];
|
||||
$this->realName = 'events';
|
||||
|
||||
$newLabel = _pgettext('Create new event', 'New');
|
||||
$new = NodeFactory::getInstanceForNewNode($newLabel, 'new_event italics');
|
||||
$new->icon = ['image' => 'b_event_add', 'title' => $newLabel];
|
||||
$new->links = [
|
||||
'text' => ['route' => '/database/events', 'params' => ['add_item' => 1, 'db' => null]],
|
||||
'icon' => ['route' => '/database/events', 'params' => ['add_item' => 1, 'db' => null]],
|
||||
];
|
||||
$this->addChild($new);
|
||||
}
|
||||
}
|
|
@ -1,52 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Functionality for the navigation tree
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace PhpMyAdmin\Navigation\Nodes;
|
||||
|
||||
use function __;
|
||||
|
||||
/**
|
||||
* Represents a function node in the navigation tree
|
||||
*/
|
||||
class NodeFunction extends NodeDatabaseChild
|
||||
{
|
||||
/**
|
||||
* Initialises the class
|
||||
*
|
||||
* @param string $name An identifier for the new node
|
||||
* @param int $type Type of node, may be one of CONTAINER or OBJECT
|
||||
* @param bool $isGroup Whether this object has been created
|
||||
* while grouping nodes
|
||||
*/
|
||||
public function __construct($name, $type = Node::OBJECT, $isGroup = false)
|
||||
{
|
||||
parent::__construct($name, $type, $isGroup);
|
||||
$this->icon = ['image' => 'b_routines', 'title' => __('Function')];
|
||||
$this->links = [
|
||||
'text' => [
|
||||
'route' => '/database/routines',
|
||||
'params' => ['item_type' => 'FUNCTION', 'edit_item' => 1, 'db' => null, 'item_name' => null],
|
||||
],
|
||||
'icon' => [
|
||||
'route' => '/database/routines',
|
||||
'params' => ['item_type' => 'FUNCTION', 'execute_dialog' => 1, 'db' => null, 'item_name' => null],
|
||||
],
|
||||
];
|
||||
$this->classes = 'function';
|
||||
$this->urlParamName = 'item_name';
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the type of the item represented by the node.
|
||||
*
|
||||
* @return string type of the item
|
||||
*/
|
||||
protected function getItemType()
|
||||
{
|
||||
return 'function';
|
||||
}
|
||||
}
|
|
@ -1,48 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Functionality for the navigation tree
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace PhpMyAdmin\Navigation\Nodes;
|
||||
|
||||
use PhpMyAdmin\Navigation\NodeFactory;
|
||||
|
||||
use function __;
|
||||
use function _pgettext;
|
||||
|
||||
/**
|
||||
* Represents a container for functions nodes in the navigation tree
|
||||
*/
|
||||
class NodeFunctionContainer extends NodeDatabaseChildContainer
|
||||
{
|
||||
/**
|
||||
* Initialises the class
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct(__('Functions'), Node::CONTAINER);
|
||||
$this->icon = ['image' => 'b_routines', 'title' => __('Functions')];
|
||||
$this->links = [
|
||||
'text' => ['route' => '/database/routines', 'params' => ['type' => 'FUNCTION', 'db' => null]],
|
||||
'icon' => ['route' => '/database/routines', 'params' => ['type' => 'FUNCTION', 'db' => null]],
|
||||
];
|
||||
$this->realName = 'functions';
|
||||
|
||||
$newLabel = _pgettext('Create new function', 'New');
|
||||
$new = NodeFactory::getInstanceForNewNode($newLabel, 'new_function italics');
|
||||
$new->icon = ['image' => 'b_routine_add', 'title' => $newLabel];
|
||||
$new->links = [
|
||||
'text' => [
|
||||
'route' => '/database/routines',
|
||||
'params' => ['item_type' => 'FUNCTION', 'add_item' => 1, 'db' => null],
|
||||
],
|
||||
'icon' => [
|
||||
'route' => '/database/routines',
|
||||
'params' => ['item_type' => 'FUNCTION', 'add_item' => 1, 'db' => null],
|
||||
],
|
||||
];
|
||||
$this->addChild($new);
|
||||
}
|
||||
}
|
|
@ -1,36 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Functionality for the navigation tree
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace PhpMyAdmin\Navigation\Nodes;
|
||||
|
||||
use function __;
|
||||
|
||||
/**
|
||||
* Represents a index node in the navigation tree
|
||||
*/
|
||||
class NodeIndex extends Node
|
||||
{
|
||||
/**
|
||||
* Initialises the class
|
||||
*
|
||||
* @param string $name An identifier for the new node
|
||||
* @param int $type Type of node, may be one of CONTAINER or OBJECT
|
||||
* @param bool $isGroup Whether this object has been created
|
||||
* while grouping nodes
|
||||
*/
|
||||
public function __construct($name, $type = Node::OBJECT, $isGroup = false)
|
||||
{
|
||||
parent::__construct($name, $type, $isGroup);
|
||||
$this->icon = ['image' => 'b_index', 'title' => __('Index')];
|
||||
$this->links = [
|
||||
'text' => ['route' => '/table/indexes', 'params' => ['db' => null, 'table' => null, 'index' => null]],
|
||||
'icon' => ['route' => '/table/indexes', 'params' => ['db' => null, 'table' => null, 'index' => null]],
|
||||
];
|
||||
$this->classes = 'index';
|
||||
$this->urlParamName = 'index';
|
||||
}
|
||||
}
|
|
@ -1,48 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Functionality for the navigation tree
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace PhpMyAdmin\Navigation\Nodes;
|
||||
|
||||
use PhpMyAdmin\Navigation\NodeFactory;
|
||||
|
||||
use function __;
|
||||
use function _pgettext;
|
||||
|
||||
/**
|
||||
* Represents a container for index nodes in the navigation tree
|
||||
*/
|
||||
class NodeIndexContainer extends Node
|
||||
{
|
||||
/**
|
||||
* Initialises the class
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct(__('Indexes'), Node::CONTAINER);
|
||||
$this->icon = ['image' => 'b_index', 'title' => __('Indexes')];
|
||||
$this->links = [
|
||||
'text' => ['route' => '/table/structure', 'params' => ['db' => null, 'table' => null]],
|
||||
'icon' => ['route' => '/table/structure', 'params' => ['db' => null, 'table' => null]],
|
||||
];
|
||||
$this->realName = 'indexes';
|
||||
|
||||
$newLabel = _pgettext('Create new index', 'New');
|
||||
$new = NodeFactory::getInstanceForNewNode($newLabel, 'new_index italics');
|
||||
$new->icon = ['image' => 'b_index_add', 'title' => $newLabel];
|
||||
$new->links = [
|
||||
'text' => [
|
||||
'route' => '/table/indexes',
|
||||
'params' => ['create_index' => 1, 'added_fields' => 2, 'db' => null, 'table' => null],
|
||||
],
|
||||
'icon' => [
|
||||
'route' => '/table/indexes',
|
||||
'params' => ['create_index' => 1, 'added_fields' => 2, 'db' => null, 'table' => null],
|
||||
],
|
||||
];
|
||||
$this->addChild($new);
|
||||
}
|
||||
}
|
|
@ -1,52 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Functionality for the navigation tree
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace PhpMyAdmin\Navigation\Nodes;
|
||||
|
||||
use function __;
|
||||
|
||||
/**
|
||||
* Represents a procedure node in the navigation tree
|
||||
*/
|
||||
class NodeProcedure extends NodeDatabaseChild
|
||||
{
|
||||
/**
|
||||
* Initialises the class
|
||||
*
|
||||
* @param string $name An identifier for the new node
|
||||
* @param int $type Type of node, may be one of CONTAINER or OBJECT
|
||||
* @param bool $isGroup Whether this object has been created
|
||||
* while grouping nodes
|
||||
*/
|
||||
public function __construct($name, $type = Node::OBJECT, $isGroup = false)
|
||||
{
|
||||
parent::__construct($name, $type, $isGroup);
|
||||
$this->icon = ['image' => 'b_routines', 'title' => __('Procedure')];
|
||||
$this->links = [
|
||||
'text' => [
|
||||
'route' => '/database/routines',
|
||||
'params' => ['item_type' => 'PROCEDURE', 'edit_item' => 1, 'db' => null, 'item_name' => null],
|
||||
],
|
||||
'icon' => [
|
||||
'route' => '/database/routines',
|
||||
'params' => ['item_type' => 'PROCEDURE', 'execute_dialog' => 1, 'db' => null, 'item_name' => null],
|
||||
],
|
||||
];
|
||||
$this->classes = 'procedure';
|
||||
$this->urlParamName = 'item_name';
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the type of the item represented by the node.
|
||||
*
|
||||
* @return string type of the item
|
||||
*/
|
||||
protected function getItemType()
|
||||
{
|
||||
return 'procedure';
|
||||
}
|
||||
}
|
|
@ -1,42 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Functionality for the navigation tree
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace PhpMyAdmin\Navigation\Nodes;
|
||||
|
||||
use PhpMyAdmin\Navigation\NodeFactory;
|
||||
|
||||
use function __;
|
||||
use function _pgettext;
|
||||
|
||||
/**
|
||||
* Represents a container for procedure nodes in the navigation tree
|
||||
*/
|
||||
class NodeProcedureContainer extends NodeDatabaseChildContainer
|
||||
{
|
||||
/**
|
||||
* Initialises the class
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct(__('Procedures'), Node::CONTAINER);
|
||||
$this->icon = ['image' => 'b_routines', 'title' => __('Procedures')];
|
||||
$this->links = [
|
||||
'text' => ['route' => '/database/routines', 'params' => ['type' => 'PROCEDURE', 'db' => null]],
|
||||
'icon' => ['route' => '/database/routines', 'params' => ['type' => 'PROCEDURE', 'db' => null]],
|
||||
];
|
||||
$this->realName = 'procedures';
|
||||
|
||||
$newLabel = _pgettext('Create new procedure', 'New');
|
||||
$new = NodeFactory::getInstanceForNewNode($newLabel, 'new_procedure italics');
|
||||
$new->icon = ['image' => 'b_routine_add', 'title' => $newLabel];
|
||||
$new->links = [
|
||||
'text' => ['route' => '/database/routines', 'params' => ['add_item' => 1, 'db' => null]],
|
||||
'icon' => ['route' => '/database/routines', 'params' => ['add_item' => 1, 'db' => null]],
|
||||
];
|
||||
$this->addChild($new);
|
||||
}
|
||||
}
|
|
@ -1,318 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Functionality for the navigation tree
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace PhpMyAdmin\Navigation\Nodes;
|
||||
|
||||
use PhpMyAdmin\Url;
|
||||
use PhpMyAdmin\Util;
|
||||
|
||||
use function __;
|
||||
use function in_array;
|
||||
use function intval;
|
||||
|
||||
/**
|
||||
* Represents a columns node in the navigation tree
|
||||
*/
|
||||
class NodeTable extends NodeDatabaseChild
|
||||
{
|
||||
/**
|
||||
* For the second IMG tag, used when rendering the node.
|
||||
*
|
||||
* @var array<string, string>|null
|
||||
* @psalm-var array{image: string, title: string}|null
|
||||
*/
|
||||
public $secondIcon;
|
||||
|
||||
/**
|
||||
* Initialises the class
|
||||
*
|
||||
* @param string $name An identifier for the new node
|
||||
* @param int $type Type of node, may be one of CONTAINER or OBJECT
|
||||
* @param bool $isGroup Whether this object has been created
|
||||
* while grouping nodes
|
||||
*/
|
||||
public function __construct($name, $type = Node::OBJECT, $isGroup = false)
|
||||
{
|
||||
parent::__construct($name, $type, $isGroup);
|
||||
$icon = $this->addIcon(
|
||||
Util::getScriptNameForOption($GLOBALS['cfg']['NavigationTreeDefaultTabTable'], 'table')
|
||||
);
|
||||
if ($icon !== null) {
|
||||
$this->icon = $icon;
|
||||
}
|
||||
|
||||
$this->secondIcon = $this->addIcon(
|
||||
Util::getScriptNameForOption($GLOBALS['cfg']['NavigationTreeDefaultTabTable2'], 'table')
|
||||
);
|
||||
$title = (string) Util::getTitleForTarget($GLOBALS['cfg']['DefaultTabTable']);
|
||||
$this->title = $title;
|
||||
|
||||
$this->links = [
|
||||
'text' => [
|
||||
'route' => Util::getUrlForOption($GLOBALS['cfg']['DefaultTabTable'], 'table'),
|
||||
'params' => ['pos' => 0, 'db' => null, 'table' => null],
|
||||
],
|
||||
'icon' => [
|
||||
'route' => Util::getUrlForOption($GLOBALS['cfg']['NavigationTreeDefaultTabTable'], 'table'),
|
||||
'params' => ['db' => null, 'table' => null],
|
||||
],
|
||||
'second_icon' => [
|
||||
'route' => Util::getUrlForOption($GLOBALS['cfg']['NavigationTreeDefaultTabTable2'], 'table'),
|
||||
'params' => ['db' => null, 'table' => null],
|
||||
],
|
||||
'title' => $this->title,
|
||||
];
|
||||
$this->classes = 'nav_node_table';
|
||||
$this->urlParamName = 'table';
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of children of type $type present inside this container
|
||||
* This method is overridden by the PhpMyAdmin\Navigation\Nodes\NodeDatabase
|
||||
* and PhpMyAdmin\Navigation\Nodes\NodeTable classes
|
||||
*
|
||||
* @param string $type The type of item we are looking for
|
||||
* ('columns' or 'indexes')
|
||||
* @param string $searchClause A string used to filter the results of the query
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getPresence($type = '', $searchClause = '')
|
||||
{
|
||||
global $dbi;
|
||||
|
||||
$retval = 0;
|
||||
$db = $this->realParent()->realName;
|
||||
$table = $this->realName;
|
||||
switch ($type) {
|
||||
case 'columns':
|
||||
if (! $GLOBALS['cfg']['Server']['DisableIS']) {
|
||||
$db = $dbi->escapeString($db);
|
||||
$table = $dbi->escapeString($table);
|
||||
$query = 'SELECT COUNT(*) ';
|
||||
$query .= 'FROM `INFORMATION_SCHEMA`.`COLUMNS` ';
|
||||
$query .= "WHERE `TABLE_NAME`='" . $table . "' ";
|
||||
$query .= "AND `TABLE_SCHEMA`='" . $db . "'";
|
||||
$retval = (int) $dbi->fetchValue($query);
|
||||
} else {
|
||||
$db = Util::backquote($db);
|
||||
$table = Util::backquote($table);
|
||||
$query = 'SHOW COLUMNS FROM ' . $table . ' FROM ' . $db . '';
|
||||
$retval = (int) $dbi->queryAndGetNumRows($query);
|
||||
}
|
||||
|
||||
break;
|
||||
case 'indexes':
|
||||
$db = Util::backquote($db);
|
||||
$table = Util::backquote($table);
|
||||
$query = 'SHOW INDEXES FROM ' . $table . ' FROM ' . $db;
|
||||
$retval = (int) $dbi->queryAndGetNumRows($query);
|
||||
break;
|
||||
case 'triggers':
|
||||
if (! $GLOBALS['cfg']['Server']['DisableIS']) {
|
||||
$db = $dbi->escapeString($db);
|
||||
$table = $dbi->escapeString($table);
|
||||
$query = 'SELECT COUNT(*) ';
|
||||
$query .= 'FROM `INFORMATION_SCHEMA`.`TRIGGERS` ';
|
||||
$query .= 'WHERE `EVENT_OBJECT_SCHEMA` '
|
||||
. Util::getCollateForIS() . "='" . $db . "' ";
|
||||
$query .= 'AND `EVENT_OBJECT_TABLE` '
|
||||
. Util::getCollateForIS() . "='" . $table . "'";
|
||||
$retval = (int) $dbi->fetchValue($query);
|
||||
} else {
|
||||
$db = Util::backquote($db);
|
||||
$table = $dbi->escapeString($table);
|
||||
$query = 'SHOW TRIGGERS FROM ' . $db . " WHERE `Table` = '" . $table . "'";
|
||||
$retval = (int) $dbi->queryAndGetNumRows($query);
|
||||
}
|
||||
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return $retval;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the names of children of type $type present inside this container
|
||||
* This method is overridden by the PhpMyAdmin\Navigation\Nodes\NodeDatabase
|
||||
* and PhpMyAdmin\Navigation\Nodes\NodeTable classes
|
||||
*
|
||||
* @param string $type The type of item we are looking for
|
||||
* ('tables', 'views', etc)
|
||||
* @param int $pos The offset of the list within the results
|
||||
* @param string $searchClause A string used to filter the results of the query
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getData($type, $pos, $searchClause = '')
|
||||
{
|
||||
global $dbi;
|
||||
|
||||
$maxItems = $GLOBALS['cfg']['MaxNavigationItems'];
|
||||
$retval = [];
|
||||
$db = $this->realParent()->realName;
|
||||
$table = $this->realName;
|
||||
switch ($type) {
|
||||
case 'columns':
|
||||
if (! $GLOBALS['cfg']['Server']['DisableIS']) {
|
||||
$db = $dbi->escapeString($db);
|
||||
$table = $dbi->escapeString($table);
|
||||
$query = 'SELECT `COLUMN_NAME` AS `name` ';
|
||||
$query .= ',`COLUMN_KEY` AS `key` ';
|
||||
$query .= ',`DATA_TYPE` AS `type` ';
|
||||
$query .= ',`COLUMN_DEFAULT` AS `default` ';
|
||||
$query .= ",IF (`IS_NULLABLE` = 'NO', '', 'nullable') AS `nullable` ";
|
||||
$query .= 'FROM `INFORMATION_SCHEMA`.`COLUMNS` ';
|
||||
$query .= "WHERE `TABLE_NAME`='" . $table . "' ";
|
||||
$query .= "AND `TABLE_SCHEMA`='" . $db . "' ";
|
||||
$query .= 'ORDER BY `COLUMN_NAME` ASC ';
|
||||
$query .= 'LIMIT ' . intval($pos) . ', ' . $maxItems;
|
||||
$retval = $dbi->fetchResult($query);
|
||||
break;
|
||||
}
|
||||
|
||||
$db = Util::backquote($db);
|
||||
$table = Util::backquote($table);
|
||||
$query = 'SHOW COLUMNS FROM ' . $table . ' FROM ' . $db;
|
||||
$handle = $dbi->tryQuery($query);
|
||||
if ($handle === false) {
|
||||
break;
|
||||
}
|
||||
|
||||
$count = 0;
|
||||
if ($handle->seek($pos)) {
|
||||
while ($arr = $handle->fetchAssoc()) {
|
||||
if ($count >= $maxItems) {
|
||||
break;
|
||||
}
|
||||
|
||||
$retval[] = [
|
||||
'name' => $arr['Field'],
|
||||
'key' => $arr['Key'],
|
||||
'type' => Util::extractColumnSpec($arr['Type'])['type'],
|
||||
'default' => $arr['Default'],
|
||||
'nullable' => ($arr['Null'] === 'NO' ? '' : 'nullable'),
|
||||
];
|
||||
$count++;
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
case 'indexes':
|
||||
$db = Util::backquote($db);
|
||||
$table = Util::backquote($table);
|
||||
$query = 'SHOW INDEXES FROM ' . $table . ' FROM ' . $db;
|
||||
$handle = $dbi->tryQuery($query);
|
||||
if ($handle === false) {
|
||||
break;
|
||||
}
|
||||
|
||||
$count = 0;
|
||||
foreach ($handle as $arr) {
|
||||
if (in_array($arr['Key_name'], $retval)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($pos <= 0 && $count < $maxItems) {
|
||||
$retval[] = $arr['Key_name'];
|
||||
$count++;
|
||||
}
|
||||
|
||||
$pos--;
|
||||
}
|
||||
|
||||
break;
|
||||
case 'triggers':
|
||||
if (! $GLOBALS['cfg']['Server']['DisableIS']) {
|
||||
$db = $dbi->escapeString($db);
|
||||
$table = $dbi->escapeString($table);
|
||||
$query = 'SELECT `TRIGGER_NAME` AS `name` ';
|
||||
$query .= 'FROM `INFORMATION_SCHEMA`.`TRIGGERS` ';
|
||||
$query .= 'WHERE `EVENT_OBJECT_SCHEMA` '
|
||||
. Util::getCollateForIS() . "='" . $db . "' ";
|
||||
$query .= 'AND `EVENT_OBJECT_TABLE` '
|
||||
. Util::getCollateForIS() . "='" . $table . "' ";
|
||||
$query .= 'ORDER BY `TRIGGER_NAME` ASC ';
|
||||
$query .= 'LIMIT ' . intval($pos) . ', ' . $maxItems;
|
||||
$retval = $dbi->fetchResult($query);
|
||||
break;
|
||||
}
|
||||
|
||||
$db = Util::backquote($db);
|
||||
$table = $dbi->escapeString($table);
|
||||
$query = 'SHOW TRIGGERS FROM ' . $db . " WHERE `Table` = '" . $table . "'";
|
||||
$handle = $dbi->tryQuery($query);
|
||||
if ($handle === false) {
|
||||
break;
|
||||
}
|
||||
|
||||
$count = 0;
|
||||
if ($handle->seek($pos)) {
|
||||
while ($arr = $handle->fetchAssoc()) {
|
||||
if ($count >= $maxItems) {
|
||||
break;
|
||||
}
|
||||
|
||||
$retval[] = $arr['Trigger'];
|
||||
$count++;
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return $retval;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the type of the item represented by the node.
|
||||
*
|
||||
* @return string type of the item
|
||||
*/
|
||||
protected function getItemType()
|
||||
{
|
||||
return 'table';
|
||||
}
|
||||
|
||||
/**
|
||||
* Add an icon to navigation tree
|
||||
*
|
||||
* @param string $page Page name to redirect
|
||||
*
|
||||
* @return array<string, string>|null
|
||||
* @psalm-return array{image: string, title: string}|null
|
||||
*/
|
||||
private function addIcon(string $page): ?array
|
||||
{
|
||||
if (empty($page)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
switch ($page) {
|
||||
case Url::getFromRoute('/table/structure'):
|
||||
return ['image' => 'b_props', 'title' => __('Structure')];
|
||||
|
||||
case Url::getFromRoute('/table/search'):
|
||||
return ['image' => 'b_search', 'title' => __('Search')];
|
||||
|
||||
case Url::getFromRoute('/table/change'):
|
||||
return ['image' => 'b_insrow', 'title' => __('Insert')];
|
||||
|
||||
case Url::getFromRoute('/table/sql'):
|
||||
return ['image' => 'b_sql', 'title' => __('SQL')];
|
||||
|
||||
case Url::getFromRoute('/sql'):
|
||||
return ['image' => 'b_browse', 'title' => __('Browse')];
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -1,43 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Functionality for the navigation tree
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace PhpMyAdmin\Navigation\Nodes;
|
||||
|
||||
use PhpMyAdmin\Navigation\NodeFactory;
|
||||
|
||||
use function __;
|
||||
use function _pgettext;
|
||||
|
||||
/**
|
||||
* Represents a container for table nodes in the navigation tree
|
||||
*/
|
||||
class NodeTableContainer extends NodeDatabaseChildContainer
|
||||
{
|
||||
/**
|
||||
* Initialises the class
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct(__('Tables'), Node::CONTAINER);
|
||||
$this->icon = ['image' => 'b_browse', 'title' => __('Tables')];
|
||||
$this->links = [
|
||||
'text' => ['route' => '/database/structure', 'params' => ['tbl_type' => 'table', 'db' => null]],
|
||||
'icon' => ['route' => '/database/structure', 'params' => ['tbl_type' => 'table', 'db' => null]],
|
||||
];
|
||||
$this->realName = 'tables';
|
||||
$this->classes = 'tableContainer subContainer';
|
||||
|
||||
$newLabel = _pgettext('Create new table', 'New');
|
||||
$new = NodeFactory::getInstanceForNewNode($newLabel, 'new_table italics');
|
||||
$new->icon = ['image' => 'b_table_add', 'title' => $newLabel];
|
||||
$new->links = [
|
||||
'text' => ['route' => '/table/create', 'params' => ['db' => null]],
|
||||
'icon' => ['route' => '/table/create', 'params' => ['db' => null]],
|
||||
];
|
||||
$this->addChild($new);
|
||||
}
|
||||
}
|
|
@ -1,42 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Functionality for the navigation tree
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace PhpMyAdmin\Navigation\Nodes;
|
||||
|
||||
use function __;
|
||||
|
||||
/**
|
||||
* Represents a trigger node in the navigation tree
|
||||
*/
|
||||
class NodeTrigger extends Node
|
||||
{
|
||||
/**
|
||||
* Initialises the class
|
||||
*
|
||||
* @param string $name An identifier for the new node
|
||||
* @param int $type Type of node, may be one of CONTAINER or OBJECT
|
||||
* @param bool $isGroup Whether this object has been created
|
||||
* while grouping nodes
|
||||
*/
|
||||
public function __construct($name, $type = Node::OBJECT, $isGroup = false)
|
||||
{
|
||||
parent::__construct($name, $type, $isGroup);
|
||||
$this->icon = ['image' => 'b_triggers', 'title' => __('Trigger')];
|
||||
$this->links = [
|
||||
'text' => [
|
||||
'route' => '/database/triggers',
|
||||
'params' => ['edit_item' => 1, 'db' => null, 'item_name' => null],
|
||||
],
|
||||
'icon' => [
|
||||
'route' => '/database/triggers',
|
||||
'params' => ['export_item' => 1, 'db' => null, 'item_name' => null],
|
||||
],
|
||||
];
|
||||
$this->classes = 'trigger';
|
||||
$this->urlParamName = 'item_name';
|
||||
}
|
||||
}
|
|
@ -1,42 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Functionality for the navigation tree
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace PhpMyAdmin\Navigation\Nodes;
|
||||
|
||||
use PhpMyAdmin\Navigation\NodeFactory;
|
||||
|
||||
use function __;
|
||||
use function _pgettext;
|
||||
|
||||
/**
|
||||
* Represents a container for trigger nodes in the navigation tree
|
||||
*/
|
||||
class NodeTriggerContainer extends Node
|
||||
{
|
||||
/**
|
||||
* Initialises the class
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct(__('Triggers'), Node::CONTAINER);
|
||||
$this->icon = ['image' => 'b_triggers', 'title' => __('Triggers')];
|
||||
$this->links = [
|
||||
'text' => ['route' => '/database/triggers', 'params' => ['db' => null, 'table' => null]],
|
||||
'icon' => ['route' => '/database/triggers', 'params' => ['db' => null, 'table' => null]],
|
||||
];
|
||||
$this->realName = 'triggers';
|
||||
|
||||
$newLabel = _pgettext('Create new trigger', 'New');
|
||||
$new = NodeFactory::getInstanceForNewNode($newLabel, 'new_trigger italics');
|
||||
$new->icon = ['image' => 'b_trigger_add', 'title' => $newLabel];
|
||||
$new->links = [
|
||||
'text' => ['route' => '/database/triggers', 'params' => ['add_item' => 1, 'db' => null]],
|
||||
'icon' => ['route' => '/database/triggers', 'params' => ['add_item' => 1, 'db' => null]],
|
||||
];
|
||||
$this->addChild($new);
|
||||
}
|
||||
}
|
|
@ -1,46 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Functionality for the navigation tree
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace PhpMyAdmin\Navigation\Nodes;
|
||||
|
||||
use function __;
|
||||
|
||||
/**
|
||||
* Represents a view node in the navigation tree
|
||||
*/
|
||||
class NodeView extends NodeDatabaseChild
|
||||
{
|
||||
/**
|
||||
* Initialises the class
|
||||
*
|
||||
* @param string $name An identifier for the new node
|
||||
* @param int $type Type of node, may be one of CONTAINER or OBJECT
|
||||
* @param bool $isGroup Whether this object has been created
|
||||
* while grouping nodes
|
||||
*/
|
||||
public function __construct($name, $type = Node::OBJECT, $isGroup = false)
|
||||
{
|
||||
parent::__construct($name, $type, $isGroup);
|
||||
$this->icon = ['image' => 'b_props', 'title' => __('View')];
|
||||
$this->links = [
|
||||
'text' => ['route' => '/sql', 'params' => ['pos' => 0, 'db' => null, 'table' => null]],
|
||||
'icon' => ['route' => '/table/structure', 'params' => ['db' => null, 'table' => null]],
|
||||
];
|
||||
$this->classes = 'view';
|
||||
$this->urlParamName = 'table';
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the type of the item represented by the node.
|
||||
*
|
||||
* @return string type of the item
|
||||
*/
|
||||
protected function getItemType()
|
||||
{
|
||||
return 'view';
|
||||
}
|
||||
}
|
|
@ -1,43 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Functionality for the navigation tree
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace PhpMyAdmin\Navigation\Nodes;
|
||||
|
||||
use PhpMyAdmin\Navigation\NodeFactory;
|
||||
|
||||
use function __;
|
||||
use function _pgettext;
|
||||
|
||||
/**
|
||||
* Represents a container for view nodes in the navigation tree
|
||||
*/
|
||||
class NodeViewContainer extends NodeDatabaseChildContainer
|
||||
{
|
||||
/**
|
||||
* Initialises the class
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct(__('Views'), Node::CONTAINER);
|
||||
$this->icon = ['image' => 'b_views', 'title' => __('Views')];
|
||||
$this->links = [
|
||||
'text' => ['route' => '/database/structure', 'params' => ['tbl_type' => 'view', 'db' => null]],
|
||||
'icon' => ['route' => '/database/structure', 'params' => ['tbl_type' => 'view', 'db' => null]],
|
||||
];
|
||||
$this->classes = 'viewContainer subContainer';
|
||||
$this->realName = 'views';
|
||||
|
||||
$newLabel = _pgettext('Create new view', 'New');
|
||||
$new = NodeFactory::getInstanceForNewNode($newLabel, 'new_view italics');
|
||||
$new->icon = ['image' => 'b_view_add', 'title' => $newLabel];
|
||||
$new->links = [
|
||||
'text' => ['route' => '/view/create', 'params' => ['db' => null]],
|
||||
'icon' => ['route' => '/view/create', 'params' => ['db' => null]],
|
||||
];
|
||||
$this->addChild($new);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue