From b07499534b6d0ed57a2b80c4d95354ca3791c236 Mon Sep 17 00:00:00 2001 From: xue <> Date: Sat, 15 Apr 2006 14:21:40 +0000 Subject: Breaking change! Changed context of the expressions in template to the template control. Evaluations of <%= %> are now all in PreRender stage. --- demos/composer/protected/pages/ClassDefinition.php | 15 +++++++-- demos/composer/protected/pages/Home.page | 38 +++++++++++----------- demos/personal/protected/Pages/Home.page | 2 ++ .../protected/pages/Configurations/Templates2.page | 2 +- .../protected/pages/Configurations/Templates3.page | 28 ++++++++++------ .../pages/Controls/Samples/TDataGrid/Sample3.page | 4 +-- .../pages/Controls/Samples/TDataList/Sample2.page | 10 +++--- .../pages/Controls/Samples/TRepeater/Sample3.page | 6 ++-- .../pages/Controls/Samples/TTextBox/Home.page | 2 +- 9 files changed, 63 insertions(+), 44 deletions(-) (limited to 'demos') diff --git a/demos/composer/protected/pages/ClassDefinition.php b/demos/composer/protected/pages/ClassDefinition.php index bd704b0e..cb657e85 100644 --- a/demos/composer/protected/pages/ClassDefinition.php +++ b/demos/composer/protected/pages/ClassDefinition.php @@ -36,8 +36,8 @@ class ClassDefinition extends TComponent if($this->Comments!=='') { $str.=" *\n"; - $str.=implode("\n * ",explode("\n",wordwrap($this->Comments))); - $str.=" *\n\n"; + $str.=" * ".implode("\n * ",explode("\n",wordwrap($this->Comments))); + $str.="\n *\n"; } if($this->Author!=='') { @@ -171,9 +171,18 @@ class ClassDefinition extends TComponent $name=$event->Name; if($name==='') continue; + if(strncasecmp($name,'on',2)!==0) + $name='On'.$name; + else + { + $name[0]='O'; + $name[1]='n'; + } + $methodName=$name; + $methodName[0]='o'; $comments=implode("\n\t * ",explode("\n",wordwrap($event->Comments))); $writer->write("\n\t/**\n\t * Raises $name event.\n\t * $comments\n\t * @param TEventParameter event parameter\n\t */\n"); - $writer->write("\tpublic function $name(\$param)\n\t{\n\t\t\$this->raiseEvent('$name',\$this,\$param);\n\t}\n"); + $writer->write("\tpublic function $methodName(\$param)\n\t{\n\t\t\$this->raiseEvent('$name',\$this,\$param);\n\t}\n"); } } diff --git a/demos/composer/protected/pages/Home.page b/demos/composer/protected/pages/Home.page index efdd1cda..51aaed8e 100644 --- a/demos/composer/protected/pages/Home.page +++ b/demos/composer/protected/pages/Home.page @@ -40,10 +40,10 @@ No properties defined.
- Parent->DataItem->Name %> CssClass="slTextBox"/> + DataItem->Name %> CssClass="slTextBox"/> - Parent->DataItem->Type %> > + DataItem->Type %> > @@ -53,41 +53,41 @@ No properties defined.
- Parent->DataItem->DefaultValue %> CssClass="slTextBox"/> + DataItem->DefaultValue %> CssClass="slTextBox"/> - Parent->DataItem->Storage %> > + DataItem->Storage %> > - Parent->DataItem->IsProtected %> /> - Parent->DataItem->ReadOnly %> /> + DataItem->IsProtected %> /> + DataItem->ReadOnly %> /> - Parent->DataItem->Comments %> CssClass="slTextBox"/> + DataItem->Comments %> CssClass="slTextBox"/> Parent->ItemIndex %> + CommandParameter=<%# $this->ItemIndex %> CssClass="button" /> Parent->ItemIndex %> - Enabled=<%# $this->Parent->ItemIndex > 0%> + CommandParameter=<%# $this->ItemIndex %> + Enabled=<%# $this->ItemIndex > 0%> CssClass="button" /> Parent->ItemIndex %> - Enabled=<%# $this->Parent->ItemIndex < $this->Page->ClassDefinition->Properties->Count-1 %> + CommandParameter=<%# $this->ItemIndex %> + Enabled=<%# $this->ItemIndex < $this->Page->ClassDefinition->Properties->Count-1 %> CssClass="button" /> @@ -123,30 +123,30 @@ No properties defined.
- Parent->DataItem->Name %> CssClass="slTextBox"/> + DataItem->Name %> CssClass="slTextBox"/> - Parent->DataItem->Comments %> CssClass="slTextBox"/> + DataItem->Comments %> CssClass="slTextBox"/> Parent->ItemIndex %> + CommandParameter=<%# $this->ItemIndex %> CssClass="button" /> Parent->ItemIndex %> - Enabled=<%# $this->Parent->ItemIndex > 0%> + CommandParameter=<%# $this->ItemIndex %> + Enabled=<%# $this->ItemIndex > 0%> CssClass="button" /> Parent->ItemIndex %> - Enabled=<%# $this->Parent->ItemIndex < $this->Page->ClassDefinition->Events->Count-1 %> + CommandParameter=<%# $this->ItemIndex %> + Enabled=<%# $this->ItemIndex < $this->Page->ClassDefinition->Events->Count-1 %> CssClass="button" /> diff --git a/demos/personal/protected/Pages/Home.page b/demos/personal/protected/Pages/Home.page index 204d4c6f..32a3b1b2 100644 --- a/demos/personal/protected/Pages/Home.page +++ b/demos/personal/protected/Pages/Home.page @@ -1,3 +1,5 @@ main content + +TextBox->Text %> /> \ No newline at end of file diff --git a/demos/quickstart/protected/pages/Configurations/Templates2.page b/demos/quickstart/protected/pages/Configurations/Templates2.page index 0971c828..9fc06fb4 100644 --- a/demos/quickstart/protected/pages/Configurations/Templates2.page +++ b/demos/quickstart/protected/pages/Configurations/Templates2.page @@ -10,7 +10,7 @@ Dynamic content tags are introduced as shortcuts to some commonly used

Expression Tags

-An expression tag represents a PHP expression that is evaluated when the template control is being rendered. The expression evaluation result is inserted at the place where the tag resides in the template. The context (namely $this) of the expression is the control owning the template. +An expression tag represents a PHP expression that is evaluated when the template control is in PreRender stage. The expression evaluation result is inserted at the place where the tag resides in the template. The context (namely $this) of the expression is the control owning the template.

The format of an expression tag is as follows, diff --git a/demos/quickstart/protected/pages/Configurations/Templates3.page b/demos/quickstart/protected/pages/Configurations/Templates3.page index d08f8736..b97b1583 100644 --- a/demos/quickstart/protected/pages/Configurations/Templates3.page +++ b/demos/quickstart/protected/pages/Configurations/Templates3.page @@ -5,11 +5,13 @@

Dynamic Property Tags

Dynamic property tags are very similar to dynamic content tags, except that they are applied to component properties. The purpose of dynamic property tags is to allow more versatile component property configuration. Note, you are not required to use dynamic property tags because what can be done using dynamic property tags can also be done in PHP code. However, using dynamic property tags bring you much more convenience at accomplishing the same tasks. The basic usage of dynamic property tags is as follows, +

<com:ComponentType PropertyName=DynamicPropertyTag ...> body content </com:ComponentType> +

where you may enclose DynamicPropertyTag within single or double quotes for better readability.

@@ -19,51 +21,54 @@ Like dynamic content tags, we have expression tags,

Expression Tags

-An expression tag represents a PHP expression that is evaluated when the template is being instantiated. The expression evaluation result is assigned to the corresponding component property. The format of expression tags is as follows, +An expression tag represents a PHP expression that is evaluated when the control is in PreRender stage. The expression evaluation result is assigned to the corresponding component property. The format of expression tags is as follows, +

<%= PhpExpression %> -In the expression, $this refers to the component specified by the component tag. The following example specifies a TLabel control whose Text property is initialized as the current page title when the TLabel control is being constructed, +

+In the expression, $this refers to the control owning the template. The following example specifies a TLabel control whose Text property is initialized as the current page title when the TLabel control is being constructed, +

<com:TLabel Text=<%= $this->Page->Title %> /> -

-

-Note, unlike dynamic content tags, the expressions tags for component properties are evaluated when the components are being constructed, while for the dynamic content tags, the expressions are evaluated when the controls are being rendered. -

Databind Tags

-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. +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 owning the template. Databind tags do not apply to all components. They can only be used for controls.

The format of databind tags is as follows, +

<%# PhpExpression %> -

Parameter Tags

Parameter tags are used to assign application parameter values to the corresponding component properties. The format of parameter tags is as follows, +

<%$ ParameterName %> +

Note, application parameters are usually defined in application configurations or page directory configurations. The parameters are evaluated when the template is instantiated.

Asset Tags

-Asset tags are used to publish private files and assign the corresponding the URLs to the component properties. For example, if you have an image file that is not Web-accessible and you want to make it visible to end-users, you can use asset tags to publish this file and show the URL to end-users so that they can fetch the published image. +Asset tags are used to publish private files and assign the corresponding the URLs to the component properties. For example, if you have an image file that is not Web-accessible and you want to make it visible to end-users, you can use asset tags to publish this file and show the URL to end-users so that they can fetch the published image. The asset tags are evaluated when the template is instantiated.

The format of asset tags is as follows, +

<%~ LocalFileName %> +

where LocalFileName refers to a file path that is relative to the directory containing the current template file. The file path can be a single file or a directory. If the latter, the content in the whole directory will be made accessible by end-users.

@@ -74,9 +79,12 @@ BE VERY CAUTIOUS when you are using asset tags as it may expose to end-users fil

Localization Tags

Localization tags represent localized texts. They are in the following format, +

<%[string]%> -where string will be translated to different languages according to the end-user's language preference. +

+where string will be translated to different languages according to the end-user's language preference. The localization tags are evaluated when the template is instantiated. +

\ No newline at end of file diff --git a/demos/quickstart/protected/pages/Controls/Samples/TDataGrid/Sample3.page b/demos/quickstart/protected/pages/Controls/Samples/TDataGrid/Sample3.page index be2f80bc..2864de46 100644 --- a/demos/quickstart/protected/pages/Controls/Samples/TDataGrid/Sample3.page +++ b/demos/quickstart/protected/pages/Controls/Samples/TDataGrid/Sample3.page @@ -48,11 +48,11 @@ /> - + NamingContainer->DataItem['rating'] %> + SelectedValue=<%#$this->Parent->DataItem['rating'] %> ID="Rating"> diff --git a/demos/quickstart/protected/pages/Controls/Samples/TDataList/Sample2.page b/demos/quickstart/protected/pages/Controls/Samples/TDataList/Sample2.page index 4b484b21..a0908f60 100644 --- a/demos/quickstart/protected/pages/Controls/Samples/TDataList/Sample2.page +++ b/demos/quickstart/protected/pages/Controls/Samples/TDataList/Sample2.page @@ -26,7 +26,7 @@ Parent->DataItem['id']%> + Text=<%#$this->DataItem['id']%> CommandName="select" /> <%#$this->DataItem['name']%> @@ -83,7 +83,7 @@ Name Parent->DataItem['name'] %> + Text=<%#$this->DataItem['name'] %> /> @@ -91,7 +91,7 @@ Quantity Parent->DataItem['quantity'] %> + Text=<%#$this->DataItem['quantity'] %> /> @@ -99,7 +99,7 @@ Price Parent->DataItem['price'] %> + Text=<%#$this->DataItem['price'] %> /> @@ -107,7 +107,7 @@ Imported Parent->DataItem['imported'] %> + Checked=<%#$this->DataItem['imported'] %> /> diff --git a/demos/quickstart/protected/pages/Controls/Samples/TRepeater/Sample3.page b/demos/quickstart/protected/pages/Controls/Samples/TRepeater/Sample3.page index 38636962..4b6849e9 100644 --- a/demos/quickstart/protected/pages/Controls/Samples/TRepeater/Sample3.page +++ b/demos/quickstart/protected/pages/Controls/Samples/TRepeater/Sample3.page @@ -19,7 +19,7 @@ The following example allows users to modify the existing tabular data using a < Parent->DataItem['name']%> /> + Text=<%#$this->DataItem['name']%> /> Parent->DataItem['price']%> /> + Text=<%#$this->DataItem['price']%> /> Parent->DataItem['imported']%> /> + Checked=<%#$this->DataItem['imported']%> /> SafeText: Page->TextBox2->SafeText%> /> + Text=<%#$this->TextBox2->SafeText%> /> -- cgit v1.2.3