summaryrefslogtreecommitdiff
path: root/framework/Web/UI/WebControls/TItemDataRenderer.php
blob: e135eeebc82a21909ddd28b2de1495a8fe3331f1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
<?php
/**
 * TItemDataRenderer class file
 *
 * @author Qiang Xue <qiang.xue@gmail.com>
 * @link http://www.pradosoft.com/
 * @copyright Copyright &copy; 2005-2014 PradoSoft
 * @license http://www.pradosoft.com/license/
 * @package Prado\Web\UI\WebControls
 * @since 3.1.2
 */

namespace Prado\Web\UI\WebControls;
use Prado\TPropertyValue;

/**
 * TItemDataRenderer class
 *
 * TItemDataRenderer is the convient base class for template-based item data renderers.
 * It implements the {@link IItemDataRenderer} interface, and because
 * TItemDataRenderer extends from {@link TTemplateControl}, derived child
 * classes can have templates to define their presentational layout.
 *
 * The following properties are provided by TItemDataRenderer:
 * - {@link getItemIndex ItemIndex}: zero-based index of this renderer in the item list collection.
 * - {@link getItemType ItemType}: item type of this renderer, such as TListItemType::AlternatingItem
 * - {@link getData Data}: data associated with this renderer
 *
 * @author Qiang Xue <qiang.xue@gmail.com>
 * @package Prado\Web\UI\WebControls
 * @since 3.1.2
 */
abstract class TItemDataRenderer extends TDataRenderer implements IItemDataRenderer
{
	/**
	 * index of the data item in the Items collection of repeater
	 */
	private $_itemIndex;
	/**
	 * type of the TRepeaterItem
	 * @var TListItemType
	 */
	private $_itemType;

	/**
	 * @return TListItemType item type
	 */
	public function getItemType()
	{
		return $this->_itemType;
	}

	/**
	 * @param TListItemType item type.
	 */
	public function setItemType($value)
	{
		$this->_itemType=TPropertyValue::ensureEnum($value,'Prado\\Web\\UI\\WebControls\\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);
	}
}