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;
 }
Example #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;
 }
Example #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"];
 }
Example #5
0
 static function getArchiveProperties($f)
 {
     if ($f instanceof File) {
         $source_file = $f;
     } else {
         $source_file = new File($f);
     }
     $reader = $source_file->openReader();
     $binarydata = $reader->read(3);
     $data = unpack("a3", $binarydata);
     if ($data[1] !== self::FF_ARCHIVE_HEADER) {
         throw new InvalidDataException("Intestazione del file non valida : " . $data[1]);
     }
     $binarydata = $reader->read(2 + 2 + 2);
     $data = unpack("v3", $binarydata);
     if ($data[1] !== self::CURRENT_MAJOR || $data[2] !== self::CURRENT_MINOR || $data[3] !== self::CURRENT_REV) {
         throw new InvalidDataException("Versione del file non supportata!! : " . $data[1] . "-" . $data[2] . "-" . $data[3]);
     }
     //properties
     $binarydata = $reader->read(2);
     $data = unpack("v", $binarydata);
     $properties_length = $data[1];
     if ($properties_length > 0) {
         $binarydata = $reader->read($properties_length);
         $data = unpack("a*", $binarydata);
         $properties = PropertiesUtils::readFromString($data[1], false);
     } else {
         $properties = array();
     }
     $reader->close();
     return $properties;
 }
Example #6
0
    function testReadFromString2()
    {
        $myString = <<<END_OF_STRING

proprieta_01 = Home
altra_prop = http://www.mbcraft.it
menu_style = small_font

ancora_props = Ancora proprietà
; Questo è un commento
ultima_props = L'ultima prop

END_OF_STRING;
        $props = PropertiesUtils::readFromString($myString, false);
        $this->assertTrue(count($props) == 5, "Il numero di properties non corrisponde!! : " . count($props));
        $this->assertEqual($props["menu_style"], "small_font", "La properties non corrisponde!!");
        $this->assertEqual($props["ancora_props"], "Ancora proprietà", "La properties non corrisponde!!");
        $this->assertEqual($props["ultima_props"], "L'ultima prop", "La properties non corrisponde!! : " . $props["ultima_props"]);
    }
 function logicToRaw($logic_value)
 {
     return PropertiesUtils::saveToString($logic_value, false);
 }
Example #8
0
 private function __load($query_result)
 {
     $all_fields = $this->__getAllFields();
     if (!is_array($query_result)) {
         throw new ErrorException("L'oggetto da caricare non è un array");
     }
     $do = $this->__create_instance($this->__getDataObjectClassName());
     $do->__markAsNotNew();
     $do->__setLoadingState(true);
     foreach ($query_result as $key => $value) {
         $saved = false;
         if (isset($this->fetchedAsProperties[$key])) {
             $do->{$key} = PropertiesUtils::readFromString($value, false);
             $saved = true;
         }
         if (isset($this->fetchedAsEntity[$key])) {
             $entity_peer = $this->fetchedAsEntity[$key]["peer_class_name"];
             $entity = $entity_peer->find_by_id($value);
             $entity_field_name = $this->fetchedAsEntity[$key]["entity_name"];
             $do->{$entity_field_name} = $entity;
             $saved = true;
         }
         //if (!isset(Config::instance()->DB_KEEP_AMERICAN_DATES) || !Config::instance()->DB_KEEP_AMERICAN_DATES)
         //{
         if ($all_fields[$key]["type"] == "date") {
             $do->{$key} = DateTimeUtils::reverse_date_yyyy_mm_dd($value);
             $saved = true;
         }
         //}
         //aggiungere datetime e time
         if (!$saved) {
             $do->{$key} = $value;
         }
     }
     $do->__setLoadingState(false);
     return $do;
 }
Example #9
0
 static function removeEntry($file, $has_sections, $key)
 {
     $properties = PropertiesUtils::readFromFile($file, $has_sections);
     unset($properties[$key]);
     PropertiesUtils::saveToFile($file, $properties, $has_sections);
 }
Example #10
0
 protected function element_found($name)
 {
     $path = $this->get_element_path_by_name($name);
     $f = new File($path);
     $props = PropertiesUtils::readFromFile($f, false);
 }
 function remove($key)
 {
     $this->create();
     PropertiesUtils::removeEntry($this->storage_file, true, $key);
 }