| 1 |
lars |
1 |
<?php
|
|
|
2 |
/**
|
|
|
3 |
* TActiveDatePicker class file
|
|
|
4 |
*
|
|
|
5 |
* @author Bradley Booms <Bradley.Booms@nsighttel.com>
|
|
|
6 |
* @author Christophe Boulain <Christophe.Boulain@gmail.com>
|
|
|
7 |
* @link http://www.pradosoft.com/
|
|
|
8 |
* @copyright Copyright © 2005-2008 PradoSoft
|
|
|
9 |
* @license http://www.pradosoft.com/license/
|
|
|
10 |
* @version $Id: TActiveDatePicker.php 2508 2008-09-24 13:09:23Z tof $
|
|
|
11 |
* @package System.Web.UI.ActiveControls
|
|
|
12 |
*/
|
|
|
13 |
|
|
|
14 |
/**
|
|
|
15 |
* Load active control adapter.
|
|
|
16 |
*/
|
|
|
17 |
Prado::using('System.Web.UI.ActiveControls.TActiveControlAdapter');
|
|
|
18 |
|
|
|
19 |
/**
|
|
|
20 |
* TActiveDatePicker class
|
|
|
21 |
*
|
|
|
22 |
* The active control counter part to date picker control.
|
|
|
23 |
* When the date selection is changed, the {@link onCallback OnCallback} event is
|
|
|
24 |
* raised.
|
|
|
25 |
*
|
|
|
26 |
* @author Bradley Booms <Bradley.Booms@nsighttel.com>
|
|
|
27 |
* @author Christophe Boulain <Christophe.Boulain@gmail.com>
|
|
|
28 |
* @version $Id: TActiveDatePicker.php 2508 2008-09-24 13:09:23Z tof $
|
|
|
29 |
* @package System.Web.UI.ActiveControls
|
|
|
30 |
* @since 3.1.3
|
|
|
31 |
*/
|
|
|
32 |
class TActiveDatePicker extends TDatePicker implements ICallbackEventHandler, IActiveControl {
|
|
|
33 |
|
|
|
34 |
|
|
|
35 |
/**
|
|
|
36 |
* Get javascript date picker options.
|
|
|
37 |
* @return array date picker client-side options
|
|
|
38 |
*/
|
|
|
39 |
protected function getDatePickerOptions(){
|
|
|
40 |
$options = parent::getDatePickerOptions();
|
|
|
41 |
$options['EventTarget'] = $this->getUniqueID();
|
|
|
42 |
return $options;
|
|
|
43 |
}
|
|
|
44 |
|
|
|
45 |
/**
|
|
|
46 |
* Creates a new callback control, sets the adapter to
|
|
|
47 |
* TActiveControlAdapter. If you override this class, be sure to set the
|
|
|
48 |
* adapter appropriately by, for example, by calling this constructor.
|
|
|
49 |
*/
|
|
|
50 |
public function __construct()
|
|
|
51 |
{
|
|
|
52 |
parent::__construct();
|
|
|
53 |
$this->setAdapter(new TActiveControlAdapter($this));
|
|
|
54 |
}
|
|
|
55 |
|
|
|
56 |
/**
|
|
|
57 |
* @return TBaseActiveCallbackControl standard callback control options.
|
|
|
58 |
*/
|
|
|
59 |
public function getActiveControl(){
|
|
|
60 |
return $this->getAdapter()->getBaseActiveControl();
|
|
|
61 |
}
|
|
|
62 |
|
|
|
63 |
/**
|
|
|
64 |
* Client-side Text property can only be updated after the OnLoad stage.
|
|
|
65 |
* @param string text content for the textbox
|
|
|
66 |
*/
|
|
|
67 |
public function setText($value){
|
|
|
68 |
parent::setText($value);
|
|
|
69 |
if($this->getActiveControl()->canUpdateClientSide() && $this->getHasLoadedPostData()){
|
|
|
70 |
$cb=$this->getPage()->getCallbackClient();
|
|
|
71 |
$cb->setValue($this, $value);
|
|
|
72 |
if ($this->getInputMode()==TDatePickerInputMode::DropDownList)
|
|
|
73 |
{
|
|
|
74 |
$s = Prado::createComponent('System.Util.TDateTimeStamp');
|
|
|
75 |
$date = $s->getDate($this->getTimeStampFromText());
|
|
|
76 |
$id=$this->getClientID();
|
|
|
77 |
$cb->select($id.TControl::CLIENT_ID_SEPARATOR.'day', 'Value', $date['mday'], 'select');
|
|
|
78 |
$cb->select($id.TControl::CLIENT_ID_SEPARATOR.'month', 'Value', $date['mon']-1, 'select');
|
|
|
79 |
$cb->select($id.TControl::CLIENT_ID_SEPARATOR.'year', 'Value', $date['year'], 'select');
|
|
|
80 |
|
|
|
81 |
}
|
|
|
82 |
}
|
|
|
83 |
}
|
|
|
84 |
|
|
|
85 |
/**
|
|
|
86 |
* Raises the callback event. This method is required by {@link
|
|
|
87 |
* ICallbackEventHandler} interface.
|
|
|
88 |
* This method is mainly used by framework and control developers.
|
|
|
89 |
* @param TCallbackEventParameter the event parameter
|
|
|
90 |
*/
|
|
|
91 |
public function raiseCallbackEvent($param){
|
|
|
92 |
$this->onCallback($param);
|
|
|
93 |
}
|
|
|
94 |
|
|
|
95 |
/**
|
|
|
96 |
* This method is invoked when a callback is requested. The method raises
|
|
|
97 |
* 'OnCallback' event to fire up the event handlers. If you override this
|
|
|
98 |
* method, be sure to call the parent implementation so that the event
|
|
|
99 |
* handler can be invoked.
|
|
|
100 |
* @param TCallbackEventParameter event parameter to be passed to the event handlers
|
|
|
101 |
*/
|
|
|
102 |
public function onCallback($param){
|
|
|
103 |
$this->raiseEvent('OnCallback', $this, $param);
|
|
|
104 |
}
|
|
|
105 |
|
|
|
106 |
/**
|
|
|
107 |
* Registers the javascript code to initialize the date picker.
|
|
|
108 |
*/
|
|
|
109 |
protected function registerCalendarClientScript()
|
|
|
110 |
{
|
|
|
111 |
if($this->getShowCalendar())
|
|
|
112 |
{
|
|
|
113 |
$cs = $this->getPage()->getClientScript();
|
|
|
114 |
$cs->registerPradoScript("activedatepicker");
|
|
|
115 |
|
|
|
116 |
if(!$cs->isEndScriptRegistered('TDatePicker.spacer'))
|
|
|
117 |
{
|
|
|
118 |
$spacer = $this->getAssetUrl('spacer.gif');
|
|
|
119 |
$code = "Prado.WebUI.TDatePicker.spacer = '$spacer';";
|
|
|
120 |
$cs->registerEndScript('TDatePicker.spacer', $code);
|
|
|
121 |
}
|
|
|
122 |
|
|
|
123 |
$options = TJavaScript::encode($this->getDatePickerOptions());
|
|
|
124 |
$code = "new Prado.WebUI.TActiveDatePicker($options);";
|
|
|
125 |
$cs->registerEndScript("prado:".$this->getClientID(), $code);
|
|
|
126 |
}
|
|
|
127 |
}
|
|
|
128 |
}
|
|
|
129 |
?>
|