From 2d6584b56f0c52686f868c4c7dafc44db0f7c5cf Mon Sep 17 00:00:00 2001 From: xue <> Date: Mon, 16 Jan 2006 01:50:52 +0000 Subject: Fixed an issue with dynamic property tags used with prop:xxx. --- demos/quickstart/protected/pages/Configurations/Templates1.page | 2 +- demos/quickstart/protected/pages/Configurations/Templates3.page | 2 +- framework/Web/UI/TTemplateManager.php | 9 +++++---- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/demos/quickstart/protected/pages/Configurations/Templates1.page b/demos/quickstart/protected/pages/Configurations/Templates1.page index f6b7dd16..ce539281 100644 --- a/demos/quickstart/protected/pages/Configurations/Templates1.page +++ b/demos/quickstart/protected/pages/Configurations/Templates1.page @@ -33,7 +33,7 @@ To deal conveniently with properties taking take big trunk of initial data, the PropertyValue </prop:PropertyName> -It is equivalent to ...PropertyName="PropertyValue"... in a component tag except that the latter may accept dynamic property tags. Property initialization tags must be directly enclosed between the corresponding opening and closing component tag. +It is equivalent to ...PropertyName="PropertyValue"... in every aspect. Property initialization tags must be directly enclosed between the corresponding opening and closing component tag.

diff --git a/demos/quickstart/protected/pages/Configurations/Templates3.page b/demos/quickstart/protected/pages/Configurations/Templates3.page index ae496553..e5abc347 100644 --- a/demos/quickstart/protected/pages/Configurations/Templates3.page +++ b/demos/quickstart/protected/pages/Configurations/Templates3.page @@ -35,7 +35,7 @@ Note, unlike dynamic content tags, the expressions tags for component properties

Databind Tags

-Databind tags are similar to expression tags, except that the expressions are evaluated only when a dataBind() call is invoked on the controls represented by the component tags. In the expression, $this refers to the control itself. Databind tags do not apply to all components. They can only be used for controls. +Databind tags are similar to expression tags, except that they can only be used with control properties and the expressions are evaluated only when a dataBind() call is invoked on the controls represented by the component tags. In the expression, $this refers to the control itself. Databind tags do not apply to all components. They can only be used for controls.

The format of databind tags is as follows, diff --git a/framework/Web/UI/TTemplateManager.php b/framework/Web/UI/TTemplateManager.php index d039288e..5d17a6fe 100644 --- a/framework/Web/UI/TTemplateManager.php +++ b/framework/Web/UI/TTemplateManager.php @@ -608,8 +608,7 @@ class TTemplate extends TComponent implements ITemplate if($matchStart>$textStart && $container>=0) { $value=substr($input,$textStart,$matchStart-$textStart); - //$tpl[$container][2][$prop]=$this->parseAttribute($value); - $tpl[$container][2][$prop]=$value; + $tpl[$container][2][$prop]=$this->parseAttribute($value); $textStart=$matchEnd+1; } $expectPropEnd=false; @@ -685,9 +684,11 @@ class TTemplate extends TComponent implements ITemplate protected function parseAttribute($value) { - if(!preg_match('/(<%#.*?%>|<%=.*?%>|<%~.*?%>|<%\\$.*?%>)/msS',$value)) + $matches=array(); + if(!preg_match('/^\s*(<%#.*?%>|<%=.*?%>|<%~.*?%>|<%\\$.*?%>)\s*$/msS',$value,$matches)) return $value; - else if($value[2]==='#') // databind + $value=$matches[1]; + if($value[2]==='#') // databind return array(self::CONFIG_DATABIND,substr($value,3,strlen($value)-5)); else if($value[2]==='=') // a dynamic initialization return array(self::CONFIG_EXPRESSION,substr($value,3,strlen($value)-5)); -- cgit v1.2.3