summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorxue <>2007-07-19 13:46:05 +0000
committerxue <>2007-07-19 13:46:05 +0000
commit46f58667d00624c115ad99a590aebef99ab133a5 (patch)
treec97aac85c4cba692542419d660cf5fe535aba423
parent8f1347c3d3fc85fb894077042b0c359928dd9233 (diff)
Fixed #577.
-rw-r--r--HISTORY1
-rw-r--r--demos/quickstart/protected/pages/Controls/Samples/TPager/Sample1.page14
-rw-r--r--framework/Web/UI/WebControls/TPager.php150
3 files changed, 150 insertions, 15 deletions
diff --git a/HISTORY b/HISTORY
index ad810fda..444fe9c4 100644
--- a/HISTORY
+++ b/HISTORY
@@ -6,6 +6,7 @@ BUG: Ticket#662 - Ensure TForm to properly encode the ampersand in action URL (Q
BUG: Ticket#666 - TActiveRecord::deleteAll() method always requires a criteria or null parameter (Qiang)
BUG: Ticket#670 - TDatePicker: Year Issue (Christophe)
ENH: Ticket#667 - Added TFeedService.ContentType property (Qiang)
+ENH: Ticket#577 - Added image button support for TPager (Qiang)
ENH: Added THead requirement check (Qiang)
Version 3.1.0 July 2, 2007
diff --git a/demos/quickstart/protected/pages/Controls/Samples/TPager/Sample1.page b/demos/quickstart/protected/pages/Controls/Samples/TPager/Sample1.page
index d24a5c82..45fa12a0 100644
--- a/demos/quickstart/protected/pages/Controls/Samples/TPager/Sample1.page
+++ b/demos/quickstart/protected/pages/Controls/Samples/TPager/Sample1.page
@@ -6,9 +6,9 @@ The following sample displays three different pagers associated with a single TD
</p>
<div>
-Go to page:
-<com:TPager ID="Pager"
- ControlToPaginate="DataList"
+Go to page:
+<com:TPager ID="Pager"
+ ControlToPaginate="DataList"
PageButtonCount="3"
Mode="Numeric"
OnPageIndexChanged="pageChanged"
@@ -56,8 +56,8 @@ Total <%# $this->Parent->PageCount %> pages.
</com:TDataList>
-<com:TPager ID="Pager2"
- ControlToPaginate="DataList"
+<com:TPager ID="Pager2"
+ ControlToPaginate="DataList"
FirstPageText="9"
LastPageText=":"
Mode="NextPrev"
@@ -68,8 +68,8 @@ Total <%# $this->Parent->PageCount %> pages.
/>
<br/>
Choose page:
-<com:TPager ID="Pager3"
- ControlToPaginate="DataList"
+<com:TPager ID="Pager3"
+ ControlToPaginate="DataList"
Mode="DropDownList"
OnPageIndexChanged="pageChanged"
/>
diff --git a/framework/Web/UI/WebControls/TPager.php b/framework/Web/UI/WebControls/TPager.php
index df096125..1248bbe4 100644
--- a/framework/Web/UI/WebControls/TPager.php
+++ b/framework/Web/UI/WebControls/TPager.php
@@ -26,6 +26,12 @@
* - Numeric: a list of page index buttons are rendered.
* - List: a dropdown list of page indices are rendered.
*
+ * When the pager mode is either NextPrev or Numeric, the paging buttons may be displayed
+ * in three types by setting {@link setButtonType ButtonType}:
+ * - LinkButton: a hyperlink button
+ * - PushButton: a normal button
+ * - ImageButton: an image button (please set XXXPageImageUrl properties accordingly to specify the button images.)
+ *
* TPager raises an {@link onPageIndexChanged OnPageIndexChanged} event when
* the end-user interacts with it and specifies a new page (e.g. clicking
* on a page button that leads to a new page.) The new page index may be obtained
@@ -184,6 +190,102 @@ class TPager extends TWebControl implements INamingContainer
}
/**
+ * @return string the image URL for the first page button. This is only used when {@link getButtonType ButtonType} is 'ImageButton'.
+ * @since 3.1.1
+ */
+ public function getFirstPageImageUrl()
+ {
+ return $this->getViewState('FirstPageImageUrl','');
+ }
+
+ /**
+ * @param string the image URL for the first page button. This is only used when {@link getButtonType ButtonType} is 'ImageButton'.
+ * @since 3.1.1
+ */
+ public function setFirstPageImageUrl($value)
+ {
+ $this->setViewState('FirstPageImageUrl',$value);
+ }
+
+ /**
+ * @return string the image URL for the last page button. This is only used when {@link getButtonType ButtonType} is 'ImageButton'.
+ * @since 3.1.1
+ */
+ public function getLastPageImageUrl()
+ {
+ return $this->getViewState('LastPageImageUrl','');
+ }
+
+ /**
+ * @param string the image URL for the last page button. This is only used when {@link getButtonType ButtonType} is 'ImageButton'.
+ * @since 3.1.1
+ */
+ public function setLastPageImageUrl($value)
+ {
+ $this->setViewState('LastPageImageUrl',$value);
+ }
+
+ /**
+ * @return string the image URL for the next page button. This is only used when {@link getButtonType ButtonType} is 'ImageButton'.
+ * @since 3.1.1
+ */
+ public function getNextPageImageUrl()
+ {
+ return $this->getViewState('NextPageImageUrl','');
+ }
+
+ /**
+ * @param string the image URL for the next page button. This is only used when {@link getButtonType ButtonType} is 'ImageButton'.
+ * @since 3.1.1
+ */
+ public function setNextPageImageUrl($value)
+ {
+ $this->setViewState('NextPageImageUrl',$value);
+ }
+
+ /**
+ * @return string the image URL for the previous page button. This is only used when {@link getButtonType ButtonType} is 'ImageButton'.
+ * @since 3.1.1
+ */
+ public function getPrevPageImageUrl()
+ {
+ return $this->getViewState('PrevPageImageUrl','');
+ }
+
+ /**
+ * @param string the image URL for the previous page button. This is only used when {@link getButtonType ButtonType} is 'ImageButton'.
+ * @since 3.1.1
+ */
+ public function setPrevPageImageUrl($value)
+ {
+ $this->setViewState('PrevPageImageUrl',$value);
+ }
+
+ /**
+ * @return string the image URL for the numeric page buttons. This is only used when {@link getButtonType ButtonType} is 'ImageButton' and {@link getMode Mode} is 'Numeric'.
+ * @see setNumericPageImageUrl
+ * @since 3.1.1
+ */
+ public function getNumericPageImageUrl()
+ {
+ return $this->getViewState('NumericPageImageUrl','');
+ }
+
+ /**
+ * Sets the image URL for the numeric page buttons.
+ * This is actually a template for generating a set of URLs corresponding to numeric button 1, 2, 3, .., etc.
+ * Use [0] as the placeholder for the numbers.
+ * For example, the image URL http://example.com/images/button[0].gif
+ * will be replaced as http://example.com/images/button1.gif, http://example.com/images/button2.gif, etc.
+ * @param string the image URL for the numeric page buttons. This is only used when {@link getButtonType ButtonType} is 'ImageButton' and {@link getMode Mode} is 'Numeric'.
+ * @since 3.1.1
+ */
+ public function setNumericPageImageUrl($value)
+ {
+ $this->setViewState('NumericPageImageUrl',$value);
+ }
+
+ /**
* @return integer maximum number of pager buttons to be displayed. Defaults to 10.
*/
public function getPageButtonCount()
@@ -322,8 +424,8 @@ class TPager extends TWebControl implements INamingContainer
* Derived classes may override this method to create additional types of buttons, such as TImageButton.
* @param string button type, either LinkButton or PushButton
* @param boolean whether the button should be enabled
- * @param string caption of the button
- * @param string CommandName corresponding to the OnCommand event of the button
+ * @param string caption of the button.
+ * @param string CommandName corresponding to the OnCommand event of the button.
* @param string CommandParameter corresponding to the OnCommand event of the button
* @return mixed the button instance
*/
@@ -342,7 +444,13 @@ class TPager extends TWebControl implements INamingContainer
}
else
{
- $button=new TButton;
+ if($buttonType===TPagerButtonType::ImageButton)
+ {
+ $button=new TImageButton;
+ $button->setImageUrl($this->getPageImageUrl($text,$commandName));
+ }
+ else
+ $button=new TButton;
if(!$enabled)
$button->setEnabled(false);
}
@@ -354,6 +462,31 @@ class TPager extends TWebControl implements INamingContainer
}
/**
+ * @param string the caption of the image button
+ * @param string the command name associated with the image button
+ * @since 3.1.1
+ */
+ protected function getPageImageUrl($text,$commandName)
+ {
+ switch($commandName)
+ {
+ case self::CMD_PAGE:
+ $url=$this->getNumericPageImageUrl();
+ return str_replace('[0]',$text,$url);
+ case self::CMD_PAGE_NEXT:
+ return $this->getNextPageImageUrl();
+ case self::CMD_PAGE_PREV:
+ return $this->getPrevPageImageUrl();
+ case self::CMD_PAGE_FIRST:
+ return $this->getFirstPageImageUrl();
+ case self::CMD_PAGE_LAST:
+ return $this->getLastPageImageUrl();
+ default:
+ return '';
+ }
+ }
+
+ /**
* Builds a next-prev pager
*/
protected function buildNextPrevPager()
@@ -364,11 +497,11 @@ class TPager extends TWebControl implements INamingContainer
{
if(($text=$this->getFirstPageText())!=='')
{
- $label=$this->createPagerButton($buttonType,false,$text,'','');
+ $label=$this->createPagerButton($buttonType,false,$text,self::CMD_PAGE_FIRST,'');
$controls->add($label);
$controls->add("\n");
}
- $label=$this->createPagerButton($buttonType,false,$this->getPrevPageText(),'','');
+ $label=$this->createPagerButton($buttonType,false,$this->getPrevPageText(),self::CMD_PAGE_PREV,'');
$controls->add($label);
}
else
@@ -385,12 +518,12 @@ class TPager extends TWebControl implements INamingContainer
$controls->add("\n");
if($this->getIsLastPage())
{
- $label=$this->createPagerButton($buttonType,false,$this->getNextPageText(),'','');
+ $label=$this->createPagerButton($buttonType,false,$this->getNextPageText(),self::CMD_PAGE_NEXT,'');
$controls->add($label);
if(($text=$this->getLastPageText())!=='')
{
$controls->add("\n");
- $label=$this->createPagerButton($buttonType,false,$text,'','');
+ $label=$this->createPagerButton($buttonType,false,$text,self::CMD_PAGE_LAST,'');
$controls->add($label);
}
}
@@ -450,7 +583,7 @@ class TPager extends TWebControl implements INamingContainer
{
if($i===$pageIndex)
{
- $label=$this->createPagerButton($buttonType,false,"$i",'','');
+ $label=$this->createPagerButton($buttonType,false,"$i",self::CMD_PAGE,'');
$controls->add($label);
}
else
@@ -654,6 +787,7 @@ class TPagerButtonType extends TEnumerable
{
const LinkButton='LinkButton';
const PushButton='PushButton';
+ const ImageButton='ImageButton';
}
?> \ No newline at end of file