diff options
author | GODZilla0480@gmail.com <> | 2011-10-17 07:36:47 +0000 |
---|---|---|
committer | GODZilla0480@gmail.com <> | 2011-10-17 07:36:47 +0000 |
commit | 22471c977d4edc4ddfe63abe23928d03e659f045 (patch) | |
tree | 363c6861ec66e705eb9289d4bcdbd1db3320fd94 /demos | |
parent | 9b0b7d32a4d7ab6d1bbd0f8ca14be9fbf325f081 (diff) |
Port changes of r3050 (branches/3.1) to trunk
Diffstat (limited to 'demos')
-rw-r--r-- | demos/quickstart/protected/pages/Configurations/UrlMapping.page | 71 |
1 files changed, 41 insertions, 30 deletions
diff --git a/demos/quickstart/protected/pages/Configurations/UrlMapping.page b/demos/quickstart/protected/pages/Configurations/UrlMapping.page index c47ace28..4af61180 100644 --- a/demos/quickstart/protected/pages/Configurations/UrlMapping.page +++ b/demos/quickstart/protected/pages/Configurations/UrlMapping.page @@ -22,12 +22,12 @@ pattern will be replaced with the corresponding GET variable values. To use <tt>TUrlMapping</tt>, one must set the <tt>UrlManager</tt> property of the <tt>THttpRequest</tt> module as the <tt>TUrlMapping</tt> module ID. See following for an example,
<com:TTextHighlighter Language="xml" CssClass="source block-content" id="code_230098">
<modules>
- <module id="request" class="THttpRequest" UrlManager="friendly-url" />
- <module id="friendly-url" class="System.Web.TUrlMapping">
- <url ServiceParameter="Posts.ViewPost" pattern="post/{id}/" parameters.id="\d+" />
- <url ServiceParameter="Posts.ListPost" pattern="archive/{time}/" parameters.time="\d{6}" />
- <url ServiceParameter="Posts.ListPost" pattern="category/{cat}/" parameters.cat="\d+" />
- </module>
+ <module id="request" class="THttpRequest" UrlManager="friendly-url" />
+ <module id="friendly-url" class="System.Web.TUrlMapping">
+ <url ServiceParameter="Posts.ViewPost" pattern="post/{id}/" parameters.id="\d+" />
+ <url ServiceParameter="Posts.ListPost" pattern="archive/{time}/" parameters.time="\d{6}" />
+ <url ServiceParameter="Posts.ListPost" pattern="category/{cat}/" parameters.cat="\d+" />
+ </module>
</modules>
</com:TTextHighlighter>
</p>
@@ -36,9 +36,9 @@ To use <tt>TUrlMapping</tt>, one must set the <tt>UrlManager</tt> property of th The above example is part of the application configuration of the <tt>blog</tt> demo in the PRADO release. It enables recognition of the following URL formats:
</p>
<ul id="u1" class="block-content">
- <li><tt>/index.php/post/123</tt> is recognized as <tt>/index.php?page=Posts.ViewPost&id=123</tt></li>
- <li><tt>/index.php/archive/200605</tt> is recognized as <tt>/index.php?page=Posts.ListPost&time=200605</tt></li>
- <li><tt>/index.php/category/2</tt> is recognized as <tt>/index.php?page=Posts.ListPost&cat=2</tt></li>
+ <li><tt>/index.php/post/123</tt> is recognized as <tt>/index.php?page=Posts.ViewPost&id=123</tt></li>
+ <li><tt>/index.php/archive/200605</tt> is recognized as <tt>/index.php?page=Posts.ListPost&time=200605</tt></li>
+ <li><tt>/index.php/category/2</tt> is recognized as <tt>/index.php?page=Posts.ListPost&cat=2</tt></li>
</ul>
<p id="230226" class="block-content">
@@ -69,13 +69,14 @@ using <tt>Parameters</tt> attribute collection. For example,
<com:TTextHighlighter Language="xml" CssClass="source block-content" id="code_230099">
<url ServiceParameter="ArticleView" pattern="articles/{year}/{month}/{day}"
- parameters.year="\d{4}" parameters.month="\d{2}" parameters.day="\d+" />
+ parameters.year="\d{4}" parameters.month="\d{2}" parameters.day="\d+" />
</com:TTextHighlighter>
</p>
The example is equivalent to the following regular expression (it uses the "named group" feature in regular expressions available in PHP):
<com:TTextHighlighter Language="xml" CssClass="source block-content" id="code_230100">
-<url ServiceParameter="ArticleView"
- RegularExpression="/articles\/(?P<year>\d{4})\/(?P<month>\d{2})\/(?P<day>\d+)/u" />
+<url ServiceParameter="ArticleView"><![CDATA[
+ #articles/(?P<year>\d{4})/(?P<month>\d{2})/(?P<day>\d+)#u
+]]></url>
</com:TTextHighlighter>
<p id="230229" class="block-content">
In the above example, the pattern contains 3 parameters named "<tt>year</tt>",
@@ -83,12 +84,22 @@ In the above example, the pattern contains 3 parameters named "<tt>year</tt>", respectively, "<tt>\d{4}</tt>" (4 digits), "<tt>\d{2}</tt>" (2 digits)
and "<tt>\d+</tt>" (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
+as substrings in replacing the placeholders in the <tt>Pattern</tt> string
to form a complete regular expression string.
</p>
-<div class="note"><b class="tip">Note:</b> If you intended to use the <tt>RegularExpression</tt>
-property you need to escape the slash in regular expressions.
+For simple (not parameterized) regular expressions you can use the <tt>RegularExpression</tt> property:
+<com:TTextHighlighter Language="xml" CssClass="source block-content">
+<url ServiceParameter="ArticleView"
+ RegularExpression="/articles\/best-of/u" />
+</com:TTextHighlighter>
+
+<div class="note"><b class="tip">Note:</b>
+ If you intended to use the <tt>RegularExpression</tt> property or regular expressions in CDATA sections,
+ notice that you need to escape the slash, if you are using the slash as regular expressions delimiter.
+ <br/>
+ If you are using the "<i>CDATA section</i>" version all whitespaces like
+ <code>\n, \t, \r</code> and so on will be removed automaticly.
</div>
<p id="230230" class="block-content">Following from the above pattern example,
@@ -107,11 +118,11 @@ object. For example, <tt>$this->Request['year']</tt>. </p>
<p id="230232" class="block-content">The URL mapping are evaluated in order they are placed and only the first pattern that matches
- the URL will be used. Cascaded mapping can be achieved by placing the URL mappings
- in particular order. For example, placing the most specific mappings first.
+the URL will be used. Cascaded mapping can be achieved by placing the URL mappings
+in particular order. For example, placing the most specific mappings first.
</p>
-<p class="block-content">Since version 3.1.4, Prado also provides wildcard patterns to use friendly URLs
+<p class="block-content">Since version 3.1.4, Prado also provides wildcard patterns to use friendly URLs
for a bunch of pages in a directory with a single rule. Therefore you can use the <tt>{*}</tt> wildcard
in your pattern to let Prado know, where to find the ServiceID in your request URL. You can also specify
parameters with these patterns if a lot of pages share common parameters.</p>
@@ -124,18 +135,18 @@ parameters with these patterns if a lot of pages share common parameters.</p> <p class="block-content">With these rules, any of the following URLs will be recognized:
<ul id="u1" class="block-content">
- <li><tt>/index.php/post/ViewPost/123</tt> is recognized as <tt>/index.php?page=Posts.ViewPost&id=123</tt></li>
- <li><tt>/index.php/post/ListPost/123</tt> is recognized as <tt>/index.php?page=Posts.ListPost&id=123</tt></li>
- <li><tt>/index.php/post/ListPost/123</tt> is recognized as <tt>/index.php?page=Posts.ListPost&id=123</tt></li>
- <li><tt>/index.php/post/MyPost</tt> is recognized as <tt>/index.php?page=Posts.MyPost</tt></li>
- <li><tt>/index.php/info/Conditions</tt> is recognized as <tt>/index.php?page=Static.Info.Conditions</tt></li>
- <li><tt>/index.php/info/About</tt> is recognized as <tt>/index.php?page=Static.Info.About</tt></li>
+ <li><tt>/index.php/post/ViewPost/123</tt> is recognized as <tt>/index.php?page=Posts.ViewPost&id=123</tt></li>
+ <li><tt>/index.php/post/ListPost/123</tt> is recognized as <tt>/index.php?page=Posts.ListPost&id=123</tt></li>
+ <li><tt>/index.php/post/ListPost/123</tt> is recognized as <tt>/index.php?page=Posts.ListPost&id=123</tt></li>
+ <li><tt>/index.php/post/MyPost</tt> is recognized as <tt>/index.php?page=Posts.MyPost</tt></li>
+ <li><tt>/index.php/info/Conditions</tt> is recognized as <tt>/index.php?page=Static.Info.Conditions</tt></li>
+ <li><tt>/index.php/info/About</tt> is recognized as <tt>/index.php?page=Static.Info.About</tt></li>
</ul>
</p>
<p id="250001" class="block-content">As above, put more specific rules before more common rules as the first matching rule will be used.</p>
-<p id="250002" class="block-content">To make configuration of friendly URLs for multiple pages even easier, you can also use <tt>UrlFormat="Path"</tt>
+<p id="250002" class="block-content">To make configuration of friendly URLs for multiple pages even easier, you can also use <tt>UrlFormat="Path"</tt>
in combination with wildcard patterns. In fact, this feature only is available in combination with wildcard rules:</P>
<com:TTextHighlighter Language="xml" CssClass="source block-content">
@@ -143,13 +154,13 @@ in combination with wildcard patterns. In fact, this feature only is available i <url ServiceParameter="*" pattern="{*}" UrlFormat="Path" />
</com:TTextHighlighter>
-<p class="block-content">Parameters will get appended to the specified patterns as name/value pairs, separated by a "/".
+<p class="block-content">Parameters will get appended to the specified patterns as name/value pairs, separated by a "/".
(You can change the separator character with <tt>UrlParamSeparator</tt>.)
<ul id="u1" class="block-content">
- <li><tt>/index.php/list/cat/15/month/12</tt> is recognized as <tt>/index.php?page=list&cat=15&month=12</tt></li>
- <li><tt>/index.php/edit/id/12</tt> is recognized as <tt>/index.php?page=list&id=12</tt></li>
- <li><tt>/index.php/show/name/foo</tt> is recognized as <tt>/index.php?page=show&name=foo</tt></li>
- <li><tt>/index.php/admin/edit/id/12</tt> is recognized as <tt>/index.php?page=user.admin.edit&id=12</tt></li>
+ <li><tt>/index.php/list/cat/15/month/12</tt> is recognized as <tt>/index.php?page=list&cat=15&month=12</tt></li>
+ <li><tt>/index.php/edit/id/12</tt> is recognized as <tt>/index.php?page=list&id=12</tt></li>
+ <li><tt>/index.php/show/name/foo</tt> is recognized as <tt>/index.php?page=show&name=foo</tt></li>
+ <li><tt>/index.php/admin/edit/id/12</tt> is recognized as <tt>/index.php?page=user.admin.edit&id=12</tt></li>
</ul>
</p>
|