Merge pull request #2138 from NileemaJadhav/CRM-13886
[civicrm-core.git] / CRM / Utils / System / Drupal.php
index fda57c0385727286cb67e173ed0b285bf2121983..16caf9e38cc92b33f084d2b247f20593115f1e3e 100644 (file)
@@ -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
    *
@@ -969,7 +940,7 @@ AND    u.status = 1
         if ($urlType == LOCALE_LANGUAGE_NEGOTIATION_URL_DOMAIN) {
           if (isset($language->domain) && $language->domain) {
             if ($addLanguagePart) {
-              $url = CRM_Utils_File::addTrailingSlash($language->domain, '/');
+              $url = (CRM_Utils_System::isSSL() ? 'https' : 'http') . '://' . $language->domain . base_path();
             }
             if ($removeLanguagePart && defined('CIVICRM_UF_BASEURL')) {
               $url = str_replace('\\', '/', $url);