Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dolibarr
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container registry
Model registry
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Software_Artifact_Infrastructure_Repository
dolibarr
Commits
320b4bde
Commit
320b4bde
authored
12 years ago
by
Laurent Destailleur
Browse files
Options
Downloads
Patches
Plain Diff
Qual: Code to output tree is now generic
parent
c38f9110
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
htdocs/admin/menus/index.php
+17
-1
17 additions, 1 deletion
htdocs/admin/menus/index.php
htdocs/core/lib/treeview.lib.php
+7
-37
7 additions, 37 deletions
htdocs/core/lib/treeview.lib.php
with
24 additions
and
38 deletions
htdocs/admin/menus/index.php
+
17
−
1
View file @
320b4bde
...
@@ -318,7 +318,23 @@ if ($conf->use_javascript_ajax)
...
@@ -318,7 +318,23 @@ if ($conf->use_javascript_ajax)
{
{
if
(
!
empty
(
$menu
[
'langs'
]))
$langs
->
load
(
$menu
[
'langs'
]);
if
(
!
empty
(
$menu
[
'langs'
]))
$langs
->
load
(
$menu
[
'langs'
]);
$titre
=
$langs
->
trans
(
$menu
[
'titre'
]);
$titre
=
$langs
->
trans
(
$menu
[
'titre'
]);
$data
[]
=
array
(
'rowid'
=>
$menu
[
'rowid'
],
'fk_menu'
=>
$menu
[
'fk_menu'
],
'title'
=>
$titre
,
'mainmenu'
=>
$menu
[
'mainmenu'
],
'leftmenu'
=>
$menu
[
'leftmenu'
],
'fk_mainmenu'
=>
$menu
[
'fk_mainmenu'
],
'fk_leftmenu'
=>
$menu
[
'fk_leftmenu'
]);
$data
[]
=
array
(
'rowid'
=>
$menu
[
'rowid'
],
'fk_menu'
=>
$menu
[
'fk_menu'
],
'title'
=>
$titre
,
'mainmenu'
=>
$menu
[
'mainmenu'
],
'leftmenu'
=>
$menu
[
'leftmenu'
],
'fk_mainmenu'
=>
$menu
[
'fk_mainmenu'
],
'fk_leftmenu'
=>
$menu
[
'fk_leftmenu'
],
'entry'
=>
'<table class="nobordernopadding centpercent"><tr><td>'
.
'<strong> <a href="edit.php?menu_handler='
.
$menu_handler_to_search
.
'&action=edit&menuId='
.
$menu
[
'rowid'
]
.
'">'
.
$titre
.
'</a></strong>'
.
'</td><td align="right">'
.
'<a href="edit.php?menu_handler='
.
$menu_handler_to_search
.
'&action=edit&menuId='
.
$menu
[
'rowid'
]
.
'">'
.
img_edit
(
'default'
,
0
,
'class="menuEdit" id="edit'
.
$menu
[
'rowid'
]
.
'"'
)
.
'</a> '
.
'<a href="edit.php?menu_handler='
.
$menu_handler_to_search
.
'&action=create&menuId='
.
$menu
[
'rowid'
]
.
'">'
.
img_edit_add
(
'default'
,
0
,
'class="menuNew" id="new'
.
$menu
[
'rowid'
]
.
'"'
)
.
'</a> '
.
'<a href="index.php?menu_handler='
.
$menu_handler_to_search
.
'&action=delete&menuId='
.
$menu
[
'rowid'
]
.
'">'
.
img_delete
(
'default'
,
0
,
'class="menuDel" id="del'
.
$menu
[
'rowid'
]
.
'"'
)
.
'</a> '
.
'<a href="index.php?menu_handler='
.
$menu_handler_to_search
.
'&action=up&menuId='
.
$menu
[
'rowid'
]
.
'">'
.
img_picto
(
"Monter"
,
"1uparrow"
)
.
'</a><a href="index.php?menu_handler='
.
$menu_handler_to_search
.
'&action=down&menuId='
.
$menu
[
'rowid'
]
.
'">'
.
img_picto
(
"Descendre"
,
"1downarrow"
)
.
'</a>'
.
'</td></tr></table>'
);
$i
++
;
$i
++
;
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
htdocs/core/lib/treeview.lib.php
+
7
−
37
View file @
320b4bde
...
@@ -145,56 +145,30 @@ function tree_showpad(&$fulltree,$key,$silent=0)
...
@@ -145,56 +145,30 @@ function tree_showpad(&$fulltree,$key,$silent=0)
// ------------------------------- Used by menu editor -----------------
// ------------------------------- Used by menu editor -----------------
/**
/**
* Show an element with correct offset
* Recursive function to output menu tree. <ul><li>...</li></ul>
*
* @param array $tab Array of element
* @param int $rang Level of offset
* @return void
*/
function
tree_showline
(
$tab
,
$rang
)
{
global
$conf
,
$rangLast
,
$idLast
,
$menu_handler
;
// Content of line
print
'<table class="nobordernopadding centpercent"><tr><td>'
;
print
'<strong> <a href="edit.php?menu_handler='
.
$menu_handler
.
'&action=edit&menuId='
.
$tab
[
'rowid'
]
.
'">'
.
$tab
[
'title'
]
.
'</a></strong>'
;
print
'</td><td align="right">'
;
print
'<a href="edit.php?menu_handler='
.
$menu_handler
.
'&action=edit&menuId='
.
$tab
[
'rowid'
]
.
'">'
.
img_edit
(
'default'
,
0
,
'class="menuEdit" id="edit'
.
$tab
[
'rowid'
]
.
'"'
)
.
'</a> '
;
print
'<a href="edit.php?menu_handler='
.
$menu_handler
.
'&action=create&menuId='
.
$tab
[
'rowid'
]
.
'">'
.
img_edit_add
(
'default'
,
0
,
'class="menuNew" id="new'
.
$tab
[
'rowid'
]
.
'"'
)
.
'</a> '
;
print
'<a href="index.php?menu_handler='
.
$menu_handler
.
'&action=delete&menuId='
.
$tab
[
'rowid'
]
.
'">'
.
img_delete
(
'default'
,
0
,
'class="menuDel" id="del'
.
$tab
[
'rowid'
]
.
'"'
)
.
'</a> '
;
print
'<a href="index.php?menu_handler='
.
$menu_handler
.
'&action=up&menuId='
.
$tab
[
'rowid'
]
.
'">'
.
img_picto
(
"Monter"
,
"1uparrow"
)
.
'</a><a href="index.php?menu_handler='
.
$menu_handler
.
'&action=down&menuId='
.
$tab
[
'rowid'
]
.
'">'
.
img_picto
(
"Descendre"
,
"1downarrow"
)
.
'</a>'
;
print
'</td></tr></table>'
;
$rangLast
=
$rang
;
$idLast
=
$tab
[
'rowid'
];
}
/**
* Recursive function to output menu tree
*
*
* @param array $tab Array of all elements
* @param array $tab Array of all elements
* @param int $pere Array with parent ids ('rowid'=>,'mainmenu'=>,'leftmenu'=>,'fk_mainmenu=>,'fk_leftmenu=>)
* @param int $pere Array with parent ids ('rowid'=>,'mainmenu'=>,'leftmenu'=>,'fk_mainmenu=>,'fk_leftmenu=>)
* @param int $rang Level of element
* @param int $rang Level of element
* @return void
* @return void
*/
*/
function
tree_recur
(
$tab
,
$pere
,
$rang
)
function
tree_recur
(
$tab
,
$pere
,
$rang
,
$iddivjstree
=
'iddivjstree'
)
{
{
if
(
empty
(
$pere
[
'rowid'
]))
if
(
empty
(
$pere
[
'rowid'
]))
{
{
// Test also done with jstree and dynatree (not able to have <a> inside label)
// Test also done with jstree and dynatree (not able to have <a> inside label)
print
'<script type="text/javascript" language="javascript">
print
'<script type="text/javascript" language="javascript">
$(document).ready(function(){
$(document).ready(function(){
$("#iddivjstree").treeview({
$("#
'
.
$
iddivjstree
.
'
").treeview({
collapsed: true,
collapsed: true,
animated: "fast",
animated: "fast",
persist: "location",
persist: "location",
control: "#iddivjstreecontrol"
control: "#
'
.
$
iddivjstree
.
'
control"
});
});
})
})
</script>'
;
</script>'
;
print
'<ul id="iddivjstree" style="min-height:300px;">'
;
print
'<ul id="
'
.
$
iddivjstree
.
'
" style="min-height:300px;">'
;
}
}
if
(
$rang
>
10
)
return
;
// Protection contre boucle infinie
if
(
$rang
>
10
)
return
;
// Protection contre boucle infinie
...
@@ -210,9 +184,7 @@ function tree_recur($tab,$pere,$rang)
...
@@ -210,9 +184,7 @@ function tree_recur($tab,$pere,$rang)
{
{
if
(
empty
(
$ulprinted
)
&&
!
empty
(
$pere
[
'rowid'
]))
{
print
'<ul'
.
(
empty
(
$pere
[
'rowid'
])
?
' id="treeData"'
:
''
)
.
'>'
;
$ulprinted
++
;
}
if
(
empty
(
$ulprinted
)
&&
!
empty
(
$pere
[
'rowid'
]))
{
print
'<ul'
.
(
empty
(
$pere
[
'rowid'
])
?
' id="treeData"'
:
''
)
.
'>'
;
$ulprinted
++
;
}
print
"
\n
"
.
'<li>'
;
print
"
\n
"
.
'<li>'
;
// We shot it with an offset
print
$tab
[
$x
][
'entry'
];
tree_showline
(
$tab
[
$x
],
$rang
);
// And now we search all its sons of lower level
// And now we search all its sons of lower level
tree_recur
(
$tab
,
$tab
[
$x
],
$rang
+
1
);
tree_recur
(
$tab
,
$tab
[
$x
],
$rang
+
1
);
print
'</li>'
;
print
'</li>'
;
...
@@ -221,9 +193,7 @@ function tree_recur($tab,$pere,$rang)
...
@@ -221,9 +193,7 @@ function tree_recur($tab,$pere,$rang)
{
{
if
(
empty
(
$ulprinted
)
&&
!
empty
(
$pere
[
'rowid'
]))
{
print
'<ul'
.
(
empty
(
$pere
[
'rowid'
])
?
' id="treeData"'
:
''
)
.
'>'
;
$ulprinted
++
;
}
if
(
empty
(
$ulprinted
)
&&
!
empty
(
$pere
[
'rowid'
]))
{
print
'<ul'
.
(
empty
(
$pere
[
'rowid'
])
?
' id="treeData"'
:
''
)
.
'>'
;
$ulprinted
++
;
}
print
"
\n
"
.
'<li>'
;
print
"
\n
"
.
'<li>'
;
// We shot it with an offset
print
$tab
[
$x
][
'entry'
];
tree_showline
(
$tab
[
$x
],
$rang
);
// And now we search all its sons of lower level
// And now we search all its sons of lower level
tree_recur
(
$tab
,
$tab
[
$x
],
$rang
+
1
);
tree_recur
(
$tab
,
$tab
[
$x
],
$rang
+
1
);
print
'</li>'
;
print
'</li>'
;
...
...
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