From d8b4c4f055f51d23aa5a728bbf7a5c1ef99893a4 Mon Sep 17 00:00:00 2001 From: wei <> Date: Sun, 24 Sep 2006 23:30:54 +0000 Subject: Add case sensitive modifiers to TUrlMappingPattern --- framework/Web/TUrlMapping.php | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) (limited to 'framework') diff --git a/framework/Web/TUrlMapping.php b/framework/Web/TUrlMapping.php index 62656563..90acfd13 100644 --- a/framework/Web/TUrlMapping.php +++ b/framework/Web/TUrlMapping.php @@ -262,6 +262,10 @@ class TUrlMappingPattern extends TComponent * @var string regular expression pattern. */ private $_regexp; + /** + * @var boolean case sensitive matching, default is true + */ + private $_caseSensitive=true; public function __construct() { @@ -358,6 +362,22 @@ class TUrlMappingPattern extends TComponent $this->_pattern = $value; } + /** + * @param boolean case sensitive pattern matching, default is true. + */ + public function setCaseSensitive($value) + { + $this->_caseSensitive=TPropertyValue::ensureBoolean($value); + } + + /** + * @return boolean case sensitive pattern matching, default is true. + */ + public function getCaseSensitive() + { + return $this->_caseSensitive; + } + /** * @return TAttributeCollection parameter key value pairs. */ @@ -384,9 +404,21 @@ class TUrlMappingPattern extends TComponent $path = $url->getPath(); $matches=array(); $pattern = str_replace('/', '\\/', $this->getRegExpPattern()); - preg_match('/'.$pattern.'/', $path, $matches); + $modifiers = $this->getModifiers(); + preg_match('/'.$pattern.'/'.$modifiers, $path, $matches); return $matches; } + + /** + * @return string regular expression matching modifiers. + */ + protected function getModifiers() + { + $modifiers = 'u'; + if(!$this->getCaseSensitive()) + $modifiers .= 'i'; + return $modifiers; + } } ?> \ No newline at end of file -- cgit v1.2.3