예제 #1
0
 public static function create($url, $xmlConfig = array())
 {
     $document = new Sabel_Xml_Document($xmlConfig);
     self::$documents[] = $document;
     $element = $document->loadXML(file_get_contents($url));
     if ($element === null) {
         // @todo exception?
     }
     switch (strtolower($element->tagName)) {
         case "rdf:rdf":
             return new Sabel_Rss_Reader_Rdf($element);
         case "rss":
             return new Sabel_Rss_Reader_Rss($element);
             break;
         case "feed":
             if ($element->getAttribute("version") === "0.3") {
                 return new Sabel_Rss_Reader_Atom03($element);
             } else {
                 return new Sabel_Rss_Reader_Atom10($element);
             }
             break;
         default:
             $message = "";
             throw new Sabel_Exception_Runtime($message);
     }
 }
예제 #2
0
 protected function _installAddon($name, $xml)
 {
     $doc = new Sabel_Xml_Document();
     $root = $doc->loadXML($xml);
     if ($error = $root->getChild("error")) {
         $this->error($error->getNodeValue());
         $this->error("install failed.");
         return;
     }
     $version = $root->getChild("version")->getNodeValue();
     $addonName = ucfirst($name);
     $className = $addonName . "_Addon";
     if (class_exists($className, true)) {
         eval('$v = ' . $className . '::VERSION;');
         if ($v === (double) $version) {
             $this->message("{$addonName}_{$version} already installed.");
             return;
         } elseif ((double) $version > $v) {
             $_v = strpos($v, ".") === false ? "{$v}.0" : $v;
             $this->message("upgrade " . $addonName . " from {$_v} to {$version}.");
         } else {
             $this->message("nothing to install.");
             return;
         }
     }
     $files = $root->getChildren("file");
     foreach ($files as $i => $file) {
         $path = $file->getChild("path")->getNodeValue();
         $path = str_replace(":", DS, $path);
         $source = $file->getChild("source")->getNodeValue();
         if (!$this->fs->isFile($path)) {
             $this->fs->mkfile($path)->write($source)->save();
         } else {
             $this->fs->getFile($path)->write($source)->save();
         }
         $this->success($path);
     }
     $this->success("install ok: {$addonName}_{$version}");
 }
예제 #3
0
파일: Test.php 프로젝트: reoring/sabel
 protected function loadXML(Sabel_Xml_Document $xml, $name)
 {
     return $xml->loadXML(file_get_contents(XML_TEST_DIR . DS . "xml" . DS . $name . ".xml"));
 }