summaryrefslogtreecommitdiff
path: root/framework/Web
diff options
context:
space:
mode:
authorxue <>2006-05-05 16:17:25 +0000
committerxue <>2006-05-05 16:17:25 +0000
commit46155621cbf97191fca495cbd09a2eedd82afa82 (patch)
tree7baf7672af301d8cb4c59f526c273537be0feb8c /framework/Web
parent94583ceb3e1d6bb2ab7a61c4907487a152fb4801 (diff)
added support to configure subproperties in a group
Diffstat (limited to 'framework/Web')
-rw-r--r--framework/Web/UI/TTemplateManager.php47
1 files changed, 37 insertions, 10 deletions
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 <prop:AttributeName> 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
+ * <prop:MainProperty SubProperty1="Value1" SubProperty2="Value2" .../>
* - directive: directive specifies the property values for the template owner.
- * It is in the format of &lt;% property name-value pairs %&gt;
- * - expressions: They are in the formate of &lt;= PHP expression &gt; and &lt;% PHP statements &gt;
+ * 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 &lt;!-- comments --&gt;, which will be treated as text strings.
- * The latter is in the format of &lt;%* comments %&gt;, which will be stripped out.
+ * 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.
*
* 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
+ * '<prop:([\w\.]+)((?:\s*[\w\.]+=\'.*?\'|\s*[\w\.]+=".*?"|\s*[\w\.]+=<%.*?%>)*)\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*%>|<%[%#~\\$=\\[](.*?)%>|<prop:([\w\.]+)((?:\s*[\w\.]+=\'.*?\'|\s*[\w\.]+=".*?"|\s*[\w\.]+=<%.*?%>)*)\s*\/>/msS';
/**
* Different configurations of component property/event/attribute
@@ -625,14 +628,38 @@ class TTemplate extends TApplicationComponent implements ITemplate
}
else if(strpos($str,'<prop:')===0) // opening property
{
- $prop=strtolower($match[3][0]);
- array_push($stack,'@'.$prop);
- if(!$expectPropEnd)
+ if(strrpos($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,'</prop:')===0) // closing property