Subversion-Projekte lars-tiefland.prado

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
1 lars 1
<?php
2
/**
3
 * TActiveLabel class file.
4
 *
5
 * @author Wei Zhuo <weizhuo[at]gmail[dot]com>
6
 * @link http://www.pradosoft.com/
7
 * @copyright Copyright &copy; 2005-2008 PradoSoft
8
 * @license http://www.pradosoft.com/license/
9
 * @version $Id: TActiveLabel.php 2541 2008-10-21 15:05:13Z qiang.xue $
10
 * @package System.Web.UI.ActiveControls
11
 */
12
 
13
/**
14
 * Load active control adapter.
15
 */
16
Prado::using('System.Web.UI.ActiveControls.TActiveControlAdapter');
17
 
18
/**
19
 * TActiveLabel class
20
 *
21
 * The active control counterpart of TLabel component. When
22
 * {@link TBaseActiveControl::setEnableUpdate ActiveControl.EnableUpdate}
23
 * property is true the during a callback request, setting {@link setText Text}
24
 * property will also set the text of the label on the client upon callback
25
 * completion. Similarly, setting {@link setForControl ForControl} will also set
26
 * the client-side "for" attribute on the label.
27
 *
28
 * @author Wei Zhuo <weizhuo[at]gmail[dot]com>
29
 * @version $Id: TActiveLabel.php 2541 2008-10-21 15:05:13Z qiang.xue $
30
 * @package System.Web.UI.ActiveControls
31
 * @since 3.1
32
 */
33
class TActiveLabel extends TLabel implements IActiveControl
34
{
35
	/**
36
	 * Creates a new callback control, sets the adapter to
37
	 * TActiveControlAdapter. If you override this class, be sure to set the
38
	 * adapter appropriately by, for example, by calling this constructor.
39
	 */
40
	public function __construct()
41
	{
42
		parent::__construct();
43
		$this->setAdapter(new TActiveControlAdapter($this));
44
	}
45
 
46
	/**
47
	 * @return TBaseActiveControl basic active control options.
48
	 */
49
	public function getActiveControl()
50
	{
51
		return $this->getAdapter()->getBaseActiveControl();
52
	}
53
 
54
	/**
55
	 * On callback response, the inner HTML of the label is updated.
56
	 * @param string the text value of the label
57
	 */
58
	public function setText($value)
59
	{
60
		parent::setText($value);
61
		if($this->getActiveControl()->canUpdateClientSide())
62
			$this->getPage()->getCallbackClient()->update($this, $value);
63
	}
64
 
65
	/**
66
	 * Sets the ID of the control that the label is associated with.
67
	 * The control must be locatable via {@link TControl::findControl} using the ID.
68
	 * On callback response, the For attribute of the label is updated.
69
	 * @param string the associated control ID
70
	 */
71
	public function setForControl($value)
72
	{
73
		parent::setForControl($value);
74
		if($this->getActiveControl()->canUpdateClientSide())
75
		{
76
			$id=$this->findControl($value)->getClientID();
77
			$this->getPage()->getCallbackClient()->setAttribute($this, 'for', $id);
78
		}
79
	}
80
 
81
	/**
82
	 * Adds attribute id to the renderer.
83
	 * @param THtmlWriter the writer used for the rendering purpose
84
	 */
85
	protected function addAttributesToRender($writer) {
86
	    $writer->addAttribute('id',$this->getClientID());
87
	    parent::addAttributesToRender($writer);
88
	}
89
}
90