2 /* vim: set expandtab sw=4 ts=4 sts=4: */
4 * Functionality for the navigation tree
6 * @package PhpMyAdmin-Navigation
8 if (! defined('PHPMYADMIN')) {
13 * Displays a collapsible of database objects in the navigation frame
15 * @package PhpMyAdmin-Navigation
17 class PMA_NavigationTree
20 * @var Node Reference to the root node of the tree
25 * @var array The actual paths to all expanded nodes in the tree
26 * This does not include nodes created after the grouping
27 * of nodes has been performed
29 private $_aPath = array();
32 * @var array The virtual paths to all expanded nodes in the tree
33 * This includes nodes created after the grouping of
34 * nodes has been performed
36 private $_vPath = array();
39 * @var int Position in the list of databases,
45 * @var int The names of the type of items that are being paginated on
46 * the second level of the navigation tree. These may be
47 * tables, views, functions, procedures or events.
49 private $_pos2_name = array();
52 * @var int The positions of nodes in the lists of tables, views,
53 * routines or events used for pagination
55 private $_pos2_value = array();
58 * @var int The names of the type of items that are being paginated
59 * on the second level of the navigation tree.
60 * These may be columns or indexes
62 private $_pos3_name = array();
65 * @var int The positions of nodes in the lists of columns or indexes
68 private $_pos3_value = array();
71 * @var string The search clause to use in SQL queries for
73 * Used by the asynchronous fast filter
75 private $_searchClause = '';
78 * @var string The search clause to use in SQL queries for
80 * Used by the asynchronous fast filter
82 private $_searchClause2 = '';
85 * Initialises the class
89 public function __construct()
91 // Save the position at which we are in the database list
92 if (isset($_REQUEST['pos'])) {
93 $this->_pos
= (int) $_REQUEST['pos'];
95 if (! isset($this->_pos
)) {
96 $this->_pos
= $this->_getNavigationDbPos();
98 // Get the active node
99 if (isset($_REQUEST['aPath'])) {
100 $this->_aPath
[0] = $this->_parsePath($_REQUEST['aPath']);
101 $this->_pos2_name
[0] = $_REQUEST['pos2_name'];
102 $this->_pos2_value
[0] = $_REQUEST['pos2_value'];
103 if (isset($_REQUEST['pos3_name'])) {
104 $this->_pos3_name
[0] = $_REQUEST['pos3_name'];
105 $this->_pos3_value
[0] = $_REQUEST['pos3_value'];
107 } else if (isset($_REQUEST['n0_aPath'])) {
109 while (isset($_REQUEST['n' . $count . '_aPath'])) {
110 $this->_aPath
[$count] = $this->_parsePath(
111 $_REQUEST['n' . $count . '_aPath']
113 $index = 'n' . $count . '_pos2_';
114 $this->_pos2_name
[$count] = $_REQUEST[$index . 'name'];
115 $this->_pos2_value
[$count] = $_REQUEST[$index . 'value'];
116 $index = 'n' . $count . '_pos3_';
117 if (isset($_REQUEST[$index])) {
118 $this->_pos3_name
[$count] = $_REQUEST[$index . 'name'];
119 $this->_pos3_value
[$count] = $_REQUEST[$index . 'value'];
124 if (isset($_REQUEST['vPath'])) {
125 $this->_vPath
[0] = $this->_parsePath($_REQUEST['vPath']);
126 } else if (isset($_REQUEST['n0_vPath'])) {
128 while (isset($_REQUEST['n' . $count . '_vPath'])) {
129 $this->_vPath
[$count] = $this->_parsePath(
130 $_REQUEST['n' . $count . '_vPath']
135 if (isset($_REQUEST['searchClause'])) {
136 $this->_searchClause
= $_REQUEST['searchClause'];
138 if (isset($_REQUEST['searchClause2'])) {
139 $this->_searchClause2
= $_REQUEST['searchClause2'];
141 // Initialise the tree by creating a root node
142 $node = PMA_NodeFactory
::getInstance('Node_Database_Container', 'root');
143 $this->_tree
= $node;
144 if ($GLOBALS['cfg']['NavigationTreeEnableGrouping']) {
145 $this->_tree
->separator
= $GLOBALS['cfg']['NavigationTreeDbSeparator'];
146 $this->_tree
->separator_depth
= 10000;
151 * Returns the database position for the page selector
155 private function _getNavigationDbPos()
158 if (! empty($GLOBALS['db'])) {
159 $query = "SELECT (COUNT(`SCHEMA_NAME`) DIV %d) * %d ";
160 $query .= "FROM `INFORMATION_SCHEMA`.`SCHEMATA` ";
161 $query .= "WHERE `SCHEMA_NAME` < '%s' ";
162 $query .= "ORDER BY `SCHEMA_NAME` ASC";
163 $retval = $GLOBALS['dbi']->fetchValue(
166 (int)$GLOBALS['cfg']['MaxNavigationItems'],
167 (int)$GLOBALS['cfg']['MaxNavigationItems'],
168 PMA_Util
::sqlAddSlashes($GLOBALS['db'])
176 * Converts an encoded path to a node in string format to an array
178 * @param string $string The path to parse
182 private function _parsePath($string)
184 $path = explode('.', $string);
185 foreach ($path as $key => $value) {
186 $path[$key] = base64_decode($value);
192 * Generates the tree structure so that it can be rendered later
194 * @return Node|false The active node or false in case of failure
196 private function _buildPath()
198 $retval = $this->_tree
;
200 // Add all databases unconditionally
201 $data = $this->_tree
->getData(
206 foreach ($data as $db) {
207 $node = PMA_NodeFactory
::getInstance('Node_Database', $db);
208 $this->_tree
->addChild($node);
211 // Whether build other parts of the tree depends
212 // on whether we have any paths in $this->_aPath
213 foreach ($this->_aPath
as $key => $path) {
214 $retval = $this->_buildPathPart(
216 $this->_pos2_name
[$key],
217 $this->_pos2_value
[$key],
218 isset($this->_pos3_name
[$key]) ?
$this->_pos3_name
[$key] : '',
219 isset($this->_pos3_value
[$key]) ?
$this->_pos3_value
[$key] : ''
226 * Builds a branch of the tree
228 * @param array $path A paths pointing to the branch
229 * of the tree that needs to be built
230 * @param string $type2 The type of item being paginated on
231 * the second level of the tree
232 * @param int $pos2 The position for the pagination of
233 * the branch at the second level of the tree
234 * @param string $type3 The type of item being paginated on
235 * the third level of the tree
236 * @param int $pos3 The position for the pagination of
237 * the branch at the third level of the tree
239 * @return Node|false The active node or false in case of failure
241 private function _buildPathPart($path, $type2, $pos2, $type3, $pos3)
244 if (count($path) > 1) {
245 array_shift($path); // remove 'root'
246 $db = $this->_tree
->getChild($path[0]);
253 $containers = $this->_addDbContainers($db, $type2, $pos2);
255 array_shift($path); // remove db
257 if ((count($path) > 0
258 && array_key_exists($path[0], $containers))
259 ||
count($containers) == 1
261 if (count($containers) == 1) {
262 $container = array_shift($containers);
264 $container = $db->getChild($path[0], true);
265 if ($container === false) {
269 $retval = $container;
271 if (count($container->children
) <= 1) {
272 $dbData = $db->getData(
273 $container->real_name
,
275 $this->_searchClause2
277 foreach ($dbData as $item) {
278 switch ($container->real_name
) {
280 $node = PMA_NodeFactory
::getInstance(
286 $node = PMA_NodeFactory
::getInstance(
292 $node = PMA_NodeFactory
::getInstance(
298 $node = PMA_NodeFactory
::getInstance(
304 $node = PMA_NodeFactory
::getInstance(
313 if ($type2 == $container->real_name
) {
316 $container->addChild($node);
320 if (count($path) > 1 && $path[0] != 'tables') {
323 array_shift($path); // remove container
324 if (count($path) > 0) {
325 $table = $container->getChild($path[0], true);
326 if ($table === false) {
330 $containers = $this->_addTableContainers(
336 array_shift($path); // remove table
338 && array_key_exists($path[0], $containers)
340 $container = $table->getChild($path[0], true);
341 $retval = $container;
342 $tableData = $table->getData(
343 $container->real_name
,
346 foreach ($tableData as $item) {
347 switch ($container->real_name
) {
349 $node = PMA_NodeFactory
::getInstance(
355 $node = PMA_NodeFactory
::getInstance(
361 $node = PMA_NodeFactory
::getInstance(
370 $node->pos2
= $container->parent
->pos2
;
371 if ($type3 == $container->real_name
) {
374 $container->addChild($node);
386 * Adds containers to a node that is a table
388 * References to existing children are returned
389 * if this function is called twice on the same node
391 * @param Node $table The table node, new containers will be
392 * attached to this node
393 * @param int $pos2 The position for the pagination of
394 * the branch at the second level of the tree
395 * @param string $type3 The type of item being paginated on
396 * the third level of the tree
397 * @param int $pos3 The position for the pagination of
398 * the branch at the third level of the tree
400 * @return array An array of new nodes
402 private function _addTableContainers($table, $pos2, $type3, $pos3)
405 if ($table->hasChildren(true) == 0) {
406 if ($table->getPresence('columns')) {
407 $retval['columns'] = PMA_NodeFactory
::getInstance(
408 'Node_Column_Container'
411 if ($table->getPresence('indexes')) {
412 $retval['indexes'] = PMA_NodeFactory
::getInstance(
413 'Node_Index_Container'
416 if ($table->getPresence('triggers')) {
417 $retval['triggers'] = PMA_NodeFactory
::getInstance(
418 'Node_Trigger_Container'
421 // Add all new Nodes to the tree
422 foreach ($retval as $node) {
424 if ($type3 == $node->real_name
) {
427 $table->addChild($node);
430 foreach ($table->children
as $node) {
431 if ($type3 == $node->real_name
) {
434 $retval[$node->real_name
] = $node;
441 * Adds containers to a node that is a database
443 * References to existing children are returned
444 * if this function is called twice on the same node
446 * @param Node $db The database node, new containers will be
447 * attached to this node
448 * @param string $type The type of item being paginated on
449 * the second level of the tree
450 * @param int $pos2 The position for the pagination of
451 * the branch at the second level of the tree
453 * @return array An array of new nodes
455 private function _addDbContainers($db, $type, $pos2)
458 if ($db->hasChildren(true) == 0) {
459 if ($db->getPresence('tables')) {
460 $retval['tables'] = PMA_NodeFactory
::getInstance(
461 'Node_Table_Container'
464 if ($db->getPresence('views')) {
465 $retval['views'] = PMA_NodeFactory
::getInstance(
466 'Node_View_Container'
469 if ($db->getPresence('functions')) {
470 $retval['functions'] = PMA_NodeFactory
::getInstance(
471 'Node_Function_Container'
474 if ($db->getPresence('procedures')) {
475 $retval['procedures'] = PMA_NodeFactory
::getInstance(
476 'Node_Procedure_Container'
479 if ($db->getPresence('events')) {
480 $retval['events'] = PMA_NodeFactory
::getInstance(
481 'Node_Event_Container'
484 // Add all new Nodes to the tree
485 foreach ($retval as $node) {
486 if ($type == $node->real_name
) {
489 $db->addChild($node);
492 foreach ($db->children
as $node) {
493 if ($type == $node->real_name
) {
496 $retval[$node->real_name
] = $node;
503 * Recursively groups tree nodes given a separator
505 * @param mixed $node The node to group or null
506 * to group the whole tree. If
507 * passed as an argument, $node
508 * must be of type CONTAINER
512 public function groupTree($node = null)
514 if (! isset($node)) {
515 $node = $this->_tree
;
517 $this->groupNode($node);
518 foreach ($node->children
as $child) {
519 $this->groupTree($child);
524 * Recursively groups tree nodes given a sperarator
526 * @param Node $node The node to group
530 public function groupNode($node)
532 if ($node->type
== Node
::CONTAINER
) {
533 $separators = array();
534 if (is_array($node->separator
)) {
535 $separators = $node->separator
;
536 } else if (strlen($node->separator
)) {
537 $separators[] = $node->separator
;
540 if ($node->separator_depth
> 0) {
541 foreach ($node->children
as $child) {
543 foreach ($separators as $separator) {
544 $sep_pos = strpos($child->name
, $separator);
545 if ($sep_pos != false
546 && $sep_pos != strlen($child->name
)
548 && ($prefix_pos == false ||
$sep_pos < $prefix_pos)
550 $prefix_pos = $sep_pos;
553 if ($prefix_pos !== false) {
554 $prefix = substr($child->name
, 0, $prefix_pos);
555 if (! isset($prefixes[$prefix])) {
556 $prefixes[$prefix] = 1;
558 $prefixes[$prefix]++
;
563 foreach ($prefixes as $key => $value) {
565 unset($prefixes[$key]);
568 if (count($prefixes)) {
570 foreach ($prefixes as $key => $value) {
571 $groups[$key] = new Node(
576 $groups[$key]->separator
= $node->separator
;
577 $groups[$key]->separator_depth
= $node->separator_depth
- 1;
578 $groups[$key]->icon
= '';
579 if (PMA_Util
::showIcons('TableNavigationLinksMode')) {
580 $groups[$key]->icon
= PMA_Util
::getImage(
584 $groups[$key]->pos2
= $node->pos2
;
585 $groups[$key]->pos3
= $node->pos3
;
586 if ($node instanceof Node_Table_Container
587 ||
$node instanceof Node_View_Container
589 $tblGroup = '&tbl_group='
590 . urlencode($key . $node->separator
);
591 $groups[$key]->links
= array(
592 'text' => $node->links
['text'] . $tblGroup,
593 'icon' => $node->links
['icon'] . $tblGroup
596 $node->addChild($groups[$key]);
597 foreach ($separators as $separator) {
598 // FIXME: this could be more efficient
599 foreach ($node->children
as $child) {
600 $name_substring = substr(
601 $child->name
, 0, strlen($key) +
strlen($separator)
603 if (($name_substring == $key . $separator
604 ||
$child->name
== $key)
605 && $child->type
== Node
::OBJECT
607 $class = get_class($child);
608 $new_child = PMA_NodeFactory
::getInstance(
612 strlen($key) +
strlen($separator)
615 $new_child->real_name
= $child->real_name
;
616 $new_child->icon
= $child->icon
;
617 $new_child->links
= $child->links
;
618 $new_child->pos2
= $child->pos2
;
619 $new_child->pos3
= $child->pos3
;
620 $groups[$key]->addChild($new_child);
621 foreach ($child->children
as $elm) {
622 $new_child->addChild($elm);
624 $node->removeChild($child->name
);
629 foreach ($prefixes as $key => $value) {
630 $this->groupNode($groups[$key]);
631 $groups[$key]->classes
= "navGroup";
638 * Renders a state of the tree, used in light mode when
639 * either JavaScript and/or Ajax are disabled
641 * @return string HTML code for the navigation tree
643 public function renderState()
646 $retval = $this->_fastFilterHtml($this->_tree
);
647 $retval .= $this->_getPageSelector($this->_tree
);
649 $retval .= "<div id='pma_navigation_tree_content'><ul>";
650 $children = $this->_tree
->children
;
651 usort($children, array('PMA_NavigationTree', 'sortNode'));
652 $this->_setVisibility();
653 for ($i=0; $i<count($children); $i++
) {
655 $retval .= $this->_renderNode($children[0], true, 'first');
656 } else if ($i +
1 != count($children)) {
657 $retval .= $this->_renderNode($children[$i], true);
659 $retval .= $this->_renderNode($children[$i], true, 'last');
662 $retval .= "</ul></div>";
667 * Renders a part of the tree, used for Ajax
668 * requests in light mode
670 * @return string HTML code for the navigation tree
672 public function renderPath()
674 $node = $this->_buildPath();
675 if ($node === false) {
679 $retval = "<div class='list_container' style='display: none;'>";
681 $retval .= $this->_fastFilterHtml($node);
682 $retval .= $this->_getPageSelector($node);
683 $children = $node->children
;
684 usort($children, array('PMA_NavigationTree', 'sortNode'));
685 for ($i=0; $i<count($children); $i++
) {
686 if ($i +
1 != count($children)) {
687 $retval .= $this->_renderNode($children[$i], true);
689 $retval .= $this->_renderNode($children[$i], true, 'last');
696 if (! empty($this->_searchClause
) ||
! empty($this->_searchClause2
)) {
697 if (! empty($this->_searchClause2
)) {
698 $results = $node->realParent()->getPresence(
700 $this->_searchClause2
703 $results = $this->_tree
->getPresence(
710 if (! empty($_REQUEST['results'])) {
711 $clientResults = (int)$_REQUEST['results'];
713 $otherResults = $results - $clientResults;
714 if ($otherResults < 1) {
717 $otherResults = sprintf(
719 '%s other result found',
720 '%s other results found',
726 PMA_Response
::getInstance()->addJSON(
735 * Renders the parameters that are required on the client
736 * side to know which page(s) we will be requesting data from
738 * @param Node $node The node to create the pagination parameters for
742 private function _getPaginationParamsHtml($node)
745 $paths = $node->getPaths();
746 if (isset($paths['aPath_clean'][2])) {
747 $retval .= "<span class='hide pos2_name'>";
748 $retval .= $paths['aPath_clean'][2];
749 $retval .= "</span>";
750 $retval .= "<span class='hide pos2_value'>";
751 $retval .= $node->pos2
;
752 $retval .= "</span>";
754 if (isset($paths['aPath_clean'][4])) {
755 $retval .= "<span class='hide pos3_name'>";
756 $retval .= $paths['aPath_clean'][4];
757 $retval .= "</span>";
758 $retval .= "<span class='hide pos3_value'>";
759 $retval .= $node->pos3
;
760 $retval .= "</span>";
766 * Renders a single node or a branch of the tree
768 * @param Node $node The node to render
769 * @param int|bool $recursive Bool: Whether to render a single node or a branch
770 * Int: How many levels deep to render
771 * @param string $class An additional class for the list item
773 * @return string HTML code for the tree node or branch
775 private function _renderNode($node, $recursive = -1, $class = '')
778 $paths = $node->getPaths();
779 if ($node->hasSiblings()
780 ||
isset($_REQUEST['results'])
781 ||
$node->realParent() === false
783 if ( $node->type
== Node
::CONTAINER
784 && count($node->children
) == 0
785 && $GLOBALS['is_ajax_request'] != true
790 if ($class ||
$node->classes
) {
791 $liClass = " class='" . trim($class . ' ' . $node->classes
) . "'";
793 $retval .= "<li$liClass>";
804 $parents = $node->parents(false, true);
805 if (count($parents)) {
806 $parentName = $parents[0]->real_name
;
809 ||
(! in_array($parentName, $sterile) && ! $node->isNew
)
812 if ($node->is_group
) {
816 if ($node->type
== Node
::CONTAINER
) {
817 $container = ' container';
819 $retval .= "<div class='block'>";
821 if ($class == 'first') {
822 $iClass = " class='first'";
824 $retval .= "<i$iClass></i>";
825 if (strpos($class, 'last') === false) {
826 $retval .= "<b></b>";
828 $icon = PMA_Util
::getImage('b_plus.png');
830 foreach ($this->_aPath
as $path) {
832 foreach ($paths['aPath_clean'] as $key => $part) {
833 if (! isset($path[$key]) ||
$part != $path[$key]) {
840 if (! $node->is_group
) {
841 $icon = PMA_Util
::getImage(
849 foreach ($this->_vPath
as $path) {
851 foreach ($paths['vPath_clean'] as $key => $part) {
852 if ((! isset($path[$key]) ||
$part != $path[$key])) {
859 $icon = PMA_Util
::getImage('b_minus.png');
864 $retval .= "<a class='expander$loaded$container'";
865 $retval .= " href='#'>";
866 $retval .= "<span class='hide aPath'>";
867 $retval .= $paths['aPath'];
868 $retval .= "</span>";
869 $retval .= "<span class='hide vPath'>";
870 $retval .= $paths['vPath'];
871 $retval .= "</span>";
872 $retval .= "<span class='hide pos'>";
873 $retval .= $this->_pos
;
874 $retval .= "</span>";
875 $retval .= $this->_getPaginationParamsHtml($node);
881 $retval .= "<div class='block'>";
883 if ($class == 'first') {
884 $iClass = " class='first'";
886 $retval .= "<i$iClass></i>";
887 $retval .= $this->_getPaginationParamsHtml($node);
899 $parent = $node->parents(false, true);
900 $isNewView = $parent[0]->real_name
== 'views' && $node->isNew
== true;
901 if ($parent[0]->type
== Node
::CONTAINER
902 && (in_array($parent[0]->real_name
, $haveAjax) ||
$isNewView)
904 $linkClass = ' class="ajax"';
907 if ($node->type
== Node
::CONTAINER
) {
910 if (PMA_Util
::showIcons('TableNavigationLinksMode')) {
911 $retval .= "<div class='block'>";
912 if (isset($node->links
['icon'])) {
914 foreach ($node->parents(true) as $parent) {
915 $args[] = urlencode($parent->real_name
);
917 $link = vsprintf($node->links
['icon'], $args);
918 $retval .= "<a$linkClass href='$link'>{$node->icon}</a>";
920 $retval .= "<u>{$node->icon}</u>";
924 if (isset($node->links
['text'])) {
926 foreach ($node->parents(true) as $parent) {
927 $args[] = urlencode($parent->real_name
);
929 $link = vsprintf($node->links
['text'], $args);
930 if ($node->type
== Node
::CONTAINER
) {
931 $retval .= "<a href='$link'>";
932 $retval .= htmlspecialchars($node->name
);
935 $retval .= "<a$linkClass href='$link'>";
936 $retval .= htmlspecialchars($node->real_name
);
940 $retval .= "{$node->name}";
942 if ($node->type
== Node
::CONTAINER
) {
945 $retval .= $node->getHtmlForControlButtons();
948 $node->visible
= true;
950 $retval .= $this->_getPaginationParamsHtml($node);
955 if ($node->visible
== false) {
956 $hide = " style='display: none;'";
958 $children = $node->children
;
959 usort($children, array('PMA_NavigationTree', 'sortNode'));
961 for ($i=0; $i<count($children); $i++
) {
962 if ($i +
1 != count($children)) {
963 $buffer .= $this->_renderNode(
966 $children[$i]->classes
969 $buffer .= $this->_renderNode(
972 $children[$i]->classes
. ' last'
976 if (! empty($buffer)) {
978 $retval .= "<div$hide class='list_container'><ul>";
980 $retval .= $this->_fastFilterHtml($node);
981 $retval .= $this->_getPageSelector($node);
984 $retval .= "</ul></div>";
988 if ($node->hasSiblings() ||
isset($_REQUEST['results'])) {
995 * Makes some nodes visible based on the which node is active
999 private function _setVisibility()
1001 foreach ($this->_vPath
as $path) {
1002 $node = $this->_tree
;
1003 foreach ($path as $value) {
1004 $child = $node->getChild($value);
1005 if ($child !== false) {
1006 $child->visible
= true;
1014 * Generates the HTML code for displaying the fast filter for tables
1016 * @param Node $node The node for which to generate the fast filter html
1018 * @return string LI element used for the fast filter
1020 private function _fastFilterHtml($node)
1023 $filter_min = (int)$GLOBALS['cfg']['NavigationTreeDisplayDbFilterMinimum'];
1024 if ($node === $this->_tree
1025 && $this->_tree
->getPresence() >= $filter_min
1027 $url_params = array(
1031 $retval .= '<li class="fast_filter db_fast_filter">';
1032 $retval .= '<form class="ajax fast_filter">';
1033 $retval .= PMA_getHiddenFields($url_params);
1034 $retval .= '<input class="searchClause" name="searchClause"';
1035 $retval .= ' accesskey="q"';
1036 // allow html5 placeholder attribute
1037 $placeholder_key = 'value';
1038 if (PMA_USR_BROWSER_AGENT
!== 'IE'
1039 || PMA_USR_BROWSER_VER
> 9
1041 $placeholder_key = 'placeholder';
1043 $retval .= " $placeholder_key='"
1044 . __('Filter databases by name or regex');
1046 $retval .= '<span title="' . __('Clear fast filter') . '">X</span>';
1047 $retval .= "</form>";
1050 } else if (($node->type
== Node
::CONTAINER
1051 && ( $node->real_name
== 'tables'
1052 ||
$node->real_name
== 'views'
1053 ||
$node->real_name
== 'functions'
1054 ||
$node->real_name
== 'procedures'
1055 ||
$node->real_name
== 'events'))
1056 && $node->realParent()->getPresence($node->real_name
) >= $filter_min
1058 $paths = $node->getPaths();
1059 $url_params = array(
1060 'pos' => $this->_pos
,
1061 'aPath' => $paths['aPath'],
1062 'vPath' => $paths['vPath'],
1063 'pos2_name' => $node->real_name
,
1066 $retval .= "<li class='fast_filter'>";
1067 $retval .= "<form class='ajax fast_filter'>";
1068 $retval .= PMA_getHiddenFields($url_params);
1069 $retval .= "<input class='searchClause' name='searchClause2'";
1070 // allow html5 placeholder attribute
1071 $placeholder_key = 'value';
1072 if (PMA_USR_BROWSER_AGENT
!== 'IE'
1073 || PMA_USR_BROWSER_VER
> 9
1075 $placeholder_key = 'placeholder';
1077 $retval .= " $placeholder_key='"
1078 . __('Filter by name or regex') . "' />";
1079 $retval .= "<span title='" . __('Clear fast filter') . "'>X</span>";
1080 $retval .= "</form>";
1087 * Generates the HTML code for displaying the list pagination
1089 * @param Node $node The node for whose children the page
1090 * selector will be created
1094 private function _getPageSelector($node)
1097 if ($node === $this->_tree
) {
1098 $retval .= PMA_Util
::getListNavigator(
1099 $this->_tree
->getPresence('databases', $this->_searchClause
),
1101 array('server' => $GLOBALS['server']),
1104 $GLOBALS['cfg']['MaxNavigationItems'],
1108 } else if ($node->type
== Node
::CONTAINER
&& ! $node->is_group
) {
1109 $paths = $node->getPaths();
1111 $level = isset($paths['aPath_clean'][4]) ?
3 : 2;
1112 $_url_params = array(
1113 'aPath' => $paths['aPath'],
1114 'vPath' => $paths['vPath'],
1115 'pos' => $this->_pos
,
1116 'server' => $GLOBALS['server'],
1117 'pos2_name' => $paths['aPath_clean'][2]
1121 $_url_params['pos2_value'] = $node->pos2
;
1122 $_url_params['pos3_name'] = $paths['aPath_clean'][4];
1126 $num = $node->realParent()->getPresence(
1128 $this->_searchClause2
1130 $retval .= PMA_Util
::getListNavigator(
1136 $GLOBALS['cfg']['MaxNavigationItems'],
1137 'pos' . $level . '_value'
1144 * Called by usort() for sorting the nodes in a container
1146 * @param Node $a The first element used in the comparison
1147 * @param Node $b The second element used in the comparison
1149 * @return int See strnatcmp() and strcmp()
1151 static public function sortNode($a, $b)
1155 } else if ($b->isNew
) {
1158 if ($GLOBALS['cfg']['NaturalOrder']) {
1159 return strnatcasecmp($a->name
, $b->name
);
1161 return strcasecmp($a->name
, $b->name
);