URL Mapping Pattern Class
Describes an URL mapping pattern, if a given URL matches the pattern, the TUrlMapping class will alter the THttpRequest parameters. The url matching is done using patterns and regular expressions.
The Pattern property takes an string expression with parameter names enclosed between a left brace '{' and a right brace '}'. The pattens for each parameter can be set using Parameters attribute collection. For example
- <url ... pattern="articles/{year}/{month}/{day}"
- parameters.year="\d{4}" parameters.month="\d{2}" parameters.day="\d+" />
In the above example, the pattern contains 3 parameters named "year", "month" and "day". The pattern for these parameters are, respectively, "\d{4}" (4 digits), "\d{2}" (2 digits) and "\d+" (1 or more digits). Essentially, the <tt>Parameters</tt> attribute name and values are used as substrings in replacing the placeholders in the <tt>Pattern</tt> string to form a complete regular expression string. A full regular expression may be expressed using the <tt>RegularExpression</tt> attribute or as the body content of the <module> tag. The above pattern is equivalent to the following regular expression pattern.
The above regular expression used the "named group" feature available in PHP. Notice that you need to escape the slash in regular expressions.
- /articles/(?P<year>d{4})/(?P<month>d{2})/(?P<day>d+)/u
In the TUrlMappingPattern class, the pattern is matched against the path property of the url only.
Thus, only an url that matches the pattern will be valid. For example, an url "<tt>http://example.com/articles/2006/07/21</tt>" will matches and is valid. However, "<tt>http://example.com/articles/2006/07/hello</tt>" is not valid since the "day" parameter pattern is not satisfied.
The parameter values are available through the standard <tt>Request</tt> object. For example, <tt>$this->Request['year']</tt>.
The ServiceParameter and ServiceID (the default ID is 'page') set the service parameter and service id respectively. The service parameter for the TPageService is the Page class name, other service may use the service parameter differently.
For more complicated mappings, the body of the <tt><url></tt> can be used to specify the mapping pattern.
Located in /Web/TUrlMapping.php (line 254)
TComponent | --TUrlMappingPattern
Subsitutue the parameter key value pairs as named groupings in the regular expression matching pattern.
Uses URL pattern (or full regular expression if available) to match the given url path.
Initialize the pattern, uses the body content as pattern is available.
Inherited From TComponent
TComponent::addParsedObject()
TComponent::attachEventHandler()
TComponent::canGetProperty()
TComponent::canSetProperty()
TComponent::createdOnTemplate()
TComponent::detachEventHandler()
TComponent::evaluateExpression()
TComponent::evaluateStatements()
TComponent::getEventHandlers()
TComponent::getSubProperty()
TComponent::hasEvent()
TComponent::hasEventHandler()
TComponent::hasProperty()
TComponent::raiseEvent()
TComponent::setSubProperty()
TComponent::__get()
TComponent::__set()
Documentation generated on Sun, 14 Jan 2007 21:44:56 -0500 by phpDocumentor 1.3.0RC4