function _path_breadcrumbs_clean_url in Path Breadcrumbs 7.3
Helper function to clean URLs according to Path Breadcrumbs settings.
Parameters
$url URL to clean.:
&$options array of options for l() function.: Function can overwrite 'query' and 'fragment' keys with data from $url.
$method One of supported methods: 'none', 'ctools', 'pathauto'.:
Return value
string Cleared URL.
2 calls to _path_breadcrumbs_clean_url()
- path_breadcrumbs_breadcrumb in ./
path_breadcrumbs.module - Override default theme_breadcrumb().
- _path_breadcrumbs_build_breadcrumbs in ./
path_breadcrumbs.module - Build breadcrumbs navigation from loaded path breadcrumb variant.
File
- ./
path_breadcrumbs.module, line 910
Code
function _path_breadcrumbs_clean_url($url, &$options, $method = NULL) {
// Reset options.
$options['fragment'] = '';
$options['query'] = array();
// Decode & back to &.
$url_short = htmlspecialchars_decode($url, ENT_NOQUOTES);
$url_parts = parse_url($url_short);
// Remove #hash from URL.
if (!empty($url_parts['fragment'])) {
$options['fragment'] = $url_parts['fragment'];
list($url_short, ) = explode('#', $url_short, 2);
}
// Remove query string from URL.
$options['query'] = array();
if (!empty($url_parts['query'])) {
list($url_short, ) = explode('?', $url_short, 2);
parse_str($url_parts['query'], $query);
$options['query'] += $query;
}
if (empty($method)) {
$method = variable_get('path_breadcrumbs_url_cleaning_method', 'none');
}
if ($method == 'none') {
return $url_short;
}
// Ignore absolute URLs.
if (preg_match('@^http(s?)://@i', $url_short)) {
return $url_short;
}
$ctools_cleanstring_settings = array(
'clean id' => 'path_breadcrumbs_url',
'lower case' => TRUE,
'transliterate' => TRUE,
'reduce ascii' => FALSE,
'separator' => '-',
);
$pieces = explode('/', $url_short);
$results = array();
if ($method == 'ctools') {
ctools_include('cleanstring');
foreach ($pieces as $piece) {
$results[] = ctools_cleanstring($piece, $ctools_cleanstring_settings);
}
$options['fragment'] = ctools_cleanstring($options['fragment'], $ctools_cleanstring_settings);
}
elseif ($method == 'pathauto' && module_exists('pathauto')) {
module_load_include('inc', 'pathauto');
foreach ($pieces as $piece) {
$results[] = pathauto_cleanstring($piece);
}
$options['fragment'] = pathauto_cleanstring($options['fragment']);
}
else {
$results = $pieces;
}
return implode('/', $results);
}