|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* TWizard and the relevant class definitions. |
|
4
|
|
|
* |
|
5
|
|
|
* @author Qiang Xue <[email protected]> |
|
6
|
|
|
* @link https://github.com/pradosoft/prado |
|
7
|
|
|
* @copyright Copyright © 2005-2015 The PRADO Group |
|
8
|
|
|
* @license https://github.com/pradosoft/prado/blob/master/COPYRIGHT |
|
9
|
|
|
* @package System.Web.UI.WebControls |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
Prado::using('System.Web.UI.WebControls.TMultiView'); |
|
13
|
|
|
Prado::using('System.Web.UI.WebControls.TPanel'); |
|
14
|
|
|
Prado::using('System.Web.UI.WebControls.TButton'); |
|
15
|
|
|
Prado::using('System.Web.UI.WebControls.TLinkButton'); |
|
16
|
|
|
Prado::using('System.Web.UI.WebControls.TImageButton'); |
|
17
|
|
|
Prado::using('System.Web.UI.WebControls.TDataList'); |
|
18
|
|
|
Prado::using('System.Web.UI.WebControls.TWizardNavigationButtonStyle'); |
|
19
|
|
|
|
|
20
|
|
|
/** |
|
21
|
|
|
* Class TWizard. |
|
22
|
|
|
* |
|
23
|
|
|
* TWizard splits a large form and presents the user with a series of smaller |
|
24
|
|
|
* forms to complete. TWizard is analogous to the installation wizard commonly |
|
25
|
|
|
* used to install software in Windows. |
|
26
|
|
|
* |
|
27
|
|
|
* The smaller forms are called wizard steps ({@link TWizardStep}, which can be accessed via |
|
28
|
|
|
* {@link getWizardSteps WizardSteps}. In template, wizard steps can be added |
|
29
|
|
|
* into a wizard using the following syntax, |
|
30
|
|
|
* <code> |
|
31
|
|
|
* <com:TWizard> |
|
32
|
|
|
* <com:TWizardStep Title="step 1"> |
|
33
|
|
|
* content in step 1, may contain other controls |
|
34
|
|
|
* </com:TWizardStep> |
|
35
|
|
|
* <com:TWizardStep Title="step 2"> |
|
36
|
|
|
* content in step 2, may contain other controls |
|
37
|
|
|
* </com:TWizardStep> |
|
38
|
|
|
* </com:TWizard> |
|
39
|
|
|
* </code> |
|
40
|
|
|
* |
|
41
|
|
|
* Each wizard step can be one of the following types: |
|
42
|
|
|
* - Start : the first step in the wizard. |
|
43
|
|
|
* - Step : the internal steps in the wizard. |
|
44
|
|
|
* - Finish : the last step that allows user interaction. |
|
45
|
|
|
* - Complete : the step that shows a summary to user (no interaction is allowed). |
|
46
|
|
|
* - Auto : the step type is determined by wizard automatically. |
|
47
|
|
|
* At any time, only one step is visible to end-users, which can be obtained |
|
48
|
|
|
* by {@link getActiveStep ActiveStep}. Its index in the step collection is given by |
|
49
|
|
|
* {@link getActiveStepIndex ActiveStepIndex}. |
|
50
|
|
|
* |
|
51
|
|
|
* Wizard content can be customized in many ways. |
|
52
|
|
|
* |
|
53
|
|
|
* The layout of a wizard consists of four parts: header, step content, navigation |
|
54
|
|
|
* and side bar. Their content are affected by the following properties, respectively, |
|
55
|
|
|
* - header: {@link setHeaderText HeaderText} and {@link setHeaderTemplate HeaderTemplate}. |
|
56
|
|
|
* If both are present, the latter takes precedence. |
|
57
|
|
|
* - step: {@link getWizardSteps WizardSteps}. |
|
58
|
|
|
* - navigation: {@link setStartNavigationTemplate StartNavigationTemplate}, |
|
59
|
|
|
* {@link setStepNavigationTemplate StepNavigationTemplate}, |
|
60
|
|
|
* {@link setFinishNavigationTemplate FinishNavigationTemplate}. |
|
61
|
|
|
* Default templates will be used if above templates are not set. |
|
62
|
|
|
* - side bar: {@link setSideBarTemplate SideBarTemplate}. |
|
63
|
|
|
* A default template will be used if this template is not set. |
|
64
|
|
|
* Its visibility is toggled by {@link setShowSideBar ShowSideBar}. |
|
65
|
|
|
* |
|
66
|
|
|
* The style of these wizard layout components can be customized via the following style properties, |
|
67
|
|
|
* - header: {@link getHeaderStyle HeaderStyle}. |
|
68
|
|
|
* - step: {@link getStepStyle StepStyle}. |
|
69
|
|
|
* - navigation: {@link getNavigationStyle NavigationStyle}, |
|
70
|
|
|
* {@link getStartNextButtonStyle StartNextButtonStyle}, |
|
71
|
|
|
* {@link getStepNextButtonStyle StepNextButtonStyle}, |
|
72
|
|
|
* {@link getStepPreviousButtonStyle StepPreviousButtonStyle}, |
|
73
|
|
|
* {@link getFinishPreviousButtonStyle FinishPreviousButtonStyle}, |
|
74
|
|
|
* {@link getFinishCompleteButtonStyle FinishCompleteButtonStyle}, |
|
75
|
|
|
* {@link getCancelButtonStyle CancelButtonStyle}. |
|
76
|
|
|
* - side bar: {@link getSideBarStyle SideBarStyle} and {@link getSideBarButtonStyle SideBarButtonStyle}. |
|
77
|
|
|
* |
|
78
|
|
|
* @author Qiang Xue <[email protected]> |
|
79
|
|
|
* @package System.Web.UI.WebControls |
|
80
|
|
|
* @since 3.0 |
|
81
|
|
|
*/ |
|
82
|
|
|
class TWizard extends TWebControl implements INamingContainer |
|
83
|
|
|
{ |
|
84
|
|
|
/** |
|
85
|
|
|
* Wizard step types. |
|
86
|
|
|
* @deprecated deprecated since version 3.0.4 (use TWizardStepType constants instead) |
|
87
|
|
|
*/ |
|
88
|
|
|
const ST_AUTO='Auto'; |
|
89
|
|
|
const ST_START='Start'; |
|
90
|
|
|
const ST_STEP='Step'; |
|
91
|
|
|
const ST_FINISH='Finish'; |
|
92
|
|
|
const ST_COMPLETE='Complete'; |
|
93
|
|
|
/** |
|
94
|
|
|
* Navigation commands. |
|
95
|
|
|
*/ |
|
96
|
|
|
const CMD_PREVIOUS='PreviousStep'; |
|
97
|
|
|
const CMD_NEXT='NextStep'; |
|
98
|
|
|
const CMD_CANCEL='Cancel'; |
|
99
|
|
|
const CMD_COMPLETE='Complete'; |
|
100
|
|
|
const CMD_MOVETO='MoveTo'; |
|
101
|
|
|
/** |
|
102
|
|
|
* Side bar button ID |
|
103
|
|
|
*/ |
|
104
|
|
|
const ID_SIDEBAR_BUTTON='SideBarButton'; |
|
105
|
|
|
/** |
|
106
|
|
|
* Side bar data list |
|
107
|
|
|
*/ |
|
108
|
|
|
const ID_SIDEBAR_LIST='SideBarList'; |
|
109
|
|
|
|
|
110
|
|
|
/** |
|
111
|
|
|
* @var TMultiView multiview that contains the wizard steps |
|
112
|
|
|
*/ |
|
113
|
|
|
private $_multiView=null; |
|
114
|
|
|
/** |
|
115
|
|
|
* @var mixed navigation template for the start step. |
|
116
|
|
|
*/ |
|
117
|
|
|
private $_startNavigationTemplate=null; |
|
118
|
|
|
/** |
|
119
|
|
|
* @var mixed navigation template for internal steps. |
|
120
|
|
|
*/ |
|
121
|
|
|
private $_stepNavigationTemplate=null; |
|
122
|
|
|
/** |
|
123
|
|
|
* @var mixed navigation template for the finish step. |
|
124
|
|
|
*/ |
|
125
|
|
|
private $_finishNavigationTemplate=null; |
|
126
|
|
|
/** |
|
127
|
|
|
* @var mixed template for wizard header. |
|
128
|
|
|
*/ |
|
129
|
|
|
private $_headerTemplate=null; |
|
130
|
|
|
/** |
|
131
|
|
|
* @var mixed template for the side bar. |
|
132
|
|
|
*/ |
|
133
|
|
|
private $_sideBarTemplate=null; |
|
134
|
|
|
/** |
|
135
|
|
|
* @var TWizardStepCollection |
|
136
|
|
|
*/ |
|
137
|
|
|
private $_wizardSteps=null; |
|
138
|
|
|
/** |
|
139
|
|
|
* @var TPanel container of the wizard header |
|
140
|
|
|
*/ |
|
141
|
|
|
private $_header; |
|
142
|
|
|
/** |
|
143
|
|
|
* @var TPanel container of the wizard step content |
|
144
|
|
|
*/ |
|
145
|
|
|
private $_stepContent; |
|
146
|
|
|
/** |
|
147
|
|
|
* @var TPanel container of the wizard side bar |
|
148
|
|
|
*/ |
|
149
|
|
|
private $_sideBar; |
|
150
|
|
|
/** |
|
151
|
|
|
* @var TPanel navigation panel |
|
152
|
|
|
*/ |
|
153
|
|
|
private $_navigation; |
|
154
|
|
|
/** |
|
155
|
|
|
* @var TWizardNavigationContainer container of the start navigation |
|
156
|
|
|
*/ |
|
157
|
|
|
private $_startNavigation; |
|
158
|
|
|
/** |
|
159
|
|
|
* @var TWizardNavigationContainer container of the step navigation |
|
160
|
|
|
*/ |
|
161
|
|
|
private $_stepNavigation; |
|
162
|
|
|
/** |
|
163
|
|
|
* @var TWizardNavigationContainer container of the finish navigation |
|
164
|
|
|
*/ |
|
165
|
|
|
private $_finishNavigation; |
|
166
|
|
|
/** |
|
167
|
|
|
* @var boolean whether ActiveStepIndex was already set |
|
168
|
|
|
*/ |
|
169
|
|
|
private $_activeStepIndexSet=false; |
|
170
|
|
|
/** |
|
171
|
|
|
* @var TDataList side bar data list. |
|
172
|
|
|
*/ |
|
173
|
|
|
private $_sideBarDataList; |
|
174
|
|
|
/** |
|
175
|
|
|
* @var boolean whether navigation should be cancelled (a status set in OnSideBarButtonClick) |
|
176
|
|
|
*/ |
|
177
|
|
|
private $_cancelNavigation=false; |
|
178
|
|
|
|
|
179
|
|
|
/** |
|
180
|
|
|
* @return string tag name for the wizard |
|
181
|
|
|
*/ |
|
182
|
|
|
protected function getTagName() |
|
183
|
|
|
{ |
|
184
|
|
|
return 'div'; |
|
185
|
|
|
} |
|
186
|
|
|
|
|
187
|
|
|
/** |
|
188
|
|
|
* Adds {@link TWizardStep} objects into step collection. |
|
189
|
|
|
* This method overrides the parent implementation and is |
|
190
|
|
|
* invoked when template is being instantiated. |
|
191
|
|
|
* @param mixed object instantiated in template |
|
192
|
|
|
*/ |
|
193
|
|
|
public function addParsedObject($object) |
|
194
|
|
|
{ |
|
195
|
|
|
if($object instanceof TWizardStep) |
|
196
|
|
|
$this->getWizardSteps()->add($object); |
|
197
|
|
|
} |
|
198
|
|
|
|
|
199
|
|
|
/** |
|
200
|
|
|
* @return TWizardStep the currently active wizard step |
|
201
|
|
|
*/ |
|
202
|
|
|
public function getActiveStep() |
|
203
|
|
|
{ |
|
204
|
|
|
return $this->getMultiView()->getActiveView(); |
|
205
|
|
|
} |
|
206
|
|
|
|
|
207
|
|
|
/** |
|
208
|
|
|
* @param TWizardStep step to be activated |
|
209
|
|
|
* @throws TInvalidOperationException if the step is not in the wizard step collection |
|
210
|
|
|
*/ |
|
211
|
|
|
public function setActiveStep($step) |
|
212
|
|
|
{ |
|
213
|
|
|
if(($index=$this->getWizardSteps()->indexOf($step))<0) |
|
214
|
|
|
throw new TInvalidOperationException('wizard_step_invalid'); |
|
215
|
|
|
$this->setActiveStepIndex($index); |
|
216
|
|
|
} |
|
217
|
|
|
|
|
218
|
|
|
/** |
|
219
|
|
|
* @return integer the zero-based index of the active wizard step |
|
220
|
|
|
*/ |
|
221
|
|
|
public function getActiveStepIndex() |
|
222
|
|
|
{ |
|
223
|
|
|
return $this->getMultiView()->getActiveViewIndex(); |
|
224
|
|
|
} |
|
225
|
|
|
|
|
226
|
|
|
/** |
|
227
|
|
|
* @param integer the zero-based index of the wizard step to be activated |
|
228
|
|
|
*/ |
|
229
|
|
|
public function setActiveStepIndex($value) |
|
230
|
|
|
{ |
|
231
|
|
|
$value=TPropertyValue::ensureInteger($value); |
|
232
|
|
|
$multiView=$this->getMultiView(); |
|
233
|
|
|
if($multiView->getActiveViewIndex()!==$value) |
|
234
|
|
|
{ |
|
235
|
|
|
$multiView->setActiveViewIndex($value); |
|
236
|
|
|
$this->_activeStepIndexSet=true; |
|
237
|
|
|
if($this->_sideBarDataList!==null && $this->getSideBarTemplate()!==null) |
|
238
|
|
|
{ |
|
239
|
|
|
$this->_sideBarDataList->setSelectedItemIndex($this->getActiveStepIndex()); |
|
240
|
|
|
$this->_sideBarDataList->dataBind(); |
|
241
|
|
|
} |
|
242
|
|
|
} |
|
243
|
|
|
} |
|
244
|
|
|
|
|
245
|
|
|
/** |
|
246
|
|
|
* @return TWizardStepCollection collection of wizard steps |
|
247
|
|
|
*/ |
|
248
|
|
|
public function getWizardSteps() |
|
249
|
|
|
{ |
|
250
|
|
|
if($this->_wizardSteps===null) |
|
251
|
|
|
$this->_wizardSteps=new TWizardStepCollection($this); |
|
252
|
|
|
return $this->_wizardSteps; |
|
253
|
|
|
} |
|
254
|
|
|
|
|
255
|
|
|
/** |
|
256
|
|
|
* @return boolean whether to display a cancel button in each wizard step. Defaults to false. |
|
257
|
|
|
*/ |
|
258
|
|
|
public function getShowCancelButton() |
|
259
|
|
|
{ |
|
260
|
|
|
return $this->getViewState('ShowCancelButton',false); |
|
261
|
|
|
} |
|
262
|
|
|
|
|
263
|
|
|
/** |
|
264
|
|
|
* @param boolean whether to display a cancel button in each wizard step. |
|
265
|
|
|
*/ |
|
266
|
|
|
public function setShowCancelButton($value) |
|
267
|
|
|
{ |
|
268
|
|
|
$this->setViewState('ShowCancelButton',TPropertyValue::ensureBoolean($value),false); |
|
269
|
|
|
} |
|
270
|
|
|
|
|
271
|
|
|
/** |
|
272
|
|
|
* @return boolean whether to display a side bar that contains links to wizard steps. Defaults to true. |
|
273
|
|
|
*/ |
|
274
|
|
|
public function getShowSideBar() |
|
275
|
|
|
{ |
|
276
|
|
|
return $this->getViewState('ShowSideBar',true); |
|
277
|
|
|
} |
|
278
|
|
|
|
|
279
|
|
|
/** |
|
280
|
|
|
* @param boolean whether to display a side bar that contains links to wizard steps. |
|
281
|
|
|
*/ |
|
282
|
|
|
public function setShowSideBar($value) |
|
283
|
|
|
{ |
|
284
|
|
|
$this->setViewState('ShowSideBar',TPropertyValue::ensureBoolean($value),true); |
|
285
|
|
|
} |
|
286
|
|
|
|
|
287
|
|
|
/** |
|
288
|
|
|
* @return ITemplate navigation template for the start step. Defaults to null. |
|
289
|
|
|
*/ |
|
290
|
|
|
public function getStartNavigationTemplate() |
|
291
|
|
|
{ |
|
292
|
|
|
return $this->_startNavigationTemplate; |
|
293
|
|
|
} |
|
294
|
|
|
|
|
295
|
|
|
/** |
|
296
|
|
|
* @param ITemplate navigation template for the start step. |
|
297
|
|
|
*/ |
|
298
|
|
|
public function setStartNavigationTemplate($value) |
|
299
|
|
|
{ |
|
300
|
|
|
$this->_startNavigationTemplate=$value; |
|
301
|
|
|
$this->requiresControlsRecreation(); |
|
302
|
|
|
} |
|
303
|
|
|
|
|
304
|
|
|
/** |
|
305
|
|
|
* @return ITemplate navigation template for internal steps. Defaults to null. |
|
306
|
|
|
*/ |
|
307
|
|
|
public function getStepNavigationTemplate() |
|
308
|
|
|
{ |
|
309
|
|
|
return $this->_stepNavigationTemplate; |
|
310
|
|
|
} |
|
311
|
|
|
|
|
312
|
|
|
/** |
|
313
|
|
|
* @param ITemplate navigation template for internal steps. |
|
314
|
|
|
*/ |
|
315
|
|
|
public function setStepNavigationTemplate($value) |
|
316
|
|
|
{ |
|
317
|
|
|
$this->_stepNavigationTemplate=$value; |
|
318
|
|
|
$this->requiresControlsRecreation(); |
|
319
|
|
|
} |
|
320
|
|
|
|
|
321
|
|
|
/** |
|
322
|
|
|
* @return ITemplate navigation template for the finish step. Defaults to null. |
|
323
|
|
|
*/ |
|
324
|
|
|
public function getFinishNavigationTemplate() |
|
325
|
|
|
{ |
|
326
|
|
|
return $this->_finishNavigationTemplate; |
|
327
|
|
|
} |
|
328
|
|
|
|
|
329
|
|
|
/** |
|
330
|
|
|
* @param ITemplate navigation template for the finish step. |
|
331
|
|
|
*/ |
|
332
|
|
|
public function setFinishNavigationTemplate($value) |
|
333
|
|
|
{ |
|
334
|
|
|
$this->_finishNavigationTemplate=$value; |
|
335
|
|
|
$this->requiresControlsRecreation(); |
|
336
|
|
|
} |
|
337
|
|
|
|
|
338
|
|
|
/** |
|
339
|
|
|
* @return ITemplate template for wizard header. Defaults to null. |
|
340
|
|
|
*/ |
|
341
|
|
|
public function getHeaderTemplate() |
|
342
|
|
|
{ |
|
343
|
|
|
return $this->_headerTemplate; |
|
344
|
|
|
} |
|
345
|
|
|
|
|
346
|
|
|
/** |
|
347
|
|
|
* @param ITemplate template for wizard header. |
|
348
|
|
|
*/ |
|
349
|
|
|
public function setHeaderTemplate($value) |
|
350
|
|
|
{ |
|
351
|
|
|
$this->_headerTemplate=$value; |
|
352
|
|
|
$this->requiresControlsRecreation(); |
|
353
|
|
|
} |
|
354
|
|
|
|
|
355
|
|
|
/** |
|
356
|
|
|
* @return ITemplate template for the side bar. Defaults to null. |
|
357
|
|
|
*/ |
|
358
|
|
|
public function getSideBarTemplate() |
|
359
|
|
|
{ |
|
360
|
|
|
return $this->_sideBarTemplate; |
|
361
|
|
|
} |
|
362
|
|
|
|
|
363
|
|
|
/** |
|
364
|
|
|
* @param ITemplate template for the side bar. |
|
365
|
|
|
*/ |
|
366
|
|
|
public function setSideBarTemplate($value) |
|
367
|
|
|
{ |
|
368
|
|
|
$this->_sideBarTemplate=$value; |
|
369
|
|
|
$this->requiresControlsRecreation(); |
|
370
|
|
|
} |
|
371
|
|
|
|
|
372
|
|
|
/** |
|
373
|
|
|
* @return string header text. Defaults to ''. |
|
374
|
|
|
*/ |
|
375
|
|
|
public function getHeaderText() |
|
376
|
|
|
{ |
|
377
|
|
|
return $this->getViewState('HeaderText',''); |
|
378
|
|
|
} |
|
379
|
|
|
|
|
380
|
|
|
/** |
|
381
|
|
|
* @param string header text. |
|
382
|
|
|
*/ |
|
383
|
|
|
public function setHeaderText($value) |
|
384
|
|
|
{ |
|
385
|
|
|
$this->setViewState('HeaderText',TPropertyValue::ensureString($value),''); |
|
386
|
|
|
} |
|
387
|
|
|
|
|
388
|
|
|
/** |
|
389
|
|
|
* @return string the URL that the browser will be redirected to if the cancel button in the |
|
390
|
|
|
* wizard is clicked. Defaults to ''. |
|
391
|
|
|
*/ |
|
392
|
|
|
public function getCancelDestinationUrl() |
|
393
|
|
|
{ |
|
394
|
|
|
return $this->getViewState('CancelDestinationUrl',''); |
|
395
|
|
|
} |
|
396
|
|
|
|
|
397
|
|
|
/** |
|
398
|
|
|
* @param string the URL that the browser will be redirected to if the cancel button in the |
|
399
|
|
|
* wizard is clicked. |
|
400
|
|
|
*/ |
|
401
|
|
|
public function setCancelDestinationUrl($value) |
|
402
|
|
|
{ |
|
403
|
|
|
$this->setViewState('CancelDestinationUrl',TPropertyValue::ensureString($value),''); |
|
404
|
|
|
} |
|
405
|
|
|
|
|
406
|
|
|
/** |
|
407
|
|
|
* @return string the URL that the browser will be redirected to if the wizard finishes. |
|
408
|
|
|
* Defaults to ''. |
|
409
|
|
|
*/ |
|
410
|
|
|
public function getFinishDestinationUrl() |
|
411
|
|
|
{ |
|
412
|
|
|
return $this->getViewState('FinishDestinationUrl',''); |
|
413
|
|
|
} |
|
414
|
|
|
|
|
415
|
|
|
/** |
|
416
|
|
|
* @param string the URL that the browser will be redirected to if the wizard finishes. |
|
417
|
|
|
*/ |
|
418
|
|
|
public function setFinishDestinationUrl($value) |
|
419
|
|
|
{ |
|
420
|
|
|
$this->setViewState('FinishDestinationUrl',TPropertyValue::ensureString($value),''); |
|
421
|
|
|
} |
|
422
|
|
|
|
|
423
|
|
|
/** |
|
424
|
|
|
* @return TStyle the style for the buttons displayed in the side bar. |
|
425
|
|
|
*/ |
|
426
|
|
|
public function getSideBarButtonStyle() |
|
427
|
|
|
{ |
|
428
|
|
|
if(($style=$this->getViewState('SideBarButtonStyle',null))===null) |
|
429
|
|
|
{ |
|
430
|
|
|
$style=new TStyle; |
|
431
|
|
|
$this->setViewState('SideBarButtonStyle',$style,null); |
|
432
|
|
|
} |
|
433
|
|
|
return $style; |
|
434
|
|
|
} |
|
435
|
|
|
|
|
436
|
|
|
/** |
|
437
|
|
|
* @return TStyle the style common for all navigation buttons. |
|
438
|
|
|
*/ |
|
439
|
|
|
public function getNavigationButtonStyle() |
|
440
|
|
|
{ |
|
441
|
|
|
if(($style=$this->getViewState('NavigationButtonStyle',null))===null) |
|
442
|
|
|
{ |
|
443
|
|
|
$style=new TStyle; |
|
444
|
|
|
$this->setViewState('NavigationButtonStyle',$style,null); |
|
445
|
|
|
} |
|
446
|
|
|
return $style; |
|
447
|
|
|
} |
|
448
|
|
|
|
|
449
|
|
|
/** |
|
450
|
|
|
* @return TWizardNavigationButtonStyle the style for the next button in the start wizard step. |
|
451
|
|
|
*/ |
|
452
|
|
|
public function getStartNextButtonStyle() |
|
453
|
|
|
{ |
|
454
|
|
|
if(($style=$this->getViewState('StartNextButtonStyle',null))===null) |
|
455
|
|
|
{ |
|
456
|
|
|
$style=new TWizardNavigationButtonStyle; |
|
457
|
|
|
$style->setButtonText('Next'); |
|
458
|
|
|
$this->setViewState('StartNextButtonStyle',$style,null); |
|
459
|
|
|
} |
|
460
|
|
|
return $style; |
|
461
|
|
|
} |
|
462
|
|
|
|
|
463
|
|
|
/** |
|
464
|
|
|
* @return TWizardNavigationButtonStyle the style for the next button in each internal wizard step. |
|
465
|
|
|
*/ |
|
466
|
|
|
public function getStepNextButtonStyle() |
|
467
|
|
|
{ |
|
468
|
|
|
if(($style=$this->getViewState('StepNextButtonStyle',null))===null) |
|
469
|
|
|
{ |
|
470
|
|
|
$style=new TWizardNavigationButtonStyle; |
|
471
|
|
|
$style->setButtonText('Next'); |
|
472
|
|
|
$this->setViewState('StepNextButtonStyle',$style,null); |
|
473
|
|
|
} |
|
474
|
|
|
return $style; |
|
475
|
|
|
} |
|
476
|
|
|
|
|
477
|
|
|
/** |
|
478
|
|
|
* @return TWizardNavigationButtonStyle the style for the previous button in the start wizard step. |
|
479
|
|
|
*/ |
|
480
|
|
|
public function getStepPreviousButtonStyle() |
|
481
|
|
|
{ |
|
482
|
|
|
if(($style=$this->getViewState('StepPreviousButtonStyle',null))===null) |
|
483
|
|
|
{ |
|
484
|
|
|
$style=new TWizardNavigationButtonStyle; |
|
485
|
|
|
$style->setButtonText('Previous'); |
|
486
|
|
|
$this->setViewState('StepPreviousButtonStyle',$style,null); |
|
487
|
|
|
} |
|
488
|
|
|
return $style; |
|
489
|
|
|
} |
|
490
|
|
|
|
|
491
|
|
|
/** |
|
492
|
|
|
* @return TWizardNavigationButtonStyle the style for the complete button in the finish wizard step. |
|
493
|
|
|
*/ |
|
494
|
|
|
public function getFinishCompleteButtonStyle() |
|
495
|
|
|
{ |
|
496
|
|
|
if(($style=$this->getViewState('FinishCompleteButtonStyle',null))===null) |
|
497
|
|
|
{ |
|
498
|
|
|
$style=new TWizardNavigationButtonStyle; |
|
499
|
|
|
$style->setButtonText('Complete'); |
|
500
|
|
|
$this->setViewState('FinishCompleteButtonStyle',$style,null); |
|
501
|
|
|
} |
|
502
|
|
|
return $style; |
|
503
|
|
|
} |
|
504
|
|
|
|
|
505
|
|
|
/** |
|
506
|
|
|
* @return TWizardNavigationButtonStyle the style for the previous button in the start wizard step. |
|
507
|
|
|
*/ |
|
508
|
|
|
public function getFinishPreviousButtonStyle() |
|
509
|
|
|
{ |
|
510
|
|
|
if(($style=$this->getViewState('FinishPreviousButtonStyle',null))===null) |
|
511
|
|
|
{ |
|
512
|
|
|
$style=new TWizardNavigationButtonStyle; |
|
513
|
|
|
$style->setButtonText('Previous'); |
|
514
|
|
|
$this->setViewState('FinishPreviousButtonStyle',$style,null); |
|
515
|
|
|
} |
|
516
|
|
|
return $style; |
|
517
|
|
|
} |
|
518
|
|
|
|
|
519
|
|
|
/** |
|
520
|
|
|
* @return TWizardNavigationButtonStyle the style for the cancel button |
|
521
|
|
|
*/ |
|
522
|
|
|
public function getCancelButtonStyle() |
|
523
|
|
|
{ |
|
524
|
|
|
if(($style=$this->getViewState('CancelButtonStyle',null))===null) |
|
525
|
|
|
{ |
|
526
|
|
|
$style=new TWizardNavigationButtonStyle; |
|
527
|
|
|
$style->setButtonText('Cancel'); |
|
528
|
|
|
$this->setViewState('CancelButtonStyle',$style,null); |
|
529
|
|
|
} |
|
530
|
|
|
return $style; |
|
531
|
|
|
} |
|
532
|
|
|
|
|
533
|
|
|
/** |
|
534
|
|
|
* @return TPanelStyle the style for the side bar. |
|
535
|
|
|
*/ |
|
536
|
|
|
public function getSideBarStyle() |
|
537
|
|
|
{ |
|
538
|
|
|
if(($style=$this->getViewState('SideBarStyle',null))===null) |
|
539
|
|
|
{ |
|
540
|
|
|
$style=new TPanelStyle; |
|
541
|
|
|
$this->setViewState('SideBarStyle',$style,null); |
|
542
|
|
|
} |
|
543
|
|
|
return $style; |
|
544
|
|
|
} |
|
545
|
|
|
|
|
546
|
|
|
/** |
|
547
|
|
|
* @return TPanelStyle the style for the header. |
|
548
|
|
|
*/ |
|
549
|
|
|
public function getHeaderStyle() |
|
550
|
|
|
{ |
|
551
|
|
|
if(($style=$this->getViewState('HeaderStyle',null))===null) |
|
552
|
|
|
{ |
|
553
|
|
|
$style=new TPanelStyle; |
|
554
|
|
|
$this->setViewState('HeaderStyle',$style,null); |
|
555
|
|
|
} |
|
556
|
|
|
return $style; |
|
557
|
|
|
} |
|
558
|
|
|
|
|
559
|
|
|
/** |
|
560
|
|
|
* @return TPanelStyle the style for each internal wizard step. |
|
561
|
|
|
*/ |
|
562
|
|
|
public function getStepStyle() |
|
563
|
|
|
{ |
|
564
|
|
|
if(($style=$this->getViewState('StepStyle',null))===null) |
|
565
|
|
|
{ |
|
566
|
|
|
$style=new TPanelStyle; |
|
567
|
|
|
$this->setViewState('StepStyle',$style,null); |
|
568
|
|
|
} |
|
569
|
|
|
return $style; |
|
570
|
|
|
} |
|
571
|
|
|
|
|
572
|
|
|
/** |
|
573
|
|
|
* @return TPanelStyle the style for the navigation panel. |
|
574
|
|
|
*/ |
|
575
|
|
|
public function getNavigationStyle() |
|
576
|
|
|
{ |
|
577
|
|
|
if(($style=$this->getViewState('NavigationStyle',null))===null) |
|
578
|
|
|
{ |
|
579
|
|
|
$style=new TPanelStyle; |
|
580
|
|
|
$this->setViewState('NavigationStyle',$style,null); |
|
581
|
|
|
} |
|
582
|
|
|
return $style; |
|
583
|
|
|
} |
|
584
|
|
|
|
|
585
|
|
|
/** |
|
586
|
|
|
* @return boolean whether to use default layout to arrange side bar and the rest wizard components. Defaults to true. |
|
587
|
|
|
*/ |
|
588
|
|
|
public function getUseDefaultLayout() |
|
589
|
|
|
{ |
|
590
|
|
|
return $this->getViewState('UseDefaultLayout',true); |
|
591
|
|
|
} |
|
592
|
|
|
|
|
593
|
|
|
/** |
|
594
|
|
|
* @param boolean whether to use default layout to arrange side bar and the rest wizard components. |
|
595
|
|
|
* If true, an HTML table will be used which places the side bar in the left cell |
|
596
|
|
|
* while the rest components in the right cell. |
|
597
|
|
|
*/ |
|
598
|
|
|
public function setUseDefaultLayout($value) |
|
599
|
|
|
{ |
|
600
|
|
|
$this->setViewState('UseDefaultLayout',TPropertyValue::ensureBoolean($value),true); |
|
601
|
|
|
} |
|
602
|
|
|
|
|
603
|
|
|
/** |
|
604
|
|
|
* @return TPanel container of the wizard header |
|
605
|
|
|
*/ |
|
606
|
|
|
public function getHeader() |
|
607
|
|
|
{ |
|
608
|
|
|
return $this->_header; |
|
609
|
|
|
} |
|
610
|
|
|
|
|
611
|
|
|
/** |
|
612
|
|
|
* @return TPanel container of the wizard step content |
|
613
|
|
|
*/ |
|
614
|
|
|
public function getStepContent() |
|
615
|
|
|
{ |
|
616
|
|
|
return $this->_stepContent; |
|
617
|
|
|
} |
|
618
|
|
|
|
|
619
|
|
|
/** |
|
620
|
|
|
* @return TPanel container of the wizard side bar |
|
621
|
|
|
*/ |
|
622
|
|
|
public function getSideBar() |
|
623
|
|
|
{ |
|
624
|
|
|
return $this->_sideBar; |
|
625
|
|
|
} |
|
626
|
|
|
|
|
627
|
|
|
/** |
|
628
|
|
|
* @return TWizardNavigationContainer container of the start navigation |
|
629
|
|
|
*/ |
|
630
|
|
|
public function getStartNavigation() |
|
631
|
|
|
{ |
|
632
|
|
|
return $this->_startNavigation; |
|
633
|
|
|
} |
|
634
|
|
|
|
|
635
|
|
|
/** |
|
636
|
|
|
* @return TWizardNavigationContainer container of the step navigation |
|
637
|
|
|
*/ |
|
638
|
|
|
public function getStepNavigation() |
|
639
|
|
|
{ |
|
640
|
|
|
return $this->_stepNavigation; |
|
641
|
|
|
} |
|
642
|
|
|
|
|
643
|
|
|
/** |
|
644
|
|
|
* @return TWizardNavigationContainer container of the finish navigation |
|
645
|
|
|
*/ |
|
646
|
|
|
public function getFinishNavigation() |
|
647
|
|
|
{ |
|
648
|
|
|
return $this->_finishNavigation; |
|
649
|
|
|
} |
|
650
|
|
|
|
|
651
|
|
|
/** |
|
652
|
|
|
* Raises <b>OnActiveStepChanged</b> event. |
|
653
|
|
|
* This event is raised when the current visible step is changed in the |
|
654
|
|
|
* wizard. |
|
655
|
|
|
* @param TEventParameter event parameter |
|
656
|
|
|
*/ |
|
657
|
|
|
public function onActiveStepChanged($param) |
|
658
|
|
|
{ |
|
659
|
|
|
$this->raiseEvent('OnActiveStepChanged',$this,$param); |
|
660
|
|
|
} |
|
661
|
|
|
|
|
662
|
|
|
/** |
|
663
|
|
|
* Raises <b>OnCancelButtonClick</b> event. |
|
664
|
|
|
* This event is raised when a cancel navigation button is clicked in the |
|
665
|
|
|
* current active step. |
|
666
|
|
|
* @param TEventParameter event parameter |
|
667
|
|
|
*/ |
|
668
|
|
|
public function onCancelButtonClick($param) |
|
669
|
|
|
{ |
|
670
|
|
|
$this->raiseEvent('OnCancelButtonClick',$this,$param); |
|
671
|
|
|
if(($url=$this->getCancelDestinationUrl())!=='') |
|
672
|
|
|
$this->getResponse()->redirect($url); |
|
673
|
|
|
} |
|
674
|
|
|
|
|
675
|
|
|
/** |
|
676
|
|
|
* Raises <b>OnCompleteButtonClick</b> event. |
|
677
|
|
|
* This event is raised when a finish navigation button is clicked in the |
|
678
|
|
|
* current active step. |
|
679
|
|
|
* @param TWizardNavigationEventParameter event parameter |
|
680
|
|
|
*/ |
|
681
|
|
|
public function onCompleteButtonClick($param) |
|
682
|
|
|
{ |
|
683
|
|
|
$this->raiseEvent('OnCompleteButtonClick',$this,$param); |
|
684
|
|
|
if(($url=$this->getFinishDestinationUrl())!=='') |
|
685
|
|
|
$this->getResponse()->redirect($url); |
|
686
|
|
|
} |
|
687
|
|
|
|
|
688
|
|
|
/** |
|
689
|
|
|
* Raises <b>OnNextButtonClick</b> event. |
|
690
|
|
|
* This event is raised when a next navigation button is clicked in the |
|
691
|
|
|
* current active step. |
|
692
|
|
|
* @param TWizardNavigationEventParameter event parameter |
|
693
|
|
|
*/ |
|
694
|
|
|
public function onNextButtonClick($param) |
|
695
|
|
|
{ |
|
696
|
|
|
$this->raiseEvent('OnNextButtonClick',$this,$param); |
|
697
|
|
|
} |
|
698
|
|
|
|
|
699
|
|
|
/** |
|
700
|
|
|
* Raises <b>OnPreviousButtonClick</b> event. |
|
701
|
|
|
* This event is raised when a previous navigation button is clicked in the |
|
702
|
|
|
* current active step. |
|
703
|
|
|
* @param TWizardNavigationEventParameter event parameter |
|
704
|
|
|
*/ |
|
705
|
|
|
public function onPreviousButtonClick($param) |
|
706
|
|
|
{ |
|
707
|
|
|
$this->raiseEvent('OnPreviousButtonClick',$this,$param); |
|
708
|
|
|
} |
|
709
|
|
|
|
|
710
|
|
|
/** |
|
711
|
|
|
* Raises <b>OnSideBarButtonClick</b> event. |
|
712
|
|
|
* This event is raised when a link button in the side bar is clicked. |
|
713
|
|
|
* @param TWizardNavigationEventParameter event parameter |
|
714
|
|
|
*/ |
|
715
|
|
|
public function onSideBarButtonClick($param) |
|
716
|
|
|
{ |
|
717
|
|
|
$this->raiseEvent('OnSideBarButtonClick',$this,$param); |
|
718
|
|
|
} |
|
719
|
|
|
|
|
720
|
|
|
/** |
|
721
|
|
|
* Returns the multiview that holds the wizard steps. |
|
722
|
|
|
* This method should only be used by control developers. |
|
723
|
|
|
* @return TMultiView the multiview holding wizard steps |
|
724
|
|
|
*/ |
|
725
|
|
|
public function getMultiView() |
|
726
|
|
|
{ |
|
727
|
|
|
if($this->_multiView===null) |
|
728
|
|
|
{ |
|
729
|
|
|
$this->_multiView=new TMultiView; |
|
730
|
|
|
$this->_multiView->setID('WizardMultiView'); |
|
731
|
|
|
$this->_multiView->attachEventHandler('OnActiveViewChanged',array($this,'onActiveStepChanged')); |
|
732
|
|
|
$this->_multiView->ignoreBubbleEvents(); |
|
733
|
|
|
} |
|
734
|
|
|
return $this->_multiView; |
|
735
|
|
|
} |
|
736
|
|
|
|
|
737
|
|
|
/** |
|
738
|
|
|
* Adds a wizard step to the multiview. |
|
739
|
|
|
* This method should only be used by control developers. |
|
740
|
|
|
* It is invoked when a step is added into the step collection of the wizard. |
|
741
|
|
|
* @param TWizardStep wizard step to be added into multiview. |
|
742
|
|
|
*/ |
|
743
|
|
|
public function addedWizardStep($step) |
|
744
|
|
|
{ |
|
745
|
|
|
if(($wizard=$step->getWizard())!==null) |
|
746
|
|
|
$wizard->getWizardSteps()->remove($step); |
|
747
|
|
|
$step->setWizard($this); |
|
748
|
|
|
$this->wizardStepsChanged(); |
|
749
|
|
|
} |
|
750
|
|
|
|
|
751
|
|
|
/** |
|
752
|
|
|
* Removes a wizard step from the multiview. |
|
753
|
|
|
* This method should only be used by control developers. |
|
754
|
|
|
* It is invoked when a step is removed from the step collection of the wizard. |
|
755
|
|
|
* @param TWizardStep wizard step to be removed from multiview. |
|
756
|
|
|
*/ |
|
757
|
|
|
public function removedWizardStep($step) |
|
758
|
|
|
{ |
|
759
|
|
|
$step->setWizard(null); |
|
760
|
|
|
$this->wizardStepsChanged(); |
|
761
|
|
|
} |
|
762
|
|
|
|
|
763
|
|
|
/** |
|
764
|
|
|
* Creates the child controls of the wizard. |
|
765
|
|
|
* This method overrides the parent implementation. |
|
766
|
|
|
* @param TEventParameter event parameter |
|
767
|
|
|
*/ |
|
768
|
|
|
public function onInit($param) |
|
769
|
|
|
{ |
|
770
|
|
|
parent::onInit($param); |
|
771
|
|
|
$this->ensureChildControls(); |
|
772
|
|
|
$this->setEnsureId(true); |
|
773
|
|
|
if($this->getActiveStepIndex()<0 && $this->getWizardSteps()->getCount()>0) |
|
774
|
|
|
$this->setActiveStepIndex(0); |
|
775
|
|
|
} |
|
776
|
|
|
|
|
777
|
|
|
/** |
|
778
|
|
|
* Saves the current active step index into history. |
|
779
|
|
|
* This method is invoked by the framework when the control state is being saved. |
|
780
|
|
|
*/ |
|
781
|
|
|
public function saveState() |
|
782
|
|
|
{ |
|
783
|
|
|
$index=$this->getActiveStepIndex(); |
|
784
|
|
|
$history=$this->getHistory(); |
|
785
|
|
|
if(!$history->getCount() || $history->peek()!==$index) |
|
786
|
|
|
$history->push($index); |
|
787
|
|
|
} |
|
788
|
|
|
|
|
789
|
|
|
/** |
|
790
|
|
|
* Indicates the wizard needs to recreate all child controls. |
|
791
|
|
|
*/ |
|
792
|
|
|
protected function requiresControlsRecreation() |
|
793
|
|
|
{ |
|
794
|
|
|
if($this->getChildControlsCreated()) |
|
795
|
|
|
$this->setChildControlsCreated(false); |
|
796
|
|
|
} |
|
797
|
|
|
|
|
798
|
|
|
/** |
|
799
|
|
|
* Renders the wizard. |
|
800
|
|
|
* @param THtmlWriter |
|
801
|
|
|
*/ |
|
802
|
|
|
public function render($writer) |
|
803
|
|
|
{ |
|
804
|
|
|
$this->ensureChildControls(); |
|
805
|
|
|
if($this->getHasControls()) |
|
806
|
|
|
{ |
|
807
|
|
|
if($this->getUseDefaultLayout()) |
|
808
|
|
|
{ |
|
809
|
|
|
$this->applyControlProperties(); |
|
810
|
|
|
$this->renderBeginTag($writer); |
|
811
|
|
|
$writer->write("\n<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" height=\"100%\" width=\"100%\">\n<tr><td width=\"1\" valign=\"top\">\n"); |
|
812
|
|
|
$this->_sideBar->renderControl($writer); |
|
813
|
|
|
$writer->write("\n</td><td valign=\"top\">\n"); |
|
814
|
|
|
$this->_header->renderControl($writer); |
|
815
|
|
|
$this->_stepContent->renderControl($writer); |
|
816
|
|
|
$this->_navigation->renderControl($writer); |
|
817
|
|
|
$writer->write("\n</td></tr></table>\n"); |
|
818
|
|
|
$this->renderEndTag($writer); |
|
819
|
|
|
} |
|
820
|
|
|
else |
|
821
|
|
|
{ |
|
822
|
|
|
$this->applyControlProperties(); |
|
823
|
|
|
$this->renderBeginTag($writer); |
|
824
|
|
|
$this->_sideBar->renderControl($writer); |
|
825
|
|
|
$this->_header->renderControl($writer); |
|
826
|
|
|
$this->_stepContent->renderControl($writer); |
|
827
|
|
|
$this->_navigation->renderControl($writer); |
|
828
|
|
|
$this->renderEndTag($writer); |
|
829
|
|
|
} |
|
830
|
|
|
} |
|
831
|
|
|
} |
|
832
|
|
|
|
|
833
|
|
|
/** |
|
834
|
|
|
* Applies various properties to the components of wizard |
|
835
|
|
|
*/ |
|
836
|
|
|
protected function applyControlProperties() |
|
837
|
|
|
{ |
|
838
|
|
|
$this->applyHeaderProperties(); |
|
839
|
|
|
$this->applySideBarProperties(); |
|
840
|
|
|
$this->applyStepContentProperties(); |
|
841
|
|
|
$this->applyNavigationProperties(); |
|
842
|
|
|
} |
|
843
|
|
|
|
|
844
|
|
|
/** |
|
845
|
|
|
* Applies properties to the wizard header |
|
846
|
|
|
*/ |
|
847
|
|
|
protected function applyHeaderProperties() |
|
848
|
|
|
{ |
|
849
|
|
|
if(($style=$this->getViewState('HeaderStyle',null))!==null) |
|
850
|
|
|
$this->_header->getStyle()->mergeWith($style); |
|
851
|
|
|
if($this->getHeaderTemplate()===null) |
|
852
|
|
|
{ |
|
853
|
|
|
$this->_header->getControls()->clear(); |
|
854
|
|
|
$this->_header->getControls()->add($this->getHeaderText()); |
|
855
|
|
|
} |
|
856
|
|
|
} |
|
857
|
|
|
|
|
858
|
|
|
/** |
|
859
|
|
|
* Applies properties to the wizard sidebar |
|
860
|
|
|
*/ |
|
861
|
|
|
protected function applySideBarProperties() |
|
862
|
|
|
{ |
|
863
|
|
|
$this->_sideBar->setVisible($this->getShowSideBar()); |
|
864
|
|
|
if($this->_sideBarDataList!==null && $this->getShowSideBar()) |
|
865
|
|
|
{ |
|
866
|
|
|
$this->_sideBarDataList->setDataSource($this->getWizardSteps()); |
|
867
|
|
|
$this->_sideBarDataList->setSelectedItemIndex($this->getActiveStepIndex()); |
|
868
|
|
|
$this->_sideBarDataList->dataBind(); |
|
869
|
|
|
if(($style=$this->getViewState('SideBarButtonStyle',null))!==null) |
|
870
|
|
|
{ |
|
871
|
|
|
foreach($this->_sideBarDataList->getItems() as $item) |
|
872
|
|
|
{ |
|
873
|
|
|
if(($button=$item->findControl('SideBarButton'))!==null) |
|
874
|
|
|
$button->getStyle()->mergeWith($style); |
|
875
|
|
|
} |
|
876
|
|
|
} |
|
877
|
|
|
} |
|
878
|
|
|
if(($style=$this->getViewState('SideBarStyle',null))!==null) |
|
879
|
|
|
$this->_sideBar->getStyle()->mergeWith($style); |
|
880
|
|
|
} |
|
881
|
|
|
|
|
882
|
|
|
/** |
|
883
|
|
|
* Applies properties to the wizard step content |
|
884
|
|
|
*/ |
|
885
|
|
|
protected function applyStepContentProperties() |
|
886
|
|
|
{ |
|
887
|
|
|
if(($style=$this->getViewState('StepStyle',null))!==null) |
|
888
|
|
|
$this->_stepContent->getStyle()->mergeWith($style); |
|
889
|
|
|
} |
|
890
|
|
|
|
|
891
|
|
|
/** |
|
892
|
|
|
* Apply properties to various navigation panels. |
|
893
|
|
|
*/ |
|
894
|
|
|
protected function applyNavigationProperties() |
|
895
|
|
|
{ |
|
896
|
|
|
$wizardSteps=$this->getWizardSteps(); |
|
897
|
|
|
$activeStep=$this->getActiveStep(); |
|
898
|
|
|
$activeStepIndex=$this->getActiveStepIndex(); |
|
899
|
|
|
|
|
900
|
|
|
if(!$this->_navigation) |
|
901
|
|
|
return; |
|
902
|
|
|
else if($activeStepIndex<0 || $activeStepIndex>=$wizardSteps->getCount()) |
|
903
|
|
|
{ |
|
904
|
|
|
$this->_navigation->setVisible(false); |
|
905
|
|
|
return; |
|
906
|
|
|
} |
|
907
|
|
|
|
|
908
|
|
|
// set visibility of different types of navigation panel |
|
909
|
|
|
$showStandard=true; |
|
910
|
|
|
foreach($wizardSteps as $step) |
|
911
|
|
|
{ |
|
912
|
|
|
if(($step instanceof TTemplatedWizardStep) && ($container=$step->getNavigationContainer())!==null) |
|
913
|
|
|
{ |
|
914
|
|
|
if($activeStep===$step) |
|
915
|
|
|
{ |
|
916
|
|
|
$container->setVisible(true); |
|
917
|
|
|
$showStandard=false; |
|
918
|
|
|
} |
|
919
|
|
|
else |
|
920
|
|
|
$container->setVisible(false); |
|
921
|
|
|
} |
|
922
|
|
|
} |
|
923
|
|
|
$activeStepType=$this->getStepType($activeStep); |
|
924
|
|
|
if($activeStepType===TWizardStepType::Complete) |
|
925
|
|
|
{ |
|
926
|
|
|
$this->_sideBar->setVisible(false); |
|
927
|
|
|
$this->_header->setVisible(false); |
|
928
|
|
|
} |
|
929
|
|
|
$this->_startNavigation->setVisible($showStandard && $activeStepType===self::ST_START); |
|
930
|
|
|
$this->_stepNavigation->setVisible($showStandard && $activeStepType===self::ST_STEP); |
|
931
|
|
|
$this->_finishNavigation->setVisible($showStandard && $activeStepType===self::ST_FINISH); |
|
932
|
|
|
|
|
933
|
|
|
if(($navigationStyle=$this->getViewState('NavigationStyle',null))!==null) |
|
934
|
|
|
$this->_navigation->getStyle()->mergeWith($navigationStyle); |
|
935
|
|
|
|
|
936
|
|
|
$displayCancelButton=$this->getShowCancelButton(); |
|
937
|
|
|
$cancelButtonStyle=$this->getCancelButtonStyle(); |
|
938
|
|
|
$buttonStyle=$this->getViewState('NavigationButtonStyle',null); |
|
939
|
|
|
if($buttonStyle!==null) |
|
940
|
|
|
$cancelButtonStyle->mergeWith($buttonStyle); |
|
941
|
|
|
|
|
942
|
|
|
// apply styles to start navigation buttons |
|
943
|
|
|
if(($cancelButton=$this->_startNavigation->getCancelButton())!==null) |
|
944
|
|
|
{ |
|
945
|
|
|
$cancelButton->setVisible($displayCancelButton); |
|
946
|
|
|
$cancelButtonStyle->apply($cancelButton); |
|
947
|
|
|
} |
|
948
|
|
|
if(($button=$this->_startNavigation->getNextButton())!==null) |
|
949
|
|
|
{ |
|
950
|
|
|
$button->setVisible(true); |
|
951
|
|
|
$style=$this->getStartNextButtonStyle(); |
|
952
|
|
|
if($buttonStyle!==null) |
|
953
|
|
|
$style->mergeWith($buttonStyle); |
|
954
|
|
|
$style->apply($button); |
|
955
|
|
|
if($activeStepType===TWizardStepType::Start) |
|
956
|
|
|
$this->getPage()->getClientScript()->registerDefaultButton($this, $button); |
|
957
|
|
|
} |
|
958
|
|
|
|
|
959
|
|
|
// apply styles to finish navigation buttons |
|
960
|
|
|
if(($cancelButton=$this->_finishNavigation->getCancelButton())!==null) |
|
961
|
|
|
{ |
|
962
|
|
|
$cancelButton->setVisible($displayCancelButton); |
|
963
|
|
|
$cancelButtonStyle->apply($cancelButton); |
|
964
|
|
|
} |
|
965
|
|
|
if(($button=$this->_finishNavigation->getPreviousButton())!==null) |
|
966
|
|
|
{ |
|
967
|
|
|
$button->setVisible($this->allowNavigationToPreviousStep()); |
|
968
|
|
|
$style=$this->getFinishPreviousButtonStyle(); |
|
969
|
|
|
if($buttonStyle!==null) |
|
970
|
|
|
$style->mergeWith($buttonStyle); |
|
971
|
|
|
$style->apply($button); |
|
972
|
|
|
} |
|
973
|
|
|
if(($button=$this->_finishNavigation->getCompleteButton())!==null) |
|
974
|
|
|
{ |
|
975
|
|
|
$button->setVisible(true); |
|
976
|
|
|
$style=$this->getFinishCompleteButtonStyle(); |
|
977
|
|
|
if($buttonStyle!==null) |
|
978
|
|
|
$style->mergeWith($buttonStyle); |
|
979
|
|
|
$style->apply($button); |
|
980
|
|
|
if($activeStepType===TWizardStepType::Finish) |
|
981
|
|
|
$this->getPage()->getClientScript()->registerDefaultButton($this, $button); |
|
982
|
|
|
} |
|
983
|
|
|
|
|
984
|
|
|
// apply styles to step navigation buttons |
|
985
|
|
|
if(($cancelButton=$this->_stepNavigation->getCancelButton())!==null) |
|
986
|
|
|
{ |
|
987
|
|
|
$cancelButton->setVisible($displayCancelButton); |
|
988
|
|
|
$cancelButtonStyle->apply($cancelButton); |
|
989
|
|
|
} |
|
990
|
|
|
if(($button=$this->_stepNavigation->getPreviousButton())!==null) |
|
991
|
|
|
{ |
|
992
|
|
|
$button->setVisible($this->allowNavigationToPreviousStep()); |
|
993
|
|
|
$style=$this->getStepPreviousButtonStyle(); |
|
994
|
|
|
if($buttonStyle!==null) |
|
995
|
|
|
$style->mergeWith($buttonStyle); |
|
996
|
|
|
$style->apply($button); |
|
997
|
|
|
} |
|
998
|
|
|
if(($button=$this->_stepNavigation->getNextButton())!==null) |
|
999
|
|
|
{ |
|
1000
|
|
|
$button->setVisible(true); |
|
1001
|
|
|
$style=$this->getStepNextButtonStyle(); |
|
1002
|
|
|
if($buttonStyle!==null) |
|
1003
|
|
|
$style->mergeWith($buttonStyle); |
|
1004
|
|
|
$style->apply($button); |
|
1005
|
|
|
if($activeStepType===TWizardStepType::Step) |
|
1006
|
|
|
$this->getPage()->getClientScript()->registerDefaultButton($this, $button); |
|
1007
|
|
|
} |
|
1008
|
|
|
} |
|
1009
|
|
|
|
|
1010
|
|
|
/** |
|
1011
|
|
|
* @return TStack history containing step indexes that were navigated before |
|
1012
|
|
|
*/ |
|
1013
|
|
|
protected function getHistory() |
|
1014
|
|
|
{ |
|
1015
|
|
|
if(($history=$this->getControlState('History',null))===null) |
|
1016
|
|
|
{ |
|
1017
|
|
|
$history=new TStack; |
|
1018
|
|
|
$this->setControlState('History',$history); |
|
1019
|
|
|
} |
|
1020
|
|
|
return $history; |
|
1021
|
|
|
} |
|
1022
|
|
|
|
|
1023
|
|
|
/** |
|
1024
|
|
|
* Determines the type of the specified wizard step. |
|
1025
|
|
|
* @param TWizardStep |
|
1026
|
|
|
* @return TWizardStepType type of the step |
|
1027
|
|
|
*/ |
|
1028
|
|
|
protected function getStepType($wizardStep) |
|
1029
|
|
|
{ |
|
1030
|
|
|
if(($type=$wizardStep->getStepType())===TWizardStepType::Auto) |
|
1031
|
|
|
{ |
|
1032
|
|
|
$steps=$this->getWizardSteps(); |
|
1033
|
|
|
if(($index=$steps->indexOf($wizardStep))>=0) |
|
1034
|
|
|
{ |
|
1035
|
|
|
$stepCount=$steps->getCount(); |
|
1036
|
|
|
if($stepCount===1 || ($index<$stepCount-1 && $steps->itemAt($index+1)->getStepType()===TWizardStepType::Complete)) |
|
1037
|
|
|
return TWizardStepType::Finish; |
|
1038
|
|
|
else if($index===0) |
|
1039
|
|
|
return TWizardStepType::Start; |
|
1040
|
|
|
else if($index===$stepCount-1) |
|
1041
|
|
|
return TWizardStepType::Finish; |
|
1042
|
|
|
else |
|
1043
|
|
|
return TWizardStepType::Step; |
|
1044
|
|
|
} |
|
1045
|
|
|
else |
|
1046
|
|
|
return $type; |
|
1047
|
|
|
} |
|
1048
|
|
|
else |
|
1049
|
|
|
return $type; |
|
1050
|
|
|
} |
|
1051
|
|
|
|
|
1052
|
|
|
/** |
|
1053
|
|
|
* Clears up everything within the wizard. |
|
1054
|
|
|
*/ |
|
1055
|
|
|
protected function reset() |
|
1056
|
|
|
{ |
|
1057
|
|
|
$this->getControls()->clear(); |
|
1058
|
|
|
$this->_header=null; |
|
1059
|
|
|
$this->_stepContent=null; |
|
1060
|
|
|
$this->_sideBar=null; |
|
1061
|
|
|
$this->_sideBarDataList=null; |
|
1062
|
|
|
$this->_navigation=null; |
|
1063
|
|
|
$this->_startNavigation=null; |
|
1064
|
|
|
$this->_stepNavigation=null; |
|
1065
|
|
|
$this->_finishNavigation=null; |
|
1066
|
|
|
} |
|
1067
|
|
|
|
|
1068
|
|
|
/** |
|
1069
|
|
|
* Creates child controls within the wizard |
|
1070
|
|
|
*/ |
|
1071
|
|
|
public function createChildControls() |
|
1072
|
|
|
{ |
|
1073
|
|
|
$this->reset(); |
|
1074
|
|
|
$this->createSideBar(); |
|
1075
|
|
|
$this->createHeader(); |
|
1076
|
|
|
$this->createStepContent(); |
|
1077
|
|
|
$this->createNavigation(); |
|
1078
|
|
|
// $this->clearChildState(); |
|
1079
|
|
|
} |
|
1080
|
|
|
|
|
1081
|
|
|
/** |
|
1082
|
|
|
* Creates the wizard header. |
|
1083
|
|
|
*/ |
|
1084
|
|
|
protected function createHeader() |
|
1085
|
|
|
{ |
|
1086
|
|
|
$this->_header=new TPanel; |
|
1087
|
|
|
if(($template=$this->getHeaderTemplate())!==null) |
|
1088
|
|
|
$template->instantiateIn($this->_header); |
|
1089
|
|
|
else |
|
1090
|
|
|
$this->_header->getControls()->add($this->getHeaderText()); |
|
1091
|
|
|
$this->getControls()->add($this->_header); |
|
1092
|
|
|
} |
|
1093
|
|
|
|
|
1094
|
|
|
/** |
|
1095
|
|
|
* Creates the wizard side bar |
|
1096
|
|
|
*/ |
|
1097
|
|
|
protected function createSideBar() |
|
1098
|
|
|
{ |
|
1099
|
|
|
if($this->getShowSideBar()) |
|
1100
|
|
|
{ |
|
1101
|
|
|
if(($template=$this->getSideBarTemplate())===null) |
|
1102
|
|
|
$template=new TWizardSideBarTemplate; |
|
1103
|
|
|
$this->_sideBar=new TPanel; |
|
1104
|
|
|
$template->instantiateIn($this->_sideBar); |
|
1105
|
|
|
$this->getControls()->add($this->_sideBar); |
|
1106
|
|
|
|
|
1107
|
|
|
if(($this->_sideBarDataList=$this->_sideBar->findControl(self::ID_SIDEBAR_LIST))!==null) |
|
1108
|
|
|
{ |
|
1109
|
|
|
$this->_sideBarDataList->attachEventHandler('OnItemCommand',array($this,'dataListItemCommand')); |
|
1110
|
|
|
$this->_sideBarDataList->attachEventHandler('OnItemDataBound',array($this,'dataListItemDataBound')); |
|
1111
|
|
|
$this->_sideBarDataList->setDataSource($this->getWizardSteps()); |
|
1112
|
|
|
$this->_sideBarDataList->setSelectedItemIndex($this->getActiveStepIndex()); |
|
1113
|
|
|
$this->_sideBarDataList->dataBind(); |
|
1114
|
|
|
} |
|
1115
|
|
|
} |
|
1116
|
|
|
else |
|
1117
|
|
|
{ |
|
1118
|
|
|
$this->_sideBar=new TPanel; |
|
1119
|
|
|
$this->getControls()->add($this->_sideBar); |
|
1120
|
|
|
} |
|
1121
|
|
|
} |
|
1122
|
|
|
|
|
1123
|
|
|
/** |
|
1124
|
|
|
* Event handler for sidebar datalist's OnItemCommand event. |
|
1125
|
|
|
* This method is used internally by wizard. It mainly |
|
1126
|
|
|
* sets the active step index according to the button clicked in the sidebar. |
|
1127
|
|
|
* @param mixed sender of the event |
|
1128
|
|
|
* @param TDataListCommandEventParameter |
|
1129
|
|
|
*/ |
|
1130
|
|
|
public function dataListItemCommand($sender,$param) |
|
1131
|
|
|
{ |
|
1132
|
|
|
$item=$param->getItem(); |
|
|
|
|
|
|
1133
|
|
|
if($param->getCommandName()===self::CMD_MOVETO) |
|
1134
|
|
|
{ |
|
1135
|
|
|
$stepIndex=$this->getActiveStepIndex(); |
|
1136
|
|
|
$newStepIndex=TPropertyValue::ensureInteger($param->getCommandParameter()); |
|
1137
|
|
|
$navParam=new TWizardNavigationEventParameter($stepIndex); |
|
1138
|
|
|
$navParam->setNextStepIndex($newStepIndex); |
|
1139
|
|
|
|
|
1140
|
|
|
// if the button clicked causes validation which fails, |
|
1141
|
|
|
// by default we will cancel navigation to the new step |
|
1142
|
|
|
$button=$param->getCommandSource(); |
|
1143
|
|
|
if(($button instanceof IButtonControl) && $button->getCausesValidation() && ($page=$this->getPage())!==null && !$page->getIsValid()) |
|
1144
|
|
|
$navParam->setCancelNavigation(true); |
|
1145
|
|
|
|
|
1146
|
|
|
$this->_activeStepIndexSet=false; |
|
1147
|
|
|
$this->onSideBarButtonClick($navParam); |
|
1148
|
|
|
$this->_cancelNavigation=$navParam->getCancelNavigation(); |
|
1149
|
|
|
if(!$this->_cancelNavigation) |
|
1150
|
|
|
{ |
|
1151
|
|
|
if(!$this->_activeStepIndexSet && $this->allowNavigationToStep($newStepIndex)) |
|
1152
|
|
|
$this->setActiveStepIndex($newStepIndex); |
|
1153
|
|
|
} |
|
1154
|
|
|
else |
|
1155
|
|
|
$this->setActiveStepIndex($stepIndex); |
|
1156
|
|
|
} |
|
1157
|
|
|
} |
|
1158
|
|
|
|
|
1159
|
|
|
/** |
|
1160
|
|
|
* Event handler for sidebar datalist's OnItemDataBound event. |
|
1161
|
|
|
* This method is used internally by wizard. It mainly configures |
|
1162
|
|
|
* the buttons in the sidebar datalist. |
|
1163
|
|
|
* @param mixed sender of the event |
|
1164
|
|
|
* @param TDataListItemEventParameter |
|
1165
|
|
|
*/ |
|
1166
|
|
|
public function dataListItemDataBound($sender,$param) |
|
1167
|
|
|
{ |
|
1168
|
|
|
$item=$param->getItem(); |
|
1169
|
|
|
$itemType=$item->getItemType(); |
|
1170
|
|
|
if($itemType==='Item' || $itemType==='AlternatingItem' || $itemType==='SelectedItem' || $itemType==='EditItem') |
|
1171
|
|
|
{ |
|
1172
|
|
|
if(($button=$item->findControl(self::ID_SIDEBAR_BUTTON))!==null) |
|
1173
|
|
|
{ |
|
1174
|
|
|
$step=$item->getData(); |
|
1175
|
|
|
if(($this->getStepType($step)===TWizardStepType::Complete)) |
|
1176
|
|
|
$button->setEnabled(false); |
|
1177
|
|
|
if(($title=$step->getTitle())!=='') |
|
1178
|
|
|
$button->setText($title); |
|
1179
|
|
|
else |
|
1180
|
|
|
$button->setText($step->getID(false)); |
|
1181
|
|
|
$index=$this->getWizardSteps()->indexOf($step); |
|
1182
|
|
|
$button->setCommandName(self::CMD_MOVETO); |
|
1183
|
|
|
$button->setCommandParameter("$index"); |
|
1184
|
|
|
} |
|
1185
|
|
|
} |
|
1186
|
|
|
} |
|
1187
|
|
|
|
|
1188
|
|
|
/** |
|
1189
|
|
|
* Creates wizard step content. |
|
1190
|
|
|
*/ |
|
1191
|
|
|
protected function createStepContent() |
|
1192
|
|
|
{ |
|
1193
|
|
|
foreach($this->getWizardSteps() as $step) |
|
1194
|
|
|
{ |
|
1195
|
|
|
if($step instanceof TTemplatedWizardStep) |
|
1196
|
|
|
$step->ensureChildControls(); |
|
1197
|
|
|
} |
|
1198
|
|
|
$multiView=$this->getMultiView(); |
|
1199
|
|
|
$this->_stepContent=new TPanel; |
|
1200
|
|
|
$this->_stepContent->getControls()->add($multiView); |
|
1201
|
|
|
$this->getControls()->add($this->_stepContent); |
|
1202
|
|
|
if($multiView->getViews()->getCount()) |
|
1203
|
|
|
$multiView->setActiveViewIndex(0); |
|
1204
|
|
|
} |
|
1205
|
|
|
|
|
1206
|
|
|
/** |
|
1207
|
|
|
* Creates navigation panel. |
|
1208
|
|
|
*/ |
|
1209
|
|
|
protected function createNavigation() |
|
1210
|
|
|
{ |
|
1211
|
|
|
$this->_navigation=new TPanel; |
|
1212
|
|
|
$this->getControls()->add($this->_navigation); |
|
1213
|
|
|
$controls=$this->_navigation->getControls(); |
|
1214
|
|
|
foreach($this->getWizardSteps() as $step) |
|
1215
|
|
|
{ |
|
1216
|
|
|
if($step instanceof TTemplatedWizardStep) |
|
1217
|
|
|
{ |
|
1218
|
|
|
$step->instantiateNavigationTemplate(); |
|
1219
|
|
|
if(($panel=$step->getNavigationContainer())!==null) |
|
1220
|
|
|
$controls->add($panel); |
|
1221
|
|
|
} |
|
1222
|
|
|
} |
|
1223
|
|
|
$this->_startNavigation=$this->createStartNavigation(); |
|
1224
|
|
|
$controls->add($this->_startNavigation); |
|
1225
|
|
|
$this->_stepNavigation=$this->createStepNavigation(); |
|
1226
|
|
|
$controls->add($this->_stepNavigation); |
|
1227
|
|
|
$this->_finishNavigation=$this->createFinishNavigation(); |
|
1228
|
|
|
$controls->add($this->_finishNavigation); |
|
1229
|
|
|
} |
|
1230
|
|
|
|
|
1231
|
|
|
/** |
|
1232
|
|
|
* Creates start navigation panel. |
|
1233
|
|
|
*/ |
|
1234
|
|
|
protected function createStartNavigation() |
|
1235
|
|
|
{ |
|
1236
|
|
|
if(($template=$this->getStartNavigationTemplate())===null) |
|
1237
|
|
|
$template=new TWizardStartNavigationTemplate($this); |
|
1238
|
|
|
$navigation=new TWizardNavigationContainer; |
|
1239
|
|
|
$template->instantiateIn($navigation); |
|
1240
|
|
|
return $navigation; |
|
1241
|
|
|
} |
|
1242
|
|
|
|
|
1243
|
|
|
/** |
|
1244
|
|
|
* Creates step navigation panel. |
|
1245
|
|
|
*/ |
|
1246
|
|
|
protected function createStepNavigation() |
|
1247
|
|
|
{ |
|
1248
|
|
|
if(($template=$this->getStepNavigationTemplate())===null) |
|
1249
|
|
|
$template=new TWizardStepNavigationTemplate($this); |
|
1250
|
|
|
$navigation=new TWizardNavigationContainer; |
|
1251
|
|
|
$template->instantiateIn($navigation); |
|
1252
|
|
|
return $navigation; |
|
1253
|
|
|
} |
|
1254
|
|
|
|
|
1255
|
|
|
/** |
|
1256
|
|
|
* Creates finish navigation panel. |
|
1257
|
|
|
*/ |
|
1258
|
|
|
protected function createFinishNavigation() |
|
1259
|
|
|
{ |
|
1260
|
|
|
if(($template=$this->getFinishNavigationTemplate())===null) |
|
1261
|
|
|
$template=new TWizardFinishNavigationTemplate($this); |
|
1262
|
|
|
$navigation=new TWizardNavigationContainer; |
|
1263
|
|
|
$template->instantiateIn($navigation); |
|
1264
|
|
|
return $navigation; |
|
1265
|
|
|
} |
|
1266
|
|
|
|
|
1267
|
|
|
/** |
|
1268
|
|
|
* Updates the sidebar datalist if any. |
|
1269
|
|
|
* This method is invoked when any wizard step is changed. |
|
1270
|
|
|
*/ |
|
1271
|
|
|
public function wizardStepsChanged() |
|
1272
|
|
|
{ |
|
1273
|
|
|
if($this->_sideBarDataList!==null) |
|
1274
|
|
|
{ |
|
1275
|
|
|
$this->_sideBarDataList->setDataSource($this->getWizardSteps()); |
|
1276
|
|
|
$this->_sideBarDataList->setSelectedItemIndex($this->getActiveStepIndex()); |
|
1277
|
|
|
$this->_sideBarDataList->dataBind(); |
|
1278
|
|
|
} |
|
1279
|
|
|
} |
|
1280
|
|
|
|
|
1281
|
|
|
/** |
|
1282
|
|
|
* Determines the index of the previous step based on history. |
|
1283
|
|
|
* @param boolean whether the first item in the history stack should be popped |
|
1284
|
|
|
* up after calling this method. |
|
1285
|
|
|
*/ |
|
1286
|
|
|
protected function getPreviousStepIndex($popStack) |
|
1287
|
|
|
{ |
|
1288
|
|
|
$history=$this->getHistory(); |
|
1289
|
|
|
if($history->getCount()>=0) |
|
1290
|
|
|
{ |
|
1291
|
|
|
$activeStepIndex=$this->getActiveStepIndex(); |
|
1292
|
|
|
$previousStepIndex=-1; |
|
|
|
|
|
|
1293
|
|
|
if($popStack) |
|
1294
|
|
|
{ |
|
1295
|
|
|
$previousStepIndex=$history->pop(); |
|
1296
|
|
|
if($activeStepIndex===$previousStepIndex && $history->getCount()>0) |
|
1297
|
|
|
$previousStepIndex=$history->pop(); |
|
1298
|
|
|
} |
|
1299
|
|
|
else |
|
1300
|
|
|
{ |
|
1301
|
|
|
$previousStepIndex=$history->peek(); |
|
1302
|
|
|
if($activeStepIndex===$previousStepIndex && $history->getCount()>1) |
|
1303
|
|
|
{ |
|
1304
|
|
|
$saveIndex=$history->pop(); |
|
1305
|
|
|
$previousStepIndex=$history->peek(); |
|
1306
|
|
|
$history->push($saveIndex); |
|
1307
|
|
|
} |
|
1308
|
|
|
} |
|
1309
|
|
|
return $activeStepIndex===$previousStepIndex ? -1 : $previousStepIndex; |
|
1310
|
|
|
} |
|
1311
|
|
|
else |
|
1312
|
|
|
return -1; |
|
1313
|
|
|
} |
|
1314
|
|
|
|
|
1315
|
|
|
/** |
|
1316
|
|
|
* @return boolean whether navigation to the previous step is allowed |
|
1317
|
|
|
*/ |
|
1318
|
|
|
protected function allowNavigationToPreviousStep() |
|
1319
|
|
|
{ |
|
1320
|
|
|
if(($index=$this->getPreviousStepIndex(false))!==-1) |
|
1321
|
|
|
return $this->getWizardSteps()->itemAt($index)->getAllowReturn(); |
|
1322
|
|
|
else |
|
1323
|
|
|
return false; |
|
1324
|
|
|
} |
|
1325
|
|
|
|
|
1326
|
|
|
/** |
|
1327
|
|
|
* @param integer index of the step |
|
1328
|
|
|
* @return boolean whether navigation to the specified step is allowed |
|
1329
|
|
|
*/ |
|
1330
|
|
|
protected function allowNavigationToStep($index) |
|
1331
|
|
|
{ |
|
1332
|
|
|
if($this->getHistory()->contains($index)) |
|
1333
|
|
|
return $this->getWizardSteps()->itemAt($index)->getAllowReturn(); |
|
1334
|
|
|
else |
|
1335
|
|
|
return true; |
|
1336
|
|
|
} |
|
1337
|
|
|
|
|
1338
|
|
|
/** |
|
1339
|
|
|
* Handles bubbled events. |
|
1340
|
|
|
* This method mainly translate certain command events into |
|
1341
|
|
|
* wizard-specific events. |
|
1342
|
|
|
* @param mixed sender of the original command event |
|
1343
|
|
|
* @param TEventParameter event parameter |
|
1344
|
|
|
* @throws TInvalidDataValueException if a navigation command is associated with an invalid parameter |
|
1345
|
|
|
*/ |
|
1346
|
|
|
public function bubbleEvent($sender,$param) |
|
1347
|
|
|
{ |
|
1348
|
|
|
if($param instanceof TCommandEventParameter) |
|
1349
|
|
|
{ |
|
1350
|
|
|
$command=$param->getCommandName(); |
|
1351
|
|
|
if(strcasecmp($command,self::CMD_CANCEL)===0) |
|
1352
|
|
|
{ |
|
1353
|
|
|
$this->onCancelButtonClick($param); |
|
1354
|
|
|
return true; |
|
1355
|
|
|
} |
|
1356
|
|
|
|
|
1357
|
|
|
$type=$this->getStepType($this->getActiveStep()); |
|
1358
|
|
|
$index=$this->getActiveStepIndex(); |
|
1359
|
|
|
$navParam=new TWizardNavigationEventParameter($index); |
|
1360
|
|
|
if(($sender instanceof IButtonControl) && $sender->getCausesValidation() && ($page=$this->getPage())!==null && !$page->getIsValid()) |
|
1361
|
|
|
$navParam->setCancelNavigation(true); |
|
1362
|
|
|
|
|
1363
|
|
|
$handled=false; |
|
1364
|
|
|
$movePrev=false; |
|
1365
|
|
|
$this->_activeStepIndexSet=false; |
|
1366
|
|
|
|
|
1367
|
|
|
if(strcasecmp($command,self::CMD_NEXT)===0) |
|
1368
|
|
|
{ |
|
1369
|
|
|
if($type!==self::ST_START && $type!==self::ST_STEP) |
|
1370
|
|
|
throw new TInvalidDataValueException('wizard_command_invalid',self::CMD_NEXT); |
|
1371
|
|
|
if($index<$this->getWizardSteps()->getCount()-1) |
|
1372
|
|
|
$navParam->setNextStepIndex($index+1); |
|
1373
|
|
|
$this->onNextButtonClick($navParam); |
|
1374
|
|
|
$handled=true; |
|
1375
|
|
|
} |
|
1376
|
|
|
else if(strcasecmp($command,self::CMD_PREVIOUS)===0) |
|
1377
|
|
|
{ |
|
1378
|
|
|
if($type!==self::ST_FINISH && $type!==self::ST_STEP) |
|
1379
|
|
|
throw new TInvalidDataValueException('wizard_command_invalid',self::CMD_PREVIOUS); |
|
1380
|
|
|
$movePrev=true; |
|
1381
|
|
|
if(($prevIndex=$this->getPreviousStepIndex(false))>=0) |
|
1382
|
|
|
$navParam->setNextStepIndex($prevIndex); |
|
1383
|
|
|
$this->onPreviousButtonClick($navParam); |
|
1384
|
|
|
$handled=true; |
|
1385
|
|
|
} |
|
1386
|
|
|
else if(strcasecmp($command,self::CMD_COMPLETE)===0) |
|
1387
|
|
|
{ |
|
1388
|
|
|
if($type!==self::ST_FINISH) |
|
1389
|
|
|
throw new TInvalidDataValueException('wizard_command_invalid',self::CMD_COMPLETE); |
|
1390
|
|
|
if($index<$this->getWizardSteps()->getCount()-1) |
|
1391
|
|
|
$navParam->setNextStepIndex($index+1); |
|
1392
|
|
|
$this->onCompleteButtonClick($navParam); |
|
1393
|
|
|
$handled=true; |
|
1394
|
|
|
} |
|
1395
|
|
|
else if(strcasecmp($command,self::CMD_MOVETO)===0) |
|
1396
|
|
|
{ |
|
1397
|
|
|
if($this->_cancelNavigation) // may be set in onSideBarButtonClick |
|
1398
|
|
|
$navParam->setCancelNavigation(true); |
|
1399
|
|
|
$requestedStep=$param->getCommandParameter(); |
|
1400
|
|
|
if (!is_numeric($requestedStep)) |
|
1401
|
|
|
{ |
|
1402
|
|
|
$requestedIndex=-1; |
|
1403
|
|
|
foreach ($this->getWizardSteps() as $index=>$step) |
|
1404
|
|
|
if ($step->getId()===$requestedStep) |
|
1405
|
|
|
{ |
|
1406
|
|
|
$requestedIndex=$index; |
|
1407
|
|
|
break; |
|
1408
|
|
|
} |
|
1409
|
|
|
if ($requestedIndex<0) |
|
1410
|
|
|
throw new TConfigurationException('wizard_step_invalid'); |
|
1411
|
|
|
} |
|
1412
|
|
|
else |
|
1413
|
|
|
$requestedIndex=TPropertyValue::ensureInteger($requestedStep); |
|
1414
|
|
|
$navParam->setNextStepIndex($requestedIndex); |
|
1415
|
|
|
$handled=true; |
|
1416
|
|
|
} |
|
1417
|
|
|
|
|
1418
|
|
|
if($handled) |
|
1419
|
|
|
{ |
|
1420
|
|
|
if(!$navParam->getCancelNavigation()) |
|
1421
|
|
|
{ |
|
1422
|
|
|
$nextStepIndex=$navParam->getNextStepIndex(); |
|
1423
|
|
|
if(!$this->_activeStepIndexSet && $this->allowNavigationToStep($nextStepIndex)) |
|
1424
|
|
|
{ |
|
1425
|
|
|
if($movePrev) |
|
1426
|
|
|
$this->getPreviousStepIndex(true); // pop out the previous move from history |
|
1427
|
|
|
$this->setActiveStepIndex($nextStepIndex); |
|
1428
|
|
|
} |
|
1429
|
|
|
} |
|
1430
|
|
|
else |
|
1431
|
|
|
$this->setActiveStepIndex($index); |
|
1432
|
|
|
return true; |
|
1433
|
|
|
} |
|
1434
|
|
|
} |
|
1435
|
|
|
return false; |
|
1436
|
|
|
} |
|
1437
|
|
|
} |
|
1438
|
|
|
|
|
1439
|
|
|
|
|
1440
|
|
|
/** |
|
1441
|
|
|
* TWizardStep class. |
|
1442
|
|
|
* |
|
1443
|
|
|
* TWizardStep represents a wizard step. The wizard owning the step |
|
1444
|
|
|
* can be obtained by {@link getWizard Wizard}. |
|
1445
|
|
|
* To specify the type of the step, set {@link setStepType StepType}; |
|
1446
|
|
|
* For step title, set {@link setTitle Title}. If a step can be re-visited, |
|
1447
|
|
|
* set {@link setAllowReturn AllowReturn} to true. |
|
1448
|
|
|
* |
|
1449
|
|
|
* @author Qiang Xue <[email protected]> |
|
1450
|
|
|
* @package System.Web.UI.WebControls |
|
1451
|
|
|
* @since 3.0 |
|
1452
|
|
|
*/ |
|
1453
|
|
|
class TWizardStep extends TView |
|
1454
|
|
|
{ |
|
1455
|
|
|
private $_wizard; |
|
1456
|
|
|
|
|
1457
|
|
|
/** |
|
1458
|
|
|
* @return TWizard the wizard owning this step |
|
1459
|
|
|
*/ |
|
1460
|
|
|
public function getWizard() |
|
1461
|
|
|
{ |
|
1462
|
|
|
return $this->_wizard; |
|
1463
|
|
|
} |
|
1464
|
|
|
|
|
1465
|
|
|
/** |
|
1466
|
|
|
* Sets the wizard owning this step. |
|
1467
|
|
|
* This method is used internally by {@link TWizard}. |
|
1468
|
|
|
* @param TWizard the wizard owning this step |
|
1469
|
|
|
*/ |
|
1470
|
|
|
public function setWizard($wizard) |
|
1471
|
|
|
{ |
|
1472
|
|
|
$this->_wizard=$wizard; |
|
1473
|
|
|
} |
|
1474
|
|
|
|
|
1475
|
|
|
/** |
|
1476
|
|
|
* @return string the title for this step. |
|
1477
|
|
|
*/ |
|
1478
|
|
|
public function getTitle() |
|
1479
|
|
|
{ |
|
1480
|
|
|
return $this->getViewState('Title',''); |
|
1481
|
|
|
} |
|
1482
|
|
|
|
|
1483
|
|
|
/** |
|
1484
|
|
|
* @param string the title for this step. |
|
1485
|
|
|
*/ |
|
1486
|
|
|
public function setTitle($value) |
|
1487
|
|
|
{ |
|
1488
|
|
|
$this->setViewState('Title',$value,''); |
|
1489
|
|
|
if($this->_wizard) |
|
1490
|
|
|
$this->_wizard->wizardStepsChanged(); |
|
1491
|
|
|
} |
|
1492
|
|
|
|
|
1493
|
|
|
/** |
|
1494
|
|
|
* @return boolean whether this step can be re-visited. Default to true. |
|
1495
|
|
|
*/ |
|
1496
|
|
|
public function getAllowReturn() |
|
1497
|
|
|
{ |
|
1498
|
|
|
return $this->getViewState('AllowReturn',true); |
|
1499
|
|
|
} |
|
1500
|
|
|
|
|
1501
|
|
|
/** |
|
1502
|
|
|
* @param boolean whether this step can be re-visited. |
|
1503
|
|
|
*/ |
|
1504
|
|
|
public function setAllowReturn($value) |
|
1505
|
|
|
{ |
|
1506
|
|
|
$this->setViewState('AllowReturn',TPropertyValue::ensureBoolean($value),true); |
|
1507
|
|
|
} |
|
1508
|
|
|
|
|
1509
|
|
|
/** |
|
1510
|
|
|
* @return TWizardStepType the wizard step type. Defaults to TWizardStepType::Auto. |
|
1511
|
|
|
*/ |
|
1512
|
|
|
public function getStepType() |
|
1513
|
|
|
{ |
|
1514
|
|
|
return $this->getViewState('StepType',TWizardStepType::Auto); |
|
1515
|
|
|
} |
|
1516
|
|
|
|
|
1517
|
|
|
/** |
|
1518
|
|
|
* @param TWizardStepType the wizard step type. |
|
1519
|
|
|
*/ |
|
1520
|
|
|
public function setStepType($type) |
|
1521
|
|
|
{ |
|
1522
|
|
|
$type=TPropertyValue::ensureEnum($type,'TWizardStepType'); |
|
1523
|
|
|
if($type!==$this->getStepType()) |
|
1524
|
|
|
{ |
|
1525
|
|
|
$this->setViewState('StepType',$type,TWizardStepType::Auto); |
|
1526
|
|
|
if($this->_wizard) |
|
1527
|
|
|
$this->_wizard->wizardStepsChanged(); |
|
1528
|
|
|
} |
|
1529
|
|
|
} |
|
1530
|
|
|
} |
|
1531
|
|
|
|
|
1532
|
|
|
|
|
1533
|
|
|
/** |
|
1534
|
|
|
* TCompleteWizardStep class. |
|
1535
|
|
|
* |
|
1536
|
|
|
* TCompleteWizardStep represents a wizard step of type TWizardStepType::Complete. |
|
1537
|
|
|
* |
|
1538
|
|
|
* @author Qiang Xue <[email protected]> |
|
1539
|
|
|
* @package System.Web.UI.WebControls |
|
1540
|
|
|
* @since 3.0 |
|
1541
|
|
|
*/ |
|
1542
|
|
|
class TCompleteWizardStep extends TWizardStep |
|
1543
|
|
|
{ |
|
1544
|
|
|
/** |
|
1545
|
|
|
* @return TWizardStepType the wizard step type. Always TWizardStepType::Complete. |
|
1546
|
|
|
*/ |
|
1547
|
|
|
public function getStepType() |
|
1548
|
|
|
{ |
|
1549
|
|
|
return TWizardStepType::Complete; |
|
1550
|
|
|
} |
|
1551
|
|
|
|
|
1552
|
|
|
/** |
|
1553
|
|
|
* @param string the wizard step type. |
|
1554
|
|
|
* @throws TInvalidOperationException whenever this method is invoked. |
|
1555
|
|
|
*/ |
|
1556
|
|
|
public function setStepType($value) |
|
1557
|
|
|
{ |
|
1558
|
|
|
throw new TInvalidOperationException('completewizardstep_steptype_readonly'); |
|
1559
|
|
|
} |
|
1560
|
|
|
} |
|
1561
|
|
|
|
|
1562
|
|
|
|
|
1563
|
|
|
/** |
|
1564
|
|
|
* TTemplatedWizardStep class. |
|
1565
|
|
|
* |
|
1566
|
|
|
* TTemplatedWizardStep represents a wizard step whose content and navigation |
|
1567
|
|
|
* can be customized using templates. To customize the step content, specify |
|
1568
|
|
|
* {@link setContentTemplate ContentTemplate}. To customize navigation specific |
|
1569
|
|
|
* to the step, specify {@link setNavigationTemplate NavigationTemplate}. Note, |
|
1570
|
|
|
* if the navigation template is not specified, default navigation will be used. |
|
1571
|
|
|
* |
|
1572
|
|
|
* @author Qiang Xue <[email protected]> |
|
1573
|
|
|
* @package System.Web.UI.WebControls |
|
1574
|
|
|
* @since 3.0 |
|
1575
|
|
|
*/ |
|
1576
|
|
|
class TTemplatedWizardStep extends TWizardStep implements INamingContainer |
|
1577
|
|
|
{ |
|
1578
|
|
|
/** |
|
1579
|
|
|
* @var ITemplate the template for displaying the navigation UI of a wizard step. |
|
1580
|
|
|
*/ |
|
1581
|
|
|
private $_navigationTemplate=null; |
|
1582
|
|
|
/** |
|
1583
|
|
|
* @var ITemplate the template for displaying the content within the wizard step. |
|
1584
|
|
|
*/ |
|
1585
|
|
|
private $_contentTemplate=null; |
|
1586
|
|
|
/** |
|
1587
|
|
|
* @var TWizardNavigationContainer |
|
1588
|
|
|
*/ |
|
1589
|
|
|
private $_navigationContainer=null; |
|
1590
|
|
|
|
|
1591
|
|
|
/** |
|
1592
|
|
|
* Creates child controls. |
|
1593
|
|
|
* This method mainly instantiates the content template, if any. |
|
1594
|
|
|
*/ |
|
1595
|
|
|
public function createChildControls() |
|
1596
|
|
|
{ |
|
1597
|
|
|
$this->getControls()->clear(); |
|
1598
|
|
|
if($this->_contentTemplate) |
|
1599
|
|
|
$this->_contentTemplate->instantiateIn($this); |
|
1600
|
|
|
} |
|
1601
|
|
|
|
|
1602
|
|
|
/** |
|
1603
|
|
|
* Ensures child controls are created. |
|
1604
|
|
|
* @param mixed event parameter |
|
1605
|
|
|
*/ |
|
1606
|
|
|
public function onInit($param) |
|
1607
|
|
|
{ |
|
1608
|
|
|
parent::onInit($param); |
|
1609
|
|
|
$this->ensureChildControls(); |
|
1610
|
|
|
} |
|
1611
|
|
|
|
|
1612
|
|
|
/** |
|
1613
|
|
|
* @return ITemplate the template for the content of the wizard step. |
|
1614
|
|
|
*/ |
|
1615
|
|
|
public function getContentTemplate() |
|
1616
|
|
|
{ |
|
1617
|
|
|
return $this->_contentTemplate; |
|
1618
|
|
|
} |
|
1619
|
|
|
|
|
1620
|
|
|
/** |
|
1621
|
|
|
* @param ITemplate the template for the content of the wizard step. |
|
1622
|
|
|
*/ |
|
1623
|
|
|
public function setContentTemplate($value) |
|
1624
|
|
|
{ |
|
1625
|
|
|
$this->_contentTemplate=$value; |
|
1626
|
|
|
} |
|
1627
|
|
|
|
|
1628
|
|
|
/** |
|
1629
|
|
|
* @return ITemplate the template for displaying the navigation UI of a wizard step. Defaults to null. |
|
1630
|
|
|
*/ |
|
1631
|
|
|
public function getNavigationTemplate() |
|
1632
|
|
|
{ |
|
1633
|
|
|
return $this->_navigationTemplate; |
|
1634
|
|
|
} |
|
1635
|
|
|
|
|
1636
|
|
|
/** |
|
1637
|
|
|
* @param ITemplate the template for displaying the navigation UI of a wizard step. |
|
1638
|
|
|
*/ |
|
1639
|
|
|
public function setNavigationTemplate($value) |
|
1640
|
|
|
{ |
|
1641
|
|
|
$this->_navigationTemplate=$value; |
|
1642
|
|
|
} |
|
1643
|
|
|
|
|
1644
|
|
|
/** |
|
1645
|
|
|
* @return TWizardNavigationContainer the control containing the navigation. |
|
1646
|
|
|
* It could be null if no navigation template is specified. |
|
1647
|
|
|
*/ |
|
1648
|
|
|
public function getNavigationContainer() |
|
1649
|
|
|
{ |
|
1650
|
|
|
return $this->_navigationContainer; |
|
1651
|
|
|
} |
|
1652
|
|
|
|
|
1653
|
|
|
/** |
|
1654
|
|
|
* Instantiates the navigation template if any |
|
1655
|
|
|
*/ |
|
1656
|
|
|
public function instantiateNavigationTemplate() |
|
1657
|
|
|
{ |
|
1658
|
|
|
if(!$this->_navigationContainer && $this->_navigationTemplate) |
|
1659
|
|
|
{ |
|
1660
|
|
|
$this->_navigationContainer=new TWizardNavigationContainer; |
|
1661
|
|
|
$this->_navigationTemplate->instantiateIn($this->_navigationContainer); |
|
1662
|
|
|
} |
|
1663
|
|
|
} |
|
1664
|
|
|
} |
|
1665
|
|
|
|
|
1666
|
|
|
|
|
1667
|
|
|
/** |
|
1668
|
|
|
* TWizardStepCollection class. |
|
1669
|
|
|
* |
|
1670
|
|
|
* TWizardStepCollection represents the collection of wizard steps owned |
|
1671
|
|
|
* by a {@link TWizard}. |
|
1672
|
|
|
* |
|
1673
|
|
|
* @author Qiang Xue <[email protected]> |
|
1674
|
|
|
* @package System.Web.UI.WebControls |
|
1675
|
|
|
* @since 3.0 |
|
1676
|
|
|
*/ |
|
1677
|
|
|
class TWizardStepCollection extends TList |
|
1678
|
|
|
{ |
|
1679
|
|
|
/** |
|
1680
|
|
|
* @var TWizard |
|
1681
|
|
|
*/ |
|
1682
|
|
|
private $_wizard; |
|
1683
|
|
|
|
|
1684
|
|
|
/** |
|
1685
|
|
|
* Constructor. |
|
1686
|
|
|
* @param TWizard wizard that owns this collection |
|
1687
|
|
|
*/ |
|
1688
|
|
|
public function __construct(TWizard $wizard) |
|
1689
|
|
|
{ |
|
1690
|
|
|
$this->_wizard=$wizard; |
|
1691
|
|
|
} |
|
1692
|
|
|
|
|
1693
|
|
|
/** |
|
1694
|
|
|
* Inserts an item at the specified position. |
|
1695
|
|
|
* This method overrides the parent implementation by checking if |
|
1696
|
|
|
* the item being added is a {@link TWizardStep}. |
|
1697
|
|
|
* @param integer the speicified position. |
|
1698
|
|
|
* @param mixed new item |
|
1699
|
|
|
* @throws TInvalidDataTypeException if the item being added is not TWizardStep. |
|
1700
|
|
|
*/ |
|
1701
|
|
|
public function insertAt($index,$item) |
|
1702
|
|
|
{ |
|
1703
|
|
|
if($item instanceof TWizardStep) |
|
1704
|
|
|
{ |
|
1705
|
|
|
parent::insertAt($index,$item); |
|
1706
|
|
|
$this->_wizard->getMultiView()->getViews()->insertAt($index,$item); |
|
1707
|
|
|
$this->_wizard->addedWizardStep($item); |
|
1708
|
|
|
} |
|
1709
|
|
|
else |
|
1710
|
|
|
throw new TInvalidDataTypeException('wizardstepcollection_wizardstep_required'); |
|
1711
|
|
|
} |
|
1712
|
|
|
|
|
1713
|
|
|
/** |
|
1714
|
|
|
* Removes an item at the specified position. |
|
1715
|
|
|
* @param integer the index of the item to be removed. |
|
1716
|
|
|
* @return mixed the removed item. |
|
1717
|
|
|
*/ |
|
1718
|
|
|
public function removeAt($index) |
|
1719
|
|
|
{ |
|
1720
|
|
|
$step=parent::removeAt($index); |
|
1721
|
|
|
$this->_wizard->getMultiView()->getViews()->remove($step); |
|
1722
|
|
|
$this->_wizard->removedWizardStep($step); |
|
1723
|
|
|
return $step; |
|
1724
|
|
|
} |
|
1725
|
|
|
} |
|
1726
|
|
|
|
|
1727
|
|
|
|
|
1728
|
|
|
/** |
|
1729
|
|
|
* TWizardNavigationContainer class. |
|
1730
|
|
|
* |
|
1731
|
|
|
* TWizardNavigationContainer represents a control containing |
|
1732
|
|
|
* a wizard navigation. The navigation may contain a few buttons, including |
|
1733
|
|
|
* {@link getPreviousButton PreviousButton}, {@link getNextButton NextButton}, |
|
1734
|
|
|
* {@link getCancelButton CancelButton}, {@link getCompleteButton CompleteButton}. |
|
1735
|
|
|
* |
|
1736
|
|
|
* @author Qiang Xue <[email protected]> |
|
1737
|
|
|
* @package System.Web.UI.WebControls |
|
1738
|
|
|
* @since 3.0 |
|
1739
|
|
|
*/ |
|
1740
|
|
|
class TWizardNavigationContainer extends TControl implements INamingContainer |
|
1741
|
|
|
{ |
|
1742
|
|
|
private $_previousButton=null; |
|
1743
|
|
|
private $_nextButton=null; |
|
1744
|
|
|
private $_cancelButton=null; |
|
1745
|
|
|
private $_completeButton=null; |
|
1746
|
|
|
|
|
1747
|
|
|
/** |
|
1748
|
|
|
* @return mixed the previous button |
|
1749
|
|
|
*/ |
|
1750
|
|
|
public function getPreviousButton() |
|
1751
|
|
|
{ |
|
1752
|
|
|
return $this->_previousButton; |
|
1753
|
|
|
} |
|
1754
|
|
|
|
|
1755
|
|
|
/** |
|
1756
|
|
|
* @param mixed the previous button |
|
1757
|
|
|
*/ |
|
1758
|
|
|
public function setPreviousButton($value) |
|
1759
|
|
|
{ |
|
1760
|
|
|
$this->_previousButton=$value; |
|
1761
|
|
|
} |
|
1762
|
|
|
|
|
1763
|
|
|
/** |
|
1764
|
|
|
* @return mixed the next button |
|
1765
|
|
|
*/ |
|
1766
|
|
|
public function getNextButton() |
|
1767
|
|
|
{ |
|
1768
|
|
|
return $this->_nextButton; |
|
1769
|
|
|
} |
|
1770
|
|
|
|
|
1771
|
|
|
/** |
|
1772
|
|
|
* @param mixed the next button |
|
1773
|
|
|
*/ |
|
1774
|
|
|
public function setNextButton($value) |
|
1775
|
|
|
{ |
|
1776
|
|
|
$this->_nextButton=$value; |
|
1777
|
|
|
} |
|
1778
|
|
|
|
|
1779
|
|
|
/** |
|
1780
|
|
|
* @return mixed the cancel button |
|
1781
|
|
|
*/ |
|
1782
|
|
|
public function getCancelButton() |
|
1783
|
|
|
{ |
|
1784
|
|
|
return $this->_cancelButton; |
|
1785
|
|
|
} |
|
1786
|
|
|
|
|
1787
|
|
|
/** |
|
1788
|
|
|
* @param mixed the cancel button |
|
1789
|
|
|
*/ |
|
1790
|
|
|
public function setCancelButton($value) |
|
1791
|
|
|
{ |
|
1792
|
|
|
$this->_cancelButton=$value; |
|
1793
|
|
|
} |
|
1794
|
|
|
|
|
1795
|
|
|
/** |
|
1796
|
|
|
* @return mixed the complete button |
|
1797
|
|
|
*/ |
|
1798
|
|
|
public function getCompleteButton() |
|
1799
|
|
|
{ |
|
1800
|
|
|
return $this->_completeButton; |
|
1801
|
|
|
} |
|
1802
|
|
|
|
|
1803
|
|
|
/** |
|
1804
|
|
|
* @param mixed the complete button |
|
1805
|
|
|
*/ |
|
1806
|
|
|
public function setCompleteButton($value) |
|
1807
|
|
|
{ |
|
1808
|
|
|
$this->_completeButton=$value; |
|
1809
|
|
|
} |
|
1810
|
|
|
} |
|
1811
|
|
|
|
|
1812
|
|
|
|
|
1813
|
|
|
/** |
|
1814
|
|
|
* TWizardNavigationEventParameter class. |
|
1815
|
|
|
* |
|
1816
|
|
|
* TWizardNavigationEventParameter represents the parameter for |
|
1817
|
|
|
* {@link TWizard}'s navigation events. |
|
1818
|
|
|
* |
|
1819
|
|
|
* The index of the currently active step can be obtained from |
|
1820
|
|
|
* {@link getCurrentStepIndex CurrentStepIndex}, while the index |
|
1821
|
|
|
* of the candidate new step is in {@link getNextStepIndex NextStepIndex}. |
|
1822
|
|
|
* By modifying {@link setNextStepIndex NextStepIndex}, the new step |
|
1823
|
|
|
* can be changed to another one. If there is anything wrong with |
|
1824
|
|
|
* the navigation and it is not wanted, set {@link setCancelNavigation CancelNavigation} |
|
1825
|
|
|
* to true. |
|
1826
|
|
|
* |
|
1827
|
|
|
* @author Qiang Xue <[email protected]> |
|
1828
|
|
|
* @package System.Web.UI.WebControls |
|
1829
|
|
|
* @since 3.0 |
|
1830
|
|
|
*/ |
|
1831
|
|
|
class TWizardNavigationEventParameter extends TEventParameter |
|
1832
|
|
|
{ |
|
1833
|
|
|
private $_cancel=false; |
|
1834
|
|
|
private $_currentStep; |
|
1835
|
|
|
private $_nextStep; |
|
1836
|
|
|
|
|
1837
|
|
|
/** |
|
1838
|
|
|
* Constructor. |
|
1839
|
|
|
* @param integer current step index |
|
1840
|
|
|
*/ |
|
1841
|
|
|
public function __construct($currentStep) |
|
1842
|
|
|
{ |
|
1843
|
|
|
$this->_currentStep=$currentStep; |
|
1844
|
|
|
$this->_nextStep=$currentStep; |
|
1845
|
|
|
} |
|
1846
|
|
|
|
|
1847
|
|
|
/** |
|
1848
|
|
|
* @return integer the zero-based index of the currently active step. |
|
1849
|
|
|
*/ |
|
1850
|
|
|
public function getCurrentStepIndex() |
|
1851
|
|
|
{ |
|
1852
|
|
|
return $this->_currentStep; |
|
1853
|
|
|
} |
|
1854
|
|
|
|
|
1855
|
|
|
/** |
|
1856
|
|
|
* @return integer the zero-based index of the next step. Default to {@link getCurrentStepIndex CurrentStepIndex}. |
|
1857
|
|
|
*/ |
|
1858
|
|
|
public function getNextStepIndex() |
|
1859
|
|
|
{ |
|
1860
|
|
|
return $this->_nextStep; |
|
1861
|
|
|
} |
|
1862
|
|
|
|
|
1863
|
|
|
/** |
|
1864
|
|
|
* @param integer the zero-based index of the next step. |
|
1865
|
|
|
*/ |
|
1866
|
|
|
public function setNextStepIndex($index) |
|
1867
|
|
|
{ |
|
1868
|
|
|
$this->_nextStep=TPropertyValue::ensureInteger($index); |
|
1869
|
|
|
} |
|
1870
|
|
|
|
|
1871
|
|
|
/** |
|
1872
|
|
|
* @return boolean whether navigation to the next step should be canceled. Default to false. |
|
1873
|
|
|
*/ |
|
1874
|
|
|
public function getCancelNavigation() |
|
1875
|
|
|
{ |
|
1876
|
|
|
return $this->_cancel; |
|
1877
|
|
|
} |
|
1878
|
|
|
|
|
1879
|
|
|
/** |
|
1880
|
|
|
* @param boolean whether navigation to the next step should be canceled. |
|
1881
|
|
|
*/ |
|
1882
|
|
|
public function setCancelNavigation($value) |
|
1883
|
|
|
{ |
|
1884
|
|
|
$this->_cancel=TPropertyValue::ensureBoolean($value); |
|
1885
|
|
|
} |
|
1886
|
|
|
} |
|
1887
|
|
|
|
|
1888
|
|
|
/** |
|
1889
|
|
|
* TWizardSideBarTemplate class. |
|
1890
|
|
|
* TWizardSideBarTemplate is the default template for wizard sidebar. |
|
1891
|
|
|
* @author Qiang Xue <[email protected]> |
|
1892
|
|
|
* @package System.Web.UI.WebControls |
|
1893
|
|
|
* @since 3.0 |
|
1894
|
|
|
*/ |
|
1895
|
|
|
class TWizardSideBarTemplate extends TComponent implements ITemplate |
|
1896
|
|
|
{ |
|
1897
|
|
|
/** |
|
1898
|
|
|
* Instantiates the template. |
|
1899
|
|
|
* It creates a {@link TDataList} control. |
|
1900
|
|
|
* @param TControl parent to hold the content within the template |
|
1901
|
|
|
*/ |
|
1902
|
|
|
public function instantiateIn($parent) |
|
1903
|
|
|
{ |
|
1904
|
|
|
$dataList=new TDataList; |
|
1905
|
|
|
$dataList->setID(TWizard::ID_SIDEBAR_LIST); |
|
1906
|
|
|
$dataList->getSelectedItemStyle()->getFont()->setBold(true); |
|
1907
|
|
|
$dataList->setItemTemplate(new TWizardSideBarListItemTemplate); |
|
1908
|
|
|
$parent->getControls()->add($dataList); |
|
1909
|
|
|
} |
|
1910
|
|
|
} |
|
1911
|
|
|
|
|
1912
|
|
|
/** |
|
1913
|
|
|
* TWizardSideBarListItemTemplate class. |
|
1914
|
|
|
* TWizardSideBarListItemTemplate is the default template for each item in the sidebar datalist. |
|
1915
|
|
|
* @author Qiang Xue <[email protected]> |
|
1916
|
|
|
* @package System.Web.UI.WebControls |
|
1917
|
|
|
* @since 3.0 |
|
1918
|
|
|
*/ |
|
1919
|
|
|
class TWizardSideBarListItemTemplate extends TComponent implements ITemplate |
|
1920
|
|
|
{ |
|
1921
|
|
|
/** |
|
1922
|
|
|
* Instantiates the template. |
|
1923
|
|
|
* It creates a {@link TLinkButton}. |
|
1924
|
|
|
* @param TControl parent to hold the content within the template |
|
1925
|
|
|
*/ |
|
1926
|
|
|
public function instantiateIn($parent) |
|
1927
|
|
|
{ |
|
1928
|
|
|
$button=new TLinkButton; |
|
1929
|
|
|
$button->setID(TWizard::ID_SIDEBAR_BUTTON); |
|
1930
|
|
|
$parent->getControls()->add($button); |
|
1931
|
|
|
} |
|
1932
|
|
|
} |
|
1933
|
|
|
|
|
1934
|
|
|
/** |
|
1935
|
|
|
* TWizardNavigationTemplate class. |
|
1936
|
|
|
* TWizardNavigationTemplate is the base class for various navigation templates. |
|
1937
|
|
|
* @author Qiang Xue <[email protected]> |
|
1938
|
|
|
* @package System.Web.UI.WebControls |
|
1939
|
|
|
* @since 3.0 |
|
1940
|
|
|
*/ |
|
1941
|
|
|
class TWizardNavigationTemplate extends TComponent implements ITemplate |
|
1942
|
|
|
{ |
|
1943
|
|
|
private $_wizard; |
|
1944
|
|
|
|
|
1945
|
|
|
/** |
|
1946
|
|
|
* Constructor. |
|
1947
|
|
|
* @param TWizard the wizard owning this template |
|
1948
|
|
|
*/ |
|
1949
|
|
|
public function __construct($wizard) |
|
1950
|
|
|
{ |
|
1951
|
|
|
$this->_wizard=$wizard; |
|
1952
|
|
|
} |
|
1953
|
|
|
|
|
1954
|
|
|
/** |
|
1955
|
|
|
* @return TWizard the wizard owning this template |
|
1956
|
|
|
*/ |
|
1957
|
|
|
public function getWizard() |
|
1958
|
|
|
{ |
|
1959
|
|
|
return $this->_wizard; |
|
1960
|
|
|
} |
|
1961
|
|
|
|
|
1962
|
|
|
/** |
|
1963
|
|
|
* Instantiates the template. |
|
1964
|
|
|
* Derived classes should override this method. |
|
1965
|
|
|
* @param TControl parent to hold the content within the template |
|
1966
|
|
|
*/ |
|
1967
|
|
|
public function instantiateIn($parent) |
|
1968
|
|
|
{ |
|
1969
|
|
|
} |
|
1970
|
|
|
|
|
1971
|
|
|
/** |
|
1972
|
|
|
* Creates a navigation button. |
|
1973
|
|
|
* It creates a {@link TButton}, {@link TLinkButton}, or {@link TImageButton}, |
|
1974
|
|
|
* depending on the given parameters. |
|
1975
|
|
|
* @param TWizardNavigationButtonStyle button style |
|
1976
|
|
|
* @param boolean whether the button should cause validation |
|
1977
|
|
|
* @param string command name for the button's OnCommand event |
|
1978
|
|
|
* @throws TInvalidDataValueException if the button type is not recognized |
|
1979
|
|
|
*/ |
|
1980
|
|
|
protected function createNavigationButton($buttonStyle,$causesValidation,$commandName) |
|
1981
|
|
|
{ |
|
1982
|
|
|
switch($buttonStyle->getButtonType()) |
|
1983
|
|
|
{ |
|
1984
|
|
|
case TWizardNavigationButtonType::Button: |
|
1985
|
|
|
$button=new TButton; |
|
1986
|
|
|
break; |
|
1987
|
|
|
case TWizardNavigationButtonType::Link: |
|
1988
|
|
|
$button=new TLinkButton; |
|
1989
|
|
|
break; |
|
1990
|
|
|
case TWizardNavigationButtonType::Image: |
|
1991
|
|
|
$button=new TImageButton; |
|
1992
|
|
|
$button->setImageUrl($buttonStyle->getImageUrl()); |
|
1993
|
|
|
break; |
|
1994
|
|
|
default: |
|
1995
|
|
|
throw new TInvalidDataValueException('wizard_buttontype_unknown',$buttonStyle->getButtonType()); |
|
1996
|
|
|
} |
|
1997
|
|
|
$button->setText($buttonStyle->getButtonText()); |
|
1998
|
|
|
$button->setCausesValidation($causesValidation); |
|
1999
|
|
|
$button->setCommandName($commandName); |
|
2000
|
|
|
return $button; |
|
2001
|
|
|
} |
|
2002
|
|
|
} |
|
2003
|
|
|
|
|
2004
|
|
|
/** |
|
2005
|
|
|
* TWizardStartNavigationTemplate class. |
|
2006
|
|
|
* TWizardStartNavigationTemplate is the template used as default wizard start navigation panel. |
|
2007
|
|
|
* It consists of two buttons, Next and Cancel. |
|
2008
|
|
|
* @author Qiang Xue <[email protected]> |
|
2009
|
|
|
* @package System.Web.UI.WebControls |
|
2010
|
|
|
* @since 3.0 |
|
2011
|
|
|
*/ |
|
2012
|
|
|
class TWizardStartNavigationTemplate extends TWizardNavigationTemplate |
|
2013
|
|
|
{ |
|
2014
|
|
|
/** |
|
2015
|
|
|
* Instantiates the template. |
|
2016
|
|
|
* @param TControl parent to hold the content within the template |
|
2017
|
|
|
*/ |
|
2018
|
|
|
public function instantiateIn($parent) |
|
2019
|
|
|
{ |
|
2020
|
|
|
$nextButton=$this->createNavigationButton($this->getWizard()->getStartNextButtonStyle(),true,TWizard::CMD_NEXT); |
|
2021
|
|
|
$cancelButton=$this->createNavigationButton($this->getWizard()->getCancelButtonStyle(),false,TWizard::CMD_CANCEL); |
|
2022
|
|
|
|
|
2023
|
|
|
$controls=$parent->getControls(); |
|
2024
|
|
|
$controls->add($nextButton); |
|
2025
|
|
|
$controls->add("\n"); |
|
2026
|
|
|
$controls->add($cancelButton); |
|
2027
|
|
|
|
|
2028
|
|
|
$parent->setNextButton($nextButton); |
|
2029
|
|
|
$parent->setCancelButton($cancelButton); |
|
2030
|
|
|
} |
|
2031
|
|
|
} |
|
2032
|
|
|
|
|
2033
|
|
|
/** |
|
2034
|
|
|
* TWizardFinishNavigationTemplate class. |
|
2035
|
|
|
* TWizardFinishNavigationTemplate is the template used as default wizard finish navigation panel. |
|
2036
|
|
|
* It consists of three buttons, Previous, Complete and Cancel. |
|
2037
|
|
|
* @author Qiang Xue <[email protected]> |
|
2038
|
|
|
* @package System.Web.UI.WebControls |
|
2039
|
|
|
* @since 3.0 |
|
2040
|
|
|
*/ |
|
2041
|
|
|
class TWizardFinishNavigationTemplate extends TWizardNavigationTemplate |
|
2042
|
|
|
{ |
|
2043
|
|
|
/** |
|
2044
|
|
|
* Instantiates the template. |
|
2045
|
|
|
* @param TControl parent to hold the content within the template |
|
2046
|
|
|
*/ |
|
2047
|
|
|
public function instantiateIn($parent) |
|
2048
|
|
|
{ |
|
2049
|
|
|
$previousButton=$this->createNavigationButton($this->getWizard()->getFinishPreviousButtonStyle(),false,TWizard::CMD_PREVIOUS); |
|
2050
|
|
|
$completeButton=$this->createNavigationButton($this->getWizard()->getFinishCompleteButtonStyle(),true,TWizard::CMD_COMPLETE); |
|
2051
|
|
|
$cancelButton=$this->createNavigationButton($this->getWizard()->getCancelButtonStyle(),false,TWizard::CMD_CANCEL); |
|
2052
|
|
|
|
|
2053
|
|
|
$controls=$parent->getControls(); |
|
2054
|
|
|
$controls->add($previousButton); |
|
2055
|
|
|
$controls->add("\n"); |
|
2056
|
|
|
$controls->add($completeButton); |
|
2057
|
|
|
$controls->add("\n"); |
|
2058
|
|
|
$controls->add($cancelButton); |
|
2059
|
|
|
|
|
2060
|
|
|
$parent->setPreviousButton($previousButton); |
|
2061
|
|
|
$parent->setCompleteButton($completeButton); |
|
2062
|
|
|
$parent->setCancelButton($cancelButton); |
|
2063
|
|
|
} |
|
2064
|
|
|
} |
|
2065
|
|
|
|
|
2066
|
|
|
/** |
|
2067
|
|
|
* TWizardStepNavigationTemplate class. |
|
2068
|
|
|
* TWizardStepNavigationTemplate is the template used as default wizard step navigation panel. |
|
2069
|
|
|
* It consists of three buttons, Previous, Next and Cancel. |
|
2070
|
|
|
* @author Qiang Xue <[email protected]> |
|
2071
|
|
|
* @package System.Web.UI.WebControls |
|
2072
|
|
|
* @since 3.0 |
|
2073
|
|
|
*/ |
|
2074
|
|
|
class TWizardStepNavigationTemplate extends TWizardNavigationTemplate |
|
2075
|
|
|
{ |
|
2076
|
|
|
/** |
|
2077
|
|
|
* Instantiates the template. |
|
2078
|
|
|
* @param TControl parent to hold the content within the template |
|
2079
|
|
|
*/ |
|
2080
|
|
|
public function instantiateIn($parent) |
|
2081
|
|
|
{ |
|
2082
|
|
|
$previousButton=$this->createNavigationButton($this->getWizard()->getStepPreviousButtonStyle(),false,TWizard::CMD_PREVIOUS); |
|
2083
|
|
|
$nextButton=$this->createNavigationButton($this->getWizard()->getStepNextButtonStyle(),true,TWizard::CMD_NEXT); |
|
2084
|
|
|
$cancelButton=$this->createNavigationButton($this->getWizard()->getCancelButtonStyle(),false,TWizard::CMD_CANCEL); |
|
2085
|
|
|
|
|
2086
|
|
|
$controls=$parent->getControls(); |
|
2087
|
|
|
$controls->add($previousButton); |
|
2088
|
|
|
$controls->add("\n"); |
|
2089
|
|
|
$controls->add($nextButton); |
|
2090
|
|
|
$controls->add("\n"); |
|
2091
|
|
|
$controls->add($cancelButton); |
|
2092
|
|
|
|
|
2093
|
|
|
$parent->setPreviousButton($previousButton); |
|
2094
|
|
|
$parent->setNextButton($nextButton); |
|
2095
|
|
|
$parent->setCancelButton($cancelButton); |
|
2096
|
|
|
} |
|
2097
|
|
|
} |
|
2098
|
|
|
|
|
2099
|
|
|
|
|
2100
|
|
|
/** |
|
2101
|
|
|
* TWizardNavigationButtonType class. |
|
2102
|
|
|
* TWizardNavigationButtonType defines the enumerable type for the possible types of buttons |
|
2103
|
|
|
* that can be used in the navigation part of a {@link TWizard}. |
|
2104
|
|
|
* |
|
2105
|
|
|
* The following enumerable values are defined: |
|
2106
|
|
|
* - Button: a regular click button |
|
2107
|
|
|
* - Image: an image button |
|
2108
|
|
|
* - Link: a hyperlink button |
|
2109
|
|
|
* |
|
2110
|
|
|
* @author Qiang Xue <[email protected]> |
|
2111
|
|
|
* @package System.Web.UI.WebControls |
|
2112
|
|
|
* @since 3.0.4 |
|
2113
|
|
|
*/ |
|
2114
|
|
|
class TWizardNavigationButtonType extends TEnumerable |
|
2115
|
|
|
{ |
|
2116
|
|
|
const Button='Button'; |
|
2117
|
|
|
const Image='Image'; |
|
2118
|
|
|
const Link='Link'; |
|
2119
|
|
|
} |
|
2120
|
|
|
|
|
2121
|
|
|
|
|
2122
|
|
|
/** |
|
2123
|
|
|
* TWizardStepType class. |
|
2124
|
|
|
* TWizardStepType defines the enumerable type for the possible types of {@link TWizard wizard} steps. |
|
2125
|
|
|
* |
|
2126
|
|
|
* The following enumerable values are defined: |
|
2127
|
|
|
* - Auto: the type is automatically determined based on the location of the wizard step in the whole step collection. |
|
2128
|
|
|
* - Complete: the step is the last summary step. |
|
2129
|
|
|
* - Start: the step is the first step |
|
2130
|
|
|
* - Step: the step is between the begin and the end steps. |
|
2131
|
|
|
* - Finish: the last step before the Complete step. |
|
2132
|
|
|
* |
|
2133
|
|
|
* @author Qiang Xue <[email protected]> |
|
2134
|
|
|
* @package System.Web.UI.WebControls |
|
2135
|
|
|
* @since 3.0.4 |
|
2136
|
|
|
*/ |
|
2137
|
|
|
class TWizardStepType extends TEnumerable |
|
2138
|
|
|
{ |
|
2139
|
|
|
const Auto='Auto'; |
|
2140
|
|
|
const Complete='Complete'; |
|
2141
|
|
|
const Start='Start'; |
|
2142
|
|
|
const Step='Step'; |
|
2143
|
|
|
const Finish='Finish'; |
|
2144
|
|
|
} |
|
2145
|
|
|
|
|
2146
|
|
|
|
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVarassignment in line 1 and the$higherassignment in line 2 are dead. The first because$myVaris never used and the second because$higheris always overwritten for every possible time line.