NodeDatabaseContainer.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. /**
  3. * Functionality for the navigation tree
  4. */
  5. declare(strict_types=1);
  6. namespace PhpMyAdmin\Navigation\Nodes;
  7. use PhpMyAdmin\CheckUserPrivileges;
  8. use PhpMyAdmin\Html\Generator;
  9. use PhpMyAdmin\Navigation\NodeFactory;
  10. use PhpMyAdmin\Url;
  11. /**
  12. * Represents a container for database nodes in the navigation tree
  13. */
  14. class NodeDatabaseContainer extends Node
  15. {
  16. /**
  17. * Initialises the class
  18. *
  19. * @param string $name An identifier for the new node
  20. */
  21. public function __construct($name)
  22. {
  23. global $dbi;
  24. $checkUserPrivileges = new CheckUserPrivileges($dbi);
  25. $checkUserPrivileges->getPrivileges();
  26. parent::__construct($name, Node::CONTAINER);
  27. if (! $GLOBALS['is_create_db_priv']
  28. || $GLOBALS['cfg']['ShowCreateDb'] === false
  29. ) {
  30. return;
  31. }
  32. $newLabel = _pgettext('Create new database', 'New');
  33. $new = NodeFactory::getInstanceForNewNode(
  34. $newLabel,
  35. 'new_database italics'
  36. );
  37. $new->icon = Generator::getImage('b_newdb', '');
  38. $new->links = [
  39. 'text' => Url::getFromRoute('/server/databases', ['server' => $GLOBALS['server']]),
  40. 'icon' => Url::getFromRoute('/server/databases', ['server' => $GLOBALS['server']]),
  41. ];
  42. $this->addChild($new);
  43. }
  44. }