diff options
Diffstat (limited to 'framework/Web')
-rw-r--r-- | framework/Web/Javascripts/source/prado/activecontrols/activecontrols3.js | 1 | ||||
-rw-r--r-- | framework/Web/TUrlMapping.php | 282 | ||||
-rw-r--r-- | framework/Web/UI/ActiveControls/TCallbackClientScript.php | 3 | ||||
-rw-r--r-- | framework/Web/UI/TTemplateManager.php | 12 | ||||
-rw-r--r-- | framework/Web/UI/WebControls/TBoundColumn.php | 16 | ||||
-rw-r--r-- | framework/Web/UI/WebControls/TDatePicker.php | 4 | ||||
-rw-r--r-- | framework/Web/UI/WebControls/TListControl.php | 151 |
7 files changed, 172 insertions, 297 deletions
diff --git a/framework/Web/Javascripts/source/prado/activecontrols/activecontrols3.js b/framework/Web/Javascripts/source/prado/activecontrols/activecontrols3.js index 56395d44..97bd4e07 100644 --- a/framework/Web/Javascripts/source/prado/activecontrols/activecontrols3.js +++ b/framework/Web/Javascripts/source/prado/activecontrols/activecontrols3.js @@ -188,7 +188,6 @@ Prado.WebUI.TTimeTriggeredCallback = Base.extend( startTimer : function()
{
- setTimeout(this.onTimerEvent.bind(this), 100);
if(typeof(this.timer) == 'undefined' || this.timer == null)
this.timer = setInterval(this.onTimerEvent.bind(this),this.options.Interval*1000);
},
diff --git a/framework/Web/TUrlMapping.php b/framework/Web/TUrlMapping.php index 47232401..b95779fe 100644 --- a/framework/Web/TUrlMapping.php +++ b/framework/Web/TUrlMapping.php @@ -4,7 +4,7 @@ *
* @author Wei Zhuo <weizhuo[at]gamil[dot]com>
* @link http://www.pradosoft.com/
- * @copyright Copyright © 2005-2008 PradoSoft + * @copyright Copyright © 2005-2008 PradoSoft
* @license http://www.pradosoft.com/license/
* @version $Id$
* @package System.Web
@@ -264,7 +264,7 @@ class TUrlMapping extends TUrlManager if(is_string($key))
$params[$key]=$value;
}
- if (!$pattern->getIsWildCardPattern()) + if (!$pattern->getIsWildCardPattern())
$params[$pattern->getServiceID()]=$pattern->getServiceParameter();
return $params;
}
@@ -300,8 +300,8 @@ class TUrlMapping extends TUrlManager if(!(is_array($getItems) || ($getItems instanceof Traversable)))
$getItems=array();
$key=$serviceID.':'.$serviceParam;
- $wildCardKey = ($pos=strrpos($serviceParam,'.'))!==false ? - $serviceID.':'.substr($serviceParam,0,$pos).'.*' : $serviceID.':*'; + $wildCardKey = ($pos=strrpos($serviceParam,'.'))!==false ?
+ $serviceID.':'.substr($serviceParam,0,$pos).'.*' : $serviceID.':*';
if(isset($this->_constructRules[$key]))
{
foreach($this->_constructRules[$key] as $rule)
@@ -309,16 +309,16 @@ class TUrlMapping extends TUrlManager if($rule->supportCustomUrl($getItems))
return $rule->constructUrl($getItems,$encodeAmpersand,$encodeGetItems);
}
- } - elseif(isset($this->_constructRules[$wildCardKey])) - { + }
+ elseif(isset($this->_constructRules[$wildCardKey]))
+ {
foreach($this->_constructRules[$wildCardKey] as $rule)
{
if($rule->supportCustomUrl($getItems))
- { - $getItems['*']= $pos ? substr($serviceParam,$pos+1) : $serviceParam; + {
+ $getItems['*']= $pos ? substr($serviceParam,$pos+1) : $serviceParam;
return $rule->constructUrl($getItems,$encodeAmpersand,$encodeGetItems);
- } + }
}
}
}
@@ -380,42 +380,42 @@ class TUrlMapping extends TUrlManager * The {@link setServiceParameter ServiceParameter} and {@link setServiceID ServiceID}
* (the default ID is 'page') set the service parameter and service id respectively.
*
- * Since 3.1.4 you can also use simplyfied wildcard patterns to match multiple - * ServiceParameters with a single rule. The pattern must contain the placeholder - * {*} for the ServiceParameter. For example - * - * <url ServiceParameter="adminpages.*" pattern="admin/{*}" /> - * - * This rule will match an URL like <tt>http://example.com/index.php/admin/edituser</tt> - * and resolve it to the page Application.pages.admin.edituser. The wildcard matching - * is non-recursive. That means you have to add a rule for every subdirectory you - * want to access pages in: - * - * <url ServiceParameter="adminpages.users.*" pattern="useradmin/{*}" /> - * - * It is still possible to define an explicit rule for a page in the wildcard path. - * This rule has to preceed the wildcard rule. - * - * You can also use parameters with wildcard patterns. The parameters are then - * available with every matching page: - * - * <url ServiceParameter="adminpages.*" pattern="admin/{*}/{id}" parameters.id="\d+" /> - * - * 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" /> - * - * This will create and parse URLs of the form - * <tt>.../index.php/admin/listuser/param1/value1/param2/value2</tt>. - * - * Use {@setUrlParamSeparator} to define another separator character between parameter - * name and value. Parameter/value pairs are always separated by a '/'. - * - * <url ServiceParameter="adminpages.*" pattern="admin/{*}" UrlFormat="Path" UrlParamSeparator="-" /> - * - * <tt>.../index.php/admin/listuser/param1-value1/param2-value2</tt>. - * + * Since 3.1.4 you can also use simplyfied wildcard patterns to match multiple
+ * ServiceParameters with a single rule. The pattern must contain the placeholder
+ * {*} for the ServiceParameter. For example
+ *
+ * <url ServiceParameter="adminpages.*" pattern="admin/{*}" />
+ *
+ * This rule will match an URL like <tt>http://example.com/index.php/admin/edituser</tt>
+ * and resolve it to the page Application.pages.admin.edituser. The wildcard matching
+ * is non-recursive. That means you have to add a rule for every subdirectory you
+ * want to access pages in:
+ *
+ * <url ServiceParameter="adminpages.users.*" pattern="useradmin/{*}" />
+ *
+ * It is still possible to define an explicit rule for a page in the wildcard path.
+ * This rule has to preceed the wildcard rule.
+ *
+ * You can also use parameters with wildcard patterns. The parameters are then
+ * available with every matching page:
+ *
+ * <url ServiceParameter="adminpages.*" pattern="admin/{*}/{id}" parameters.id="\d+" />
+ *
+ * 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" />
+ *
+ * This will create and parse URLs of the form
+ * <tt>.../index.php/admin/listuser/param1/value1/param2/value2</tt>.
+ *
+ * Use {@setUrlParamSeparator} to define another separator character between parameter
+ * name and value. Parameter/value pairs are always separated by a '/'.
+ *
+ * <url ServiceParameter="adminpages.*" pattern="admin/{*}" UrlFormat="Path" UrlParamSeparator="-" />
+ *
+ * <tt>.../index.php/admin/listuser/param1-value1/param2-value2</tt>.
+ *
* @author Wei Zhuo <weizhuo[at]gmail[dot]com>
* @version $Id$
* @package System.Web
@@ -449,12 +449,12 @@ class TUrlMappingPattern extends TComponent private $_manager;
private $_caseSensitive=true;
- - private $_isWildCardPattern=false; - - private $_urlFormat=THttpRequestUrlFormat::Get; - - private $_separator='/'; +
+ private $_isWildCardPattern=false;
+
+ private $_urlFormat=THttpRequestUrlFormat::Get;
+
+ private $_separator='/';
/**
* Constructor.
@@ -484,8 +484,8 @@ class TUrlMappingPattern extends TComponent {
if($this->_serviceParameter===null)
throw new TConfigurationException('urlmappingpattern_serviceparameter_required', $this->getPattern());
- if(strpos($this->_serviceParameter,'*')!==false) - $this->_isWildCardPattern=true; + if(strpos($this->_serviceParameter,'*')!==false)
+ $this->_isWildCardPattern=true;
}
/**
@@ -502,19 +502,19 @@ class TUrlMappingPattern extends TComponent $params[]='{'.$key.'}';
$values[]='(?P<'.$key.'>'.$value.')';
}
- if ($this->getIsWildCardPattern()) { - $params[]='{*}'; - // service parameter must not contain '=' and '/' - $values[]='(?P<'.$this->getServiceID().'>[^=/]+)'; - } + if ($this->getIsWildCardPattern()) {
+ $params[]='{*}';
+ // service parameter must not contain '=' and '/'
+ $values[]='(?P<'.$this->getServiceID().'>[^=/]+)';
+ }
$params[]='/';
$values[]='\\/';
$regexp=str_replace($params,$values,trim($this->getPattern(),'/').'/');
- if ($this->_urlFormat===THttpRequestUrlFormat::Get) + if ($this->_urlFormat===THttpRequestUrlFormat::Get)
$regexp='/^'.$regexp.'$/u';
- else + else
$regexp='/^'.$regexp.'(?P<urlparams>.*)$/u';
- +
if(!$this->getCaseSensitive())
$regexp.='i';
return $regexp;
@@ -629,30 +629,30 @@ class TUrlMappingPattern extends TComponent preg_match($pattern,$request->getPathInfo(),$matches);
else
preg_match($this->getParameterizedPattern(),trim($request->getPathInfo(),'/').'/',$matches);
- - if($this->getIsWildCardPattern() && isset($matches[$this->_serviceID])) - $matches[$this->_serviceID]=str_replace('*',$matches[$this->_serviceID],$this->_serviceParameter); - - if (isset($matches['urlparams'])) - { - $params=explode('/',$matches['urlparams']); - if ($this->_separator==='/') - { - while($key=array_shift($params)) - $matches2[$key]=($value=array_shift($params)) ? $value : ''; - } - else - { - array_pop($params); - foreach($params as $param) - { - list($key,$value)=explode($this->_separator,$param,2); - $matches[$key]=$value; - } - } - unset($matches['urlparams']); - } - +
+ if($this->getIsWildCardPattern() && isset($matches[$this->_serviceID]))
+ $matches[$this->_serviceID]=str_replace('*',$matches[$this->_serviceID],$this->_serviceParameter);
+
+ if (isset($matches['urlparams']))
+ {
+ $params=explode('/',$matches['urlparams']);
+ if ($this->_separator==='/')
+ {
+ while($key=array_shift($params))
+ $matches[$key]=($value=array_shift($params)) ? $value : '';
+ }
+ else
+ {
+ array_pop($params);
+ foreach($params as $param)
+ {
+ list($key,$value)=explode($this->_separator,$param,2);
+ $matches[$key]=$value;
+ }
+ }
+ unset($matches['urlparams']);
+ }
+
return $matches;
}
@@ -676,57 +676,57 @@ class TUrlMappingPattern extends TComponent }
/**
- * @return boolean whether this pattern is a wildcard pattern + * @return boolean whether this pattern is a wildcard pattern
* @since 3.1.4
*/
- public function getIsWildCardPattern() { - return $this->_isWildCardPattern; - } - - /** - * @return THttpRequestUrlFormat the format of URLs. Defaults to THttpRequestUrlFormat::Get. - */ - public function getUrlFormat() - { - return $this->_urlFormat; - } - - /** - * Sets the format of URLs constructed and interpreted by this pattern. - * A Get URL format is like index.php?name1=value1&name2=value2 - * while a Path URL format is like index.php/name1/value1/name2/value. - * The separating character between name and value can be configured with - * {@link setUrlParamSeparator} and defaults to '/'. - * Changing the UrlFormat will affect {@link constructUrl} and how GET variables - * are parsed. - * @param THttpRequestUrlFormat the format of URLs. - * @param since 3.1.4 - */ - public function setUrlFormat($value) - { - $this->_urlFormat=TPropertyValue::ensureEnum($value,'THttpRequestUrlFormat'); - } - - /** - * @return string separator used to separate GET variable name and value when URL format is Path. Defaults to slash '/'. - */ - public function getUrlParamSeparator() - { - return $this->_separator; - } - - /** - * @param string separator used to separate GET variable name and value when URL format is Path. - * @throws TInvalidDataValueException if the separator is not a single character - */ - public function setUrlParamSeparator($value) - { - if(strlen($value)===1) - $this->_separator=$value; - else - throw new TInvalidDataValueException('httprequest_separator_invalid'); - } - + public function getIsWildCardPattern() {
+ return $this->_isWildCardPattern;
+ }
+
+ /**
+ * @return THttpRequestUrlFormat the format of URLs. Defaults to THttpRequestUrlFormat::Get.
+ */
+ public function getUrlFormat()
+ {
+ return $this->_urlFormat;
+ }
+
+ /**
+ * Sets the format of URLs constructed and interpreted by this pattern.
+ * A Get URL format is like index.php?name1=value1&name2=value2
+ * while a Path URL format is like index.php/name1/value1/name2/value.
+ * The separating character between name and value can be configured with
+ * {@link setUrlParamSeparator} and defaults to '/'.
+ * Changing the UrlFormat will affect {@link constructUrl} and how GET variables
+ * are parsed.
+ * @param THttpRequestUrlFormat the format of URLs.
+ * @param since 3.1.4
+ */
+ public function setUrlFormat($value)
+ {
+ $this->_urlFormat=TPropertyValue::ensureEnum($value,'THttpRequestUrlFormat');
+ }
+
+ /**
+ * @return string separator used to separate GET variable name and value when URL format is Path. Defaults to slash '/'.
+ */
+ public function getUrlParamSeparator()
+ {
+ return $this->_separator;
+ }
+
+ /**
+ * @param string separator used to separate GET variable name and value when URL format is Path.
+ * @throws TInvalidDataValueException if the separator is not a single character
+ */
+ public function setUrlParamSeparator($value)
+ {
+ if(strlen($value)===1)
+ $this->_separator=$value;
+ else
+ throw new TInvalidDataValueException('httprequest_separator_invalid');
+ }
+
/**
* @param array list of GET items to be put in the constructed URL
* @return boolean whether this pattern IS the one for constructing the URL with the specified GET items.
@@ -770,12 +770,12 @@ class TUrlMappingPattern extends TComponent // for the rest of the GET variables, put them in the query string
if(count($extra)>0)
{
- if ($this->_urlFormat===THttpRequestUrlFormat::Path && $this->getIsWildCardPattern()) { - foreach ($extra as $name=>$value) - $url.='/'.$name.$this->_separator.($encodeGetItems?rawurlencode($value):$value); - return $url; - } - + if ($this->_urlFormat===THttpRequestUrlFormat::Path && $this->getIsWildCardPattern()) {
+ foreach ($extra as $name=>$value)
+ $url.='/'.$name.$this->_separator.($encodeGetItems?rawurlencode($value):$value);
+ return $url;
+ }
+
$url2='';
$amp=$encodeAmpersand?'&':'&';
if($encodeGetItems)
diff --git a/framework/Web/UI/ActiveControls/TCallbackClientScript.php b/framework/Web/UI/ActiveControls/TCallbackClientScript.php index 8fbdd864..d35e89a0 100644 --- a/framework/Web/UI/ActiveControls/TCallbackClientScript.php +++ b/framework/Web/UI/ActiveControls/TCallbackClientScript.php @@ -164,7 +164,8 @@ class TCallbackClientScript extends TApplicationComponent */
public function setAttribute($control, $name, $value)
{
- if ($control instanceof ISurroundable)
+ // Attributes should be applied on Surrounding tag, except for 'disabled' attribute
+ if ($control instanceof ISurroundable && strtolower($name)!=='disabled')
$control=$control->getSurroundingTagID();
$this->callClientFunction('Prado.Element.setAttribute',array($control, $name, $value));
}
diff --git a/framework/Web/UI/TTemplateManager.php b/framework/Web/UI/TTemplateManager.php index 6d44d7d7..af88620c 100644 --- a/framework/Web/UI/TTemplateManager.php +++ b/framework/Web/UI/TTemplateManager.php @@ -890,15 +890,19 @@ class TTemplate extends TApplicationComponent implements ITemplate else
return array(self::CONFIG_EXPRESSION,ltrim($expr,'.'));
}
- else if(preg_match('/\\s*(<%~.*?%>|<%\\$.*?%>|<%\\[.*?\\]%>)\\s*/msS',$value,$matches) && $matches[0]===$value)
+ else if(preg_match('/\\s*(<%~.*?%>|<%\\$.*?%>|<%\\[.*?\\]%>|<%\/.*?%>)\\s*/msS',$value,$matches) && $matches[0]===$value)
{
$value=$matches[1];
- if($value[2]==='~') // a URL
+ if($value[2]==='~')
return array(self::CONFIG_ASSET,trim(substr($value,3,strlen($value)-5)));
- else if($value[2]==='[')
+ elseif($value[2]==='[')
return array(self::CONFIG_LOCALIZATION,trim(substr($value,3,strlen($value)-6)));
- else if($value[2]==='$')
+ elseif($value[2]==='$')
return array(self::CONFIG_PARAMETER,trim(substr($value,3,strlen($value)-5)));
+ elseif($value[2]==='/') {
+ $literal = trim(substr($value,3,strlen($value)-5));
+ return array(self::CONFIG_EXPRESSION,"dirname(\$this->getApplication()->getRequest()->getApplicationUrl()).'/$literal'");
+ }
}
else
return $value;
diff --git a/framework/Web/UI/WebControls/TBoundColumn.php b/framework/Web/UI/WebControls/TBoundColumn.php index fdcde9b2..098ffeef 100644 --- a/framework/Web/UI/WebControls/TBoundColumn.php +++ b/framework/Web/UI/WebControls/TBoundColumn.php @@ -197,6 +197,7 @@ class TBoundColumn extends TDataGridColumn $control->setItemType($item->getItemType());
}
$cell->getControls()->add($control);
+ $cell->registerObject('EditControl',$control);
}
else
{
@@ -206,7 +207,20 @@ class TBoundColumn extends TDataGridColumn }
}
else
- $control=$cell;
+ {
+ if(($classPath=$this->getItemRenderer())!=='')
+ {
+ $control=Prado::createComponent($classPath);
+ if($control instanceof IItemDataRenderer)
+ {
+ $control->setItemIndex($item->getItemIndex());
+ $control->setItemType($item->getItemType());
+ }
+ $cell->getControls()->add($control);
+ }
+ else
+ $control=$cell;
+ }
$control->attachEventHandler('OnDataBinding',array($this,'dataBindColumn'));
break;
default:
diff --git a/framework/Web/UI/WebControls/TDatePicker.php b/framework/Web/UI/WebControls/TDatePicker.php index e678b046..c81d8bc1 100644 --- a/framework/Web/UI/WebControls/TDatePicker.php +++ b/framework/Web/UI/WebControls/TDatePicker.php @@ -487,7 +487,7 @@ class TDatePicker extends TTextBox if(isset($values[$key.'$day']))
$day = intval($values[$key.'$day']);
else
- $day = 1;
+ $day = $date['mday'];
if(isset($values[$key.'$month']))
$month = intval($values[$key.'$month']) + 1;
@@ -961,4 +961,4 @@ class TDatePickerPositionMode extends TEnumerable {
const Top='Top';
const Bottom='Bottom';
-}
\ No newline at end of file +}
diff --git a/framework/Web/UI/WebControls/TListControl.php b/framework/Web/UI/WebControls/TListControl.php index c69b387e..e0c25b9e 100644 --- a/framework/Web/UI/WebControls/TListControl.php +++ b/framework/Web/UI/WebControls/TListControl.php @@ -1,10 +1,12 @@ <?php
+
/**
* TListControl class file
*
+ * @author Robin J. Rogge <rojaro@gmail.com>
* @author Qiang Xue <qiang.xue@gmail.com>
* @link http://www.pradosoft.com/
- * @copyright Copyright © 2005-2008 PradoSoft
+ * @copyright Copyright © 2005-2010 PradoSoft
* @license http://www.pradosoft.com/license/
* @version $Id$
* @package System.Web.UI.WebControls
@@ -15,10 +17,10 @@ */
Prado::using('System.Web.UI.WebControls.TDataBoundControl');
Prado::using('System.Web.UI.WebControls.TListItem');
+Prado::using('System.Collections.TListItemCollection');
Prado::using('System.Collections.TAttributeCollection');
Prado::using('System.Util.TDataFieldAccessor');
-
/**
* TListControl class
*
@@ -879,151 +881,6 @@ abstract class TListControl extends TDataBoundControl implements IDataRenderer }
/**
- * TListItemCollection class.
- *
- * TListItemCollection maintains a list of {@link TListItem} for {@link TListControl}.
- *
- * @author Qiang Xue <qiang.xue@gmail.com>
- * @version $Id$
- * @package System.Web.UI.WebControls
- * @since 3.0
- */
-class TListItemCollection extends TList
-{
- /**
- * Creates a list item object.
- * This method may be overriden to provide a customized list item object.
- * @param integer index where the newly created item is to be inserted at.
- * If -1, the item will be appended to the end.
- * @return TListItem list item object
- */
- public function createListItem($index=-1)
- {
- $item=$this->createNewListItem();
- if($index<0)
- $this->add($item);
- else
- $this->insertAt($index,$item);
- return $item;
- }
-
- /**
- * @return TListItem new item.
- */
- protected function createNewListItem($text=null)
- {
- $item = new TListItem;
- if($text!==null)
- $item->setText($text);
- return $item;
- }
-
- /**
- * Inserts an item into the collection.
- * @param integer the location where the item will be inserted.
- * The current item at the place and the following ones will be moved backward.
- * @param TListItem the item to be inserted.
- * @throws TInvalidDataTypeException if the item being inserted is neither a string nor TListItem
- */
- public function insertAt($index,$item)
- {
- if(is_string($item))
- $item = $this->createNewListItem($item);
- if(!($item instanceof TListItem))
- throw new TInvalidDataTypeException('listitemcollection_item_invalid',get_class($this));
- parent::insertAt($index,$item);
- }
-
- /**
- * Finds the lowest cardinal index of the item whose value is the one being looked for.
- * @param string the value to be looked for
- * @param boolean whether to look for disabled items also
- * @return integer the index of the item found, -1 if not found.
- */
- public function findIndexByValue($value,$includeDisabled=true)
- {
- $value=TPropertyValue::ensureString($value);
- $index=0;
- foreach($this as $item)
- {
- if($item->getValue()===$value && ($includeDisabled || $item->getEnabled()))
- return $index;
- $index++;
- }
- return -1;
- }
-
- /**
- * Finds the lowest cardinal index of the item whose text is the one being looked for.
- * @param string the text to be looked for
- * @param boolean whether to look for disabled items also
- * @return integer the index of the item found, -1 if not found.
- */
- public function findIndexByText($text,$includeDisabled=true)
- {
- $text=TPropertyValue::ensureString($text);
- $index=0;
- foreach($this as $item)
- {
- if($item->getText()===$text && ($includeDisabled || $item->getEnabled()))
- return $index;
- $index++;
- }
- return -1;
- }
-
- /**
- * Finds the item whose value is the one being looked for.
- * @param string the value to be looked for
- * @param boolean whether to look for disabled items also
- * @return TListItem the item found, null if not found.
- */
- public function findItemByValue($value,$includeDisabled=true)
- {
- if(($index=$this->findIndexByValue($value,$includeDisabled))>=0)
- return $this->itemAt($index);
- else
- return null;
- }
-
- /**
- * Finds the item whose text is the one being looked for.
- * @param string the text to be looked for
- * @param boolean whether to look for disabled items also
- * @return TListItem the item found, null if not found.
- */
- public function findItemByText($text,$includeDisabled=true)
- {
- if(($index=$this->findIndexByText($text,$includeDisabled))>=0)
- return $this->itemAt($index);
- else
- return null;
- }
-
- /**
- * Loads state into every item in the collection.
- * This method should only be used by framework and control developers.
- * @param array|null state to be loaded.
- */
- public function loadState($state)
- {
- $this->clear();
- if($state!==null)
- $this->copyFrom($state);
- }
-
- /**
- * Saves state of items.
- * This method should only be used by framework and control developers.
- * @return array|null the saved state
- */
- public function saveState()
- {
- return ($this->getCount()>0) ? $this->toArray() : null;
- }
-}
-
-/**
* IListControlAdapter interface
*
* @author Wei Zhuo <weizhuo[at]gmail[dot]com>
|