From 9afa1445890254e867dd172a36f42484aec8916b Mon Sep 17 00:00:00 2001 From: xue <> Date: Wed, 28 Jun 2006 18:23:52 +0000 Subject: merge from 3.0 branch till 1208. --- demos/quickstart/protected/application.xml | 3 - .../protected/comments/QuickStartComments.php | 34 ++++----- demos/quickstart/protected/index/api/_0.cfs | Bin 378721 -> 0 bytes demos/quickstart/protected/index/api/deletable | Bin 4 -> 0 bytes demos/quickstart/protected/index/api/segments | Bin 27 -> 0 bytes .../quickstart/protected/pages/Controls/Pager.page | 38 ++++++++++ .../pages/Controls/Samples/TPager/Sample1.page | 77 +++++++++++++++++++ .../pages/Controls/Samples/TPager/Sample1.php | 82 +++++++++++++++++++++ .../protected/pages/Controls/Standard.page | 4 + 9 files changed, 218 insertions(+), 20 deletions(-) delete mode 100644 demos/quickstart/protected/index/api/_0.cfs delete mode 100644 demos/quickstart/protected/index/api/deletable delete mode 100644 demos/quickstart/protected/index/api/segments create mode 100644 demos/quickstart/protected/pages/Controls/Pager.page create mode 100644 demos/quickstart/protected/pages/Controls/Samples/TPager/Sample1.page create mode 100644 demos/quickstart/protected/pages/Controls/Samples/TPager/Sample1.php (limited to 'demos') diff --git a/demos/quickstart/protected/application.xml b/demos/quickstart/protected/application.xml index 1765230b..79ee4529 100644 --- a/demos/quickstart/protected/application.xml +++ b/demos/quickstart/protected/application.xml @@ -13,9 +13,6 @@ - diff --git a/demos/quickstart/protected/comments/QuickStartComments.php b/demos/quickstart/protected/comments/QuickStartComments.php index c138bd94..7b504caf 100644 --- a/demos/quickstart/protected/comments/QuickStartComments.php +++ b/demos/quickstart/protected/comments/QuickStartComments.php @@ -18,7 +18,7 @@ class QuickStartComments * @var sqlite connection. */ private $_connection; - + /** * Sets the sqlite comment database file. */ @@ -26,7 +26,7 @@ class QuickStartComments { $this->_database = realpath(dirname(__FILE__).'/comments.db'); } - + /** * Closed the database connection. */ @@ -35,7 +35,7 @@ class QuickStartComments if(!is_null($this->_connection)) sqlite_close($this->_connection); } - + /** * @return resource sqlite database connection. */ @@ -45,7 +45,7 @@ class QuickStartComments $this->_connection = sqlite_open($this->_database); return $this->_connection; } - + /** * Quote database input data. */ @@ -53,7 +53,7 @@ class QuickStartComments { return sqlite_escape_string($value); } - + /** * Executes an sqlite query. * @param string SQL @@ -63,7 +63,7 @@ class QuickStartComments { return sqlite_query($this->getConnection(), $sql); } - + /** * Returns a row from the sqlite result. * @param resource sqlite result @@ -76,7 +76,7 @@ class QuickStartComments else return false; } - + /** * Fetch all the records for given SQL query. * @param string SQL query. @@ -90,7 +90,7 @@ class QuickStartComments $rows[] = $row; return $rows; } - + /** * Returns all the comments for a given page. * @param string specific page comments @@ -99,10 +99,10 @@ class QuickStartComments public function getComments($pageID) { $page = $this->quote($pageID); - $sql = "SELECT * FROM comments WHERE page=\"$page\" AND approved = 1 ORDER BY date_added ASC"; + $sql = "SELECT * FROM comments WHERE page='$page' AND approved = 1 ORDER BY date_added ASC"; return $this->fetchAll($sql); } - + /** * Adds a new comment for moderation. * @param string ID of the page to comment belongs @@ -117,11 +117,11 @@ class QuickStartComments $date_added = time(); $sql = <<query($sql); } - + /** * Update an existing comment. * @param string comment ID @@ -136,13 +136,13 @@ EOD; $comment = $this->quote($content); $page = $this->quote($page); $sql = <<query($sql); } - + /** * Delete a comment. * @param string comment ID @@ -152,7 +152,7 @@ EOD; $ID = intval($commentID); $this->query("DELETE FROM comments WHERE id=$ID"); } - + /** * @return array all the quequed comments. */ @@ -160,7 +160,7 @@ EOD; { return $this->fetchAll("SELECT * FROM comments WHERE approved != 1"); } - + /** * Approve a quequed comment. * @param string comment ID. diff --git a/demos/quickstart/protected/index/api/_0.cfs b/demos/quickstart/protected/index/api/_0.cfs deleted file mode 100644 index b5eb219b..00000000 Binary files a/demos/quickstart/protected/index/api/_0.cfs and /dev/null differ diff --git a/demos/quickstart/protected/index/api/deletable b/demos/quickstart/protected/index/api/deletable deleted file mode 100644 index 593f4708..00000000 Binary files a/demos/quickstart/protected/index/api/deletable and /dev/null differ diff --git a/demos/quickstart/protected/index/api/segments b/demos/quickstart/protected/index/api/segments deleted file mode 100644 index da225127..00000000 Binary files a/demos/quickstart/protected/index/api/segments and /dev/null differ diff --git a/demos/quickstart/protected/pages/Controls/Pager.page b/demos/quickstart/protected/pages/Controls/Pager.page new file mode 100644 index 00000000..3c74d0de --- /dev/null +++ b/demos/quickstart/protected/pages/Controls/Pager.page @@ -0,0 +1,38 @@ + + +

TPager

+ + +

+TPager creates a pager that provides UI for end-users to interactively specify which page of data to be rendered in a TDataBoundControl-derived control, such as TDataList, TRepeater, TCheckBoxList, etc. The target data-bound control is specified by the ControlToPaginate property, which must be the ID path of the target control reaching from the pager's naming container. +

+ +

+Note, the target data-bound control must have its AllowPaging set to true. Otherwise the pager will be invisible. Also, in case when there is only one page of data available, the pager will also be invisible. +

+ +

+TPager can display one of the following three types of user interface, specified via its Mode property: +

+
    +
  • NextPrev - a next page and a previous page button are rendered on each page.
  • +
  • Numeric - a list of page index buttons are rendered.
  • +
  • List - a dropdown list of page indices is rendered.
  • +
+

+These user interfaces may be further customized by configuring the following properties +

+
    +
  • NextPageText and PrevPageText - the label of the next/previous page button. These properties are used when the pager Mode is NextPrev or Numeric.
  • +
  • FirstPageText and LastPageText - the label of the first/last page button. If empty, the corresponding button will not be displayed. These properties are used when the pager Mode is NextPrev or Numeric.
  • +
  • PageButtonCount - the maximum number of page index buttons on a page. This property is used when the pager Mode is Numeric.
  • +
  • ButtonType - type of page buttons, either PushButton meaning normal form submission buttons, or LinkButton meaning hyperlink buttons.
  • +
+ +

+TPager raises an OnPageIndexChanged event when an end-user interacts with it and specifies a new page (e.g. by clicking on a next page button that would lead to the next page.) Developers may write handlers to respond to this event and obtain the desired new page index from the event parameter's property NewPageIndex. Using this new page index, one can feed a new page of data to the associated data-bound control. +

+ + + +
\ No newline at end of file diff --git a/demos/quickstart/protected/pages/Controls/Samples/TPager/Sample1.page b/demos/quickstart/protected/pages/Controls/Samples/TPager/Sample1.page new file mode 100644 index 00000000..0d61f580 --- /dev/null +++ b/demos/quickstart/protected/pages/Controls/Samples/TPager/Sample1.page @@ -0,0 +1,77 @@ + + +

TPager Sample

+

+The following sample displays three different pagers associated with a single TDataList control. The datalist control is enabled with custom paging, which allows it to read only one page of data each time. This is typical in DB-driven applications. +

+ +
+Go to page: + +
+ + + + +
Computer Parts
+
+ + +
+Total <%# $this->Parent->PageCount %> pages. +
+
+ + + + + + + + + + + + +
IDNameQuantityPrice
DataItem['id'] %> />DataItem['name'] %> />DataItem['quantity'] %> />$DataItem['price'] %> />
+
+ +
+ + +
+Choose page: + + +
\ 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 new file mode 100644 index 00000000..e5446f60 --- /dev/null +++ b/demos/quickstart/protected/pages/Controls/Samples/TPager/Sample1.php @@ -0,0 +1,82 @@ +'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/Standard.page b/demos/quickstart/protected/pages/Controls/Standard.page index dfaee35b..156b39e5 100644 --- a/demos/quickstart/protected/pages/Controls/Standard.page +++ b/demos/quickstart/protected/pages/Controls/Standard.page @@ -79,6 +79,10 @@ TMultiView represents a container for a group of TView controls, each of which is container for other controls. At any time, at most one TView is visible. +
  • + TPager generates UI that allows users to interactively specify which page of data to be displayed in a data-bound control. +
  • +
  • TPanel represents a container for other controls on a Web page. In HTML, it is displayed as a <div> element.
  • -- cgit v1.2.3