|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* TJuiControlAdapter class file. |
|
4
|
|
|
* |
|
5
|
|
|
* @author Fabio Bas <[email protected]> |
|
6
|
|
|
* @link https://github.com/pradosoft/prado |
|
7
|
|
|
* @copyright Copyright © 2013-2015 PradoSoft |
|
8
|
|
|
* @license https://github.com/pradosoft/prado/blob/master/COPYRIGHT |
|
9
|
|
|
* @package Prado\Web\UI\JuiControls |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
namespace Prado\Web\UI\JuiControls; |
|
13
|
|
|
|
|
14
|
|
|
use Prado\TPropertyValue; |
|
15
|
|
|
use Prado\Web\UI\ActiveControls\TCallbackPageStateTracker; |
|
16
|
|
|
|
|
17
|
|
|
/** |
|
18
|
|
|
* TJuiCallbackPageStateTracker class. |
|
19
|
|
|
* |
|
20
|
|
|
* Tracking changes to the page state during callback, including {@link TJuiControlOptions}. |
|
21
|
|
|
* |
|
22
|
|
|
* @author LANDWEHR Computer und Software GmbH |
|
23
|
|
|
* @package Prado\Web\UI\JuiControls |
|
24
|
|
|
* @since 3.3 |
|
25
|
|
|
*/ |
|
26
|
|
|
class TJuiCallbackPageStateTracker extends TCallbackPageStateTracker { |
|
27
|
|
|
|
|
28
|
|
|
/** |
|
29
|
|
|
* Add the {@link TJuiControlOptions} to the states to track. |
|
30
|
|
|
*/ |
|
31
|
|
|
protected function addStatesToTrack() |
|
32
|
|
|
{ |
|
33
|
|
|
parent::addStatesToTrack(); |
|
|
|
|
|
|
34
|
|
|
$states = $this->getStatesToTrack(); |
|
35
|
|
|
$states['JuiOptions'] = array('TMapCollectionDiff', array($this, 'updateJuiOptions')); |
|
36
|
|
|
} |
|
37
|
|
|
|
|
38
|
|
|
/** |
|
39
|
|
|
* Updates the options of the jQueryUI widget. |
|
40
|
|
|
* @param array list of widget options to change. |
|
41
|
|
|
*/ |
|
42
|
|
|
protected function updateJuiOptions($options) |
|
43
|
|
|
{ |
|
44
|
|
|
foreach ($options as $key => $value) $options[$key] = $key . ': ' . (is_string($value) ? "'{$value}'" : TPropertyValue::ensureString($value)); |
|
45
|
|
|
$code = "jQuery('#{$this->_control->getWidgetID()}').{$this->_control->getWidget()}('option', { " . implode(', ', $options) . " });"; |
|
46
|
|
|
$this->_control->getPage()->getClientScript()->registerEndScript(sprintf('%08X', crc32($code)), $code); |
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
|
|
} |
PHP Analyzer performs a side-effects analysis of your code. A side-effect is basically anything that might be visible after the scope of the method is left.
Let’s take a look at an example:
If we look at the
getEmail()method, we can see that it has no side-effect. Whether you call this method or not, no future calls to other methods are affected by this. As such code as the following is useless:On the hand, if we look at the
setEmail(), this method _has_ side-effects. In the following case, we could not remove the method call: