From 46155621cbf97191fca495cbd09a2eedd82afa82 Mon Sep 17 00:00:00 2001 From: xue <> Date: Fri, 5 May 2006 16:17:25 +0000 Subject: added support to configure subproperties in a group --- HISTORY | 1 + .../pages/Controls/Samples/TWizard/Sample2.page | 33 +++++++++------ framework/Web/UI/TTemplateManager.php | 47 +++++++++++++++++----- 3 files changed, 58 insertions(+), 23 deletions(-) diff --git a/HISTORY b/HISTORY index b35cb588..d048d35b 100644 --- a/HISTORY +++ b/HISTORY @@ -1,5 +1,6 @@ Version 3.1.0 To be released ============================ +ENH: Ticket#117 - added support to configure subproperties in a group. (Qiang) NEW: TOutputCache (Qiang) NEW: TQueue (Qiang) NEW: TSessionPageStatePersister (Qiang) diff --git a/demos/quickstart/protected/pages/Controls/Samples/TWizard/Sample2.page b/demos/quickstart/protected/pages/Controls/Samples/TWizard/Sample2.page index 2ac672d8..17a0cd72 100644 --- a/demos/quickstart/protected/pages/Controls/Samples/TWizard/Sample2.page +++ b/demos/quickstart/protected/pages/Controls/Samples/TWizard/Sample2.page @@ -10,24 +10,31 @@ BorderWidth="1px" BorderStyle="Solid" HeaderText="Please let us know your preference" - SideBarStyle.Width="100px" - SideBarStyle.Height="100px" - SideBarStyle.BackColor="#507CD1" - SideBarStyle.HorizontalAlign="Center" StepStyle.HorizontalAlign="Center" NavigationStyle.HorizontalAlign="Center" - NavigationButtonStyle.BackColor="White" - NavigationButtonStyle.BorderColor="#507CD1" - NavigationButtonStyle.BorderStyle="Solid" - NavigationButtonStyle.BorderWidth="1px" - NavigationButtonStyle.ForeColor="#284E98" SideBarButtonStyle.ForeColor="White" - HeaderStyle.BackColor="#284E98" - HeaderStyle.Font.Bold="True" - HeaderStyle.ForeColor="White" - HeaderStyle.HorizontalAlign="Center" OnCompleteButtonClick="wizardCompleted" > + + + +

Your favorite color: diff --git a/framework/Web/UI/TTemplateManager.php b/framework/Web/UI/TTemplateManager.php index 6e12726a..d2a92c04 100644 --- a/framework/Web/UI/TTemplateManager.php +++ b/framework/Web/UI/TTemplateManager.php @@ -127,14 +127,16 @@ class TTemplateManager extends TModule * are treated as either property initial values, event handler attachment, or regular * tag attributes. * - property tags: property tags are used to set large block of attribute values. - * The property tag name is in the format of prop:AttributeName, where AttributeName + * The property tag name is in the format of where AttributeName * can be a property name, an event name or a regular tag attribute name. + * - group subproperty tags: subproperties of a common property can be configured using + * * - directive: directive specifies the property values for the template owner. - * It is in the format of <% property name-value pairs %> - * - expressions: They are in the formate of <= PHP expression > and <% PHP statements > + * It is in the format of <%@ property name-value pairs %>; + * - expressions: They are in the formate of <%= PHP expression %> and <%% PHP statements %> * - comments: There are two kinds of comments, regular HTML comments and special template comments. - * The former is in the format of <!-- comments -->, which will be treated as text strings. - * The latter is in the format of <%* comments %>, which will be stripped out. + * The former is in the format of , which will be treated as text strings. + * The latter is in the format of , which will be stripped out. * * Tags other than the above are not required to be well-formed. * @@ -157,8 +159,9 @@ class TTemplate extends TApplicationComponent implements ITemplate * '<\/?prop:([\w\.]+)\s*>' - property tags * '<%@\s*((?:\s*[\w\.]+=\'.*?\'|\s*[\w\.]+=".*?")*)\s*%>' - directives * '<%[%#~\\$=\\[](.*?)%>' - expressions + * ')*)\s*\/>' - group subproperty tags */ - const REGEX_RULES='/||<\/?com:([\w\.]+)((?:\s*[\w\.]+=\'.*?\'|\s*[\w\.]+=".*?"|\s*[\w\.]+=<%.*?%>)*)\s*\/?>|<\/?prop:([\w\.]+)\s*>|<%@\s*((?:\s*[\w\.]+=\'.*?\'|\s*[\w\.]+=".*?")*)\s*%>|<%[%#~\\$=\\[](.*?)%>/msS'; + const REGEX_RULES='/||<\/?com:([\w\.]+)((?:\s*[\w\.]+=\'.*?\'|\s*[\w\.]+=".*?"|\s*[\w\.]+=<%.*?%>)*)\s*\/?>|<\/?prop:([\w\.]+)\s*>|<%@\s*((?:\s*[\w\.]+=\'.*?\'|\s*[\w\.]+=".*?")*)\s*%>|<%[%#~\\$=\\[](.*?)%>|)*)\s*\/>/msS'; /** * Different configurations of component property/event/attribute @@ -625,14 +628,38 @@ class TTemplate extends TApplicationComponent implements ITemplate } else if(strpos($str,'')===strlen($str)-2) //subproperties { + if($expectPropEnd) + continue; if($matchStart>$textStart) $tpl[$c++]=array($container,substr($input,$textStart,$matchStart-$textStart)); $textStart=$matchEnd+1; - $expectPropEnd=true; + $prop=strtolower($match[6][0]); + $attrs=$this->parseAttributes($match[7][0],$match[7][1]); + $attributes=array(); + foreach($attrs as $name=>$value) + $attributes[$prop.'.'.$name]=$value; + $type=$tpl[$container][1]; + $this->validateAttributes($type,$attributes); + foreach($attributes as $name=>$value) + { + if(isset($tpl[$container][2][$name])) + throw new TConfigurationException('template_property_duplicated',$name); + $tpl[$container][2][$name]=$value; + } + } + else // regular property + { + $prop=strtolower($match[3][0]); + array_push($stack,'@'.$prop); + if(!$expectPropEnd) + { + if($matchStart>$textStart) + $tpl[$c++]=array($container,substr($input,$textStart,$matchStart-$textStart)); + $textStart=$matchEnd+1; + $expectPropEnd=true; + } } } else if(strpos($str,'