function _messaging_htmlmail_url in Messaging 7
Helper function to format urls
Parameters
$url an url:
Return value
an absolute url, sans mailto:
2 calls to _messaging_htmlmail_url()
- _messaging_htmlmail_expand_links in messaging_htmlmail/
messaging_htmlmail.inc - Callback for preg_replace_callback()
- _messaging_htmlmail_file in messaging_htmlmail/
messaging_htmlmail.inc - Helper function to extract local files
File
- messaging_htmlmail/
messaging_htmlmail.inc, line 595 - Drupal Messaging Framework - Send_Method class file
Code
function _messaging_htmlmail_url($url, $embed_file = NULL) {
global $base_url;
$url = urldecode($url);
// If the URL is absolute or a mailto, return it as-is.
if (strpos($url, '://') !== FALSE || preg_match('!mailto:!', $url)) {
$url = str_replace(' ', '%20', $url);
return $url;
}
$url = preg_replace('!^' . base_path() . '!', '', $url, 1);
// If we're processing to embed the file, we're done here so return.
if ($embed_file) {
return $url;
}
if (!preg_match('!^\\?q=*!', $url)) {
$strip_clean = TRUE;
}
$url = str_replace('?q=', '', $url);
list($url, $fragment) = explode('#', $url, 2);
list($path, $query) = explode('?', $url, 2);
// If we're dealing with an intra-document reference, return it.
if (empty($path) && !empty($fragment)) {
return '#' . $fragment;
}
// If we have not yet returned, then let's clean things up and leave.
$url = url($path, array(
'query' => $query,
'fragment' => $fragment,
'absolute' => TRUE,
));
// If url() added a ?q= where there should not be one, remove it.
if ($strip_clean) {
$url = preg_replace('!\\?q=!', '', $url);
}
$url = str_replace('+', '%20', $url);
return $url;
}