]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-15351: testing to make folder expanded by default
authorscyrma <scyrma>
Thu, 11 Sep 2008 07:48:35 +0000 (07:48 +0000)
committerscyrma <scyrma>
Thu, 11 Sep 2008 07:48:35 +0000 (07:48 +0000)
repository/local/repository.class.php

index f5367d2ee9810a312ad34fe100edbd3b0c064467..ad282dcbe0e924f2c56ce5d9e597a4ae6fca1231 100755 (executable)
@@ -107,7 +107,8 @@ class repository_local extends repository {
      */
     private function build_tree($fileinfo, $search, $dynamicmode, &$list) {
         global $CFG;
-           
+
+        $filecount = 0;
         $children = $fileinfo->get_children();
 
         foreach ($children as $child) {
@@ -143,11 +144,15 @@ class repository_local extends repository {
                     if ($search && stristr($tmp['title'], $search) !== false) {
                         $_search = false;
                     }
-                    $filecount = $this->build_tree($child, $_search, $dynamicmode, $tmp['children']);
+                    if ( $_filecount = $this->build_tree($child, $_search, $dynamicmode, $tmp['children']) ) {
+                        $tmp['expanded'] = 1;
+                    }
+
                 //}
                 
-                if (!$search || $filecount || (stristr($tmp['title'], $search) !== false)) {
+                if (!$search || $_filecount || (stristr($tmp['title'], $search) !== false)) {
                     $list[] = $tmp;
+                    $filecount += $_filecount;
                 }
 
             } else { // not a directory
@@ -162,10 +167,11 @@ class repository_local extends repository {
                     'source' => $child->get_url(),
                     'thumbnail' => $CFG->pixpath .'/f/'. mimeinfo_from_type("icon", $filetype)
                 );
+                $filecount++;
             }
         }
 
-        return $list;
+        return $filecount;
     }
 
     public function print_listing() {