@@ -44,8 +44,8 @@ |
||
44 | 44 | */ |
45 | 45 | public function setSelectedValues($values); |
46 | 46 | |
47 | - /** |
|
48 | - * Clears all existing selections on the client side. |
|
49 | - */ |
|
50 | - public function clearSelection(); |
|
47 | + /** |
|
48 | + * Clears all existing selections on the client side. |
|
49 | + */ |
|
50 | + public function clearSelection(); |
|
51 | 51 | } |
52 | 52 | \ No newline at end of file |
@@ -225,13 +225,13 @@ |
||
225 | 225 | */ |
226 | 226 | public function getIsValid() |
227 | 227 | { |
228 | - return $this->_isValid; |
|
228 | + return $this->_isValid; |
|
229 | 229 | } |
230 | 230 | /** |
231 | 231 | * @param bool wether this control is valid. |
232 | 232 | */ |
233 | 233 | public function setIsValid($value) |
234 | 234 | { |
235 | - $this->_isValid=TPropertyValue::ensureBoolean($value); |
|
235 | + $this->_isValid=TPropertyValue::ensureBoolean($value); |
|
236 | 236 | } |
237 | 237 | } |
238 | 238 | \ No newline at end of file |
@@ -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 |