From d4b940958da86cee51f8cf906c47e7fdb7420bef Mon Sep 17 00:00:00 2001
From: xue <>
Date: Mon, 6 Feb 2006 18:05:57 +0000
Subject: Added EmptyTemplate property to TRepeater.
---
demos/composer/protected/pages/Home.page | 8 ++++++
framework/Web/UI/WebControls/TRepeater.php | 39 ++++++++++++++++++++++++++----
2 files changed, 42 insertions(+), 5 deletions(-)
diff --git a/demos/composer/protected/pages/Home.page b/demos/composer/protected/pages/Home.page
index 28b4320d..d77bf3ca 100644
--- a/demos/composer/protected/pages/Home.page
+++ b/demos/composer/protected/pages/Home.page
@@ -16,6 +16,10 @@ implements
+
+No properties defined.
+
+
@@ -96,6 +100,10 @@ implements
+
+No events defined.
+
+
diff --git a/framework/Web/UI/WebControls/TRepeater.php b/framework/Web/UI/WebControls/TRepeater.php
index 716478b8..ffec8a4c 100644
--- a/framework/Web/UI/WebControls/TRepeater.php
+++ b/framework/Web/UI/WebControls/TRepeater.php
@@ -72,6 +72,10 @@ class TRepeater extends TDataBoundControl implements INamingContainer
* @var ITemplate template for footer
*/
private $_footerTemplate=null;
+ /**
+ * @var ITemplate template used for repeater when no data is bound
+ */
+ private $_emptyTemplate=null;
/**
* @var ITemplate template for separator
*/
@@ -178,6 +182,26 @@ class TRepeater extends TDataBoundControl implements INamingContainer
throw new TInvalidDataTypeException('repeater_template_required','FooterTemplate');
}
+ /**
+ * @return ITemplate the template applied when no data is bound to the repeater
+ */
+ public function getEmptyTemplate()
+ {
+ return $this->_emptyTemplate;
+ }
+
+ /**
+ * @param ITemplate the template applied when no data is bound to the repeater
+ * @throws TInvalidDataTypeException if the input is not an {@link ITemplate} or not null.
+ */
+ public function setEmptyTemplate($value)
+ {
+ if($value instanceof ITemplate || $value===null)
+ $this->_emptyTemplate=$value;
+ else
+ throw new TInvalidDataTypeException('repeater_template_required','EmptyTemplate');
+ }
+
/**
* @return ITemplate the separator template
*/
@@ -227,7 +251,7 @@ class TRepeater extends TDataBoundControl implements INamingContainer
/**
* Creates a repeater item instance based on the item type and index.
* @param integer zero-based item index
- * @param string item type, may be 'Header', 'Footer', 'Item', 'Separator', 'AlternatingItem', 'SelectedItem', 'EditItem'.
+ * @param string item type, may be 'Header', 'Footer', 'Empty', 'Item', 'Separator', 'AlternatingItem', 'SelectedItem', 'EditItem'.
* @return TRepeaterItem created repeater item
*/
protected function createItem($itemIndex,$itemType)
@@ -239,7 +263,7 @@ class TRepeater extends TDataBoundControl implements INamingContainer
* Creates a repeater item and does databinding if needed.
* This method invokes {@link createItem} to create a new repeater item.
* @param integer zero-based item index.
- * @param string item type, may be 'Header', 'Footer', 'Item', 'Separator', 'AlternatingItem', 'SelectedItem', 'EditItem'.
+ * @param string item type, may be 'Header', 'Footer', 'Empty', 'Item', 'Separator', 'AlternatingItem', 'SelectedItem', 'EditItem'.
* @param boolean whether to do databinding for the item
* @param mixed data to be associated with the item
* @return TRepeaterItem the created item
@@ -279,6 +303,7 @@ class TRepeater extends TDataBoundControl implements INamingContainer
{
case 'Header': $template=$this->_headerTemplate; break;
case 'Footer': $template=$this->_footerTemplate; break;
+ case 'Empty': $template=$this->_emptyTemplate; break;
case 'Item': $template=$this->_itemTemplate; break;
case 'Separator': $template=$this->_separatorTemplate; break;
case 'AlternatingItem': $template=$this->_alternatingItemTemplate===null ? $this->_itemTemplate : $this->_alternatingItemTemplate; break;
@@ -360,6 +385,8 @@ class TRepeater extends TDataBoundControl implements INamingContainer
if($this->_footerTemplate!==null)
$this->_footer=$this->createItemInternal(-1,'Footer',false,null);
}
+ else if($this->_emptyTemplate!==null)
+ $this->createItemInternal(-1,'Empty',false,null);
$this->clearChildState();
}
@@ -387,6 +414,8 @@ class TRepeater extends TDataBoundControl implements INamingContainer
}
if($itemIndex>0 && $this->_footerTemplate!==null)
$this->_footer=$this->createItemInternal(-1,'Footer',true,null);
+ if($itemIndex===0 && $this->_emptyTemplate!==null)
+ $this->createItemInternal(-1,'Empty',true,null);
$this->setViewState('ItemCount',$itemIndex,0);
}
@@ -588,16 +617,16 @@ class TRepeaterItem extends TControl implements INamingContainer
/**
* Constructor.
* @param integer zero-based index of the item in the item collection of repeater
- * @param string item type, can be 'Header','Footer','Item','AlternatingItem','SelectedItem','EditItem','Separator','Pager'.
+ * @param string item type, can be 'Header','Footer','Empty','Item','AlternatingItem','SelectedItem','EditItem','Separator','Pager'.
*/
public function __construct($itemIndex,$itemType)
{
$this->_itemIndex=$itemIndex;
- $this->_itemType=TPropertyValue::ensureEnum($itemType,'Header','Footer','Item','AlternatingItem','SelectedItem','EditItem','Separator','Pager');
+ $this->_itemType=TPropertyValue::ensureEnum($itemType,'Header','Footer','Empty','Item','AlternatingItem','SelectedItem','EditItem','Separator','Pager');
}
/**
- * @return string item type, can be 'Header','Footer','Item','AlternatingItem','SelectedItem','EditItem','Separator','Pager'
+ * @return string item type, can be 'Header','Footer','Empty','Item','AlternatingItem','SelectedItem','EditItem','Separator','Pager'
*/
public function getItemType()
{
--
cgit v1.2.3