@@ -60,310 +60,310 @@ |
||
| 60 | 60 | |
| 61 | 61 | class TReCaptcha2 extends TActivePanel implements \Prado\Web\UI\ActiveControls\ICallbackEventHandler, \Prado\Web\UI\IValidatable |
| 62 | 62 | { |
| 63 | - const ChallengeFieldName = 'g-recaptcha-response'; |
|
| 64 | - private $_widgetId=0; |
|
| 65 | - private $_isValid=true; |
|
| 63 | + const ChallengeFieldName = 'g-recaptcha-response'; |
|
| 64 | + private $_widgetId=0; |
|
| 65 | + private $_isValid=true; |
|
| 66 | 66 | |
| 67 | - public function __construct() |
|
| 68 | - { |
|
| 69 | - parent::__construct(); |
|
| 70 | - $this->setAdapter(new TActiveControlAdapter($this)); |
|
| 71 | - } |
|
| 72 | - public function getActiveControl() |
|
| 73 | - { |
|
| 74 | - return $this->getAdapter()->getBaseActiveControl(); |
|
| 75 | - } |
|
| 76 | - public function getClientSide() |
|
| 77 | - { |
|
| 78 | - return $this->getAdapter()->getBaseActiveControl()->getClientSide(); |
|
| 79 | - } |
|
| 80 | - public function getClientClassName() |
|
| 81 | - { |
|
| 82 | - return 'Prado.WebUI.TReCaptcha2'; |
|
| 83 | - } |
|
| 84 | - public function getTagName() |
|
| 85 | - { |
|
| 86 | - return 'div'; |
|
| 87 | - } |
|
| 88 | - /** |
|
| 89 | - * Returns true if this control validated successfully. |
|
| 90 | - * Defaults to true. |
|
| 91 | - * @return bool wether this control validated successfully. |
|
| 92 | - */ |
|
| 93 | - public function getIsValid() |
|
| 94 | - { |
|
| 95 | - return $this->_isValid; |
|
| 96 | - } |
|
| 97 | - /** |
|
| 98 | - * @param bool wether this control is valid. |
|
| 99 | - */ |
|
| 100 | - public function setIsValid($value) |
|
| 101 | - { |
|
| 102 | - $this->_isValid=TPropertyValue::ensureBoolean($value); |
|
| 103 | - } |
|
| 104 | - public function getValidationPropertyValue() |
|
| 105 | - { |
|
| 106 | - return $this->Request[$this->getResponseFieldName()]; |
|
| 107 | - } |
|
| 108 | - public function getResponseFieldName() |
|
| 109 | - { |
|
| 110 | - $captchas = $this->Page->findControlsByType('Prado\Web\UI\WebControls\TReCaptcha2'); |
|
| 111 | - $cont = 0; |
|
| 112 | - $responseFieldName = self::ChallengeFieldName; |
|
| 113 | - foreach ($captchas as $captcha) |
|
| 114 | - { |
|
| 115 | - if ($this->getClientID() == $captcha->ClientID) |
|
| 116 | - { |
|
| 117 | - $responseFieldName .= ($cont > 0) ? '-'.$cont : ''; |
|
| 118 | - } |
|
| 119 | - $cont++; |
|
| 120 | - } |
|
| 121 | - return $responseFieldName; |
|
| 122 | - } |
|
| 123 | - /** |
|
| 124 | - * Returns your site key. |
|
| 125 | - * @return string. |
|
| 126 | - */ |
|
| 127 | - public function getSiteKey() |
|
| 128 | - { |
|
| 129 | - return $this->getViewState('SiteKey'); |
|
| 130 | - } |
|
| 131 | - /** |
|
| 132 | - * @param string your site key. |
|
| 133 | - */ |
|
| 134 | - public function setSiteKey($value) |
|
| 135 | - { |
|
| 136 | - $this->setViewState('SiteKey', TPropertyValue::ensureString($value)); |
|
| 137 | - } |
|
| 138 | - /** |
|
| 139 | - * Returns your secret key. |
|
| 140 | - * @return string. |
|
| 141 | - */ |
|
| 142 | - public function getSecretKey() |
|
| 143 | - { |
|
| 144 | - return $this->getViewState('SecretKey'); |
|
| 145 | - } |
|
| 146 | - /** |
|
| 147 | - * @param string your secret key. |
|
| 148 | - */ |
|
| 149 | - public function setSecretKey($value) |
|
| 150 | - { |
|
| 151 | - $this->setViewState('SecretKey', TPropertyValue::ensureString($value)); |
|
| 152 | - } |
|
| 153 | - /** |
|
| 154 | - * Returns your language. |
|
| 155 | - * @return string. |
|
| 156 | - */ |
|
| 157 | - public function getLanguage() |
|
| 158 | - { |
|
| 159 | - return $this->getViewState('Language', 'en'); |
|
| 160 | - } |
|
| 161 | - /** |
|
| 162 | - * @param string your language. |
|
| 163 | - */ |
|
| 164 | - public function setLanguage($value) |
|
| 165 | - { |
|
| 166 | - $this->setViewState('Language', TPropertyValue::ensureString($value), 'en'); |
|
| 167 | - } |
|
| 168 | - /** |
|
| 169 | - * Returns the color theme of the widget. |
|
| 170 | - * @return string. |
|
| 171 | - */ |
|
| 172 | - public function getTheme() |
|
| 173 | - { |
|
| 174 | - return $this->getViewState('Theme', 'light'); |
|
| 175 | - } |
|
| 176 | - /** |
|
| 177 | - * The color theme of the widget. |
|
| 178 | - * Default: light |
|
| 179 | - * @param string the color theme of the widget. |
|
| 180 | - */ |
|
| 181 | - public function setTheme($value) |
|
| 182 | - { |
|
| 183 | - $this->setViewState('Theme', TPropertyValue::ensureString($value), 'light'); |
|
| 184 | - } |
|
| 185 | - /** |
|
| 186 | - * Returns the type of CAPTCHA to serve. |
|
| 187 | - * @return string. |
|
| 188 | - */ |
|
| 189 | - public function getType() |
|
| 190 | - { |
|
| 191 | - return $this->getViewState('Type', 'image'); |
|
| 192 | - } |
|
| 193 | - /** |
|
| 194 | - * The type of CAPTCHA to serve. |
|
| 195 | - * Default: image |
|
| 196 | - * @param string the type of CAPTCHA to serve. |
|
| 197 | - */ |
|
| 198 | - public function setType($value) |
|
| 199 | - { |
|
| 200 | - $this->setViewState('Type', TPropertyValue::ensureString($value), 'image'); |
|
| 201 | - } |
|
| 202 | - /** |
|
| 203 | - * Returns the size of the widget. |
|
| 204 | - * @return string. |
|
| 205 | - */ |
|
| 206 | - public function getSize() |
|
| 207 | - { |
|
| 208 | - return $this->getViewState('Size', 'normal'); |
|
| 209 | - } |
|
| 210 | - /** |
|
| 211 | - * The size of the widget. |
|
| 212 | - * Default: normal |
|
| 213 | - * @param string the size of the widget. |
|
| 214 | - */ |
|
| 215 | - public function setSize($value) |
|
| 216 | - { |
|
| 217 | - $this->setViewState('Size', TPropertyValue::ensureString($value), 'normal'); |
|
| 218 | - } |
|
| 219 | - /** |
|
| 220 | - * Returns the tabindex of the widget and challenge. |
|
| 221 | - * If other elements in your page use tabindex, it should be set to make user navigation easier. |
|
| 222 | - * @return string. |
|
| 223 | - */ |
|
| 224 | - public function getTabIndex() |
|
| 225 | - { |
|
| 226 | - return $this->getViewState('TabIndex', 0); |
|
| 227 | - } |
|
| 228 | - /** |
|
| 229 | - * The tabindex of the widget and challenge. |
|
| 230 | - * If other elements in your page use tabindex, it should be set to make user navigation easier. |
|
| 231 | - * Default: 0 |
|
| 232 | - * @param string the tabindex of the widget and challenge. |
|
| 233 | - */ |
|
| 234 | - public function setTabIndex($value) |
|
| 235 | - { |
|
| 236 | - $this->setViewState('TabIndex', TPropertyValue::ensureInteger($value), 0); |
|
| 237 | - } |
|
| 238 | - /** |
|
| 239 | - * Resets the reCAPTCHA widget. |
|
| 240 | - * Optional widget ID, defaults to the first widget created if unspecified. |
|
| 241 | - */ |
|
| 242 | - public function reset() |
|
| 243 | - { |
|
| 244 | - $this->Page->CallbackClient->callClientFunction('grecaptcha.reset',array(array($this->WidgetId))); |
|
| 245 | - } |
|
| 246 | - /** |
|
| 247 | - * Gets the response for the reCAPTCHA widget. |
|
| 248 | - */ |
|
| 249 | - public function getResponse() |
|
| 250 | - { |
|
| 251 | - return $this->getViewState('Response', ''); |
|
| 252 | - } |
|
| 253 | - public function setResponse($value) |
|
| 254 | - { |
|
| 255 | - $this->setViewState('Response', TPropertyValue::ensureString($value), ''); |
|
| 256 | - } |
|
| 257 | - public function getWidgetId() |
|
| 258 | - { |
|
| 259 | - return $this->getViewState('WidgetId', 0); |
|
| 260 | - } |
|
| 261 | - public function setWidgetId($value) |
|
| 262 | - { |
|
| 263 | - $this->setViewState('WidgetId', TPropertyValue::ensureInteger($value), 0); |
|
| 264 | - } |
|
| 265 | - protected function getClientOptions() |
|
| 266 | - { |
|
| 267 | - $options['ID'] = $this->getClientID(); |
|
| 268 | - $options['EventTarget'] = $this->getUniqueID(); |
|
| 269 | - $options['FormID'] = $this->Page->getForm()->getClientID(); |
|
| 270 | - $options['onCallback'] = $this->hasEventHandler('OnCallback'); |
|
| 271 | - $options['onCallbackExpired'] = $this->hasEventHandler('OnCallbackExpired'); |
|
| 272 | - $options['options']['sitekey'] = $this->getSiteKey(); |
|
| 273 | - if ($theme = $this->getTheme()) $options['options']['theme'] = $theme; |
|
| 274 | - if ($type = $this->getType()) $options['options']['type'] = $type; |
|
| 275 | - if ($size = $this->getSize()) $options['options']['size'] = $size; |
|
| 276 | - if ($tabIndex = $this->getTabIndex()) $options['options']['tabindex'] = $tabIndex; |
|
| 67 | + public function __construct() |
|
| 68 | + { |
|
| 69 | + parent::__construct(); |
|
| 70 | + $this->setAdapter(new TActiveControlAdapter($this)); |
|
| 71 | + } |
|
| 72 | + public function getActiveControl() |
|
| 73 | + { |
|
| 74 | + return $this->getAdapter()->getBaseActiveControl(); |
|
| 75 | + } |
|
| 76 | + public function getClientSide() |
|
| 77 | + { |
|
| 78 | + return $this->getAdapter()->getBaseActiveControl()->getClientSide(); |
|
| 79 | + } |
|
| 80 | + public function getClientClassName() |
|
| 81 | + { |
|
| 82 | + return 'Prado.WebUI.TReCaptcha2'; |
|
| 83 | + } |
|
| 84 | + public function getTagName() |
|
| 85 | + { |
|
| 86 | + return 'div'; |
|
| 87 | + } |
|
| 88 | + /** |
|
| 89 | + * Returns true if this control validated successfully. |
|
| 90 | + * Defaults to true. |
|
| 91 | + * @return bool wether this control validated successfully. |
|
| 92 | + */ |
|
| 93 | + public function getIsValid() |
|
| 94 | + { |
|
| 95 | + return $this->_isValid; |
|
| 96 | + } |
|
| 97 | + /** |
|
| 98 | + * @param bool wether this control is valid. |
|
| 99 | + */ |
|
| 100 | + public function setIsValid($value) |
|
| 101 | + { |
|
| 102 | + $this->_isValid=TPropertyValue::ensureBoolean($value); |
|
| 103 | + } |
|
| 104 | + public function getValidationPropertyValue() |
|
| 105 | + { |
|
| 106 | + return $this->Request[$this->getResponseFieldName()]; |
|
| 107 | + } |
|
| 108 | + public function getResponseFieldName() |
|
| 109 | + { |
|
| 110 | + $captchas = $this->Page->findControlsByType('Prado\Web\UI\WebControls\TReCaptcha2'); |
|
| 111 | + $cont = 0; |
|
| 112 | + $responseFieldName = self::ChallengeFieldName; |
|
| 113 | + foreach ($captchas as $captcha) |
|
| 114 | + { |
|
| 115 | + if ($this->getClientID() == $captcha->ClientID) |
|
| 116 | + { |
|
| 117 | + $responseFieldName .= ($cont > 0) ? '-'.$cont : ''; |
|
| 118 | + } |
|
| 119 | + $cont++; |
|
| 120 | + } |
|
| 121 | + return $responseFieldName; |
|
| 122 | + } |
|
| 123 | + /** |
|
| 124 | + * Returns your site key. |
|
| 125 | + * @return string. |
|
| 126 | + */ |
|
| 127 | + public function getSiteKey() |
|
| 128 | + { |
|
| 129 | + return $this->getViewState('SiteKey'); |
|
| 130 | + } |
|
| 131 | + /** |
|
| 132 | + * @param string your site key. |
|
| 133 | + */ |
|
| 134 | + public function setSiteKey($value) |
|
| 135 | + { |
|
| 136 | + $this->setViewState('SiteKey', TPropertyValue::ensureString($value)); |
|
| 137 | + } |
|
| 138 | + /** |
|
| 139 | + * Returns your secret key. |
|
| 140 | + * @return string. |
|
| 141 | + */ |
|
| 142 | + public function getSecretKey() |
|
| 143 | + { |
|
| 144 | + return $this->getViewState('SecretKey'); |
|
| 145 | + } |
|
| 146 | + /** |
|
| 147 | + * @param string your secret key. |
|
| 148 | + */ |
|
| 149 | + public function setSecretKey($value) |
|
| 150 | + { |
|
| 151 | + $this->setViewState('SecretKey', TPropertyValue::ensureString($value)); |
|
| 152 | + } |
|
| 153 | + /** |
|
| 154 | + * Returns your language. |
|
| 155 | + * @return string. |
|
| 156 | + */ |
|
| 157 | + public function getLanguage() |
|
| 158 | + { |
|
| 159 | + return $this->getViewState('Language', 'en'); |
|
| 160 | + } |
|
| 161 | + /** |
|
| 162 | + * @param string your language. |
|
| 163 | + */ |
|
| 164 | + public function setLanguage($value) |
|
| 165 | + { |
|
| 166 | + $this->setViewState('Language', TPropertyValue::ensureString($value), 'en'); |
|
| 167 | + } |
|
| 168 | + /** |
|
| 169 | + * Returns the color theme of the widget. |
|
| 170 | + * @return string. |
|
| 171 | + */ |
|
| 172 | + public function getTheme() |
|
| 173 | + { |
|
| 174 | + return $this->getViewState('Theme', 'light'); |
|
| 175 | + } |
|
| 176 | + /** |
|
| 177 | + * The color theme of the widget. |
|
| 178 | + * Default: light |
|
| 179 | + * @param string the color theme of the widget. |
|
| 180 | + */ |
|
| 181 | + public function setTheme($value) |
|
| 182 | + { |
|
| 183 | + $this->setViewState('Theme', TPropertyValue::ensureString($value), 'light'); |
|
| 184 | + } |
|
| 185 | + /** |
|
| 186 | + * Returns the type of CAPTCHA to serve. |
|
| 187 | + * @return string. |
|
| 188 | + */ |
|
| 189 | + public function getType() |
|
| 190 | + { |
|
| 191 | + return $this->getViewState('Type', 'image'); |
|
| 192 | + } |
|
| 193 | + /** |
|
| 194 | + * The type of CAPTCHA to serve. |
|
| 195 | + * Default: image |
|
| 196 | + * @param string the type of CAPTCHA to serve. |
|
| 197 | + */ |
|
| 198 | + public function setType($value) |
|
| 199 | + { |
|
| 200 | + $this->setViewState('Type', TPropertyValue::ensureString($value), 'image'); |
|
| 201 | + } |
|
| 202 | + /** |
|
| 203 | + * Returns the size of the widget. |
|
| 204 | + * @return string. |
|
| 205 | + */ |
|
| 206 | + public function getSize() |
|
| 207 | + { |
|
| 208 | + return $this->getViewState('Size', 'normal'); |
|
| 209 | + } |
|
| 210 | + /** |
|
| 211 | + * The size of the widget. |
|
| 212 | + * Default: normal |
|
| 213 | + * @param string the size of the widget. |
|
| 214 | + */ |
|
| 215 | + public function setSize($value) |
|
| 216 | + { |
|
| 217 | + $this->setViewState('Size', TPropertyValue::ensureString($value), 'normal'); |
|
| 218 | + } |
|
| 219 | + /** |
|
| 220 | + * Returns the tabindex of the widget and challenge. |
|
| 221 | + * If other elements in your page use tabindex, it should be set to make user navigation easier. |
|
| 222 | + * @return string. |
|
| 223 | + */ |
|
| 224 | + public function getTabIndex() |
|
| 225 | + { |
|
| 226 | + return $this->getViewState('TabIndex', 0); |
|
| 227 | + } |
|
| 228 | + /** |
|
| 229 | + * The tabindex of the widget and challenge. |
|
| 230 | + * If other elements in your page use tabindex, it should be set to make user navigation easier. |
|
| 231 | + * Default: 0 |
|
| 232 | + * @param string the tabindex of the widget and challenge. |
|
| 233 | + */ |
|
| 234 | + public function setTabIndex($value) |
|
| 235 | + { |
|
| 236 | + $this->setViewState('TabIndex', TPropertyValue::ensureInteger($value), 0); |
|
| 237 | + } |
|
| 238 | + /** |
|
| 239 | + * Resets the reCAPTCHA widget. |
|
| 240 | + * Optional widget ID, defaults to the first widget created if unspecified. |
|
| 241 | + */ |
|
| 242 | + public function reset() |
|
| 243 | + { |
|
| 244 | + $this->Page->CallbackClient->callClientFunction('grecaptcha.reset',array(array($this->WidgetId))); |
|
| 245 | + } |
|
| 246 | + /** |
|
| 247 | + * Gets the response for the reCAPTCHA widget. |
|
| 248 | + */ |
|
| 249 | + public function getResponse() |
|
| 250 | + { |
|
| 251 | + return $this->getViewState('Response', ''); |
|
| 252 | + } |
|
| 253 | + public function setResponse($value) |
|
| 254 | + { |
|
| 255 | + $this->setViewState('Response', TPropertyValue::ensureString($value), ''); |
|
| 256 | + } |
|
| 257 | + public function getWidgetId() |
|
| 258 | + { |
|
| 259 | + return $this->getViewState('WidgetId', 0); |
|
| 260 | + } |
|
| 261 | + public function setWidgetId($value) |
|
| 262 | + { |
|
| 263 | + $this->setViewState('WidgetId', TPropertyValue::ensureInteger($value), 0); |
|
| 264 | + } |
|
| 265 | + protected function getClientOptions() |
|
| 266 | + { |
|
| 267 | + $options['ID'] = $this->getClientID(); |
|
| 268 | + $options['EventTarget'] = $this->getUniqueID(); |
|
| 269 | + $options['FormID'] = $this->Page->getForm()->getClientID(); |
|
| 270 | + $options['onCallback'] = $this->hasEventHandler('OnCallback'); |
|
| 271 | + $options['onCallbackExpired'] = $this->hasEventHandler('OnCallbackExpired'); |
|
| 272 | + $options['options']['sitekey'] = $this->getSiteKey(); |
|
| 273 | + if ($theme = $this->getTheme()) $options['options']['theme'] = $theme; |
|
| 274 | + if ($type = $this->getType()) $options['options']['type'] = $type; |
|
| 275 | + if ($size = $this->getSize()) $options['options']['size'] = $size; |
|
| 276 | + if ($tabIndex = $this->getTabIndex()) $options['options']['tabindex'] = $tabIndex; |
|
| 277 | 277 | |
| 278 | - return $options; |
|
| 279 | - } |
|
| 280 | - protected function registerClientScript() |
|
| 281 | - { |
|
| 282 | - $id = $this->getClientID(); |
|
| 283 | - $options = TJavaScript::encode($this->getClientOptions()); |
|
| 284 | - $className = $this->getClientClassName(); |
|
| 285 | - $cs = $this->Page->ClientScript; |
|
| 286 | - $code = "new $className($options);"; |
|
| 278 | + return $options; |
|
| 279 | + } |
|
| 280 | + protected function registerClientScript() |
|
| 281 | + { |
|
| 282 | + $id = $this->getClientID(); |
|
| 283 | + $options = TJavaScript::encode($this->getClientOptions()); |
|
| 284 | + $className = $this->getClientClassName(); |
|
| 285 | + $cs = $this->Page->ClientScript; |
|
| 286 | + $code = "new $className($options);"; |
|
| 287 | 287 | |
| 288 | - $cs->registerPradoScript('ajax'); |
|
| 289 | - $cs->registerEndScript("grecaptcha:$id", $code); |
|
| 290 | - } |
|
| 291 | - public function validate() |
|
| 292 | - { |
|
| 293 | - $value = $this->getValidationPropertyValue(); |
|
| 294 | - if($value === null || empty($value)) |
|
| 295 | - return false; |
|
| 288 | + $cs->registerPradoScript('ajax'); |
|
| 289 | + $cs->registerEndScript("grecaptcha:$id", $code); |
|
| 290 | + } |
|
| 291 | + public function validate() |
|
| 292 | + { |
|
| 293 | + $value = $this->getValidationPropertyValue(); |
|
| 294 | + if($value === null || empty($value)) |
|
| 295 | + return false; |
|
| 296 | 296 | |
| 297 | - return true; |
|
| 298 | - } |
|
| 299 | - /** |
|
| 300 | - * Checks for API keys |
|
| 301 | - * @param mixed event parameter |
|
| 302 | - */ |
|
| 303 | - public function onPreRender($param) |
|
| 304 | - { |
|
| 305 | - parent::onPreRender($param); |
|
| 297 | + return true; |
|
| 298 | + } |
|
| 299 | + /** |
|
| 300 | + * Checks for API keys |
|
| 301 | + * @param mixed event parameter |
|
| 302 | + */ |
|
| 303 | + public function onPreRender($param) |
|
| 304 | + { |
|
| 305 | + parent::onPreRender($param); |
|
| 306 | 306 | |
| 307 | - if("" == $this->getSiteKey()) |
|
| 308 | - throw new TConfigurationException('recaptcha_publickey_unknown'); |
|
| 309 | - if("" == $this->getSecretKey()) |
|
| 310 | - throw new TConfigurationException('recaptcha_privatekey_unknown'); |
|
| 307 | + if("" == $this->getSiteKey()) |
|
| 308 | + throw new TConfigurationException('recaptcha_publickey_unknown'); |
|
| 309 | + if("" == $this->getSecretKey()) |
|
| 310 | + throw new TConfigurationException('recaptcha_privatekey_unknown'); |
|
| 311 | 311 | |
| 312 | - // need to register captcha fields so they will be sent postback |
|
| 313 | - $this->Page->registerRequiresPostData($this->getResponseFieldName()); |
|
| 314 | - $this->Page->ClientScript->registerHeadScriptFile('grecaptcha2', 'https://www.google.com/recaptcha/api.js?onload=TReCaptcha2_onloadCallback&render=explicit&hl=' . $this->getLanguage()); |
|
| 315 | - } |
|
| 316 | - protected function addAttributesToRender($writer) |
|
| 317 | - { |
|
| 318 | - $writer->addAttribute('id',$this->getClientID()); |
|
| 319 | - parent::addAttributesToRender($writer); |
|
| 320 | - } |
|
| 321 | - public function raiseCallbackEvent($param) |
|
| 322 | - { |
|
| 323 | - $params = $param->getCallbackParameter(); |
|
| 324 | - if ($params instanceof stdClass) |
|
| 325 | - { |
|
| 326 | - $callback = property_exists($params, 'onCallback'); |
|
| 327 | - $callbackExpired = property_exists($params, 'onCallbackExpired'); |
|
| 312 | + // need to register captcha fields so they will be sent postback |
|
| 313 | + $this->Page->registerRequiresPostData($this->getResponseFieldName()); |
|
| 314 | + $this->Page->ClientScript->registerHeadScriptFile('grecaptcha2', 'https://www.google.com/recaptcha/api.js?onload=TReCaptcha2_onloadCallback&render=explicit&hl=' . $this->getLanguage()); |
|
| 315 | + } |
|
| 316 | + protected function addAttributesToRender($writer) |
|
| 317 | + { |
|
| 318 | + $writer->addAttribute('id',$this->getClientID()); |
|
| 319 | + parent::addAttributesToRender($writer); |
|
| 320 | + } |
|
| 321 | + public function raiseCallbackEvent($param) |
|
| 322 | + { |
|
| 323 | + $params = $param->getCallbackParameter(); |
|
| 324 | + if ($params instanceof stdClass) |
|
| 325 | + { |
|
| 326 | + $callback = property_exists($params, 'onCallback'); |
|
| 327 | + $callbackExpired = property_exists($params, 'onCallbackExpired'); |
|
| 328 | 328 | |
| 329 | - if ($callback) |
|
| 330 | - { |
|
| 331 | - $this->WidgetId = $params->widgetId; |
|
| 332 | - $this->Response = $params->response; |
|
| 333 | - $this->Page->CallbackClient->jQuery($params->responseField, 'text',array($params->response)); |
|
| 329 | + if ($callback) |
|
| 330 | + { |
|
| 331 | + $this->WidgetId = $params->widgetId; |
|
| 332 | + $this->Response = $params->response; |
|
| 333 | + $this->Page->CallbackClient->jQuery($params->responseField, 'text',array($params->response)); |
|
| 334 | 334 | |
| 335 | - if ($params->onCallback) |
|
| 336 | - { |
|
| 337 | - $this->onCallback($param); |
|
| 338 | - } |
|
| 339 | - } |
|
| 335 | + if ($params->onCallback) |
|
| 336 | + { |
|
| 337 | + $this->onCallback($param); |
|
| 338 | + } |
|
| 339 | + } |
|
| 340 | 340 | |
| 341 | - if ($callbackExpired) |
|
| 342 | - { |
|
| 343 | - $this->Response = ''; |
|
| 344 | - $this->reset(); |
|
| 341 | + if ($callbackExpired) |
|
| 342 | + { |
|
| 343 | + $this->Response = ''; |
|
| 344 | + $this->reset(); |
|
| 345 | 345 | |
| 346 | - if ($params->onCallbackExpired) |
|
| 347 | - { |
|
| 348 | - $this->onCallbackExpired($param); |
|
| 349 | - } |
|
| 350 | - } |
|
| 351 | - } |
|
| 352 | - } |
|
| 346 | + if ($params->onCallbackExpired) |
|
| 347 | + { |
|
| 348 | + $this->onCallbackExpired($param); |
|
| 349 | + } |
|
| 350 | + } |
|
| 351 | + } |
|
| 352 | + } |
|
| 353 | 353 | |
| 354 | - public function onCallback($param) |
|
| 355 | - { |
|
| 356 | - $this->raiseEvent('OnCallback', $this, $param); |
|
| 357 | - } |
|
| 354 | + public function onCallback($param) |
|
| 355 | + { |
|
| 356 | + $this->raiseEvent('OnCallback', $this, $param); |
|
| 357 | + } |
|
| 358 | 358 | |
| 359 | - public function onCallbackExpired($param) |
|
| 360 | - { |
|
| 361 | - $this->raiseEvent('OnCallbackExpired', $this, $param); |
|
| 362 | - } |
|
| 359 | + public function onCallbackExpired($param) |
|
| 360 | + { |
|
| 361 | + $this->raiseEvent('OnCallbackExpired', $this, $param); |
|
| 362 | + } |
|
| 363 | 363 | |
| 364 | - public function render($writer) |
|
| 365 | - { |
|
| 366 | - $this->registerClientScript(); |
|
| 367 | - parent::render($writer); |
|
| 368 | - } |
|
| 364 | + public function render($writer) |
|
| 365 | + { |
|
| 366 | + $this->registerClientScript(); |
|
| 367 | + parent::render($writer); |
|
| 368 | + } |
|
| 369 | 369 | } |
@@ -34,8 +34,8 @@ discard block |
||
| 34 | 34 | */ |
| 35 | 35 | public function __construct() |
| 36 | 36 | { |
| 37 | - parent::__construct(); |
|
| 38 | - $this->setAdapter(new TActiveControlAdapter($this)); |
|
| 37 | + parent::__construct(); |
|
| 38 | + $this->setAdapter(new TActiveControlAdapter($this)); |
|
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | /** |
@@ -43,7 +43,7 @@ discard block |
||
| 43 | 43 | */ |
| 44 | 44 | public function getActiveControl() |
| 45 | 45 | { |
| 46 | - return $this->getAdapter()->getBaseActiveControl(); |
|
| 46 | + return $this->getAdapter()->getBaseActiveControl(); |
|
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | /** |
@@ -55,11 +55,11 @@ discard block |
||
| 55 | 55 | */ |
| 56 | 56 | public function setDataSource($value) |
| 57 | 57 | { |
| 58 | - parent::setDataSource($value); |
|
| 59 | - if($this->getActiveControl()->canUpdateClientSide()) { |
|
| 60 | - $this->renderPager(); |
|
| 61 | - $this->getPage()->getAdapter()->registerControlToRender($this,$this->getResponse()->createHtmlWriter()); |
|
| 62 | - } |
|
| 58 | + parent::setDataSource($value); |
|
| 59 | + if($this->getActiveControl()->canUpdateClientSide()) { |
|
| 60 | + $this->renderPager(); |
|
| 61 | + $this->getPage()->getAdapter()->registerControlToRender($this,$this->getResponse()->createHtmlWriter()); |
|
| 62 | + } |
|
| 63 | 63 | } |
| 64 | 64 | |
| 65 | 65 | /** |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | */ |
| 69 | 69 | protected function getContainerID() |
| 70 | 70 | { |
| 71 | - return $this->ClientID.'_Container'; |
|
| 71 | + return $this->ClientID.'_Container'; |
|
| 72 | 72 | } |
| 73 | 73 | |
| 74 | 74 | /** |
@@ -79,13 +79,13 @@ discard block |
||
| 79 | 79 | */ |
| 80 | 80 | public function render($writer) |
| 81 | 81 | { |
| 82 | - if($this->getHasPreRendered()) { |
|
| 83 | - $this->renderDataList($writer); |
|
| 84 | - if($this->getActiveControl()->canUpdateClientSide()) $this->getPage()->getCallbackClient()->replaceContent($this->getContainerID(),$writer); |
|
| 85 | - } |
|
| 86 | - else { |
|
| 87 | - $this->getPage()->getAdapter()->registerControlToRender($this,$writer); |
|
| 88 | - } |
|
| 82 | + if($this->getHasPreRendered()) { |
|
| 83 | + $this->renderDataList($writer); |
|
| 84 | + if($this->getActiveControl()->canUpdateClientSide()) $this->getPage()->getCallbackClient()->replaceContent($this->getContainerID(),$writer); |
|
| 85 | + } |
|
| 86 | + else { |
|
| 87 | + $this->getPage()->getAdapter()->registerControlToRender($this,$writer); |
|
| 88 | + } |
|
| 89 | 89 | } |
| 90 | 90 | |
| 91 | 91 | /** |
@@ -95,14 +95,14 @@ discard block |
||
| 95 | 95 | */ |
| 96 | 96 | private function renderPager() |
| 97 | 97 | { |
| 98 | - $pager=$this->getPage()->findControlsByType('Prado\Web\UI\ActiveControls\TActivePager', false); |
|
| 99 | - foreach($pager as $item) |
|
| 100 | - { |
|
| 101 | - if($item->ControlToPaginate==$this->ID) { |
|
| 102 | - $writer=$this->getResponse()->createHtmlWriter(); |
|
| 103 | - $this->getPage()->getAdapter()->registerControlToRender($item,$writer); |
|
| 104 | - } |
|
| 105 | - } |
|
| 98 | + $pager=$this->getPage()->findControlsByType('Prado\Web\UI\ActiveControls\TActivePager', false); |
|
| 99 | + foreach($pager as $item) |
|
| 100 | + { |
|
| 101 | + if($item->ControlToPaginate==$this->ID) { |
|
| 102 | + $writer=$this->getResponse()->createHtmlWriter(); |
|
| 103 | + $this->getPage()->getAdapter()->registerControlToRender($item,$writer); |
|
| 104 | + } |
|
| 105 | + } |
|
| 106 | 106 | } |
| 107 | 107 | |
| 108 | 108 | /** |
@@ -112,8 +112,8 @@ discard block |
||
| 112 | 112 | */ |
| 113 | 113 | private function renderDataList($writer) |
| 114 | 114 | { |
| 115 | - $writer->write('<span id="'.$this->getContainerID().'">'); |
|
| 116 | - parent::render($writer); |
|
| 117 | - $writer->write('</span>'); |
|
| 115 | + $writer->write('<span id="'.$this->getContainerID().'">'); |
|
| 116 | + parent::render($writer); |
|
| 117 | + $writer->write('</span>'); |
|
| 118 | 118 | } |
| 119 | 119 | } |
@@ -335,12 +335,12 @@ |
||
| 335 | 335 | return false; |
| 336 | 336 | } |
| 337 | 337 | |
| 338 | - /** |
|
| 339 | - * Returns all table names in the database. |
|
| 340 | - * @param string $schema the schema of the tables. Defaults to empty string, meaning the current or default schema. |
|
| 341 | - * If not empty, the returned table names will be prefixed with the schema name. |
|
| 342 | - * @return array all table names in the database. |
|
| 343 | - */ |
|
| 338 | + /** |
|
| 339 | + * Returns all table names in the database. |
|
| 340 | + * @param string $schema the schema of the tables. Defaults to empty string, meaning the current or default schema. |
|
| 341 | + * If not empty, the returned table names will be prefixed with the schema name. |
|
| 342 | + * @return array all table names in the database. |
|
| 343 | + */ |
|
| 344 | 344 | public function findTableNames($schema='') |
| 345 | 345 | { |
| 346 | 346 | if($schema==='') |
@@ -6,7 +6,7 @@ discard block |
||
| 6 | 6 | * @link https://github.com/pradosoft/prado |
| 7 | 7 | * @copyright Copyright © 2005-2016 The PRADO Group |
| 8 | 8 | * @license https://github.com/pradosoft/prado/blob/master/LICENSE |
| 9 | - * @package Prado\Data\ActiveRecord\Scaffold |
|
| 9 | + * @package Prado\Data\ActiveRecord\Scaffold |
|
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | 12 | namespace Prado\Data\ActiveRecord\Scaffold; |
@@ -32,7 +32,7 @@ discard block |
||
| 32 | 32 | * are database dependent). |
| 33 | 33 | * |
| 34 | 34 | * @author Wei Zhuo <weizhuo[at]gmail[dot]com> |
| 35 | - * @package Prado\Data\ActiveRecord\Scaffold |
|
| 35 | + * @package Prado\Data\ActiveRecord\Scaffold |
|
| 36 | 36 | * @since 3.1 |
| 37 | 37 | */ |
| 38 | 38 | class TScaffoldSearch extends TScaffoldBase |
@@ -6,7 +6,7 @@ discard block |
||
| 6 | 6 | * @link https://github.com/pradosoft/prado |
| 7 | 7 | * @copyright Copyright © 2005-2016 The PRADO Group |
| 8 | 8 | * @license https://github.com/pradosoft/prado/blob/master/LICENSE |
| 9 | - * @package Prado\Data\ActiveRecord\Scaffold |
|
| 9 | + * @package Prado\Data\ActiveRecord\Scaffold |
|
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | 12 | namespace Prado\Data\ActiveRecord\Scaffold; |
@@ -20,7 +20,7 @@ discard block |
||
| 20 | 20 | * that is called before the save() method is called on the TActiveRecord. |
| 21 | 21 | * |
| 22 | 22 | * @author Wei Zhuo <weizho[at]gmail[dot]com> |
| 23 | - * @package Prado\Data\ActiveRecord\Scaffold |
|
| 23 | + * @package Prado\Data\ActiveRecord\Scaffold |
|
| 24 | 24 | * @since 3.1 |
| 25 | 25 | */ |
| 26 | 26 | interface IScaffoldEditRenderer extends \Prado\IDataRenderer |
@@ -5,7 +5,7 @@ |
||
| 5 | 5 | * @link https://github.com/pradosoft/prado |
| 6 | 6 | * @copyright Copyright © 2005-2016 The PRADO Group |
| 7 | 7 | * @license https://github.com/pradosoft/prado/blob/master/LICENSE |
| 8 | - * @package Prado\Data\ActiveRecord\Scaffold\InputBuilder |
|
| 8 | + * @package Prado\Data\ActiveRecord\Scaffold\InputBuilder |
|
| 9 | 9 | */ |
| 10 | 10 | |
| 11 | 11 | namespace Prado\Data\ActiveRecord\Scaffold\InputBuilder; |
@@ -6,7 +6,7 @@ discard block |
||
| 6 | 6 | * @link https://github.com/pradosoft/prado |
| 7 | 7 | * @copyright Copyright © 2005-2016 The PRADO Group |
| 8 | 8 | * @license https://github.com/pradosoft/prado/blob/master/LICENSE |
| 9 | - * @package Prado\Data\ActiveRecord\Scaffold |
|
| 9 | + * @package Prado\Data\ActiveRecord\Scaffold |
|
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | 12 | namespace Prado\Data\ActiveRecord\Scaffold; |
@@ -32,7 +32,7 @@ discard block |
||
| 32 | 32 | * file explicitly. |
| 33 | 33 | * |
| 34 | 34 | * @author Wei Zhuo <weizho[at]gmail[dot]com> |
| 35 | - * @package Prado\Data\ActiveRecord\Scaffold |
|
| 35 | + * @package Prado\Data\ActiveRecord\Scaffold |
|
| 36 | 36 | * @since 3.1 |
| 37 | 37 | */ |
| 38 | 38 | abstract class TScaffoldBase extends TTemplateControl |
@@ -12,8 +12,8 @@ |
||
| 12 | 12 | namespace Prado\I18N; |
| 13 | 13 | |
| 14 | 14 | /** |
| 15 | - * Get the ChoiceFormat class. |
|
| 16 | - */ |
|
| 15 | + * Get the ChoiceFormat class. |
|
| 16 | + */ |
|
| 17 | 17 | use Prado\I18N\core\ChoiceFormat; |
| 18 | 18 | use Prado\Prado; |
| 19 | 19 | |
@@ -63,7 +63,7 @@ discard block |
||
| 63 | 63 | |
| 64 | 64 | /** |
| 65 | 65 | * Sets the horizontal alignment of the contents within the table item. |
| 66 | - * Valid values include 'NotSet', 'Justify', 'Left', 'Right', 'Center' |
|
| 66 | + * Valid values include 'NotSet', 'Justify', 'Left', 'Right', 'Center' |
|
| 67 | 67 | * @param string the horizontal alignment |
| 68 | 68 | */ |
| 69 | 69 | public function setHorizontalAlign($value) |
@@ -84,7 +84,7 @@ discard block |
||
| 84 | 84 | |
| 85 | 85 | /** |
| 86 | 86 | * Sets the vertical alignment of the contents within the table item. |
| 87 | - * Valid values include 'NotSet','Top','Bottom','Middle' |
|
| 87 | + * Valid values include 'NotSet','Top','Bottom','Middle' |
|
| 88 | 88 | * @param string the horizontal alignment |
| 89 | 89 | */ |
| 90 | 90 | public function setVerticalAlign($value) |