diff --git a/CRM/Utils/System/Base.php b/CRM/Utils/System/Base.php index c49b8afba2db..233390e4f3ec 100644 --- a/CRM/Utils/System/Base.php +++ b/CRM/Utils/System/Base.php @@ -667,13 +667,9 @@ public function getCiviSourceStorage() { $baseURL = str_replace('http://', 'https://', $baseURL); } - if ($config->userFramework == 'Joomla') { - $userFrameworkResourceURL = $baseURL . "components/com_civicrm/civicrm/"; - } - elseif ($config->userFramework == 'WordPress') { - $userFrameworkResourceURL = CIVICRM_PLUGIN_URL . "civicrm/"; - } - elseif ($this->is_drupal) { + // @todo this function is only called / code is only reached when is_drupal is true - move this to the drupal classes + // and don't implement here. + if ($this->is_drupal) { // Drupal setting // check and see if we are installed in sites/all (for D5 and above) // we dont use checkURL since drupal generates an error page and throws diff --git a/CRM/Utils/System/Joomla.php b/CRM/Utils/System/Joomla.php index 84437d481f80..380fb3774bfb 100644 --- a/CRM/Utils/System/Joomla.php +++ b/CRM/Utils/System/Joomla.php @@ -879,4 +879,41 @@ public function synchronizeUsers() { ]; } + /** + * Determine the location of the CiviCRM source tree. + * + * FIXME: + * 1. This was pulled out from a bigger function. It should be split + * into even smaller pieces and marked abstract. + * 2. This would be easier to compute by a calling a CMS API, but + * for whatever reason we take the hard way. + * + * @return array + * - url: string. ex: "http://example.com/sites/all/modules/civicrm" + * - path: string. ex: "/var/www/sites/all/modules/civicrm" + */ + public function getCiviSourceStorage() { + global $civicrm_root; + if (!defined('CIVICRM_UF_BASEURL')) { + throw new RuntimeException('Undefined constant: CIVICRM_UF_BASEURL'); + } + $baseURL = CRM_Utils_File::addTrailingSlash(CIVICRM_UF_BASEURL, '/'); + if (CRM_Utils_System::isSSL()) { + $baseURL = str_replace('http://', 'https://', $baseURL); + } + + // For Joomla CiviCRM Core files always live within the admistrator folder and $base_url is different on the frontend compared to the backend. + if (strpos($baseURL, 'administrator') === FALSE) { + $userFrameworkResourceURL = $baseURL . "administrator/components/com_civicrm/civicrm/"; + } + else { + $userFrameworkResourceURL = $baseURL . "components/com_civicrm/civicrm/"; + } + + return [ + 'url' => CRM_Utils_File::addTrailingSlash($userFrameworkResourceURL, '/'), + 'path' => CRM_Utils_File::addTrailingSlash($civicrm_root), + ]; + } + }