@@ -43,16 +43,16 @@ discard block |
||
43 | 43 | */ |
44 | 44 | public function setInterval($value) |
45 | 45 | { |
46 | - $interval = TPropertyValue::ensureFloat($value); |
|
46 | + $interval=TPropertyValue::ensureFloat($value); |
|
47 | 47 | if($interval <= 0) |
48 | 48 | throw new TConfigurationException('callback_interval_be_positive', $this->getID()); |
49 | 49 | |
50 | - if($this->getInterval() === $value) |
|
50 | + if($this->getInterval()===$value) |
|
51 | 51 | return; |
52 | 52 | |
53 | 53 | $this->setViewState('Interval', $interval, 1); |
54 | - if ($this->getActiveControl()->canUpdateClientSide()){ |
|
55 | - $client = $this->getPage()->getCallbackClient(); |
|
54 | + if($this->getActiveControl()->canUpdateClientSide()) { |
|
55 | + $client=$this->getPage()->getCallbackClient(); |
|
56 | 56 | $client->callClientFunction('Prado.WebUI.TTimeTriggeredCallback.setTimerInterval', array($this, $interval)); |
57 | 57 | } |
58 | 58 | } |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | */ |
63 | 63 | public function startTimer() |
64 | 64 | { |
65 | - $client = $this->getPage()->getCallbackClient(); |
|
65 | + $client=$this->getPage()->getCallbackClient(); |
|
66 | 66 | $client->callClientFunction('Prado.WebUI.TTimeTriggeredCallback.start', array($this)); |
67 | 67 | } |
68 | 68 | |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | */ |
72 | 72 | public function stopTimer() |
73 | 73 | { |
74 | - $client = $this->getPage()->getCallbackClient(); |
|
74 | + $client=$this->getPage()->getCallbackClient(); |
|
75 | 75 | $client->callClientFunction('Prado.WebUI.TTimeTriggeredCallback.stop', array($this)); |
76 | 76 | } |
77 | 77 | |
@@ -97,9 +97,9 @@ discard block |
||
97 | 97 | */ |
98 | 98 | protected function getTriggerOptions() |
99 | 99 | { |
100 | - $options['ID'] = $this->getClientID(); |
|
101 | - $options['EventTarget']= $this->getUniqueID(); |
|
102 | - $options['Interval'] = $this->getInterval(); |
|
100 | + $options['ID']=$this->getClientID(); |
|
101 | + $options['EventTarget']=$this->getUniqueID(); |
|
102 | + $options['Interval']=$this->getInterval(); |
|
103 | 103 | return $options; |
104 | 104 | } |
105 | 105 | |
@@ -112,10 +112,10 @@ discard block |
||
112 | 112 | parent::render($writer); |
113 | 113 | $this->getActiveControl()->registerCallbackClientScript( |
114 | 114 | $this->getClientClassName(), $this->getTriggerOptions()); |
115 | - if($this->getStartTimerOnLoad()){ |
|
116 | - $id = $this->getClientID(); |
|
117 | - $code = "Prado.WebUI.TTimeTriggeredCallback.start('{$id}');"; |
|
118 | - $cs = $this->getPage()->getClientScript(); |
|
115 | + if($this->getStartTimerOnLoad()) { |
|
116 | + $id=$this->getClientID(); |
|
117 | + $code="Prado.WebUI.TTimeTriggeredCallback.start('{$id}');"; |
|
118 | + $cs=$this->getPage()->getClientScript(); |
|
119 | 119 | $cs->registerEndScript("{$id}:start", $code); |
120 | 120 | } |
121 | 121 | } |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | */ |
95 | 95 | public function setText($value) |
96 | 96 | { |
97 | - if(parent::getText() === $value) |
|
97 | + if(parent::getText()===$value) |
|
98 | 98 | return; |
99 | 99 | |
100 | 100 | parent::setText($value); |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | protected function addAttributesToRender($writer) |
118 | 118 | { |
119 | 119 | parent::addAttributesToRender($writer); |
120 | - $writer->addAttribute('id',$this->getClientID()); |
|
120 | + $writer->addAttribute('id', $this->getClientID()); |
|
121 | 121 | $this->getActiveControl()->registerCallbackClientScript( |
122 | 122 | $this->getClientClassName(), $this->getPostBackOptions()); |
123 | 123 | } |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | */ |
49 | 49 | public function setAlternateText($value) |
50 | 50 | { |
51 | - if(parent::getAlternateText() === $value) |
|
51 | + if(parent::getAlternateText()===$value) |
|
52 | 52 | return; |
53 | 53 | |
54 | 54 | parent::setAlternateText($value); |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | */ |
66 | 66 | public function setImageAlign($value) |
67 | 67 | { |
68 | - if(parent::getImageAlign() === $value) |
|
68 | + if(parent::getImageAlign()===$value) |
|
69 | 69 | return; |
70 | 70 | |
71 | 71 | parent::setImageAlign($value); |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | */ |
79 | 79 | public function setImageUrl($value) |
80 | 80 | { |
81 | - if(parent::getImageUrl() === $value) |
|
81 | + if(parent::getImageUrl()===$value) |
|
82 | 82 | return; |
83 | 83 | |
84 | 84 | parent::setImageUrl($value); |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | */ |
92 | 92 | public function setDescriptionUrl($value) |
93 | 93 | { |
94 | - if(parent::getDescriptionUrl() === $value) |
|
94 | + if(parent::getDescriptionUrl()===$value) |
|
95 | 95 | return; |
96 | 96 | |
97 | 97 | parent::setDescriptionUrl($value); |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | */ |
96 | 96 | public function setText($value) |
97 | 97 | { |
98 | - if(parent::getText() === $value) |
|
98 | + if(parent::getText()===$value) |
|
99 | 99 | return; |
100 | 100 | |
101 | 101 | parent::setText($value); |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | protected function addAttributesToRender($writer) |
119 | 119 | { |
120 | 120 | parent::addAttributesToRender($writer); |
121 | - $writer->addAttribute('id',$this->getClientID()); |
|
121 | + $writer->addAttribute('id', $this->getClientID()); |
|
122 | 122 | |
123 | 123 | if($this->getEnabled(true)) |
124 | 124 | { |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | */ |
135 | 135 | public function setEnabled($value) |
136 | 136 | { |
137 | - if(parent::getEnabled() === $value) |
|
137 | + if(parent::getEnabled()===$value) |
|
138 | 138 | return; |
139 | 139 | |
140 | 140 | parent::setEnabled($value); |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | { |
143 | 143 | if($this->getEnabled(true)) |
144 | 144 | { |
145 | - $nop = "javascript:;//".$this->getClientID(); |
|
145 | + $nop="javascript:;//".$this->getClientID(); |
|
146 | 146 | $this->getPage()->getCallbackClient()->setAttribute($this, 'href', $nop); |
147 | 147 | |
148 | 148 | $this->getActiveControl()->registerCallbackClientScript( |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | */ |
89 | 89 | public function setText($value) |
90 | 90 | { |
91 | - if(parent::getText() === $value) |
|
91 | + if(parent::getText()===$value) |
|
92 | 92 | return; |
93 | 93 | |
94 | 94 | parent::setText($value); |
@@ -105,8 +105,8 @@ discard block |
||
105 | 105 | */ |
106 | 106 | public function setChecked($value) |
107 | 107 | { |
108 | - $value = TPropertyValue::ensureBoolean($value); |
|
109 | - if(parent::getChecked() === $value) |
|
108 | + $value=TPropertyValue::ensureBoolean($value); |
|
109 | + if(parent::getChecked()===$value) |
|
110 | 110 | return; |
111 | 111 | |
112 | 112 | parent::setChecked($value); |
@@ -132,10 +132,10 @@ discard block |
||
132 | 132 | * @param string checkbox id |
133 | 133 | * @param string onclick js |
134 | 134 | */ |
135 | - protected function renderInputTag($writer,$clientID,$onclick) |
|
135 | + protected function renderInputTag($writer, $clientID, $onclick) |
|
136 | 136 | { |
137 | - parent::renderInputTag($writer,$clientID,$onclick); |
|
138 | - if ($this->getAutoPostBack()) |
|
137 | + parent::renderInputTag($writer, $clientID, $onclick); |
|
138 | + if($this->getAutoPostBack()) |
|
139 | 139 | $this->getActiveControl()->registerCallbackClientScript( |
140 | 140 | $this->getClientClassName(), $this->getPostBackOptions()); |
141 | 141 | } |
@@ -154,8 +154,8 @@ discard block |
||
154 | 154 | */ |
155 | 155 | public function getLabelAttributes() |
156 | 156 | { |
157 | - $attributes = parent::getLabelAttributes(); |
|
158 | - $attributes['id'] = $this->getDefaultLabelID(); |
|
157 | + $attributes=parent::getLabelAttributes(); |
|
158 | + $attributes['id']=$this->getDefaultLabelID(); |
|
159 | 159 | return $attributes; |
160 | 160 | } |
161 | 161 | |
@@ -165,7 +165,7 @@ discard block |
||
165 | 165 | * @param string checkbox id |
166 | 166 | * @param string label text |
167 | 167 | */ |
168 | - protected function renderLabel($writer,$clientID,$text) |
|
168 | + protected function renderLabel($writer, $clientID, $text) |
|
169 | 169 | { |
170 | 170 | $writer->addAttribute('id', $this->getDefaultLabelID()); |
171 | 171 | parent::renderLabel($writer, $clientID, $text); |
@@ -176,7 +176,7 @@ discard block |
||
176 | 176 | */ |
177 | 177 | protected function getDefaultLabelID() |
178 | 178 | { |
179 | - if($attributes=$this->getViewState('LabelAttributes',null)) |
|
179 | + if($attributes=$this->getViewState('LabelAttributes', null)) |
|
180 | 180 | return TCheckBox::getLabelAttributes()->itemAt('id'); |
181 | 181 | else |
182 | 182 | return $this->getClientID().'_label'; |
@@ -1,1 +1,1 @@ |
||
1 | -<?php /** * TEACache class file * * @author Dario rigolin <[email protected]> * @link https://github.com/pradosoft/prado * @copyright Copyright © 2005-2016 The PRADO Group * @license https://github.com/pradosoft/prado/blob/master/COPYRIGHT * @package System.Caching */ /** * TEACache class * * TEACache implements a cache application module based on {@link http://eaccelerator.net/ eAccelerator}. * * By definition, cache does not ensure the existence of a value * even if it never expires. Cache is not meant to be an persistent storage. * * To use this module, the eAccelerator PHP extension must be loaded and enabled * * Please note that as of v0.9.6, eAccelerator no longer supports data caching. * This means if you still want to use this component, your eAccelerator should be of 0.9.5.x or lower version. * * Some usage examples of TEACache are as follows, * <code> * $cache=new TEACache; // TEACache may also be loaded as a Prado application module * $cache->init(null); * $cache->add('object',$object); * $object2=$cache->get('object'); * </code> * * If loaded, TEACache will register itself with {@link TApplication} as the * cache module. It can be accessed via {@link TApplication::getCache()}. * * TEACache may be configured in application configuration file as follows * <code> * <module id="cache" class="System.Caching.TEACache" /> * </code> * * @author Dario Rigolin <[email protected]> * @package System.Caching * @since 3.2.2 */ class TEACache extends TCache { /** * Initializes this module. * This method is required by the IModule interface. * @param TXmlElement configuration for this module, can be null * @throws TConfigurationException if eaccelerator extension is not installed or not started, check your php.ini */ public function init($config) { if(!function_exists('eaccelerator_get')) throw new TConfigurationException('eacceleratorcache_extension_required'); parent::init($config); } /** * Retrieves a value from cache with a specified key. * This is the implementation of the method declared in the parent class. * @param string a unique key identifying the cached value * @return string the value stored in cache, false if the value is not in the cache or expired. */ protected function getValue($key) { $value = eaccelerator_get($key); return ($value === null) ? false : $value; } /** * Stores a value identified by a key in cache. * This is the implementation of the method declared in the parent class. * * @param string the key identifying the value to be cached * @param string the value to be cached * @param integer the number of seconds in which the cached value will expire. 0 means never expire. * @return boolean true if the value is successfully stored into cache, false otherwise */ protected function setValue($key,$value,$expire) { return eaccelerator_put($key,$value,$expire); } /** * Stores a value identified by a key into cache if the cache does not contain this key. * This is the implementation of the method declared in the parent class. * * @param string the key identifying the value to be cached * @param string the value to be cached * @param integer the number of seconds in which the cached value will expire. 0 means never expire. * @return boolean true if the value is successfully stored into cache, false otherwise */ protected function addValue($key,$value,$expire) { return (null === eaccelerator_get($key)) ? $this->setValue($key,$value,$expire) : false; } /** * Deletes a value with the specified key from cache * This is the implementation of the method declared in the parent class. * @param string the key of the value to be deleted * @return boolean if no error happens during deletion */ protected function deleteValue($key) { return eaccelerator_rm($key); } /** * Deletes all values from cache. * Be careful of performing this operation if the cache is shared by multiple applications. */ public function flush() { // first, remove expired content from cache eaccelerator_gc(); // now, remove leftover cache-keys $keys = eaccelerator_list_keys(); foreach($keys as $key) $this->deleteValue(substr($key['name'], 1)); return true; } } |
|
2 | 1 | \ No newline at end of file |
2 | +<?php /** * TEACache class file * * @author Dario rigolin <[email protected]> * @link https://github.com/pradosoft/prado * @copyright Copyright © 2005-2016 The PRADO Group * @license https://github.com/pradosoft/prado/blob/master/COPYRIGHT * @package System.Caching */ /** * TEACache class * * TEACache implements a cache application module based on {@link http://eaccelerator.net/ eAccelerator}. * * By definition, cache does not ensure the existence of a value * even if it never expires. Cache is not meant to be an persistent storage. * * To use this module, the eAccelerator PHP extension must be loaded and enabled * * Please note that as of v0.9.6, eAccelerator no longer supports data caching. * This means if you still want to use this component, your eAccelerator should be of 0.9.5.x or lower version. * * Some usage examples of TEACache are as follows, * <code> * $cache=new TEACache; // TEACache may also be loaded as a Prado application module * $cache->init(null); * $cache->add('object',$object); * $object2=$cache->get('object'); * </code> * * If loaded, TEACache will register itself with {@link TApplication} as the * cache module. It can be accessed via {@link TApplication::getCache()}. * * TEACache may be configured in application configuration file as follows * <code> * <module id="cache" class="System.Caching.TEACache" /> * </code> * * @author Dario Rigolin <[email protected]> * @package System.Caching * @since 3.2.2 */ class TEACache extends TCache { /** * Initializes this module. * This method is required by the IModule interface. * @param TXmlElement configuration for this module, can be null * @throws TConfigurationException if eaccelerator extension is not installed or not started, check your php.ini */ public function init($config) { if(!function_exists('eaccelerator_get')) throw new TConfigurationException('eacceleratorcache_extension_required'); parent::init($config); } /** * Retrieves a value from cache with a specified key. * This is the implementation of the method declared in the parent class. * @param string a unique key identifying the cached value * @return string the value stored in cache, false if the value is not in the cache or expired. */ protected function getValue($key) { $value=eaccelerator_get($key); return ($value===null) ? false : $value; } /** * Stores a value identified by a key in cache. * This is the implementation of the method declared in the parent class. * * @param string the key identifying the value to be cached * @param string the value to be cached * @param integer the number of seconds in which the cached value will expire. 0 means never expire. * @return boolean true if the value is successfully stored into cache, false otherwise */ protected function setValue($key, $value, $expire) { return eaccelerator_put($key, $value, $expire); } /** * Stores a value identified by a key into cache if the cache does not contain this key. * This is the implementation of the method declared in the parent class. * * @param string the key identifying the value to be cached * @param string the value to be cached * @param integer the number of seconds in which the cached value will expire. 0 means never expire. * @return boolean true if the value is successfully stored into cache, false otherwise */ protected function addValue($key, $value, $expire) { return (null===eaccelerator_get($key)) ? $this->setValue($key, $value, $expire) : false; } /** * Deletes a value with the specified key from cache * This is the implementation of the method declared in the parent class. * @param string the key of the value to be deleted * @return boolean if no error happens during deletion */ protected function deleteValue($key) { return eaccelerator_rm($key); } /** * Deletes all values from cache. * Be careful of performing this operation if the cache is shared by multiple applications. */ public function flush() { // first, remove expired content from cache eaccelerator_gc(); // now, remove leftover cache-keys $keys=eaccelerator_list_keys(); foreach($keys as $key) $this->deleteValue(substr($key['name'], 1)); return true; } } |
|
3 | 3 | \ No newline at end of file |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | */ |
89 | 89 | public function setText($value) |
90 | 90 | { |
91 | - if(parent::getText() === $value) |
|
91 | + if(parent::getText()===$value) |
|
92 | 92 | return; |
93 | 93 | |
94 | 94 | parent::setText($value); |
@@ -105,8 +105,8 @@ discard block |
||
105 | 105 | */ |
106 | 106 | public function setChecked($value) |
107 | 107 | { |
108 | - $value = TPropertyValue::ensureBoolean($value); |
|
109 | - if(parent::getChecked() === $value) |
|
108 | + $value=TPropertyValue::ensureBoolean($value); |
|
109 | + if(parent::getChecked()===$value) |
|
110 | 110 | return; |
111 | 111 | |
112 | 112 | parent::setChecked($value); |
@@ -132,10 +132,10 @@ discard block |
||
132 | 132 | * @param string checkbox id |
133 | 133 | * @param string onclick js |
134 | 134 | */ |
135 | - protected function renderInputTag($writer,$clientID,$onclick) |
|
135 | + protected function renderInputTag($writer, $clientID, $onclick) |
|
136 | 136 | { |
137 | - parent::renderInputTag($writer,$clientID,$onclick); |
|
138 | - if ($this->getAutoPostBack()) |
|
137 | + parent::renderInputTag($writer, $clientID, $onclick); |
|
138 | + if($this->getAutoPostBack()) |
|
139 | 139 | $this->getActiveControl()->registerCallbackClientScript( |
140 | 140 | $this->getClientClassName(), $this->getPostBackOptions()); |
141 | 141 | } |
@@ -154,8 +154,8 @@ discard block |
||
154 | 154 | */ |
155 | 155 | public function getLabelAttributes() |
156 | 156 | { |
157 | - $attributes = parent::getLabelAttributes(); |
|
158 | - $attributes['id'] = $this->getDefaultLabelID(); |
|
157 | + $attributes=parent::getLabelAttributes(); |
|
158 | + $attributes['id']=$this->getDefaultLabelID(); |
|
159 | 159 | return $attributes; |
160 | 160 | } |
161 | 161 | |
@@ -165,7 +165,7 @@ discard block |
||
165 | 165 | * @param string checkbox id |
166 | 166 | * @param string label text |
167 | 167 | */ |
168 | - protected function renderLabel($writer,$clientID,$text) |
|
168 | + protected function renderLabel($writer, $clientID, $text) |
|
169 | 169 | { |
170 | 170 | $writer->addAttribute('id', $this->getDefaultLabelID()); |
171 | 171 | parent::renderLabel($writer, $clientID, $text); |
@@ -176,7 +176,7 @@ discard block |
||
176 | 176 | */ |
177 | 177 | protected function getDefaultLabelID() |
178 | 178 | { |
179 | - if($attributes=$this->getViewState('LabelAttributes',null)) |
|
179 | + if($attributes=$this->getViewState('LabelAttributes', null)) |
|
180 | 180 | return TCheckBox::getLabelAttributes()->itemAt('id'); |
181 | 181 | else |
182 | 182 | return $this->getClientID().'_label'; |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | */ |
95 | 95 | public function setText($value) |
96 | 96 | { |
97 | - if(parent::getText() === $value) |
|
97 | + if(parent::getText()===$value) |
|
98 | 98 | return; |
99 | 99 | |
100 | 100 | parent::setText($value); |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | protected function addAttributesToRender($writer) |
118 | 118 | { |
119 | 119 | parent::addAttributesToRender($writer); |
120 | - $writer->addAttribute('id',$this->getClientID()); |
|
120 | + $writer->addAttribute('id', $this->getClientID()); |
|
121 | 121 | $this->getActiveControl()->registerCallbackClientScript( |
122 | 122 | $this->getClientClassName(), $this->getPostBackOptions()); |
123 | 123 | } |
@@ -29,82 +29,82 @@ |
||
29 | 29 | |
30 | 30 | class TReCaptcha2Validator extends TBaseValidator |
31 | 31 | { |
32 | - protected $_isvalid = null; |
|
32 | + protected $_isvalid = null; |
|
33 | 33 | |
34 | - protected function getClientClassName() |
|
35 | - { |
|
36 | - return 'Prado.WebUI.TReCaptcha2Validator'; |
|
37 | - } |
|
38 | - public function getEnableClientScript() |
|
39 | - { |
|
40 | - return true; |
|
41 | - } |
|
42 | - protected function getCaptchaControl() |
|
43 | - { |
|
44 | - $control = $this->getValidationTarget(); |
|
45 | - if (!$control) |
|
46 | - throw new Exception('No target control specified for TReCaptcha2Validator'); |
|
47 | - if (!($control instanceof TReCaptcha2)) |
|
48 | - throw new Exception('TReCaptcha2Validator only works with TReCaptcha2 controls'); |
|
49 | - return $control; |
|
50 | - } |
|
51 | - public function getClientScriptOptions() |
|
52 | - { |
|
53 | - $options = parent::getClientScriptOptions(); |
|
54 | - $options['ResponseFieldName'] = $this->getCaptchaControl()->getResponseFieldName(); |
|
55 | - return $options; |
|
56 | - } |
|
57 | - /** |
|
58 | - * This method overrides the parent's implementation. |
|
59 | - * The validation succeeds if the input control has the same value |
|
60 | - * as the one displayed in the corresponding RECAPTCHA control. |
|
61 | - * |
|
62 | - * @return boolean whether the validation succeeds |
|
63 | - */ |
|
64 | - protected function evaluateIsValid() |
|
65 | - { |
|
66 | - // check validity only once (if trying to evaulate multiple times, all redundant checks would fail) |
|
67 | - if (is_null($this->_isvalid)) |
|
68 | - { |
|
69 | - $control = $this->getCaptchaControl(); |
|
70 | - $this->_isvalid = $control->validate(); |
|
71 | - } |
|
72 | - return ($this->_isvalid==true); |
|
73 | - } |
|
74 | - public function onPreRender($param) |
|
75 | - { |
|
76 | - parent::onPreRender($param); |
|
34 | + protected function getClientClassName() |
|
35 | + { |
|
36 | + return 'Prado.WebUI.TReCaptcha2Validator'; |
|
37 | + } |
|
38 | + public function getEnableClientScript() |
|
39 | + { |
|
40 | + return true; |
|
41 | + } |
|
42 | + protected function getCaptchaControl() |
|
43 | + { |
|
44 | + $control = $this->getValidationTarget(); |
|
45 | + if (!$control) |
|
46 | + throw new Exception('No target control specified for TReCaptcha2Validator'); |
|
47 | + if (!($control instanceof TReCaptcha2)) |
|
48 | + throw new Exception('TReCaptcha2Validator only works with TReCaptcha2 controls'); |
|
49 | + return $control; |
|
50 | + } |
|
51 | + public function getClientScriptOptions() |
|
52 | + { |
|
53 | + $options = parent::getClientScriptOptions(); |
|
54 | + $options['ResponseFieldName'] = $this->getCaptchaControl()->getResponseFieldName(); |
|
55 | + return $options; |
|
56 | + } |
|
57 | + /** |
|
58 | + * This method overrides the parent's implementation. |
|
59 | + * The validation succeeds if the input control has the same value |
|
60 | + * as the one displayed in the corresponding RECAPTCHA control. |
|
61 | + * |
|
62 | + * @return boolean whether the validation succeeds |
|
63 | + */ |
|
64 | + protected function evaluateIsValid() |
|
65 | + { |
|
66 | + // check validity only once (if trying to evaulate multiple times, all redundant checks would fail) |
|
67 | + if (is_null($this->_isvalid)) |
|
68 | + { |
|
69 | + $control = $this->getCaptchaControl(); |
|
70 | + $this->_isvalid = $control->validate(); |
|
71 | + } |
|
72 | + return ($this->_isvalid==true); |
|
73 | + } |
|
74 | + public function onPreRender($param) |
|
75 | + { |
|
76 | + parent::onPreRender($param); |
|
77 | 77 | |
78 | - $cs = $this->Page->getClientScript(); |
|
79 | - $cs->registerPradoScript('validator'); |
|
78 | + $cs = $this->Page->getClientScript(); |
|
79 | + $cs->registerPradoScript('validator'); |
|
80 | 80 | |
81 | - // communicate validation status to the client side |
|
82 | - $value = $this->_isvalid===false ? '0' : '1'; |
|
83 | - $cs->registerHiddenField($this->getClientID().'_1',$value); |
|
81 | + // communicate validation status to the client side |
|
82 | + $value = $this->_isvalid===false ? '0' : '1'; |
|
83 | + $cs->registerHiddenField($this->getClientID().'_1',$value); |
|
84 | 84 | |
85 | - // update validator display |
|
86 | - if ($control = $this->getValidationTarget()) |
|
87 | - { |
|
88 | - $fn = 'captchaUpdateValidatorStatus_'.$this->getClientID(); |
|
85 | + // update validator display |
|
86 | + if ($control = $this->getValidationTarget()) |
|
87 | + { |
|
88 | + $fn = 'captchaUpdateValidatorStatus_'.$this->getClientID(); |
|
89 | 89 | |
90 | - $cs->registerEndScript($this->getClientID().'::validate', implode(' ',array( |
|
91 | - // this function will be used to update the validator |
|
92 | - 'function '.$fn.'(valid)', |
|
93 | - '{', |
|
94 | - ' jQuery('.TJavaScript::quoteString('#'.$this->getClientID().'_1').').val(valid);', |
|
95 | - ' Prado.Validation.validateControl('.TJavaScript::quoteString($control->ClientID).'); ', |
|
96 | - '}', |
|
97 | - '', |
|
98 | - // update the validator to the result if we're in a callback |
|
99 | - // (if we're in initial rendering or a postback then the result will be rendered directly to the page html anyway) |
|
100 | - $this->Page->IsCallback ? $fn.'('.$value.');' : '', |
|
101 | - '', |
|
102 | - // install event handler that clears the validation error when user changes the captcha response field |
|
103 | - 'jQuery("#'.$control->getClientID().'").on("change", '.TJavaScript::quoteString('#'.$control->getResponseFieldName()).', function() { ', |
|
104 | - $fn.'("1");', |
|
105 | - '});', |
|
106 | - ))); |
|
107 | - } |
|
108 | - } |
|
90 | + $cs->registerEndScript($this->getClientID().'::validate', implode(' ',array( |
|
91 | + // this function will be used to update the validator |
|
92 | + 'function '.$fn.'(valid)', |
|
93 | + '{', |
|
94 | + ' jQuery('.TJavaScript::quoteString('#'.$this->getClientID().'_1').').val(valid);', |
|
95 | + ' Prado.Validation.validateControl('.TJavaScript::quoteString($control->ClientID).'); ', |
|
96 | + '}', |
|
97 | + '', |
|
98 | + // update the validator to the result if we're in a callback |
|
99 | + // (if we're in initial rendering or a postback then the result will be rendered directly to the page html anyway) |
|
100 | + $this->Page->IsCallback ? $fn.'('.$value.');' : '', |
|
101 | + '', |
|
102 | + // install event handler that clears the validation error when user changes the captcha response field |
|
103 | + 'jQuery("#'.$control->getClientID().'").on("change", '.TJavaScript::quoteString('#'.$control->getResponseFieldName()).', function() { ', |
|
104 | + $fn.'("1");', |
|
105 | + '});', |
|
106 | + ))); |
|
107 | + } |
|
108 | + } |
|
109 | 109 | } |
110 | 110 |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | |
30 | 30 | class TReCaptcha2Validator extends TBaseValidator |
31 | 31 | { |
32 | - protected $_isvalid = null; |
|
32 | + protected $_isvalid=null; |
|
33 | 33 | |
34 | 34 | protected function getClientClassName() |
35 | 35 | { |
@@ -41,17 +41,17 @@ discard block |
||
41 | 41 | } |
42 | 42 | protected function getCaptchaControl() |
43 | 43 | { |
44 | - $control = $this->getValidationTarget(); |
|
45 | - if (!$control) |
|
44 | + $control=$this->getValidationTarget(); |
|
45 | + if(!$control) |
|
46 | 46 | throw new Exception('No target control specified for TReCaptcha2Validator'); |
47 | - if (!($control instanceof TReCaptcha2)) |
|
47 | + if(!($control instanceof TReCaptcha2)) |
|
48 | 48 | throw new Exception('TReCaptcha2Validator only works with TReCaptcha2 controls'); |
49 | 49 | return $control; |
50 | 50 | } |
51 | 51 | public function getClientScriptOptions() |
52 | 52 | { |
53 | - $options = parent::getClientScriptOptions(); |
|
54 | - $options['ResponseFieldName'] = $this->getCaptchaControl()->getResponseFieldName(); |
|
53 | + $options=parent::getClientScriptOptions(); |
|
54 | + $options['ResponseFieldName']=$this->getCaptchaControl()->getResponseFieldName(); |
|
55 | 55 | return $options; |
56 | 56 | } |
57 | 57 | /** |
@@ -64,10 +64,10 @@ discard block |
||
64 | 64 | protected function evaluateIsValid() |
65 | 65 | { |
66 | 66 | // check validity only once (if trying to evaulate multiple times, all redundant checks would fail) |
67 | - if (is_null($this->_isvalid)) |
|
67 | + if(is_null($this->_isvalid)) |
|
68 | 68 | { |
69 | - $control = $this->getCaptchaControl(); |
|
70 | - $this->_isvalid = $control->validate(); |
|
69 | + $control=$this->getCaptchaControl(); |
|
70 | + $this->_isvalid=$control->validate(); |
|
71 | 71 | } |
72 | 72 | return ($this->_isvalid==true); |
73 | 73 | } |
@@ -75,19 +75,19 @@ discard block |
||
75 | 75 | { |
76 | 76 | parent::onPreRender($param); |
77 | 77 | |
78 | - $cs = $this->Page->getClientScript(); |
|
78 | + $cs=$this->Page->getClientScript(); |
|
79 | 79 | $cs->registerPradoScript('validator'); |
80 | 80 | |
81 | 81 | // communicate validation status to the client side |
82 | - $value = $this->_isvalid===false ? '0' : '1'; |
|
83 | - $cs->registerHiddenField($this->getClientID().'_1',$value); |
|
82 | + $value=$this->_isvalid===false ? '0' : '1'; |
|
83 | + $cs->registerHiddenField($this->getClientID().'_1', $value); |
|
84 | 84 | |
85 | 85 | // update validator display |
86 | - if ($control = $this->getValidationTarget()) |
|
86 | + if($control=$this->getValidationTarget()) |
|
87 | 87 | { |
88 | - $fn = 'captchaUpdateValidatorStatus_'.$this->getClientID(); |
|
88 | + $fn='captchaUpdateValidatorStatus_'.$this->getClientID(); |
|
89 | 89 | |
90 | - $cs->registerEndScript($this->getClientID().'::validate', implode(' ',array( |
|
90 | + $cs->registerEndScript($this->getClientID().'::validate', implode(' ', array( |
|
91 | 91 | // this function will be used to update the validator |
92 | 92 | 'function '.$fn.'(valid)', |
93 | 93 | '{', |