function _gotwo_cleanstring in Go - url redirects 7
Mangle the input for url friendlyness. Based on pathauto_cleanstring from pathauto.module
1 call to _gotwo_cleanstring()
- _gotwo_get in ./
gotwo.module - Return the GO object url for a given link.
File
- ./
gotwo.module, line 400 - Module that provides easy to use redirection links. A redirection link would be like: http://examples.org/go/a_label http://examples.org/go/123546 http://examples.org/go/or/like/this
Code
function _gotwo_cleanstring($string) {
// Transliterate the URL with transliteration module.
if (module_exists('transliteration') && variable_get('gotwo_transliteration', TRUE)) {
$string = transliteration_get($string, '?', language_default('language'));
}
$output = str_replace("'", "", $string);
$pattern = '#[^a-zA-Z0-9./]+# ';
$separator = variable_get('gotwo_separator', '-');
$output = preg_replace($pattern, $separator, $output);
if ($separator) {
if (ctype_alnum($separator)) {
$seppattern = $separator;
}
else {
$seppattern = '\\' . $separator;
}
$output = preg_replace("/^{$seppattern}+|{$seppattern}+\$/", "", $output);
}
$maxlength = variable_get('gotwo_max_length', 128);
$output = substr($output, 0, $maxlength);
return $output;
}