Exemple #1
0
 static function xml($name, $value = null)
 {
     if (is_null($value)) {
         self::assert($name);
         ($xtree = @unserialize($_SESSION[$name])) !== false and $xtree instanceof xtree or runtime_error('Session fetched variable is not an XML: ' . $name);
         return $xtree->xml();
     } else {
         self::assert();
         $value instanceof xml or runtime_error('Session stored variable is not an XML: ' . $name);
         $_SESSION[$name] = serialize(xtree::create($value));
     }
 }
Exemple #2
0
 function load($filename)
 {
     $this->xml = xml::load($filename);
     $query = array();
     foreach (self::$languages as $language) {
         $query[] = "/local//{$language}";
     }
     foreach ($this->xml->query(implode('|', $query)) as $node) {
         $doc = new xml();
         foreach ($this->xml->query('* | text()', $node) as $piece) {
             $doc->append($doc->import($piece));
         }
         $path = explode(':', str_replace('/', ':', trim($node->path(), '/')));
         array_shift($path);
         $this->local[implode(':', $path)] = xtree::create($doc);
     }
 }