summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitattributes2
-rw-r--r--demos/quickstart/protected/pages/Controls/Samples/TRepeater/Sample1.page2
-rw-r--r--demos/quickstart/protected/pages/Controls/Samples/TRepeater/Sample2.page10
-rw-r--r--demos/quickstart/protected/pages/Controls/Samples/TRepeater/Sample3.page92
-rw-r--r--demos/quickstart/protected/pages/Controls/Samples/TRepeater/Sample3.php79
-rw-r--r--framework/Web/UI/WebControls/TSafeHtml.php4
6 files changed, 182 insertions, 7 deletions
diff --git a/.gitattributes b/.gitattributes
index 9cd03436..12f6557d 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -148,6 +148,8 @@ demos/quickstart/protected/pages/Controls/Samples/TRepeater/Sample1.page -text
demos/quickstart/protected/pages/Controls/Samples/TRepeater/Sample1.php -text
demos/quickstart/protected/pages/Controls/Samples/TRepeater/Sample2.page -text
demos/quickstart/protected/pages/Controls/Samples/TRepeater/Sample2.php -text
+demos/quickstart/protected/pages/Controls/Samples/TRepeater/Sample3.page -text
+demos/quickstart/protected/pages/Controls/Samples/TRepeater/Sample3.php -text
demos/quickstart/protected/pages/Controls/Samples/TRequiredFieldValidator/Home.page -text
demos/quickstart/protected/pages/Controls/Samples/TRequiredFieldValidator/Home.php -text
demos/quickstart/protected/pages/Controls/Samples/TTable/Home.page -text
diff --git a/demos/quickstart/protected/pages/Controls/Samples/TRepeater/Sample1.page b/demos/quickstart/protected/pages/Controls/Samples/TRepeater/Sample1.page
index 8e469fde..1922ca2a 100644
--- a/demos/quickstart/protected/pages/Controls/Samples/TRepeater/Sample1.page
+++ b/demos/quickstart/protected/pages/Controls/Samples/TRepeater/Sample1.page
@@ -2,7 +2,7 @@
<h1>TRepeater Sample 1</h1>
-<com:TRepeater ID="Repeater" >
+<com:TRepeater ID="Repeater" EnableViewState="false">
<prop:HeaderTemplate>
<table cellpadding="2">
diff --git a/demos/quickstart/protected/pages/Controls/Samples/TRepeater/Sample2.page b/demos/quickstart/protected/pages/Controls/Samples/TRepeater/Sample2.page
index bb78c35a..b939c586 100644
--- a/demos/quickstart/protected/pages/Controls/Samples/TRepeater/Sample2.page
+++ b/demos/quickstart/protected/pages/Controls/Samples/TRepeater/Sample2.page
@@ -3,11 +3,12 @@
<h1>TRepeater Sample 2</h1>
<com:TRepeater ID="Repeater"
+ EnableViewState="false"
OnItemDataBound="dataBindRepeater2"
OnItemCreated="repeaterItemCreated">
<prop:HeaderTemplate>
-<table cellspacing="1" style="border-collapse:collapse;border:1px solid silver">
+<table cellspacing="1" style="border:1px solid silver">
</prop:HeaderTemplate>
<prop:ItemTemplate>
@@ -16,10 +17,13 @@
<%#$this->NamingContainer->DataItem %>
</com:TTableCell>
<td>
- <com:TRepeater ID="Repeater2" OnItemCreated="Page.repeater2ItemCreated">
+ <com:TRepeater
+ ID="Repeater2"
+ EnableViewState="false"
+ OnItemCreated="Page.repeater2ItemCreated">
<prop:HeaderTemplate>
- <table cellspacing="1" style="border-collapse: collapse;">
+ <table cellspacing="1">
</prop:HeaderTemplate>
<prop:ItemTemplate>
diff --git a/demos/quickstart/protected/pages/Controls/Samples/TRepeater/Sample3.page b/demos/quickstart/protected/pages/Controls/Samples/TRepeater/Sample3.page
new file mode 100644
index 00000000..115018ec
--- /dev/null
+++ b/demos/quickstart/protected/pages/Controls/Samples/TRepeater/Sample3.page
@@ -0,0 +1,92 @@
+<com:TContent ID="body">
+
+<h1>TRepeater Sample 3</h1>
+
+<p>
+The following example allows users to modify the existing tabular data using a <tt>TRepeater</tt>. Two validators are used in the repeater to ensure the validity of user inputs. One is to ensure product names are not empty, the other ensures product prices are valid numeric format. After clicking on the <tt>save</tt> button, the input data is displayed in a table at the bottom of the page.
+</p>
+
+<table>
+<tr>
+ <th>Name</th>
+ <th>Category</th>
+ <th>Price</th>
+ <th>Imported</th>
+</tr>
+<com:TRepeater ID="Repeater" OnItemDataBound="repeaterDataBound">
+<prop:ItemTemplate>
+<tr>
+ <td>
+ <com:TTextBox
+ ID="ProductName"
+ Text=<%#$this->Parent->DataItem['name']%> />
+ </td>
+ <td>
+ <com:TDropDownList
+ ID="ProductCategory" />
+ </td>
+ <td>
+ <com:TTextBox
+ ID="ProductPrice"
+ Columns="7"
+ Text=<%#$this->Parent->DataItem['price']%> />
+ </td>
+ <td>
+ <com:TCheckBox
+ ID="ProductImported"
+ Checked=<%#$this->Parent->DataItem['imported']%> />
+ <com:TRequiredFieldValidator
+ ControlToValidate="ProductName"
+ ErrorMessage="Product name cannot be empty."
+ Display="Dynamic" />
+ <com:TRegularExpressionValidator
+ ControlToValidate="ProductPrice"
+ RegularExpression="\d+(\.\d{1,2})?"
+ ErrorMessage="Product price must be in the format of ddd.dd"
+ Display="Dynamic" />
+ </td>
+</tr>
+</prop:ItemTemplate>
+</com:TRepeater>
+</table>
+
+<div>
+<com:TButton Text="Save" OnClick="saveInput"/>
+</div>
+
+<com:TSafeHtml>
+<com:TRepeater ID="Repeater2" EnableViewState="false">
+
+<prop:HeaderTemplate>
+<table cellpadding="2">
+<tr style="color:white;background-color:black">
+ <th>ID</th>
+ <th>Name</th>
+ <th>Category</th>
+ <th>Price</th>
+ <th>Imported</th>
+</tr>
+</prop:HeaderTemplate>
+
+<prop:ItemTemplate>
+<tr style="<%# 'background-color:' . ($this->Parent->ItemIndex%2 ? 'silver' : 'green') %>">
+<td><%#$this->Parent->DataItem['id']%></td>
+<td><%#$this->Parent->DataItem['name']%></td>
+<td><%#$this->Parent->DataItem['category']%></td>
+<td><%#$this->Parent->DataItem['price']%></td>
+<td><%#$this->Parent->DataItem['imported']?'Yes':'No'%></td>
+</tr>
+</prop:ItemTemplate>
+
+<prop:FooterTemplate>
+<tr style="color:white;background-color:black;text-align:center;">
+<td colspan="5">Computer Parts Inventory</td>
+</tr>
+</table>
+</prop:FooterTemplate>
+
+</com:TRepeater>
+
+</com:TSafeHtml>
+
+</com:TContent> \ No newline at end of file
diff --git a/demos/quickstart/protected/pages/Controls/Samples/TRepeater/Sample3.php b/demos/quickstart/protected/pages/Controls/Samples/TRepeater/Sample3.php
new file mode 100644
index 00000000..d4f4c8e9
--- /dev/null
+++ b/demos/quickstart/protected/pages/Controls/Samples/TRepeater/Sample3.php
@@ -0,0 +1,79 @@
+<?php
+
+class Sample3 extends TPage
+{
+ protected function getProducts()
+ {
+ return array(
+ array('id'=>'ITN001','name'=>'Motherboard','category'=>'CAT004','price'=>100.00,'imported'=>true),
+ array('id'=>'ITN002','name'=>'CPU','category'=>'CAT004','price'=>150.00,'imported'=>true),
+ array('id'=>'ITN003','name'=>'Harddrive','category'=>'CAT003','price'=>80.00,'imported'=>true),
+ array('id'=>'ITN006','name'=>'Keyboard','category'=>'CAT002','price'=>20.00,'imported'=>false),
+ array('id'=>'ITN008','name'=>'CDRW drive','category'=>'CAT003','price'=>40.00,'imported'=>true),
+ array('id'=>'ITN009','name'=>'Cooling fan','category'=>'CAT001','price'=>10.00,'imported'=>false),
+ array('id'=>'ITN012','name'=>'Floppy drive','category'=>'CAT003','price'=>12.00,'imported'=>false),
+ array('id'=>'ITN013','name'=>'CD drive','category'=>'CAT003','price'=>20.00,'imported'=>true),
+ array('id'=>'ITN014','name'=>'DVD drive','category'=>'CAT003','price'=>80.00,'imported'=>true),
+ array('id'=>'ITN015','name'=>'Mouse pad','category'=>'CAT001','price'=>5.00,'imported'=>false),
+ );
+ }
+
+ protected function getCategories()
+ {
+ return array(
+ array('id'=>'CAT001','name'=>'Accessories'),
+ array('id'=>'CAT002','name'=>'Input Devices'),
+ array('id'=>'CAT003','name'=>'Drives'),
+ array('id'=>'CAT004','name'=>'Barebone'),
+ );
+ }
+
+ public function onLoad($param)
+ {
+ parent::onLoad($param);
+ if(!$this->IsPostBack)
+ {
+ $this->Repeater->DataSource=$this->Products;
+ $this->Repeater->dataBind();
+ }
+ }
+
+ public function repeaterDataBound($sender,$param)
+ {
+ $item=$param->Item;
+ if($item->ItemType==='Item' || $item->ItemType==='AlternatingItem')
+ {
+ $item->ProductCategory->DataSource=$this->Categories;
+ $item->ProductCategory->DataTextField='name';
+ $item->ProductCategory->DataValueField='id';
+ $item->ProductCategory->dataBind();
+ $item->ProductCategory->SelectedValue=$item->DataItem['category'];
+ }
+ }
+
+ public function saveInput($sender,$param)
+ {
+ if($this->IsValid)
+ {
+ $index=0;
+ $products=$this->Products;
+ $data=array();
+ foreach($this->Repeater->Items as $item)
+ {
+ $item=array(
+ 'id'=>$products[$index]['id'],
+ 'name'=>$item->ProductName->Text,
+ 'category'=>$item->ProductCategory->SelectedItem->Text,
+ 'price'=>TPropertyValue::ensureFloat($item->ProductPrice->Text),
+ 'imported'=>$item->ProductImported->Checked,
+ );
+ $data[]=$item;
+ $index++;
+ }
+ $this->Repeater2->DataSource=$data;
+ $this->Repeater2->dataBind();
+ }
+ }
+}
+
+?> \ No newline at end of file
diff --git a/framework/Web/UI/WebControls/TSafeHtml.php b/framework/Web/UI/WebControls/TSafeHtml.php
index 0dae3b75..83e72167 100644
--- a/framework/Web/UI/WebControls/TSafeHtml.php
+++ b/framework/Web/UI/WebControls/TSafeHtml.php
@@ -1,7 +1,5 @@
<?php
-Prado::using('System.3rdParty.SafeHtml.TSafeHtmlParser');
-
/**
* ${classname}
*
@@ -33,7 +31,7 @@ class TSafeHtml extends TControl
*/
protected function parseSafeHtml($text)
{
- $renderer = new TSafeHtmlParser();
+ $renderer = Prado::createComponent('System.3rdParty.SafeHtml.TSafeHtmlParser');
return $renderer->parse($content);
}
}