From 168be77df107d5ca4dfe41e4c0b887b8e146d294 Mon Sep 17 00:00:00 2001 From: Eileen Date: Thu, 14 Nov 2013 09:37:16 +1300 Subject: [PATCH] CRM-13737 allow drupal folder to be at the same level as the civicrm folder ---------------------------------------- * CRM-13737: Restrucure drupal folder out of the civicrm folder http://issues.civicrm.org/jira/browse/CRM-13737 CRM-13737 tidy up previous commit ---------------------------------------- * CRM-13737: Restrucure drupal folder out of the civicrm folder http://issues.civicrm.org/jira/browse/CRM-13737 --- CRM/Utils/System/DrupalBase.php | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/CRM/Utils/System/DrupalBase.php b/CRM/Utils/System/DrupalBase.php index b0a4c7765c..7efe21bb62 100644 --- a/CRM/Utils/System/DrupalBase.php +++ b/CRM/Utils/System/DrupalBase.php @@ -86,12 +86,13 @@ abstract class CRM_Utils_System_DrupalBase extends CRM_Utils_System_Base { // Handle absolute urls if (strpos($url, $base_url) === 0) { $internal = TRUE; + $url = $this->appendCoreDirectoryToResourceBase($url); $url = trim(str_replace($base_url, '', $url), '/'); } // Handle relative urls elseif (strpos($url, $base) === 0) { $internal = TRUE; - $url = substr(drupal_get_path('module', 'civicrm'), 0, -6) . trim(substr($url, strlen($base)), '/'); + $url = $this->appendCoreDirectoryToResourceBase(substr(drupal_get_path('module', 'civicrm'), 0, -6)) . trim(substr($url, strlen($base)), '/'); } // Strip query string $q = strpos($url, '?'); @@ -100,4 +101,23 @@ abstract class CRM_Utils_System_DrupalBase extends CRM_Utils_System_Base { } return $internal; } + + /** + * In instance where civicrm folder has a drupal folder & a civicrm core folder @ the same level append the + * civicrm folder name to the url + * See CRM-13737 for discussion of how this allows implementers to alter the folder structure + * @todo - this only provides a limited amount of flexiblity - it still expects a 'civicrm' folder with a 'drupal' folder + * and is only flexible as to the name of the civicrm folder. + * + * @param string $url potential resource url based on standard folder assumptions + * @return string $url with civicrm-core directory appended if not standard civi dir + */ + function appendCoreDirectoryToResourceBase($url) { + global $civicrm_root; + $lastDirectory = implode(',', array_slice(explode('/', $civicrm_root), -1, 1, TRUE)); + if(!$lastDirectory != 'civicrm') { + return $url .= $lastDirectory . '/'; + } + return $url; + } } -- 2.25.1