From 370c682479edb2fd3f40ee701f7bb4ef088e8283 Mon Sep 17 00:00:00 2001 From: xue <> Date: Fri, 7 Apr 2006 03:32:11 +0000 Subject: Breaking change!! Optimized the representation and evaluation of template expression, statements and databind tags. --- .../protected/pages/Configurations/Templates2.page | 30 +++++++++++++++------- .../protected/pages/Controls/Expression.page | 13 ++-------- .../pages/Controls/Samples/TDataGrid/Sample2.page | 2 +- .../pages/Controls/Samples/TDataGrid/Sample2.php | 2 ++ .../pages/Controls/Samples/TDataGrid/Sample6.page | 1 + .../pages/Controls/Samples/TDataList/Sample1.page | 10 ++++---- .../pages/Controls/Samples/TDataList/Sample2.page | 12 ++++----- .../pages/Controls/Samples/TExpression/Home.page | 6 ----- .../pages/Controls/Samples/TRepeater/Sample1.page | 20 +++++++-------- .../pages/Controls/Samples/TRepeater/Sample2.page | 8 +++--- .../pages/Controls/Samples/TRepeater/Sample3.page | 12 ++++----- .../pages/Controls/Samples/TStatements/Home.page | 9 ------- .../protected/pages/Controls/Statements.page | 19 ++++++-------- 13 files changed, 66 insertions(+), 78 deletions(-) (limited to 'demos/quickstart/protected') diff --git a/demos/quickstart/protected/pages/Configurations/Templates2.page b/demos/quickstart/protected/pages/Configurations/Templates2.page index f4f68b69..0971c828 100644 --- a/demos/quickstart/protected/pages/Configurations/Templates2.page +++ b/demos/quickstart/protected/pages/Configurations/Templates2.page @@ -10,52 +10,59 @@ 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. Its format is as follows, +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. +

+

+The format of an expression tag is as follows, +

<%= PhpExpression %> -Inernally, an expression tag is represented by a TExpression control. Therefore, in the expression $this refers to the TExpression control. For example, the following expression tag will display the current page title at the place, +

+For example, the following expression tag will display the current page title at the place, +

-<%= $this->Page->Title %> +<%= $this->Title %> -

Statement Tags

-Statement tags are similar to expression tags, except that statement tags contain PHP statements rather than expressions. The output of the PHP statements (using for example echo or print in PHP) are displayed at the place where the statement tag resides in the template. Inernally, a statement tag is represented by a TStatements control. Therefore, in the statements $this refers to the TStatements control. The format of statement tags is as follows, +Statement tags are similar to expression tags, except that statement tags contain PHP statements rather than expressions. The output of the PHP statements (using for example echo or print in PHP) are displayed at the place where the statement tag resides in the template. The context (namely $this) of the statements is the control owning the template. The format of statement tags is as follows, +

<%% PHP Statements %> -

The following example displays the current time in Dutch at the place, +

<%% setlocale(LC_ALL, 'nl_NL'); echo strftime("%A %e %B %Y",time()); %> -

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 representing the databind tags. Internally, a TLiteral control is used to represent a databind tag and $this in the expression would refer to the control. The format of databind tags is as follows, +Databind tags are similar to expression tags, except that the expressions are evaluated only when a dataBind() call is invoked on the controls representing the databind tags. The context (namely $this) of a databind expression is the control owning the template. The format of databind tags is as follows, +

<%# PhpExpression %> -

Parameter Tags

Parameter tags are used to insert application parameters at the place where they appear in the template. 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.

@@ -66,9 +73,11 @@ Asset tags are used to publish private files and display the corresponding the U

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.

@@ -79,9 +88,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. +

\ No newline at end of file diff --git a/demos/quickstart/protected/pages/Controls/Expression.page b/demos/quickstart/protected/pages/Controls/Expression.page index c87f0ba4..80a45a3a 100644 --- a/demos/quickstart/protected/pages/Controls/Expression.page +++ b/demos/quickstart/protected/pages/Controls/Expression.page @@ -4,23 +4,14 @@

-TExpression evaluates a PHP expression and displays the evaluation result. To specify the expression to be evaluated, set the Expression property. In a control template, expression tags are often used instead of the complete component tags when the main purpose is to display the evaluation result of some PHP expression. For example, the following two tags are equivalent, -

- -<com:TExpression Expression="date()" /> -<%= date() %> - - -

-TExpression evaluates the expression during the rendering control lifecycle. +TExpression evaluates a PHP expression and displays the evaluation result. To specify the expression to be evaluated, set the Expression property. Note, TExpression evaluates the expression during the rendering control lifecycle.

-The context of the expression in a TExpression control is the control itself. That is, $this represents the control object if it is present in the expression. For example, both of the following template tags will display the title of the page containing the TExpression control. +The context of the expression in a TExpression control is the control itself. That is, $this represents the control object if it is present in the expression. For example, the following template tag will display the title of the page containing the TExpression control.

<com:TExpression Expression="$this->Page->Title" /> -<%= $this->Page->Title %>

diff --git a/demos/quickstart/protected/pages/Controls/Samples/TDataGrid/Sample2.page b/demos/quickstart/protected/pages/Controls/Samples/TDataGrid/Sample2.page index 6de3063a..79c1890c 100644 --- a/demos/quickstart/protected/pages/Controls/Samples/TDataGrid/Sample2.page +++ b/demos/quickstart/protected/pages/Controls/Samples/TDataGrid/Sample2.page @@ -42,7 +42,7 @@ Rating - + diff --git a/demos/quickstart/protected/pages/Controls/Samples/TDataGrid/Sample2.php b/demos/quickstart/protected/pages/Controls/Samples/TDataGrid/Sample2.php index d40e3be3..a49077b5 100644 --- a/demos/quickstart/protected/pages/Controls/Samples/TDataGrid/Sample2.php +++ b/demos/quickstart/protected/pages/Controls/Samples/TDataGrid/Sample2.php @@ -78,6 +78,8 @@ class Sample2 extends TPage { foreach($this->DataGrid->Columns as $index=>$column) $column->Visible=$sender->Items[$index]->Selected; + $this->DataGrid->DataSource=$this->Data; + $this->DataGrid->dataBind(); } } diff --git a/demos/quickstart/protected/pages/Controls/Samples/TDataGrid/Sample6.page b/demos/quickstart/protected/pages/Controls/Samples/TDataGrid/Sample6.page index d2277bc5..3d1a33a8 100644 --- a/demos/quickstart/protected/pages/Controls/Samples/TDataGrid/Sample6.page +++ b/demos/quickstart/protected/pages/Controls/Samples/TDataGrid/Sample6.page @@ -6,6 +6,7 @@

-Total <%# $this->Parent->Parent->ItemCount %> products. +Total <%# $this->Parent->ItemCount %> products.
@@ -36,10 +36,10 @@ Total <%# $this->Parent->Parent->ItemCount %> products. IDNameQuantityPrice - <%#$this->Parent->DataItem['id'] %> - <%#$this->Parent->DataItem['name'] %> - <%#$this->Parent->DataItem['quantity'] %> - $<%#$this->Parent->DataItem['price'] %> + <%#$this->DataItem['id'] %> + <%#$this->DataItem['name'] %> + <%#$this->DataItem['quantity'] %> + $<%#$this->DataItem['price'] %> diff --git a/demos/quickstart/protected/pages/Controls/Samples/TDataList/Sample2.page b/demos/quickstart/protected/pages/Controls/Samples/TDataList/Sample2.page index 07980c49..4b484b21 100644 --- a/demos/quickstart/protected/pages/Controls/Samples/TDataList/Sample2.page +++ b/demos/quickstart/protected/pages/Controls/Samples/TDataList/Sample2.page @@ -29,7 +29,7 @@ Text=<%#$this->Parent->DataItem['id']%> CommandName="select" /> - <%#$this->Parent->DataItem['name']%> + <%#$this->DataItem['name']%> IDNameQuantityPrice - <%#$this->Parent->DataItem['id'] %> - <%#$this->Parent->DataItem['name'] %> - <%#$this->Parent->DataItem['quantity'] %> - $<%#$this->Parent->DataItem['price'] %> + <%#$this->DataItem['id'] %> + <%#$this->DataItem['name'] %> + <%#$this->DataItem['quantity'] %> + $<%#$this->DataItem['price'] %> @@ -77,7 +77,7 @@ - + diff --git a/demos/quickstart/protected/pages/Controls/Samples/TExpression/Home.page b/demos/quickstart/protected/pages/Controls/Samples/TExpression/Home.page index 2273f3c1..8c736ca9 100644 --- a/demos/quickstart/protected/pages/Controls/Samples/TExpression/Home.page +++ b/demos/quickstart/protected/pages/Controls/Samples/TExpression/Home.page @@ -10,12 +10,6 @@ Using expression component tag: - -
ID<%#$this->Parent->DataItem['id']%><%#$this->DataItem['id']%>
Name
-Using shortcut expression tag: - -<%= $this->Page->PagePath %> -
\ No newline at end of file diff --git a/demos/quickstart/protected/pages/Controls/Samples/TRepeater/Sample1.page b/demos/quickstart/protected/pages/Controls/Samples/TRepeater/Sample1.page index e28ef6fb..f519342d 100644 --- a/demos/quickstart/protected/pages/Controls/Samples/TRepeater/Sample1.page +++ b/demos/quickstart/protected/pages/Controls/Samples/TRepeater/Sample1.page @@ -17,21 +17,21 @@ -<%#$this->Parent->DataItem['id']%> -<%#$this->Parent->DataItem['name']%> -<%#$this->Parent->DataItem['quantity']%> -<%#$this->Parent->DataItem['price']%> -<%#$this->Parent->DataItem['imported']?'Yes':'No'%> +<%#$this->DataItem['id']%> +<%#$this->DataItem['name']%> +<%#$this->DataItem['quantity']%> +<%#$this->DataItem['price']%> +<%#$this->DataItem['imported']?'Yes':'No'%> -<%#$this->Parent->DataItem['id']%> -<%#$this->Parent->DataItem['name']%> -<%#$this->Parent->DataItem['quantity']%> -<%#$this->Parent->DataItem['price']%> -<%#$this->Parent->DataItem['imported']?'Yes':'No'%> +<%#$this->DataItem['id']%> +<%#$this->DataItem['name']%> +<%#$this->DataItem['quantity']%> +<%#$this->DataItem['price']%> +<%#$this->DataItem['imported']?'Yes':'No'%> diff --git a/demos/quickstart/protected/pages/Controls/Samples/TRepeater/Sample2.page b/demos/quickstart/protected/pages/Controls/Samples/TRepeater/Sample2.page index b939c586..ce0942c3 100644 --- a/demos/quickstart/protected/pages/Controls/Samples/TRepeater/Sample2.page +++ b/demos/quickstart/protected/pages/Controls/Samples/TRepeater/Sample2.page @@ -14,7 +14,7 @@ - <%#$this->NamingContainer->DataItem %> + <%#$this->DataItem %> - <%#$this->NamingContainer->DataItem['name'] %> + <%#$this->DataItem['name'] %> - <%#$this->NamingContainer->DataItem['age'] %> + <%#$this->DataItem['age'] %> - <%#$this->NamingContainer->DataItem['position'] %> + <%#$this->DataItem['position'] %> diff --git a/demos/quickstart/protected/pages/Controls/Samples/TRepeater/Sample3.page b/demos/quickstart/protected/pages/Controls/Samples/TRepeater/Sample3.page index fde06a36..38636962 100644 --- a/demos/quickstart/protected/pages/Controls/Samples/TRepeater/Sample3.page +++ b/demos/quickstart/protected/pages/Controls/Samples/TRepeater/Sample3.page @@ -69,12 +69,12 @@ The following example allows users to modify the existing tabular data using a < - -<%#$this->Parent->DataItem['id']%> -<%#$this->Parent->DataItem['name']%> -<%#$this->Parent->DataItem['category']%> -<%#$this->Parent->DataItem['price']%> -<%#$this->Parent->DataItem['imported']?'Yes':'No'%> + +<%#$this->DataItem['id']%> +<%#$this->DataItem['name']%> +<%#$this->DataItem['category']%> +<%#$this->DataItem['price']%> +<%#$this->DataItem['imported']?'Yes':'No'%> diff --git a/demos/quickstart/protected/pages/Controls/Samples/TStatements/Home.page b/demos/quickstart/protected/pages/Controls/Samples/TStatements/Home.page index 66734ce0..d07bf159 100644 --- a/demos/quickstart/protected/pages/Controls/Samples/TStatements/Home.page +++ b/demos/quickstart/protected/pages/Controls/Samples/TStatements/Home.page @@ -15,15 +15,6 @@ Using TStatements component tag: - -Using shortcut statements tag: - -<%% - $uid=$this->UniqueID; - echo "UniqueID is '$uid'."; -%> - - \ No newline at end of file diff --git a/demos/quickstart/protected/pages/Controls/Statements.page b/demos/quickstart/protected/pages/Controls/Statements.page index c6807738..dd26ec1b 100644 --- a/demos/quickstart/protected/pages/Controls/Statements.page +++ b/demos/quickstart/protected/pages/Controls/Statements.page @@ -4,34 +4,31 @@

-TStatements evaluates a sequence of PHP statements and displays the content rendered by the statements. To specify the PHP statements to be evaluated, set the Statements property. In a control template, statement tags are often used instead of the complete component tags when the main purpose is to display the result rendered by some PHP statements. For example, the following two tags are equivalent, +TStatements evaluates a sequence of PHP statements and displays the content rendered by the statements. To specify the PHP statements to be evaluated, set the Statements property. For example, the following component tag displays the current time on the Web page,

<com:TStatements> - <prop:Expression> + <prop:Statements> setlocale(LC_ALL, 'nl_NL'); echo strftime("%A %e %B %Y",time()); - </prop:Expression> + </prop:Statements> </com:TStatements> - -<%% - setlocale(LC_ALL, 'nl_NL'); - echo strftime("%A %e %B %Y",time()); -%>

-TStatements evaluates the PHP statements during the rendering control lifecycle. Unlike TExpression, TStatements only displays the content 'echoed' within the statements. +Note, TStatements evaluates the PHP statements during the rendering control lifecycle. Unlike TExpression, TStatements only displays the content 'echoed' within the statements.

The context of the statements in a TStatements control is the control itself. That is, $this represents the control object if it is present in the statements. For example, the following statement tag will display the title of the page containing the TStatements control.

-<%% +<com:TStatements> + <prop:Statements> $page=$this->Page; echo $page->Title; -%> + </prop:Statements> +</com:TStatements>

-- cgit v1.2.3