function _hansel_switch_string_compare in Hansel breadcrumbs 7
Same name and namespace in other branches
- 8 hansel.switches.inc \_hansel_switch_string_compare()
Helper function to compare a path with a given value.
Parameters
array $arguments:
string $value:
Return value
boolean
2 calls to _hansel_switch_string_compare()
- hansel_switch_path_alias_compare in ./
hansel.switches.inc - Callback for "path alias" switch to compare a given value.
- hansel_switch_request_uri_compare in ./
hansel.switches.inc - Callback for "Request URI" switch.
File
- ./
hansel.switches.inc, line 190 - Hansel switches
Code
function _hansel_switch_string_compare($arguments, $value, $path) {
$mode = empty($arguments['mode']) ? 0 : $arguments['mode'];
switch ($mode) {
case 0:
$pattern = '^' . preg_quote($value);
break;
case 1:
$pattern = preg_quote($value) . '$';
break;
case 2:
$pattern = preg_quote($value);
break;
case 3:
$pattern = $value;
break;
}
$pattern = str_replace('/', '\\/', $pattern);
$pattern = "/{$pattern}/s";
if (empty($arguments['cs'])) {
$pattern .= 'i';
}
return (bool) @preg_match($pattern, $path);
}