Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
drupal-3174996
Manage
Activity
Members
Labels
Plan
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Issue forks
drupal-3174996
Commits
f22b5d31
Commit
f22b5d31
authored
17 years ago
by
Gábor Hojtsy
Browse files
Options
Downloads
Patches
Plain Diff
#115847
by chx and pwolanin: traverse to upper menu items for default tabs
parent
8b8d7e6a
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
includes/menu.inc
+27
-14
27 additions, 14 deletions
includes/menu.inc
with
27 additions
and
14 deletions
includes/menu.inc
+
27
−
14
View file @
f22b5d31
...
...
@@ -914,7 +914,7 @@ function menu_secondary_links() {
* @param $level
* The level of tasks you ask for. Primary tasks are 0, secondary are 1.
* @return
*
An array of links to the tabs
.
*
Themed output corresponding to the tabs of the requested level
.
*/
function
menu_local_tasks
(
$level
=
0
)
{
static
$tabs
=
array
();
...
...
@@ -924,32 +924,39 @@ function menu_local_tasks($level = 0) {
if
(
!
$router_item
||
!
$router_item
[
'access'
])
{
return
array
();
}
// Get all tabs
$result
=
db_query
(
"SELECT * FROM
{
menu_router
}
WHERE tab_root = '%s'
AND tab_parent != ''
ORDER BY weight, title"
,
$router_item
[
'tab_root'
]);
// Get all tabs
and the root page.
$result
=
db_query
(
"SELECT * FROM
{
menu_router
}
WHERE tab_root = '%s' ORDER BY weight, title"
,
$router_item
[
'tab_root'
]);
$map
=
arg
();
$children
=
array
();
$ta
b_parent
=
array
();
$ta
sks
=
array
();
while
(
$item
=
db_fetch_array
(
$result
))
{
$children
[
$item
[
'tab_parent'
]][
$item
[
'path'
]]
=
$item
;
$tab_parent
[
$item
[
'path'
]]
=
$item
[
'tab_parent'
];
_menu_translate
(
$item
,
$map
,
TRUE
);
if
(
$item
[
'tab_parent'
])
{
// All tabs, but not the root page.
$children
[
$item
[
'tab_parent'
]][
$item
[
'path'
]]
=
$item
;
}
// Store the translated item for later use.
$tasks
[
$item
[
'path'
]]
=
$item
;
}
// Find all tabs below the current path
// Find all tabs below the current path
.
$path
=
$router_item
[
'path'
];
while
(
isset
(
$children
[
$path
]))
{
$tabs_current
=
''
;
$next_path
=
''
;
foreach
(
$children
[
$path
]
as
$item
)
{
_menu_translate
(
$item
,
$map
,
TRUE
);
if
(
$item
[
'access'
])
{
$link
=
l
(
$item
[
'title'
],
$item
[
'href'
]);
// TODO options?
// The default task is always active.
if
(
$item
[
'type'
]
==
MENU_DEFAULT_LOCAL_TASK
)
{
// Find the first parent which is not a default local task.
for
(
$p
=
$item
[
'tab_parent'
];
$tasks
[
$p
][
'type'
]
==
MENU_DEFAULT_LOCAL_TASK
;
$p
=
$tasks
[
$p
][
'tab_parent'
]);
$link
=
l
(
$item
[
'title'
],
$tasks
[
$p
][
'href'
]);
$tabs_current
.
=
theme
(
'menu_local_task'
,
$link
,
TRUE
);
$next_path
=
$item
[
'path'
];
}
else
{
$link
=
l
(
$item
[
'title'
],
$item
[
'href'
]);
$tabs_current
.
=
theme
(
'menu_local_task'
,
$link
);
}
}
...
...
@@ -967,15 +974,21 @@ function menu_local_tasks($level = 0) {
$next_path
=
''
;
$next_parent
=
''
;
foreach
(
$children
[
$parent
]
as
$item
)
{
_menu_translate
(
$item
,
$map
,
TRUE
);
if
(
$item
[
'access'
])
{
$link
=
l
(
$item
[
'title'
],
$item
[
'href'
]);
// TODO options?
if
(
$item
[
'type'
]
==
MENU_DEFAULT_LOCAL_TASK
)
{
// Find the first parent which is not a default local task.
for
(
$p
=
$item
[
'tab_parent'
];
$tasks
[
$p
][
'type'
]
==
MENU_DEFAULT_LOCAL_TASK
;
$p
=
$tasks
[
$p
][
'tab_parent'
]);
$link
=
l
(
$item
[
'title'
],
$tasks
[
$p
][
'href'
]);
}
else
{
$link
=
l
(
$item
[
'title'
],
$item
[
'href'
]);
}
// We check for the active tab.
if
(
$item
[
'path'
]
==
$path
)
{
$tabs_current
.
=
theme
(
'menu_local_task'
,
$link
,
TRUE
);
$next_path
=
$item
[
'tab_parent'
];
if
(
isset
(
$ta
b_parent
[
$next_path
]))
{
$next_parent
=
$ta
b_parent
[
$next_path
];
if
(
isset
(
$ta
sks
[
$next_path
]))
{
$next_parent
=
$ta
sks
[
$next_path
]
[
'tab_parent'
]
;
}
}
else
{
...
...
@@ -987,7 +1000,7 @@ function menu_local_tasks($level = 0) {
$parent
=
$next_parent
;
$tabs
[
$item
[
'number_parts'
]]
=
$tabs_current
;
}
// Sort by depth
// Sort by depth
.
ksort
(
$tabs
);
// Remove the depth, we are interested only in their relative placement.
$tabs
=
array_values
(
$tabs
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment