From 42e1a97c2f0a14ae69c4b58b75bfb264f76953d5 Mon Sep 17 00:00:00 2001 From: Eileen Date: Thu, 14 Nov 2013 09:31:05 +1300 Subject: [PATCH] CRM-13737 drupal userSystem class fix formatResourceURL function to use class inheritance rather than a static functii ion ---------------------------------------- * CRM-13737: Restrucure drupal folder out of the civicrm folder http://issues.civicrm.org/jira/browse/CRM-13737 --- CRM/Utils/System/Drupal.php | 33 ++------------------------------- CRM/Utils/System/Drupal6.php | 4 ++-- CRM/Utils/System/DrupalBase.php | 29 +++++++++++++++++++++++++++++ 3 files changed, 33 insertions(+), 33 deletions(-) diff --git a/CRM/Utils/System/Drupal.php b/CRM/Utils/System/Drupal.php index 1e6cd0b3d4..16caf9e38c 100644 --- a/CRM/Utils/System/Drupal.php +++ b/CRM/Utils/System/Drupal.php @@ -331,7 +331,7 @@ class CRM_Utils_System_Drupal extends CRM_Utils_System_DrupalBase { return FALSE; } // If the path is within the drupal directory we can use the more efficient 'file' setting - $params['type'] = self::formatResourceUrl($url) ? 'file' : 'external'; + $params['type'] = $this->formatResourceUrl($url) ? 'file' : 'external'; drupal_add_js($url, $params); return TRUE; } @@ -380,7 +380,7 @@ class CRM_Utils_System_Drupal extends CRM_Utils_System_DrupalBase { } $params = array(); // If the path is within the drupal directory we can use the more efficient 'file' setting - $params['type'] = self::formatResourceUrl($url) ? 'file' : 'external'; + $params['type'] = $this->formatResourceUrl($url) ? 'file' : 'external'; drupal_add_css($url, $params); return TRUE; } @@ -406,35 +406,6 @@ class CRM_Utils_System_Drupal extends CRM_Utils_System_DrupalBase { return TRUE; } - /** - * Check if a resource url is within the drupal directory and format appropriately - * - * @param url (reference) - * - * @return bool: TRUE for internal paths, FALSE for external - */ - static function formatResourceUrl(&$url) { - $internal = FALSE; - $base = CRM_Core_Config::singleton()->resourceBase; - global $base_url; - // Handle absolute urls - if (strpos($url, $base_url) === 0) { - $internal = TRUE; - $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)), '/'); - } - // Strip query string - $q = strpos($url, '?'); - if ($q && $internal) { - $url = substr($url, 0, $q); - } - return $internal; - } - /** * rewrite various system urls to https * diff --git a/CRM/Utils/System/Drupal6.php b/CRM/Utils/System/Drupal6.php index 8ceba7259d..e5b6a1d66d 100644 --- a/CRM/Utils/System/Drupal6.php +++ b/CRM/Utils/System/Drupal6.php @@ -339,7 +339,7 @@ class CRM_Utils_System_Drupal6 extends CRM_Utils_System_DrupalBase { return FALSE; } // If the path is within the drupal directory we can add in the normal way - if (CRM_Utils_System_Drupal::formatResourceUrl($url)) { + if ($this->formatResourceUrl($url)) { drupal_add_js($url, 'module', $scope); return TRUE; } @@ -384,7 +384,7 @@ class CRM_Utils_System_Drupal6 extends CRM_Utils_System_DrupalBase { * @access public */ public function addStyleUrl($url, $region) { - if ($region != 'html-header' || !CRM_Utils_System_Drupal::formatResourceUrl($url)) { + if ($region != 'html-header' || !$this->formatResourceUrl($url)) { return FALSE; } drupal_add_css($url); diff --git a/CRM/Utils/System/DrupalBase.php b/CRM/Utils/System/DrupalBase.php index 82b79dd3e8..b0a4c7765c 100644 --- a/CRM/Utils/System/DrupalBase.php +++ b/CRM/Utils/System/DrupalBase.php @@ -71,4 +71,33 @@ abstract class CRM_Utils_System_DrupalBase extends CRM_Utils_System_Base { $url = $config->userFrameworkBaseURL; return array($url, $siteName, $siteRoot); } + + /** + * Check if a resource url is within the drupal directory and format appropriately + * + * @param url (reference) + * + * @return bool: TRUE for internal paths, FALSE for external + */ + function formatResourceUrl(&$url) { + $internal = FALSE; + $base = CRM_Core_Config::singleton()->resourceBase; + global $base_url; + // Handle absolute urls + if (strpos($url, $base_url) === 0) { + $internal = TRUE; + $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)), '/'); + } + // Strip query string + $q = strpos($url, '?'); + if ($q && $internal) { + $url = substr($url, 0, $q); + } + return $internal; + } } -- 2.25.1