1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66:
<?php
class DispatcherUrlMapping extends UrlMapping
{
private $high_priority = false;
private $low_priority = false;
public function __construct($dispatcher_name, $match = '([\w/_-]*)$', $from_path = '', $redirect_path = '')
{
if (!empty($from_path))
{
if ($from_path == 'root')
{
$from = '^' . $match;
$to = $dispatcher_name . '?url=/' . ($redirect_path ? $redirect_path : '$1');
$this->low_priority = true;
}
else
{
$dispatcher_path = ltrim(TextHelper::substr($from_path, 0, TextHelper::strrpos($from_path, '/') + 1), '/');
$from = '^' . $dispatcher_path . $match;
$to = $dispatcher_name . '?url=/' . $dispatcher_path . '$1';
$this->high_priority = true;
}
}
else
{
$dispatcher_path = ltrim(TextHelper::substr($dispatcher_name, 0, TextHelper::strrpos($dispatcher_name, '/') + 1), '/');
$from = '^' . $dispatcher_path . $match;
$to = $dispatcher_name . '?url=/$1';
}
parent::__construct($from, $to);
}
public function is_high_priority()
{
return $this->high_priority;
}
public function is_low_priority()
{
return $this->low_priority;
}
}
?>