X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=CRM%2FExtension%2FBrowser.php;h=fa46980699b0e8346c18fc3e393e5168743f10e7;hb=ccaae7e57d54ce580fafd43e13ad7c2bdeeb9996;hp=70eaba90b627507b15387f45b6976c45bf8c61da;hpb=2f5ff37192635986fc82a3b46970121cf6688836;p=civicrm-core.git diff --git a/CRM/Extension/Browser.php b/CRM/Extension/Browser.php index 70eaba90b6..fa46980699 100644 --- a/CRM/Extension/Browser.php +++ b/CRM/Extension/Browser.php @@ -1,9 +1,9 @@ getRepositoryUrl()); } + /** + * @return string + */ public function getRepositoryUrl() { return $this->repoUrl; } @@ -132,6 +135,8 @@ class CRM_Extension_Browser { /** * Get a description of a particular extension * + * @param $key + * * @return CRM_Extension_Info|NULL */ public function getExtension($key) { @@ -145,6 +150,10 @@ class CRM_Extension_Browser { } } + /** + * @return array + * @throws CRM_Extension_Exception_ParseException + */ private function _discoverRemote() { $tsPath = $this->getTsPath(); $timestamp = FALSE; @@ -181,6 +190,9 @@ class CRM_Extension_Browser { return $this->_remotesDiscovered; } + /** + * @return array + */ private function grabCachedKeyList() { $result = array(); $cachedPath = $this->cacheDir . DIRECTORY_SEPARATOR; @@ -217,29 +229,29 @@ class CRM_Extension_Browser { return array(); } + $exts = array(); list ($status, $extdir) = CRM_Utils_HttpClient::singleton()->get($this->getRepositoryUrl() . $this->indexPath); if ($extdir === FALSE || $status !== CRM_Utils_HttpClient::STATUS_OK) { CRM_Core_Session::setStatus(ts('The CiviCRM public extensions directory at %1 could not be contacted - please check your webserver can make external HTTP requests or contact CiviCRM team on CiviCRM forum.
', array(1 => $this->getRepositoryUrl())), ts('Connection Error'), 'error'); - } - - $lines = explode("\n", $extdir); - - foreach ($lines as $ln) { - if (preg_match("@\(.*)\@i", $ln, $out)) { - // success - $extsRaw[] = $out; - $key = strip_tags($out[1]); - if (substr($key, -4) == '.xml') { - $exts[] = array('key' => substr($key, 0, -4)); + } else { + $lines = explode("\n", $extdir); + + foreach ($lines as $ln) { + if (preg_match("@\(.*)\@i", $ln, $out)) { + // success + $extsRaw[] = $out; + $key = strip_tags($out[1]); + if (substr($key, -4) == '.xml') { + $exts[] = array('key' => substr($key, 0, -4)); + } } } } + // CRM-13141 There may not be any compatible extensions available for the requested CiviCRM version + CMS. If so, $extdir is empty so just return a notification. if (empty($exts)) { - if ($extdir !== FALSE) { - CRM_Core_Session::setStatus(ts('Could not retrieve a list of extensions from the CiviCRM public directory at %1 - please contact CiviCRM team on CiviCRM forum.
', array(1 => $this->getRepositoryUrl())), ts('Failed Fetching List'), 'error'); - } - $exts = array(); + $config = CRM_Core_Config::singleton(); + CRM_Core_Session::setStatus(ts('There are currently no extensions on the CiviCRM public extension directory which are compatible with version %2 (requested extensions from here). If you want to install an extension which is not marked as compatible, you may be able to download and install extensions manually (depending on access to your web server).
', array(1 => $this->getRepositoryUrl(), 2 => $config->civiVersion, 3 => 'http://wiki.civicrm.org/confluence/display/CRMDOC/Extensions')), ts('No Extensions Available for this Version'), 'info'); } ini_restore('allow_url_fopen'); @@ -289,6 +301,9 @@ class CRM_Extension_Browser { } } + /** + * @return string + */ private function getTsPath() { return $this->cacheDir . DIRECTORY_SEPARATOR . 'timestamp.txt'; } @@ -300,4 +315,4 @@ class CRM_Extension_Browser { return; } -} \ No newline at end of file +}