diff options
Diffstat (limited to 'demos/quickstart/protected/pages')
91 files changed, 3298 insertions, 3298 deletions
diff --git a/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveButton/Home.php b/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveButton/Home.php index 4a4e23ca..e3afdaae 100644 --- a/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveButton/Home.php +++ b/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveButton/Home.php @@ -1,20 +1,20 @@ -<?php
-
-// $Id$
-class Home extends TPage
-{
- public function buttonClicked($sender, $param)
- {
- if($param instanceof TCommandEventParameter)
- $sender->Text="Name: {$param->CommandName}, Param: {$param->CommandParameter}";
- else
- $sender->Text="I'm clicked";
- }
-
- public function buttonCallback($sender, $param)
- {
- $sender->Text .= ' using callback';
- }
-}
-
+<?php + +// $Id$ +class Home extends TPage +{ + public function buttonClicked($sender, $param) + { + if($param instanceof TCommandEventParameter) + $sender->Text="Name: {$param->CommandName}, Param: {$param->CommandParameter}"; + else + $sender->Text="I'm clicked"; + } + + public function buttonCallback($sender, $param) + { + $sender->Text .= ' using callback'; + } +} + ?>
\ No newline at end of file diff --git a/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveCheckBox/Home.php b/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveCheckBox/Home.php index f0543695..5a73a6f4 100644 --- a/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveCheckBox/Home.php +++ b/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveCheckBox/Home.php @@ -1,16 +1,16 @@ -<?php
-// $Id$
-class Home extends TPage
-{
- public function checkboxClicked($sender,$param)
- {
- $sender->Text= $sender->ClientID . " clicked";
- }
-
- public function checkboxCallback($sender, $param)
- {
- $sender->Text .= ' using callback';
- }
-}
-
+<?php +// $Id$ +class Home extends TPage +{ + public function checkboxClicked($sender,$param) + { + $sender->Text= $sender->ClientID . " clicked"; + } + + public function checkboxCallback($sender, $param) + { + $sender->Text .= ' using callback'; + } +} + ?>
\ No newline at end of file diff --git a/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveCheckBoxList/Home.php b/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveCheckBoxList/Home.php index 3644721e..b9060163 100644 --- a/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveCheckBoxList/Home.php +++ b/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveCheckBoxList/Home.php @@ -1,26 +1,26 @@ -<?php
-
-class Home extends TPage
-{
- protected function collectSelectionResult($input,$output)
- {
- $indices=$input->SelectedIndices;
- $result='';
- foreach($indices as $index)
- {
- $item=$input->Items[$index];
- $result.="(Index: $index, Value: $item->Value, Text: $item->Text)";
- }
- if($result==='')
- $output->Text='Your selection is empty.';
- else
- $output->Text='Your selection is: '.$result;
- }
-
- public function selectionChanged($sender,$param)
- {
- $this->collectSelectionResult($this->CheckBoxList,$this->SelectionResult);
- }
-}
-
+<?php + +class Home extends TPage +{ + protected function collectSelectionResult($input,$output) + { + $indices=$input->SelectedIndices; + $result=''; + foreach($indices as $index) + { + $item=$input->Items[$index]; + $result.="(Index: $index, Value: $item->Value, Text: $item->Text)"; + } + if($result==='') + $output->Text='Your selection is empty.'; + else + $output->Text='Your selection is: '.$result; + } + + public function selectionChanged($sender,$param) + { + $this->collectSelectionResult($this->CheckBoxList,$this->SelectionResult); + } +} + ?>
\ No newline at end of file diff --git a/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveCustomValidator/Home.php b/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveCustomValidator/Home.php index 102afcb0..c668c86d 100644 --- a/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveCustomValidator/Home.php +++ b/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveCustomValidator/Home.php @@ -1,11 +1,11 @@ -<?php
-
-class Home extends TPage
-{
- public function validator1_onvalidate($sender, $param)
- {
- $param->IsValid = $this->textbox1->Text == 'Prado';
- }
-}
-
+<?php + +class Home extends TPage +{ + public function validator1_onvalidate($sender, $param) + { + $param->IsValid = $this->textbox1->Text == 'Prado'; + } +} + ?>
\ No newline at end of file diff --git a/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveDataGrid/Sample1.php b/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveDataGrid/Sample1.php index ada1ee6e..43d645ab 100644 --- a/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveDataGrid/Sample1.php +++ b/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveDataGrid/Sample1.php @@ -1,37 +1,37 @@ -<?php
-
-class Sample1 extends TPage
-{
- protected function getData()
- {
- return array(
- array('id'=>'ITN001','name'=>'Motherboard','quantity'=>1,'price'=>100.00,'imported'=>true),
- array('id'=>'ITN002','name'=>'CPU','quantity'=>1,'price'=>150.00,'imported'=>true),
- array('id'=>'ITN003','name'=>'Harddrive','quantity'=>2,'price'=>80.00,'imported'=>true),
- array('id'=>'ITN004','name'=>'Sound card','quantity'=>1,'price'=>40.00,'imported'=>false),
- array('id'=>'ITN005','name'=>'Video card','quantity'=>1,'price'=>150.00,'imported'=>true),
- array('id'=>'ITN006','name'=>'Keyboard','quantity'=>1,'price'=>20.00,'imported'=>false),
- array('id'=>'ITN007','name'=>'Monitor','quantity'=>2,'price'=>300.00,'imported'=>true),
- array('id'=>'ITN008','name'=>'CDRW drive','quantity'=>1,'price'=>40.00,'imported'=>true),
- array('id'=>'ITN009','name'=>'Cooling fan','quantity'=>2,'price'=>10.00,'imported'=>false),
- array('id'=>'ITN010','name'=>'Video camera','quantity'=>20,'price'=>30.00,'imported'=>true),
- array('id'=>'ITN011','name'=>'Card reader','quantity'=>10,'price'=>24.00,'imported'=>true),
- array('id'=>'ITN012','name'=>'Floppy drive','quantity'=>50,'price'=>12.00,'imported'=>false),
- array('id'=>'ITN013','name'=>'CD drive','quantity'=>25,'price'=>20.00,'imported'=>true),
- array('id'=>'ITN014','name'=>'DVD drive','quantity'=>15,'price'=>80.00,'imported'=>true),
- array('id'=>'ITN015','name'=>'Mouse pad','quantity'=>50,'price'=>5.00,'imported'=>false),
- array('id'=>'ITN016','name'=>'Network cable','quantity'=>40,'price'=>8.00,'imported'=>true),
- array('id'=>'ITN017','name'=>'Case','quantity'=>8,'price'=>65.00,'imported'=>false),
- array('id'=>'ITN018','name'=>'Surge protector','quantity'=>45,'price'=>15.00,'imported'=>false),
- array('id'=>'ITN019','name'=>'Speaker','quantity'=>35,'price'=>65.00,'imported'=>false),
- );
- }
-
- public function buttonClicked($sender, $param)
- {
- $this->DataGrid->DataSource=$this->Data;
- $this->DataGrid->dataBind();
- }
-}
-
+<?php + +class Sample1 extends TPage +{ + protected function getData() + { + return array( + array('id'=>'ITN001','name'=>'Motherboard','quantity'=>1,'price'=>100.00,'imported'=>true), + array('id'=>'ITN002','name'=>'CPU','quantity'=>1,'price'=>150.00,'imported'=>true), + array('id'=>'ITN003','name'=>'Harddrive','quantity'=>2,'price'=>80.00,'imported'=>true), + array('id'=>'ITN004','name'=>'Sound card','quantity'=>1,'price'=>40.00,'imported'=>false), + array('id'=>'ITN005','name'=>'Video card','quantity'=>1,'price'=>150.00,'imported'=>true), + array('id'=>'ITN006','name'=>'Keyboard','quantity'=>1,'price'=>20.00,'imported'=>false), + array('id'=>'ITN007','name'=>'Monitor','quantity'=>2,'price'=>300.00,'imported'=>true), + array('id'=>'ITN008','name'=>'CDRW drive','quantity'=>1,'price'=>40.00,'imported'=>true), + array('id'=>'ITN009','name'=>'Cooling fan','quantity'=>2,'price'=>10.00,'imported'=>false), + array('id'=>'ITN010','name'=>'Video camera','quantity'=>20,'price'=>30.00,'imported'=>true), + array('id'=>'ITN011','name'=>'Card reader','quantity'=>10,'price'=>24.00,'imported'=>true), + array('id'=>'ITN012','name'=>'Floppy drive','quantity'=>50,'price'=>12.00,'imported'=>false), + array('id'=>'ITN013','name'=>'CD drive','quantity'=>25,'price'=>20.00,'imported'=>true), + array('id'=>'ITN014','name'=>'DVD drive','quantity'=>15,'price'=>80.00,'imported'=>true), + array('id'=>'ITN015','name'=>'Mouse pad','quantity'=>50,'price'=>5.00,'imported'=>false), + array('id'=>'ITN016','name'=>'Network cable','quantity'=>40,'price'=>8.00,'imported'=>true), + array('id'=>'ITN017','name'=>'Case','quantity'=>8,'price'=>65.00,'imported'=>false), + array('id'=>'ITN018','name'=>'Surge protector','quantity'=>45,'price'=>15.00,'imported'=>false), + array('id'=>'ITN019','name'=>'Speaker','quantity'=>35,'price'=>65.00,'imported'=>false), + ); + } + + public function buttonClicked($sender, $param) + { + $this->DataGrid->DataSource=$this->Data; + $this->DataGrid->dataBind(); + } +} + ?>
\ No newline at end of file diff --git a/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveDataGrid/Sample2.php b/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveDataGrid/Sample2.php index 3831582d..10a37e0a 100644 --- a/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveDataGrid/Sample2.php +++ b/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveDataGrid/Sample2.php @@ -1,86 +1,86 @@ -<?php
-
-class Sample2 extends TPage
-{
- protected function getData()
- {
- return array(
- array(
- 'ISBN'=>'0596007124',
- 'title'=>'Head First Design Patterns',
- 'publisher'=>'O\'Reilly Media, Inc.',
- 'price'=>29.67,
- 'instock'=>true,
- 'rating'=>4,
- ),
- array(
- 'ISBN'=>'0201633612',
- 'title'=>'Design Patterns: Elements of Reusable Object-Oriented Software',
- 'publisher'=>'Addison-Wesley Professional',
- 'price'=>47.04,
- 'instock'=>true,
- 'rating'=>5,
- ),
- array(
- 'ISBN'=>'0321247140',
- 'title'=>'Design Patterns Explained : A New Perspective on Object-Oriented Design',
- 'publisher'=>'Addison-Wesley Professional',
- 'price'=>37.49,
- 'instock'=>true,
- 'rating'=>4,
- ),
- array(
- 'ISBN'=>'0201485672',
- 'title'=>'Refactoring: Improving the Design of Existing Code',
- 'publisher'=>'Addison-Wesley Professional',
- 'price'=>47.14,
- 'instock'=>true,
- 'rating'=>3,
- ),
- array(
- 'ISBN'=>'0321213351',
- 'title'=>'Refactoring to Patterns',
- 'publisher'=>'Addison-Wesley Professional',
- 'price'=>38.49,
- 'instock'=>true,
- 'rating'=>2,
- ),
- array(
- 'ISBN'=>'0735619670',
- 'title'=>'Code Complete',
- 'publisher'=>'Microsoft Press',
- 'price'=>32.99,
- 'instock'=>false,
- 'rating'=>4,
- ),
- array(
- 'ISBN'=>'0321278658',
- 'title'=>'Extreme Programming Explained : Embrace Change',
- 'publisher'=>'Addison-Wesley Professional',
- 'price'=>34.99,
- 'instock'=>true,
- 'rating'=>3,
- ),
- );
- }
-
- public function onLoad($param)
- {
- parent::onLoad($param);
- if(!$this->IsPostBack && !$this->IsCallBack)
- {
- $this->DataGrid->DataSource=$this->Data;
- $this->DataGrid->dataBind();
- }
- }
-
- public function toggleColumnVisibility($sender,$param)
- {
- foreach($this->DataGrid->Columns as $index=>$column)
- $column->Visible=$sender->Items[$index]->Selected;
- $this->DataGrid->DataSource=$this->Data;
- $this->DataGrid->dataBind();
- }
-}
-
+<?php + +class Sample2 extends TPage +{ + protected function getData() + { + return array( + array( + 'ISBN'=>'0596007124', + 'title'=>'Head First Design Patterns', + 'publisher'=>'O\'Reilly Media, Inc.', + 'price'=>29.67, + 'instock'=>true, + 'rating'=>4, + ), + array( + 'ISBN'=>'0201633612', + 'title'=>'Design Patterns: Elements of Reusable Object-Oriented Software', + 'publisher'=>'Addison-Wesley Professional', + 'price'=>47.04, + 'instock'=>true, + 'rating'=>5, + ), + array( + 'ISBN'=>'0321247140', + 'title'=>'Design Patterns Explained : A New Perspective on Object-Oriented Design', + 'publisher'=>'Addison-Wesley Professional', + 'price'=>37.49, + 'instock'=>true, + 'rating'=>4, + ), + array( + 'ISBN'=>'0201485672', + 'title'=>'Refactoring: Improving the Design of Existing Code', + 'publisher'=>'Addison-Wesley Professional', + 'price'=>47.14, + 'instock'=>true, + 'rating'=>3, + ), + array( + 'ISBN'=>'0321213351', + 'title'=>'Refactoring to Patterns', + 'publisher'=>'Addison-Wesley Professional', + 'price'=>38.49, + 'instock'=>true, + 'rating'=>2, + ), + array( + 'ISBN'=>'0735619670', + 'title'=>'Code Complete', + 'publisher'=>'Microsoft Press', + 'price'=>32.99, + 'instock'=>false, + 'rating'=>4, + ), + array( + 'ISBN'=>'0321278658', + 'title'=>'Extreme Programming Explained : Embrace Change', + 'publisher'=>'Addison-Wesley Professional', + 'price'=>34.99, + 'instock'=>true, + 'rating'=>3, + ), + ); + } + + public function onLoad($param) + { + parent::onLoad($param); + if(!$this->IsPostBack && !$this->IsCallBack) + { + $this->DataGrid->DataSource=$this->Data; + $this->DataGrid->dataBind(); + } + } + + public function toggleColumnVisibility($sender,$param) + { + foreach($this->DataGrid->Columns as $index=>$column) + $column->Visible=$sender->Items[$index]->Selected; + $this->DataGrid->DataSource=$this->Data; + $this->DataGrid->dataBind(); + } +} + ?>
\ No newline at end of file diff --git a/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveDataGrid/Sample3.php b/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveDataGrid/Sample3.php index 9768ca31..5e2fb355 100644 --- a/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveDataGrid/Sample3.php +++ b/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveDataGrid/Sample3.php @@ -1,190 +1,190 @@ -<?php
-
-class Sample3 extends TPage
-{
- private $_data=null;
-
- protected function getData()
- {
- if($this->_data===null)
- $this->loadData();
- return $this->_data;
- }
-
- protected function loadData()
- {
- // We use viewstate keep track of data.
- // In real applications, data should come from database using an SQL SELECT statement.
- // In the following tabular data, field 'ISBN' is the primary key.
- // All update and delete operations should come with an 'id' value in order to go through.
- if(($this->_data=$this->getViewState('Data',null))===null)
- {
- $this->_data=array(
- array(
- 'ISBN'=>'0596007124',
- 'title'=>'Head First Design Patterns',
- 'publisher'=>'O\'Reilly Media, Inc.',
- 'price'=>29.67,
- 'instock'=>true,
- 'rating'=>4,
- ),
- array(
- 'ISBN'=>'0201633612',
- 'title'=>'Design Patterns: Elements of Reusable Object-Oriented Software',
- 'publisher'=>'Addison-Wesley Professional',
- 'price'=>47.04,
- 'instock'=>true,
- 'rating'=>5,
- ),
- array(
- 'ISBN'=>'0321247140',
- 'title'=>'Design Patterns Explained : A New Perspective on Object-Oriented Design',
- 'publisher'=>'Addison-Wesley Professional',
- 'price'=>37.49,
- 'instock'=>true,
- 'rating'=>4,
- ),
- array(
- 'ISBN'=>'0201485672',
- 'title'=>'Refactoring: Improving the Design of Existing Code',
- 'publisher'=>'Addison-Wesley Professional',
- 'price'=>47.14,
- 'instock'=>true,
- 'rating'=>3,
- ),
- array(
- 'ISBN'=>'0321213351',
- 'title'=>'Refactoring to Patterns',
- 'publisher'=>'Addison-Wesley Professional',
- 'price'=>38.49,
- 'instock'=>true,
- 'rating'=>2,
- ),
- array(
- 'ISBN'=>'0735619670',
- 'title'=>'Code Complete',
- 'publisher'=>'Microsoft Press',
- 'price'=>32.99,
- 'instock'=>false,
- 'rating'=>4,
- ),
- array(
- 'ISBN'=>'0321278658 ',
- 'title'=>'Extreme Programming Explained : Embrace Change',
- 'publisher'=>'Addison-Wesley Professional',
- 'price'=>34.99,
- 'instock'=>true,
- 'rating'=>3,
- ),
- );
- $this->saveData();
- }
- }
-
- protected function saveData()
- {
- $this->setViewState('Data',$this->_data);
- }
-
- protected function updateBook($isbn,$title,$publisher,$price,$instock,$rating)
- {
- // In real applications, data should be saved to database using an SQL UPDATE statement
- if($this->_data===null)
- $this->loadData();
- $updateRow=null;
- foreach($this->_data as $index=>$row)
- if($row['ISBN']===$isbn)
- $updateRow=&$this->_data[$index];
- if($updateRow!==null)
- {
- $updateRow['title']=$title;
- $updateRow['publisher']=$publisher;
- $updateRow['price']=TPropertyValue::ensureFloat(ltrim($price,'$'));
- $updateRow['instock']=TPropertyValue::ensureBoolean($instock);
- $updateRow['rating']=TPropertyValue::ensureInteger($rating);
- $this->saveData();
- }
- }
-
- protected function deleteBook($isbn)
- {
- // In real applications, data should be saved to database using an SQL DELETE statement
- if($this->_data===null)
- $this->loadData();
- $deleteIndex=-1;
- foreach($this->_data as $index=>$row)
- if($row['ISBN']===$isbn)
- $deleteIndex=$index;
- if($deleteIndex>=0)
- {
- unset($this->_data[$deleteIndex]);
- $this->saveData();
- }
- }
-
- public function onLoad($param)
- {
- parent::onLoad($param);
- if(!$this->IsPostBack && !$this->IsCallBack)
- {
- $this->DataGrid->DataSource=$this->Data;
- $this->DataGrid->dataBind();
- }
- }
-
- public function itemCreated($sender,$param)
- {
- $item=$param->Item;
- if($item->ItemType==='EditItem')
- {
- // set column width of textboxes
- $item->BookTitleColumn->TextBox->Columns=40;
- $item->PriceColumn->TextBox->Columns=5;
- }
- if($item->ItemType==='Item' || $item->ItemType==='AlternatingItem' || $item->ItemType==='EditItem')
- {
- // add an aleart dialog to delete buttons
- $item->DeleteColumn->Button->Attributes->onclick='if(!confirm(\'Are you sure?\')) return false;';
- }
- }
-
- public function editItem($sender,$param)
- {
- $this->DataGrid->EditItemIndex=$param->Item->ItemIndex;
- $this->DataGrid->DataSource=$this->Data;
- $this->DataGrid->dataBind();
- }
-
- public function saveItem($sender,$param)
- {
- $item=$param->Item;
- $this->updateBook(
- $this->DataGrid->DataKeys[$item->ItemIndex], // ISBN
- $item->BookTitleColumn->TextBox->Text, // title
- $item->PublisherColumn->TextBox->Text, // publisher
- $item->PriceColumn->TextBox->Text, // price
- $item->InStockColumn->CheckBox->Checked, // instock
- $item->RatingColumn->DropDownList->SelectedValue // rating
- );
- $this->DataGrid->EditItemIndex=-1;
- $this->DataGrid->DataSource=$this->Data;
- $this->DataGrid->dataBind();
- }
-
- public function cancelItem($sender,$param)
- {
- $this->DataGrid->EditItemIndex=-1;
- $this->DataGrid->DataSource=$this->Data;
- $this->DataGrid->dataBind();
- }
-
- public function deleteItem($sender,$param)
- {
- $this->deleteBook($this->DataGrid->DataKeys[$param->Item->ItemIndex]);
- $this->DataGrid->EditItemIndex=-1;
- $this->DataGrid->DataSource=$this->Data;
- $this->DataGrid->dataBind();
- }
-}
-
+<?php + +class Sample3 extends TPage +{ + private $_data=null; + + protected function getData() + { + if($this->_data===null) + $this->loadData(); + return $this->_data; + } + + protected function loadData() + { + // We use viewstate keep track of data. + // In real applications, data should come from database using an SQL SELECT statement. + // In the following tabular data, field 'ISBN' is the primary key. + // All update and delete operations should come with an 'id' value in order to go through. + if(($this->_data=$this->getViewState('Data',null))===null) + { + $this->_data=array( + array( + 'ISBN'=>'0596007124', + 'title'=>'Head First Design Patterns', + 'publisher'=>'O\'Reilly Media, Inc.', + 'price'=>29.67, + 'instock'=>true, + 'rating'=>4, + ), + array( + 'ISBN'=>'0201633612', + 'title'=>'Design Patterns: Elements of Reusable Object-Oriented Software', + 'publisher'=>'Addison-Wesley Professional', + 'price'=>47.04, + 'instock'=>true, + 'rating'=>5, + ), + array( + 'ISBN'=>'0321247140', + 'title'=>'Design Patterns Explained : A New Perspective on Object-Oriented Design', + 'publisher'=>'Addison-Wesley Professional', + 'price'=>37.49, + 'instock'=>true, + 'rating'=>4, + ), + array( + 'ISBN'=>'0201485672', + 'title'=>'Refactoring: Improving the Design of Existing Code', + 'publisher'=>'Addison-Wesley Professional', + 'price'=>47.14, + 'instock'=>true, + 'rating'=>3, + ), + array( + 'ISBN'=>'0321213351', + 'title'=>'Refactoring to Patterns', + 'publisher'=>'Addison-Wesley Professional', + 'price'=>38.49, + 'instock'=>true, + 'rating'=>2, + ), + array( + 'ISBN'=>'0735619670', + 'title'=>'Code Complete', + 'publisher'=>'Microsoft Press', + 'price'=>32.99, + 'instock'=>false, + 'rating'=>4, + ), + array( + 'ISBN'=>'0321278658 ', + 'title'=>'Extreme Programming Explained : Embrace Change', + 'publisher'=>'Addison-Wesley Professional', + 'price'=>34.99, + 'instock'=>true, + 'rating'=>3, + ), + ); + $this->saveData(); + } + } + + protected function saveData() + { + $this->setViewState('Data',$this->_data); + } + + protected function updateBook($isbn,$title,$publisher,$price,$instock,$rating) + { + // In real applications, data should be saved to database using an SQL UPDATE statement + if($this->_data===null) + $this->loadData(); + $updateRow=null; + foreach($this->_data as $index=>$row) + if($row['ISBN']===$isbn) + $updateRow=&$this->_data[$index]; + if($updateRow!==null) + { + $updateRow['title']=$title; + $updateRow['publisher']=$publisher; + $updateRow['price']=TPropertyValue::ensureFloat(ltrim($price,'$')); + $updateRow['instock']=TPropertyValue::ensureBoolean($instock); + $updateRow['rating']=TPropertyValue::ensureInteger($rating); + $this->saveData(); + } + } + + protected function deleteBook($isbn) + { + // In real applications, data should be saved to database using an SQL DELETE statement + if($this->_data===null) + $this->loadData(); + $deleteIndex=-1; + foreach($this->_data as $index=>$row) + if($row['ISBN']===$isbn) + $deleteIndex=$index; + if($deleteIndex>=0) + { + unset($this->_data[$deleteIndex]); + $this->saveData(); + } + } + + public function onLoad($param) + { + parent::onLoad($param); + if(!$this->IsPostBack && !$this->IsCallBack) + { + $this->DataGrid->DataSource=$this->Data; + $this->DataGrid->dataBind(); + } + } + + public function itemCreated($sender,$param) + { + $item=$param->Item; + if($item->ItemType==='EditItem') + { + // set column width of textboxes + $item->BookTitleColumn->TextBox->Columns=40; + $item->PriceColumn->TextBox->Columns=5; + } + if($item->ItemType==='Item' || $item->ItemType==='AlternatingItem' || $item->ItemType==='EditItem') + { + // add an aleart dialog to delete buttons + $item->DeleteColumn->Button->Attributes->onclick='if(!confirm(\'Are you sure?\')) return false;'; + } + } + + public function editItem($sender,$param) + { + $this->DataGrid->EditItemIndex=$param->Item->ItemIndex; + $this->DataGrid->DataSource=$this->Data; + $this->DataGrid->dataBind(); + } + + public function saveItem($sender,$param) + { + $item=$param->Item; + $this->updateBook( + $this->DataGrid->DataKeys[$item->ItemIndex], // ISBN + $item->BookTitleColumn->TextBox->Text, // title + $item->PublisherColumn->TextBox->Text, // publisher + $item->PriceColumn->TextBox->Text, // price + $item->InStockColumn->CheckBox->Checked, // instock + $item->RatingColumn->DropDownList->SelectedValue // rating + ); + $this->DataGrid->EditItemIndex=-1; + $this->DataGrid->DataSource=$this->Data; + $this->DataGrid->dataBind(); + } + + public function cancelItem($sender,$param) + { + $this->DataGrid->EditItemIndex=-1; + $this->DataGrid->DataSource=$this->Data; + $this->DataGrid->dataBind(); + } + + public function deleteItem($sender,$param) + { + $this->deleteBook($this->DataGrid->DataKeys[$param->Item->ItemIndex]); + $this->DataGrid->EditItemIndex=-1; + $this->DataGrid->DataSource=$this->Data; + $this->DataGrid->dataBind(); + } +} + ?>
\ No newline at end of file diff --git a/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveDataGrid/Sample4.php b/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveDataGrid/Sample4.php index eb1a0e5b..46c7dc81 100644 --- a/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveDataGrid/Sample4.php +++ b/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveDataGrid/Sample4.php @@ -1,21 +1,21 @@ -<?php
-
-Prado::using('Application.pages.ActiveControls.Samples.TActiveDataGrid.Sample2');
-
-class Sample4 extends Sample2
-{
- protected function sortData($data,$key)
- {
- $compare = create_function('$a,$b','if ($a["'.$key.'"] == $b["'.$key.'"]) {return 0;}else {return ($a["'.$key.'"] > $b["'.$key.'"]) ? 1 : -1;}');
- usort($data,$compare) ;
- return $data ;
- }
-
- public function sortDataGrid($sender,$param)
- {
- $this->DataGrid->DataSource=$this->sortData($this->Data,$param->SortExpression);
- $this->DataGrid->dataBind();
- }
-}
-
+<?php + +Prado::using('Application.pages.ActiveControls.Samples.TActiveDataGrid.Sample2'); + +class Sample4 extends Sample2 +{ + protected function sortData($data,$key) + { + $compare = create_function('$a,$b','if ($a["'.$key.'"] == $b["'.$key.'"]) {return 0;}else {return ($a["'.$key.'"] > $b["'.$key.'"]) ? 1 : -1;}'); + usort($data,$compare) ; + return $data ; + } + + public function sortDataGrid($sender,$param) + { + $this->DataGrid->DataSource=$this->sortData($this->Data,$param->SortExpression); + $this->DataGrid->dataBind(); + } +} + ?>
\ No newline at end of file diff --git a/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveDataGrid/Sample5.php b/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveDataGrid/Sample5.php index 95bf9a0e..dc4a4dd6 100644 --- a/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveDataGrid/Sample5.php +++ b/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveDataGrid/Sample5.php @@ -1,79 +1,79 @@ -<?php
-
-Prado::using('Application.pages.ActiveControls.Samples.TActiveDataGrid.Sample1');
-
-class Sample5 extends Sample1
-{
-
- public function onLoad($param)
- {
- parent::onLoad($param);
- if(!$this->IsPostback && ! $this->IsCallback)
- {
- $this->DataGrid->DataSource=$this->Data;
- $this->DataGrid->dataBind();
- }
- }
-
- public function changePage($sender,$param)
- {
- $this->DataGrid->CurrentPageIndex=$param->NewPageIndex;
- $this->DataGrid->DataSource=$this->Data;
- $this->DataGrid->dataBind();
- }
-
- public function pagerCreated($sender,$param)
- {
- $param->Pager->Controls->insertAt(0,'Page: ');
- }
-
- public function changePagerPosition($sender,$param)
- {
- $top=$sender->Items[0]->Selected;
- $bottom=$sender->Items[1]->Selected;
- if($top && $bottom)
- $position='TopAndBottom';
- else if($top)
- $position='Top';
- else if($bottom)
- $position='Bottom';
- else
- $position='';
- if($position==='')
- $this->DataGrid->PagerStyle->Visible=false;
- else
- {
- $this->DataGrid->PagerStyle->Position=$position;
- $this->DataGrid->PagerStyle->Visible=true;
- }
- }
-
- public function useNumericPager($sender,$param)
- {
- $this->DataGrid->PagerStyle->Mode='Numeric';
- $this->DataGrid->PagerStyle->NextPageText=$this->NextPageText->Text;
- $this->DataGrid->PagerStyle->PrevPageText=$this->PrevPageText->Text;
- $this->DataGrid->PagerStyle->PageButtonCount=$this->PageButtonCount->Text;
- $this->DataGrid->DataSource=$this->Data;
- $this->DataGrid->dataBind();
- }
-
- public function useNextPrevPager($sender,$param)
- {
- $this->DataGrid->PagerStyle->Mode='NextPrev';
- $this->DataGrid->PagerStyle->NextPageText=$this->NextPageText->Text;
- $this->DataGrid->PagerStyle->PrevPageText=$this->PrevPageText->Text;
- $this->DataGrid->DataSource=$this->Data;
- $this->DataGrid->dataBind();
- }
-
- public function changePageSize($sender,$param)
- {
- $this->DataGrid->PageSize=TPropertyValue::ensureInteger($this->PageSize->Text);
- $this->DataGrid->CurrentPageIndex=0;
- $this->DataGrid->DataSource=$this->Data;
- $this->DataGrid->dataBind();
- }
-}
-
+<?php + +Prado::using('Application.pages.ActiveControls.Samples.TActiveDataGrid.Sample1'); + +class Sample5 extends Sample1 +{ + + public function onLoad($param) + { + parent::onLoad($param); + if(!$this->IsPostback && ! $this->IsCallback) + { + $this->DataGrid->DataSource=$this->Data; + $this->DataGrid->dataBind(); + } + } + + public function changePage($sender,$param) + { + $this->DataGrid->CurrentPageIndex=$param->NewPageIndex; + $this->DataGrid->DataSource=$this->Data; + $this->DataGrid->dataBind(); + } + + public function pagerCreated($sender,$param) + { + $param->Pager->Controls->insertAt(0,'Page: '); + } + + public function changePagerPosition($sender,$param) + { + $top=$sender->Items[0]->Selected; + $bottom=$sender->Items[1]->Selected; + if($top && $bottom) + $position='TopAndBottom'; + else if($top) + $position='Top'; + else if($bottom) + $position='Bottom'; + else + $position=''; + if($position==='') + $this->DataGrid->PagerStyle->Visible=false; + else + { + $this->DataGrid->PagerStyle->Position=$position; + $this->DataGrid->PagerStyle->Visible=true; + } + } + + public function useNumericPager($sender,$param) + { + $this->DataGrid->PagerStyle->Mode='Numeric'; + $this->DataGrid->PagerStyle->NextPageText=$this->NextPageText->Text; + $this->DataGrid->PagerStyle->PrevPageText=$this->PrevPageText->Text; + $this->DataGrid->PagerStyle->PageButtonCount=$this->PageButtonCount->Text; + $this->DataGrid->DataSource=$this->Data; + $this->DataGrid->dataBind(); + } + + public function useNextPrevPager($sender,$param) + { + $this->DataGrid->PagerStyle->Mode='NextPrev'; + $this->DataGrid->PagerStyle->NextPageText=$this->NextPageText->Text; + $this->DataGrid->PagerStyle->PrevPageText=$this->PrevPageText->Text; + $this->DataGrid->DataSource=$this->Data; + $this->DataGrid->dataBind(); + } + + public function changePageSize($sender,$param) + { + $this->DataGrid->PageSize=TPropertyValue::ensureInteger($this->PageSize->Text); + $this->DataGrid->CurrentPageIndex=0; + $this->DataGrid->DataSource=$this->Data; + $this->DataGrid->dataBind(); + } +} + ?>
\ No newline at end of file diff --git a/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveDataList/Home.php b/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveDataList/Home.php index c62a239d..b77fe63c 100644 --- a/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveDataList/Home.php +++ b/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveDataList/Home.php @@ -1,132 +1,132 @@ -<?php
-
-class Home extends TPage
-{
- private $_data=null;
-
- protected function getData()
- {
- if($this->_data===null)
- $this->loadData();
- return $this->_data;
- }
-
- protected function loadData()
- {
- // We use viewstate keep track of data.
- // In real applications, data should come from database using an SQL SELECT statement.
- // In the following tabular data, field 'id' is the primary key.
- // All update and delete operations should come with an 'id' value in order to go through.
- if(($this->_data=$this->getViewState('Data',null))===null)
- {
- $this->_data=array(
- array('id'=>'ITN001','name'=>'Motherboard','quantity'=>1,'price'=>100.00,'imported'=>true),
- array('id'=>'ITN002','name'=>'CPU','quantity'=>1,'price'=>150.00,'imported'=>true),
- array('id'=>'ITN003','name'=>'Harddrive','quantity'=>2,'price'=>80.00,'imported'=>false),
- array('id'=>'ITN004','name'=>'Sound card','quantity'=>1,'price'=>40.00,'imported'=>false),
- array('id'=>'ITN005','name'=>'Video card','quantity'=>1,'price'=>150.00,'imported'=>true),
- array('id'=>'ITN006','name'=>'Keyboard','quantity'=>1,'price'=>20.00,'imported'=>true),
- array('id'=>'ITN007','name'=>'Monitor','quantity'=>2,'price'=>300.00,'imported'=>false),
- );
- $this->saveData();
- }
- }
-
- protected function saveData()
- {
- $this->setViewState('Data',$this->_data);
- }
-
- protected function updateProduct($id,$name,$quantity,$price,$imported)
- {
- // In real applications, data should be saved to database using an SQL UPDATE statement
- if($this->_data===null)
- $this->loadData();
- $updateRow=null;
- foreach($this->_data as $index=>$row)
- if($row['id']===$id)
- $updateRow=&$this->_data[$index];
- if($updateRow!==null)
- {
- $updateRow['name']=$name;
- $updateRow['quantity']=TPropertyValue::ensureInteger($quantity);
- $updateRow['price']=TPropertyValue::ensureFloat($price);
- $updateRow['imported']=TPropertyValue::ensureBoolean($imported);
- $this->saveData();
- }
- }
-
- protected function deleteProduct($id)
- {
- // In real applications, data should be saved to database using an SQL DELETE statement
- if($this->_data===null)
- $this->loadData();
- $deleteIndex=-1;
- foreach($this->_data as $index=>$row)
- if($row['id']===$id)
- $deleteIndex=$index;
- if($deleteIndex>=0)
- {
- unset($this->_data[$deleteIndex]);
- $this->saveData();
- }
- }
-
- public function onLoad($param)
- {
- parent::onLoad($param);
- if(!$this->IsPostBack)
- {
- $this->DataList->DataSource=$this->Data;
- $this->DataList->dataBind();
- }
- }
-
- public function editItem($sender,$param)
- {
- $this->DataList->SelectedItemIndex=-1;
- $this->DataList->EditItemIndex=$param->Item->ItemIndex;
- $this->DataList->DataSource=$this->Data;
- $this->DataList->dataBind();
- }
-
- public function cancelItem($sender,$param)
- {
- $this->DataList->SelectedItemIndex=-1;
- $this->DataList->EditItemIndex=-1;
- $this->DataList->DataSource=$this->Data;
- $this->DataList->dataBind();
- }
-
- public function updateItem($sender,$param)
- {
- $item=$param->Item;
- $this->updateProduct(
- $this->DataList->DataKeys[$item->ItemIndex],
- $item->ProductName->Text,
- $item->ProductQuantity->Text,
- $item->ProductPrice->Text,
- $item->ProductImported->Checked);
- $this->DataList->EditItemIndex=-1;
- $this->DataList->DataSource=$this->Data;
- $this->DataList->dataBind();
- }
-
- public function deleteItem($sender,$param)
- {
- $this->deleteProduct($this->DataList->DataKeys[$param->Item->ItemIndex]);
- $this->DataList->SelectedItemIndex=-1;
- $this->DataList->EditItemIndex=-1;
- $this->DataList->DataSource=$this->Data;
- $this->DataList->dataBind();
- }
-
- public function selectItem($sender,$param)
- {
- $this->DataList->EditItemIndex=-1;
- $this->DataList->DataSource=$this->Data;
- $this->DataList->dataBind();
- }
-}
-
+<?php + +class Home extends TPage +{ + private $_data=null; + + protected function getData() + { + if($this->_data===null) + $this->loadData(); + return $this->_data; + } + + protected function loadData() + { + // We use viewstate keep track of data. + // In real applications, data should come from database using an SQL SELECT statement. + // In the following tabular data, field 'id' is the primary key. + // All update and delete operations should come with an 'id' value in order to go through. + if(($this->_data=$this->getViewState('Data',null))===null) + { + $this->_data=array( + array('id'=>'ITN001','name'=>'Motherboard','quantity'=>1,'price'=>100.00,'imported'=>true), + array('id'=>'ITN002','name'=>'CPU','quantity'=>1,'price'=>150.00,'imported'=>true), + array('id'=>'ITN003','name'=>'Harddrive','quantity'=>2,'price'=>80.00,'imported'=>false), + array('id'=>'ITN004','name'=>'Sound card','quantity'=>1,'price'=>40.00,'imported'=>false), + array('id'=>'ITN005','name'=>'Video card','quantity'=>1,'price'=>150.00,'imported'=>true), + array('id'=>'ITN006','name'=>'Keyboard','quantity'=>1,'price'=>20.00,'imported'=>true), + array('id'=>'ITN007','name'=>'Monitor','quantity'=>2,'price'=>300.00,'imported'=>false), + ); + $this->saveData(); + } + } + + protected function saveData() + { + $this->setViewState('Data',$this->_data); + } + + protected function updateProduct($id,$name,$quantity,$price,$imported) + { + // In real applications, data should be saved to database using an SQL UPDATE statement + if($this->_data===null) + $this->loadData(); + $updateRow=null; + foreach($this->_data as $index=>$row) + if($row['id']===$id) + $updateRow=&$this->_data[$index]; + if($updateRow!==null) + { + $updateRow['name']=$name; + $updateRow['quantity']=TPropertyValue::ensureInteger($quantity); + $updateRow['price']=TPropertyValue::ensureFloat($price); + $updateRow['imported']=TPropertyValue::ensureBoolean($imported); + $this->saveData(); + } + } + + protected function deleteProduct($id) + { + // In real applications, data should be saved to database using an SQL DELETE statement + if($this->_data===null) + $this->loadData(); + $deleteIndex=-1; + foreach($this->_data as $index=>$row) + if($row['id']===$id) + $deleteIndex=$index; + if($deleteIndex>=0) + { + unset($this->_data[$deleteIndex]); + $this->saveData(); + } + } + + public function onLoad($param) + { + parent::onLoad($param); + if(!$this->IsPostBack) + { + $this->DataList->DataSource=$this->Data; + $this->DataList->dataBind(); + } + } + + public function editItem($sender,$param) + { + $this->DataList->SelectedItemIndex=-1; + $this->DataList->EditItemIndex=$param->Item->ItemIndex; + $this->DataList->DataSource=$this->Data; + $this->DataList->dataBind(); + } + + public function cancelItem($sender,$param) + { + $this->DataList->SelectedItemIndex=-1; + $this->DataList->EditItemIndex=-1; + $this->DataList->DataSource=$this->Data; + $this->DataList->dataBind(); + } + + public function updateItem($sender,$param) + { + $item=$param->Item; + $this->updateProduct( + $this->DataList->DataKeys[$item->ItemIndex], + $item->ProductName->Text, + $item->ProductQuantity->Text, + $item->ProductPrice->Text, + $item->ProductImported->Checked); + $this->DataList->EditItemIndex=-1; + $this->DataList->DataSource=$this->Data; + $this->DataList->dataBind(); + } + + public function deleteItem($sender,$param) + { + $this->deleteProduct($this->DataList->DataKeys[$param->Item->ItemIndex]); + $this->DataList->SelectedItemIndex=-1; + $this->DataList->EditItemIndex=-1; + $this->DataList->DataSource=$this->Data; + $this->DataList->dataBind(); + } + + public function selectItem($sender,$param) + { + $this->DataList->EditItemIndex=-1; + $this->DataList->DataSource=$this->Data; + $this->DataList->dataBind(); + } +} + ?>
\ No newline at end of file diff --git a/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveDropDownList/Home.php b/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveDropDownList/Home.php index 0ba728c6..5b16af2c 100644 --- a/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveDropDownList/Home.php +++ b/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveDropDownList/Home.php @@ -1,60 +1,60 @@ -<?php
-
-class Home extends TPage
-{
- public function onLoad($param)
- {
- parent::onLoad($param);
- if(!$this->IsPostBack && !$this->IsCallback)
- {
- $this->resetClicked(null,null);
- }
- }
-
- protected function collectSelectionResult($input,$output)
- {
- $indices=$input->SelectedIndices;
- $result='';
- foreach($indices as $index)
- {
- $item=$input->Items[$index];
- $result.="(Index: $index, Value: $item->Value, Text: $item->Text)";
- }
- if($result==='')
- $output->Text='Your selection is empty.';
- else
- $output->Text='Your selection is: '.$result;
- }
-
- public function selectionChanged($sender,$param)
- {
- $this->collectSelectionResult($sender,$this->SelectionResult);
- }
-
- public function buttonClicked($sender, $param)
- {
- $data=array();
- for($i = 0; $i <= $this->ddl1->Items->Count; $i++)
- $data[$i]="Item number #".$i;
- $this->ddl1->DataSource=$data;
- $this->ddl1->dataBind();
- $this->label1->Text="Total ".count($data)." items";
- }
-
- public function resetClicked($sender, $param)
- {
- $data=array('item 1','item 2','item 3','item 4');
- $this->ddl2->DataSource=$data;
- $this->ddl2->dataBind();
- $this->label2->Text="DropDownList has been reset";
- }
-
- public function clearClicked($sender, $param)
- {
- $this->ddl2->DataSource=array();
- $this->ddl2->dataBind();
- $this->label2->Text="DropDownList cleared";
- }
-}
-
+<?php + +class Home extends TPage +{ + public function onLoad($param) + { + parent::onLoad($param); + if(!$this->IsPostBack && !$this->IsCallback) + { + $this->resetClicked(null,null); + } + } + + protected function collectSelectionResult($input,$output) + { + $indices=$input->SelectedIndices; + $result=''; + foreach($indices as $index) + { + $item=$input->Items[$index]; + $result.="(Index: $index, Value: $item->Value, Text: $item->Text)"; + } + if($result==='') + $output->Text='Your selection is empty.'; + else + $output->Text='Your selection is: '.$result; + } + + public function selectionChanged($sender,$param) + { + $this->collectSelectionResult($sender,$this->SelectionResult); + } + + public function buttonClicked($sender, $param) + { + $data=array(); + for($i = 0; $i <= $this->ddl1->Items->Count; $i++) + $data[$i]="Item number #".$i; + $this->ddl1->DataSource=$data; + $this->ddl1->dataBind(); + $this->label1->Text="Total ".count($data)." items"; + } + + public function resetClicked($sender, $param) + { + $data=array('item 1','item 2','item 3','item 4'); + $this->ddl2->DataSource=$data; + $this->ddl2->dataBind(); + $this->label2->Text="DropDownList has been reset"; + } + + public function clearClicked($sender, $param) + { + $this->ddl2->DataSource=array(); + $this->ddl2->dataBind(); + $this->label2->Text="DropDownList cleared"; + } +} + ?>
\ No newline at end of file diff --git a/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveFileUpload/Home.php b/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveFileUpload/Home.php index d5cf990a..29d05a1c 100644 --- a/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveFileUpload/Home.php +++ b/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveFileUpload/Home.php @@ -1,21 +1,21 @@ -<?php
-
-class Home extends TPage
-{
- public function fileUploaded($sender,$param)
- {
- if($sender->HasFile)
- {
- $this->Result->Text="
- You just uploaded a file:
- <br/>
- Name: {$sender->FileName}
- <br/>
- Size: {$sender->FileSize}
- <br/>
- Type: {$sender->FileType}";
- }
- }
-}
-
+<?php + +class Home extends TPage +{ + public function fileUploaded($sender,$param) + { + if($sender->HasFile) + { + $this->Result->Text=" + You just uploaded a file: + <br/> + Name: {$sender->FileName} + <br/> + Size: {$sender->FileSize} + <br/> + Type: {$sender->FileType}"; + } + } +} + ?>
\ No newline at end of file diff --git a/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveHyperLink/Home.php b/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveHyperLink/Home.php index c125d902..45ea1584 100644 --- a/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveHyperLink/Home.php +++ b/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveHyperLink/Home.php @@ -1,26 +1,26 @@ -<?php
-
-class Home extends TPage
-{
- function button1_clicked($sender, $param)
- {
- $this->link1->NavigateUrl = 'http://www.google.com';
- }
-
- function button2_clicked($sender, $param)
- {
- $this->link2->Target = '_self';
- }
-
- function button3_clicked($sender, $param)
- {
- $this->link3->Text = 'PradoSoft.com';
- }
-
- function button4_clicked($sender, $param)
- {
- $img = $this->publishFilePath(dirname(__FILE__).'/hello_world.gif');
- $this->link4->ImageUrl = $img;
- }
-}
+<?php + +class Home extends TPage +{ + function button1_clicked($sender, $param) + { + $this->link1->NavigateUrl = 'http://www.google.com'; + } + + function button2_clicked($sender, $param) + { + $this->link2->Target = '_self'; + } + + function button3_clicked($sender, $param) + { + $this->link3->Text = 'PradoSoft.com'; + } + + function button4_clicked($sender, $param) + { + $img = $this->publishFilePath(dirname(__FILE__).'/hello_world.gif'); + $this->link4->ImageUrl = $img; + } +} ?>
\ No newline at end of file diff --git a/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveImage/Home.php b/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveImage/Home.php index 3628ad0a..6850fb40 100644 --- a/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveImage/Home.php +++ b/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveImage/Home.php @@ -1,17 +1,17 @@ -<?php
-
-// $Id: Home.php 1405 2006-09-10 01:03:56Z wei $
-class Home extends TPage
-{
- public function buttonClicked($sender, $param)
- {
- $this->imageTest->ImageUrl=$this->publishAsset("hello_world.gif");
- }
-
- public function buttonClicked2($sender, $param)
- {
- $this->imageTest->ImageUrl=$this->publishAsset("hello_world2.gif");
- }
-}
-
+<?php + +// $Id: Home.php 1405 2006-09-10 01:03:56Z wei $ +class Home extends TPage +{ + public function buttonClicked($sender, $param) + { + $this->imageTest->ImageUrl=$this->publishAsset("hello_world.gif"); + } + + public function buttonClicked2($sender, $param) + { + $this->imageTest->ImageUrl=$this->publishAsset("hello_world2.gif"); + } +} + ?>
\ No newline at end of file diff --git a/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveImageButton/Home.php b/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveImageButton/Home.php index b1f2c53b..28be10f9 100644 --- a/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveImageButton/Home.php +++ b/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveImageButton/Home.php @@ -1,18 +1,18 @@ -<?php
-
-class Home extends TPage
-{
- public function buttonClicked($sender,$param)
- {
- if($param instanceof TCallbackEventParameter)
- {
- $this->Result2->Text="Callback parameter: $param->CallbackParameter";
- }
- else
- {
- $this->Result->Text="You clicked at ($param->X,$param->Y)";
- }
- }
-}
-
+<?php + +class Home extends TPage +{ + public function buttonClicked($sender,$param) + { + if($param instanceof TCallbackEventParameter) + { + $this->Result2->Text="Callback parameter: $param->CallbackParameter"; + } + else + { + $this->Result->Text="You clicked at ($param->X,$param->Y)"; + } + } +} + ?>
\ No newline at end of file diff --git a/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveLinkButton/Home.php b/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveLinkButton/Home.php index 64e2dede..e929c07b 100644 --- a/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveLinkButton/Home.php +++ b/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveLinkButton/Home.php @@ -1,14 +1,14 @@ -<?php
-
-class Home extends TPage
-{
- public function buttonClicked($sender,$param)
- {
- if($param instanceof TCallbackEventParameter)
- $sender->Text="Callback Parameter: {$param->CallbackParameter}";
- else
- $sender->Text="I'm clicked";
- }
-}
-
+<?php + +class Home extends TPage +{ + public function buttonClicked($sender,$param) + { + if($param instanceof TCallbackEventParameter) + $sender->Text="Callback Parameter: {$param->CallbackParameter}"; + else + $sender->Text="I'm clicked"; + } +} + ?>
\ No newline at end of file diff --git a/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveListBox/Home.php b/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveListBox/Home.php index 795e3eca..509e32ab 100644 --- a/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveListBox/Home.php +++ b/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveListBox/Home.php @@ -1,65 +1,65 @@ -<?php
-
-class Home extends TPage
-{
- public function onLoad($param)
- {
- parent::onLoad($param);
- if(!$this->IsPostBack && !$this->IsCallback)
- {
- $this->resetClicked(null,null);
- }
- }
-
- protected function collectSelectionResult($input,$output)
- {
- $indices=$input->SelectedIndices;
- $result='';
- foreach($indices as $index)
- {
- $item=$input->Items[$index];
- $result.="(Index: $index, Value: $item->Value, Text: $item->Text)";
- }
- if($result==='')
- $output->Text='Your selection is empty.';
- else
- $output->Text='Your selection is: '.$result;
- }
-
- public function selectionChanged($sender,$param)
- {
- $this->collectSelectionResult($sender,$this->SelectionResult);
- }
-
- public function multiSelectionChanged($sender,$param)
- {
- $this->collectSelectionResult($sender,$this->MSelectionResult);
- }
-
- public function buttonClicked($sender, $param)
- {
- $data=array();
- for($i = 0; $i <= $this->box1->Items->Count; $i++)
- $data[$i]="Item number #".$i;
- $this->box1->DataSource=$data;
- $this->box1->dataBind();
- $this->label1->Text="Total ".count($data)." items";
- }
-
- public function resetClicked($sender, $param)
- {
- $data=array('item 1','item 2','item 3','item 4');
- $this->box2->DataSource=$data;
- $this->box2->dataBind();
- $this->label2->Text="ListBox has been reset";
- }
-
- public function clearClicked($sender, $param)
- {
- $this->box2->DataSource=array();
- $this->box2->dataBind();
- $this->label2->Text="ListBox cleared";
- }
-}
-
+<?php + +class Home extends TPage +{ + public function onLoad($param) + { + parent::onLoad($param); + if(!$this->IsPostBack && !$this->IsCallback) + { + $this->resetClicked(null,null); + } + } + + protected function collectSelectionResult($input,$output) + { + $indices=$input->SelectedIndices; + $result=''; + foreach($indices as $index) + { + $item=$input->Items[$index]; + $result.="(Index: $index, Value: $item->Value, Text: $item->Text)"; + } + if($result==='') + $output->Text='Your selection is empty.'; + else + $output->Text='Your selection is: '.$result; + } + + public function selectionChanged($sender,$param) + { + $this->collectSelectionResult($sender,$this->SelectionResult); + } + + public function multiSelectionChanged($sender,$param) + { + $this->collectSelectionResult($sender,$this->MSelectionResult); + } + + public function buttonClicked($sender, $param) + { + $data=array(); + for($i = 0; $i <= $this->box1->Items->Count; $i++) + $data[$i]="Item number #".$i; + $this->box1->DataSource=$data; + $this->box1->dataBind(); + $this->label1->Text="Total ".count($data)." items"; + } + + public function resetClicked($sender, $param) + { + $data=array('item 1','item 2','item 3','item 4'); + $this->box2->DataSource=$data; + $this->box2->dataBind(); + $this->label2->Text="ListBox has been reset"; + } + + public function clearClicked($sender, $param) + { + $this->box2->DataSource=array(); + $this->box2->dataBind(); + $this->label2->Text="ListBox cleared"; + } +} + ?>
\ No newline at end of file diff --git a/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveMultiView/Home.php b/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveMultiView/Home.php index 1a5dbed3..24a240ca 100644 --- a/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveMultiView/Home.php +++ b/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveMultiView/Home.php @@ -1,15 +1,15 @@ -<?php
-
-class Home extends TPage
-{
- public function viewChanged($sender,$param)
- {
- if($this->MultiView->ActiveViewIndex===2)
- {
- $this->Result1->Text="Your text input is: ".$this->Memo->Text;
- $this->Result2->Text="Your color choice is: ".$this->DropDownList->SelectedValue;
- }
- }
-}
-
+<?php + +class Home extends TPage +{ + public function viewChanged($sender,$param) + { + if($this->MultiView->ActiveViewIndex===2) + { + $this->Result1->Text="Your text input is: ".$this->Memo->Text; + $this->Result2->Text="Your color choice is: ".$this->DropDownList->SelectedValue; + } + } +} + ?>
\ No newline at end of file diff --git a/demos/quickstart/protected/pages/ActiveControls/Samples/TActivePanel/Home.php b/demos/quickstart/protected/pages/ActiveControls/Samples/TActivePanel/Home.php index ae174f59..362fdebe 100644 --- a/demos/quickstart/protected/pages/ActiveControls/Samples/TActivePanel/Home.php +++ b/demos/quickstart/protected/pages/ActiveControls/Samples/TActivePanel/Home.php @@ -1,21 +1,21 @@ -<?php
-
-class Home extends TPage
-{
- public function buttonClicked($sender,$param)
- {
- $this->check1->Checked = !$this->check1->Checked;
- if($this->txt1->Text=="")
- $this->txt1->Text="changes happens";
- else
- $this->txt1->Text="";
- if($this->label1->Text=="")
- $this->label1->Text="label has changed, too";
- else
- $this->label1->Text="";
-
- $this->panel1->render($param->NewWriter);
- }
-}
-
+<?php + +class Home extends TPage +{ + public function buttonClicked($sender,$param) + { + $this->check1->Checked = !$this->check1->Checked; + if($this->txt1->Text=="") + $this->txt1->Text="changes happens"; + else + $this->txt1->Text=""; + if($this->label1->Text=="") + $this->label1->Text="label has changed, too"; + else + $this->label1->Text=""; + + $this->panel1->render($param->NewWriter); + } +} + ?>
\ No newline at end of file diff --git a/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveRadioButton/Home.php b/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveRadioButton/Home.php index 034d2fcc..a0c2af32 100644 --- a/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveRadioButton/Home.php +++ b/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveRadioButton/Home.php @@ -1,27 +1,27 @@ -<?php
-
-class Home extends TPage
-{
- public function radiobuttonClicked($sender,$param)
- {
- $sender->Text="I'm clicked";
- }
-
- public function selectRadioButton($sender,$param)
- {
- $selection='';
- if($this->Radio1->Checked)
- $selection.='1';
- if($this->Radio2->Checked)
- $selection.='2';
- if($this->Radio3->Checked)
- $selection.='3';
- if($this->Radio4->Checked)
- $selection.='4';
- if($selection==='')
- $selection='empty';
- $this->Result->Text='Your selection is '.$selection;
- }
-}
-
+<?php + +class Home extends TPage +{ + public function radiobuttonClicked($sender,$param) + { + $sender->Text="I'm clicked"; + } + + public function selectRadioButton($sender,$param) + { + $selection=''; + if($this->Radio1->Checked) + $selection.='1'; + if($this->Radio2->Checked) + $selection.='2'; + if($this->Radio3->Checked) + $selection.='3'; + if($this->Radio4->Checked) + $selection.='4'; + if($selection==='') + $selection='empty'; + $this->Result->Text='Your selection is '.$selection; + } +} + ?>
\ No newline at end of file diff --git a/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveRadioButtonList/Home.php b/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveRadioButtonList/Home.php index dfa52ce4..1033837c 100644 --- a/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveRadioButtonList/Home.php +++ b/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveRadioButtonList/Home.php @@ -1,26 +1,26 @@ -<?php
-
-class Home extends TPage
-{
- protected function collectSelectionResult($input,$output)
- {
- $indices=$input->SelectedIndices;
- $result='';
- foreach($indices as $index)
- {
- $item=$input->Items[$index];
- $result.="(Index: $index, Value: $item->Value, Text: $item->Text)";
- }
- if($result==='')
- $output->Text='Your selection is empty.';
- else
- $output->Text='Your selection is: '.$result;
- }
-
- public function selectionChanged($sender,$param)
- {
- $this->collectSelectionResult($this->RadioButtonList,$this->SelectionResult);
- }
-}
-
+<?php + +class Home extends TPage +{ + protected function collectSelectionResult($input,$output) + { + $indices=$input->SelectedIndices; + $result=''; + foreach($indices as $index) + { + $item=$input->Items[$index]; + $result.="(Index: $index, Value: $item->Value, Text: $item->Text)"; + } + if($result==='') + $output->Text='Your selection is empty.'; + else + $output->Text='Your selection is: '.$result; + } + + public function selectionChanged($sender,$param) + { + $this->collectSelectionResult($this->RadioButtonList,$this->SelectionResult); + } +} + ?>
\ No newline at end of file diff --git a/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveRepeater/Home.php b/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveRepeater/Home.php index f7c8d61c..ae765ee1 100644 --- a/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveRepeater/Home.php +++ b/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveRepeater/Home.php @@ -1,79 +1,79 @@ -<?php
-
-class Home 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();
- }
- }
-}
-
+<?php + +class Home 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/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveTableRow/Home.php b/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveTableRow/Home.php index b056eba8..d74160bb 100644 --- a/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveTableRow/Home.php +++ b/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveTableRow/Home.php @@ -1,22 +1,22 @@ -<?php
-
-// $Id: Home.php 1405 2006-09-10 01:03:56Z wei $
-class Home extends TPage
-{
-
- public function clickCell ($sender, $param)
- {
- $sender->Text .= "<br/>Clicked";
- $this->lblResult->Text='You clicked on cell #'.$param->SelectedCellIndex.' with id='.$sender->id;
- $sender->render($param->NewWriter);
- }
-
- public function clickRow ($sender, $param)
- {
- $sender->BackColor="yellow";
- $this->lblResult->Text='You clicked on row #'.$param->SelectedRowIndex.' with id='.$sender->id;
- $sender->render($param->NewWriter);
- }
-}
-
+<?php + +// $Id: Home.php 1405 2006-09-10 01:03:56Z wei $ +class Home extends TPage +{ + + public function clickCell ($sender, $param) + { + $sender->Text .= "<br/>Clicked"; + $this->lblResult->Text='You clicked on cell #'.$param->SelectedCellIndex.' with id='.$sender->id; + $sender->render($param->NewWriter); + } + + public function clickRow ($sender, $param) + { + $sender->BackColor="yellow"; + $this->lblResult->Text='You clicked on row #'.$param->SelectedRowIndex.' with id='.$sender->id; + $sender->render($param->NewWriter); + } +} + ?>
\ No newline at end of file diff --git a/demos/quickstart/protected/pages/ActiveControls/Samples/TAutoComplete/Home.php b/demos/quickstart/protected/pages/ActiveControls/Samples/TAutoComplete/Home.php index ca8a9e59..290995c7 100644 --- a/demos/quickstart/protected/pages/ActiveControls/Samples/TAutoComplete/Home.php +++ b/demos/quickstart/protected/pages/ActiveControls/Samples/TAutoComplete/Home.php @@ -1,34 +1,34 @@ -<?php
-// $Id$
-class Home extends TPage
-{
- public function suggestNames($sender,$param) {
- // Get the token
- $token=$param->getToken();
- // Sender is the Suggestions repeater
- $sender->DataSource=$this->getDummyData($token);
- $sender->dataBind();
- }
-
- public function suggestionSelected1($sender,$param) {
- $id=$sender->Suggestions->DataKeys[ $param->selectedIndex ];
- $this->Selection1->Text='Selected ID: '.$id;
- }
-
- public function suggestionSelected2($sender,$param) {
- $id=$sender->Suggestions->DataKeys[ $param->selectedIndex ];
- $this->Selection2->Text='Selected ID: '.$id;
- }
-
- public function getDummyData($token) {
- // You would look for matches to the given token here
- return array(
- array('id'=>1, 'name'=>'John'),
- array('id'=>2, 'name'=>'Paul'),
- array('id'=>3, 'name'=>'George'),
- array('id'=>4, 'name'=>'Ringo')
- );
- }
-}
-
-?>
+<?php +// $Id$ +class Home extends TPage +{ + public function suggestNames($sender,$param) { + // Get the token + $token=$param->getToken(); + // Sender is the Suggestions repeater + $sender->DataSource=$this->getDummyData($token); + $sender->dataBind(); + } + + public function suggestionSelected1($sender,$param) { + $id=$sender->Suggestions->DataKeys[ $param->selectedIndex ]; + $this->Selection1->Text='Selected ID: '.$id; + } + + public function suggestionSelected2($sender,$param) { + $id=$sender->Suggestions->DataKeys[ $param->selectedIndex ]; + $this->Selection2->Text='Selected ID: '.$id; + } + + public function getDummyData($token) { + // You would look for matches to the given token here + return array( + array('id'=>1, 'name'=>'John'), + array('id'=>2, 'name'=>'Paul'), + array('id'=>3, 'name'=>'George'), + array('id'=>4, 'name'=>'Ringo') + ); + } +} + +?> diff --git a/demos/quickstart/protected/pages/ActiveControls/Samples/TCallbackClientScript/Home.php b/demos/quickstart/protected/pages/ActiveControls/Samples/TCallbackClientScript/Home.php index 500d7987..a8cef26c 100644 --- a/demos/quickstart/protected/pages/ActiveControls/Samples/TCallbackClientScript/Home.php +++ b/demos/quickstart/protected/pages/ActiveControls/Samples/TCallbackClientScript/Home.php @@ -1,29 +1,29 @@ -<?php
-
-// $Id: Home.php -1 $
-class Home extends TPage
-{
- public function buttonCallback ($sender, $param)
- {
- switch($this->radio1->SelectedValue)
- {
- case 1:
- $this->getCallbackClient()->evaluateScript("<script> alert('something'); </script>");
- break;
- case 2:
- $this->getCallbackClient()->check($this->check1, !$this->check1->Checked);
- break;
- case 3:
- $this->getCallbackClient()->hide($this->label1);
- break;
- case 4:
- $this->getCallbackClient()->show($this->label1);
- break;
- case 5:
- $this->getCallbackClient()->focus($this->txt1);
- break;
- }
- }
-}
-
+<?php + +// $Id: Home.php -1 $ +class Home extends TPage +{ + public function buttonCallback ($sender, $param) + { + switch($this->radio1->SelectedValue) + { + case 1: + $this->getCallbackClient()->evaluateScript("<script> alert('something'); </script>"); + break; + case 2: + $this->getCallbackClient()->check($this->check1, !$this->check1->Checked); + break; + case 3: + $this->getCallbackClient()->hide($this->label1); + break; + case 4: + $this->getCallbackClient()->show($this->label1); + break; + case 5: + $this->getCallbackClient()->focus($this->txt1); + break; + } + } +} + ?>
\ No newline at end of file diff --git a/demos/quickstart/protected/pages/ActiveControls/Samples/TCallbackClientSide/Home.php b/demos/quickstart/protected/pages/ActiveControls/Samples/TCallbackClientSide/Home.php index 8dd794fe..f642ccbb 100644 --- a/demos/quickstart/protected/pages/ActiveControls/Samples/TCallbackClientSide/Home.php +++ b/demos/quickstart/protected/pages/ActiveControls/Samples/TCallbackClientSide/Home.php @@ -1,12 +1,12 @@ -<?php
-
-// $Id: Home.php -1 $
-class Home extends TPage
-{
- public function buttonCallback ($sender, $param)
- {
- sleep(5);
- }
-}
-
+<?php + +// $Id: Home.php -1 $ +class Home extends TPage +{ + public function buttonCallback ($sender, $param) + { + sleep(5); + } +} + ?>
\ No newline at end of file diff --git a/demos/quickstart/protected/pages/ActiveControls/Samples/TCallbackOptions/Home.php b/demos/quickstart/protected/pages/ActiveControls/Samples/TCallbackOptions/Home.php index 6f101107..caff7360 100644 --- a/demos/quickstart/protected/pages/ActiveControls/Samples/TCallbackOptions/Home.php +++ b/demos/quickstart/protected/pages/ActiveControls/Samples/TCallbackOptions/Home.php @@ -1,12 +1,12 @@ -<?php
-
-// $Id$
-class Home extends TPage
-{
- public function buttonCallback ($sender, $param)
- {
- sleep(5);
- }
-}
-
+<?php + +// $Id$ +class Home extends TPage +{ + public function buttonCallback ($sender, $param) + { + sleep(5); + } +} + ?>
\ No newline at end of file diff --git a/demos/quickstart/protected/pages/Advanced/Samples/I18N/Home.php b/demos/quickstart/protected/pages/Advanced/Samples/I18N/Home.php index cce1ed4e..634c1773 100644 --- a/demos/quickstart/protected/pages/Advanced/Samples/I18N/Home.php +++ b/demos/quickstart/protected/pages/Advanced/Samples/I18N/Home.php @@ -1,45 +1,45 @@ -<?php
-
-class Home extends TPage
-{
- /**
- * Change the globalization culture using value from request "lang" parameter.
- */
- public function __construct()
- {
- parent::__construct();
- $lang = $this->Request['lang'];
- $info = new CultureInfo();
- if($info->validCulture($lang)) //only valid lang is permitted
- $this->getApplication()->getGlobalization()->setCulture($lang);
- }
-
- /**
- * Initialize the page with some arbituary data.
- * @param TEventParameter event parameter.
- */
- public function onLoad($param)
- {
- parent::onLoad($param);
- $time1 = $this->Time1;
- $time1->Value = time();
-
- $number2 = $this->Number2;
- $number2->Value = 46412.416;
-
- $this->dataBind();
- }
-
- /**
- * Get the localized current culture name.
- * @return string localized curreny culture name.
- */
- public function getCurrentCulture()
- {
- $culture = $this->getApplication()->getGlobalization()->getCulture();
- $cultureInfo = new CultureInfo($culture);
- return $cultureInfo->getNativeName();
- }
-}
-
+<?php + +class Home extends TPage +{ + /** + * Change the globalization culture using value from request "lang" parameter. + */ + public function __construct() + { + parent::__construct(); + $lang = $this->Request['lang']; + $info = new CultureInfo(); + if($info->validCulture($lang)) //only valid lang is permitted + $this->getApplication()->getGlobalization()->setCulture($lang); + } + + /** + * Initialize the page with some arbituary data. + * @param TEventParameter event parameter. + */ + public function onLoad($param) + { + parent::onLoad($param); + $time1 = $this->Time1; + $time1->Value = time(); + + $number2 = $this->Number2; + $number2->Value = 46412.416; + + $this->dataBind(); + } + + /** + * Get the localized current culture name. + * @return string localized curreny culture name. + */ + public function getCurrentCulture() + { + $culture = $this->getApplication()->getGlobalization()->getCulture(); + $cultureInfo = new CultureInfo($culture); + return $cultureInfo->getNativeName(); + } +} + ?>
\ No newline at end of file diff --git a/demos/quickstart/protected/pages/Advanced/Samples/I18N/LanguageList.php b/demos/quickstart/protected/pages/Advanced/Samples/I18N/LanguageList.php index d3db187d..bdeb5039 100644 --- a/demos/quickstart/protected/pages/Advanced/Samples/I18N/LanguageList.php +++ b/demos/quickstart/protected/pages/Advanced/Samples/I18N/LanguageList.php @@ -1,19 +1,19 @@ -<?php
-/**
- * Language List
- * @author $Author: weizhuo $
- * @version $Id$
- * @package prado.examples
- */
-
-/**
- *
- * @author $Author: weizhuo $
- * @version $Id$
- */
-class LanguageList extends TTemplateControl
-{
-
-}
-
+<?php +/** + * Language List + * @author $Author: weizhuo $ + * @version $Id$ + * @package prado.examples + */ + +/** + * + * @author $Author: weizhuo $ + * @version $Id$ + */ +class LanguageList extends TTemplateControl +{ + +} + ?>
\ No newline at end of file diff --git a/demos/quickstart/protected/pages/Controls/Samples/LabeledTextBox1/Home.php b/demos/quickstart/protected/pages/Controls/Samples/LabeledTextBox1/Home.php index 2309bd88..cfc01a31 100644 --- a/demos/quickstart/protected/pages/Controls/Samples/LabeledTextBox1/Home.php +++ b/demos/quickstart/protected/pages/Controls/Samples/LabeledTextBox1/Home.php @@ -1,13 +1,13 @@ -<?php
-
-Prado::using('Application.pages.Controls.Samples.LabeledTextBox1.LabeledTextBox');
-
-class Home extends TPage
-{
- public function buttonClicked($sender,$param)
- {
- $sender->Text=$this->Input->TextBox->Text;
- }
-}
-
+<?php + +Prado::using('Application.pages.Controls.Samples.LabeledTextBox1.LabeledTextBox'); + +class Home extends TPage +{ + public function buttonClicked($sender,$param) + { + $sender->Text=$this->Input->TextBox->Text; + } +} + ?>
\ No newline at end of file diff --git a/demos/quickstart/protected/pages/Controls/Samples/LabeledTextBox1/LabeledTextBox.php b/demos/quickstart/protected/pages/Controls/Samples/LabeledTextBox1/LabeledTextBox.php index 999639d7..0c374b72 100644 --- a/demos/quickstart/protected/pages/Controls/Samples/LabeledTextBox1/LabeledTextBox.php +++ b/demos/quickstart/protected/pages/Controls/Samples/LabeledTextBox1/LabeledTextBox.php @@ -1,18 +1,18 @@ -<?php
-
-class LabeledTextBox extends TTemplateControl
-{
- public function getLabel()
- {
- $this->ensureChildControls();
- return $this->getRegisteredObject('Label');
- }
-
- public function getTextBox()
- {
- $this->ensureChildControls();
- return $this->getRegisteredObject('TextBox');
- }
-}
-
+<?php + +class LabeledTextBox extends TTemplateControl +{ + public function getLabel() + { + $this->ensureChildControls(); + return $this->getRegisteredObject('Label'); + } + + public function getTextBox() + { + $this->ensureChildControls(); + return $this->getRegisteredObject('TextBox'); + } +} + ?>
\ No newline at end of file diff --git a/demos/quickstart/protected/pages/Controls/Samples/LabeledTextBox2/Home.php b/demos/quickstart/protected/pages/Controls/Samples/LabeledTextBox2/Home.php index 2b18972d..ae3f9e8b 100644 --- a/demos/quickstart/protected/pages/Controls/Samples/LabeledTextBox2/Home.php +++ b/demos/quickstart/protected/pages/Controls/Samples/LabeledTextBox2/Home.php @@ -1,13 +1,13 @@ -<?php
-
-Prado::using('Application.pages.Controls.Samples.LabeledTextBox2.LabeledTextBox');
-
-class Home extends TPage
-{
- public function buttonClicked($sender,$param)
- {
- $sender->Text=$this->Input->TextBox->Text;
- }
-}
-
+<?php + +Prado::using('Application.pages.Controls.Samples.LabeledTextBox2.LabeledTextBox'); + +class Home extends TPage +{ + public function buttonClicked($sender,$param) + { + $sender->Text=$this->Input->TextBox->Text; + } +} + ?>
\ No newline at end of file diff --git a/demos/quickstart/protected/pages/Controls/Samples/LabeledTextBox2/LabeledTextBox.php b/demos/quickstart/protected/pages/Controls/Samples/LabeledTextBox2/LabeledTextBox.php index fc912003..601cebc6 100644 --- a/demos/quickstart/protected/pages/Controls/Samples/LabeledTextBox2/LabeledTextBox.php +++ b/demos/quickstart/protected/pages/Controls/Samples/LabeledTextBox2/LabeledTextBox.php @@ -1,33 +1,33 @@ -<?php
-
-class LabeledTextBox extends TCompositeControl
-{
- private $_label;
- private $_textbox;
-
- public function createChildControls()
- {
- $this->_label=new TLabel;
- $this->_label->setID('Label');
- $this->getControls()->add($this->_label);
- $this->getControls()->add(' ');
- $this->_textbox=new TTextBox;
- $this->_textbox->setID('TextBox');
- $this->_label->setForControl('TextBox');
- $this->getControls()->add($this->_textbox);
- }
-
- public function getLabel()
- {
- $this->ensureChildControls();
- return $this->_label;
- }
-
- public function getTextBox()
- {
- $this->ensureChildControls();
- return $this->_textbox;
- }
-}
-
+<?php + +class LabeledTextBox extends TCompositeControl +{ + private $_label; + private $_textbox; + + public function createChildControls() + { + $this->_label=new TLabel; + $this->_label->setID('Label'); + $this->getControls()->add($this->_label); + $this->getControls()->add(' '); + $this->_textbox=new TTextBox; + $this->_textbox->setID('TextBox'); + $this->_label->setForControl('TextBox'); + $this->getControls()->add($this->_textbox); + } + + public function getLabel() + { + $this->ensureChildControls(); + return $this->_label; + } + + public function getTextBox() + { + $this->ensureChildControls(); + return $this->_textbox; + } +} + ?>
\ No newline at end of file diff --git a/demos/quickstart/protected/pages/Controls/Samples/ResetValidation/Home.php b/demos/quickstart/protected/pages/Controls/Samples/ResetValidation/Home.php index 88d2dbf2..1c5efbcf 100644 --- a/demos/quickstart/protected/pages/Controls/Samples/ResetValidation/Home.php +++ b/demos/quickstart/protected/pages/Controls/Samples/ResetValidation/Home.php @@ -1,8 +1,8 @@ -<?php
-
-class Home extends TPage
-{
-
-}
-
+<?php + +class Home extends TPage +{ + +} + ?>
\ No newline at end of file diff --git a/demos/quickstart/protected/pages/Controls/Samples/TAccordion/Home.php b/demos/quickstart/protected/pages/Controls/Samples/TAccordion/Home.php index 3da69927..4faaef1c 100644 --- a/demos/quickstart/protected/pages/Controls/Samples/TAccordion/Home.php +++ b/demos/quickstart/protected/pages/Controls/Samples/TAccordion/Home.php @@ -1,17 +1,17 @@ -<?php
-
-class Home extends TPage
-{
- public function onLoad($param)
- {
- parent::onLoad($param);
- $this->lab1->Text="";
- }
-
- public function executeTransaction($sender, $param)
- {
- $this->lab1->Text="executeTransaction ok";
- }
-}
-
+<?php + +class Home extends TPage +{ + public function onLoad($param) + { + parent::onLoad($param); + $this->lab1->Text=""; + } + + public function executeTransaction($sender, $param) + { + $this->lab1->Text="executeTransaction ok"; + } +} + ?>
\ No newline at end of file diff --git a/demos/quickstart/protected/pages/Controls/Samples/TBulletedList/Home.php b/demos/quickstart/protected/pages/Controls/Samples/TBulletedList/Home.php index d3e04787..93c947fe 100644 --- a/demos/quickstart/protected/pages/Controls/Samples/TBulletedList/Home.php +++ b/demos/quickstart/protected/pages/Controls/Samples/TBulletedList/Home.php @@ -1,12 +1,12 @@ -<?php
-
-class Home extends TPage
-{
- public function buttonClicked($sender,$param)
- {
- $item=$sender->Items[$param->Index];
- $this->Result->Text="You clicked $item->Text : $item->Value.";
- }
-}
-
+<?php + +class Home extends TPage +{ + public function buttonClicked($sender,$param) + { + $item=$sender->Items[$param->Index]; + $this->Result->Text="You clicked $item->Text : $item->Value."; + } +} + ?>
\ No newline at end of file diff --git a/demos/quickstart/protected/pages/Controls/Samples/TButton/Home.php b/demos/quickstart/protected/pages/Controls/Samples/TButton/Home.php index f18072f2..3711ca46 100644 --- a/demos/quickstart/protected/pages/Controls/Samples/TButton/Home.php +++ b/demos/quickstart/protected/pages/Controls/Samples/TButton/Home.php @@ -1,14 +1,14 @@ -<?php
-
-class Home extends TPage
-{
- public function buttonClicked($sender,$param)
- {
- if($param instanceof TCommandEventParameter)
- $sender->Text="Name: {$param->CommandName}, Param: {$param->CommandParameter}";
- else
- $sender->Text="I'm clicked";
- }
-}
-
+<?php + +class Home extends TPage +{ + public function buttonClicked($sender,$param) + { + if($param instanceof TCommandEventParameter) + $sender->Text="Name: {$param->CommandName}, Param: {$param->CommandParameter}"; + else + $sender->Text="I'm clicked"; + } +} + ?>
\ No newline at end of file diff --git a/demos/quickstart/protected/pages/Controls/Samples/TCaptcha/Home.php b/demos/quickstart/protected/pages/Controls/Samples/TCaptcha/Home.php index 6965bbbd..c88b9378 100644 --- a/demos/quickstart/protected/pages/Controls/Samples/TCaptcha/Home.php +++ b/demos/quickstart/protected/pages/Controls/Samples/TCaptcha/Home.php @@ -1,27 +1,27 @@ -<?php
-
-class Home extends TPage
-{
- public function onInit($param)
- {
- if(!$this->IsPostBack)
- {
- $this->CaptchaList->DataSource=range(0,63);
- $this->CaptchaList->dataBind();
- }
- }
-
- public function regenerateToken($sender,$param)
- {
- $this->Captcha->regenerateToken();
- $this->SubmitButton->Text="Submit";
- }
-
- public function buttonClicked($sender,$param)
- {
- if($this->IsValid)
- $sender->Text="You passed!";
- }
-}
-
+<?php + +class Home extends TPage +{ + public function onInit($param) + { + if(!$this->IsPostBack) + { + $this->CaptchaList->DataSource=range(0,63); + $this->CaptchaList->dataBind(); + } + } + + public function regenerateToken($sender,$param) + { + $this->Captcha->regenerateToken(); + $this->SubmitButton->Text="Submit"; + } + + public function buttonClicked($sender,$param) + { + if($this->IsValid) + $sender->Text="You passed!"; + } +} + ?>
\ No newline at end of file diff --git a/demos/quickstart/protected/pages/Controls/Samples/TCheckBox/Home.php b/demos/quickstart/protected/pages/Controls/Samples/TCheckBox/Home.php index 37eae19b..89fb6852 100644 --- a/demos/quickstart/protected/pages/Controls/Samples/TCheckBox/Home.php +++ b/demos/quickstart/protected/pages/Controls/Samples/TCheckBox/Home.php @@ -1,11 +1,11 @@ -<?php
-
-class Home extends TPage
-{
- public function checkboxClicked($sender,$param)
- {
- $sender->Text="I'm clicked";
- }
-}
-
+<?php + +class Home extends TPage +{ + public function checkboxClicked($sender,$param) + { + $sender->Text="I'm clicked"; + } +} + ?>
\ No newline at end of file diff --git a/demos/quickstart/protected/pages/Controls/Samples/TCheckBoxList/Home.php b/demos/quickstart/protected/pages/Controls/Samples/TCheckBoxList/Home.php index 08c6f3ca..ac7ca8bc 100644 --- a/demos/quickstart/protected/pages/Controls/Samples/TCheckBoxList/Home.php +++ b/demos/quickstart/protected/pages/Controls/Samples/TCheckBoxList/Home.php @@ -1,70 +1,70 @@ -<?php
-
-class Home extends TPage
-{
- public function onLoad($param)
- {
- parent::onLoad($param);
- if(!$this->IsPostBack)
- {
- $data=array('item 1','item 2','item 3','item 4');
- $this->DBCheckBoxList1->DataSource=$data;
- $this->DBCheckBoxList1->dataBind();
-
- $data=array('key 1'=>'item 1','key 2'=>'item 2',
- 'key 3'=>'item 3','key 4'=>'item 4');
- $this->DBCheckBoxList2->DataSource=$data;
- $this->DBCheckBoxList2->dataBind();
-
- $data=array(
- array('id'=>'001','name'=>'John','age'=>31),
- array('id'=>'002','name'=>'Mary','age'=>30),
- array('id'=>'003','name'=>'Cary','age'=>20));
- $this->DBCheckBoxList3->DataSource=$data;
- $this->DBCheckBoxList3->dataBind();
- }
- }
-
- protected function collectSelectionResult($input,$output)
- {
- $indices=$input->SelectedIndices;
- $result='';
- foreach($indices as $index)
- {
- $item=$input->Items[$index];
- $result.="(Index: $index, Value: $item->Value, Text: $item->Text)";
- }
- if($result==='')
- $output->Text='Your selection is empty.';
- else
- $output->Text='Your selection is: '.$result;
- }
-
- public function buttonClicked($sender,$param)
- {
- $this->collectSelectionResult($this->CheckBoxList,$this->SelectionResult);
- }
-
- public function selectionChanged($sender,$param)
- {
- $this->collectSelectionResult($sender,$this->SelectionResult2);
- }
-
- public function DBCheckBoxList1Changed($sender,$param)
- {
- $this->collectSelectionResult($sender,$this->DBCheckBoxList1Result);
- }
-
- public function DBCheckBoxList2Changed($sender,$param)
- {
- $this->collectSelectionResult($sender,$this->DBCheckBoxList2Result);
- }
-
- public function DBCheckBoxList3Changed($sender,$param)
- {
- $this->collectSelectionResult($sender,$this->DBCheckBoxList3Result);
- }
-
-}
-
+<?php + +class Home extends TPage +{ + public function onLoad($param) + { + parent::onLoad($param); + if(!$this->IsPostBack) + { + $data=array('item 1','item 2','item 3','item 4'); + $this->DBCheckBoxList1->DataSource=$data; + $this->DBCheckBoxList1->dataBind(); + + $data=array('key 1'=>'item 1','key 2'=>'item 2', + 'key 3'=>'item 3','key 4'=>'item 4'); + $this->DBCheckBoxList2->DataSource=$data; + $this->DBCheckBoxList2->dataBind(); + + $data=array( + array('id'=>'001','name'=>'John','age'=>31), + array('id'=>'002','name'=>'Mary','age'=>30), + array('id'=>'003','name'=>'Cary','age'=>20)); + $this->DBCheckBoxList3->DataSource=$data; + $this->DBCheckBoxList3->dataBind(); + } + } + + protected function collectSelectionResult($input,$output) + { + $indices=$input->SelectedIndices; + $result=''; + foreach($indices as $index) + { + $item=$input->Items[$index]; + $result.="(Index: $index, Value: $item->Value, Text: $item->Text)"; + } + if($result==='') + $output->Text='Your selection is empty.'; + else + $output->Text='Your selection is: '.$result; + } + + public function buttonClicked($sender,$param) + { + $this->collectSelectionResult($this->CheckBoxList,$this->SelectionResult); + } + + public function selectionChanged($sender,$param) + { + $this->collectSelectionResult($sender,$this->SelectionResult2); + } + + public function DBCheckBoxList1Changed($sender,$param) + { + $this->collectSelectionResult($sender,$this->DBCheckBoxList1Result); + } + + public function DBCheckBoxList2Changed($sender,$param) + { + $this->collectSelectionResult($sender,$this->DBCheckBoxList2Result); + } + + public function DBCheckBoxList3Changed($sender,$param) + { + $this->collectSelectionResult($sender,$this->DBCheckBoxList3Result); + } + +} + ?>
\ No newline at end of file diff --git a/demos/quickstart/protected/pages/Controls/Samples/TClientSideValidator/Home.php b/demos/quickstart/protected/pages/Controls/Samples/TClientSideValidator/Home.php index d6dded08..cccbf845 100644 --- a/demos/quickstart/protected/pages/Controls/Samples/TClientSideValidator/Home.php +++ b/demos/quickstart/protected/pages/Controls/Samples/TClientSideValidator/Home.php @@ -1,17 +1,17 @@ -<?php
-
-class Home extends TPage
-{
- function check_validate($sender, $params)
- {
- $sender->enabled = $this->check1->checked;
- }
-
- function onPreRender($param)
- {
- //always re-enable the validator2 so as to display the client-side validator
- $this->validator2->enabled=true;
- }
-}
-
+<?php + +class Home extends TPage +{ + function check_validate($sender, $params) + { + $sender->enabled = $this->check1->checked; + } + + function onPreRender($param) + { + //always re-enable the validator2 so as to display the client-side validator + $this->validator2->enabled=true; + } +} + ?>
\ No newline at end of file diff --git a/demos/quickstart/protected/pages/Controls/Samples/TCompareValidator/Home.php b/demos/quickstart/protected/pages/Controls/Samples/TCompareValidator/Home.php index 88d2dbf2..1c5efbcf 100644 --- a/demos/quickstart/protected/pages/Controls/Samples/TCompareValidator/Home.php +++ b/demos/quickstart/protected/pages/Controls/Samples/TCompareValidator/Home.php @@ -1,8 +1,8 @@ -<?php
-
-class Home extends TPage
-{
-
-}
-
+<?php + +class Home extends TPage +{ + +} + ?>
\ No newline at end of file diff --git a/demos/quickstart/protected/pages/Controls/Samples/TConditional/Home.php b/demos/quickstart/protected/pages/Controls/Samples/TConditional/Home.php index badbca73..b03361b8 100644 --- a/demos/quickstart/protected/pages/Controls/Samples/TConditional/Home.php +++ b/demos/quickstart/protected/pages/Controls/Samples/TConditional/Home.php @@ -1,7 +1,7 @@ -<?php
-
-class Home extends TPage
-{
-}
-
+<?php + +class Home extends TPage +{ +} + ?>
\ No newline at end of file diff --git a/demos/quickstart/protected/pages/Controls/Samples/TCustomValidator/Home.php b/demos/quickstart/protected/pages/Controls/Samples/TCustomValidator/Home.php index da0d15b2..a3b83ff5 100644 --- a/demos/quickstart/protected/pages/Controls/Samples/TCustomValidator/Home.php +++ b/demos/quickstart/protected/pages/Controls/Samples/TCustomValidator/Home.php @@ -1,18 +1,18 @@ -<?php
-
-class Home extends TPage
-{
- public function serverValidate($sender,$param)
- {
- if($param->Value!=='test')
- $param->IsValid=false;
- }
-
- public function serverValidateNoControl($sender,$param)
- {
- if($this->TextBox4->Text!=='test')
- $param->IsValid=false;
- }
-}
-
+<?php + +class Home extends TPage +{ + public function serverValidate($sender,$param) + { + if($param->Value!=='test') + $param->IsValid=false; + } + + public function serverValidateNoControl($sender,$param) + { + if($this->TextBox4->Text!=='test') + $param->IsValid=false; + } +} + ?>
\ No newline at end of file diff --git a/demos/quickstart/protected/pages/Controls/Samples/TDataGrid/Sample1.php b/demos/quickstart/protected/pages/Controls/Samples/TDataGrid/Sample1.php index ec78006b..628d0740 100644 --- a/demos/quickstart/protected/pages/Controls/Samples/TDataGrid/Sample1.php +++ b/demos/quickstart/protected/pages/Controls/Samples/TDataGrid/Sample1.php @@ -1,41 +1,41 @@ -<?php
-
-class Sample1 extends TPage
-{
- protected function getData()
- {
- return array(
- array('id'=>'ITN001','name'=>'Motherboard','quantity'=>1,'price'=>100.00,'imported'=>true),
- array('id'=>'ITN002','name'=>'CPU','quantity'=>1,'price'=>150.00,'imported'=>true),
- array('id'=>'ITN003','name'=>'Harddrive','quantity'=>2,'price'=>80.00,'imported'=>true),
- array('id'=>'ITN004','name'=>'Sound card','quantity'=>1,'price'=>40.00,'imported'=>false),
- array('id'=>'ITN005','name'=>'Video card','quantity'=>1,'price'=>150.00,'imported'=>true),
- array('id'=>'ITN006','name'=>'Keyboard','quantity'=>1,'price'=>20.00,'imported'=>false),
- array('id'=>'ITN007','name'=>'Monitor','quantity'=>2,'price'=>300.00,'imported'=>true),
- array('id'=>'ITN008','name'=>'CDRW drive','quantity'=>1,'price'=>40.00,'imported'=>true),
- array('id'=>'ITN009','name'=>'Cooling fan','quantity'=>2,'price'=>10.00,'imported'=>false),
- array('id'=>'ITN010','name'=>'Video camera','quantity'=>20,'price'=>30.00,'imported'=>true),
- array('id'=>'ITN011','name'=>'Card reader','quantity'=>10,'price'=>24.00,'imported'=>true),
- array('id'=>'ITN012','name'=>'Floppy drive','quantity'=>50,'price'=>12.00,'imported'=>false),
- array('id'=>'ITN013','name'=>'CD drive','quantity'=>25,'price'=>20.00,'imported'=>true),
- array('id'=>'ITN014','name'=>'DVD drive','quantity'=>15,'price'=>80.00,'imported'=>true),
- array('id'=>'ITN015','name'=>'Mouse pad','quantity'=>50,'price'=>5.00,'imported'=>false),
- array('id'=>'ITN016','name'=>'Network cable','quantity'=>40,'price'=>8.00,'imported'=>true),
- array('id'=>'ITN017','name'=>'Case','quantity'=>8,'price'=>65.00,'imported'=>false),
- array('id'=>'ITN018','name'=>'Surge protector','quantity'=>45,'price'=>15.00,'imported'=>false),
- array('id'=>'ITN019','name'=>'Speaker','quantity'=>35,'price'=>65.00,'imported'=>false),
- );
- }
-
- public function onLoad($param)
- {
- parent::onLoad($param);
- if(!$this->IsPostBack)
- {
- $this->DataGrid->DataSource=$this->Data;
- $this->DataGrid->dataBind();
- }
- }
-}
-
+<?php + +class Sample1 extends TPage +{ + protected function getData() + { + return array( + array('id'=>'ITN001','name'=>'Motherboard','quantity'=>1,'price'=>100.00,'imported'=>true), + array('id'=>'ITN002','name'=>'CPU','quantity'=>1,'price'=>150.00,'imported'=>true), + array('id'=>'ITN003','name'=>'Harddrive','quantity'=>2,'price'=>80.00,'imported'=>true), + array('id'=>'ITN004','name'=>'Sound card','quantity'=>1,'price'=>40.00,'imported'=>false), + array('id'=>'ITN005','name'=>'Video card','quantity'=>1,'price'=>150.00,'imported'=>true), + array('id'=>'ITN006','name'=>'Keyboard','quantity'=>1,'price'=>20.00,'imported'=>false), + array('id'=>'ITN007','name'=>'Monitor','quantity'=>2,'price'=>300.00,'imported'=>true), + array('id'=>'ITN008','name'=>'CDRW drive','quantity'=>1,'price'=>40.00,'imported'=>true), + array('id'=>'ITN009','name'=>'Cooling fan','quantity'=>2,'price'=>10.00,'imported'=>false), + array('id'=>'ITN010','name'=>'Video camera','quantity'=>20,'price'=>30.00,'imported'=>true), + array('id'=>'ITN011','name'=>'Card reader','quantity'=>10,'price'=>24.00,'imported'=>true), + array('id'=>'ITN012','name'=>'Floppy drive','quantity'=>50,'price'=>12.00,'imported'=>false), + array('id'=>'ITN013','name'=>'CD drive','quantity'=>25,'price'=>20.00,'imported'=>true), + array('id'=>'ITN014','name'=>'DVD drive','quantity'=>15,'price'=>80.00,'imported'=>true), + array('id'=>'ITN015','name'=>'Mouse pad','quantity'=>50,'price'=>5.00,'imported'=>false), + array('id'=>'ITN016','name'=>'Network cable','quantity'=>40,'price'=>8.00,'imported'=>true), + array('id'=>'ITN017','name'=>'Case','quantity'=>8,'price'=>65.00,'imported'=>false), + array('id'=>'ITN018','name'=>'Surge protector','quantity'=>45,'price'=>15.00,'imported'=>false), + array('id'=>'ITN019','name'=>'Speaker','quantity'=>35,'price'=>65.00,'imported'=>false), + ); + } + + public function onLoad($param) + { + parent::onLoad($param); + if(!$this->IsPostBack) + { + $this->DataGrid->DataSource=$this->Data; + $this->DataGrid->dataBind(); + } + } +} + ?>
\ No newline at end of file diff --git a/demos/quickstart/protected/pages/Controls/Samples/TDataGrid/Sample2.php b/demos/quickstart/protected/pages/Controls/Samples/TDataGrid/Sample2.php index a49077b5..026d1a5a 100644 --- a/demos/quickstart/protected/pages/Controls/Samples/TDataGrid/Sample2.php +++ b/demos/quickstart/protected/pages/Controls/Samples/TDataGrid/Sample2.php @@ -1,86 +1,86 @@ -<?php
-
-class Sample2 extends TPage
-{
- protected function getData()
- {
- return array(
- array(
- 'ISBN'=>'0596007124',
- 'title'=>'Head First Design Patterns',
- 'publisher'=>'O\'Reilly Media, Inc.',
- 'price'=>29.67,
- 'instock'=>true,
- 'rating'=>4,
- ),
- array(
- 'ISBN'=>'0201633612',
- 'title'=>'Design Patterns: Elements of Reusable Object-Oriented Software',
- 'publisher'=>'Addison-Wesley Professional',
- 'price'=>47.04,
- 'instock'=>true,
- 'rating'=>5,
- ),
- array(
- 'ISBN'=>'0321247140',
- 'title'=>'Design Patterns Explained : A New Perspective on Object-Oriented Design',
- 'publisher'=>'Addison-Wesley Professional',
- 'price'=>37.49,
- 'instock'=>true,
- 'rating'=>4,
- ),
- array(
- 'ISBN'=>'0201485672',
- 'title'=>'Refactoring: Improving the Design of Existing Code',
- 'publisher'=>'Addison-Wesley Professional',
- 'price'=>47.14,
- 'instock'=>true,
- 'rating'=>3,
- ),
- array(
- 'ISBN'=>'0321213351',
- 'title'=>'Refactoring to Patterns',
- 'publisher'=>'Addison-Wesley Professional',
- 'price'=>38.49,
- 'instock'=>true,
- 'rating'=>2,
- ),
- array(
- 'ISBN'=>'0735619670',
- 'title'=>'Code Complete',
- 'publisher'=>'Microsoft Press',
- 'price'=>32.99,
- 'instock'=>false,
- 'rating'=>4,
- ),
- array(
- 'ISBN'=>'0321278658',
- 'title'=>'Extreme Programming Explained : Embrace Change',
- 'publisher'=>'Addison-Wesley Professional',
- 'price'=>34.99,
- 'instock'=>true,
- 'rating'=>3,
- ),
- );
- }
-
- public function onLoad($param)
- {
- parent::onLoad($param);
- if(!$this->IsPostBack)
- {
- $this->DataGrid->DataSource=$this->Data;
- $this->DataGrid->dataBind();
- }
- }
-
- public function toggleColumnVisibility($sender,$param)
- {
- foreach($this->DataGrid->Columns as $index=>$column)
- $column->Visible=$sender->Items[$index]->Selected;
- $this->DataGrid->DataSource=$this->Data;
- $this->DataGrid->dataBind();
- }
-}
-
+<?php + +class Sample2 extends TPage +{ + protected function getData() + { + return array( + array( + 'ISBN'=>'0596007124', + 'title'=>'Head First Design Patterns', + 'publisher'=>'O\'Reilly Media, Inc.', + 'price'=>29.67, + 'instock'=>true, + 'rating'=>4, + ), + array( + 'ISBN'=>'0201633612', + 'title'=>'Design Patterns: Elements of Reusable Object-Oriented Software', + 'publisher'=>'Addison-Wesley Professional', + 'price'=>47.04, + 'instock'=>true, + 'rating'=>5, + ), + array( + 'ISBN'=>'0321247140', + 'title'=>'Design Patterns Explained : A New Perspective on Object-Oriented Design', + 'publisher'=>'Addison-Wesley Professional', + 'price'=>37.49, + 'instock'=>true, + 'rating'=>4, + ), + array( + 'ISBN'=>'0201485672', + 'title'=>'Refactoring: Improving the Design of Existing Code', + 'publisher'=>'Addison-Wesley Professional', + 'price'=>47.14, + 'instock'=>true, + 'rating'=>3, + ), + array( + 'ISBN'=>'0321213351', + 'title'=>'Refactoring to Patterns', + 'publisher'=>'Addison-Wesley Professional', + 'price'=>38.49, + 'instock'=>true, + 'rating'=>2, + ), + array( + 'ISBN'=>'0735619670', + 'title'=>'Code Complete', + 'publisher'=>'Microsoft Press', + 'price'=>32.99, + 'instock'=>false, + 'rating'=>4, + ), + array( + 'ISBN'=>'0321278658', + 'title'=>'Extreme Programming Explained : Embrace Change', + 'publisher'=>'Addison-Wesley Professional', + 'price'=>34.99, + 'instock'=>true, + 'rating'=>3, + ), + ); + } + + public function onLoad($param) + { + parent::onLoad($param); + if(!$this->IsPostBack) + { + $this->DataGrid->DataSource=$this->Data; + $this->DataGrid->dataBind(); + } + } + + public function toggleColumnVisibility($sender,$param) + { + foreach($this->DataGrid->Columns as $index=>$column) + $column->Visible=$sender->Items[$index]->Selected; + $this->DataGrid->DataSource=$this->Data; + $this->DataGrid->dataBind(); + } +} + ?>
\ No newline at end of file diff --git a/demos/quickstart/protected/pages/Controls/Samples/TDataGrid/Sample3.php b/demos/quickstart/protected/pages/Controls/Samples/TDataGrid/Sample3.php index bb18f36b..74085a0f 100644 --- a/demos/quickstart/protected/pages/Controls/Samples/TDataGrid/Sample3.php +++ b/demos/quickstart/protected/pages/Controls/Samples/TDataGrid/Sample3.php @@ -1,190 +1,190 @@ -<?php
-
-class Sample3 extends TPage
-{
- private $_data=null;
-
- protected function getData()
- {
- if($this->_data===null)
- $this->loadData();
- return $this->_data;
- }
-
- protected function loadData()
- {
- // We use viewstate keep track of data.
- // In real applications, data should come from database using an SQL SELECT statement.
- // In the following tabular data, field 'ISBN' is the primary key.
- // All update and delete operations should come with an 'id' value in order to go through.
- if(($this->_data=$this->getViewState('Data',null))===null)
- {
- $this->_data=array(
- array(
- 'ISBN'=>'0596007124',
- 'title'=>'Head First Design Patterns',
- 'publisher'=>'O\'Reilly Media, Inc.',
- 'price'=>29.67,
- 'instock'=>true,
- 'rating'=>4,
- ),
- array(
- 'ISBN'=>'0201633612',
- 'title'=>'Design Patterns: Elements of Reusable Object-Oriented Software',
- 'publisher'=>'Addison-Wesley Professional',
- 'price'=>47.04,
- 'instock'=>true,
- 'rating'=>5,
- ),
- array(
- 'ISBN'=>'0321247140',
- 'title'=>'Design Patterns Explained : A New Perspective on Object-Oriented Design',
- 'publisher'=>'Addison-Wesley Professional',
- 'price'=>37.49,
- 'instock'=>true,
- 'rating'=>4,
- ),
- array(
- 'ISBN'=>'0201485672',
- 'title'=>'Refactoring: Improving the Design of Existing Code',
- 'publisher'=>'Addison-Wesley Professional',
- 'price'=>47.14,
- 'instock'=>true,
- 'rating'=>3,
- ),
- array(
- 'ISBN'=>'0321213351',
- 'title'=>'Refactoring to Patterns',
- 'publisher'=>'Addison-Wesley Professional',
- 'price'=>38.49,
- 'instock'=>true,
- 'rating'=>2,
- ),
- array(
- 'ISBN'=>'0735619670',
- 'title'=>'Code Complete',
- 'publisher'=>'Microsoft Press',
- 'price'=>32.99,
- 'instock'=>false,
- 'rating'=>4,
- ),
- array(
- 'ISBN'=>'0321278658 ',
- 'title'=>'Extreme Programming Explained : Embrace Change',
- 'publisher'=>'Addison-Wesley Professional',
- 'price'=>34.99,
- 'instock'=>true,
- 'rating'=>3,
- ),
- );
- $this->saveData();
- }
- }
-
- protected function saveData()
- {
- $this->setViewState('Data',$this->_data);
- }
-
- protected function updateBook($isbn,$title,$publisher,$price,$instock,$rating)
- {
- // In real applications, data should be saved to database using an SQL UPDATE statement
- if($this->_data===null)
- $this->loadData();
- $updateRow=null;
- foreach($this->_data as $index=>$row)
- if($row['ISBN']===$isbn)
- $updateRow=&$this->_data[$index];
- if($updateRow!==null)
- {
- $updateRow['title']=$title;
- $updateRow['publisher']=$publisher;
- $updateRow['price']=TPropertyValue::ensureFloat(ltrim($price,'$'));
- $updateRow['instock']=TPropertyValue::ensureBoolean($instock);
- $updateRow['rating']=TPropertyValue::ensureInteger($rating);
- $this->saveData();
- }
- }
-
- protected function deleteBook($isbn)
- {
- // In real applications, data should be saved to database using an SQL DELETE statement
- if($this->_data===null)
- $this->loadData();
- $deleteIndex=-1;
- foreach($this->_data as $index=>$row)
- if($row['ISBN']===$isbn)
- $deleteIndex=$index;
- if($deleteIndex>=0)
- {
- unset($this->_data[$deleteIndex]);
- $this->saveData();
- }
- }
-
- public function onLoad($param)
- {
- parent::onLoad($param);
- if(!$this->IsPostBack)
- {
- $this->DataGrid->DataSource=$this->Data;
- $this->DataGrid->dataBind();
- }
- }
-
- public function itemCreated($sender,$param)
- {
- $item=$param->Item;
- if($item->ItemType==='EditItem')
- {
- // set column width of textboxes
- $item->BookTitleColumn->TextBox->Columns=40;
- $item->PriceColumn->TextBox->Columns=5;
- }
- if($item->ItemType==='Item' || $item->ItemType==='AlternatingItem' || $item->ItemType==='EditItem')
- {
- // add an aleart dialog to delete buttons
- $item->DeleteColumn->Button->Attributes->onclick='if(!confirm(\'Are you sure?\')) return false;';
- }
- }
-
- public function editItem($sender,$param)
- {
- $this->DataGrid->EditItemIndex=$param->Item->ItemIndex;
- $this->DataGrid->DataSource=$this->Data;
- $this->DataGrid->dataBind();
- }
-
- public function saveItem($sender,$param)
- {
- $item=$param->Item;
- $this->updateBook(
- $this->DataGrid->DataKeys[$item->ItemIndex], // ISBN
- $item->BookTitleColumn->TextBox->Text, // title
- $item->PublisherColumn->TextBox->Text, // publisher
- $item->PriceColumn->TextBox->Text, // price
- $item->InStockColumn->CheckBox->Checked, // instock
- $item->RatingColumn->DropDownList->SelectedValue // rating
- );
- $this->DataGrid->EditItemIndex=-1;
- $this->DataGrid->DataSource=$this->Data;
- $this->DataGrid->dataBind();
- }
-
- public function cancelItem($sender,$param)
- {
- $this->DataGrid->EditItemIndex=-1;
- $this->DataGrid->DataSource=$this->Data;
- $this->DataGrid->dataBind();
- }
-
- public function deleteItem($sender,$param)
- {
- $this->deleteBook($this->DataGrid->DataKeys[$param->Item->ItemIndex]);
- $this->DataGrid->EditItemIndex=-1;
- $this->DataGrid->DataSource=$this->Data;
- $this->DataGrid->dataBind();
- }
-}
-
+<?php + +class Sample3 extends TPage +{ + private $_data=null; + + protected function getData() + { + if($this->_data===null) + $this->loadData(); + return $this->_data; + } + + protected function loadData() + { + // We use viewstate keep track of data. + // In real applications, data should come from database using an SQL SELECT statement. + // In the following tabular data, field 'ISBN' is the primary key. + // All update and delete operations should come with an 'id' value in order to go through. + if(($this->_data=$this->getViewState('Data',null))===null) + { + $this->_data=array( + array( + 'ISBN'=>'0596007124', + 'title'=>'Head First Design Patterns', + 'publisher'=>'O\'Reilly Media, Inc.', + 'price'=>29.67, + 'instock'=>true, + 'rating'=>4, + ), + array( + 'ISBN'=>'0201633612', + 'title'=>'Design Patterns: Elements of Reusable Object-Oriented Software', + 'publisher'=>'Addison-Wesley Professional', + 'price'=>47.04, + 'instock'=>true, + 'rating'=>5, + ), + array( + 'ISBN'=>'0321247140', + 'title'=>'Design Patterns Explained : A New Perspective on Object-Oriented Design', + 'publisher'=>'Addison-Wesley Professional', + 'price'=>37.49, + 'instock'=>true, + 'rating'=>4, + ), + array( + 'ISBN'=>'0201485672', + 'title'=>'Refactoring: Improving the Design of Existing Code', + 'publisher'=>'Addison-Wesley Professional', + 'price'=>47.14, + 'instock'=>true, + 'rating'=>3, + ), + array( + 'ISBN'=>'0321213351', + 'title'=>'Refactoring to Patterns', + 'publisher'=>'Addison-Wesley Professional', + 'price'=>38.49, + 'instock'=>true, + 'rating'=>2, + ), + array( + 'ISBN'=>'0735619670', + 'title'=>'Code Complete', + 'publisher'=>'Microsoft Press', + 'price'=>32.99, + 'instock'=>false, + 'rating'=>4, + ), + array( + 'ISBN'=>'0321278658 ', + 'title'=>'Extreme Programming Explained : Embrace Change', + 'publisher'=>'Addison-Wesley Professional', + 'price'=>34.99, + 'instock'=>true, + 'rating'=>3, + ), + ); + $this->saveData(); + } + } + + protected function saveData() + { + $this->setViewState('Data',$this->_data); + } + + protected function updateBook($isbn,$title,$publisher,$price,$instock,$rating) + { + // In real applications, data should be saved to database using an SQL UPDATE statement + if($this->_data===null) + $this->loadData(); + $updateRow=null; + foreach($this->_data as $index=>$row) + if($row['ISBN']===$isbn) + $updateRow=&$this->_data[$index]; + if($updateRow!==null) + { + $updateRow['title']=$title; + $updateRow['publisher']=$publisher; + $updateRow['price']=TPropertyValue::ensureFloat(ltrim($price,'$')); + $updateRow['instock']=TPropertyValue::ensureBoolean($instock); + $updateRow['rating']=TPropertyValue::ensureInteger($rating); + $this->saveData(); + } + } + + protected function deleteBook($isbn) + { + // In real applications, data should be saved to database using an SQL DELETE statement + if($this->_data===null) + $this->loadData(); + $deleteIndex=-1; + foreach($this->_data as $index=>$row) + if($row['ISBN']===$isbn) + $deleteIndex=$index; + if($deleteIndex>=0) + { + unset($this->_data[$deleteIndex]); + $this->saveData(); + } + } + + public function onLoad($param) + { + parent::onLoad($param); + if(!$this->IsPostBack) + { + $this->DataGrid->DataSource=$this->Data; + $this->DataGrid->dataBind(); + } + } + + public function itemCreated($sender,$param) + { + $item=$param->Item; + if($item->ItemType==='EditItem') + { + // set column width of textboxes + $item->BookTitleColumn->TextBox->Columns=40; + $item->PriceColumn->TextBox->Columns=5; + } + if($item->ItemType==='Item' || $item->ItemType==='AlternatingItem' || $item->ItemType==='EditItem') + { + // add an aleart dialog to delete buttons + $item->DeleteColumn->Button->Attributes->onclick='if(!confirm(\'Are you sure?\')) return false;'; + } + } + + public function editItem($sender,$param) + { + $this->DataGrid->EditItemIndex=$param->Item->ItemIndex; + $this->DataGrid->DataSource=$this->Data; + $this->DataGrid->dataBind(); + } + + public function saveItem($sender,$param) + { + $item=$param->Item; + $this->updateBook( + $this->DataGrid->DataKeys[$item->ItemIndex], // ISBN + $item->BookTitleColumn->TextBox->Text, // title + $item->PublisherColumn->TextBox->Text, // publisher + $item->PriceColumn->TextBox->Text, // price + $item->InStockColumn->CheckBox->Checked, // instock + $item->RatingColumn->DropDownList->SelectedValue // rating + ); + $this->DataGrid->EditItemIndex=-1; + $this->DataGrid->DataSource=$this->Data; + $this->DataGrid->dataBind(); + } + + public function cancelItem($sender,$param) + { + $this->DataGrid->EditItemIndex=-1; + $this->DataGrid->DataSource=$this->Data; + $this->DataGrid->dataBind(); + } + + public function deleteItem($sender,$param) + { + $this->deleteBook($this->DataGrid->DataKeys[$param->Item->ItemIndex]); + $this->DataGrid->EditItemIndex=-1; + $this->DataGrid->DataSource=$this->Data; + $this->DataGrid->dataBind(); + } +} + ?>
\ No newline at end of file diff --git a/demos/quickstart/protected/pages/Controls/Samples/TDataGrid/Sample4.php b/demos/quickstart/protected/pages/Controls/Samples/TDataGrid/Sample4.php index f9c0804d..ba7cba11 100644 --- a/demos/quickstart/protected/pages/Controls/Samples/TDataGrid/Sample4.php +++ b/demos/quickstart/protected/pages/Controls/Samples/TDataGrid/Sample4.php @@ -1,21 +1,21 @@ -<?php
-
-Prado::using('Application.pages.Controls.Samples.TDataGrid.Sample2');
-
-class Sample4 extends Sample2
-{
- protected function sortData($data,$key)
- {
- $compare = create_function('$a,$b','if ($a["'.$key.'"] == $b["'.$key.'"]) {return 0;}else {return ($a["'.$key.'"] > $b["'.$key.'"]) ? 1 : -1;}');
- usort($data,$compare) ;
- return $data ;
- }
-
- public function sortDataGrid($sender,$param)
- {
- $this->DataGrid->DataSource=$this->sortData($this->Data,$param->SortExpression);
- $this->DataGrid->dataBind();
- }
-}
-
+<?php + +Prado::using('Application.pages.Controls.Samples.TDataGrid.Sample2'); + +class Sample4 extends Sample2 +{ + protected function sortData($data,$key) + { + $compare = create_function('$a,$b','if ($a["'.$key.'"] == $b["'.$key.'"]) {return 0;}else {return ($a["'.$key.'"] > $b["'.$key.'"]) ? 1 : -1;}'); + usort($data,$compare) ; + return $data ; + } + + public function sortDataGrid($sender,$param) + { + $this->DataGrid->DataSource=$this->sortData($this->Data,$param->SortExpression); + $this->DataGrid->dataBind(); + } +} + ?>
\ No newline at end of file diff --git a/demos/quickstart/protected/pages/Controls/Samples/TDataGrid/Sample5.php b/demos/quickstart/protected/pages/Controls/Samples/TDataGrid/Sample5.php index bdca2ca8..fcf075ea 100644 --- a/demos/quickstart/protected/pages/Controls/Samples/TDataGrid/Sample5.php +++ b/demos/quickstart/protected/pages/Controls/Samples/TDataGrid/Sample5.php @@ -1,68 +1,68 @@ -<?php
-
-Prado::using('Application.pages.Controls.Samples.TDataGrid.Sample1');
-
-class Sample5 extends Sample1
-{
- public function changePage($sender,$param)
- {
- $this->DataGrid->CurrentPageIndex=$param->NewPageIndex;
- $this->DataGrid->DataSource=$this->Data;
- $this->DataGrid->dataBind();
- }
-
- public function pagerCreated($sender,$param)
- {
- $param->Pager->Controls->insertAt(0,'Page: ');
- }
-
- public function changePagerPosition($sender,$param)
- {
- $top=$sender->Items[0]->Selected;
- $bottom=$sender->Items[1]->Selected;
- if($top && $bottom)
- $position='TopAndBottom';
- else if($top)
- $position='Top';
- else if($bottom)
- $position='Bottom';
- else
- $position='';
- if($position==='')
- $this->DataGrid->PagerStyle->Visible=false;
- else
- {
- $this->DataGrid->PagerStyle->Position=$position;
- $this->DataGrid->PagerStyle->Visible=true;
- }
- }
-
- public function useNumericPager($sender,$param)
- {
- $this->DataGrid->PagerStyle->Mode='Numeric';
- $this->DataGrid->PagerStyle->NextPageText=$this->NextPageText->Text;
- $this->DataGrid->PagerStyle->PrevPageText=$this->PrevPageText->Text;
- $this->DataGrid->PagerStyle->PageButtonCount=$this->PageButtonCount->Text;
- $this->DataGrid->DataSource=$this->Data;
- $this->DataGrid->dataBind();
- }
-
- public function useNextPrevPager($sender,$param)
- {
- $this->DataGrid->PagerStyle->Mode='NextPrev';
- $this->DataGrid->PagerStyle->NextPageText=$this->NextPageText->Text;
- $this->DataGrid->PagerStyle->PrevPageText=$this->PrevPageText->Text;
- $this->DataGrid->DataSource=$this->Data;
- $this->DataGrid->dataBind();
- }
-
- public function changePageSize($sender,$param)
- {
- $this->DataGrid->PageSize=TPropertyValue::ensureInteger($this->PageSize->Text);
- $this->DataGrid->CurrentPageIndex=0;
- $this->DataGrid->DataSource=$this->Data;
- $this->DataGrid->dataBind();
- }
-}
-
+<?php + +Prado::using('Application.pages.Controls.Samples.TDataGrid.Sample1'); + +class Sample5 extends Sample1 +{ + public function changePage($sender,$param) + { + $this->DataGrid->CurrentPageIndex=$param->NewPageIndex; + $this->DataGrid->DataSource=$this->Data; + $this->DataGrid->dataBind(); + } + + public function pagerCreated($sender,$param) + { + $param->Pager->Controls->insertAt(0,'Page: '); + } + + public function changePagerPosition($sender,$param) + { + $top=$sender->Items[0]->Selected; + $bottom=$sender->Items[1]->Selected; + if($top && $bottom) + $position='TopAndBottom'; + else if($top) + $position='Top'; + else if($bottom) + $position='Bottom'; + else + $position=''; + if($position==='') + $this->DataGrid->PagerStyle->Visible=false; + else + { + $this->DataGrid->PagerStyle->Position=$position; + $this->DataGrid->PagerStyle->Visible=true; + } + } + + public function useNumericPager($sender,$param) + { + $this->DataGrid->PagerStyle->Mode='Numeric'; + $this->DataGrid->PagerStyle->NextPageText=$this->NextPageText->Text; + $this->DataGrid->PagerStyle->PrevPageText=$this->PrevPageText->Text; + $this->DataGrid->PagerStyle->PageButtonCount=$this->PageButtonCount->Text; + $this->DataGrid->DataSource=$this->Data; + $this->DataGrid->dataBind(); + } + + public function useNextPrevPager($sender,$param) + { + $this->DataGrid->PagerStyle->Mode='NextPrev'; + $this->DataGrid->PagerStyle->NextPageText=$this->NextPageText->Text; + $this->DataGrid->PagerStyle->PrevPageText=$this->PrevPageText->Text; + $this->DataGrid->DataSource=$this->Data; + $this->DataGrid->dataBind(); + } + + public function changePageSize($sender,$param) + { + $this->DataGrid->PageSize=TPropertyValue::ensureInteger($this->PageSize->Text); + $this->DataGrid->CurrentPageIndex=0; + $this->DataGrid->DataSource=$this->Data; + $this->DataGrid->dataBind(); + } +} + ?>
\ No newline at end of file diff --git a/demos/quickstart/protected/pages/Controls/Samples/TDataGrid/Sample6.php b/demos/quickstart/protected/pages/Controls/Samples/TDataGrid/Sample6.php index 90e3f7fe..3f24c9ac 100644 --- a/demos/quickstart/protected/pages/Controls/Samples/TDataGrid/Sample6.php +++ b/demos/quickstart/protected/pages/Controls/Samples/TDataGrid/Sample6.php @@ -1,56 +1,56 @@ -<?php
-
-Prado::using('Application.pages.Controls.Samples.TDataGrid.Sample1');
-
-class Sample6 extends Sample1
-{
- /**
- * Returns a subset of data.
- * In MySQL database, this can be replaced by LIMIT clause
- * in an SQL select statement.
- * @param integer the starting index of the row
- * @param integer number of rows to be returned
- * @return array subset of data
- */
- protected function getDataRows($offset,$rows)
- {
- $data=$this->getData();
- $page=array();
- for($i=0;$i<$rows;++$i)
- {
- if($offset+$i<$this->getRowCount())
- $page[$i]=$data[$offset+$i];
- }
- return $page;
- }
-
- /**
- * Returns total number of data rows.
- * In real DB applications, this may be replaced by an SQL select
- * query with count().
- * @return integer total number of data rows
- */
- protected function getRowCount()
- {
- return 19;
- }
-
- public function onLoad($param)
- {
- if(!$this->IsPostBack)
- {
- $this->DataGrid->DataSource=$this->getDataRows(0,$this->DataGrid->PageSize);
- $this->DataGrid->dataBind();
- }
- }
-
- public function changePage($sender,$param)
- {
- $this->DataGrid->CurrentPageIndex=$param->NewPageIndex;
- $offset=$param->NewPageIndex*$this->DataGrid->PageSize;
- $this->DataGrid->DataSource=$this->getDataRows($offset,$this->DataGrid->PageSize);
- $this->DataGrid->dataBind();
- }
-}
-
+<?php + +Prado::using('Application.pages.Controls.Samples.TDataGrid.Sample1'); + +class Sample6 extends Sample1 +{ + /** + * Returns a subset of data. + * In MySQL database, this can be replaced by LIMIT clause + * in an SQL select statement. + * @param integer the starting index of the row + * @param integer number of rows to be returned + * @return array subset of data + */ + protected function getDataRows($offset,$rows) + { + $data=$this->getData(); + $page=array(); + for($i=0;$i<$rows;++$i) + { + if($offset+$i<$this->getRowCount()) + $page[$i]=$data[$offset+$i]; + } + return $page; + } + + /** + * Returns total number of data rows. + * In real DB applications, this may be replaced by an SQL select + * query with count(). + * @return integer total number of data rows + */ + protected function getRowCount() + { + return 19; + } + + public function onLoad($param) + { + if(!$this->IsPostBack) + { + $this->DataGrid->DataSource=$this->getDataRows(0,$this->DataGrid->PageSize); + $this->DataGrid->dataBind(); + } + } + + public function changePage($sender,$param) + { + $this->DataGrid->CurrentPageIndex=$param->NewPageIndex; + $offset=$param->NewPageIndex*$this->DataGrid->PageSize; + $this->DataGrid->DataSource=$this->getDataRows($offset,$this->DataGrid->PageSize); + $this->DataGrid->dataBind(); + } +} + ?>
\ No newline at end of file diff --git a/demos/quickstart/protected/pages/Controls/Samples/TDataList/Sample1.php b/demos/quickstart/protected/pages/Controls/Samples/TDataList/Sample1.php index 7b8a2ae4..037036f5 100644 --- a/demos/quickstart/protected/pages/Controls/Samples/TDataList/Sample1.php +++ b/demos/quickstart/protected/pages/Controls/Samples/TDataList/Sample1.php @@ -1,41 +1,41 @@ -<?php
-
-class Sample1 extends TPage
-{
- protected function getData()
- {
- return array(
- array('id'=>'ITN001','name'=>'Motherboard','quantity'=>1,'price'=>100.00,'imported'=>true),
- array('id'=>'ITN002','name'=>'CPU','quantity'=>1,'price'=>150.00,'imported'=>true),
- array('id'=>'ITN003','name'=>'Harddrive','quantity'=>2,'price'=>80.00,'imported'=>true),
- array('id'=>'ITN004','name'=>'Sound card','quantity'=>1,'price'=>40.00,'imported'=>false),
- array('id'=>'ITN005','name'=>'Video card','quantity'=>1,'price'=>150.00,'imported'=>true),
- array('id'=>'ITN006','name'=>'Keyboard','quantity'=>1,'price'=>20.00,'imported'=>false),
- array('id'=>'ITN007','name'=>'Monitor','quantity'=>2,'price'=>300.00,'imported'=>true),
- array('id'=>'ITN008','name'=>'CDRW drive','quantity'=>1,'price'=>40.00,'imported'=>true),
- array('id'=>'ITN009','name'=>'Cooling fan','quantity'=>2,'price'=>10.00,'imported'=>false),
- array('id'=>'ITN010','name'=>'Video camera','quantity'=>20,'price'=>30.00,'imported'=>true),
- array('id'=>'ITN011','name'=>'Card reader','quantity'=>10,'price'=>24.00,'imported'=>true),
- array('id'=>'ITN012','name'=>'Floppy drive','quantity'=>50,'price'=>12.00,'imported'=>false),
- array('id'=>'ITN013','name'=>'CD drive','quantity'=>25,'price'=>20.00,'imported'=>true),
- array('id'=>'ITN014','name'=>'DVD drive','quantity'=>15,'price'=>80.00,'imported'=>true),
- array('id'=>'ITN015','name'=>'Mouse pad','quantity'=>50,'price'=>5.00,'imported'=>false),
- array('id'=>'ITN016','name'=>'Network cable','quantity'=>40,'price'=>8.00,'imported'=>true),
- array('id'=>'ITN017','name'=>'Case','quantity'=>8,'price'=>65.00,'imported'=>false),
- array('id'=>'ITN018','name'=>'Surge protector','quantity'=>45,'price'=>15.00,'imported'=>false),
- array('id'=>'ITN019','name'=>'Speaker','quantity'=>35,'price'=>65.00,'imported'=>false),
- );
- }
-
- public function onLoad($param)
- {
- parent::onLoad($param);
- if(!$this->IsPostBack)
- {
- $this->DataList->DataSource=$this->Data;
- $this->DataList->dataBind();
- }
- }
-}
-
+<?php + +class Sample1 extends TPage +{ + protected function getData() + { + return array( + array('id'=>'ITN001','name'=>'Motherboard','quantity'=>1,'price'=>100.00,'imported'=>true), + array('id'=>'ITN002','name'=>'CPU','quantity'=>1,'price'=>150.00,'imported'=>true), + array('id'=>'ITN003','name'=>'Harddrive','quantity'=>2,'price'=>80.00,'imported'=>true), + array('id'=>'ITN004','name'=>'Sound card','quantity'=>1,'price'=>40.00,'imported'=>false), + array('id'=>'ITN005','name'=>'Video card','quantity'=>1,'price'=>150.00,'imported'=>true), + array('id'=>'ITN006','name'=>'Keyboard','quantity'=>1,'price'=>20.00,'imported'=>false), + array('id'=>'ITN007','name'=>'Monitor','quantity'=>2,'price'=>300.00,'imported'=>true), + array('id'=>'ITN008','name'=>'CDRW drive','quantity'=>1,'price'=>40.00,'imported'=>true), + array('id'=>'ITN009','name'=>'Cooling fan','quantity'=>2,'price'=>10.00,'imported'=>false), + array('id'=>'ITN010','name'=>'Video camera','quantity'=>20,'price'=>30.00,'imported'=>true), + array('id'=>'ITN011','name'=>'Card reader','quantity'=>10,'price'=>24.00,'imported'=>true), + array('id'=>'ITN012','name'=>'Floppy drive','quantity'=>50,'price'=>12.00,'imported'=>false), + array('id'=>'ITN013','name'=>'CD drive','quantity'=>25,'price'=>20.00,'imported'=>true), + array('id'=>'ITN014','name'=>'DVD drive','quantity'=>15,'price'=>80.00,'imported'=>true), + array('id'=>'ITN015','name'=>'Mouse pad','quantity'=>50,'price'=>5.00,'imported'=>false), + array('id'=>'ITN016','name'=>'Network cable','quantity'=>40,'price'=>8.00,'imported'=>true), + array('id'=>'ITN017','name'=>'Case','quantity'=>8,'price'=>65.00,'imported'=>false), + array('id'=>'ITN018','name'=>'Surge protector','quantity'=>45,'price'=>15.00,'imported'=>false), + array('id'=>'ITN019','name'=>'Speaker','quantity'=>35,'price'=>65.00,'imported'=>false), + ); + } + + public function onLoad($param) + { + parent::onLoad($param); + if(!$this->IsPostBack) + { + $this->DataList->DataSource=$this->Data; + $this->DataList->dataBind(); + } + } +} + ?>
\ No newline at end of file diff --git a/demos/quickstart/protected/pages/Controls/Samples/TDataList/Sample2.php b/demos/quickstart/protected/pages/Controls/Samples/TDataList/Sample2.php index 9715f5ba..7273dd39 100644 --- a/demos/quickstart/protected/pages/Controls/Samples/TDataList/Sample2.php +++ b/demos/quickstart/protected/pages/Controls/Samples/TDataList/Sample2.php @@ -1,132 +1,132 @@ -<?php
-
-class Sample2 extends TPage
-{
- private $_data=null;
-
- protected function getData()
- {
- if($this->_data===null)
- $this->loadData();
- return $this->_data;
- }
-
- protected function loadData()
- {
- // We use viewstate keep track of data.
- // In real applications, data should come from database using an SQL SELECT statement.
- // In the following tabular data, field 'id' is the primary key.
- // All update and delete operations should come with an 'id' value in order to go through.
- if(($this->_data=$this->getViewState('Data',null))===null)
- {
- $this->_data=array(
- array('id'=>'ITN001','name'=>'Motherboard','quantity'=>1,'price'=>100.00,'imported'=>true),
- array('id'=>'ITN002','name'=>'CPU','quantity'=>1,'price'=>150.00,'imported'=>true),
- array('id'=>'ITN003','name'=>'Harddrive','quantity'=>2,'price'=>80.00,'imported'=>false),
- array('id'=>'ITN004','name'=>'Sound card','quantity'=>1,'price'=>40.00,'imported'=>false),
- array('id'=>'ITN005','name'=>'Video card','quantity'=>1,'price'=>150.00,'imported'=>true),
- array('id'=>'ITN006','name'=>'Keyboard','quantity'=>1,'price'=>20.00,'imported'=>true),
- array('id'=>'ITN007','name'=>'Monitor','quantity'=>2,'price'=>300.00,'imported'=>false),
- );
- $this->saveData();
- }
- }
-
- protected function saveData()
- {
- $this->setViewState('Data',$this->_data);
- }
-
- protected function updateProduct($id,$name,$quantity,$price,$imported)
- {
- // In real applications, data should be saved to database using an SQL UPDATE statement
- if($this->_data===null)
- $this->loadData();
- $updateRow=null;
- foreach($this->_data as $index=>$row)
- if($row['id']===$id)
- $updateRow=&$this->_data[$index];
- if($updateRow!==null)
- {
- $updateRow['name']=$name;
- $updateRow['quantity']=TPropertyValue::ensureInteger($quantity);
- $updateRow['price']=TPropertyValue::ensureFloat($price);
- $updateRow['imported']=TPropertyValue::ensureBoolean($imported);
- $this->saveData();
- }
- }
-
- protected function deleteProduct($id)
- {
- // In real applications, data should be saved to database using an SQL DELETE statement
- if($this->_data===null)
- $this->loadData();
- $deleteIndex=-1;
- foreach($this->_data as $index=>$row)
- if($row['id']===$id)
- $deleteIndex=$index;
- if($deleteIndex>=0)
- {
- unset($this->_data[$deleteIndex]);
- $this->saveData();
- }
- }
-
- public function onLoad($param)
- {
- parent::onLoad($param);
- if(!$this->IsPostBack)
- {
- $this->DataList->DataSource=$this->Data;
- $this->DataList->dataBind();
- }
- }
-
- public function editItem($sender,$param)
- {
- $this->DataList->SelectedItemIndex=-1;
- $this->DataList->EditItemIndex=$param->Item->ItemIndex;
- $this->DataList->DataSource=$this->Data;
- $this->DataList->dataBind();
- }
-
- public function cancelItem($sender,$param)
- {
- $this->DataList->SelectedItemIndex=-1;
- $this->DataList->EditItemIndex=-1;
- $this->DataList->DataSource=$this->Data;
- $this->DataList->dataBind();
- }
-
- public function updateItem($sender,$param)
- {
- $item=$param->Item;
- $this->updateProduct(
- $this->DataList->DataKeys[$item->ItemIndex],
- $item->ProductName->Text,
- $item->ProductQuantity->Text,
- $item->ProductPrice->Text,
- $item->ProductImported->Checked);
- $this->DataList->EditItemIndex=-1;
- $this->DataList->DataSource=$this->Data;
- $this->DataList->dataBind();
- }
-
- public function deleteItem($sender,$param)
- {
- $this->deleteProduct($this->DataList->DataKeys[$param->Item->ItemIndex]);
- $this->DataList->SelectedItemIndex=-1;
- $this->DataList->EditItemIndex=-1;
- $this->DataList->DataSource=$this->Data;
- $this->DataList->dataBind();
- }
-
- public function selectItem($sender,$param)
- {
- $this->DataList->EditItemIndex=-1;
- $this->DataList->DataSource=$this->Data;
- $this->DataList->dataBind();
- }
-}
-
+<?php + +class Sample2 extends TPage +{ + private $_data=null; + + protected function getData() + { + if($this->_data===null) + $this->loadData(); + return $this->_data; + } + + protected function loadData() + { + // We use viewstate keep track of data. + // In real applications, data should come from database using an SQL SELECT statement. + // In the following tabular data, field 'id' is the primary key. + // All update and delete operations should come with an 'id' value in order to go through. + if(($this->_data=$this->getViewState('Data',null))===null) + { + $this->_data=array( + array('id'=>'ITN001','name'=>'Motherboard','quantity'=>1,'price'=>100.00,'imported'=>true), + array('id'=>'ITN002','name'=>'CPU','quantity'=>1,'price'=>150.00,'imported'=>true), + array('id'=>'ITN003','name'=>'Harddrive','quantity'=>2,'price'=>80.00,'imported'=>false), + array('id'=>'ITN004','name'=>'Sound card','quantity'=>1,'price'=>40.00,'imported'=>false), + array('id'=>'ITN005','name'=>'Video card','quantity'=>1,'price'=>150.00,'imported'=>true), + array('id'=>'ITN006','name'=>'Keyboard','quantity'=>1,'price'=>20.00,'imported'=>true), + array('id'=>'ITN007','name'=>'Monitor','quantity'=>2,'price'=>300.00,'imported'=>false), + ); + $this->saveData(); + } + } + + protected function saveData() + { + $this->setViewState('Data',$this->_data); + } + + protected function updateProduct($id,$name,$quantity,$price,$imported) + { + // In real applications, data should be saved to database using an SQL UPDATE statement + if($this->_data===null) + $this->loadData(); + $updateRow=null; + foreach($this->_data as $index=>$row) + if($row['id']===$id) + $updateRow=&$this->_data[$index]; + if($updateRow!==null) + { + $updateRow['name']=$name; + $updateRow['quantity']=TPropertyValue::ensureInteger($quantity); + $updateRow['price']=TPropertyValue::ensureFloat($price); + $updateRow['imported']=TPropertyValue::ensureBoolean($imported); + $this->saveData(); + } + } + + protected function deleteProduct($id) + { + // In real applications, data should be saved to database using an SQL DELETE statement + if($this->_data===null) + $this->loadData(); + $deleteIndex=-1; + foreach($this->_data as $index=>$row) + if($row['id']===$id) + $deleteIndex=$index; + if($deleteIndex>=0) + { + unset($this->_data[$deleteIndex]); + $this->saveData(); + } + } + + public function onLoad($param) + { + parent::onLoad($param); + if(!$this->IsPostBack) + { + $this->DataList->DataSource=$this->Data; + $this->DataList->dataBind(); + } + } + + public function editItem($sender,$param) + { + $this->DataList->SelectedItemIndex=-1; + $this->DataList->EditItemIndex=$param->Item->ItemIndex; + $this->DataList->DataSource=$this->Data; + $this->DataList->dataBind(); + } + + public function cancelItem($sender,$param) + { + $this->DataList->SelectedItemIndex=-1; + $this->DataList->EditItemIndex=-1; + $this->DataList->DataSource=$this->Data; + $this->DataList->dataBind(); + } + + public function updateItem($sender,$param) + { + $item=$param->Item; + $this->updateProduct( + $this->DataList->DataKeys[$item->ItemIndex], + $item->ProductName->Text, + $item->ProductQuantity->Text, + $item->ProductPrice->Text, + $item->ProductImported->Checked); + $this->DataList->EditItemIndex=-1; + $this->DataList->DataSource=$this->Data; + $this->DataList->dataBind(); + } + + public function deleteItem($sender,$param) + { + $this->deleteProduct($this->DataList->DataKeys[$param->Item->ItemIndex]); + $this->DataList->SelectedItemIndex=-1; + $this->DataList->EditItemIndex=-1; + $this->DataList->DataSource=$this->Data; + $this->DataList->dataBind(); + } + + public function selectItem($sender,$param) + { + $this->DataList->EditItemIndex=-1; + $this->DataList->DataSource=$this->Data; + $this->DataList->dataBind(); + } +} + ?>
\ No newline at end of file diff --git a/demos/quickstart/protected/pages/Controls/Samples/TDataTypeValidator/Home.php b/demos/quickstart/protected/pages/Controls/Samples/TDataTypeValidator/Home.php index 88d2dbf2..1c5efbcf 100644 --- a/demos/quickstart/protected/pages/Controls/Samples/TDataTypeValidator/Home.php +++ b/demos/quickstart/protected/pages/Controls/Samples/TDataTypeValidator/Home.php @@ -1,8 +1,8 @@ -<?php
-
-class Home extends TPage
-{
-
-}
-
+<?php + +class Home extends TPage +{ + +} + ?>
\ No newline at end of file diff --git a/demos/quickstart/protected/pages/Controls/Samples/TDropDownList/Home.php b/demos/quickstart/protected/pages/Controls/Samples/TDropDownList/Home.php index 133a797a..74e47b6c 100644 --- a/demos/quickstart/protected/pages/Controls/Samples/TDropDownList/Home.php +++ b/demos/quickstart/protected/pages/Controls/Samples/TDropDownList/Home.php @@ -1,69 +1,69 @@ -<?php
-
-class Home extends TPage
-{
- public function onLoad($param)
- {
- parent::onLoad($param);
- if(!$this->IsPostBack)
- {
- $data=array('item 1','item 2','item 3','item 4');
- $this->DBDropDownList1->DataSource=$data;
- $this->DBDropDownList1->dataBind();
-
- $data=array('key 1'=>'item 1','key 2'=>'item 2',
- 'key 3'=>'item 3','key 4'=>'item 4');
- $this->DBDropDownList2->DataSource=$data;
- $this->DBDropDownList2->dataBind();
-
- $data=array(
- array('id'=>'001','name'=>'John','age'=>31),
- array('id'=>'002','name'=>'Mary','age'=>30),
- array('id'=>'003','name'=>'Cary','age'=>20));
- $this->DBDropDownList3->DataSource=$data;
- $this->DBDropDownList3->dataBind();
- }
- }
-
- protected function collectSelectionResult($input,$output)
- {
- $indices=$input->SelectedIndices;
- $result='';
- foreach($indices as $index)
- {
- $item=$input->Items[$index];
- $result.="(Index: $index, Value: $item->Value, Text: $item->Text)";
- }
- if($result==='')
- $output->Text='Your selection is empty.';
- else
- $output->Text='Your selection is: '.$result;
- }
-
- public function DBDropDownList1Changed($sender,$param)
- {
- $this->collectSelectionResult($sender,$this->DBDropDownList1Result);
- }
-
- public function DBDropDownList2Changed($sender,$param)
- {
- $this->collectSelectionResult($sender,$this->DBDropDownList2Result);
- }
-
- public function DBDropDownList3Changed($sender,$param)
- {
- $this->collectSelectionResult($sender,$this->DBDropDownList3Result);
- }
-
- public function selectionChanged($sender,$param)
- {
- $this->collectSelectionResult($sender,$this->SelectionResult);
- }
-
- public function buttonClicked($sender,$param)
- {
- $this->collectSelectionResult($this->DropDownList1,$this->SelectionResult2);
- }
-}
-
+<?php + +class Home extends TPage +{ + public function onLoad($param) + { + parent::onLoad($param); + if(!$this->IsPostBack) + { + $data=array('item 1','item 2','item 3','item 4'); + $this->DBDropDownList1->DataSource=$data; + $this->DBDropDownList1->dataBind(); + + $data=array('key 1'=>'item 1','key 2'=>'item 2', + 'key 3'=>'item 3','key 4'=>'item 4'); + $this->DBDropDownList2->DataSource=$data; + $this->DBDropDownList2->dataBind(); + + $data=array( + array('id'=>'001','name'=>'John','age'=>31), + array('id'=>'002','name'=>'Mary','age'=>30), + array('id'=>'003','name'=>'Cary','age'=>20)); + $this->DBDropDownList3->DataSource=$data; + $this->DBDropDownList3->dataBind(); + } + } + + protected function collectSelectionResult($input,$output) + { + $indices=$input->SelectedIndices; + $result=''; + foreach($indices as $index) + { + $item=$input->Items[$index]; + $result.="(Index: $index, Value: $item->Value, Text: $item->Text)"; + } + if($result==='') + $output->Text='Your selection is empty.'; + else + $output->Text='Your selection is: '.$result; + } + + public function DBDropDownList1Changed($sender,$param) + { + $this->collectSelectionResult($sender,$this->DBDropDownList1Result); + } + + public function DBDropDownList2Changed($sender,$param) + { + $this->collectSelectionResult($sender,$this->DBDropDownList2Result); + } + + public function DBDropDownList3Changed($sender,$param) + { + $this->collectSelectionResult($sender,$this->DBDropDownList3Result); + } + + public function selectionChanged($sender,$param) + { + $this->collectSelectionResult($sender,$this->SelectionResult); + } + + public function buttonClicked($sender,$param) + { + $this->collectSelectionResult($this->DropDownList1,$this->SelectionResult2); + } +} + ?>
\ No newline at end of file diff --git a/demos/quickstart/protected/pages/Controls/Samples/TEmailAddressValidator/Home.php b/demos/quickstart/protected/pages/Controls/Samples/TEmailAddressValidator/Home.php index 88d2dbf2..1c5efbcf 100644 --- a/demos/quickstart/protected/pages/Controls/Samples/TEmailAddressValidator/Home.php +++ b/demos/quickstart/protected/pages/Controls/Samples/TEmailAddressValidator/Home.php @@ -1,8 +1,8 @@ -<?php
-
-class Home extends TPage
-{
-
-}
-
+<?php + +class Home extends TPage +{ + +} + ?>
\ No newline at end of file diff --git a/demos/quickstart/protected/pages/Controls/Samples/TFileUpload/Home.php b/demos/quickstart/protected/pages/Controls/Samples/TFileUpload/Home.php index d5cf990a..29d05a1c 100644 --- a/demos/quickstart/protected/pages/Controls/Samples/TFileUpload/Home.php +++ b/demos/quickstart/protected/pages/Controls/Samples/TFileUpload/Home.php @@ -1,21 +1,21 @@ -<?php
-
-class Home extends TPage
-{
- public function fileUploaded($sender,$param)
- {
- if($sender->HasFile)
- {
- $this->Result->Text="
- You just uploaded a file:
- <br/>
- Name: {$sender->FileName}
- <br/>
- Size: {$sender->FileSize}
- <br/>
- Type: {$sender->FileType}";
- }
- }
-}
-
+<?php + +class Home extends TPage +{ + public function fileUploaded($sender,$param) + { + if($sender->HasFile) + { + $this->Result->Text=" + You just uploaded a file: + <br/> + Name: {$sender->FileName} + <br/> + Size: {$sender->FileSize} + <br/> + Type: {$sender->FileType}"; + } + } +} + ?>
\ No newline at end of file diff --git a/demos/quickstart/protected/pages/Controls/Samples/THtmlArea/Home.php b/demos/quickstart/protected/pages/Controls/Samples/THtmlArea/Home.php index c56b5229..255a2bf3 100644 --- a/demos/quickstart/protected/pages/Controls/Samples/THtmlArea/Home.php +++ b/demos/quickstart/protected/pages/Controls/Samples/THtmlArea/Home.php @@ -1,21 +1,21 @@ -<?php
-
-class Home extends TPage
-{
- public function button1Clicked($sender,$param)
- {
- $this->Result1->Text="You have entered: ".$this->HtmlArea1->Text;
- }
-
- public function button2Clicked($sender,$param)
- {
- $this->Result2->Text="You have entered: ".$this->HtmlArea2->Text;
- }
-
- public function button3Clicked($sender,$param)
- {
- $this->Result3->Text="You have entered: ".$this->HtmlArea3->Text;
- }
-}
-
+<?php + +class Home extends TPage +{ + public function button1Clicked($sender,$param) + { + $this->Result1->Text="You have entered: ".$this->HtmlArea1->Text; + } + + public function button2Clicked($sender,$param) + { + $this->Result2->Text="You have entered: ".$this->HtmlArea2->Text; + } + + public function button3Clicked($sender,$param) + { + $this->Result3->Text="You have entered: ".$this->HtmlArea3->Text; + } +} + ?>
\ No newline at end of file diff --git a/demos/quickstart/protected/pages/Controls/Samples/TImageButton/Home.php b/demos/quickstart/protected/pages/Controls/Samples/TImageButton/Home.php index df61ed82..e30aab2b 100644 --- a/demos/quickstart/protected/pages/Controls/Samples/TImageButton/Home.php +++ b/demos/quickstart/protected/pages/Controls/Samples/TImageButton/Home.php @@ -1,18 +1,18 @@ -<?php
-
-class Home extends TPage
-{
- public function buttonClicked($sender,$param)
- {
- if($param instanceof TCommandEventParameter)
- {
- $this->Result2->Text="Command name: $param->CommandName, Command parameter: $param->CommandParameter";
- }
- else
- {
- $this->Result->Text="You clicked at ($param->X,$param->Y)";
- }
- }
-}
-
+<?php + +class Home extends TPage +{ + public function buttonClicked($sender,$param) + { + if($param instanceof TCommandEventParameter) + { + $this->Result2->Text="Command name: $param->CommandName, Command parameter: $param->CommandParameter"; + } + else + { + $this->Result->Text="You clicked at ($param->X,$param->Y)"; + } + } +} + ?>
\ No newline at end of file diff --git a/demos/quickstart/protected/pages/Controls/Samples/TImageMap/Home.php b/demos/quickstart/protected/pages/Controls/Samples/TImageMap/Home.php index b8e17941..01294c60 100644 --- a/demos/quickstart/protected/pages/Controls/Samples/TImageMap/Home.php +++ b/demos/quickstart/protected/pages/Controls/Samples/TImageMap/Home.php @@ -1,11 +1,11 @@ -<?php
-
-class Home extends TPage
-{
- public function buttonClicked($sender,$param)
- {
- $this->Result->Text="Your post value is : ".$param->PostBackValue;
- }
-}
-
+<?php + +class Home extends TPage +{ + public function buttonClicked($sender,$param) + { + $this->Result->Text="Your post value is : ".$param->PostBackValue; + } +} + ?>
\ No newline at end of file diff --git a/demos/quickstart/protected/pages/Controls/Samples/TKeyboard/Home.php b/demos/quickstart/protected/pages/Controls/Samples/TKeyboard/Home.php index 689f45c8..d725dc06 100644 --- a/demos/quickstart/protected/pages/Controls/Samples/TKeyboard/Home.php +++ b/demos/quickstart/protected/pages/Controls/Samples/TKeyboard/Home.php @@ -1,11 +1,11 @@ -<?php
-
-class Home extends TPage
-{
- public function buttonClicked($sender,$param)
- {
- $this->Result->Text='You have entered "'.$this->PasswordInput->Text.'".';
- }
-}
-
+<?php + +class Home extends TPage +{ + public function buttonClicked($sender,$param) + { + $this->Result->Text='You have entered "'.$this->PasswordInput->Text.'".'; + } +} + ?>
\ No newline at end of file diff --git a/demos/quickstart/protected/pages/Controls/Samples/TLinkButton/Home.php b/demos/quickstart/protected/pages/Controls/Samples/TLinkButton/Home.php index f18072f2..3711ca46 100644 --- a/demos/quickstart/protected/pages/Controls/Samples/TLinkButton/Home.php +++ b/demos/quickstart/protected/pages/Controls/Samples/TLinkButton/Home.php @@ -1,14 +1,14 @@ -<?php
-
-class Home extends TPage
-{
- public function buttonClicked($sender,$param)
- {
- if($param instanceof TCommandEventParameter)
- $sender->Text="Name: {$param->CommandName}, Param: {$param->CommandParameter}";
- else
- $sender->Text="I'm clicked";
- }
-}
-
+<?php + +class Home extends TPage +{ + public function buttonClicked($sender,$param) + { + if($param instanceof TCommandEventParameter) + $sender->Text="Name: {$param->CommandName}, Param: {$param->CommandParameter}"; + else + $sender->Text="I'm clicked"; + } +} + ?>
\ No newline at end of file diff --git a/demos/quickstart/protected/pages/Controls/Samples/TListBox/Home.php b/demos/quickstart/protected/pages/Controls/Samples/TListBox/Home.php index a570d38b..9e5add52 100644 --- a/demos/quickstart/protected/pages/Controls/Samples/TListBox/Home.php +++ b/demos/quickstart/protected/pages/Controls/Samples/TListBox/Home.php @@ -1,79 +1,79 @@ -<?php
-
-class Home extends TPage
-{
- public function onLoad($param)
- {
- parent::onLoad($param);
- if(!$this->IsPostBack)
- {
- $data=array('item 1','item 2','item 3','item 4');
- $this->DBListBox1->DataSource=$data;
- $this->DBListBox1->dataBind();
-
- $data=array('key 1'=>'item 1','key 2'=>'item 2',
- 'key 3'=>'item 3','key 4'=>'item 4');
- $this->DBListBox2->DataSource=$data;
- $this->DBListBox2->dataBind();
-
- $data=array(
- array('id'=>'001','name'=>'John','age'=>31),
- array('id'=>'002','name'=>'Mary','age'=>30),
- array('id'=>'003','name'=>'Cary','age'=>20));
- $this->DBListBox3->DataSource=$data;
- $this->DBListBox3->dataBind();
- }
- }
-
- public function DBListBox1Changed($sender,$param)
- {
- $this->collectSelectionResult($sender,$this->DBListBox1Result);
- }
-
- public function DBListBox2Changed($sender,$param)
- {
- $this->collectSelectionResult($sender,$this->DBListBox2Result);
- }
-
- public function DBListBox3Changed($sender,$param)
- {
- $this->collectSelectionResult($sender,$this->DBListBox3Result);
- }
-
- protected function collectSelectionResult($input,$output)
- {
- $indices=$input->SelectedIndices;
- $result='';
- foreach($indices as $index)
- {
- $item=$input->Items[$index];
- $result.="(Index: $index, Value: $item->Value, Text: $item->Text)";
- }
- if($result==='')
- $output->Text='Your selection is empty.';
- else
- $output->Text='Your selection is: '.$result;
- }
-
- public function selectionChanged($sender,$param)
- {
- $this->collectSelectionResult($sender,$this->SelectionResult);
- }
-
- public function buttonClicked($sender,$param)
- {
- $this->collectSelectionResult($this->ListBox1,$this->SelectionResult2);
- }
-
- public function multiSelectionChanged($sender,$param)
- {
- $this->collectSelectionResult($sender,$this->MultiSelectionResult);
- }
-
- public function buttonClicked2($sender,$param)
- {
- $this->collectSelectionResult($this->ListBox2,$this->MultiSelectionResult2);
- }
-}
-
+<?php + +class Home extends TPage +{ + public function onLoad($param) + { + parent::onLoad($param); + if(!$this->IsPostBack) + { + $data=array('item 1','item 2','item 3','item 4'); + $this->DBListBox1->DataSource=$data; + $this->DBListBox1->dataBind(); + + $data=array('key 1'=>'item 1','key 2'=>'item 2', + 'key 3'=>'item 3','key 4'=>'item 4'); + $this->DBListBox2->DataSource=$data; + $this->DBListBox2->dataBind(); + + $data=array( + array('id'=>'001','name'=>'John','age'=>31), + array('id'=>'002','name'=>'Mary','age'=>30), + array('id'=>'003','name'=>'Cary','age'=>20)); + $this->DBListBox3->DataSource=$data; + $this->DBListBox3->dataBind(); + } + } + + public function DBListBox1Changed($sender,$param) + { + $this->collectSelectionResult($sender,$this->DBListBox1Result); + } + + public function DBListBox2Changed($sender,$param) + { + $this->collectSelectionResult($sender,$this->DBListBox2Result); + } + + public function DBListBox3Changed($sender,$param) + { + $this->collectSelectionResult($sender,$this->DBListBox3Result); + } + + protected function collectSelectionResult($input,$output) + { + $indices=$input->SelectedIndices; + $result=''; + foreach($indices as $index) + { + $item=$input->Items[$index]; + $result.="(Index: $index, Value: $item->Value, Text: $item->Text)"; + } + if($result==='') + $output->Text='Your selection is empty.'; + else + $output->Text='Your selection is: '.$result; + } + + public function selectionChanged($sender,$param) + { + $this->collectSelectionResult($sender,$this->SelectionResult); + } + + public function buttonClicked($sender,$param) + { + $this->collectSelectionResult($this->ListBox1,$this->SelectionResult2); + } + + public function multiSelectionChanged($sender,$param) + { + $this->collectSelectionResult($sender,$this->MultiSelectionResult); + } + + public function buttonClicked2($sender,$param) + { + $this->collectSelectionResult($this->ListBox2,$this->MultiSelectionResult2); + } +} + ?>
\ No newline at end of file diff --git a/demos/quickstart/protected/pages/Controls/Samples/TMultiView/Home.php b/demos/quickstart/protected/pages/Controls/Samples/TMultiView/Home.php index 1a5dbed3..24a240ca 100644 --- a/demos/quickstart/protected/pages/Controls/Samples/TMultiView/Home.php +++ b/demos/quickstart/protected/pages/Controls/Samples/TMultiView/Home.php @@ -1,15 +1,15 @@ -<?php
-
-class Home extends TPage
-{
- public function viewChanged($sender,$param)
- {
- if($this->MultiView->ActiveViewIndex===2)
- {
- $this->Result1->Text="Your text input is: ".$this->Memo->Text;
- $this->Result2->Text="Your color choice is: ".$this->DropDownList->SelectedValue;
- }
- }
-}
-
+<?php + +class Home extends TPage +{ + public function viewChanged($sender,$param) + { + if($this->MultiView->ActiveViewIndex===2) + { + $this->Result1->Text="Your text input is: ".$this->Memo->Text; + $this->Result2->Text="Your color choice is: ".$this->DropDownList->SelectedValue; + } + } +} + ?>
\ No newline at end of file diff --git a/demos/quickstart/protected/pages/Controls/Samples/TPager/Sample1.php b/demos/quickstart/protected/pages/Controls/Samples/TPager/Sample1.php index e5446f60..86563cc1 100644 --- a/demos/quickstart/protected/pages/Controls/Samples/TPager/Sample1.php +++ b/demos/quickstart/protected/pages/Controls/Samples/TPager/Sample1.php @@ -1,82 +1,82 @@ -<?php
-
-class Sample1 extends TPage
-{
- /**
- * Returns total number of data items.
- * In DB-driven applications, this typically requires
- * execution of an SQL statement with COUNT function.
- * Here we simply return a constant number.
- */
- protected function getDataItemCount()
- {
- return 19;
- }
-
- /**
- * Fetches a page of data.
- * In DB-driven applications, this can be achieved by executing
- * an SQL query with LIMIT clause.
- */
- protected function getData($offset,$limit)
- {
- $data=array(
- array('id'=>'ITN001','name'=>'Motherboard','quantity'=>1,'price'=>100.00,'imported'=>true),
- array('id'=>'ITN002','name'=>'CPU','quantity'=>1,'price'=>150.00,'imported'=>true),
- array('id'=>'ITN003','name'=>'Harddrive','quantity'=>2,'price'=>80.00,'imported'=>true),
- array('id'=>'ITN004','name'=>'Sound card','quantity'=>1,'price'=>40.00,'imported'=>false),
- array('id'=>'ITN005','name'=>'Video card','quantity'=>1,'price'=>150.00,'imported'=>true),
- array('id'=>'ITN006','name'=>'Keyboard','quantity'=>1,'price'=>20.00,'imported'=>false),
- array('id'=>'ITN007','name'=>'Monitor','quantity'=>2,'price'=>300.00,'imported'=>true),
- array('id'=>'ITN008','name'=>'CDRW drive','quantity'=>1,'price'=>40.00,'imported'=>true),
- array('id'=>'ITN009','name'=>'Cooling fan','quantity'=>2,'price'=>10.00,'imported'=>false),
- array('id'=>'ITN010','name'=>'Video camera','quantity'=>20,'price'=>30.00,'imported'=>true),
- array('id'=>'ITN011','name'=>'Card reader','quantity'=>10,'price'=>24.00,'imported'=>true),
- array('id'=>'ITN012','name'=>'Floppy drive','quantity'=>50,'price'=>12.00,'imported'=>false),
- array('id'=>'ITN013','name'=>'CD drive','quantity'=>25,'price'=>20.00,'imported'=>true),
- array('id'=>'ITN014','name'=>'DVD drive','quantity'=>15,'price'=>80.00,'imported'=>true),
- array('id'=>'ITN015','name'=>'Mouse pad','quantity'=>50,'price'=>5.00,'imported'=>false),
- array('id'=>'ITN016','name'=>'Network cable','quantity'=>40,'price'=>8.00,'imported'=>true),
- array('id'=>'ITN017','name'=>'Case','quantity'=>8,'price'=>65.00,'imported'=>false),
- array('id'=>'ITN018','name'=>'Surge protector','quantity'=>45,'price'=>15.00,'imported'=>false),
- array('id'=>'ITN019','name'=>'Speaker','quantity'=>35,'price'=>65.00,'imported'=>false),
- );
- return array_slice($data,$offset,$limit);
- }
-
- /**
- * Determines which page of data to be displayed and
- * populates the datalist with the fetched data.
- */
- protected function populateData()
- {
- $offset=$this->DataList->CurrentPageIndex*$this->DataList->PageSize;
- $limit=$this->DataList->PageSize;
- if($offset+$limit>$this->DataList->VirtualItemCount)
- $limit=$this->DataList->VirtualItemCount-$offset;
- $data=$this->getData($offset,$limit);
- $this->DataList->DataSource=$data;
- $this->DataList->dataBind();
- }
-
- public function onLoad($param)
- {
- parent::onLoad($param);
- if(!$this->IsPostBack)
- {
- $this->DataList->VirtualItemCount=$this->DataItemCount;
- $this->populateData();
- }
- }
-
- /**
- * Event handler to the OnPageIndexChanged event of pagers.
- */
- public function pageChanged($sender,$param)
- {
- $this->DataList->CurrentPageIndex=$param->NewPageIndex;
- $this->populateData();
- }
-}
-
+<?php + +class Sample1 extends TPage +{ + /** + * Returns total number of data items. + * In DB-driven applications, this typically requires + * execution of an SQL statement with COUNT function. + * Here we simply return a constant number. + */ + protected function getDataItemCount() + { + return 19; + } + + /** + * Fetches a page of data. + * In DB-driven applications, this can be achieved by executing + * an SQL query with LIMIT clause. + */ + protected function getData($offset,$limit) + { + $data=array( + array('id'=>'ITN001','name'=>'Motherboard','quantity'=>1,'price'=>100.00,'imported'=>true), + array('id'=>'ITN002','name'=>'CPU','quantity'=>1,'price'=>150.00,'imported'=>true), + array('id'=>'ITN003','name'=>'Harddrive','quantity'=>2,'price'=>80.00,'imported'=>true), + array('id'=>'ITN004','name'=>'Sound card','quantity'=>1,'price'=>40.00,'imported'=>false), + array('id'=>'ITN005','name'=>'Video card','quantity'=>1,'price'=>150.00,'imported'=>true), + array('id'=>'ITN006','name'=>'Keyboard','quantity'=>1,'price'=>20.00,'imported'=>false), + array('id'=>'ITN007','name'=>'Monitor','quantity'=>2,'price'=>300.00,'imported'=>true), + array('id'=>'ITN008','name'=>'CDRW drive','quantity'=>1,'price'=>40.00,'imported'=>true), + array('id'=>'ITN009','name'=>'Cooling fan','quantity'=>2,'price'=>10.00,'imported'=>false), + array('id'=>'ITN010','name'=>'Video camera','quantity'=>20,'price'=>30.00,'imported'=>true), + array('id'=>'ITN011','name'=>'Card reader','quantity'=>10,'price'=>24.00,'imported'=>true), + array('id'=>'ITN012','name'=>'Floppy drive','quantity'=>50,'price'=>12.00,'imported'=>false), + array('id'=>'ITN013','name'=>'CD drive','quantity'=>25,'price'=>20.00,'imported'=>true), + array('id'=>'ITN014','name'=>'DVD drive','quantity'=>15,'price'=>80.00,'imported'=>true), + array('id'=>'ITN015','name'=>'Mouse pad','quantity'=>50,'price'=>5.00,'imported'=>false), + array('id'=>'ITN016','name'=>'Network cable','quantity'=>40,'price'=>8.00,'imported'=>true), + array('id'=>'ITN017','name'=>'Case','quantity'=>8,'price'=>65.00,'imported'=>false), + array('id'=>'ITN018','name'=>'Surge protector','quantity'=>45,'price'=>15.00,'imported'=>false), + array('id'=>'ITN019','name'=>'Speaker','quantity'=>35,'price'=>65.00,'imported'=>false), + ); + return array_slice($data,$offset,$limit); + } + + /** + * Determines which page of data to be displayed and + * populates the datalist with the fetched data. + */ + protected function populateData() + { + $offset=$this->DataList->CurrentPageIndex*$this->DataList->PageSize; + $limit=$this->DataList->PageSize; + if($offset+$limit>$this->DataList->VirtualItemCount) + $limit=$this->DataList->VirtualItemCount-$offset; + $data=$this->getData($offset,$limit); + $this->DataList->DataSource=$data; + $this->DataList->dataBind(); + } + + public function onLoad($param) + { + parent::onLoad($param); + if(!$this->IsPostBack) + { + $this->DataList->VirtualItemCount=$this->DataItemCount; + $this->populateData(); + } + } + + /** + * Event handler to the OnPageIndexChanged event of pagers. + */ + public function pageChanged($sender,$param) + { + $this->DataList->CurrentPageIndex=$param->NewPageIndex; + $this->populateData(); + } +} + ?>
\ No newline at end of file diff --git a/demos/quickstart/protected/pages/Controls/Samples/TPanel/Home.php b/demos/quickstart/protected/pages/Controls/Samples/TPanel/Home.php index d6cf1bd5..1864f380 100644 --- a/demos/quickstart/protected/pages/Controls/Samples/TPanel/Home.php +++ b/demos/quickstart/protected/pages/Controls/Samples/TPanel/Home.php @@ -1,11 +1,11 @@ -<?php
-
-class Home extends TPage
-{
- public function buttonClicked($sender,$param)
- {
- $this->Result->Text="You have clicked on '$sender->Text'.";
- }
-}
-
+<?php + +class Home extends TPage +{ + public function buttonClicked($sender,$param) + { + $this->Result->Text="You have clicked on '$sender->Text'."; + } +} + ?>
\ No newline at end of file diff --git a/demos/quickstart/protected/pages/Controls/Samples/TPlaceHolder/Home.php b/demos/quickstart/protected/pages/Controls/Samples/TPlaceHolder/Home.php index ecae7876..8987c230 100644 --- a/demos/quickstart/protected/pages/Controls/Samples/TPlaceHolder/Home.php +++ b/demos/quickstart/protected/pages/Controls/Samples/TPlaceHolder/Home.php @@ -1,16 +1,16 @@ -<?php
-
-class Home extends TPage
-{
- public function onInit($param)
- {
- parent::onInit($param);
- $label=new TLabel;
- $label->Text='dynamic';
- $label->BackColor='silver';
- $this->PlaceHolder1->Controls[]=$label;
- $this->PlaceHolder1->Controls[]=' content';
- }
-}
-
+<?php + +class Home extends TPage +{ + public function onInit($param) + { + parent::onInit($param); + $label=new TLabel; + $label->Text='dynamic'; + $label->BackColor='silver'; + $this->PlaceHolder1->Controls[]=$label; + $this->PlaceHolder1->Controls[]=' content'; + } +} + ?>
\ No newline at end of file diff --git a/demos/quickstart/protected/pages/Controls/Samples/TRadioButton/Home.php b/demos/quickstart/protected/pages/Controls/Samples/TRadioButton/Home.php index 034d2fcc..a0c2af32 100644 --- a/demos/quickstart/protected/pages/Controls/Samples/TRadioButton/Home.php +++ b/demos/quickstart/protected/pages/Controls/Samples/TRadioButton/Home.php @@ -1,27 +1,27 @@ -<?php
-
-class Home extends TPage
-{
- public function radiobuttonClicked($sender,$param)
- {
- $sender->Text="I'm clicked";
- }
-
- public function selectRadioButton($sender,$param)
- {
- $selection='';
- if($this->Radio1->Checked)
- $selection.='1';
- if($this->Radio2->Checked)
- $selection.='2';
- if($this->Radio3->Checked)
- $selection.='3';
- if($this->Radio4->Checked)
- $selection.='4';
- if($selection==='')
- $selection='empty';
- $this->Result->Text='Your selection is '.$selection;
- }
-}
-
+<?php + +class Home extends TPage +{ + public function radiobuttonClicked($sender,$param) + { + $sender->Text="I'm clicked"; + } + + public function selectRadioButton($sender,$param) + { + $selection=''; + if($this->Radio1->Checked) + $selection.='1'; + if($this->Radio2->Checked) + $selection.='2'; + if($this->Radio3->Checked) + $selection.='3'; + if($this->Radio4->Checked) + $selection.='4'; + if($selection==='') + $selection='empty'; + $this->Result->Text='Your selection is '.$selection; + } +} + ?>
\ No newline at end of file diff --git a/demos/quickstart/protected/pages/Controls/Samples/TRadioButtonList/Home.php b/demos/quickstart/protected/pages/Controls/Samples/TRadioButtonList/Home.php index b45441f9..62b4d7e7 100644 --- a/demos/quickstart/protected/pages/Controls/Samples/TRadioButtonList/Home.php +++ b/demos/quickstart/protected/pages/Controls/Samples/TRadioButtonList/Home.php @@ -1,69 +1,69 @@ -<?php
-
-class Home extends TPage
-{
- public function onLoad($param)
- {
- parent::onLoad($param);
- if(!$this->IsPostBack)
- {
- $data=array('item 1','item 2','item 3','item 4');
- $this->DBRadioButtonList1->DataSource=$data;
- $this->DBRadioButtonList1->dataBind();
-
- $data=array('key 1'=>'item 1','key 2'=>'item 2',
- 'key 3'=>'item 3','key 4'=>'item 4');
- $this->DBRadioButtonList2->DataSource=$data;
- $this->DBRadioButtonList2->dataBind();
-
- $data=array(
- array('id'=>'001','name'=>'John','age'=>31),
- array('id'=>'002','name'=>'Mary','age'=>30),
- array('id'=>'003','name'=>'Cary','age'=>20));
- $this->DBRadioButtonList3->DataSource=$data;
- $this->DBRadioButtonList3->dataBind();
- }
- }
-
- protected function collectSelectionResult($input,$output)
- {
- $indices=$input->SelectedIndices;
- $result='';
- foreach($indices as $index)
- {
- $item=$input->Items[$index];
- $result.="(Index: $index, Value: $item->Value, Text: $item->Text)";
- }
- if($result==='')
- $output->Text='Your selection is empty.';
- else
- $output->Text='Your selection is: '.$result;
- }
-
- public function buttonClicked($sender,$param)
- {
- $this->collectSelectionResult($this->RadioButtonList,$this->SelectionResult);
- }
-
- public function selectionChanged($sender,$param)
- {
- $this->collectSelectionResult($sender,$this->SelectionResult2);
- }
-
- public function DBRadioButtonList1Changed($sender,$param)
- {
- $this->collectSelectionResult($sender,$this->DBRadioButtonList1Result);
- }
-
- public function DBRadioButtonList2Changed($sender,$param)
- {
- $this->collectSelectionResult($sender,$this->DBRadioButtonList2Result);
- }
-
- public function DBRadioButtonList3Changed($sender,$param)
- {
- $this->collectSelectionResult($sender,$this->DBRadioButtonList3Result);
- }
-}
-
+<?php + +class Home extends TPage +{ + public function onLoad($param) + { + parent::onLoad($param); + if(!$this->IsPostBack) + { + $data=array('item 1','item 2','item 3','item 4'); + $this->DBRadioButtonList1->DataSource=$data; + $this->DBRadioButtonList1->dataBind(); + + $data=array('key 1'=>'item 1','key 2'=>'item 2', + 'key 3'=>'item 3','key 4'=>'item 4'); + $this->DBRadioButtonList2->DataSource=$data; + $this->DBRadioButtonList2->dataBind(); + + $data=array( + array('id'=>'001','name'=>'John','age'=>31), + array('id'=>'002','name'=>'Mary','age'=>30), + array('id'=>'003','name'=>'Cary','age'=>20)); + $this->DBRadioButtonList3->DataSource=$data; + $this->DBRadioButtonList3->dataBind(); + } + } + + protected function collectSelectionResult($input,$output) + { + $indices=$input->SelectedIndices; + $result=''; + foreach($indices as $index) + { + $item=$input->Items[$index]; + $result.="(Index: $index, Value: $item->Value, Text: $item->Text)"; + } + if($result==='') + $output->Text='Your selection is empty.'; + else + $output->Text='Your selection is: '.$result; + } + + public function buttonClicked($sender,$param) + { + $this->collectSelectionResult($this->RadioButtonList,$this->SelectionResult); + } + + public function selectionChanged($sender,$param) + { + $this->collectSelectionResult($sender,$this->SelectionResult2); + } + + public function DBRadioButtonList1Changed($sender,$param) + { + $this->collectSelectionResult($sender,$this->DBRadioButtonList1Result); + } + + public function DBRadioButtonList2Changed($sender,$param) + { + $this->collectSelectionResult($sender,$this->DBRadioButtonList2Result); + } + + public function DBRadioButtonList3Changed($sender,$param) + { + $this->collectSelectionResult($sender,$this->DBRadioButtonList3Result); + } +} + ?>
\ No newline at end of file diff --git a/demos/quickstart/protected/pages/Controls/Samples/TRangeValidator/Home.php b/demos/quickstart/protected/pages/Controls/Samples/TRangeValidator/Home.php index 88d2dbf2..1c5efbcf 100644 --- a/demos/quickstart/protected/pages/Controls/Samples/TRangeValidator/Home.php +++ b/demos/quickstart/protected/pages/Controls/Samples/TRangeValidator/Home.php @@ -1,8 +1,8 @@ -<?php
-
-class Home extends TPage
-{
-
-}
-
+<?php + +class Home extends TPage +{ + +} + ?>
\ No newline at end of file diff --git a/demos/quickstart/protected/pages/Controls/Samples/TRegularExpressionValidator/Home.php b/demos/quickstart/protected/pages/Controls/Samples/TRegularExpressionValidator/Home.php index 88d2dbf2..1c5efbcf 100644 --- a/demos/quickstart/protected/pages/Controls/Samples/TRegularExpressionValidator/Home.php +++ b/demos/quickstart/protected/pages/Controls/Samples/TRegularExpressionValidator/Home.php @@ -1,8 +1,8 @@ -<?php
-
-class Home extends TPage
-{
-
-}
-
+<?php + +class Home extends TPage +{ + +} + ?>
\ No newline at end of file diff --git a/demos/quickstart/protected/pages/Controls/Samples/TRepeater/RegionDisplay.php b/demos/quickstart/protected/pages/Controls/Samples/TRepeater/RegionDisplay.php index 40d1841e..4f7ab6c2 100644 --- a/demos/quickstart/protected/pages/Controls/Samples/TRepeater/RegionDisplay.php +++ b/demos/quickstart/protected/pages/Controls/Samples/TRepeater/RegionDisplay.php @@ -1,28 +1,28 @@ -<?php
-
-class RegionDisplay extends TRepeaterItemRenderer
-{
- /**
- * This method is invoked when the data is being bound
- * to the parent repeater.
- * At this time, the <b>Data</b> is available which
- * refers to the data row associated with the parent repeater item.
- */
- public function onDataBinding($param)
- {
- parent::onDataBinding($param);
- $this->Repeater->DataSource=$this->Data['detail'];
- $this->Repeater->dataBind();
- }
-
- public function itemCreated($sender,$param)
- {
- static $itemIndex=0;
- $item=$param->Item;
- if($item->ItemType==='Item' || $item->ItemType==='AlternatingItem')
- $item->Row->BackColor=$itemIndex%2 ? "#BFCFFF" : "#E6ECFF";
- $itemIndex++;
- }
-}
-
+<?php + +class RegionDisplay extends TRepeaterItemRenderer +{ + /** + * This method is invoked when the data is being bound + * to the parent repeater. + * At this time, the <b>Data</b> is available which + * refers to the data row associated with the parent repeater item. + */ + public function onDataBinding($param) + { + parent::onDataBinding($param); + $this->Repeater->DataSource=$this->Data['detail']; + $this->Repeater->dataBind(); + } + + public function itemCreated($sender,$param) + { + static $itemIndex=0; + $item=$param->Item; + if($item->ItemType==='Item' || $item->ItemType==='AlternatingItem') + $item->Row->BackColor=$itemIndex%2 ? "#BFCFFF" : "#E6ECFF"; + $itemIndex++; + } +} + ?>
\ No newline at end of file diff --git a/demos/quickstart/protected/pages/Controls/Samples/TRepeater/Sample1.php b/demos/quickstart/protected/pages/Controls/Samples/TRepeater/Sample1.php index 905a3b8d..c3cff79b 100644 --- a/demos/quickstart/protected/pages/Controls/Samples/TRepeater/Sample1.php +++ b/demos/quickstart/protected/pages/Controls/Samples/TRepeater/Sample1.php @@ -1,41 +1,41 @@ -<?php
-
-class Sample1 extends TPage
-{
- protected function getData()
- {
- return array(
- array('id'=>'ITN001','name'=>'Motherboard','quantity'=>1,'price'=>100.00,'imported'=>true),
- array('id'=>'ITN002','name'=>'CPU','quantity'=>1,'price'=>150.00,'imported'=>true),
- array('id'=>'ITN003','name'=>'Harddrive','quantity'=>2,'price'=>80.00,'imported'=>true),
- array('id'=>'ITN004','name'=>'Sound card','quantity'=>1,'price'=>40.00,'imported'=>false),
- array('id'=>'ITN005','name'=>'Video card','quantity'=>1,'price'=>150.00,'imported'=>true),
- array('id'=>'ITN006','name'=>'Keyboard','quantity'=>1,'price'=>20.00,'imported'=>false),
- array('id'=>'ITN007','name'=>'Monitor','quantity'=>2,'price'=>300.00,'imported'=>true),
- array('id'=>'ITN008','name'=>'CDRW drive','quantity'=>1,'price'=>40.00,'imported'=>true),
- array('id'=>'ITN009','name'=>'Cooling fan','quantity'=>2,'price'=>10.00,'imported'=>false),
- array('id'=>'ITN010','name'=>'Video camera','quantity'=>20,'price'=>30.00,'imported'=>true),
- array('id'=>'ITN011','name'=>'Card reader','quantity'=>10,'price'=>24.00,'imported'=>true),
- array('id'=>'ITN012','name'=>'Floppy drive','quantity'=>50,'price'=>12.00,'imported'=>false),
- array('id'=>'ITN013','name'=>'CD drive','quantity'=>25,'price'=>20.00,'imported'=>true),
- array('id'=>'ITN014','name'=>'DVD drive','quantity'=>15,'price'=>80.00,'imported'=>true),
- array('id'=>'ITN015','name'=>'Mouse pad','quantity'=>50,'price'=>5.00,'imported'=>false),
- array('id'=>'ITN016','name'=>'Network cable','quantity'=>40,'price'=>8.00,'imported'=>true),
- array('id'=>'ITN017','name'=>'Case','quantity'=>8,'price'=>65.00,'imported'=>false),
- array('id'=>'ITN018','name'=>'Surge protector','quantity'=>45,'price'=>15.00,'imported'=>false),
- array('id'=>'ITN019','name'=>'Speaker','quantity'=>35,'price'=>65.00,'imported'=>false),
- );
- }
-
- public function onLoad($param)
- {
- parent::onLoad($param);
- if(!$this->IsPostBack)
- {
- $this->Repeater->DataSource=$this->getData();
- $this->Repeater->dataBind();
- }
- }
-}
-
+<?php + +class Sample1 extends TPage +{ + protected function getData() + { + return array( + array('id'=>'ITN001','name'=>'Motherboard','quantity'=>1,'price'=>100.00,'imported'=>true), + array('id'=>'ITN002','name'=>'CPU','quantity'=>1,'price'=>150.00,'imported'=>true), + array('id'=>'ITN003','name'=>'Harddrive','quantity'=>2,'price'=>80.00,'imported'=>true), + array('id'=>'ITN004','name'=>'Sound card','quantity'=>1,'price'=>40.00,'imported'=>false), + array('id'=>'ITN005','name'=>'Video card','quantity'=>1,'price'=>150.00,'imported'=>true), + array('id'=>'ITN006','name'=>'Keyboard','quantity'=>1,'price'=>20.00,'imported'=>false), + array('id'=>'ITN007','name'=>'Monitor','quantity'=>2,'price'=>300.00,'imported'=>true), + array('id'=>'ITN008','name'=>'CDRW drive','quantity'=>1,'price'=>40.00,'imported'=>true), + array('id'=>'ITN009','name'=>'Cooling fan','quantity'=>2,'price'=>10.00,'imported'=>false), + array('id'=>'ITN010','name'=>'Video camera','quantity'=>20,'price'=>30.00,'imported'=>true), + array('id'=>'ITN011','name'=>'Card reader','quantity'=>10,'price'=>24.00,'imported'=>true), + array('id'=>'ITN012','name'=>'Floppy drive','quantity'=>50,'price'=>12.00,'imported'=>false), + array('id'=>'ITN013','name'=>'CD drive','quantity'=>25,'price'=>20.00,'imported'=>true), + array('id'=>'ITN014','name'=>'DVD drive','quantity'=>15,'price'=>80.00,'imported'=>true), + array('id'=>'ITN015','name'=>'Mouse pad','quantity'=>50,'price'=>5.00,'imported'=>false), + array('id'=>'ITN016','name'=>'Network cable','quantity'=>40,'price'=>8.00,'imported'=>true), + array('id'=>'ITN017','name'=>'Case','quantity'=>8,'price'=>65.00,'imported'=>false), + array('id'=>'ITN018','name'=>'Surge protector','quantity'=>45,'price'=>15.00,'imported'=>false), + array('id'=>'ITN019','name'=>'Speaker','quantity'=>35,'price'=>65.00,'imported'=>false), + ); + } + + public function onLoad($param) + { + parent::onLoad($param); + if(!$this->IsPostBack) + { + $this->Repeater->DataSource=$this->getData(); + $this->Repeater->dataBind(); + } + } +} + ?>
\ No newline at end of file diff --git a/demos/quickstart/protected/pages/Controls/Samples/TRepeater/Sample2.php b/demos/quickstart/protected/pages/Controls/Samples/TRepeater/Sample2.php index e84580a2..803201e9 100644 --- a/demos/quickstart/protected/pages/Controls/Samples/TRepeater/Sample2.php +++ b/demos/quickstart/protected/pages/Controls/Samples/TRepeater/Sample2.php @@ -1,79 +1,79 @@ -<?php
-
-class Sample2 extends TPage
-{
- protected function getMasterData()
- {
- return array('North','West','East','South');
- }
-
- protected function getDetailData($region)
- {
- static $data=array(
- 'North'=>array(
- array('name'=>'John','age'=>30,'position'=>'Program Manager'),
- array('name'=>'Edward','age'=>35,'position'=>'Developer'),
- array('name'=>'Walter','age'=>28,'position'=>'Developer'),
- ),
- 'West'=>array(
- array('name'=>'Cary','age'=>31,'position'=>'Senior Manager'),
- array('name'=>'Ted','age'=>25,'position'=>'Developer'),
- array('name'=>'Kevin','age'=>28,'position'=>'Developer'),
- ),
- 'East'=>array(
- array('name'=>'Shawn','age'=>30,'position'=>'Sales Manager'),
- array('name'=>'Larry','age'=>28,'position'=>'Document Writer'),
- ),
- 'South'=>array(
- array('name'=>'King','age'=>30,'position'=>'Program Manager'),
- array('name'=>'Carter','age'=>22,'position'=>'Developer'),
- ),
- );
- return $data[$region];
- }
-
- public function onLoad($param)
- {
- parent::onLoad($param);
- if(!$this->IsPostBack)
- {
- $this->Repeater->DataSource=$this->getMasterData();
- $this->Repeater->dataBind();
- }
- }
-
- public function dataBindRepeater2($sender,$param)
- {
- $item=$param->Item;
- if($item->ItemType==='Item' || $item->ItemType==='AlternatingItem')
- {
- $item->Repeater2->DataSource=$this->getDetailData($item->DataItem);
- $item->Repeater2->dataBind();
- }
- }
-
- public function repeaterItemCreated($sender,$param)
- {
- static $itemIndex=0;
- $item=$param->Item;
- if($item->ItemType==='Item' || $item->ItemType==='AlternatingItem')
- {
- $item->Cell->BackColor=$itemIndex%2 ? "#6078BF" : "#809FFF";
- $item->Cell->ForeColor='white';
- $itemIndex++;
- }
- }
-
- public function repeater2ItemCreated($sender,$param)
- {
- static $itemIndex=0;
- $item=$param->Item;
- if($item->ItemType==='Item' || $item->ItemType==='AlternatingItem')
- {
- $item->Row->BackColor=$itemIndex%2 ? "#BFCFFF" : "#E6ECFF";
- $itemIndex++;
- }
- }
-}
-
+<?php + +class Sample2 extends TPage +{ + protected function getMasterData() + { + return array('North','West','East','South'); + } + + protected function getDetailData($region) + { + static $data=array( + 'North'=>array( + array('name'=>'John','age'=>30,'position'=>'Program Manager'), + array('name'=>'Edward','age'=>35,'position'=>'Developer'), + array('name'=>'Walter','age'=>28,'position'=>'Developer'), + ), + 'West'=>array( + array('name'=>'Cary','age'=>31,'position'=>'Senior Manager'), + array('name'=>'Ted','age'=>25,'position'=>'Developer'), + array('name'=>'Kevin','age'=>28,'position'=>'Developer'), + ), + 'East'=>array( + array('name'=>'Shawn','age'=>30,'position'=>'Sales Manager'), + array('name'=>'Larry','age'=>28,'position'=>'Document Writer'), + ), + 'South'=>array( + array('name'=>'King','age'=>30,'position'=>'Program Manager'), + array('name'=>'Carter','age'=>22,'position'=>'Developer'), + ), + ); + return $data[$region]; + } + + public function onLoad($param) + { + parent::onLoad($param); + if(!$this->IsPostBack) + { + $this->Repeater->DataSource=$this->getMasterData(); + $this->Repeater->dataBind(); + } + } + + public function dataBindRepeater2($sender,$param) + { + $item=$param->Item; + if($item->ItemType==='Item' || $item->ItemType==='AlternatingItem') + { + $item->Repeater2->DataSource=$this->getDetailData($item->DataItem); + $item->Repeater2->dataBind(); + } + } + + public function repeaterItemCreated($sender,$param) + { + static $itemIndex=0; + $item=$param->Item; + if($item->ItemType==='Item' || $item->ItemType==='AlternatingItem') + { + $item->Cell->BackColor=$itemIndex%2 ? "#6078BF" : "#809FFF"; + $item->Cell->ForeColor='white'; + $itemIndex++; + } + } + + public function repeater2ItemCreated($sender,$param) + { + static $itemIndex=0; + $item=$param->Item; + if($item->ItemType==='Item' || $item->ItemType==='AlternatingItem') + { + $item->Row->BackColor=$itemIndex%2 ? "#BFCFFF" : "#E6ECFF"; + $itemIndex++; + } + } +} + ?>
\ 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 index d4f4c8e9..dbaf598f 100644 --- a/demos/quickstart/protected/pages/Controls/Samples/TRepeater/Sample3.php +++ b/demos/quickstart/protected/pages/Controls/Samples/TRepeater/Sample3.php @@ -1,79 +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();
- }
- }
-}
-
+<?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/demos/quickstart/protected/pages/Controls/Samples/TRepeater/Sample4.php b/demos/quickstart/protected/pages/Controls/Samples/TRepeater/Sample4.php index aabab157..fb0e4922 100644 --- a/demos/quickstart/protected/pages/Controls/Samples/TRepeater/Sample4.php +++ b/demos/quickstart/protected/pages/Controls/Samples/TRepeater/Sample4.php @@ -1,37 +1,37 @@ -<?php
-
-Prado::using('System.Collections.TDummyDataSource');
-
-class Sample4 extends TPage
-{
- public function onLoad($param)
- {
- parent::onLoad($param);
- if(!$this->IsPostBack)
- {
- // use a dummy data source to create 3 repeater items
- $this->Repeater->DataSource=new TDummyDataSource(3);
- $this->Repeater->dataBind();
- }
- }
-
- public function itemCreated($sender,$param)
- {
- // $param->Item refers to the newly created repeater item
- $param->Item->Style="width:300px; margin:10px; margin-left:0px";
- }
-
- public function buttonClicked($sender,$param)
- {
- $links=array();
- foreach($this->Repeater->Items as $textBox)
- {
- if($textBox->Text!=='')
- $links[]=$textBox->Text;
- }
- $this->Repeater2->DataSource=$links;
- $this->Repeater2->dataBind();
- }
-}
-
+<?php + +Prado::using('System.Collections.TDummyDataSource'); + +class Sample4 extends TPage +{ + public function onLoad($param) + { + parent::onLoad($param); + if(!$this->IsPostBack) + { + // use a dummy data source to create 3 repeater items + $this->Repeater->DataSource=new TDummyDataSource(3); + $this->Repeater->dataBind(); + } + } + + public function itemCreated($sender,$param) + { + // $param->Item refers to the newly created repeater item + $param->Item->Style="width:300px; margin:10px; margin-left:0px"; + } + + public function buttonClicked($sender,$param) + { + $links=array(); + foreach($this->Repeater->Items as $textBox) + { + if($textBox->Text!=='') + $links[]=$textBox->Text; + } + $this->Repeater2->DataSource=$links; + $this->Repeater2->dataBind(); + } +} + ?>
\ No newline at end of file diff --git a/demos/quickstart/protected/pages/Controls/Samples/TRepeater/Sample5.php b/demos/quickstart/protected/pages/Controls/Samples/TRepeater/Sample5.php index 60beb30e..de6e5bd9 100644 --- a/demos/quickstart/protected/pages/Controls/Samples/TRepeater/Sample5.php +++ b/demos/quickstart/protected/pages/Controls/Samples/TRepeater/Sample5.php @@ -1,52 +1,52 @@ -<?php
-
-class Sample5 extends TPage
-{
- protected function getData()
- {
- return array(
- array(
- 'name'=>'North',
- 'detail'=>array(
- array('name'=>'John','age'=>30,'position'=>'Program Manager'),
- array('name'=>'Edward','age'=>35,'position'=>'Developer'),
- array('name'=>'Walter','age'=>28,'position'=>'Developer'),
- ),
- ),
- array(
- 'name'=>'West',
- 'detail'=>array(
- array('name'=>'Cary','age'=>31,'position'=>'Senior Manager'),
- array('name'=>'Ted','age'=>25,'position'=>'Developer'),
- array('name'=>'Kevin','age'=>28,'position'=>'Developer'),
- ),
- ),
- array(
- 'name'=>'East',
- 'detail'=>array(
- array('name'=>'Shawn','age'=>30,'position'=>'Sales Manager'),
- array('name'=>'Larry','age'=>28,'position'=>'Document Writer'),
- ),
- ),
- array(
- 'name'=>'South',
- 'detail'=>array(
- array('name'=>'King','age'=>30,'position'=>'Program Manager'),
- array('name'=>'Carter','age'=>22,'position'=>'Developer'),
- ),
- ),
- );
- }
-
- public function onLoad($param)
- {
- parent::onLoad($param);
- if(!$this->IsPostBack)
- {
- $this->Repeater->DataSource=$this->getData();
- $this->Repeater->dataBind();
- }
- }
-}
-
+<?php + +class Sample5 extends TPage +{ + protected function getData() + { + return array( + array( + 'name'=>'North', + 'detail'=>array( + array('name'=>'John','age'=>30,'position'=>'Program Manager'), + array('name'=>'Edward','age'=>35,'position'=>'Developer'), + array('name'=>'Walter','age'=>28,'position'=>'Developer'), + ), + ), + array( + 'name'=>'West', + 'detail'=>array( + array('name'=>'Cary','age'=>31,'position'=>'Senior Manager'), + array('name'=>'Ted','age'=>25,'position'=>'Developer'), + array('name'=>'Kevin','age'=>28,'position'=>'Developer'), + ), + ), + array( + 'name'=>'East', + 'detail'=>array( + array('name'=>'Shawn','age'=>30,'position'=>'Sales Manager'), + array('name'=>'Larry','age'=>28,'position'=>'Document Writer'), + ), + ), + array( + 'name'=>'South', + 'detail'=>array( + array('name'=>'King','age'=>30,'position'=>'Program Manager'), + array('name'=>'Carter','age'=>22,'position'=>'Developer'), + ), + ), + ); + } + + public function onLoad($param) + { + parent::onLoad($param); + if(!$this->IsPostBack) + { + $this->Repeater->DataSource=$this->getData(); + $this->Repeater->dataBind(); + } + } +} + ?>
\ No newline at end of file diff --git a/demos/quickstart/protected/pages/Controls/Samples/TRequiredFieldValidator/Home.php b/demos/quickstart/protected/pages/Controls/Samples/TRequiredFieldValidator/Home.php index 88d2dbf2..1c5efbcf 100644 --- a/demos/quickstart/protected/pages/Controls/Samples/TRequiredFieldValidator/Home.php +++ b/demos/quickstart/protected/pages/Controls/Samples/TRequiredFieldValidator/Home.php @@ -1,8 +1,8 @@ -<?php
-
-class Home extends TPage
-{
-
-}
-
+<?php + +class Home extends TPage +{ + +} + ?>
\ No newline at end of file diff --git a/demos/quickstart/protected/pages/Controls/Samples/TSlider/Home.php b/demos/quickstart/protected/pages/Controls/Samples/TSlider/Home.php index c1c8a711..228fd727 100644 --- a/demos/quickstart/protected/pages/Controls/Samples/TSlider/Home.php +++ b/demos/quickstart/protected/pages/Controls/Samples/TSlider/Home.php @@ -1,9 +1,9 @@ <?php class Home extends TPage -{
- public function onInit ($param)
- {
- parent::onInit($param);
+{ + public function onInit ($param) + { + parent::onInit($param); } public function submit1 ($sender, $param) { diff --git a/demos/quickstart/protected/pages/Controls/Samples/TTabPanel/Home.php b/demos/quickstart/protected/pages/Controls/Samples/TTabPanel/Home.php index badbca73..b03361b8 100644 --- a/demos/quickstart/protected/pages/Controls/Samples/TTabPanel/Home.php +++ b/demos/quickstart/protected/pages/Controls/Samples/TTabPanel/Home.php @@ -1,7 +1,7 @@ -<?php
-
-class Home extends TPage
-{
-}
-
+<?php + +class Home extends TPage +{ +} + ?>
\ No newline at end of file diff --git a/demos/quickstart/protected/pages/Controls/Samples/TTable/Home.php b/demos/quickstart/protected/pages/Controls/Samples/TTable/Home.php index fa5efe38..505a6ded 100644 --- a/demos/quickstart/protected/pages/Controls/Samples/TTable/Home.php +++ b/demos/quickstart/protected/pages/Controls/Samples/TTable/Home.php @@ -1,33 +1,33 @@ -<?php
-
-class Home extends TPage
-{
- public function onLoad($param)
- {
- $this->Table->GridLines='Both';
-
- $row=new TTableRow;
- $this->Table->Rows[]=$row;
-
- $cell=new TTableHeaderCell;
- $cell->Text='Header 1';
- $row->Cells[]=$cell;
-
- $cell=new TTableHeaderCell;
- $cell->Text='Header 2';
- $row->Cells[]=$cell;
-
- $row=new TTableRow;
- $this->Table->Rows[]=$row;
-
- $cell=new TTableCell;
- $cell->Text='Cell 1';
- $row->Cells[]=$cell;
-
- $cell=new TTableCell;
- $cell->Text='Cell 2';
- $row->Cells[]=$cell;
- }
-}
-
+<?php + +class Home extends TPage +{ + public function onLoad($param) + { + $this->Table->GridLines='Both'; + + $row=new TTableRow; + $this->Table->Rows[]=$row; + + $cell=new TTableHeaderCell; + $cell->Text='Header 1'; + $row->Cells[]=$cell; + + $cell=new TTableHeaderCell; + $cell->Text='Header 2'; + $row->Cells[]=$cell; + + $row=new TTableRow; + $this->Table->Rows[]=$row; + + $cell=new TTableCell; + $cell->Text='Cell 1'; + $row->Cells[]=$cell; + + $cell=new TTableCell; + $cell->Text='Cell 2'; + $row->Cells[]=$cell; + } +} + ?>
\ No newline at end of file diff --git a/demos/quickstart/protected/pages/Controls/Samples/TTextBox/Home.php b/demos/quickstart/protected/pages/Controls/Samples/TTextBox/Home.php index f8aa0825..2ac0cb3f 100644 --- a/demos/quickstart/protected/pages/Controls/Samples/TTextBox/Home.php +++ b/demos/quickstart/protected/pages/Controls/Samples/TTextBox/Home.php @@ -1,22 +1,22 @@ -<?php
-
-class Home extends TPage
-{
- public function onLoad($param)
- {
- parent::onLoad($param);
- $this->Output->dataBind();
- }
-
- public function textChanged($sender,$param)
- {
- $sender->Text="text changed";
- }
-
- public function submitText($sender,$param)
- {
- $this->TextBox1->Text="You just entered '".$this->TextBox1->Text."'.";
- }
-}
-
+<?php + +class Home extends TPage +{ + public function onLoad($param) + { + parent::onLoad($param); + $this->Output->dataBind(); + } + + public function textChanged($sender,$param) + { + $sender->Text="text changed"; + } + + public function submitText($sender,$param) + { + $this->TextBox1->Text="You just entered '".$this->TextBox1->Text."'."; + } +} + ?>
\ No newline at end of file diff --git a/demos/quickstart/protected/pages/Controls/Samples/TValidationSummary/Home.php b/demos/quickstart/protected/pages/Controls/Samples/TValidationSummary/Home.php index 88d2dbf2..1c5efbcf 100644 --- a/demos/quickstart/protected/pages/Controls/Samples/TValidationSummary/Home.php +++ b/demos/quickstart/protected/pages/Controls/Samples/TValidationSummary/Home.php @@ -1,8 +1,8 @@ -<?php
-
-class Home extends TPage
-{
-
-}
-
+<?php + +class Home extends TPage +{ + +} + ?>
\ No newline at end of file diff --git a/demos/quickstart/protected/pages/Controls/Samples/TWizard/Sample1.php b/demos/quickstart/protected/pages/Controls/Samples/TWizard/Sample1.php index 20440e62..5d9bcb1d 100644 --- a/demos/quickstart/protected/pages/Controls/Samples/TWizard/Sample1.php +++ b/demos/quickstart/protected/pages/Controls/Samples/TWizard/Sample1.php @@ -1,11 +1,11 @@ -<?php
-
-class Sample1 extends TPage
-{
- public function wizardCompleted($sender,$param)
- {
- $this->Result->Text="Your favorite color is: " . $this->DropDownList1->SelectedValue;
- }
-}
-
+<?php + +class Sample1 extends TPage +{ + public function wizardCompleted($sender,$param) + { + $this->Result->Text="Your favorite color is: " . $this->DropDownList1->SelectedValue; + } +} + ?>
\ No newline at end of file diff --git a/demos/quickstart/protected/pages/Controls/Samples/TWizard/Sample2.php b/demos/quickstart/protected/pages/Controls/Samples/TWizard/Sample2.php index a508fbf3..61572075 100644 --- a/demos/quickstart/protected/pages/Controls/Samples/TWizard/Sample2.php +++ b/demos/quickstart/protected/pages/Controls/Samples/TWizard/Sample2.php @@ -1,11 +1,11 @@ -<?php
-
-class Sample2 extends TPage
-{
- public function wizardCompleted($sender,$param)
- {
- $this->Result->Text="Your favorite color is: " . $this->DropDownList1->SelectedValue;
- }
-}
-
+<?php + +class Sample2 extends TPage +{ + public function wizardCompleted($sender,$param) + { + $this->Result->Text="Your favorite color is: " . $this->DropDownList1->SelectedValue; + } +} + ?>
\ No newline at end of file diff --git a/demos/quickstart/protected/pages/Controls/Samples/TWizard/Sample3.php b/demos/quickstart/protected/pages/Controls/Samples/TWizard/Sample3.php index d85d041a..6e767cd4 100644 --- a/demos/quickstart/protected/pages/Controls/Samples/TWizard/Sample3.php +++ b/demos/quickstart/protected/pages/Controls/Samples/TWizard/Sample3.php @@ -1,25 +1,25 @@ -<?php
-
-class Sample3 extends TPage
-{
- public function wizard3Completed($sender,$param)
- {
- if($this->StudentCheckBox->Checked)
- {
- $str="You are a college student.<br/>";
- $str.="You are in major: ".$this->DropDownList11->SelectedValue."<br/>";
- $str.="Your favorite sport is: ".$this->DropDownList22->SelectedValue;
- }
- else
- $str="Your favorite sport is: ".$this->DropDownList22->SelectedValue;
- $this->Wizard3Result->Text=$str;
- }
-
- public function wizard3NextStep($sender,$param)
- {
- if($param->CurrentStepIndex===0 && !$this->StudentCheckBox->Checked)
- $this->Wizard3->ActiveStepIndex=2;
- }
-}
-
+<?php + +class Sample3 extends TPage +{ + public function wizard3Completed($sender,$param) + { + if($this->StudentCheckBox->Checked) + { + $str="You are a college student.<br/>"; + $str.="You are in major: ".$this->DropDownList11->SelectedValue."<br/>"; + $str.="Your favorite sport is: ".$this->DropDownList22->SelectedValue; + } + else + $str="Your favorite sport is: ".$this->DropDownList22->SelectedValue; + $this->Wizard3Result->Text=$str; + } + + public function wizard3NextStep($sender,$param) + { + if($param->CurrentStepIndex===0 && !$this->StudentCheckBox->Checked) + $this->Wizard3->ActiveStepIndex=2; + } +} + ?>
\ No newline at end of file diff --git a/demos/quickstart/protected/pages/Controls/Samples/TWizard/Sample4.php b/demos/quickstart/protected/pages/Controls/Samples/TWizard/Sample4.php index 6b79698d..c7317654 100644 --- a/demos/quickstart/protected/pages/Controls/Samples/TWizard/Sample4.php +++ b/demos/quickstart/protected/pages/Controls/Samples/TWizard/Sample4.php @@ -1,11 +1,11 @@ -<?php
-
-class Sample4 extends TPage
-{
- public function wizardCompleted($sender,$param)
- {
- $this->Result->Text="Your favorite color is: " . $this->DropDownList1->SelectedValue;
- }
-}
-
+<?php + +class Sample4 extends TPage +{ + public function wizardCompleted($sender,$param) + { + $this->Result->Text="Your favorite color is: " . $this->DropDownList1->SelectedValue; + } +} + ?>
\ No newline at end of file diff --git a/demos/quickstart/protected/pages/Controls/Samples/TWizard/Sample5.php b/demos/quickstart/protected/pages/Controls/Samples/TWizard/Sample5.php index 4ab6d08b..4fb64395 100644 --- a/demos/quickstart/protected/pages/Controls/Samples/TWizard/Sample5.php +++ b/demos/quickstart/protected/pages/Controls/Samples/TWizard/Sample5.php @@ -1,12 +1,12 @@ -<?php
-
-class Sample5 extends TPage
-{
- public function wizardCompleted($sender,$param)
- {
- $this->Result1->Text="Your favorite color is: " . $this->DropDownList1->SelectedValue;
- $this->Result2->Text="Your favorite sport is: " . $this->Step2->DropDownList2->SelectedValue;
- }
-}
-
+<?php + +class Sample5 extends TPage +{ + public function wizardCompleted($sender,$param) + { + $this->Result1->Text="Your favorite color is: " . $this->DropDownList1->SelectedValue; + $this->Result2->Text="Your favorite sport is: " . $this->Step2->DropDownList2->SelectedValue; + } +} + ?>
\ No newline at end of file diff --git a/demos/quickstart/protected/pages/Database/Samples/Scaffold/Home.php b/demos/quickstart/protected/pages/Database/Samples/Scaffold/Home.php index 45d72f1f..4801baed 100644 --- a/demos/quickstart/protected/pages/Database/Samples/Scaffold/Home.php +++ b/demos/quickstart/protected/pages/Database/Samples/Scaffold/Home.php @@ -1,33 +1,33 @@ -<?php
-
-Prado::using('System.Data.ActiveRecord.TActiveRecord');
-Prado::using('System.Data.ActiveRecord.Scaffold.TScaffoldView');
-
-class AddressRecord extends TActiveRecord
-{
- const TABLE='addresses';
-
- public $id;
- public $username;
- public $phone;
-
- //for demo, we use static db here
- //otherwise we should use TActiveRecordConfig in application.xml
- private static $_db;
- public function getDbConnection()
- {
- if(self::$_db===null)
- {
- $file = dirname(__FILE__).'/sqlite.db';
- self::$_db = new TDbConnection("sqlite:{$file}");
- }
- return self::$_db;
- }
-}
-
-class Home extends TPage
-{
-
-}
-
+<?php + +Prado::using('System.Data.ActiveRecord.TActiveRecord'); +Prado::using('System.Data.ActiveRecord.Scaffold.TScaffoldView'); + +class AddressRecord extends TActiveRecord +{ + const TABLE='addresses'; + + public $id; + public $username; + public $phone; + + //for demo, we use static db here + //otherwise we should use TActiveRecordConfig in application.xml + private static $_db; + public function getDbConnection() + { + if(self::$_db===null) + { + $file = dirname(__FILE__).'/sqlite.db'; + self::$_db = new TDbConnection("sqlite:{$file}"); + } + return self::$_db; + } +} + +class Home extends TPage +{ + +} + ?>
\ No newline at end of file diff --git a/demos/quickstart/protected/pages/Fundamentals/Samples/Hangman/Home.php b/demos/quickstart/protected/pages/Fundamentals/Samples/Hangman/Home.php index 711600aa..6aff0859 100644 --- a/demos/quickstart/protected/pages/Fundamentals/Samples/Hangman/Home.php +++ b/demos/quickstart/protected/pages/Fundamentals/Samples/Hangman/Home.php @@ -1,121 +1,121 @@ -<?php
-class Home extends TPage
-{
- public function onLoad($param)
- {
- if (!$this->IsPostBack)
- $this->GameMultiView->ActiveView=$this->IntroView;
- }
-
- public function selectLevel($sender,$param)
- {
- if(($selection=$this->LevelSelection->SelectedValue)==='')
- {
- $this->LevelError->Visible=true;
- return;
- }
- else
- $this->Level=TPropertyValue::ensureInteger($selection);
- $this->Word=$this->generateWord();
- $this->GuessWord=str_repeat('_',strlen($this->Word));
- $this->Misses=0;
- $this->GameMultiView->ActiveView=$this->GuessView;
- }
-
- public function guessWord($sender,$param)
- {
- $sender->Enabled=false;
- $letter=$sender->Text;
- $word=$this->Word;
- $guessWord=$this->GuessWord;
- $pos=0;
- $success=false;
- while(($pos=strpos($word,$letter,$pos))!==false)
- {
- $guessWord[$pos]=$letter;
- $success=true;
- $pos++;
- }
- if($success)
- {
- $this->GuessWord=$guessWord;
- if($guessWord===$word)
- $this->GameMultiView->ActiveView=$this->WinView;
- }
- else
- {
- $this->Misses++;
- if($this->Misses>=$this->Level)
- $this->giveUp(null,null);
- }
- }
-
- public function giveUp($sender,$param)
- {
- $this->GameMultiView->ActiveView=$this->LoseView;
- }
-
- public function startAgain($sender,$param)
- {
- $this->GameMultiView->ActiveView=$this->IntroView;
- $this->LevelError->Visible=false;
- for($letter=65;$letter<=90;++$letter)
- {
- $guessLetter='Guess'.chr($letter);
- $this->$guessLetter->Enabled=true;
- }
- }
-
- protected function generateWord()
- {
- $wordFile=dirname(__FILE__).'/words.txt';
- $words=preg_split("/[\s,]+/",file_get_contents($wordFile));
- do
- {
- $i=rand(0,count($words)-1);
- $word=$words[$i];
- } while(strlen($word)<5 || !preg_match('/^[a-z]*$/i',$word));
- return strtoupper($word);
- }
-
- public function setLevel($value)
- {
- $this->setViewState('Level',$value,0);
- }
-
- public function getLevel()
- {
- return $this->getViewState('Level',0);
- }
-
- public function setWord($value)
- {
- $this->setViewState('Word',$value,'');
- }
-
- public function getWord()
- {
- return $this->getViewState('Word','');
- }
-
- public function getGuessWord()
- {
- return $this->getViewState('GuessWord','');
- }
-
- public function setGuessWord($value)
- {
- $this->setViewState('GuessWord',$value,'');
- }
-
- public function setMisses($value)
- {
- $this->setViewState('Misses',$value,0);
- }
-
- public function getMisses()
- {
- return $this->getViewState('Misses',0);
- }
-}
+<?php +class Home extends TPage +{ + public function onLoad($param) + { + if (!$this->IsPostBack) + $this->GameMultiView->ActiveView=$this->IntroView; + } + + public function selectLevel($sender,$param) + { + if(($selection=$this->LevelSelection->SelectedValue)==='') + { + $this->LevelError->Visible=true; + return; + } + else + $this->Level=TPropertyValue::ensureInteger($selection); + $this->Word=$this->generateWord(); + $this->GuessWord=str_repeat('_',strlen($this->Word)); + $this->Misses=0; + $this->GameMultiView->ActiveView=$this->GuessView; + } + + public function guessWord($sender,$param) + { + $sender->Enabled=false; + $letter=$sender->Text; + $word=$this->Word; + $guessWord=$this->GuessWord; + $pos=0; + $success=false; + while(($pos=strpos($word,$letter,$pos))!==false) + { + $guessWord[$pos]=$letter; + $success=true; + $pos++; + } + if($success) + { + $this->GuessWord=$guessWord; + if($guessWord===$word) + $this->GameMultiView->ActiveView=$this->WinView; + } + else + { + $this->Misses++; + if($this->Misses>=$this->Level) + $this->giveUp(null,null); + } + } + + public function giveUp($sender,$param) + { + $this->GameMultiView->ActiveView=$this->LoseView; + } + + public function startAgain($sender,$param) + { + $this->GameMultiView->ActiveView=$this->IntroView; + $this->LevelError->Visible=false; + for($letter=65;$letter<=90;++$letter) + { + $guessLetter='Guess'.chr($letter); + $this->$guessLetter->Enabled=true; + } + } + + protected function generateWord() + { + $wordFile=dirname(__FILE__).'/words.txt'; + $words=preg_split("/[\s,]+/",file_get_contents($wordFile)); + do + { + $i=rand(0,count($words)-1); + $word=$words[$i]; + } while(strlen($word)<5 || !preg_match('/^[a-z]*$/i',$word)); + return strtoupper($word); + } + + public function setLevel($value) + { + $this->setViewState('Level',$value,0); + } + + public function getLevel() + { + return $this->getViewState('Level',0); + } + + public function setWord($value) + { + $this->setViewState('Word',$value,''); + } + + public function getWord() + { + return $this->getViewState('Word',''); + } + + public function getGuessWord() + { + return $this->getViewState('GuessWord',''); + } + + public function setGuessWord($value) + { + $this->setViewState('GuessWord',$value,''); + } + + public function setMisses($value) + { + $this->setViewState('Misses',$value,0); + } + + public function getMisses() + { + return $this->getViewState('Misses',0); + } +} ?>
\ No newline at end of file diff --git a/demos/quickstart/protected/pages/Search.php b/demos/quickstart/protected/pages/Search.php index d2dfa7da..c36eba54 100644 --- a/demos/quickstart/protected/pages/Search.php +++ b/demos/quickstart/protected/pages/Search.php @@ -1,56 +1,56 @@ -<?php
-/*
- * Created on 7/05/2006
- */
-
-class Search extends TPage
-{
- public function onLoad($param)
- {
- if(!$this->IsPostBack && strlen($text = $this->search->getText()) > 0)
- {
- $quickstart = $this->getApplication()->getModule("quickstart_search");
- $hits_1 = $quickstart->find($text);
- $this->quickstart_results->setDataSource($hits_1);
- $this->quickstart_results->dataBind();
-
- $this->emptyResult->setVisible(!count($hits_1));
- }
- }
-
- public function highlightSearch($text)
- {
- $words = str_word_count($text, 1);
- $keys = str_word_count(strtolower($this->search->getText()),1);
- $where = 0;
- $t = count($words);
- for($i = 0; $i<$t; $i++)
- {
- if($this->containsKeys(strtolower($words[$i]), $keys))
- {
- $words[$i] = '<span class="searchterm">'.$words[$i].'</span>';
- $where = $i;
- break;
- }
- }
-
- $min = $where - 15 < 0 ? 0 : $where - 15;
- $max = $where + 15 > $t ? $t : $where + 15;
- $subtext = array_splice($words, $min, $max-$min);
- $prefix = $min == 0 ? '' : '...';
- $suffix = $max == $t ? '' : '...';
- return $prefix.implode(' ', $subtext).$suffix;
- }
-
- protected function containsKeys($word, $keys)
- {
- foreach($keys as $key)
- {
- if(is_int(strpos($word, $key)))
- return true;
- }
- return false;
- }
-}
-
+<?php +/* + * Created on 7/05/2006 + */ + +class Search extends TPage +{ + public function onLoad($param) + { + if(!$this->IsPostBack && strlen($text = $this->search->getText()) > 0) + { + $quickstart = $this->getApplication()->getModule("quickstart_search"); + $hits_1 = $quickstart->find($text); + $this->quickstart_results->setDataSource($hits_1); + $this->quickstart_results->dataBind(); + + $this->emptyResult->setVisible(!count($hits_1)); + } + } + + public function highlightSearch($text) + { + $words = str_word_count($text, 1); + $keys = str_word_count(strtolower($this->search->getText()),1); + $where = 0; + $t = count($words); + for($i = 0; $i<$t; $i++) + { + if($this->containsKeys(strtolower($words[$i]), $keys)) + { + $words[$i] = '<span class="searchterm">'.$words[$i].'</span>'; + $where = $i; + break; + } + } + + $min = $where - 15 < 0 ? 0 : $where - 15; + $max = $where + 15 > $t ? $t : $where + 15; + $subtext = array_splice($words, $min, $max-$min); + $prefix = $min == 0 ? '' : '...'; + $suffix = $max == $t ? '' : '...'; + return $prefix.implode(' ', $subtext).$suffix; + } + + protected function containsKeys($word, $keys) + { + foreach($keys as $key) + { + if(is_int(strpos($word, $key))) + return true; + } + return false; + } +} + ?>
\ No newline at end of file diff --git a/demos/quickstart/protected/pages/ViewSource.php b/demos/quickstart/protected/pages/ViewSource.php index f267f318..2bbcf097 100644 --- a/demos/quickstart/protected/pages/ViewSource.php +++ b/demos/quickstart/protected/pages/ViewSource.php @@ -1,112 +1,112 @@ -<?php
-
-class ViewSource extends TPage
-{
- private $_path=null;
- private $_fullPath=null;
- private $_fileType=null;
-
- public function onLoad($param)
- {
- parent::onLoad($param);
- $path=$this->Request['path'];
- $fullPath=realpath($this->Service->BasePath.'/'.$path);
- $fileExt=$this->getFileExtension($fullPath);
- if($fullPath!==false && is_file($fullPath) && strpos($fullPath,$this->Service->BasePath)!==false)
- {
- if($this->isFileTypeAllowed($fileExt))
- {
- $this->_fullPath=strtr($fullPath,'\\','/');
- $this->_path=strtr(substr($fullPath,strlen($this->Service->BasePath)),'\\','/');
- }
- }
- if($this->_fullPath===null)
- throw new THttpException(500,'File Not Found: %s',$path);
-
- $this->SourceList->DataSource=$this->SourceFiles;
- $this->SourceList->dataBind();
-
- $this->Highlighter->Language=$this->getFileLanguage($fileExt);
- if($this->Request['lines']==='false')
- $this->Highlighter->ShowLineNumbers=false;
- $this->SourceView->Text=file_get_contents($this->_fullPath);
- }
-
- public function getFilePath()
- {
- return $this->_path;
- }
-
- protected function getSourceFiles()
- {
- $list=array();
- $basePath=dirname($this->_fullPath);
- if($dh=opendir($basePath))
- {
- while(($file=readdir($dh))!==false)
- {
- if(is_file($basePath.'/'.$file))
- {
- $extension=$this->getFileExtension($basePath.'/'.$file);
- if($this->isFileTypeAllowed($extension))
- {
- $fileType=$this->getFileType($extension);
- $list[]=array(
- 'name'=>$file,
- 'type'=>$fileType,
- 'active'=>basename($this->_fullPath)===$file,
- 'url'=>'?page=ViewSource&path=/'.ltrim(strtr(dirname($this->_path),'\\','/').'/'.$file,'/')
- );
- }
- }
-
- }
- closedir($dh);
- }
- foreach($list as $item)
- $aux[]=$item['name'];
- array_multisort($aux, SORT_ASC, $list);
- return $list;
- }
-
- protected function isFileTypeAllowed($extension)
- {
- return in_array($extension,array('tpl','page','php','html'));
- }
-
- protected function getFileExtension($fileName)
- {
- if(($pos=strrpos($fileName,'.'))===false)
- return '';
- else
- return substr($fileName,$pos+1);
- }
-
- protected function getFileType($extension)
- {
- if($extension==='tpl' || $extension==='page')
- return 'Template file';
- else
- return 'Class file';
- }
-
- protected function getFileLanguage($extension)
- {
- switch($extension)
- {
- case 'page' :
- case 'tpl' :
- return 'prado';
- case 'php' :
- return 'php';
- break;
- case 'xml' :
- return 'xml';
- break;
- default :
- return 'html';
- }
- }
-}
-
+<?php + +class ViewSource extends TPage +{ + private $_path=null; + private $_fullPath=null; + private $_fileType=null; + + public function onLoad($param) + { + parent::onLoad($param); + $path=$this->Request['path']; + $fullPath=realpath($this->Service->BasePath.'/'.$path); + $fileExt=$this->getFileExtension($fullPath); + if($fullPath!==false && is_file($fullPath) && strpos($fullPath,$this->Service->BasePath)!==false) + { + if($this->isFileTypeAllowed($fileExt)) + { + $this->_fullPath=strtr($fullPath,'\\','/'); + $this->_path=strtr(substr($fullPath,strlen($this->Service->BasePath)),'\\','/'); + } + } + if($this->_fullPath===null) + throw new THttpException(500,'File Not Found: %s',$path); + + $this->SourceList->DataSource=$this->SourceFiles; + $this->SourceList->dataBind(); + + $this->Highlighter->Language=$this->getFileLanguage($fileExt); + if($this->Request['lines']==='false') + $this->Highlighter->ShowLineNumbers=false; + $this->SourceView->Text=file_get_contents($this->_fullPath); + } + + public function getFilePath() + { + return $this->_path; + } + + protected function getSourceFiles() + { + $list=array(); + $basePath=dirname($this->_fullPath); + if($dh=opendir($basePath)) + { + while(($file=readdir($dh))!==false) + { + if(is_file($basePath.'/'.$file)) + { + $extension=$this->getFileExtension($basePath.'/'.$file); + if($this->isFileTypeAllowed($extension)) + { + $fileType=$this->getFileType($extension); + $list[]=array( + 'name'=>$file, + 'type'=>$fileType, + 'active'=>basename($this->_fullPath)===$file, + 'url'=>'?page=ViewSource&path=/'.ltrim(strtr(dirname($this->_path),'\\','/').'/'.$file,'/') + ); + } + } + + } + closedir($dh); + } + foreach($list as $item) + $aux[]=$item['name']; + array_multisort($aux, SORT_ASC, $list); + return $list; + } + + protected function isFileTypeAllowed($extension) + { + return in_array($extension,array('tpl','page','php','html')); + } + + protected function getFileExtension($fileName) + { + if(($pos=strrpos($fileName,'.'))===false) + return ''; + else + return substr($fileName,$pos+1); + } + + protected function getFileType($extension) + { + if($extension==='tpl' || $extension==='page') + return 'Template file'; + else + return 'Class file'; + } + + protected function getFileLanguage($extension) + { + switch($extension) + { + case 'page' : + case 'tpl' : + return 'prado'; + case 'php' : + return 'php'; + break; + case 'xml' : + return 'xml'; + break; + default : + return 'html'; + } + } +} + ?>
\ No newline at end of file |