5656use function floor ;
5757use function htmlspecialchars ;
5858use function in_array ;
59- use function is_array ;
6059use function is_bool ;
61- use function is_object ;
62- use function is_string ;
6360use function mb_strlen ;
6461use function mb_strpos ;
6562use function mb_substr ;
@@ -84,8 +81,8 @@ class NavigationTree
8481{
8582 private const SPECIAL_NODE_NAMES = ['tables ' , 'views ' , 'functions ' , 'procedures ' , 'events ' ];
8683
87- /** @var Node Reference to the root node of the tree */
88- private Node $ tree ;
84+ /** @var NodeDatabaseContainer Reference to the root node of the tree */
85+ private NodeDatabaseContainer $ tree ;
8986 /**
9087 * @var mixed[] The actual paths to all expanded nodes in the tree
9188 * This does not include nodes created after the grouping
@@ -211,15 +208,6 @@ public function __construct(
211208
212209 // Initialize the tree by creating a root node
213210 $ this ->tree = new NodeDatabaseContainer ($ this ->config , 'root ' );
214- if (
215- ! $ this ->config ->settings ['NavigationTreeEnableGrouping ' ]
216- || ! $ this ->config ->settings ['ShowDatabasesNavigationAsTree ' ]
217- ) {
218- return ;
219- }
220-
221- $ this ->tree ->separator = $ this ->config ->settings ['NavigationTreeDbSeparator ' ];
222- $ this ->tree ->separatorDepth = 10000 ;
223211 }
224212
225213 /**
@@ -676,18 +664,11 @@ public function groupNode(Node $node): void
676664 return ;
677665 }
678666
679- $ separators = [];
680- if (is_array ($ node ->separator )) {
681- $ separators = $ node ->separator ;
682- } elseif (is_string ($ node ->separator ) && $ node ->separator !== '' ) {
683- $ separators [] = $ node ->separator ;
684- }
685-
686667 $ prefixes = [];
687668 if ($ node ->separatorDepth > 0 ) {
688669 foreach ($ node ->children as $ child ) {
689670 $ prefixPos = false ;
690- foreach ($ separators as $ separator ) {
671+ foreach ($ node -> separators as $ separator ) {
691672 $ sepPos = mb_strpos ($ child ->name , $ separator );
692673 if (
693674 $ sepPos === false
@@ -771,7 +752,7 @@ public function groupNode(Node $node): void
771752 }
772753
773754 $ newChildren = [];
774- foreach ($ separators as $ separator ) {
755+ foreach ($ node -> separators as $ separator ) {
775756 $ separatorLength = strlen ($ separator );
776757 // FIXME: this could be more efficient
777758 foreach ($ node ->children as $ child ) {
@@ -785,7 +766,11 @@ public function groupNode(Node $node): void
785766 }
786767
787768 $ newChild = new $ child ($ this ->config , mb_substr ($ child ->name , $ keySeparatorLength ));
788- if ($ child instanceof NodeDatabase && $ child ->getHiddenCount () > 0 ) {
769+ if (
770+ $ child instanceof NodeDatabase
771+ && $ newChild instanceof NodeDatabase
772+ && $ child ->getHiddenCount () > 0
773+ ) {
789774 $ newChild ->setHiddenCount ($ child ->getHiddenCount ());
790775 }
791776
@@ -810,16 +795,16 @@ public function groupNode(Node $node): void
810795 // and the new group contains all of the current node's children, combine them
811796 $ class = $ node ::class;
812797 if (count ($ newChildren ) === $ numChildren && substr ($ class , strrpos ($ class , '\\' ) + 1 ) === 'Node ' ) {
813- $ node ->name .= $ separators [0 ] . htmlspecialchars ((string ) $ key );
814- $ node ->realName .= $ separators [0 ] . htmlspecialchars ((string ) $ key );
798+ $ node ->name .= $ node -> separators [0 ] . htmlspecialchars ((string ) $ key );
799+ $ node ->realName .= $ node -> separators [0 ] . htmlspecialchars ((string ) $ key );
815800 $ node ->separatorDepth --;
816801 foreach ($ newChildren as $ newChild ) {
817802 $ node ->removeChild ($ newChild ['replaces_name ' ]);
818803 $ node ->addChild ($ newChild ['node ' ]);
819804 }
820805 } else {
821806 $ groups [$ key ] = new Node ($ this ->config , (string ) $ key , NodeType::Container, true );
822- $ groups [$ key ]->separator = $ node ->separator ;
807+ $ groups [$ key ]->separators = $ node ->separators ;
823808 $ groups [$ key ]->separatorDepth = $ node ->separatorDepth - 1 ;
824809 $ groups [$ key ]->icon = ['image ' => 'b_group ' , 'title ' => __ ('Groups ' )];
825810 $ groups [$ key ]->pos2 = $ node ->pos2 ;
@@ -918,9 +903,9 @@ public function renderPath(UserPrivileges $userPrivileges): string|false
918903 if ($ hasSearchClause && ! is_bool ($ node )) {
919904 $ results = 0 ;
920905 if ($ this ->searchClause2 !== '' ) {
921- if ( is_object ( $ node ->realParent ())) {
922- $ results = $ node -> realParent ()
923- ->getPresence ($ userPrivileges , $ node ->realName , $ this ->searchClause2 );
906+ $ parent = $ node ->getRealParent ();
907+ if ( $ parent instanceof Node) {
908+ $ results = $ parent ->getPresence ($ userPrivileges , $ node ->realName , $ this ->searchClause2 );
924909 }
925910 } else {
926911 $ results = $ this ->tree ->getPresence ($ userPrivileges , 'databases ' , $ this ->searchClause );
@@ -1095,7 +1080,7 @@ private function renderNode(UserPrivileges $userPrivileges, Node $node, string $
10951080 'title ' => $ node ->icon ['title ' ],
10961081 ];
10971082
1098- if (isset ($ node ->links ['second_icon ' ], $ node ->secondIcon )) {
1083+ if ($ node instanceof NodeTable && isset ($ node ->links ['second_icon ' ], $ node ->secondIcon )) {
10991084 $ iconLinks [] = [
11001085 'route ' => $ node ->links ['second_icon ' ]['route ' ],
11011086 'params ' => array_merge (
@@ -1146,6 +1131,7 @@ private function renderNode(UserPrivileges $userPrivileges, Node $node, string $
11461131
11471132 return $ this ->template ->render ('navigation/tree/node ' , [
11481133 'node ' => $ node ,
1134+ 'displayName ' => $ node instanceof NodeColumn ? $ node ->displayName : $ node ->realName ,
11491135 'class ' => $ class ,
11501136 'show_node ' => $ showNode ,
11511137 'has_siblings ' => $ node ->hasSiblings (),
@@ -1269,7 +1255,7 @@ private function fastFilterHtml(UserPrivileges $userPrivileges, Node $node): str
12691255
12701256 $ nodeIsSpecial = in_array ($ node ->realName , self ::SPECIAL_NODE_NAMES , true );
12711257
1272- $ realParent = $ node ->realParent ();
1258+ $ realParent = $ node ->getRealParent ();
12731259 if (
12741260 $ nodeIsContainer && $ nodeIsSpecial
12751261 && $ realParent instanceof Node
@@ -1360,7 +1346,7 @@ private function getPageSelector(UserPrivileges $userPrivileges, Node $node): st
13601346 }
13611347
13621348 /** @var Node $realParent */
1363- $ realParent = $ node ->realParent ();
1349+ $ realParent = $ node ->getRealParent ();
13641350 $ num = $ realParent ->getPresence ($ userPrivileges , $ node ->realName , $ this ->searchClause2 );
13651351 $ retval .= Generator::getListNavigator (
13661352 $ num ,
0 commit comments