コード例 #1
0
 /**
  * Retrieve list of packages available to download.
  *
  * Example of return value:
  * array(
  *  'packages' => array(
  *                      '<package_name1>' => array( "name" =>... , "version" =>... , "summary" => ... "url" =>... ),
  *                      '<package_name2>' => array( "name" =>... , "version" =>... , "summary" => ... "url" =>... )
  *                     )
  *      );
  *
  */
 function retrieveRemotePackagesList($onlySitePackages = false)
 {
     // Download index file.
     $idxFileName = $this->downloadFile($this->XMLIndexURL, eZStepSiteTypes::tempDir(), 'index.xml');
     if ($idxFileName === false) {
         // Searching for a local index.xml file to use for offline installation
         $destIndexPath = eZStepSiteTypes::tempDir() . DIRECTORY_SEPARATOR . 'index.xml';
         $repo = eZPackage::systemRepositoryInformation();
         if ($repo) {
             $sourceIndexPath = $repo['path'] . DIRECTORY_SEPARATOR . 'index.xml';
             if (file_exists($sourceIndexPath)) {
                 eZFileHandler::copy($sourceIndexPath, $destIndexPath);
                 $idxFileName = $destIndexPath;
                 // Removing error message from downloadFile
                 $this->ErrorMsg = false;
             }
         }
     }
     if ($idxFileName === false) {
         $this->ErrorMsg = ezpI18n::tr('design/standard/setup/init', 'Retrieving remote site packages list failed. ' . 'You may upload packages manually.');
         eZDebug::writeNotice("Cannot download remote packages index file from '{$this->XMLIndexURL}'.");
         return false;
     }
     // Parse it.
     $dom = new DOMDocument('1.0', 'utf-8');
     $dom->preserveWhiteSpace = false;
     $success = $dom->load(realpath($idxFileName));
     @unlink($idxFileName);
     if (!$success) {
         eZDebug::writeError("Unable to open index file.");
         return false;
     }
     $root = $dom->documentElement;
     if ($root->localName != 'packages') {
         eZDebug::writeError("Malformed index file.");
         return false;
     }
     $packageList = array();
     foreach ($root->childNodes as $packageNode) {
         if ($packageNode->localName != 'package') {
             // skip unwanted chilren
             continue;
         }
         if ($onlySitePackages && $packageNode->getAttribute('type') != 'site') {
             // skip non-site packages
             continue;
         }
         $packageAttributes = array();
         foreach ($packageNode->attributes as $attributeNode) {
             $packageAttributes[$attributeNode->localName] = $attributeNode->value;
         }
         $packageList[$packageAttributes['name']] = $packageAttributes;
     }
     return $packageList;
 }
コード例 #2
0
 /**
  * Retrieve list of packages available to download.
  *
  * Example of return value:
  * array(
  *  'packages' => array(
  *                      '<package_name1>' => array( "name" =>... , "version" =>... , "summary" => ... "url" =>... ),
  *                      '<package_name2>' => array( "name" =>... , "version" =>... , "summary" => ... "url" =>... )
  *                     )
  *      );
  *
  */
 function retrieveRemotePackagesList($onlySitePackages = false)
 {
     // Download index file.
     $idxFileName = $this->downloadFile($this->XMLIndexURL, eZStepSiteTypes::tempDir(), 'index.xml');
     if ($idxFileName === false) {
         $this->ErrorMsg = ezpI18n::tr('design/standard/setup/init', 'Retrieving remote site packages list failed. ' . 'You may upload packages manually.');
         eZDebug::writeNotice("Cannot download remote packages index file from '{$this->XMLIndexURL}'.");
         return false;
     }
     // Parse it.
     $dom = new DOMDocument('1.0', 'utf-8');
     $dom->preserveWhiteSpace = false;
     $success = $dom->load(realpath($idxFileName));
     @unlink($idxFileName);
     if (!$success) {
         eZDebug::writeError("Unable to open index file.");
         return false;
     }
     $root = $dom->documentElement;
     if ($root->localName != 'packages') {
         eZDebug::writeError("Malformed index file.");
         return false;
     }
     $packageList = array();
     foreach ($root->childNodes as $packageNode) {
         if ($packageNode->localName != 'package') {
             // skip unwanted chilren
             continue;
         }
         if ($onlySitePackages && $packageNode->getAttribute('type') != 'site') {
             // skip non-site packages
             continue;
         }
         $packageAttributes = array();
         foreach ($packageNode->attributes as $attributeNode) {
             $packageAttributes[$attributeNode->localName] = $attributeNode->value;
         }
         $packageList[$packageAttributes['name']] = $packageAttributes;
     }
     return $packageList;
 }