summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--inc/media.php26
-rw-r--r--lib/exe/mediamanager.php3
2 files changed, 22 insertions, 7 deletions
diff --git a/inc/media.php b/inc/media.php
index bd80db577..db1ca0d57 100644
--- a/inc/media.php
+++ b/inc/media.php
@@ -1686,18 +1686,36 @@ function media_nstree($ns){
$ns = cleanID($ns);
if(empty($ns)){
global $ID;
- $ns = dirname(str_replace(':','/',$ID));
- if($ns == '.') $ns ='';
+ $ns = (string)getNS($ID);
}
- $ns = utf8_encodeFN(str_replace(':','/',$ns));
+
+ $ns_dir = utf8_encodeFN(str_replace(':','/',$ns));
$data = array();
- search($data,$conf['mediadir'],'search_index',array('ns' => $ns, 'nofiles' => true));
+ search($data,$conf['mediadir'],'search_index',array('ns' => $ns_dir, 'nofiles' => true));
// wrap a list with the root level around the other namespaces
array_unshift($data, array('level' => 0, 'id' => '', 'open' =>'true',
'label' => '['.$lang['mediaroot'].']'));
+ // insert the current ns into the hierarchy if it isn't already part of it
+ $ns_parts = explode(':', $ns);
+ $tmp_ns = '';
+ $pos = 0;
+ foreach ($ns_parts as $level => $part) {
+ if ($tmp_ns) $tmp_ns .= ':'.$part;
+ else $tmp_ns = $part;
+
+ // find the namespace parts or insert them
+ while ($data[$pos]['id'] != $tmp_ns) {
+ if ($pos >= count($data) || ($data[$pos]['level'] <= $level+1 && strnatcmp(utf8_encodeFN($data[$pos]['id']), utf8_encodeFN($tmp_ns)) > 0)) {
+ array_splice($data, $pos, 0, array(array('level' => $level+1, 'id' => $tmp_ns, 'open' => 'true')));
+ break;
+ }
+ ++$pos;
+ }
+ }
+
echo html_buildlist($data,'idx','media_nstree_item','media_nstree_li');
}
diff --git a/lib/exe/mediamanager.php b/lib/exe/mediamanager.php
index e0a90a291..53d438321 100644
--- a/lib/exe/mediamanager.php
+++ b/lib/exe/mediamanager.php
@@ -40,9 +40,6 @@
die($lang['accessdenied']);
}
- // create the given namespace (just for beautification)
- if($AUTH >= AUTH_UPLOAD) { io_createNamespace("$NS:xxx", 'media'); }
-
// handle flash upload
if(isset($_FILES['Filedata'])){
$_FILES['upload'] =& $_FILES['Filedata'];