From ee7b5a6202608290324cb28c5f555ed797f24fc4 Mon Sep 17 00:00:00 2001
From: Andreas Gohr <andi@splitbrain.org>
Date: Fri, 3 Nov 2006 16:08:50 +0100
Subject: [PATCH] don't show .txt files as medianamespaces #963

darcs-hash:20061103150850-7ad00-9b6936efb8dd47eb366e5cd34a3149f4d81caa14.gz
---
 inc/media.php    | 2 +-
 inc/search.php   | 2 +-
 lib/exe/ajax.php | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/inc/media.php b/inc/media.php
index fb185435d..dcb8aa76d 100644
--- a/inc/media.php
+++ b/inc/media.php
@@ -469,7 +469,7 @@ function media_nstree($ns){
     $ns  = utf8_encodeFN(str_replace(':','/',$ns));
 
     $data = array();
-    search($data,$conf['mediadir'],'search_index',array('ns' => $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' => '',
diff --git a/inc/search.php b/inc/search.php
index 3c473daee..d8fe75122 100644
--- a/inc/search.php
+++ b/inc/search.php
@@ -149,7 +149,7 @@ function search_index(&$data,$base,$file,$type,$lvl,$opts){
   if($type == 'd' && !preg_match('#^'.$file.'(/|$)#','/'.$opts['ns'])){
     //add but don't recurse
     $return = false;
-  }elseif($type == 'f' && !preg_match('#\.txt$#',$file)){
+  }elseif($type == 'f' && ($opts['nofiles'] || !preg_match('#\.txt$#',$file))){
     //don't add
     return false;
   }
diff --git a/lib/exe/ajax.php b/lib/exe/ajax.php
index 9e89d6bd3..5218803ea 100644
--- a/lib/exe/ajax.php
+++ b/lib/exe/ajax.php
@@ -133,7 +133,7 @@ function ajax_medians(){
   $lvl = count(explode(':',$ns));
 
   $data = array();
-  search($data,$conf['mediadir'],'search_index',array(),$dir);
+  search($data,$conf['mediadir'],'search_index',array('nofiles' => true),$dir);
   foreach($data as $item){
     $item['level'] = $lvl+1;
     echo media_nstree_li($item);
-- 
GitLab