@@ -332,8 +332,8 @@ discard block |
||
| 332 | 332 | |
| 333 | 333 | /** |
| 334 | 334 | * @return boolean a value indicating whether an automatic postback to the server |
| 335 | - * will occur whenever the user makes change to the list control and then tabs out of it. |
|
| 336 | - * Defaults to false. |
|
| 335 | + * will occur whenever the user makes change to the list control and then tabs out of it. |
|
| 336 | + * Defaults to false. |
|
| 337 | 337 | */ |
| 338 | 338 | public function getAutoPostBack() |
| 339 | 339 | { |
@@ -589,23 +589,23 @@ discard block |
||
| 589 | 589 | * @param string the value of the item to be selected. |
| 590 | 590 | */ |
| 591 | 591 | public function setSelectedValue($value) |
| 592 | - { |
|
| 593 | - if($this->_items) |
|
| 594 | - { |
|
| 595 | - if($value===null) |
|
| 596 | - $this->clearSelection(); |
|
| 597 | - else if(($item=$this->_items->findItemByValue($value))!==null) |
|
| 598 | - { |
|
| 599 | - $this->clearSelection(); |
|
| 600 | - $item->setSelected(true); |
|
| 601 | - } |
|
| 602 | - else |
|
| 592 | + { |
|
| 593 | + if($this->_items) |
|
| 594 | + { |
|
| 595 | + if($value===null) |
|
| 596 | + $this->clearSelection(); |
|
| 597 | + else if(($item=$this->_items->findItemByValue($value))!==null) |
|
| 598 | + { |
|
| 599 | + $this->clearSelection(); |
|
| 600 | + $item->setSelected(true); |
|
| 601 | + } |
|
| 602 | + else |
|
| 603 | 603 | $this->clearSelection(); |
| 604 | - } |
|
| 605 | - $this->_cachedSelectedValue=$value; |
|
| 604 | + } |
|
| 605 | + $this->_cachedSelectedValue=$value; |
|
| 606 | 606 | if($this->getAdapter() instanceof IListControlAdapter) |
| 607 | 607 | $this->getAdapter()->setSelectedValue($value); |
| 608 | - } |
|
| 608 | + } |
|
| 609 | 609 | |
| 610 | 610 | |
| 611 | 611 | /** |
@@ -653,36 +653,36 @@ discard block |
||
| 653 | 653 | $this->getAdapter()->setSelectedValues($values); |
| 654 | 654 | } |
| 655 | 655 | |
| 656 | - /** |
|
| 657 | - * @return string selected value |
|
| 658 | - */ |
|
| 659 | - public function getText() |
|
| 660 | - { |
|
| 661 | - return $this->getSelectedValue(); |
|
| 662 | - } |
|
| 663 | - |
|
| 664 | - /** |
|
| 665 | - * @param string value to be selected |
|
| 666 | - */ |
|
| 667 | - public function setText($value) |
|
| 668 | - { |
|
| 669 | - $this->setSelectedValue($value); |
|
| 670 | - } |
|
| 671 | - |
|
| 672 | - /** |
|
| 673 | - * Clears all existing selections. |
|
| 674 | - */ |
|
| 675 | - public function clearSelection() |
|
| 676 | - { |
|
| 677 | - if($this->_items) |
|
| 678 | - { |
|
| 679 | - foreach($this->_items as $item) |
|
| 680 | - $item->setSelected(false); |
|
| 681 | - } |
|
| 656 | + /** |
|
| 657 | + * @return string selected value |
|
| 658 | + */ |
|
| 659 | + public function getText() |
|
| 660 | + { |
|
| 661 | + return $this->getSelectedValue(); |
|
| 662 | + } |
|
| 663 | + |
|
| 664 | + /** |
|
| 665 | + * @param string value to be selected |
|
| 666 | + */ |
|
| 667 | + public function setText($value) |
|
| 668 | + { |
|
| 669 | + $this->setSelectedValue($value); |
|
| 670 | + } |
|
| 671 | + |
|
| 672 | + /** |
|
| 673 | + * Clears all existing selections. |
|
| 674 | + */ |
|
| 675 | + public function clearSelection() |
|
| 676 | + { |
|
| 677 | + if($this->_items) |
|
| 678 | + { |
|
| 679 | + foreach($this->_items as $item) |
|
| 680 | + $item->setSelected(false); |
|
| 681 | + } |
|
| 682 | 682 | |
| 683 | 683 | if($this->getAdapter() instanceof IListControlAdapter) |
| 684 | 684 | $this->getAdapter()->clearSelection(); |
| 685 | - } |
|
| 685 | + } |
|
| 686 | 686 | |
| 687 | 687 | /** |
| 688 | 688 | * @return string the group of validators which the list control causes validation upon postback |
@@ -111,30 +111,30 @@ discard block |
||
| 111 | 111 | /** |
| 112 | 112 | * @var boolean controls the use of a persistent connection. Default to true. |
| 113 | 113 | */ |
| 114 | - private $_persistence = true; |
|
| 115 | - /** |
|
| 116 | - * @var integer number of buckets to create for this server which in turn control its |
|
| 117 | - * probability of it being selected. The probability is relative to the total weight |
|
| 118 | - * of all servers. |
|
| 119 | - */ |
|
| 120 | - private $_weight = 1; |
|
| 114 | + private $_persistence = true; |
|
| 115 | + /** |
|
| 116 | + * @var integer number of buckets to create for this server which in turn control its |
|
| 117 | + * probability of it being selected. The probability is relative to the total weight |
|
| 118 | + * of all servers. |
|
| 119 | + */ |
|
| 120 | + private $_weight = 1; |
|
| 121 | 121 | |
| 122 | - private $_timeout = 360; |
|
| 122 | + private $_timeout = 360; |
|
| 123 | 123 | |
| 124 | - private $_retryInterval = 15; |
|
| 124 | + private $_retryInterval = 15; |
|
| 125 | 125 | /** |
| 126 | - * @var integer Controls the minimum value length before attempting to compress automatically. |
|
| 127 | - */ |
|
| 128 | - private $_threshold=0; |
|
| 126 | + * @var integer Controls the minimum value length before attempting to compress automatically. |
|
| 127 | + */ |
|
| 128 | + private $_threshold=0; |
|
| 129 | 129 | |
| 130 | 130 | /** |
| 131 | - * @var float Specifies the minimum amount of savings to actually store the value compressed. The supplied value must be between 0 and 1. Default value is 0.2 giving a minimum 20% compression savings. |
|
| 132 | - */ |
|
| 133 | - private $_minSavings=0.0; |
|
| 131 | + * @var float Specifies the minimum amount of savings to actually store the value compressed. The supplied value must be between 0 and 1. Default value is 0.2 giving a minimum 20% compression savings. |
|
| 132 | + */ |
|
| 133 | + private $_minSavings=0.0; |
|
| 134 | 134 | |
| 135 | - private $_status = true; |
|
| 135 | + private $_status = true; |
|
| 136 | 136 | |
| 137 | - private $_failureCallback = null; |
|
| 137 | + private $_failureCallback = null; |
|
| 138 | 138 | |
| 139 | 139 | /** |
| 140 | 140 | * @var boolean whether to use memcached or memcache as the underlying caching extension. |
@@ -178,63 +178,63 @@ discard block |
||
| 178 | 178 | $this->_cache = $this->_useMemcached ? new Memcached : new Memcache; |
| 179 | 179 | $this->loadConfig($config); |
| 180 | 180 | if(count($this->_servers)) |
| 181 | - { |
|
| 182 | - foreach($this->_servers as $server) |
|
| 183 | - { |
|
| 184 | - Prado::trace('Adding server '.$server['Host'].' from serverlist', '\Prado\Caching\TMemCache'); |
|
| 185 | - if($this->_cache->addServer($server['Host'],$server['Port'],$server['Persistent'], |
|
| 186 | - $server['Weight'],$server['Timeout'],$server['RetryInterval'])===false) |
|
| 187 | - throw new TConfigurationException('memcache_connection_failed',$server['Host'],$server['Port']); |
|
| 188 | - } |
|
| 189 | - } |
|
| 190 | - else |
|
| 191 | - { |
|
| 192 | - Prado::trace('Adding server '.$this->_host, '\Prado\Caching\TMemCache'); |
|
| 193 | - if($this->_cache->addServer($this->_host,$this->_port)===false) |
|
| 194 | - throw new TConfigurationException('memcache_connection_failed',$this->_host,$this->_port); |
|
| 195 | - } |
|
| 181 | + { |
|
| 182 | + foreach($this->_servers as $server) |
|
| 183 | + { |
|
| 184 | + Prado::trace('Adding server '.$server['Host'].' from serverlist', '\Prado\Caching\TMemCache'); |
|
| 185 | + if($this->_cache->addServer($server['Host'],$server['Port'],$server['Persistent'], |
|
| 186 | + $server['Weight'],$server['Timeout'],$server['RetryInterval'])===false) |
|
| 187 | + throw new TConfigurationException('memcache_connection_failed',$server['Host'],$server['Port']); |
|
| 188 | + } |
|
| 189 | + } |
|
| 190 | + else |
|
| 191 | + { |
|
| 192 | + Prado::trace('Adding server '.$this->_host, '\Prado\Caching\TMemCache'); |
|
| 193 | + if($this->_cache->addServer($this->_host,$this->_port)===false) |
|
| 194 | + throw new TConfigurationException('memcache_connection_failed',$this->_host,$this->_port); |
|
| 195 | + } |
|
| 196 | 196 | if($this->_threshold!==0) |
| 197 | - $this->_cache->setCompressThreshold($this->_threshold,$this->_minSavings); |
|
| 197 | + $this->_cache->setCompressThreshold($this->_threshold,$this->_minSavings); |
|
| 198 | 198 | $this->_initialized=true; |
| 199 | 199 | parent::init($config); |
| 200 | 200 | } |
| 201 | 201 | |
| 202 | - /** |
|
| 202 | + /** |
|
| 203 | 203 | * Loads configuration from an XML element |
| 204 | 204 | * @param TXmlElement configuration node |
| 205 | 205 | * @throws TConfigurationException if log route class or type is not specified |
| 206 | 206 | */ |
| 207 | 207 | private function loadConfig($xml) |
| 208 | 208 | { |
| 209 | - if($xml instanceof TXmlElement) |
|
| 209 | + if($xml instanceof TXmlElement) |
|
| 210 | 210 | { |
| 211 | - foreach($xml->getElementsByTagName('server') as $serverConfig) |
|
| 212 | - { |
|
| 213 | - $properties=$serverConfig->getAttributes(); |
|
| 214 | - if(($host=$properties->remove('Host'))===null) |
|
| 215 | - throw new TConfigurationException('memcache_serverhost_required'); |
|
| 216 | - if(($port=$properties->remove('Port'))===null) |
|
| 217 | - throw new TConfigurationException('memcache_serverport_required'); |
|
| 218 | - if(!is_numeric($port)) |
|
| 219 | - throw new TConfigurationException('memcache_serverport_invalid'); |
|
| 220 | - $server = array('Host'=>$host,'Port'=>$port,'Weight'=>1,'Timeout'=>1800,'RetryInterval'=>15,'Persistent'=>true); |
|
| 221 | - $checks = array( |
|
| 222 | - 'Weight'=>'memcache_serverweight_invalid', |
|
| 223 | - 'Timeout'=>'memcache_servertimeout_invalid', |
|
| 224 | - 'RetryInterval'=>'memcach_serverretryinterval_invalid' |
|
| 225 | - ); |
|
| 226 | - foreach($checks as $property=>$exception) |
|
| 227 | - { |
|
| 228 | - $value=$properties->remove($property); |
|
| 229 | - if($value!==null && is_numeric($value)) |
|
| 230 | - $server[$property]=$value; |
|
| 231 | - else if($value!==null) |
|
| 232 | - throw new TConfigurationException($exception); |
|
| 233 | - } |
|
| 234 | - $server['Persistent']= TPropertyValue::ensureBoolean($properties->remove('Persistent')); |
|
| 235 | - $this->_servers[]=$server; |
|
| 236 | - } |
|
| 237 | - } |
|
| 211 | + foreach($xml->getElementsByTagName('server') as $serverConfig) |
|
| 212 | + { |
|
| 213 | + $properties=$serverConfig->getAttributes(); |
|
| 214 | + if(($host=$properties->remove('Host'))===null) |
|
| 215 | + throw new TConfigurationException('memcache_serverhost_required'); |
|
| 216 | + if(($port=$properties->remove('Port'))===null) |
|
| 217 | + throw new TConfigurationException('memcache_serverport_required'); |
|
| 218 | + if(!is_numeric($port)) |
|
| 219 | + throw new TConfigurationException('memcache_serverport_invalid'); |
|
| 220 | + $server = array('Host'=>$host,'Port'=>$port,'Weight'=>1,'Timeout'=>1800,'RetryInterval'=>15,'Persistent'=>true); |
|
| 221 | + $checks = array( |
|
| 222 | + 'Weight'=>'memcache_serverweight_invalid', |
|
| 223 | + 'Timeout'=>'memcache_servertimeout_invalid', |
|
| 224 | + 'RetryInterval'=>'memcach_serverretryinterval_invalid' |
|
| 225 | + ); |
|
| 226 | + foreach($checks as $property=>$exception) |
|
| 227 | + { |
|
| 228 | + $value=$properties->remove($property); |
|
| 229 | + if($value!==null && is_numeric($value)) |
|
| 230 | + $server[$property]=$value; |
|
| 231 | + else if($value!==null) |
|
| 232 | + throw new TConfigurationException($exception); |
|
| 233 | + } |
|
| 234 | + $server['Persistent']= TPropertyValue::ensureBoolean($properties->remove('Persistent')); |
|
| 235 | + $this->_servers[]=$server; |
|
| 236 | + } |
|
| 237 | + } |
|
| 238 | 238 | } |
| 239 | 239 | |
| 240 | 240 | /** |
@@ -178,12 +178,12 @@ discard block |
||
| 178 | 178 | public function validate() |
| 179 | 179 | { |
| 180 | 180 | if (! |
| 181 | - ( |
|
| 181 | + ( |
|
| 182 | 182 | ($challenge = @$_POST[$this->getChallengeFieldName()]) |
| 183 | 183 | and |
| 184 | 184 | ($response = @$_POST[$this->getResponseFieldName()]) |
| 185 | - ) |
|
| 186 | - ) |
|
| 185 | + ) |
|
| 186 | + ) |
|
| 187 | 187 | return false; |
| 188 | 188 | |
| 189 | 189 | return $this->recaptcha_check_answer( |
@@ -350,14 +350,14 @@ discard block |
||
| 350 | 350 | } |
| 351 | 351 | |
| 352 | 352 | /** |
| 353 | - * Calls an HTTP POST function to verify if the user's guess was correct |
|
| 354 | - * @param string $privkey |
|
| 355 | - * @param string $remoteip |
|
| 356 | - * @param string $challenge |
|
| 357 | - * @param string $response |
|
| 358 | - * @param array $extra_params an array of extra variables to post to the server |
|
| 359 | - * @return bool |
|
| 360 | - */ |
|
| 353 | + * Calls an HTTP POST function to verify if the user's guess was correct |
|
| 354 | + * @param string $privkey |
|
| 355 | + * @param string $remoteip |
|
| 356 | + * @param string $challenge |
|
| 357 | + * @param string $response |
|
| 358 | + * @param array $extra_params an array of extra variables to post to the server |
|
| 359 | + * @return bool |
|
| 360 | + */ |
|
| 361 | 361 | private function recaptcha_check_answer($privkey, $remoteip, $challenge, $response, $extra_params = array()) |
| 362 | 362 | { |
| 363 | 363 | //discard spam submissions |
@@ -26,13 +26,13 @@ |
||
| 26 | 26 | if(!defined('PRADO_DIR')) |
| 27 | 27 | define('PRADO_DIR', __DIR__); |
| 28 | 28 | /** |
| 29 | - * Defines the default permission for writable directories and files |
|
| 30 | - */ |
|
| 29 | + * Defines the default permission for writable directories and files |
|
| 30 | + */ |
|
| 31 | 31 | if(!defined('PRADO_CHMOD')) |
| 32 | 32 | define('PRADO_CHMOD',0777); |
| 33 | 33 | /** |
| 34 | - * Defines the Composer's vendor/ path. |
|
| 35 | - */ |
|
| 34 | + * Defines the Composer's vendor/ path. |
|
| 35 | + */ |
|
| 36 | 36 | if(!defined('PRADO_VENDORDIR')) |
| 37 | 37 | { |
| 38 | 38 | $reflector = new \ReflectionClass('\Composer\Autoload\ClassLoader'); |
@@ -623,31 +623,31 @@ discard block |
||
| 623 | 623 | */ |
| 624 | 624 | class PradoCommandLineActiveRecordGenAll extends PradoCommandLineAction |
| 625 | 625 | { |
| 626 | - protected $action = 'generateAll'; |
|
| 627 | - protected $parameters = array('output'); |
|
| 628 | - protected $optional = array('directory', 'soap', 'overwrite', 'prefix', 'postfix'); |
|
| 629 | - protected $description = "Generate Active Record skeleton for all Tables to <output> file using application.xml in [directory]. May also generate [soap] properties.\nGenerated Classes are named like the Table with optional [Prefix] and/or [Postfix]. [Overwrite] is used to overwrite existing Files."; |
|
| 630 | - private $_soap = false; |
|
| 631 | - private $_prefix = ''; |
|
| 632 | - private $_postfix = ''; |
|
| 633 | - private $_overwrite = false; |
|
| 634 | - |
|
| 635 | - public function performAction($args) { |
|
| 636 | - $app_dir = count($args) > 2 ? $this->getAppDir($args[2]) : $this->getAppDir(); |
|
| 637 | - $this->_soap = count($args) > 3 ? ($args[3] == "soap" || $args[3] == "true" ? true : false) : false; |
|
| 638 | - $this->_overwrite = count($args) > 4 ? ($args[4] == "overwrite" || $args[4] == "true" ? true : false) : false; |
|
| 639 | - $this->_prefix = count($args) > 5 ? $args[5] : ''; |
|
| 640 | - $this->_postfix = count($args) > 6 ? $args[6] : ''; |
|
| 641 | - |
|
| 642 | - if ($app_dir !== false) { |
|
| 643 | - $config = $this->getActiveRecordConfig($app_dir); |
|
| 644 | - |
|
| 645 | - $manager = TActiveRecordManager::getInstance(); |
|
| 646 | - $con = $manager->getDbConnection(); |
|
| 647 | - $con->Active = true; |
|
| 648 | - |
|
| 649 | - switch($con->getDriverName()) |
|
| 650 | - { |
|
| 626 | + protected $action = 'generateAll'; |
|
| 627 | + protected $parameters = array('output'); |
|
| 628 | + protected $optional = array('directory', 'soap', 'overwrite', 'prefix', 'postfix'); |
|
| 629 | + protected $description = "Generate Active Record skeleton for all Tables to <output> file using application.xml in [directory]. May also generate [soap] properties.\nGenerated Classes are named like the Table with optional [Prefix] and/or [Postfix]. [Overwrite] is used to overwrite existing Files."; |
|
| 630 | + private $_soap = false; |
|
| 631 | + private $_prefix = ''; |
|
| 632 | + private $_postfix = ''; |
|
| 633 | + private $_overwrite = false; |
|
| 634 | + |
|
| 635 | + public function performAction($args) { |
|
| 636 | + $app_dir = count($args) > 2 ? $this->getAppDir($args[2]) : $this->getAppDir(); |
|
| 637 | + $this->_soap = count($args) > 3 ? ($args[3] == "soap" || $args[3] == "true" ? true : false) : false; |
|
| 638 | + $this->_overwrite = count($args) > 4 ? ($args[4] == "overwrite" || $args[4] == "true" ? true : false) : false; |
|
| 639 | + $this->_prefix = count($args) > 5 ? $args[5] : ''; |
|
| 640 | + $this->_postfix = count($args) > 6 ? $args[6] : ''; |
|
| 641 | + |
|
| 642 | + if ($app_dir !== false) { |
|
| 643 | + $config = $this->getActiveRecordConfig($app_dir); |
|
| 644 | + |
|
| 645 | + $manager = TActiveRecordManager::getInstance(); |
|
| 646 | + $con = $manager->getDbConnection(); |
|
| 647 | + $con->Active = true; |
|
| 648 | + |
|
| 649 | + switch($con->getDriverName()) |
|
| 650 | + { |
|
| 651 | 651 | case 'mysqli': |
| 652 | 652 | case 'mysql': |
| 653 | 653 | $command = $con->createCommand("SHOW TABLES"); |
@@ -665,27 +665,27 @@ discard block |
||
| 665 | 665 | default: |
| 666 | 666 | echo "\n Sorry, generateAll is not implemented for ".$con->getDriverName()."\n"; |
| 667 | 667 | |
| 668 | - } |
|
| 669 | - |
|
| 670 | - $dataReader = $command->query(); |
|
| 671 | - $dataReader->bindColumn(1, $table); |
|
| 672 | - $tables = array(); |
|
| 673 | - while ($dataReader->read() !== false) { |
|
| 674 | - $tables[] = $table; |
|
| 675 | - } |
|
| 676 | - $con->Active = False; |
|
| 677 | - foreach ($tables as $key => $table) { |
|
| 678 | - $output = $args[1] . "." . $this->_prefix . ucfirst($table) . $this->_postfix; |
|
| 679 | - if ($config !== false && $output !== false) { |
|
| 680 | - $this->generate("generate " . $table . " " . $output . " " . $this->_soap . " " . $this->_overwrite); |
|
| 681 | - } |
|
| 682 | - } |
|
| 683 | - } |
|
| 684 | - return true; |
|
| 685 | - } |
|
| 686 | - |
|
| 687 | - public function generate($l) |
|
| 688 | - { |
|
| 668 | + } |
|
| 669 | + |
|
| 670 | + $dataReader = $command->query(); |
|
| 671 | + $dataReader->bindColumn(1, $table); |
|
| 672 | + $tables = array(); |
|
| 673 | + while ($dataReader->read() !== false) { |
|
| 674 | + $tables[] = $table; |
|
| 675 | + } |
|
| 676 | + $con->Active = False; |
|
| 677 | + foreach ($tables as $key => $table) { |
|
| 678 | + $output = $args[1] . "." . $this->_prefix . ucfirst($table) . $this->_postfix; |
|
| 679 | + if ($config !== false && $output !== false) { |
|
| 680 | + $this->generate("generate " . $table . " " . $output . " " . $this->_soap . " " . $this->_overwrite); |
|
| 681 | + } |
|
| 682 | + } |
|
| 683 | + } |
|
| 684 | + return true; |
|
| 685 | + } |
|
| 686 | + |
|
| 687 | + public function generate($l) |
|
| 688 | + { |
|
| 689 | 689 | $input = explode(" ", trim($l)); |
| 690 | 690 | if(count($input) > 2) |
| 691 | 691 | { |
@@ -702,49 +702,49 @@ discard block |
||
| 702 | 702 | { |
| 703 | 703 | echo "\n Usage: generate table_name Application.pages.RecordClassName\n"; |
| 704 | 704 | } |
| 705 | - } |
|
| 706 | - |
|
| 707 | - protected function getAppDir($dir=".") { |
|
| 708 | - if (is_dir($dir)) |
|
| 709 | - return realpath($dir); |
|
| 710 | - if (false !== ($app_dir = realpath($dir . '/protected/')) && is_dir($app_dir)) |
|
| 711 | - return $app_dir; |
|
| 712 | - echo '** Unable to find directory "' . $dir . "\".\n"; |
|
| 713 | - return false; |
|
| 714 | - } |
|
| 715 | - |
|
| 716 | - protected function getXmlFile($app_dir) { |
|
| 717 | - if (false !== ($xml = realpath($app_dir . '/application.xml')) && is_file($xml)) |
|
| 718 | - return $xml; |
|
| 719 | - if (false !== ($xml = realpath($app_dir . '/protected/application.xml')) && is_file($xml)) |
|
| 720 | - return $xml; |
|
| 721 | - echo '** Unable to find application.xml in ' . $app_dir . "\n"; |
|
| 722 | - return false; |
|
| 723 | - } |
|
| 724 | - |
|
| 725 | - protected function getActiveRecordConfig($app_dir) { |
|
| 726 | - if (false === ($xml = $this->getXmlFile($app_dir))) |
|
| 727 | - return false; |
|
| 728 | - if (false !== ($app = $this->initializePradoApplication($app_dir))) { |
|
| 729 | - Prado::using('System.Data.ActiveRecord.TActiveRecordConfig'); |
|
| 730 | - foreach ($app->getModules() as $module) |
|
| 731 | - if ($module instanceof TActiveRecordConfig) |
|
| 732 | - return $module; |
|
| 733 | - echo '** Unable to find TActiveRecordConfig module in ' . $xml . "\n"; |
|
| 734 | - } |
|
| 735 | - return false; |
|
| 736 | - } |
|
| 737 | - |
|
| 738 | - protected function getOutputFile($app_dir, $namespace) { |
|
| 739 | - if (is_file($namespace) && strpos($namespace, $app_dir) === 0) |
|
| 740 | - return $namespace; |
|
| 741 | - $file = Prado::getPathOfNamespace($namespace, ""); |
|
| 742 | - if ($file !== null && false !== ($path = realpath(dirname($file))) && is_dir($path)) { |
|
| 743 | - if (strpos($path, $app_dir) === 0) |
|
| 744 | - return $file; |
|
| 745 | - } |
|
| 746 | - echo '** Output file ' . $file . ' must be within directory ' . $app_dir . "\n"; |
|
| 747 | - return false; |
|
| 748 | - } |
|
| 705 | + } |
|
| 706 | + |
|
| 707 | + protected function getAppDir($dir=".") { |
|
| 708 | + if (is_dir($dir)) |
|
| 709 | + return realpath($dir); |
|
| 710 | + if (false !== ($app_dir = realpath($dir . '/protected/')) && is_dir($app_dir)) |
|
| 711 | + return $app_dir; |
|
| 712 | + echo '** Unable to find directory "' . $dir . "\".\n"; |
|
| 713 | + return false; |
|
| 714 | + } |
|
| 715 | + |
|
| 716 | + protected function getXmlFile($app_dir) { |
|
| 717 | + if (false !== ($xml = realpath($app_dir . '/application.xml')) && is_file($xml)) |
|
| 718 | + return $xml; |
|
| 719 | + if (false !== ($xml = realpath($app_dir . '/protected/application.xml')) && is_file($xml)) |
|
| 720 | + return $xml; |
|
| 721 | + echo '** Unable to find application.xml in ' . $app_dir . "\n"; |
|
| 722 | + return false; |
|
| 723 | + } |
|
| 724 | + |
|
| 725 | + protected function getActiveRecordConfig($app_dir) { |
|
| 726 | + if (false === ($xml = $this->getXmlFile($app_dir))) |
|
| 727 | + return false; |
|
| 728 | + if (false !== ($app = $this->initializePradoApplication($app_dir))) { |
|
| 729 | + Prado::using('System.Data.ActiveRecord.TActiveRecordConfig'); |
|
| 730 | + foreach ($app->getModules() as $module) |
|
| 731 | + if ($module instanceof TActiveRecordConfig) |
|
| 732 | + return $module; |
|
| 733 | + echo '** Unable to find TActiveRecordConfig module in ' . $xml . "\n"; |
|
| 734 | + } |
|
| 735 | + return false; |
|
| 736 | + } |
|
| 737 | + |
|
| 738 | + protected function getOutputFile($app_dir, $namespace) { |
|
| 739 | + if (is_file($namespace) && strpos($namespace, $app_dir) === 0) |
|
| 740 | + return $namespace; |
|
| 741 | + $file = Prado::getPathOfNamespace($namespace, ""); |
|
| 742 | + if ($file !== null && false !== ($path = realpath(dirname($file))) && is_dir($path)) { |
|
| 743 | + if (strpos($path, $app_dir) === 0) |
|
| 744 | + return $file; |
|
| 745 | + } |
|
| 746 | + echo '** Output file ' . $file . ' must be within directory ' . $app_dir . "\n"; |
|
| 747 | + return false; |
|
| 748 | + } |
|
| 749 | 749 | |
| 750 | 750 | } |
@@ -54,8 +54,8 @@ discard block |
||
| 54 | 54 | * It reads the CacheModule property. |
| 55 | 55 | * @param TXmlElement module configuration |
| 56 | 56 | */ |
| 57 | - public function init($config) |
|
| 58 | - { |
|
| 57 | + public function init($config) |
|
| 58 | + { |
|
| 59 | 59 | if($this->_cacheModuleID==='') |
| 60 | 60 | throw new TConfigurationException('cachesession_cachemoduleid_required'); |
| 61 | 61 | else if(($cache=$this->getApplication()->getModule($this->_cacheModuleID))===null) |
@@ -66,7 +66,7 @@ discard block |
||
| 66 | 66 | throw new TConfigurationException('cachesession_cachemodule_invalid',$this->_cacheModuleID); |
| 67 | 67 | $this->setUseCustomStorage(true); |
| 68 | 68 | parent::init($config); |
| 69 | - } |
|
| 69 | + } |
|
| 70 | 70 | |
| 71 | 71 | /** |
| 72 | 72 | * @return string the ID of the cache module. |
@@ -99,7 +99,7 @@ discard block |
||
| 99 | 99 | */ |
| 100 | 100 | public function _read($id) |
| 101 | 101 | { |
| 102 | - return (string)$this->_cache->get($this->calculateKey($id)); |
|
| 102 | + return (string)$this->_cache->get($this->calculateKey($id)); |
|
| 103 | 103 | } |
| 104 | 104 | |
| 105 | 105 | /** |
@@ -121,7 +121,7 @@ discard block |
||
| 121 | 121 | */ |
| 122 | 122 | public function _destroy($id) |
| 123 | 123 | { |
| 124 | - return $this->_cache->delete($this->calculateKey($id)); |
|
| 124 | + return $this->_cache->delete($this->calculateKey($id)); |
|
| 125 | 125 | } |
| 126 | 126 | |
| 127 | 127 | /** |
@@ -129,15 +129,15 @@ discard block |
||
| 129 | 129 | */ |
| 130 | 130 | public function getKeyPrefix() |
| 131 | 131 | { |
| 132 | - return $this->_prefix; |
|
| 132 | + return $this->_prefix; |
|
| 133 | 133 | } |
| 134 | 134 | |
| 135 | 135 | /** |
| 136 | - * @param string prefix of session variable name to avoid conflict with other cache data |
|
| 137 | - */ |
|
| 136 | + * @param string prefix of session variable name to avoid conflict with other cache data |
|
| 137 | + */ |
|
| 138 | 138 | public function setKeyPrefix($value) |
| 139 | 139 | { |
| 140 | - $this->_prefix=$value; |
|
| 140 | + $this->_prefix=$value; |
|
| 141 | 141 | } |
| 142 | 142 | |
| 143 | 143 | /** |
@@ -146,7 +146,7 @@ discard block |
||
| 146 | 146 | */ |
| 147 | 147 | protected function calculateKey($id) |
| 148 | 148 | { |
| 149 | - return $this->_prefix.':'.$id; |
|
| 149 | + return $this->_prefix.':'.$id; |
|
| 150 | 150 | } |
| 151 | 151 | } |
| 152 | 152 | |
@@ -74,7 +74,6 @@ discard block |
||
| 74 | 74 | * </code> |
| 75 | 75 | * where {@link setHost Host} and {@link setPort Port} or {@link setSocket Socket} are configurable properties |
| 76 | 76 | * of TRedisCache. |
| 77 | - |
|
| 78 | 77 | * @author Jens Klaer <[email protected]> |
| 79 | 78 | * @author LANDWEHR Computer und Software GmbH |
| 80 | 79 | * @since 4.0 |
@@ -112,8 +111,8 @@ discard block |
||
| 112 | 111 | */ |
| 113 | 112 | public function __destruct() |
| 114 | 113 | { |
| 115 | - if ($this->_cache instanceof \Redis) |
|
| 116 | - $this->_cache->close(); |
|
| 114 | + if ($this->_cache instanceof \Redis) |
|
| 115 | + $this->_cache->close(); |
|
| 117 | 116 | } |
| 118 | 117 | |
| 119 | 118 | /** |
@@ -125,21 +124,21 @@ discard block |
||
| 125 | 124 | */ |
| 126 | 125 | public function init($config) |
| 127 | 126 | { |
| 128 | - if (!extension_loaded('redis') || !class_exists('\Redis', false)) |
|
| 129 | - throw new TConfigurationException('rediscache_extension_required'); |
|
| 130 | - $this->_cache = new \Redis(); |
|
| 131 | - if ($this->_socket !== null) |
|
| 132 | - $this->_cache->connect($this->_socket); |
|
| 133 | - else |
|
| 134 | - $this->_cache->connect($this->_host, $this->_port); |
|
| 135 | - $this->_cache->setOption(\Redis::OPT_SERIALIZER, \Redis::SERIALIZER_PHP); |
|
| 136 | - $this->_cache->select($this->_index); |
|
| 137 | - parent::init($config); |
|
| 138 | - $this->_initialized = true; |
|
| 127 | + if (!extension_loaded('redis') || !class_exists('\Redis', false)) |
|
| 128 | + throw new TConfigurationException('rediscache_extension_required'); |
|
| 129 | + $this->_cache = new \Redis(); |
|
| 130 | + if ($this->_socket !== null) |
|
| 131 | + $this->_cache->connect($this->_socket); |
|
| 132 | + else |
|
| 133 | + $this->_cache->connect($this->_host, $this->_port); |
|
| 134 | + $this->_cache->setOption(\Redis::OPT_SERIALIZER, \Redis::SERIALIZER_PHP); |
|
| 135 | + $this->_cache->select($this->_index); |
|
| 136 | + parent::init($config); |
|
| 137 | + $this->_initialized = true; |
|
| 139 | 138 | } |
| 140 | 139 | |
| 141 | 140 | public function valid($key) { |
| 142 | - return true; |
|
| 141 | + return true; |
|
| 143 | 142 | } |
| 144 | 143 | |
| 145 | 144 | /** |
@@ -147,7 +146,7 @@ discard block |
||
| 147 | 146 | */ |
| 148 | 147 | public function getHost() |
| 149 | 148 | { |
| 150 | - return $this->_host; |
|
| 149 | + return $this->_host; |
|
| 151 | 150 | } |
| 152 | 151 | |
| 153 | 152 | /** |
@@ -156,10 +155,10 @@ discard block |
||
| 156 | 155 | */ |
| 157 | 156 | public function setHost($value) |
| 158 | 157 | { |
| 159 | - if ($this->_initialized) |
|
| 160 | - throw new TInvalidOperationException('rediscache_host_unchangeable'); |
|
| 161 | - else |
|
| 162 | - $this->_host = $value; |
|
| 158 | + if ($this->_initialized) |
|
| 159 | + throw new TInvalidOperationException('rediscache_host_unchangeable'); |
|
| 160 | + else |
|
| 161 | + $this->_host = $value; |
|
| 163 | 162 | } |
| 164 | 163 | |
| 165 | 164 | /** |
@@ -167,7 +166,7 @@ discard block |
||
| 167 | 166 | */ |
| 168 | 167 | public function getPort() |
| 169 | 168 | { |
| 170 | - return $this->_port; |
|
| 169 | + return $this->_port; |
|
| 171 | 170 | } |
| 172 | 171 | |
| 173 | 172 | /** |
@@ -176,10 +175,10 @@ discard block |
||
| 176 | 175 | */ |
| 177 | 176 | public function setPort($value) |
| 178 | 177 | { |
| 179 | - if ($this->_initialized) |
|
| 180 | - throw new TInvalidOperationException('rediscache_port_unchangeable'); |
|
| 181 | - else |
|
| 182 | - $this->_port = TPropertyValue::ensureInteger($value); |
|
| 178 | + if ($this->_initialized) |
|
| 179 | + throw new TInvalidOperationException('rediscache_port_unchangeable'); |
|
| 180 | + else |
|
| 181 | + $this->_port = TPropertyValue::ensureInteger($value); |
|
| 183 | 182 | } |
| 184 | 183 | |
| 185 | 184 | /** |
@@ -187,7 +186,7 @@ discard block |
||
| 187 | 186 | */ |
| 188 | 187 | public function getSocket() |
| 189 | 188 | { |
| 190 | - return $this->_socket; |
|
| 189 | + return $this->_socket; |
|
| 191 | 190 | } |
| 192 | 191 | |
| 193 | 192 | /** |
@@ -196,10 +195,10 @@ discard block |
||
| 196 | 195 | */ |
| 197 | 196 | public function setSocket($value) |
| 198 | 197 | { |
| 199 | - if($this->_initialized) |
|
| 200 | - throw new TInvalidOperationException('rediscache_socket_unchangeable'); |
|
| 201 | - else |
|
| 202 | - $this->_socket = TPropertyValue::ensureString($value); |
|
| 198 | + if($this->_initialized) |
|
| 199 | + throw new TInvalidOperationException('rediscache_socket_unchangeable'); |
|
| 200 | + else |
|
| 201 | + $this->_socket = TPropertyValue::ensureString($value); |
|
| 203 | 202 | } |
| 204 | 203 | |
| 205 | 204 | /** |
@@ -207,7 +206,7 @@ discard block |
||
| 207 | 206 | */ |
| 208 | 207 | public function getIndex() |
| 209 | 208 | { |
| 210 | - return $this->_index; |
|
| 209 | + return $this->_index; |
|
| 211 | 210 | } |
| 212 | 211 | |
| 213 | 212 | /** |
@@ -216,10 +215,10 @@ discard block |
||
| 216 | 215 | */ |
| 217 | 216 | public function setIndex($value) |
| 218 | 217 | { |
| 219 | - if ($this->_initialized) |
|
| 220 | - throw new TInvalidOperationException('rediscache_index_unchangeable'); |
|
| 221 | - else |
|
| 222 | - $this->_index = TPropertyValue::ensureInteger($value); |
|
| 218 | + if ($this->_initialized) |
|
| 219 | + throw new TInvalidOperationException('rediscache_index_unchangeable'); |
|
| 220 | + else |
|
| 221 | + $this->_index = TPropertyValue::ensureInteger($value); |
|
| 223 | 222 | } |
| 224 | 223 | |
| 225 | 224 | /** |
@@ -230,7 +229,7 @@ discard block |
||
| 230 | 229 | */ |
| 231 | 230 | protected function getValue($key) |
| 232 | 231 | { |
| 233 | - return $this->_cache->get($key); |
|
| 232 | + return $this->_cache->get($key); |
|
| 234 | 233 | } |
| 235 | 234 | |
| 236 | 235 | /** |
@@ -244,8 +243,8 @@ discard block |
||
| 244 | 243 | */ |
| 245 | 244 | protected function setValue($key, $value, $expire) |
| 246 | 245 | { |
| 247 | - $options = $expire === 0 ? array() : array('ex' => $expire); |
|
| 248 | - return $this->_cache->set($key, $value, $options); |
|
| 246 | + $options = $expire === 0 ? array() : array('ex' => $expire); |
|
| 247 | + return $this->_cache->set($key, $value, $options); |
|
| 249 | 248 | } |
| 250 | 249 | |
| 251 | 250 | /** |
@@ -259,8 +258,8 @@ discard block |
||
| 259 | 258 | */ |
| 260 | 259 | protected function addValue($key, $value, $expire) |
| 261 | 260 | { |
| 262 | - $options = $expire === 0 ? array('nx') : array('nx', 'ex' => $expire); |
|
| 263 | - return $this->_cache->set($key, $value, $options); |
|
| 261 | + $options = $expire === 0 ? array('nx') : array('nx', 'ex' => $expire); |
|
| 262 | + return $this->_cache->set($key, $value, $options); |
|
| 264 | 263 | } |
| 265 | 264 | |
| 266 | 265 | /** |
@@ -271,8 +270,8 @@ discard block |
||
| 271 | 270 | */ |
| 272 | 271 | protected function deleteValue($key) |
| 273 | 272 | { |
| 274 | - $this->_cache->delete($key); |
|
| 275 | - return true; |
|
| 273 | + $this->_cache->delete($key); |
|
| 274 | + return true; |
|
| 276 | 275 | } |
| 277 | 276 | |
| 278 | 277 | /** |
@@ -280,7 +279,7 @@ discard block |
||
| 280 | 279 | */ |
| 281 | 280 | public function flush() |
| 282 | 281 | { |
| 283 | - return $this->_cache->flushDB(); |
|
| 282 | + return $this->_cache->flushDB(); |
|
| 284 | 283 | } |
| 285 | 284 | } |
| 286 | 285 | |
@@ -83,9 +83,9 @@ discard block |
||
| 83 | 83 | } |
| 84 | 84 | |
| 85 | 85 | /** |
| 86 | - * Gets the host the etcd instance is running on, defaults to 'localhost'. |
|
| 87 | - * @return string the etcd host |
|
| 88 | - */ |
|
| 86 | + * Gets the host the etcd instance is running on, defaults to 'localhost'. |
|
| 87 | + * @return string the etcd host |
|
| 88 | + */ |
|
| 89 | 89 | public function getHost() { |
| 90 | 90 | return $this->_host; |
| 91 | 91 | } |
@@ -95,13 +95,13 @@ discard block |
||
| 95 | 95 | * @param string $value the etcd host |
| 96 | 96 | */ |
| 97 | 97 | public function setHost($value) { |
| 98 | - $this->_host = TPropertyValue::ensureString($value); |
|
| 98 | + $this->_host = TPropertyValue::ensureString($value); |
|
| 99 | 99 | } |
| 100 | 100 | |
| 101 | 101 | /** |
| 102 | - * Gets the port the etcd instance is running on, defaults to 2379. |
|
| 103 | - * @return integer the etcd port |
|
| 104 | - */ |
|
| 102 | + * Gets the port the etcd instance is running on, defaults to 2379. |
|
| 103 | + * @return integer the etcd port |
|
| 104 | + */ |
|
| 105 | 105 | public function getPort() { |
| 106 | 106 | return $this->_port; |
| 107 | 107 | } |
@@ -111,13 +111,13 @@ discard block |
||
| 111 | 111 | * @param integer $value the etcd port |
| 112 | 112 | */ |
| 113 | 113 | public function setPort($value) { |
| 114 | - $this->_port = TPropertyValue::ensureInteger($value); |
|
| 114 | + $this->_port = TPropertyValue::ensureInteger($value); |
|
| 115 | 115 | } |
| 116 | 116 | |
| 117 | 117 | /** |
| 118 | - * Sets the directory to store values in, defaults to 'pradocache'. |
|
| 119 | - * @return string the directory to store values in |
|
| 120 | - */ |
|
| 118 | + * Sets the directory to store values in, defaults to 'pradocache'. |
|
| 119 | + * @return string the directory to store values in |
|
| 120 | + */ |
|
| 121 | 121 | public function getDir() { |
| 122 | 122 | return $this->_dir; |
| 123 | 123 | } |
@@ -127,7 +127,7 @@ discard block |
||
| 127 | 127 | * @param string $value the directory to store values in |
| 128 | 128 | */ |
| 129 | 129 | public function setDir($value) { |
| 130 | - $this->_dir = TPropertyValue::ensureString($value); |
|
| 130 | + $this->_dir = TPropertyValue::ensureString($value); |
|
| 131 | 131 | } |
| 132 | 132 | |
| 133 | 133 | /** |
@@ -139,7 +139,7 @@ discard block |
||
| 139 | 139 | protected function getValue($key) |
| 140 | 140 | { |
| 141 | 141 | $result = $this->request('GET', $this->_dir . '/' . $key); |
| 142 | - return property_exists($result, 'errorCode') ? false : unserialize($result->node->value); |
|
| 142 | + return property_exists($result, 'errorCode') ? false : unserialize($result->node->value); |
|
| 143 | 143 | } |
| 144 | 144 | |
| 145 | 145 | /** |
@@ -153,10 +153,10 @@ discard block |
||
| 153 | 153 | */ |
| 154 | 154 | protected function setValue($key, $value, $expire) |
| 155 | 155 | { |
| 156 | - $value = array('value' => serialize($value)); |
|
| 157 | - if ($expire > 0) $value['ttl'] = $expire; |
|
| 156 | + $value = array('value' => serialize($value)); |
|
| 157 | + if ($expire > 0) $value['ttl'] = $expire; |
|
| 158 | 158 | $result = $this->request('PUT', $this->_dir . '/' . $key, $value); |
| 159 | - return !property_exists($result, 'errorCode'); |
|
| 159 | + return !property_exists($result, 'errorCode'); |
|
| 160 | 160 | } |
| 161 | 161 | |
| 162 | 162 | /** |
@@ -170,10 +170,10 @@ discard block |
||
| 170 | 170 | */ |
| 171 | 171 | protected function addValue($key, $value, $expire) |
| 172 | 172 | { |
| 173 | - $value = array('value' => serialize($value), 'prevExist' => 'false'); |
|
| 174 | - if ($expire > 0) $value['ttl'] = $expire; |
|
| 173 | + $value = array('value' => serialize($value), 'prevExist' => 'false'); |
|
| 174 | + if ($expire > 0) $value['ttl'] = $expire; |
|
| 175 | 175 | $result = $this->request('PUT', $this->_dir . '/' . $key, $value); |
| 176 | - return !property_exists($result, 'errorCode'); |
|
| 176 | + return !property_exists($result, 'errorCode'); |
|
| 177 | 177 | } |
| 178 | 178 | |
| 179 | 179 | /** |
@@ -185,7 +185,7 @@ discard block |
||
| 185 | 185 | protected function deleteValue($key) |
| 186 | 186 | { |
| 187 | 187 | $this->request('DELETE', $this->_dir . '/' . $key); |
| 188 | - return true; |
|
| 188 | + return true; |
|
| 189 | 189 | } |
| 190 | 190 | |
| 191 | 191 | /** |
@@ -194,30 +194,30 @@ discard block |
||
| 194 | 194 | */ |
| 195 | 195 | public function flush() |
| 196 | 196 | { |
| 197 | - $this->request('DELETE', $this->_dir . '?recursive=true'); |
|
| 197 | + $this->request('DELETE', $this->_dir . '?recursive=true'); |
|
| 198 | 198 | } |
| 199 | 199 | |
| 200 | 200 | /** |
| 201 | - * This method does the actual cURL request by generating the method specific |
|
| 202 | - * URL, setting the cURL options and adding additional request parameters. |
|
| 203 | - * The etcd always returns a JSON string which is decoded and returned to |
|
| 204 | - * the calling method. |
|
| 205 | - * @param string the HTTP method for the request (GET,PUT,DELETE) |
|
| 206 | - * @param string the the key to perform the action on (includes the directory) |
|
| 207 | - * @param array the additional post data to send with the request |
|
| 208 | - * @return \stdClass the response from the etcd instance |
|
| 209 | - */ |
|
| 201 | + * This method does the actual cURL request by generating the method specific |
|
| 202 | + * URL, setting the cURL options and adding additional request parameters. |
|
| 203 | + * The etcd always returns a JSON string which is decoded and returned to |
|
| 204 | + * the calling method. |
|
| 205 | + * @param string the HTTP method for the request (GET,PUT,DELETE) |
|
| 206 | + * @param string the the key to perform the action on (includes the directory) |
|
| 207 | + * @param array the additional post data to send with the request |
|
| 208 | + * @return \stdClass the response from the etcd instance |
|
| 209 | + */ |
|
| 210 | 210 | protected function request($method, $key, $value=array()) { |
| 211 | - $curl = curl_init("http://{$this->_host}:{$this->_port}/v2/keys/{$key}"); |
|
| 212 | - curl_setopt($curl, CURLOPT_CUSTOMREQUEST, $method); |
|
| 213 | - curl_setopt($curl, CURLOPT_HEADER, false); |
|
| 214 | - curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); |
|
| 215 | - curl_setopt($curl, CURLOPT_FOLLOWLOCATION, false); |
|
| 216 | - curl_setopt($curl, CURLOPT_HTTPHEADER, array('Content-Type: application/x-www-form-urlencoded')); |
|
| 217 | - curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($value)); |
|
| 218 | - $response = curl_exec($curl); |
|
| 219 | - curl_close($curl); |
|
| 220 | - return json_decode($response); |
|
| 211 | + $curl = curl_init("http://{$this->_host}:{$this->_port}/v2/keys/{$key}"); |
|
| 212 | + curl_setopt($curl, CURLOPT_CUSTOMREQUEST, $method); |
|
| 213 | + curl_setopt($curl, CURLOPT_HEADER, false); |
|
| 214 | + curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); |
|
| 215 | + curl_setopt($curl, CURLOPT_FOLLOWLOCATION, false); |
|
| 216 | + curl_setopt($curl, CURLOPT_HTTPHEADER, array('Content-Type: application/x-www-form-urlencoded')); |
|
| 217 | + curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($value)); |
|
| 218 | + $response = curl_exec($curl); |
|
| 219 | + curl_close($curl); |
|
| 220 | + return json_decode($response); |
|
| 221 | 221 | } |
| 222 | 222 | |
| 223 | 223 | } |
| 224 | 224 | \ No newline at end of file |
@@ -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 | } |