return $url;
}
+ /**
+ * Generates an extern url.
+ *
+ * @param string $path
+ * The extern path, such as "extern/url".
+ * @param string $query
+ * A query string to append to the link.
+ * @param string $fragment
+ * A fragment identifier (named anchor) to append to the link.
+ * @param bool $absolute
+ * Whether to force the output to be an absolute link (beginning with a
+ * URI-scheme such as 'http:').
+ * @param bool $isSSL
+ * NULL to autodetect. TRUE to force to SSL.
+ *
+ * @return string rawencoded URL.
+ */
+ public static function externUrl($path = NULL, $query = NULL, $fragment = NULL, $absolute = TRUE, $isSSL = NULL) {
+ $query = self::makeQueryString($query);
+
+ $url = Civi::paths()->getUrl("[civicrm.root]/{$path}.php", $absolute ? 'absolute' : 'relative', $isSSL)
+ . ($query ? "?$query" : "")
+ . ($fragment ? "#$fragment" : "");
+
+ $parsedUrl = CRM_Utils_Url::parseUrl($url);
+ $event = \Civi\Core\Event\GenericHookEvent::create([
+ 'url' => &$parsedUrl,
+ 'path' => $path,
+ 'query' => $query,
+ 'fragment' => $fragment,
+ 'absolute' => $absolute,
+ 'isSSL' => $isSSL,
+ ]);
+ Civi::service('dispatcher')->dispatch('hook_civicrm_alterExternUrl', $event);
+ return urldecode(CRM_Utils_Url::unparseUrl($event->url));
+ }
+
/**
* Path of the current page e.g. 'civicrm/contact/view'
*
* Returns TRUE if the requirement is met, FALSE if the requirement is not
* met and we're not aborting due to the failed requirement. If $abort is
* TRUE and the requirement fails, this function does not return.
+ *
+ * @throws CRM_Core_Exception
*/
public static function checkPHPVersion($ver = 5, $abort = TRUE) {
$phpVersion = substr(PHP_VERSION, 0, 1);
}
if ($abort) {
- CRM_Core_Error::fatal(ts('This feature requires PHP Version %1 or greater',
+ throw new CRM_Core_Exception(ts('This feature requires PHP Version %1 or greater',
[1 => $ver]
));
}
*
* @return string
* civicrm version
+ *
+ * @throws CRM_Core_Exception
*/
public static function version() {
static $version;
// pattern check
if (!CRM_Utils_System::isVersionFormatValid($version)) {
- CRM_Core_Error::fatal('Unknown codebase version.');
+ throw new CRM_Core_Exception('Unknown codebase version.');
}
}
*
* @param bool|FALSE $abort
*
- * @throws \Exception
+ * @throws \CRM_Core_Exception
*/
public static function redirectToSSL($abort = FALSE) {
$config = CRM_Core_Config::singleton();
Civi::log()->warning('CiviCRM thinks site is not SSL, redirecting to {url}', ['url' => $url]);
if (!self::checkURL($url, TRUE)) {
if ($abort) {
- CRM_Core_Error::fatal('HTTPS is not set up on this machine');
+ throw new CRM_Core_Exception('HTTPS is not set up on this machine');
}
else {
CRM_Core_Session::setStatus(ts('HTTPS is not set up on this machine'), ts('Warning'), 'alert');
// 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));