summaryrefslogtreecommitdiff
path: root/inc
diff options
context:
space:
mode:
authorAdrian Lang <mail@adrianlang.de>2011-07-11 22:17:27 +0200
committerAdrian Lang <mail@adrianlang.de>2011-07-11 23:03:28 +0200
commita1dee2b998bc3dc8436bb076435d405ec412e054 (patch)
treed1c7609b4085ac6f2be349b1a478f939eea8771a /inc
parent2d57e114e1b33b0965a48b2838ec5dd38888c3b6 (diff)
downloadrpg-a1dee2b998bc3dc8436bb076435d405ec412e054.tar.gz
rpg-a1dee2b998bc3dc8436bb076435d405ec412e054.tar.bz2
Fix some bugs and glitches in (mediamanager) tree
* Fix selector in subtree loading callback * Remove HTML inconsistencies between AJAX and plain PHP lists * Unify icon and CSS class switching in dw_tree and dw_mediamanager
Diffstat (limited to 'inc')
-rw-r--r--inc/html.php16
-rw-r--r--inc/media.php9
2 files changed, 15 insertions, 10 deletions
diff --git a/inc/html.php b/inc/html.php
index 6e187ebe1..de860a0fe 100644
--- a/inc/html.php
+++ b/inc/html.php
@@ -737,7 +737,7 @@ function html_list_index($item){
/**
* Index List item
*
- * This user function is used in html_build_lidt to build the
+ * This user function is used in html_buildlist to build the
* <li> tags for namespaces when displaying the page index
* it gives different classes to opened or closed "folders"
*
@@ -778,10 +778,20 @@ function html_li_default($item){
* @author Andreas Gohr <andi@splitbrain.org>
*/
function html_buildlist($data,$class,$func,$lifunc='html_li_default'){
- $level = 0;
+ if (count($data) === 0) {
+ return '';
+ }
+
+ $level = $data[0]['level'];
$opens = 0;
$ret = '';
+ if ($level < 2) {
+ // Trigger building a wrapper ul if the first level is
+ // 0 (we have a root object) or 1 (just the root content)
+ --$level;
+ }
+
foreach ($data as $item){
if( $item['level'] > $level ){
@@ -797,7 +807,7 @@ function html_buildlist($data,$class,$func,$lifunc='html_li_default'){
//close higher lists
$ret .= "</ul>\n</li>\n";
}
- }else{
+ } elseif ($ret !== '') {
//close last item
$ret .= "</li>\n";
}
diff --git a/inc/media.php b/inc/media.php
index 10da501b0..731ba1668 100644
--- a/inc/media.php
+++ b/inc/media.php
@@ -767,15 +767,10 @@ function media_nstree($ns){
search($data,$conf['mediadir'],'search_index',array('ns' => $ns, 'nofiles' => true));
// wrap a list with the root level around the other namespaces
- $item = array( 'level' => 0, 'id' => '',
- 'open' =>'true', 'label' => '['.$lang['mediaroot'].']');
+ array_unshift($data, array('level' => 0, 'id' => '', 'open' =>'true',
+ 'label' => '['.$lang['mediaroot'].']'));
- echo '<ul class="idx">';
- echo media_nstree_li($item);
- echo media_nstree_item($item);
echo html_buildlist($data,'idx','media_nstree_item','media_nstree_li');
- echo '</li>';
- echo '</ul>';
}
/**