示例#1
0
 /**
  * Get the download url for an application from the OCS server
  * @return array|null an array of application data or null
  *
  * This function returns an download url for an applications from the OCS server
  * @param string $id
  * @param integer $item
  * @param array $targetVersion The target ownCloud version
  */
 public static function getApplicationDownload($id, $item, array $targetVersion)
 {
     if (OC_Config::getValue('appstoreenabled', true) == false) {
         return null;
     }
     $url = OC_OCSClient::getAppStoreURL() . '/content/download/' . urlencode($id) . '/' . urlencode($item);
     $url .= '?version=' . implode('x', $targetVersion);
     $xml = OC_OCSClient::getOCSresponse($url);
     if ($xml == false) {
         OC_Log::write('core', 'Unable to parse OCS content', OC_Log::FATAL);
         return null;
     }
     $loadEntities = libxml_disable_entity_loader(true);
     $data = simplexml_load_string($xml);
     libxml_disable_entity_loader($loadEntities);
     $tmp = $data->data->content;
     $app = array();
     if (isset($tmp->downloadlink)) {
         $app['downloadlink'] = $tmp->downloadlink;
     } else {
         $app['downloadlink'] = '';
     }
     return $app;
 }
 /**
  * @brief Get the download url for an application from the OCS server
  * @returns array with application data
  *
  * This function returns an download url for an applications from the OCS server
  */
 public static function getApplicationDownload($id, $item)
 {
     $url = OC_OCSClient::getAppStoreURL() . '/content/download/' . urlencode($id) . '/' . urlencode($item);
     $xml = @file_get_contents($url);
     if ($xml == FALSE) {
         OC_Log::write('core', 'Unable to parse OCS content', OC_Log::FATAL);
         return NULL;
     }
     $data = simplexml_load_string($xml);
     $tmp = $data->data->content;
     $app = array();
     if (isset($tmp->downloadlink)) {
         $app['downloadlink'] = $tmp->downloadlink;
     } else {
         $app['downloadlink'] = '';
     }
     return $app;
 }