| 1 |
lars |
1 |
<?php
|
|
|
2 |
/**
|
|
|
3 |
* TActiveImageButton class file.
|
|
|
4 |
*
|
|
|
5 |
* @author Wei Zhuo <weizhuo[at]gamil[dot]com>
|
|
|
6 |
* @link http://www.pradosoft.com/
|
|
|
7 |
* @copyright Copyright © 2005-2008 PradoSoft
|
|
|
8 |
* @license http://www.pradosoft.com/license/
|
|
|
9 |
* @version $Id: TActiveImageButton.php 2482 2008-07-30 02:07:13Z knut $
|
|
|
10 |
* @package System.Web.UI.ActiveControls
|
|
|
11 |
*/
|
|
|
12 |
|
|
|
13 |
/**
|
|
|
14 |
* TActiveImageButton class.
|
|
|
15 |
*
|
|
|
16 |
* TActiveImageButton is the active control counter part to TLinkButton.
|
|
|
17 |
* When a TActiveImageButton is clicked, rather than a normal post back request a
|
|
|
18 |
* callback request is initiated.
|
|
|
19 |
*
|
|
|
20 |
* The {@link onCallback OnCallback} event is raised during a callback request
|
|
|
21 |
* and it is raise <b>after</b> the {@link onClick OnClick} event.
|
|
|
22 |
*
|
|
|
23 |
* @author Wei Zhuo <weizhuo[at]gmail[dot]com>
|
|
|
24 |
* @version $Id: TActiveImageButton.php 2482 2008-07-30 02:07:13Z knut $
|
|
|
25 |
* @package System.Web.UI.ActiveControls
|
|
|
26 |
* @since 3.1
|
|
|
27 |
*/
|
|
|
28 |
class TActiveImageButton extends TImageButton implements IActiveControl, ICallbackEventHandler
|
|
|
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 |
* @return TCallbackClientSide client side request options.
|
|
|
51 |
*/
|
|
|
52 |
public function getClientSide()
|
|
|
53 |
{
|
|
|
54 |
return $this->getAdapter()->getBaseActiveControl()->getClientSide();
|
|
|
55 |
}
|
|
|
56 |
|
|
|
57 |
/**
|
|
|
58 |
* Sets the alternative text to be displayed in the TImage when the image is unavailable.
|
|
|
59 |
* @param string the alternative text
|
|
|
60 |
*/
|
|
|
61 |
public function setAlternateText($value)
|
|
|
62 |
{
|
|
|
63 |
parent::setAlternateText($value);
|
|
|
64 |
if($this->getActiveControl()->canUpdateClientSide())
|
|
|
65 |
$this->getPage()->getCallbackClient()->setAttribute($this, 'alt', $value);
|
|
|
66 |
}
|
|
|
67 |
|
|
|
68 |
/**
|
|
|
69 |
* Sets the alignment of the image with respective to other elements on the page.
|
|
|
70 |
* Possible values include: absbottom, absmiddle, baseline, bottom, left,
|
|
|
71 |
* middle, right, texttop, and top. If an empty string is passed in,
|
|
|
72 |
* imagealign attribute will not be rendered.
|
|
|
73 |
* @param string the alignment of the image
|
|
|
74 |
*/
|
|
|
75 |
public function setImageAlign($value)
|
|
|
76 |
{
|
|
|
77 |
parent::setImageAlign($value);
|
|
|
78 |
if($this->getActiveControl()->canUpdateClientSide())
|
|
|
79 |
$this->getPage()->getCallbackClient()->setAttribute($this, 'align', $value);
|
|
|
80 |
}
|
|
|
81 |
|
|
|
82 |
/**
|
|
|
83 |
* @param string the URL of the image file
|
|
|
84 |
*/
|
|
|
85 |
public function setImageUrl($value)
|
|
|
86 |
{
|
|
|
87 |
parent::setImageUrl($value);
|
|
|
88 |
if($this->getActiveControl()->canUpdateClientSide())
|
|
|
89 |
$this->getPage()->getCallbackClient()->setAttribute($this, 'src', $value);
|
|
|
90 |
}
|
|
|
91 |
|
|
|
92 |
/**
|
|
|
93 |
* @param string the URL to the long description of the image.
|
|
|
94 |
*/
|
|
|
95 |
public function setDescriptionUrl($value)
|
|
|
96 |
{
|
|
|
97 |
parent::setDescriptionUrl($value);
|
|
|
98 |
if($this->getActiveControl()->canUpdateClientSide())
|
|
|
99 |
$this->getPage()->getCallbackClient()->setAttribute($this, 'longdesc', $value);
|
|
|
100 |
}
|
|
|
101 |
|
|
|
102 |
/**
|
|
|
103 |
* Raises the callback event. This method is required by {@link
|
|
|
104 |
* ICallbackEventHandler} interface. If {@link getCausesValidation
|
|
|
105 |
* CausesValidation} is true, it will invoke the page's {@link TPage::
|
|
|
106 |
* validate validate} method first. It will raise {@link onClick
|
|
|
107 |
* OnClick} event first and then the {@link onCallback OnCallback} event.
|
|
|
108 |
* This method is mainly used by framework and control developers.
|
|
|
109 |
* @param TCallbackEventParameter the event parameter
|
|
|
110 |
*/
|
|
|
111 |
public function raiseCallbackEvent($param)
|
|
|
112 |
{
|
|
|
113 |
$this->raisePostBackEvent($param);
|
|
|
114 |
$this->onCallback($param);
|
|
|
115 |
}
|
|
|
116 |
|
|
|
117 |
/**
|
|
|
118 |
* This method is invoked when a callback is requested. The method raises
|
|
|
119 |
* 'OnCallback' event to fire up the event handlers. If you override this
|
|
|
120 |
* method, be sure to call the parent implementation so that the event
|
|
|
121 |
* handler can be invoked.
|
|
|
122 |
* @param TCallbackEventParameter event parameter to be passed to the event handlers
|
|
|
123 |
*/
|
|
|
124 |
public function onCallback($param)
|
|
|
125 |
{
|
|
|
126 |
$this->raiseEvent('OnCallback', $this, $param);
|
|
|
127 |
}
|
|
|
128 |
|
|
|
129 |
/**
|
|
|
130 |
* Override parent implementation, no javascript is rendered here instead
|
|
|
131 |
* the javascript required for active control is registered in {@link addAttributesToRender}.
|
|
|
132 |
*/
|
|
|
133 |
protected function renderClientControlScript($writer)
|
|
|
134 |
{
|
|
|
135 |
}
|
|
|
136 |
|
|
|
137 |
/**
|
|
|
138 |
* Register the x and y hidden input names of the position clicked.
|
|
|
139 |
* @param THtmlWriter the renderer.
|
|
|
140 |
*/
|
|
|
141 |
public function onPreRender($writer)
|
|
|
142 |
{
|
|
|
143 |
parent::onPreRender($writer);
|
|
|
144 |
$uid = $uid=$this->getUniqueID();
|
|
|
145 |
$this->getPage()->registerPostDataLoader($uid.'_x');
|
|
|
146 |
$this->getPage()->registerPostDataLoader($uid.'_y');
|
|
|
147 |
}
|
|
|
148 |
|
|
|
149 |
/**
|
|
|
150 |
* Ensure that the ID attribute is rendered and registers the javascript code
|
|
|
151 |
* for initializing the active control.
|
|
|
152 |
*/
|
|
|
153 |
protected function addAttributesToRender($writer)
|
|
|
154 |
{
|
|
|
155 |
parent::addAttributesToRender($writer);
|
|
|
156 |
$writer->addAttribute('id',$this->getClientID());
|
|
|
157 |
$this->getActiveControl()->registerCallbackClientScript(
|
|
|
158 |
$this->getClientClassName(), $this->getPostBackOptions());
|
|
|
159 |
}
|
|
|
160 |
|
|
|
161 |
/**
|
|
|
162 |
* @return string corresponding javascript class name for this TActiveLinkButton.
|
|
|
163 |
*/
|
|
|
164 |
protected function getClientClassName()
|
|
|
165 |
{
|
|
|
166 |
return 'Prado.WebUI.TActiveImageButton';
|
|
|
167 |
}
|
|
|
168 |
}
|
|
|
169 |
|
|
|
170 |
?>
|