<?php
/*
+--------------------------------------------------------------------+
- | CiviCRM version 4.6 |
+ | CiviCRM version 4.7 |
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2015 |
+--------------------------------------------------------------------+
// Handle relative urls that are within the CiviCRM module directory
elseif (strpos($url, $base) === 0) {
$internal = TRUE;
- $url = $this->appendCoreDirectoryToResourceBase(substr(drupal_get_path('module', 'civicrm'), 0, -6)) . trim(substr($url, strlen($base)), '/');
+ $url = $this->appendCoreDirectoryToResourceBase(dirname(drupal_get_path('module', 'civicrm')) . '/') . trim(substr($url, strlen($base)), '/');
}
// Strip query string
$q = strpos($url, '?');
$query = NULL,
$absolute = FALSE,
$fragment = NULL,
- $htmlize = TRUE,
$frontend = FALSE,
$forceBackend = FALSE
) {
$fragment = '#' . $fragment;
}
- if (!isset($config->useFrameworkRelativeBase)) {
- $base = parse_url($config->userFrameworkBaseURL);
- $config->useFrameworkRelativeBase = $base['path'];
- }
$base = $absolute ? $config->userFrameworkBaseURL : $config->useFrameworkRelativeBase;
- $separator = $htmlize ? '&' : '&';
+ $separator = '&';
if (!$config->cleanURL) {
if (isset($path)) {
/**
* Append Drupal js to coreResourcesList.
+ *
+ * @param array $list
*/
public function appendCoreResources(&$list) {
$list[] = 'js/crm.drupal.js';
return CRM_Core_I18n_PseudoConstant::longForShort(substr($language->language, 0, 2));
}
+ /**
+ * @inheritDoc
+ */
+ public function setUFLocale($civicrm_language) {
+ global $language;
+
+ $langcode = substr($civicrm_language, 0, 2);
+ $languages = language_list();
+
+ if (isset($languages[$langcode])) {
+ $language = $languages[$langcode];
+
+ // Config must be re-initialized to reset the base URL
+ // otherwise links will have the wrong language prefix/domain.
+ $config = CRM_Core_Config::singleton();
+ $config->free();
+
+ return TRUE;
+ }
+
+ return FALSE;
+ }
+
/**
* Perform any post login activities required by the UF -
* e.g. for drupal: records a watchdog message about the new session, saves the login timestamp,
/**
* Fixme: Why are we overriding the parent function? Seems inconsistent.
* This version supplies slightly different params to $this->url (not absolute and html encoded) but why?
+ *
+ * @param string $action
+ *
+ * @return string
*/
public function postURL($action) {
if (!empty($action)) {
return user_load($userID);
}
+ public function parseDrupalSiteName($civicrm_root) {
+ $siteName = NULL;
+ if (strpos($civicrm_root,
+ DIRECTORY_SEPARATOR . 'sites' . DIRECTORY_SEPARATOR . 'all' . DIRECTORY_SEPARATOR . 'modules'
+ ) === FALSE
+ ) {
+ $startPos = strpos($civicrm_root,
+ DIRECTORY_SEPARATOR . 'sites' . DIRECTORY_SEPARATOR
+ );
+ $endPos = strpos($civicrm_root,
+ DIRECTORY_SEPARATOR . 'modules' . DIRECTORY_SEPARATOR
+ );
+ if ($startPos && $endPos) {
+ // if component is in sites/SITENAME/modules
+ $siteName = substr($civicrm_root,
+ $startPos + 7,
+ $endPos - $startPos - 7
+ );
+ }
+ }
+ return $siteName;
+ }
+
}