Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
Tenzing
/
Tz Tools
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
840f94ca
authored
2010-10-22 17:09:43 +0000
by
Chris Boden
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
Fixed hierarchy menu
1 parent
2ea55b3d
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
5 deletions
com/Menu/Menu.php
com/Menu/Menu.php
View file @
840f94c
...
...
@@ -23,25 +23,35 @@ class HierarchicalMenu implements Countable, Iterator {
private
$target_lookup
=
Array
();
public
function
__construct
(
Array
$menu
,
$parent
=
0
)
{
$
i
=
0
;
$
last_id
=
-
1
;
$
last_id
=
$i
=
-
1
;
$
nest
=
Array
()
;
foreach
(
$menu
as
$key
=>
$item
)
{
foreach
(
$menu
as
$key
=>
$realitem
)
{
$item
=
clone
$realitem
;
$item
->
_children
=
false
;
if
(
$item
->
menu_item_parent
==
$parent
)
{
$i
++
;
$this
->
contents
[
$i
]
=
$item
;
$this
->
id_lookup
[
$item
->
ID
]
=
$i
;
$this
->
target_lookup
[
$item
->
object_id
]
=
$i
;
$i
++
;
$last_id
=
$item
->
ID
;
}
elseif
(
$item
->
menu_item_parent
==
$last_id
)
{
$this
->
contents
[
$this
->
id_lookup
[
$last_id
]]
->
_children
=
true
;
$nest
[]
=
$last_id
;
$last_id
=
$item
->
ID
;
}
elseif
(
count
(
$nest
)
>
0
)
{
$last_id
=
array_pop
(
$nest
);
if
(
isset
(
$this
->
id_lookup
[
$last_id
]))
{
$this
->
contents
[
$this
->
id_lookup
[
$last_id
]]
->
_children
=
true
;
}
}
}
foreach
(
$this
->
contents
as
$key
=>
$item
)
{
foreach
(
$this
->
contents
as
$key
=>
&
$item
)
{
if
(
true
===
$item
->
_children
)
{
$item
->
HierarchicalMenu
=
new
HierarchicalMenu
(
$menu
,
$item
->
ID
);
}
...
...
Please
register
or
sign in
to post a comment