Beispiel #1
0
 static function list_files($plugin_path)
 {
     $plugin_dir = new Dir(self::DEFAULT_DIR . $plugin_path);
     $final_result = array();
     if ($plugin_dir->exists()) {
         $all_files = $plugin_dir->findFilesEndingWith(self::DEFAULT_EXTENSION);
         foreach ($all_files as $f) {
             $final_result[] = $f->getIncludePath();
         }
     }
     return $final_result;
 }
 function get_gallery()
 {
     $gallery_name = Params::get("gallery_name");
     $result = array();
     $result["gallery_name"] = $gallery_name;
     $d = new Dir(self::GALLERY_ROOT_PATH . $gallery_name);
     $files = $d->listFiles();
     $image_list = array();
     foreach ($files as $f) {
         if ($f->isFile() && $f->getExtension() != ".ini") {
             $image = array();
             $image["path"] = $f->getPath();
             $image["title"] = str_replace("_", " ", $f->getName());
             $image_list[$f->getFilename()] = $image;
         }
     }
     $gallery_dir = new Dir(self::GALLERY_ROOT_PATH . $gallery_name . DS);
     $found_files = $gallery_dir->findFilesEndingWith("gallery.ini");
     if (count($found_files) > 0) {
         $gallery_ini_file = $found_files[0];
         $gallery_props = PropertiesUtils::readFromFile($gallery_ini_file, true);
         $enhanced_image_list = array();
         foreach ($section as $s) {
             $path = $s["path"];
             if (strpos($path, "DS") === 0) {
                 $new_image["path"] = $path;
             } else {
                 $new_image["path"] = self::GALLERY_ROOT_PATH . $gallery_name . $s["path"];
             }
             $f = new File($new_image["path"]);
             $new_image["title"] = isset($s["title"]) ? $s["title"] : str_replace("_", " ", $f->getName());
             $new_image["description"] = isset($s["description"]) ? $s["description"] : null;
             $enhanced_image_list[] = $new_image;
         }
         $result["image_list"] = $enhanced_image_list;
     } else {
         $result["image_list"] = $image_list;
     }
     return $result;
 }
Beispiel #3
0
 function testFindFilesEndingWithBasic()
 {
     $d = new Dir("/" . FRAMEWORK_CORE_PATH . "tests/io/advances_dir_list/");
     $only_image_png = $d->findFilesEndingWith("image.png");
     $this->assertTrue(count($only_image_png) == 2, "Il numero dei file trovati non corrisponde!!");
 }