コード例 #1
0
 /**
  * Index action
  */
 function indexAction()
 {
     $filepath = CACHE_DIR . '/analytics/report-' . Fox_Core_Model_Date::getCurrentDate('Y-m-d') . '.xml';
     $xDom = new Uni_Data_XDOMDocument();
     $xDom->load($filepath);
     header('Content-Type: text/xml');
     echo $xDom->saveXML();
 }
コード例 #2
0
 /**
  * Load package to package session
  * 
  * @param string $pkgName Valid generated package name.
  * @return Fox_Extensionmanager_Model_Generate_Package 
  */
 public function load($pkgName, $field = NULL)
 {
     $this->getSession()->setFormData(NULL);
     $pkgFile = $this->getGeneratedPkgDir() . DS . $pkgName;
     if (!($pkgName && !is_dir($pkgFile) && file_exists($pkgFile))) {
         throw new Exception("Invalid package.");
         return;
     }
     $info = pathinfo($pkgFile);
     if ($info["extension"] != "xml") {
         throw new Exception("Invalid package file.");
     }
     $doc = new DOMDocument();
     $doc->load($pkgFile);
     if ($doc->documentElement->nodeName != self::PACKAGE_ROOT_ELEMENT) {
         throw new Exception("Invalid package xml.");
     }
     $data = array();
     $nList = $doc->documentElement->childNodes;
     foreach ($nList as $n) {
         if ($n->nodeName == self::PACKAGE_RELEASE_NOTE_ELEMENT) {
             $data["release_note"] = $n->nodeValue;
         } elseif ($n->nodeName == self::PACKAGE_LICENSE_ELEMENT) {
             $data[$n->nodeName] = $n->nodeValue;
             $data["license_url"] = $n->getAttribute("url");
         } elseif ($n->nodeName == self::PACKAGE_PROVIDERS_NOTE_ELEMENT) {
             $data["provider_note"] = $n->nodeValue;
         } elseif ($n->nodeName == self::PACKAGE_PROVIDERS_ELEMENT) {
             $authorList = $n->childNodes;
             foreach ($authorList as $author) {
                 if ($author->nodeName == "#text") {
                     continue;
                 }
                 $infos = $author->childNodes;
                 foreach ($infos as $info) {
                     if ($info->nodeName == "#text") {
                         continue;
                     }
                     $data["providers"][$info->nodeName][] = $info->nodeValue;
                 }
             }
         } elseif ($n->nodeName == self::PACKAGE_CONTENTS_ELEMENT) {
             $destinationList = $n->childNodes;
             $treeDom = new Uni_Data_XDOMDocument();
             $treeDom->loadXML("<root></root>");
             foreach ($destinationList as $destination) {
                 if ($destination->nodeName == "#text") {
                     continue;
                 }
                 $treeDom->documentElement->appendChild($treeDom->importNode($destination, true));
             }
             $data["content_tree_data"] = trim(preg_replace('/<\\?xml.*\\?>/', '', $treeDom->saveXML(), 1));
         } elseif ($n->nodeName == self::PACKAGE_STABILITY_ELEMENT) {
             $stblOp = array_flip(Fox::getModel("extensionmanager/package/state")->_getOptionArray());
             $data[$n->nodeName] = $stblOp[$n->nodeValue];
         } else {
             $data[$n->nodeName] = $n->nodeValue;
         }
     }
     if ($data) {
         $this->setData($data);
         $this->getSession()->setFormData($data);
     }
     return $this;
 }