* The URL fragment.
*/
public static function makeURL($urlVar, $includeReset = FALSE, $includeForce = TRUE, $path = NULL, $absolute = FALSE) {
- if (empty($path)) {
- $config = CRM_Core_Config::singleton();
- $path = CRM_Utils_Array::value($config->userFrameworkURLVar, $_GET);
- if (empty($path)) {
- return '';
- }
+ $path = $path ?: CRM_Utils_System::currentPath();
+ if (!$path) {
+ return '';
}
return self::url(
- $path,
- CRM_Utils_System::getLinksUrl($urlVar, $includeReset, $includeForce),
- $absolute
- );
+ $path,
+ CRM_Utils_System::getLinksUrl($urlVar, $includeReset, $includeForce),
+ $absolute
+ );
}
/**
'absolute' => $absolute,
'isSSL' => $isSSL,
]);
- Civi::service('dispatcher')->dispatch('hook_civicrm_alterExternUrl', $event);
+ Civi::dispatcher()->dispatch('hook_civicrm_alterExternUrl', $event);
return urldecode(CRM_Utils_Url::unparseUrl($event->url));
}
/**
- * Path of the current page e.g. 'civicrm/contact/view'
+ * @deprecated
+ * @see \CRM_Utils_System::currentPath
*
* @return string|null
*/
public static function getUrlPath() {
- if (isset($_GET[CRM_Core_Config::singleton()->userFrameworkURLVar])) {
- return $_GET[CRM_Core_Config::singleton()->userFrameworkURLVar];
- }
- return NULL;
+ CRM_Core_Error::deprecatedFunctionWarning('CRM_Utils_System::currentPath');
+ return self::currentPath();
}
/**
}
/**
- * What menu path are we currently on. Called for the primary tpl.
+ * Path of the current page e.g. 'civicrm/contact/view'
*
- * @return string
+ * @return string|null
* the current menu path
*/
public static function currentPath() {
$config = CRM_Core_Config::singleton();
- return trim(CRM_Utils_Array::value($config->userFrameworkURLVar, $_GET), '/');
+ return isset($_GET[$config->userFrameworkURLVar]) ? trim($_GET[$config->userFrameworkURLVar], '/') : NULL;
}
/**
* url
*/
public static function crmURL($params) {
- $p = CRM_Utils_Array::value('p', $params);
+ $p = $params['p'] ?? NULL;
if (!isset($p)) {
$p = self::currentPath();
}
$url = $default;
$session = CRM_Core_Session::singleton();
- $referer = CRM_Utils_Array::value('HTTP_REFERER', $_SERVER);
+ $referer = $_SERVER['HTTP_REFERER'] ?? NULL;
if ($referer && !empty($names)) {
foreach ($names as $name) {
// this is kinda hackish but not sure how to do it right
$url = str_replace('&', '&', $url);
- $context['output'] = CRM_Utils_Array::value('snippet', $_GET);
+ $context['output'] = $_GET['snippet'] ?? NULL;
$parsedUrl = CRM_Utils_Url::parseUrl($url);
CRM_Utils_Hook::alterRedirect($parsedUrl, $context);
* this function, please go and change the code in the install script as well.
*/
public static function isSSL() {
- return (isset($_SERVER['HTTPS']) &&
- !empty($_SERVER['HTTPS']) &&
- strtolower($_SERVER['HTTPS']) != 'off') ? TRUE : FALSE;
+ return !empty($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) != 'off';
}
/**
* IP address of logged in user.
*/
public static function ipAddress($strictIPV4 = TRUE) {
- $address = CRM_Utils_Array::value('REMOTE_ADDR', $_SERVER);
+ $address = $_SERVER['REMOTE_ADDR'] ?? NULL;
$config = CRM_Core_Config::singleton();
if ($config->userSystem->is_drupal && function_exists('ip_address')) {
* The previous page URL
*/
public static function refererPath() {
- return CRM_Utils_Array::value('HTTP_REFERER', $_SERVER);
+ return $_SERVER['HTTP_REFERER'] ?? NULL;
}
/**
// reset ACL cache
CRM_ACL_BAO_Cache::resetCache();
+ // clear asset builder folder
+ \Civi::service('asset_builder')->clear(FALSE);
+
// reset various static arrays used here
CRM_Contact_BAO_Contact::$_importableFields = CRM_Contact_BAO_Contact::$_exportableFields
= CRM_Contribute_BAO_Contribution::$_importableFields
}
else {
$config = CRM_Core_Config::singleton();
+ $tsLocale = CRM_Core_I18n::getLocale();
$vars = [
'{ver}' => CRM_Utils_System::version(),
'{uf}' => $config->userFramework,
'{php}' => phpversion(),
'{sid}' => self::getSiteID(),
'{baseUrl}' => $config->userFrameworkBaseURL,
- '{lang}' => $config->lcMessages,
+ '{lang}' => $tsLocale,
'{co}' => $config->defaultContactCountry,
];
return strtr($url, array_map('urlencode', $vars));