X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=CRM%2FUtils%2FSystem%2FDrupalBase.php;h=56cf330f94d72982dea8d1b9bb198b4e76438ed5;hb=fd1f3a266a087d557658f87979faece9ddf4161f;hp=fac22c0c7e9d9e0b631c30af22f6ddcc2ed48a00;hpb=638c59ed3d7f7fda62fa581d271c475c473043ce;p=civicrm-core.git diff --git a/CRM/Utils/System/DrupalBase.php b/CRM/Utils/System/DrupalBase.php index fac22c0c7e..56cf330f94 100644 --- a/CRM/Utils/System/DrupalBase.php +++ b/CRM/Utils/System/DrupalBase.php @@ -160,10 +160,6 @@ abstract class CRM_Utils_System_DrupalBase extends CRM_Utils_System_Base { $fragment = '#' . $fragment; } - if (!isset($config->useFrameworkRelativeBase)) { - $base = parse_url($config->userFrameworkBaseURL); - $config->useFrameworkRelativeBase = $base['path']; - } $base = $absolute ? $config->userFrameworkBaseURL : $config->useFrameworkRelativeBase; $separator = $htmlize ? '&' : '&'; @@ -429,6 +425,29 @@ abstract class CRM_Utils_System_DrupalBase extends CRM_Utils_System_Base { 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, @@ -517,4 +536,27 @@ abstract class CRM_Utils_System_DrupalBase extends CRM_Utils_System_Base { 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; + } + }