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 --- framework/Web/UI/TTemplateManager.php | 47 +++++++++++++++++++++++++++-------- 1 file changed, 37 insertions(+), 10 deletions(-) (limited to 'framework') 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,'