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; }
function rawToLogic($raw_value) { return PropertiesUtils::readFromString($raw_value, false); }
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"]); }
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; }