Subversion-Projekte lars-tiefland.prado

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
1 lars 1
<?php
2
/**
3
 * TActiveHyperLink class file.
4
 *
5
 * @author Wei Zhuo <weizhuo[at]gamil[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: TActiveHyperLink.php 2482 2008-07-30 02:07:13Z knut $
10
 * @package System.Web.UI.ActiveControls
11
 */
12
 
13
/**
14
 * TActiveHyperLink class.
15
 *
16
 * The active control counterpart of THyperLink component. When
17
 * {@link TBaseActiveControl::setEnableUpdate ActiveControl.EnableUpdate}
18
 * property is true the during a callback request, setting {@link setText Text}
19
 * property will also set the text of the label on the client upon callback
20
 * completion. Similarly, for other properties such as {@link setImageUrl ImageUrl},
21
 * {@link setNavigateUrl NavigateUrl} and {@link setTarget Target}.
22
 *
23
 * @author Wei Zhuo <weizhuo[at]gmail[dot]com>
24
 * @version $Id: TActiveHyperLink.php 2482 2008-07-30 02:07:13Z knut $
25
 * @package System.Web.UI.ActiveControls
26
 * @since 3.1
27
 */
28
class TActiveHyperLink extends THyperLink implements IActiveControl
29
{
30
	/**
31
	 * Creates a new callback control, sets the adapter to
32
	 * TActiveControlAdapter. If you override this class, be sure to set the
33
	 * adapter appropriately by, for example, by calling this constructor.
34
	 */
35
	public function __construct()
36
	{
37
		parent::__construct();
38
		$this->setAdapter(new TActiveControlAdapter($this));
39
	}
40
 
41
	/**
42
	 * @return TBaseActiveControl basic active control options.
43
	 */
44
	public function getActiveControl()
45
	{
46
		return $this->getAdapter()->getBaseActiveControl();
47
	}
48
 
49
	/**
50
	 * On callback response, the inner HTMl of the label is updated.
51
	 * @param string the text value of the label
52
	 */
53
	public function setText($value)
54
	{
55
		parent::setText($value);
56
		if($this->getActiveControl()->canUpdateClientSide())
57
			$this->getPage()->getCallbackClient()->update($this, $value);
58
	}
59
 
60
	/**
61
	 * Sets the location of image file of the THyperLink.
62
	 * @param string the image file location
63
	 */
64
	public function setImageUrl($value)
65
	{
66
		parent::setImageUrl($value);
67
		if($this->getActiveControl()->canUpdateClientSide() && $value !== '')
68
		{
69
			$textWriter = new TTextWriter();
70
			$renderer = new THtmlWriter($textWriter);
71
			$this->createImage($value)->renderControl($renderer);
72
			$this->getPage()->getCallbackClient()->update($this, $textWriter->flush());
73
		}
74
	}
75
 
76
	/**
77
	 * Sets the URL to link to when the THyperLink component is clicked.
78
	 * @param string the URL
79
	 */
80
	public function setNavigateUrl($value)
81
	{
82
		parent::setNavigateUrl($value);
83
		if($this->getActiveControl()->canUpdateClientSide())
84
		{
85
			//replace &amp; with & and urldecode the url (setting the href using javascript is literal)
86
			$url = urldecode(str_replace('&amp;', '&', $value));
87
			$this->getPage()->getCallbackClient()->setAttribute($this, 'href', $url);
88
		}
89
	}
90
 
91
	/**
92
	 * Sets the target window or frame to display the Web page content linked to when the THyperLink component is clicked.
93
	 * @param string the target window, valid values include '_blank', '_parent', '_self', '_top' and empty string.
94
	 */
95
	public function setTarget($value)
96
	{
97
		parent::setTarget($value);
98
		if($this->getActiveControl()->canUpdateClientSide())
99
			$this->getPage()->getCallbackClient()->setAttribute($this, 'target', $value);
100
	}
101
}
102
 
103
?>