Esempio n. 1
0
 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;
 }
Esempio n. 2
0
 private static function loadSortedMenuData($folder)
 {
     $menu_files = $folder->findFilesEndingWith("menu.ini");
     if (count($menu_files) == 0) {
         return null;
     }
     $file = new File($folder->getPath() . $menu_files[0]->getFilename());
     $all_data = PropertiesUtils::readFromFile($file, true);
     $final_sorted_data = array();
     foreach ($all_data as $section => $data) {
         $data["key"] = $section;
         if (isset($data["folder"])) {
             $childs = MenuBuilder::loadSortedMenuData(new Dir($data["folder"]));
             if ($childs !== null) {
                 $data["childs"] = $childs;
             }
         }
         $final_sorted_data[(int) $data["position"]] = $data;
     }
     ArrayUtils::reorder_from_zero($final_sorted_data);
     return $final_sorted_data;
 }
Esempio n. 3
0
 public static function loadByLang($result, $lang, $dir, $recursive = false)
 {
     if ($dir instanceof Dir) {
         $props_dir = new Dir($dir);
     } else {
         $props_dir = new Dir($dir);
     }
     $all_files = $props_dir->listFiles();
     foreach ($all_files as $f) {
         if ($f->isDir() && $recursive) {
             $result = array_merge($result, self::loadByLang($result, $lang, $f, true));
         }
         if ($f->isFile()) {
             $full_extension = $f->getFullExtension();
             $ext_parts = explode(".", $full_extension);
             if (count($ext_parts) == 2 && $ext_parts[1] == "ini") {
                 $lang_part = $ext_parts[0];
                 if (substr($lang_part, 0, strlen($lang)) == $lang) {
                     $result = array_merge($result, PropertiesUtils::readFromFile($f, false));
                 }
             }
         }
     }
 }
 function application_name()
 {
     $f = new File("/application.ini");
     $props = PropertiesUtils::readFromFile($f, false);
     return $props["name"];
 }
Esempio n. 5
0
 function testRemoveEntry()
 {
     $file = new File("/" . FRAMEWORK_CORE_PATH . "tests/io/properties_dir/test_folder_2/remove_props.ini");
     $properties = array("entry1" => array("one" => 1, "two" => 2, "mondo" => "mah"), "entry2" => array("one" => 7, "two" => 16, "mondo" => "blah"), 3 => array("pizza" => 5, "problems" => 0));
     PropertiesUtils::saveToFile($file, $properties, true);
     PropertiesUtils::removeEntry($file, true, "entry2");
     $removed = PropertiesUtils::readFromFile($file, true);
     $this->assertTrue(count($removed) == 2, "Il numero delle proprietà non corrisponde!!");
     $this->assertTrue(isset($removed["entry1"]), "entry1 è stata cancellata!!");
     $this->assertFalse(isset($removed["entry2"]), "entry2 non è stata cancellata!!");
     $this->assertTrue(isset($removed[3]), "'3' è stata cancellata!!");
     $this->assertEqual($removed["entry1"]["one"], 1, "Il valore della properties non corrisponde!");
     $this->assertEqual($removed["entry1"]["two"], 2, "Il valore della properties non corrisponde!");
     $this->assertEqual($removed["entry1"]["mondo"], "mah", "Il valore della properties non corrisponde!");
     $this->assertTrue(count($removed["entry1"]) == 3, "Il numero delle chiavi non corrisponde!");
     $this->assertEqual($removed[3]["pizza"], 5, "Il valore della properties non corrisponde!");
     $this->assertEqual($removed[3]["problems"], 0, "Il valore della properties non corrisponde!");
     $this->assertTrue(count($removed[3]) == 2, "Il numero delle chiavi non corrisponde!");
 }
Esempio n. 6
0
 static function removeEntry($file, $has_sections, $key)
 {
     $properties = PropertiesUtils::readFromFile($file, $has_sections);
     unset($properties[$key]);
     PropertiesUtils::saveToFile($file, $properties, $has_sections);
 }
Esempio n. 7
0
 protected function element_found($name)
 {
     $path = $this->get_element_path_by_name($name);
     $f = new File($path);
     $props = PropertiesUtils::readFromFile($f, false);
 }
Esempio n. 8
0
 function readAll()
 {
     $this->create();
     return PropertiesUtils::readFromFile($this->storage_file, true);
 }