summaryrefslogtreecommitdiff
path: root/framework/Web/TUrlMapping.php
diff options
context:
space:
mode:
authorCiro Mattia Gonano <ciromattia@gmail.com>2013-04-24 09:59:46 +0200
committerCiro Mattia Gonano <ciromattia@gmail.com>2013-04-24 09:59:48 +0200
commitdaa4dde508865ef0f08e584987b0695d4847809a (patch)
treee4aaed56bea63ec5d569fc74ff10f0e36618c50e /framework/Web/TUrlMapping.php
parenta08d87f68a22df1ffb001ebe1cc3f438c045b843 (diff)
Update to 3.2.1
Diffstat (limited to 'framework/Web/TUrlMapping.php')
-rw-r--r--framework/Web/TUrlMapping.php98
1 files changed, 17 insertions, 81 deletions
diff --git a/framework/Web/TUrlMapping.php b/framework/Web/TUrlMapping.php
index b5a09f14..ecbe5935 100644
--- a/framework/Web/TUrlMapping.php
+++ b/framework/Web/TUrlMapping.php
@@ -6,7 +6,7 @@
* @link http://www.pradosoft.com/
* @copyright Copyright &copy; 2005-2013 PradoSoft
* @license http://www.pradosoft.com/license/
- * @version $Id$
+ * @version $Id: TUrlMapping.php 3245 2013-01-07 20:23:32Z ctrlaltca $
* @package System.Web
*/
@@ -63,7 +63,7 @@ Prado::using('System.Collections.TAttributeCollection');
* in the GET variables.
*
* @author Wei Zhuo <weizhuo[at]gmail[dot]com>
- * @version $Id$
+ * @version $Id: TUrlMapping.php 3245 2013-01-07 20:23:32Z ctrlaltca $
* @package System.Web
* @since 3.0.5
*/
@@ -450,7 +450,7 @@ class TUrlMapping extends TUrlManager
*
* <url ServiceParameter="adminpages.*" pattern="admin/{*}/{id}" parameters.id="\d+" />
*
- * To enable automatic parameter encoding in a path format from wildcard patterns you can set
+ * To enable automatic parameter encoding in a path format fro wildcard patterns you can set
* {@setUrlFormat UrlFormat} to 'Path':
*
* <url ServiceParameter="adminpages.*" pattern="admin/{*}" UrlFormat="Path" />
@@ -465,19 +465,8 @@ class TUrlMapping extends TUrlManager
*
* <tt>.../index.php/admin/listuser/param1-value1/param2-value2</tt>.
*
- * Since 3.2.2 you can also add a list of "constants" parameters that can be used just
- * like the original "parameters" parameters, except that the supplied value will be treated
- * as a simple string constant instead of a regular expression. For example
- *
- * <url ServiceParameter="MyPage" pattern="/mypage/mypath/list/detail/{pageidx}" parameters.pageidx="\d+" constants.listtype="detailed"/>
- * <url ServiceParameter="MyPage" pattern="/mypage/mypath/list/summary/{pageidx}" parameters.pageidx="\d+" constants.listtype="summarized"/>
- *
- * These rules, when matched by the actual request, will make the application see a "lisstype" parameter present
- * (even through not supplied in the request) and equal to "detailed" or "summarized", depending on the friendly url matched.
- * The constants is practically a table-based validation and translation of specified, fixed-set parameter values.
- *
* @author Wei Zhuo <weizhuo[at]gmail[dot]com>
- * @version $Id$
+ * @version $Id: TUrlMapping.php 3245 2013-01-07 20:23:32Z ctrlaltca $
* @package System.Web
* @since 3.0.5
*/
@@ -496,14 +485,10 @@ class TUrlMappingPattern extends TComponent
*/
private $_pattern;
/**
- * @var TAttributeCollection parameter regular expressions.
+ * @var TMap parameter regular expressions.
*/
private $_parameters;
/**
- * @var TAttributeCollection of constant parameters.
- */
- protected $_constants;
- /**
* @var string regular expression pattern.
*/
private $_regexp='';
@@ -533,6 +518,8 @@ class TUrlMappingPattern extends TComponent
public function __construct(TUrlManager $manager)
{
$this->_manager=$manager;
+ $this->_parameters=new TAttributeCollection;
+ $this->_parameters->setCaseSensitive(true);
}
/**
@@ -565,16 +552,12 @@ class TUrlMappingPattern extends TComponent
{
$params=array();
$values=array();
- if ($this->_parameters)
+ foreach($this->_parameters as $key=>$value)
{
- foreach($this->_parameters as $key=>$value)
- {
- $params[]='{'.$key.'}';
- $values[]='(?P<'.$key.'>'.$value.')';
- }
+ $params[]='{'.$key.'}';
+ $values[]='(?P<'.$key.'>'.$value.')';
}
- if ($this->getIsWildCardPattern())
- {
+ if ($this->getIsWildCardPattern()) {
$params[]='{*}';
// service parameter must not contain '=' and '/'
$values[]='(?P<'.$this->getServiceID().'>[^=/]+)';
@@ -677,11 +660,6 @@ class TUrlMappingPattern extends TComponent
*/
public function getParameters()
{
- if (!$this->_parameters)
- {
- $this->_parameters=new TAttributeCollection;
- $this->_parameters->setCaseSensitive(true);
- }
return $this->_parameters;
}
@@ -694,20 +672,6 @@ class TUrlMappingPattern extends TComponent
}
/**
- * @return TAttributeCollection constanst parameter key value pairs.
- * @since 3.2.2
- */
- public function getConstants()
- {
- if (!$this->_constants)
- {
- $this->_constants = new TAttributeCollection;
- $this->_constants->setCaseSensitive(true);
- }
- return $this->_constants;
- }
-
- /**
* Uses URL pattern (or full regular expression if available) to
* match the given url path.
* @param THttpRequest the request module
@@ -744,12 +708,6 @@ class TUrlMappingPattern extends TComponent
unset($matches['urlparams']);
}
- if(count($matches) > 0 && $this->_constants)
- {
- foreach($this->_constants->toArray() as $key=>$value)
- $matches[$key] = $value;
- }
-
return $matches;
}
@@ -797,7 +755,7 @@ class TUrlMappingPattern extends TComponent
* Changing the UrlFormat will affect {@link constructUrl} and how GET variables
* are parsed.
* @param THttpRequestUrlFormat the format of URLs.
- * @since 3.1.4
+ * @param since 3.1.4
*/
public function setUrlFormat($value)
{
@@ -851,24 +809,10 @@ class TUrlMappingPattern extends TComponent
{
if(!$this->_customUrl || $this->getPattern()===null)
return false;
- if ($this->_parameters)
- {
- foreach($this->_parameters as $key=>$value)
- {
- if(!isset($getItems[$key]))
- return false;
- }
- }
-
- if ($this->_constants)
+ foreach($this->_parameters as $key=>$value)
{
- foreach($this->_constants->toArray() as $key=>$value)
- {
- if (!isset($getItems[$key]))
- return false;
- if ($getItems[$key]!=$value)
- return false;
- }
+ if(!isset($getItems[$key]))
+ return false;
}
return true;
}
@@ -883,20 +827,12 @@ class TUrlMappingPattern extends TComponent
*/
public function constructUrl($getItems,$encodeAmpersand,$encodeGetItems)
{
- if ($this->_constants)
- {
- foreach($this->_constants->toArray() as $key=>$value)
- {
- unset($getItems[$key]);
- }
- }
-
$extra=array();
$replace=array();
// for the GET variables matching the pattern, put them in the URL path
foreach($getItems as $key=>$value)
{
- if($this->_parameters && ($this->_parameters->contains($key) || $key==='*' && $this->getIsWildCardPattern()))
+ if($this->_parameters->contains($key) || $key==='*' && $this->getIsWildCardPattern())
$replace['{'.$key.'}']=$encodeGetItems ? rawurlencode($value) : $value;
else
$extra[$key]=$value;
@@ -994,7 +930,7 @@ class TUrlMappingPattern extends TComponent
* URL prefix behavior that can be used by {@link TUrlMappingPattern::constructUrl()}.
*
* @author Yves Berkholz <godzilla80[at]gmx[dot]net>
- * @version $Id$
+ * @version $Id: TUrlMapping.php 3245 2013-01-07 20:23:32Z ctrlaltca $
* @package System.Web
* @since 3.2
*/