From 0aaa8b5ef02479653c0a532d9249b423ef34c7ca Mon Sep 17 00:00:00 2001 From: xue <> Date: Mon, 5 Feb 2007 02:24:34 +0000 Subject: Added IStyleable and fixed style rendering issue about TDataList. --- .../Web/UI/WebControls/TRepeaterItemRenderer.php | 123 +++++++++++++++++++++ 1 file changed, 123 insertions(+) create mode 100644 framework/Web/UI/WebControls/TRepeaterItemRenderer.php (limited to 'framework/Web/UI/WebControls/TRepeaterItemRenderer.php') diff --git a/framework/Web/UI/WebControls/TRepeaterItemRenderer.php b/framework/Web/UI/WebControls/TRepeaterItemRenderer.php new file mode 100644 index 00000000..fa0b2aca --- /dev/null +++ b/framework/Web/UI/WebControls/TRepeaterItemRenderer.php @@ -0,0 +1,123 @@ + + * @link http://www.pradosoft.com/ + * @copyright Copyright © 2007 PradoSoft + * @license http://www.pradosoft.com/license/ + * @version $Id$ + * @package System.Web.UI.WebControls + */ + +Prado::using('System.Web.UI.WebControls.TRepeater'); + +/** + * TRepeaterItemRenderer class + * + * TRepeaterItemRenderer can be used as a convenient base class to + * define an item renderer class for {@link TRepeater}. + * + * Because TRepeaterItemRenderer extends from {@link TTemplateControl}, derived child classes + * can have templates to define their presentational layout. + * + * TRepeaterItemRenderer implements {@link IItemDataRenderer} interface, + * which enables the following properties that are related with data-bound controls: + * - {@link getItemIndex ItemIndex}: zero-based index of this control in the repeater item collection. + * - {@link getItemType ItemType}: item type of this control, such as TListItemType::AlternatingItem + * - {@link getData Data}: data associated with this control + + * @author Qiang Xue + * @version $Id$ + * @package System.Web.UI.WebControls + * @since 3.1.0 + */ +class TRepeaterItemRenderer extends TTemplateControl implements IItemDataRenderer +{ + /** + * index of the data item in the Items collection of repeater + */ + private $_itemIndex; + /** + * type of the TRepeaterItem + * @var TListItemType + */ + private $_itemType; + /** + * data associated with this item + * @var mixed + */ + private $_data; + + /** + * @return TListItemType item type + */ + public function getItemType() + { + return $this->_itemType; + } + + /** + * @param TListItemType item type. + */ + public function setItemType($value) + { + $this->_itemType=TPropertyValue::ensureEnum($value,'TListItemType'); + } + + /** + * Returns a value indicating the zero-based index of the item in the corresponding data control's item collection. + * If the item is not in the collection (e.g. it is a header item), it returns -1. + * @return integer zero-based index of the item. + */ + public function getItemIndex() + { + return $this->_itemIndex; + } + + /** + * Sets the zero-based index for the item. + * If the item is not in the item collection (e.g. it is a header item), -1 should be used. + * @param integer zero-based index of the item. + */ + public function setItemIndex($value) + { + $this->_itemIndex=TPropertyValue::ensureInteger($value); + } + + /** + * @return mixed data associated with the item + */ + public function getData() + { + return $this->_data; + } + + /** + * @param mixed data to be associated with the item + */ + public function setData($value) + { + $this->_data=$value; + } + + /** + * This method overrides parent's implementation by wrapping event parameter + * for OnCommand event with item information. + * @param TControl the sender of the event + * @param TEventParameter event parameter + * @return boolean whether the event bubbling should stop here. + */ + public function bubbleEvent($sender,$param) + { + if($param instanceof TCommandEventParameter) + { + $this->raiseBubbleEvent($this,new TRepeaterCommandEventParameter($this,$sender,$param)); + return true; + } + else + return false; + } +} + +?> \ No newline at end of file -- cgit v1.2.3