@@ -59,7 +59,7 @@ |
||
| 59 | 59 | |
| 60 | 60 | $tmp = $data; |
| 61 | 61 | foreach (explode(".", $field) as $f) |
| 62 | - $tmp = $tmp[$f]; |
|
| 62 | + $tmp = $tmp[$f]; |
|
| 63 | 63 | return $tmp; |
| 64 | 64 | } |
| 65 | 65 | else if(is_object($data)) |
@@ -48,7 +48,7 @@ discard block |
||
| 48 | 48 | * @return mixed value at the specified field |
| 49 | 49 | * @throws TInvalidDataValueException if field or data is invalid |
| 50 | 50 | */ |
| 51 | - public static function getDataFieldValue($data,$field) |
|
| 51 | + public static function getDataFieldValue($data, $field) |
|
| 52 | 52 | { |
| 53 | 53 | try |
| 54 | 54 | { |
@@ -57,33 +57,33 @@ discard block |
||
| 57 | 57 | if(isset($data[$field])) |
| 58 | 58 | return $data[$field]; |
| 59 | 59 | |
| 60 | - $tmp = $data; |
|
| 61 | - foreach (explode(".", $field) as $f) |
|
| 62 | - $tmp = $tmp[$f]; |
|
| 60 | + $tmp=$data; |
|
| 61 | + foreach(explode(".", $field) as $f) |
|
| 62 | + $tmp=$tmp[$f]; |
|
| 63 | 63 | return $tmp; |
| 64 | 64 | } |
| 65 | 65 | else if(is_object($data)) |
| 66 | 66 | { |
| 67 | - if(strpos($field,'.')===false) // simple field |
|
| 67 | + if(strpos($field, '.')===false) // simple field |
|
| 68 | 68 | { |
| 69 | 69 | if(method_exists($data, 'get'.$field)) |
| 70 | - return call_user_func(array($data,'get'.$field)); |
|
| 70 | + return call_user_func(array($data, 'get'.$field)); |
|
| 71 | 71 | else |
| 72 | 72 | return $data->{$field}; |
| 73 | 73 | } |
| 74 | 74 | else // field in the format of xxx.yyy.zzz |
| 75 | 75 | { |
| 76 | 76 | $object=$data; |
| 77 | - foreach(explode('.',$field) as $f) |
|
| 78 | - $object = TDataFieldAccessor::getDataFieldValue($object, $f); |
|
| 77 | + foreach(explode('.', $field) as $f) |
|
| 78 | + $object=TDataFieldAccessor::getDataFieldValue($object, $f); |
|
| 79 | 79 | return $object; |
| 80 | 80 | } |
| 81 | 81 | } |
| 82 | 82 | } |
| 83 | 83 | catch(Exception $e) |
| 84 | 84 | { |
| 85 | - throw new TInvalidDataValueException('datafieldaccessor_datafield_invalid',$field,$e->getMessage()); |
|
| 85 | + throw new TInvalidDataValueException('datafieldaccessor_datafield_invalid', $field, $e->getMessage()); |
|
| 86 | 86 | } |
| 87 | - throw new TInvalidDataValueException('datafieldaccessor_data_invalid',$field); |
|
| 87 | + throw new TInvalidDataValueException('datafieldaccessor_data_invalid', $field); |
|
| 88 | 88 | } |
| 89 | 89 | } |
@@ -61,8 +61,7 @@ discard block |
||
| 61 | 61 | foreach (explode(".", $field) as $f) |
| 62 | 62 | $tmp = $tmp[$f]; |
| 63 | 63 | return $tmp; |
| 64 | - } |
|
| 65 | - else if(is_object($data)) |
|
| 64 | + } else if(is_object($data)) |
|
| 66 | 65 | { |
| 67 | 66 | if(strpos($field,'.')===false) // simple field |
| 68 | 67 | { |
@@ -70,8 +69,7 @@ discard block |
||
| 70 | 69 | return call_user_func(array($data,'get'.$field)); |
| 71 | 70 | else |
| 72 | 71 | return $data->{$field}; |
| 73 | - } |
|
| 74 | - else // field in the format of xxx.yyy.zzz |
|
| 72 | + } else // field in the format of xxx.yyy.zzz |
|
| 75 | 73 | { |
| 76 | 74 | $object=$data; |
| 77 | 75 | foreach(explode('.',$field) as $f) |
@@ -79,8 +77,7 @@ discard block |
||
| 79 | 77 | return $object; |
| 80 | 78 | } |
| 81 | 79 | } |
| 82 | - } |
|
| 83 | - catch(Exception $e) |
|
| 80 | + } catch(Exception $e) |
|
| 84 | 81 | { |
| 85 | 82 | throw new TInvalidDataValueException('datafieldaccessor_datafield_invalid',$field,$e->getMessage()); |
| 86 | 83 | } |
@@ -1,13 +1,12 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | - * TDateTimeStamp class file. |
|
| 4 | - |
|
| 5 | - * @author Fabio Bas ctrlaltca[AT]gmail[DOT]com |
|
| 6 | - * @link https://github.com/pradosoft/prado |
|
| 7 | - * @copyright Copyright © 2005-2015 The PRADO Group |
|
| 8 | - * @license https://github.com/pradosoft/prado/blob/master/COPYRIGHT |
|
| 9 | - * @package System.Util |
|
| 10 | - */ |
|
| 3 | + * TDateTimeStamp class file. |
|
| 4 | + * @author Fabio Bas ctrlaltca[AT]gmail[DOT]com |
|
| 5 | + * @link https://github.com/pradosoft/prado |
|
| 6 | + * @copyright Copyright © 2005-2015 The PRADO Group |
|
| 7 | + * @license https://github.com/pradosoft/prado/blob/master/COPYRIGHT |
|
| 8 | + * @package System.Util |
|
| 9 | + */ |
|
| 11 | 10 | |
| 12 | 11 | /** |
| 13 | 12 | * TDateTimeStamp Class |
@@ -186,7 +185,7 @@ discard block |
||
| 186 | 185 | |
| 187 | 186 | /** |
| 188 | 187 | * @return integer|float a timestamp given a local time |
| 189 | - */ |
|
| 188 | + */ |
|
| 190 | 189 | function getTimeStamp($hr,$min,$sec,$mon=false,$day=false,$year=false,$is_gmt=false) |
| 191 | 190 | { |
| 192 | 191 | $dt = new DateTime(); |
@@ -185,7 +185,7 @@ |
||
| 185 | 185 | } |
| 186 | 186 | |
| 187 | 187 | /** |
| 188 | - * @return integer|float a timestamp given a local time |
|
| 188 | + * @return integer a timestamp given a local time |
|
| 189 | 189 | */ |
| 190 | 190 | function getTimeStamp($hr,$min,$sec,$mon=false,$day=false,$year=false,$is_gmt=false) |
| 191 | 191 | { |
@@ -25,8 +25,8 @@ discard block |
||
| 25 | 25 | */ |
| 26 | 26 | class TDateTimeStamp |
| 27 | 27 | { |
| 28 | - protected static $_month_normal = array("",31,28,31,30,31,30,31,31,30,31,30,31); |
|
| 29 | - protected static $_month_leaf = array("",31,29,31,30,31,30,31,31,30,31,30,31); |
|
| 28 | + protected static $_month_normal=array("", 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31); |
|
| 29 | + protected static $_month_leaf=array("", 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31); |
|
| 30 | 30 | |
| 31 | 31 | /** |
| 32 | 32 | * Returns the day of the week (0=Sunday, 1=Monday, .. 6=Saturday) |
@@ -36,7 +36,7 @@ discard block |
||
| 36 | 36 | */ |
| 37 | 37 | public function getDayofWeek($year, $month, $day) |
| 38 | 38 | { |
| 39 | - $dt = new DateTime(); |
|
| 39 | + $dt=new DateTime(); |
|
| 40 | 40 | $dt->setDate($year, $month, $day); |
| 41 | 41 | return (int) $dt->format('w'); |
| 42 | 42 | } |
@@ -49,8 +49,8 @@ discard block |
||
| 49 | 49 | */ |
| 50 | 50 | public function isLeapYear($year) |
| 51 | 51 | { |
| 52 | - $year = $this->digitCheck($year); |
|
| 53 | - $dt = new DateTime(); |
|
| 52 | + $year=$this->digitCheck($year); |
|
| 53 | + $dt=new DateTime(); |
|
| 54 | 54 | $dt->setDate($year, 1, 1); |
| 55 | 55 | return (bool) $dt->format('L'); |
| 56 | 56 | } |
@@ -62,22 +62,22 @@ discard block |
||
| 62 | 62 | */ |
| 63 | 63 | protected function digitCheck($y) |
| 64 | 64 | { |
| 65 | - if ($y < 100){ |
|
| 66 | - $yr = (integer) date("Y"); |
|
| 67 | - $century = (integer) ($yr /100); |
|
| 65 | + if($y < 100) { |
|
| 66 | + $yr=(integer) date("Y"); |
|
| 67 | + $century=(integer) ($yr / 100); |
|
| 68 | 68 | |
| 69 | - if ($yr%100 > 50) { |
|
| 70 | - $c1 = $century + 1; |
|
| 71 | - $c0 = $century; |
|
| 69 | + if($yr % 100 > 50) { |
|
| 70 | + $c1=$century + 1; |
|
| 71 | + $c0=$century; |
|
| 72 | 72 | } else { |
| 73 | - $c1 = $century; |
|
| 74 | - $c0 = $century - 1; |
|
| 73 | + $c1=$century; |
|
| 74 | + $c0=$century - 1; |
|
| 75 | 75 | } |
| 76 | - $c1 *= 100; |
|
| 76 | + $c1*=100; |
|
| 77 | 77 | // if 2-digit year is less than 30 years in future, set it to this century |
| 78 | 78 | // otherwise if more than 30 years in future, then we set 2-digit year to the prev century. |
| 79 | - if (($y + $c1) < $yr+30) $y = $y + $c1; |
|
| 80 | - else $y = $y + $c0*100; |
|
| 79 | + if(($y + $c1) < $yr + 30) $y=$y + $c1; |
|
| 80 | + else $y=$y + $c0 * 100; |
|
| 81 | 81 | } |
| 82 | 82 | return $y; |
| 83 | 83 | } |
@@ -92,7 +92,7 @@ discard block |
||
| 92 | 92 | */ |
| 93 | 93 | public function getGMTDiff($ts=false) |
| 94 | 94 | { |
| 95 | - $dt = new DateTime(); |
|
| 95 | + $dt=new DateTime(); |
|
| 96 | 96 | if($ts) |
| 97 | 97 | $dt->setTimeStamp($ts); |
| 98 | 98 | else |
@@ -106,9 +106,9 @@ discard block |
||
| 106 | 106 | */ |
| 107 | 107 | function parseDate($txt=false) |
| 108 | 108 | { |
| 109 | - if ($txt === false) return getdate(); |
|
| 109 | + if($txt===false) return getdate(); |
|
| 110 | 110 | |
| 111 | - $dt = new DateTime($txt); |
|
| 111 | + $dt=new DateTime($txt); |
|
| 112 | 112 | |
| 113 | 113 | return array( |
| 114 | 114 | 'seconds' => (int) $dt->format('s'), |
@@ -128,11 +128,11 @@ discard block |
||
| 128 | 128 | /** |
| 129 | 129 | * @return array an array with date info. |
| 130 | 130 | */ |
| 131 | - function getDate($d=false,$fast=false) |
|
| 131 | + function getDate($d=false, $fast=false) |
|
| 132 | 132 | { |
| 133 | - if ($d === false) return getdate(); |
|
| 133 | + if($d===false) return getdate(); |
|
| 134 | 134 | |
| 135 | - $dt = new DateTime(); |
|
| 135 | + $dt=new DateTime(); |
|
| 136 | 136 | $dt->setTimestamp($d); |
| 137 | 137 | |
| 138 | 138 | return array( |
@@ -153,20 +153,20 @@ discard block |
||
| 153 | 153 | /** |
| 154 | 154 | * @return boolean true if valid date, semantic check only. |
| 155 | 155 | */ |
| 156 | - public function isValidDate($y,$m,$d) |
|
| 156 | + public function isValidDate($y, $m, $d) |
|
| 157 | 157 | { |
| 158 | - if ($this->isLeapYear($y)) |
|
| 159 | - $marr =& self::$_month_leaf; |
|
| 158 | + if($this->isLeapYear($y)) |
|
| 159 | + $marr=& self::$_month_leaf; |
|
| 160 | 160 | else |
| 161 | - $marr =& self::$_month_normal; |
|
| 161 | + $marr=& self::$_month_normal; |
|
| 162 | 162 | |
| 163 | - if ($m > 12 || $m < 1) return false; |
|
| 163 | + if($m > 12 || $m < 1) return false; |
|
| 164 | 164 | |
| 165 | - if ($d > 31 || $d < 1) return false; |
|
| 165 | + if($d > 31 || $d < 1) return false; |
|
| 166 | 166 | |
| 167 | - if ($marr[$m] < $d) return false; |
|
| 167 | + if($marr[$m] < $d) return false; |
|
| 168 | 168 | |
| 169 | - if ($y < 1000 && $y > 3000) return false; |
|
| 169 | + if($y < 1000 && $y > 3000) return false; |
|
| 170 | 170 | |
| 171 | 171 | return true; |
| 172 | 172 | } |
@@ -174,9 +174,9 @@ discard block |
||
| 174 | 174 | /** |
| 175 | 175 | * @return string formatted date based on timestamp $d |
| 176 | 176 | */ |
| 177 | - function formatDate($fmt,$ts=false,$is_gmt=false) |
|
| 177 | + function formatDate($fmt, $ts=false, $is_gmt=false) |
|
| 178 | 178 | { |
| 179 | - $dt = new DateTime(); |
|
| 179 | + $dt=new DateTime(); |
|
| 180 | 180 | if($is_gmt) |
| 181 | 181 | $dt->setTimeZone(new DateTimeZone('UTC')); |
| 182 | 182 | $dt->setTimestamp($ts); |
@@ -187,9 +187,9 @@ discard block |
||
| 187 | 187 | /** |
| 188 | 188 | * @return integer|float a timestamp given a local time |
| 189 | 189 | */ |
| 190 | - function getTimeStamp($hr,$min,$sec,$mon=false,$day=false,$year=false,$is_gmt=false) |
|
| 190 | + function getTimeStamp($hr, $min, $sec, $mon=false, $day=false, $year=false, $is_gmt=false) |
|
| 191 | 191 | { |
| 192 | - $dt = new DateTime(); |
|
| 192 | + $dt=new DateTime(); |
|
| 193 | 193 | if($is_gmt) |
| 194 | 194 | $dt->setTimeZone(new DateTimeZone('UTC')); |
| 195 | 195 | $dt->setDate($year!==false ? $year : date('Y'), |
@@ -104,30 +104,30 @@ discard block |
||
| 104 | 104 | /** |
| 105 | 105 | * @var boolean controls the use of a persistent connection. Default to true. |
| 106 | 106 | */ |
| 107 | - private $_persistence = true; |
|
| 108 | - /** |
|
| 109 | - * @var integer number of buckets to create for this server which in turn control its |
|
| 110 | - * probability of it being selected. The probability is relative to the total weight |
|
| 111 | - * of all servers. |
|
| 112 | - */ |
|
| 113 | - private $_weight = 1; |
|
| 107 | + private $_persistence = true; |
|
| 108 | + /** |
|
| 109 | + * @var integer number of buckets to create for this server which in turn control its |
|
| 110 | + * probability of it being selected. The probability is relative to the total weight |
|
| 111 | + * of all servers. |
|
| 112 | + */ |
|
| 113 | + private $_weight = 1; |
|
| 114 | 114 | |
| 115 | - private $_timeout = 360; |
|
| 115 | + private $_timeout = 360; |
|
| 116 | 116 | |
| 117 | - private $_retryInterval = 15; |
|
| 117 | + private $_retryInterval = 15; |
|
| 118 | 118 | /** |
| 119 | - * @var integer Controls the minimum value length before attempting to compress automatically. |
|
| 120 | - */ |
|
| 121 | - private $_threshold=0; |
|
| 119 | + * @var integer Controls the minimum value length before attempting to compress automatically. |
|
| 120 | + */ |
|
| 121 | + private $_threshold=0; |
|
| 122 | 122 | |
| 123 | 123 | /** |
| 124 | - * @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. |
|
| 125 | - */ |
|
| 126 | - private $_minSavings=0.0; |
|
| 124 | + * @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. |
|
| 125 | + */ |
|
| 126 | + private $_minSavings=0.0; |
|
| 127 | 127 | |
| 128 | - private $_status = true; |
|
| 128 | + private $_status = true; |
|
| 129 | 129 | |
| 130 | - private $_failureCallback = null; |
|
| 130 | + private $_failureCallback = null; |
|
| 131 | 131 | |
| 132 | 132 | /** |
| 133 | 133 | * @var boolean whether to use memcached or memcache as the underlying caching extension. |
@@ -171,63 +171,63 @@ discard block |
||
| 171 | 171 | $this->_cache = $this->_useMemcached ? new Memcached : new Memcache; |
| 172 | 172 | $this->loadConfig($config); |
| 173 | 173 | if(count($this->_servers)) |
| 174 | - { |
|
| 175 | - foreach($this->_servers as $server) |
|
| 176 | - { |
|
| 177 | - Prado::trace('Adding server '.$server['Host'].' from serverlist', 'System.Caching.TMemCache'); |
|
| 178 | - if($this->_cache->addServer($server['Host'],$server['Port'],$server['Persistent'], |
|
| 179 | - $server['Weight'],$server['Timeout'],$server['RetryInterval'])===false) |
|
| 180 | - throw new TConfigurationException('memcache_connection_failed',$server['Host'],$server['Port']); |
|
| 181 | - } |
|
| 182 | - } |
|
| 183 | - else |
|
| 184 | - { |
|
| 185 | - Prado::trace('Adding server '.$this->_host, 'System.Caching.TMemCache'); |
|
| 186 | - if($this->_cache->addServer($this->_host,$this->_port)===false) |
|
| 187 | - throw new TConfigurationException('memcache_connection_failed',$this->_host,$this->_port); |
|
| 188 | - } |
|
| 174 | + { |
|
| 175 | + foreach($this->_servers as $server) |
|
| 176 | + { |
|
| 177 | + Prado::trace('Adding server '.$server['Host'].' from serverlist', 'System.Caching.TMemCache'); |
|
| 178 | + if($this->_cache->addServer($server['Host'],$server['Port'],$server['Persistent'], |
|
| 179 | + $server['Weight'],$server['Timeout'],$server['RetryInterval'])===false) |
|
| 180 | + throw new TConfigurationException('memcache_connection_failed',$server['Host'],$server['Port']); |
|
| 181 | + } |
|
| 182 | + } |
|
| 183 | + else |
|
| 184 | + { |
|
| 185 | + Prado::trace('Adding server '.$this->_host, 'System.Caching.TMemCache'); |
|
| 186 | + if($this->_cache->addServer($this->_host,$this->_port)===false) |
|
| 187 | + throw new TConfigurationException('memcache_connection_failed',$this->_host,$this->_port); |
|
| 188 | + } |
|
| 189 | 189 | if($this->_threshold!==0) |
| 190 | - $this->_cache->setCompressThreshold($this->_threshold,$this->_minSavings); |
|
| 190 | + $this->_cache->setCompressThreshold($this->_threshold,$this->_minSavings); |
|
| 191 | 191 | $this->_initialized=true; |
| 192 | 192 | parent::init($config); |
| 193 | 193 | } |
| 194 | 194 | |
| 195 | - /** |
|
| 195 | + /** |
|
| 196 | 196 | * Loads configuration from an XML element |
| 197 | 197 | * @param TXmlElement configuration node |
| 198 | 198 | * @throws TConfigurationException if log route class or type is not specified |
| 199 | 199 | */ |
| 200 | 200 | private function loadConfig($xml) |
| 201 | 201 | { |
| 202 | - if($xml instanceof TXmlElement) |
|
| 202 | + if($xml instanceof TXmlElement) |
|
| 203 | 203 | { |
| 204 | - foreach($xml->getElementsByTagName('server') as $serverConfig) |
|
| 205 | - { |
|
| 206 | - $properties=$serverConfig->getAttributes(); |
|
| 207 | - if(($host=$properties->remove('Host'))===null) |
|
| 208 | - throw new TConfigurationException('memcache_serverhost_required'); |
|
| 209 | - if(($port=$properties->remove('Port'))===null) |
|
| 210 | - throw new TConfigurationException('memcache_serverport_required'); |
|
| 211 | - if(!is_numeric($port)) |
|
| 212 | - throw new TConfigurationException('memcache_serverport_invalid'); |
|
| 213 | - $server = array('Host'=>$host,'Port'=>$port,'Weight'=>1,'Timeout'=>1800,'RetryInterval'=>15,'Persistent'=>true); |
|
| 214 | - $checks = array( |
|
| 215 | - 'Weight'=>'memcache_serverweight_invalid', |
|
| 216 | - 'Timeout'=>'memcache_servertimeout_invalid', |
|
| 217 | - 'RetryInterval'=>'memcach_serverretryinterval_invalid' |
|
| 218 | - ); |
|
| 219 | - foreach($checks as $property=>$exception) |
|
| 220 | - { |
|
| 221 | - $value=$properties->remove($property); |
|
| 222 | - if($value!==null && is_numeric($value)) |
|
| 223 | - $server[$property]=$value; |
|
| 224 | - else if($value!==null) |
|
| 225 | - throw new TConfigurationException($exception); |
|
| 226 | - } |
|
| 227 | - $server['Persistent']= TPropertyValue::ensureBoolean($properties->remove('Persistent')); |
|
| 228 | - $this->_servers[]=$server; |
|
| 229 | - } |
|
| 230 | - } |
|
| 204 | + foreach($xml->getElementsByTagName('server') as $serverConfig) |
|
| 205 | + { |
|
| 206 | + $properties=$serverConfig->getAttributes(); |
|
| 207 | + if(($host=$properties->remove('Host'))===null) |
|
| 208 | + throw new TConfigurationException('memcache_serverhost_required'); |
|
| 209 | + if(($port=$properties->remove('Port'))===null) |
|
| 210 | + throw new TConfigurationException('memcache_serverport_required'); |
|
| 211 | + if(!is_numeric($port)) |
|
| 212 | + throw new TConfigurationException('memcache_serverport_invalid'); |
|
| 213 | + $server = array('Host'=>$host,'Port'=>$port,'Weight'=>1,'Timeout'=>1800,'RetryInterval'=>15,'Persistent'=>true); |
|
| 214 | + $checks = array( |
|
| 215 | + 'Weight'=>'memcache_serverweight_invalid', |
|
| 216 | + 'Timeout'=>'memcache_servertimeout_invalid', |
|
| 217 | + 'RetryInterval'=>'memcach_serverretryinterval_invalid' |
|
| 218 | + ); |
|
| 219 | + foreach($checks as $property=>$exception) |
|
| 220 | + { |
|
| 221 | + $value=$properties->remove($property); |
|
| 222 | + if($value!==null && is_numeric($value)) |
|
| 223 | + $server[$property]=$value; |
|
| 224 | + else if($value!==null) |
|
| 225 | + throw new TConfigurationException($exception); |
|
| 226 | + } |
|
| 227 | + $server['Persistent']= TPropertyValue::ensureBoolean($properties->remove('Persistent')); |
|
| 228 | + $this->_servers[]=$server; |
|
| 229 | + } |
|
| 230 | + } |
|
| 231 | 231 | } |
| 232 | 232 | |
| 233 | 233 | /** |
@@ -104,17 +104,17 @@ discard block |
||
| 104 | 104 | /** |
| 105 | 105 | * @var boolean controls the use of a persistent connection. Default to true. |
| 106 | 106 | */ |
| 107 | - private $_persistence = true; |
|
| 107 | + private $_persistence=true; |
|
| 108 | 108 | /** |
| 109 | 109 | * @var integer number of buckets to create for this server which in turn control its |
| 110 | 110 | * probability of it being selected. The probability is relative to the total weight |
| 111 | 111 | * of all servers. |
| 112 | 112 | */ |
| 113 | - private $_weight = 1; |
|
| 113 | + private $_weight=1; |
|
| 114 | 114 | |
| 115 | - private $_timeout = 360; |
|
| 115 | + private $_timeout=360; |
|
| 116 | 116 | |
| 117 | - private $_retryInterval = 15; |
|
| 117 | + private $_retryInterval=15; |
|
| 118 | 118 | /** |
| 119 | 119 | * @var integer Controls the minimum value length before attempting to compress automatically. |
| 120 | 120 | */ |
@@ -125,9 +125,9 @@ discard block |
||
| 125 | 125 | */ |
| 126 | 126 | private $_minSavings=0.0; |
| 127 | 127 | |
| 128 | - private $_status = true; |
|
| 128 | + private $_status=true; |
|
| 129 | 129 | |
| 130 | - private $_failureCallback = null; |
|
| 130 | + private $_failureCallback=null; |
|
| 131 | 131 | |
| 132 | 132 | /** |
| 133 | 133 | * @var boolean whether to use memcached or memcache as the underlying caching extension. |
@@ -168,26 +168,26 @@ discard block |
||
| 168 | 168 | if(!extension_loaded('memcached') && $this->_useMemcached) |
| 169 | 169 | throw new TConfigurationException('memcached_extension_required'); |
| 170 | 170 | |
| 171 | - $this->_cache = $this->_useMemcached ? new Memcached : new Memcache; |
|
| 171 | + $this->_cache=$this->_useMemcached ? new Memcached : new Memcache; |
|
| 172 | 172 | $this->loadConfig($config); |
| 173 | 173 | if(count($this->_servers)) |
| 174 | 174 | { |
| 175 | 175 | foreach($this->_servers as $server) |
| 176 | 176 | { |
| 177 | 177 | Prado::trace('Adding server '.$server['Host'].' from serverlist', 'System.Caching.TMemCache'); |
| 178 | - if($this->_cache->addServer($server['Host'],$server['Port'],$server['Persistent'], |
|
| 179 | - $server['Weight'],$server['Timeout'],$server['RetryInterval'])===false) |
|
| 180 | - throw new TConfigurationException('memcache_connection_failed',$server['Host'],$server['Port']); |
|
| 178 | + if($this->_cache->addServer($server['Host'], $server['Port'], $server['Persistent'], |
|
| 179 | + $server['Weight'], $server['Timeout'], $server['RetryInterval'])===false) |
|
| 180 | + throw new TConfigurationException('memcache_connection_failed', $server['Host'], $server['Port']); |
|
| 181 | 181 | } |
| 182 | 182 | } |
| 183 | 183 | else |
| 184 | 184 | { |
| 185 | 185 | Prado::trace('Adding server '.$this->_host, 'System.Caching.TMemCache'); |
| 186 | - if($this->_cache->addServer($this->_host,$this->_port)===false) |
|
| 187 | - throw new TConfigurationException('memcache_connection_failed',$this->_host,$this->_port); |
|
| 186 | + if($this->_cache->addServer($this->_host, $this->_port)===false) |
|
| 187 | + throw new TConfigurationException('memcache_connection_failed', $this->_host, $this->_port); |
|
| 188 | 188 | } |
| 189 | 189 | if($this->_threshold!==0) |
| 190 | - $this->_cache->setCompressThreshold($this->_threshold,$this->_minSavings); |
|
| 190 | + $this->_cache->setCompressThreshold($this->_threshold, $this->_minSavings); |
|
| 191 | 191 | $this->_initialized=true; |
| 192 | 192 | parent::init($config); |
| 193 | 193 | } |
@@ -210,8 +210,8 @@ discard block |
||
| 210 | 210 | throw new TConfigurationException('memcache_serverport_required'); |
| 211 | 211 | if(!is_numeric($port)) |
| 212 | 212 | throw new TConfigurationException('memcache_serverport_invalid'); |
| 213 | - $server = array('Host'=>$host,'Port'=>$port,'Weight'=>1,'Timeout'=>1800,'RetryInterval'=>15,'Persistent'=>true); |
|
| 214 | - $checks = array( |
|
| 213 | + $server=array('Host'=>$host, 'Port'=>$port, 'Weight'=>1, 'Timeout'=>1800, 'RetryInterval'=>15, 'Persistent'=>true); |
|
| 214 | + $checks=array( |
|
| 215 | 215 | 'Weight'=>'memcache_serverweight_invalid', |
| 216 | 216 | 'Timeout'=>'memcache_servertimeout_invalid', |
| 217 | 217 | 'RetryInterval'=>'memcach_serverretryinterval_invalid' |
@@ -224,7 +224,7 @@ discard block |
||
| 224 | 224 | else if($value!==null) |
| 225 | 225 | throw new TConfigurationException($exception); |
| 226 | 226 | } |
| 227 | - $server['Persistent']= TPropertyValue::ensureBoolean($properties->remove('Persistent')); |
|
| 227 | + $server['Persistent']=TPropertyValue::ensureBoolean($properties->remove('Persistent')); |
|
| 228 | 228 | $this->_servers[]=$server; |
| 229 | 229 | } |
| 230 | 230 | } |
@@ -350,12 +350,12 @@ discard block |
||
| 350 | 350 | * @param integer the number of seconds in which the cached value will expire. 0 means never expire. |
| 351 | 351 | * @return boolean true if the value is successfully stored into cache, false otherwise |
| 352 | 352 | */ |
| 353 | - protected function setValue($key,$value,$expire) |
|
| 353 | + protected function setValue($key, $value, $expire) |
|
| 354 | 354 | { |
| 355 | 355 | if($this->_useMemcached) { |
| 356 | - return $this->_cache->set($key,$value,$expire); |
|
| 356 | + return $this->_cache->set($key, $value, $expire); |
|
| 357 | 357 | } else { |
| 358 | - return $this->_cache->set($key,$value,0,$expire); |
|
| 358 | + return $this->_cache->set($key, $value, 0, $expire); |
|
| 359 | 359 | } |
| 360 | 360 | } |
| 361 | 361 | |
@@ -368,12 +368,12 @@ discard block |
||
| 368 | 368 | * @param integer the number of seconds in which the cached value will expire. 0 means never expire. |
| 369 | 369 | * @return boolean true if the value is successfully stored into cache, false otherwise |
| 370 | 370 | */ |
| 371 | - protected function addValue($key,$value,$expire) |
|
| 371 | + protected function addValue($key, $value, $expire) |
|
| 372 | 372 | { |
| 373 | 373 | if($this->_useMemcached) { |
| 374 | - $this->_cache->add($key,$value,$expire); |
|
| 374 | + $this->_cache->add($key, $value, $expire); |
|
| 375 | 375 | } else { |
| 376 | - return $this->_cache->add($key,$value,0,$expire); |
|
| 376 | + return $this->_cache->add($key, $value, 0, $expire); |
|
| 377 | 377 | } |
| 378 | 378 | } |
| 379 | 379 | |
@@ -124,8 +124,7 @@ |
||
| 124 | 124 | if (!@mysql_select_db($dsninfo['database'], $conn)) |
| 125 | 125 | throw new Exception('Error in connecting database, dns:'. |
| 126 | 126 | $dsninfo); |
| 127 | - } |
|
| 128 | - else |
|
| 127 | + } else |
|
| 129 | 128 | throw new Exception('Please provide a database for message'. |
| 130 | 129 | ' translation.'); |
| 131 | 130 | return $conn; |
@@ -139,9 +139,9 @@ |
||
| 139 | 139 | $feed->init($feedConfig); |
| 140 | 140 | |
| 141 | 141 | $content=$feed->getFeedContent(); |
| 142 | - //$this->getResponse()->setContentType('application/rss+xml'); |
|
| 143 | - $this->getResponse()->setContentType($feed->getContentType()); |
|
| 144 | - $this->getResponse()->write($content); |
|
| 142 | + //$this->getResponse()->setContentType('application/rss+xml'); |
|
| 143 | + $this->getResponse()->setContentType($feed->getContentType()); |
|
| 144 | + $this->getResponse()->write($content); |
|
| 145 | 145 | } |
| 146 | 146 | else |
| 147 | 147 | throw new THttpException(404,'feedservice_feed_unknown',$id); |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | if(is_array($config)) |
| 73 | 73 | { |
| 74 | 74 | foreach($config as $id => $feed) |
| 75 | - $this->_feeds[$id] = $feed; |
|
| 75 | + $this->_feeds[$id]=$feed; |
|
| 76 | 76 | } |
| 77 | 77 | } |
| 78 | 78 | else |
@@ -105,20 +105,20 @@ discard block |
||
| 105 | 105 | if(isset($this->_feeds[$id])) |
| 106 | 106 | { |
| 107 | 107 | $feedConfig=$this->_feeds[$id]; |
| 108 | - $properties = array(); |
|
| 109 | - $feed = null; |
|
| 108 | + $properties=array(); |
|
| 109 | + $feed=null; |
|
| 110 | 110 | if($this->getApplication()->getConfigurationType()==TApplication::CONFIG_TYPE_PHP) |
| 111 | 111 | { |
| 112 | 112 | if(isset($feedConfig['class'])) |
| 113 | 113 | { |
| 114 | 114 | $feed=Prado::createComponent($feedConfig['class']); |
| 115 | 115 | if($service instanceof IFeedContentProvider) |
| 116 | - $properties=isset($feedConfig['properties'])?$feedConfig['properties']:array(); |
|
| 116 | + $properties=isset($feedConfig['properties']) ? $feedConfig['properties'] : array(); |
|
| 117 | 117 | else |
| 118 | - throw new TConfigurationException('jsonservice_response_type_invalid',$id); |
|
| 118 | + throw new TConfigurationException('jsonservice_response_type_invalid', $id); |
|
| 119 | 119 | } |
| 120 | 120 | else |
| 121 | - throw new TConfigurationException('jsonservice_class_required',$id); |
|
| 121 | + throw new TConfigurationException('jsonservice_class_required', $id); |
|
| 122 | 122 | } |
| 123 | 123 | else |
| 124 | 124 | { |
@@ -127,15 +127,15 @@ discard block |
||
| 127 | 127 | { |
| 128 | 128 | $feed=Prado::createComponent($class); |
| 129 | 129 | if(!($feed instanceof IFeedContentProvider)) |
| 130 | - throw new TConfigurationException('feedservice_feedtype_invalid',$id); |
|
| 130 | + throw new TConfigurationException('feedservice_feedtype_invalid', $id); |
|
| 131 | 131 | } |
| 132 | 132 | else |
| 133 | - throw new TConfigurationException('feedservice_class_required',$id); |
|
| 133 | + throw new TConfigurationException('feedservice_class_required', $id); |
|
| 134 | 134 | } |
| 135 | 135 | |
| 136 | 136 | // init feed properties |
| 137 | 137 | foreach($properties as $name=>$value) |
| 138 | - $feed->setSubproperty($name,$value); |
|
| 138 | + $feed->setSubproperty($name, $value); |
|
| 139 | 139 | $feed->init($feedConfig); |
| 140 | 140 | |
| 141 | 141 | $content=$feed->getFeedContent(); |
@@ -144,7 +144,7 @@ discard block |
||
| 144 | 144 | $this->getResponse()->write($content); |
| 145 | 145 | } |
| 146 | 146 | else |
| 147 | - throw new THttpException(404,'feedservice_feed_unknown',$id); |
|
| 147 | + throw new THttpException(404, 'feedservice_feed_unknown', $id); |
|
| 148 | 148 | } |
| 149 | 149 | } |
| 150 | 150 | |
@@ -74,8 +74,7 @@ discard block |
||
| 74 | 74 | foreach($config as $id => $feed) |
| 75 | 75 | $this->_feeds[$id] = $feed; |
| 76 | 76 | } |
| 77 | - } |
|
| 78 | - else |
|
| 77 | + } else |
|
| 79 | 78 | { |
| 80 | 79 | foreach($config->getElementsByTagName('feed') as $feed) |
| 81 | 80 | { |
@@ -116,11 +115,9 @@ discard block |
||
| 116 | 115 | $properties=isset($feedConfig['properties'])?$feedConfig['properties']:array(); |
| 117 | 116 | else |
| 118 | 117 | throw new TConfigurationException('jsonservice_response_type_invalid',$id); |
| 119 | - } |
|
| 120 | - else |
|
| 118 | + } else |
|
| 121 | 119 | throw new TConfigurationException('jsonservice_class_required',$id); |
| 122 | - } |
|
| 123 | - else |
|
| 120 | + } else |
|
| 124 | 121 | { |
| 125 | 122 | $properties=$feedConfig->getAttributes(); |
| 126 | 123 | if(($class=$properties->remove('class'))!==null) |
@@ -128,8 +125,7 @@ discard block |
||
| 128 | 125 | $feed=Prado::createComponent($class); |
| 129 | 126 | if(!($feed instanceof IFeedContentProvider)) |
| 130 | 127 | throw new TConfigurationException('feedservice_feedtype_invalid',$id); |
| 131 | - } |
|
| 132 | - else |
|
| 128 | + } else |
|
| 133 | 129 | throw new TConfigurationException('feedservice_class_required',$id); |
| 134 | 130 | } |
| 135 | 131 | |
@@ -142,8 +138,7 @@ discard block |
||
| 142 | 138 | //$this->getResponse()->setContentType('application/rss+xml'); |
| 143 | 139 | $this->getResponse()->setContentType($feed->getContentType()); |
| 144 | 140 | $this->getResponse()->write($content); |
| 145 | - } |
|
| 146 | - else |
|
| 141 | + } else |
|
| 147 | 142 | throw new THttpException(404,'feedservice_feed_unknown',$id); |
| 148 | 143 | } |
| 149 | 144 | } |
@@ -144,15 +144,15 @@ |
||
| 144 | 144 | */ |
| 145 | 145 | public function getKeyPrefix() |
| 146 | 146 | { |
| 147 | - return $this->_prefix; |
|
| 147 | + return $this->_prefix; |
|
| 148 | 148 | } |
| 149 | 149 | |
| 150 | 150 | /** |
| 151 | - * @param string prefix of cache variable name to avoid conflict with other cache data |
|
| 152 | - */ |
|
| 151 | + * @param string prefix of cache variable name to avoid conflict with other cache data |
|
| 152 | + */ |
|
| 153 | 153 | public function setKeyPrefix($value) |
| 154 | 154 | { |
| 155 | - $this->_prefix=$value; |
|
| 155 | + $this->_prefix=$value; |
|
| 156 | 156 | } |
| 157 | 157 | |
| 158 | 158 | /** |
@@ -110,7 +110,7 @@ discard block |
||
| 110 | 110 | if($cache===null || !($cache instanceof ICache)) |
| 111 | 111 | { |
| 112 | 112 | if($this->_cacheModuleID!=='') |
| 113 | - throw new TConfigurationException('cachepagestatepersister_cachemoduleid_invalid',$this->_cacheModuleID); |
|
| 113 | + throw new TConfigurationException('cachepagestatepersister_cachemoduleid_invalid', $this->_cacheModuleID); |
|
| 114 | 114 | else |
| 115 | 115 | throw new TConfigurationException('cachepagestatepersister_cache_required'); |
| 116 | 116 | } |
@@ -133,7 +133,7 @@ discard block |
||
| 133 | 133 | */ |
| 134 | 134 | public function setCacheTimeout($value) |
| 135 | 135 | { |
| 136 | - if(($value=TPropertyValue::ensureInteger($value))>=0) |
|
| 136 | + if(($value=TPropertyValue::ensureInteger($value)) >= 0) |
|
| 137 | 137 | $this->_timeout=$value; |
| 138 | 138 | else |
| 139 | 139 | throw new TInvalidDataValueException('cachepagestatepersister_timeout_invalid'); |
@@ -173,10 +173,10 @@ discard block |
||
| 173 | 173 | */ |
| 174 | 174 | public function save($data) |
| 175 | 175 | { |
| 176 | - $timestamp=(string)microtime(true); |
|
| 176 | + $timestamp=(string) microtime(true); |
|
| 177 | 177 | $key=$this->calculateKey($timestamp); |
| 178 | - $this->getCache()->add($key,$data,$this->_timeout); |
|
| 179 | - $this->_page->setClientState(TPageStateFormatter::serialize($this->_page,$timestamp)); |
|
| 178 | + $this->getCache()->add($key, $data, $this->_timeout); |
|
| 179 | + $this->_page->setClientState(TPageStateFormatter::serialize($this->_page, $timestamp)); |
|
| 180 | 180 | } |
| 181 | 181 | |
| 182 | 182 | /** |
@@ -186,13 +186,13 @@ discard block |
||
| 186 | 186 | */ |
| 187 | 187 | public function load() |
| 188 | 188 | { |
| 189 | - if(($timestamp=TPageStateFormatter::unserialize($this->_page,$this->_page->getRequestClientState()))!==null) |
|
| 189 | + if(($timestamp=TPageStateFormatter::unserialize($this->_page, $this->_page->getRequestClientState()))!==null) |
|
| 190 | 190 | { |
| 191 | 191 | $key=$this->calculateKey($timestamp); |
| 192 | 192 | if(($data=$this->getCache()->get($key))!==false) |
| 193 | 193 | return $data; |
| 194 | 194 | } |
| 195 | - throw new THttpException(400,'cachepagestatepersister_pagestate_corrupted'); |
|
| 195 | + throw new THttpException(400, 'cachepagestatepersister_pagestate_corrupted'); |
|
| 196 | 196 | } |
| 197 | 197 | } |
| 198 | 198 | |
@@ -334,8 +334,8 @@ discard block |
||
| 334 | 334 | |
| 335 | 335 | /** |
| 336 | 336 | * @return boolean a value indicating whether an automatic postback to the server |
| 337 | - * will occur whenever the user makes change to the list control and then tabs out of it. |
|
| 338 | - * Defaults to false. |
|
| 337 | + * will occur whenever the user makes change to the list control and then tabs out of it. |
|
| 338 | + * Defaults to false. |
|
| 339 | 339 | */ |
| 340 | 340 | public function getAutoPostBack() |
| 341 | 341 | { |
@@ -591,23 +591,23 @@ discard block |
||
| 591 | 591 | * @param string the value of the item to be selected. |
| 592 | 592 | */ |
| 593 | 593 | public function setSelectedValue($value) |
| 594 | - { |
|
| 595 | - if($this->_items) |
|
| 596 | - { |
|
| 597 | - if($value===null) |
|
| 598 | - $this->clearSelection(); |
|
| 599 | - else if(($item=$this->_items->findItemByValue($value))!==null) |
|
| 600 | - { |
|
| 601 | - $this->clearSelection(); |
|
| 602 | - $item->setSelected(true); |
|
| 603 | - } |
|
| 604 | - else |
|
| 594 | + { |
|
| 595 | + if($this->_items) |
|
| 596 | + { |
|
| 597 | + if($value===null) |
|
| 598 | + $this->clearSelection(); |
|
| 599 | + else if(($item=$this->_items->findItemByValue($value))!==null) |
|
| 600 | + { |
|
| 601 | + $this->clearSelection(); |
|
| 602 | + $item->setSelected(true); |
|
| 603 | + } |
|
| 604 | + else |
|
| 605 | 605 | $this->clearSelection(); |
| 606 | - } |
|
| 607 | - $this->_cachedSelectedValue=$value; |
|
| 606 | + } |
|
| 607 | + $this->_cachedSelectedValue=$value; |
|
| 608 | 608 | if($this->getAdapter() instanceof IListControlAdapter) |
| 609 | 609 | $this->getAdapter()->setSelectedValue($value); |
| 610 | - } |
|
| 610 | + } |
|
| 611 | 611 | |
| 612 | 612 | |
| 613 | 613 | /** |
@@ -655,36 +655,36 @@ discard block |
||
| 655 | 655 | $this->getAdapter()->setSelectedValues($values); |
| 656 | 656 | } |
| 657 | 657 | |
| 658 | - /** |
|
| 659 | - * @return string selected value |
|
| 660 | - */ |
|
| 661 | - public function getText() |
|
| 662 | - { |
|
| 663 | - return $this->getSelectedValue(); |
|
| 664 | - } |
|
| 665 | - |
|
| 666 | - /** |
|
| 667 | - * @param string value to be selected |
|
| 668 | - */ |
|
| 669 | - public function setText($value) |
|
| 670 | - { |
|
| 671 | - $this->setSelectedValue($value); |
|
| 672 | - } |
|
| 673 | - |
|
| 674 | - /** |
|
| 675 | - * Clears all existing selections. |
|
| 676 | - */ |
|
| 677 | - public function clearSelection() |
|
| 678 | - { |
|
| 679 | - if($this->_items) |
|
| 680 | - { |
|
| 681 | - foreach($this->_items as $item) |
|
| 682 | - $item->setSelected(false); |
|
| 683 | - } |
|
| 658 | + /** |
|
| 659 | + * @return string selected value |
|
| 660 | + */ |
|
| 661 | + public function getText() |
|
| 662 | + { |
|
| 663 | + return $this->getSelectedValue(); |
|
| 664 | + } |
|
| 665 | + |
|
| 666 | + /** |
|
| 667 | + * @param string value to be selected |
|
| 668 | + */ |
|
| 669 | + public function setText($value) |
|
| 670 | + { |
|
| 671 | + $this->setSelectedValue($value); |
|
| 672 | + } |
|
| 673 | + |
|
| 674 | + /** |
|
| 675 | + * Clears all existing selections. |
|
| 676 | + */ |
|
| 677 | + public function clearSelection() |
|
| 678 | + { |
|
| 679 | + if($this->_items) |
|
| 680 | + { |
|
| 681 | + foreach($this->_items as $item) |
|
| 682 | + $item->setSelected(false); |
|
| 683 | + } |
|
| 684 | 684 | |
| 685 | 685 | if($this->getAdapter() instanceof IListControlAdapter) |
| 686 | 686 | $this->getAdapter()->clearSelection(); |
| 687 | - } |
|
| 687 | + } |
|
| 688 | 688 | |
| 689 | 689 | /** |
| 690 | 690 | * @return string the group of validators which the list control causes validation upon postback |
@@ -914,10 +914,10 @@ discard block |
||
| 914 | 914 | */ |
| 915 | 915 | public function setSelectedValues($values); |
| 916 | 916 | |
| 917 | - /** |
|
| 918 | - * Clears all existing selections on the client side. |
|
| 919 | - */ |
|
| 920 | - public function clearSelection(); |
|
| 917 | + /** |
|
| 918 | + * Clears all existing selections on the client side. |
|
| 919 | + */ |
|
| 920 | + public function clearSelection(); |
|
| 921 | 921 | } |
| 922 | 922 | |
| 923 | 923 | |
@@ -347,6 +347,7 @@ discard block |
||
| 347 | 347 | * An automatic postback to the server will occur whenever the user |
| 348 | 348 | * makes change to the list control and then tabs out of it. |
| 349 | 349 | * @param boolean the value indicating if postback automatically |
| 350 | + * @param boolean $value |
|
| 350 | 351 | */ |
| 351 | 352 | public function setAutoPostBack($value) |
| 352 | 353 | { |
@@ -379,6 +380,7 @@ discard block |
||
| 379 | 380 | |
| 380 | 381 | /** |
| 381 | 382 | * @param string the field of the data source that provides the text content of the list items. |
| 383 | + * @param string $value |
|
| 382 | 384 | */ |
| 383 | 385 | public function setDataTextField($value) |
| 384 | 386 | { |
@@ -398,6 +400,7 @@ discard block |
||
| 398 | 400 | * The format string is used in {@link TDataValueFormatter::format()} to format the Text property value |
| 399 | 401 | * of each item in the list control. |
| 400 | 402 | * @param string the formatting string used to control how data bound to the list control is displayed. |
| 403 | + * @param string $value |
|
| 401 | 404 | * @see TDataValueFormatter::format() |
| 402 | 405 | */ |
| 403 | 406 | public function setDataTextFormatString($value) |
@@ -415,6 +418,7 @@ discard block |
||
| 415 | 418 | |
| 416 | 419 | /** |
| 417 | 420 | * @param string the field of the data source that provides the value of each list item. |
| 421 | + * @param string $value |
|
| 418 | 422 | */ |
| 419 | 423 | public function setDataValueField($value) |
| 420 | 424 | { |
@@ -856,6 +860,7 @@ discard block |
||
| 856 | 860 | * as the first and second parameters in {@link sprintf}. |
| 857 | 861 | * @param string format string |
| 858 | 862 | * @param mixed the data to be formatted |
| 863 | + * @param string $formatString |
|
| 859 | 864 | * @return string the formatted result |
| 860 | 865 | */ |
| 861 | 866 | protected function formatDataValue($formatString,$value) |
@@ -894,28 +899,33 @@ discard block |
||
| 894 | 899 | /** |
| 895 | 900 | * Selects an item based on zero-base index on the client side. |
| 896 | 901 | * @param integer the index (zero-based) of the item to be selected |
| 902 | + * @return void |
|
| 897 | 903 | */ |
| 898 | 904 | public function setSelectedIndex($index); |
| 899 | 905 | /** |
| 900 | 906 | * Selects a list of item based on zero-base indices on the client side. |
| 901 | 907 | * @param array list of index of items to be selected |
| 908 | + * @return void |
|
| 902 | 909 | */ |
| 903 | 910 | public function setSelectedIndices($indices); |
| 904 | 911 | |
| 905 | 912 | /** |
| 906 | 913 | * Sets selection by item value on the client side. |
| 907 | 914 | * @param string the value of the item to be selected. |
| 915 | + * @return void |
|
| 908 | 916 | */ |
| 909 | 917 | public function setSelectedValue($value); |
| 910 | 918 | |
| 911 | 919 | /** |
| 912 | 920 | * Sets selection by a list of item values on the client side. |
| 913 | 921 | * @param array list of the selected item values |
| 922 | + * @return void |
|
| 914 | 923 | */ |
| 915 | 924 | public function setSelectedValues($values); |
| 916 | 925 | |
| 917 | 926 | /** |
| 918 | 927 | * Clears all existing selections on the client side. |
| 928 | + * @return void |
|
| 919 | 929 | */ |
| 920 | 930 | public function clearSelection(); |
| 921 | 931 | } |
@@ -113,7 +113,7 @@ discard block |
||
| 113 | 113 | */ |
| 114 | 114 | public function getEnableClientScript() |
| 115 | 115 | { |
| 116 | - return $this->getViewState('EnableClientScript',true); |
|
| 116 | + return $this->getViewState('EnableClientScript', true); |
|
| 117 | 117 | } |
| 118 | 118 | |
| 119 | 119 | /** |
@@ -121,7 +121,7 @@ discard block |
||
| 121 | 121 | */ |
| 122 | 122 | public function setEnableClientScript($value) |
| 123 | 123 | { |
| 124 | - $this->setViewState('EnableClientScript',TPropertyValue::ensureBoolean($value),true); |
|
| 124 | + $this->setViewState('EnableClientScript', TPropertyValue::ensureBoolean($value), true); |
|
| 125 | 125 | } |
| 126 | 126 | |
| 127 | 127 | /** |
@@ -133,7 +133,7 @@ discard block |
||
| 133 | 133 | $page=$this->getPage(); |
| 134 | 134 | $page->ensureRenderInForm($this); |
| 135 | 135 | if($this->getIsMultiSelect()) |
| 136 | - $writer->addAttribute('multiple','multiple'); |
|
| 136 | + $writer->addAttribute('multiple', 'multiple'); |
|
| 137 | 137 | if($this->getEnabled(true)) |
| 138 | 138 | { |
| 139 | 139 | if($this->getAutoPostBack() |
@@ -144,7 +144,7 @@ discard block |
||
| 144 | 144 | } |
| 145 | 145 | } |
| 146 | 146 | else if($this->getEnabled()) |
| 147 | - $writer->addAttribute('disabled','disabled'); |
|
| 147 | + $writer->addAttribute('disabled', 'disabled'); |
|
| 148 | 148 | parent::addAttributesToRender($writer); |
| 149 | 149 | } |
| 150 | 150 | |
@@ -153,8 +153,8 @@ discard block |
||
| 153 | 153 | */ |
| 154 | 154 | protected function renderClientControlScript($writer) |
| 155 | 155 | { |
| 156 | - $writer->addAttribute('id',$this->getClientID()); |
|
| 157 | - $this->getPage()->getClientScript()->registerPostBackControl($this->getClientClassName(),$this->getPostBackOptions()); |
|
| 156 | + $writer->addAttribute('id', $this->getClientID()); |
|
| 157 | + $this->getPage()->getClientScript()->registerPostBackControl($this->getClientClassName(), $this->getPostBackOptions()); |
|
| 158 | 158 | } |
| 159 | 159 | |
| 160 | 160 | /** |
@@ -172,10 +172,10 @@ discard block |
||
| 172 | 172 | */ |
| 173 | 173 | protected function getPostBackOptions() |
| 174 | 174 | { |
| 175 | - $options['ID'] = $this->getClientID(); |
|
| 176 | - $options['CausesValidation'] = $this->getCausesValidation(); |
|
| 177 | - $options['ValidationGroup'] = $this->getValidationGroup(); |
|
| 178 | - $options['EventTarget'] = $this->getUniqueID(); |
|
| 175 | + $options['ID']=$this->getClientID(); |
|
| 176 | + $options['CausesValidation']=$this->getCausesValidation(); |
|
| 177 | + $options['ValidationGroup']=$this->getValidationGroup(); |
|
| 178 | + $options['EventTarget']=$this->getUniqueID(); |
|
| 179 | 179 | return $options; |
| 180 | 180 | } |
| 181 | 181 | |
@@ -224,18 +224,18 @@ discard block |
||
| 224 | 224 | $item=$items->createListItem(); |
| 225 | 225 | if(is_array($object) || is_object($object)) |
| 226 | 226 | { |
| 227 | - $text=TDataFieldAccessor::getDataFieldValue($object,$textField); |
|
| 228 | - $value=TDataFieldAccessor::getDataFieldValue($object,$valueField); |
|
| 227 | + $text=TDataFieldAccessor::getDataFieldValue($object, $textField); |
|
| 228 | + $value=TDataFieldAccessor::getDataFieldValue($object, $valueField); |
|
| 229 | 229 | $item->setValue($value); |
| 230 | 230 | if($groupField!=='') |
| 231 | - $item->setAttribute('Group',TDataFieldAccessor::getDataFieldValue($object,$groupField)); |
|
| 231 | + $item->setAttribute('Group', TDataFieldAccessor::getDataFieldValue($object, $groupField)); |
|
| 232 | 232 | } |
| 233 | 233 | else |
| 234 | 234 | { |
| 235 | 235 | $text=$object; |
| 236 | 236 | $item->setValue("$key"); |
| 237 | 237 | } |
| 238 | - $item->setText($this->formatDataValue($textFormat,$text)); |
|
| 238 | + $item->setText($this->formatDataValue($textFormat, $text)); |
|
| 239 | 239 | } |
| 240 | 240 | // SelectedValue or SelectedIndex may be set before databinding |
| 241 | 241 | // so we make them be effective now |
@@ -287,7 +287,7 @@ discard block |
||
| 287 | 287 | { |
| 288 | 288 | parent::saveState(); |
| 289 | 289 | if($this->_items) |
| 290 | - $this->setViewState('Items',$this->_items->saveState(),null); |
|
| 290 | + $this->setViewState('Items', $this->_items->saveState(), null); |
|
| 291 | 291 | else |
| 292 | 292 | $this->clearViewState('Items'); |
| 293 | 293 | } |
@@ -303,7 +303,7 @@ discard block |
||
| 303 | 303 | if(!$this->getIsDataBound()) |
| 304 | 304 | { |
| 305 | 305 | $this->_items=$this->createListItemCollection(); |
| 306 | - $this->_items->loadState($this->getViewState('Items',null)); |
|
| 306 | + $this->_items->loadState($this->getViewState('Items', null)); |
|
| 307 | 307 | } |
| 308 | 308 | $this->clearViewState('Items'); |
| 309 | 309 | } |
@@ -321,7 +321,7 @@ discard block |
||
| 321 | 321 | */ |
| 322 | 322 | public function getAppendDataBoundItems() |
| 323 | 323 | { |
| 324 | - return $this->getViewState('AppendDataBoundItems',false); |
|
| 324 | + return $this->getViewState('AppendDataBoundItems', false); |
|
| 325 | 325 | } |
| 326 | 326 | |
| 327 | 327 | /** |
@@ -329,7 +329,7 @@ discard block |
||
| 329 | 329 | */ |
| 330 | 330 | public function setAppendDataBoundItems($value) |
| 331 | 331 | { |
| 332 | - $this->setViewState('AppendDataBoundItems',TPropertyValue::ensureBoolean($value),false); |
|
| 332 | + $this->setViewState('AppendDataBoundItems', TPropertyValue::ensureBoolean($value), false); |
|
| 333 | 333 | } |
| 334 | 334 | |
| 335 | 335 | /** |
@@ -339,7 +339,7 @@ discard block |
||
| 339 | 339 | */ |
| 340 | 340 | public function getAutoPostBack() |
| 341 | 341 | { |
| 342 | - return $this->getViewState('AutoPostBack',false); |
|
| 342 | + return $this->getViewState('AutoPostBack', false); |
|
| 343 | 343 | } |
| 344 | 344 | |
| 345 | 345 | /** |
@@ -350,7 +350,7 @@ discard block |
||
| 350 | 350 | */ |
| 351 | 351 | public function setAutoPostBack($value) |
| 352 | 352 | { |
| 353 | - $this->setViewState('AutoPostBack',TPropertyValue::ensureBoolean($value),false); |
|
| 353 | + $this->setViewState('AutoPostBack', TPropertyValue::ensureBoolean($value), false); |
|
| 354 | 354 | } |
| 355 | 355 | |
| 356 | 356 | /** |
@@ -358,7 +358,7 @@ discard block |
||
| 358 | 358 | */ |
| 359 | 359 | public function getCausesValidation() |
| 360 | 360 | { |
| 361 | - return $this->getViewState('CausesValidation',true); |
|
| 361 | + return $this->getViewState('CausesValidation', true); |
|
| 362 | 362 | } |
| 363 | 363 | |
| 364 | 364 | /** |
@@ -366,7 +366,7 @@ discard block |
||
| 366 | 366 | */ |
| 367 | 367 | public function setCausesValidation($value) |
| 368 | 368 | { |
| 369 | - $this->setViewState('CausesValidation',TPropertyValue::ensureBoolean($value),true); |
|
| 369 | + $this->setViewState('CausesValidation', TPropertyValue::ensureBoolean($value), true); |
|
| 370 | 370 | } |
| 371 | 371 | |
| 372 | 372 | /** |
@@ -374,7 +374,7 @@ discard block |
||
| 374 | 374 | */ |
| 375 | 375 | public function getDataTextField() |
| 376 | 376 | { |
| 377 | - return $this->getViewState('DataTextField',''); |
|
| 377 | + return $this->getViewState('DataTextField', ''); |
|
| 378 | 378 | } |
| 379 | 379 | |
| 380 | 380 | /** |
@@ -382,7 +382,7 @@ discard block |
||
| 382 | 382 | */ |
| 383 | 383 | public function setDataTextField($value) |
| 384 | 384 | { |
| 385 | - $this->setViewState('DataTextField',$value,''); |
|
| 385 | + $this->setViewState('DataTextField', $value, ''); |
|
| 386 | 386 | } |
| 387 | 387 | |
| 388 | 388 | /** |
@@ -390,7 +390,7 @@ discard block |
||
| 390 | 390 | */ |
| 391 | 391 | public function getDataTextFormatString() |
| 392 | 392 | { |
| 393 | - return $this->getViewState('DataTextFormatString',''); |
|
| 393 | + return $this->getViewState('DataTextFormatString', ''); |
|
| 394 | 394 | } |
| 395 | 395 | |
| 396 | 396 | /** |
@@ -402,7 +402,7 @@ discard block |
||
| 402 | 402 | */ |
| 403 | 403 | public function setDataTextFormatString($value) |
| 404 | 404 | { |
| 405 | - $this->setViewState('DataTextFormatString',$value,''); |
|
| 405 | + $this->setViewState('DataTextFormatString', $value, ''); |
|
| 406 | 406 | } |
| 407 | 407 | |
| 408 | 408 | /** |
@@ -410,7 +410,7 @@ discard block |
||
| 410 | 410 | */ |
| 411 | 411 | public function getDataValueField() |
| 412 | 412 | { |
| 413 | - return $this->getViewState('DataValueField',''); |
|
| 413 | + return $this->getViewState('DataValueField', ''); |
|
| 414 | 414 | } |
| 415 | 415 | |
| 416 | 416 | /** |
@@ -418,7 +418,7 @@ discard block |
||
| 418 | 418 | */ |
| 419 | 419 | public function setDataValueField($value) |
| 420 | 420 | { |
| 421 | - $this->setViewState('DataValueField',$value,''); |
|
| 421 | + $this->setViewState('DataValueField', $value, ''); |
|
| 422 | 422 | } |
| 423 | 423 | |
| 424 | 424 | /** |
@@ -426,7 +426,7 @@ discard block |
||
| 426 | 426 | */ |
| 427 | 427 | public function getDataGroupField() |
| 428 | 428 | { |
| 429 | - return $this->getViewState('DataGroupField',''); |
|
| 429 | + return $this->getViewState('DataGroupField', ''); |
|
| 430 | 430 | } |
| 431 | 431 | |
| 432 | 432 | /** |
@@ -434,7 +434,7 @@ discard block |
||
| 434 | 434 | */ |
| 435 | 435 | public function setDataGroupField($value) |
| 436 | 436 | { |
| 437 | - $this->setViewState('DataGroupField',$value,''); |
|
| 437 | + $this->setViewState('DataGroupField', $value, ''); |
|
| 438 | 438 | } |
| 439 | 439 | |
| 440 | 440 | /** |
@@ -442,7 +442,7 @@ discard block |
||
| 442 | 442 | */ |
| 443 | 443 | public function getItemCount() |
| 444 | 444 | { |
| 445 | - return $this->_items?$this->_items->getCount():0; |
|
| 445 | + return $this->_items ? $this->_items->getCount() : 0; |
|
| 446 | 446 | } |
| 447 | 447 | |
| 448 | 448 | /** |
@@ -450,7 +450,7 @@ discard block |
||
| 450 | 450 | */ |
| 451 | 451 | public function getHasItems() |
| 452 | 452 | { |
| 453 | - return ($this->_items && $this->_items->getCount()>0); |
|
| 453 | + return ($this->_items && $this->_items->getCount() > 0); |
|
| 454 | 454 | } |
| 455 | 455 | |
| 456 | 456 | /** |
@@ -471,7 +471,7 @@ discard block |
||
| 471 | 471 | if($this->_items) |
| 472 | 472 | { |
| 473 | 473 | $n=$this->_items->getCount(); |
| 474 | - for($i=0;$i<$n;++$i) |
|
| 474 | + for($i=0; $i < $n; ++$i) |
|
| 475 | 475 | if($this->_items->itemAt($i)->getSelected()) |
| 476 | 476 | return $i; |
| 477 | 477 | } |
@@ -483,12 +483,12 @@ discard block |
||
| 483 | 483 | */ |
| 484 | 484 | public function setSelectedIndex($index) |
| 485 | 485 | { |
| 486 | - if(($index=TPropertyValue::ensureInteger($index))<0) |
|
| 486 | + if(($index=TPropertyValue::ensureInteger($index)) < 0) |
|
| 487 | 487 | $index=-1; |
| 488 | 488 | if($this->_items) |
| 489 | 489 | { |
| 490 | 490 | $this->clearSelection(); |
| 491 | - if($index>=0 && $index<$this->_items->getCount()) |
|
| 491 | + if($index >= 0 && $index < $this->_items->getCount()) |
|
| 492 | 492 | $this->_items->itemAt($index)->setSelected(true); |
| 493 | 493 | } |
| 494 | 494 | $this->_cachedSelectedIndex=$index; |
@@ -505,7 +505,7 @@ discard block |
||
| 505 | 505 | if($this->_items) |
| 506 | 506 | { |
| 507 | 507 | $n=$this->_items->getCount(); |
| 508 | - for($i=0;$i<$n;++$i) |
|
| 508 | + for($i=0; $i < $n; ++$i) |
|
| 509 | 509 | if($this->_items->itemAt($i)->getSelected()) |
| 510 | 510 | $selections[]=$i; |
| 511 | 511 | } |
@@ -525,14 +525,14 @@ discard block |
||
| 525 | 525 | $n=$this->_items->getCount(); |
| 526 | 526 | foreach($indices as $index) |
| 527 | 527 | { |
| 528 | - if($index>=0 && $index<$n) |
|
| 528 | + if($index >= 0 && $index < $n) |
|
| 529 | 529 | $this->_items->itemAt($index)->setSelected(true); |
| 530 | 530 | } |
| 531 | 531 | } |
| 532 | 532 | $this->_cachedSelectedIndices=$indices; |
| 533 | 533 | } |
| 534 | 534 | else |
| 535 | - throw new TNotSupportedException('listcontrol_multiselect_unsupported',get_class($this)); |
|
| 535 | + throw new TNotSupportedException('listcontrol_multiselect_unsupported', get_class($this)); |
|
| 536 | 536 | |
| 537 | 537 | if($this->getAdapter() instanceof IListControlAdapter) |
| 538 | 538 | $this->getAdapter()->setSelectedIndices($indices); |
@@ -543,7 +543,7 @@ discard block |
||
| 543 | 543 | */ |
| 544 | 544 | public function getSelectedItem() |
| 545 | 545 | { |
| 546 | - if(($index=$this->getSelectedIndex())>=0) |
|
| 546 | + if(($index=$this->getSelectedIndex()) >= 0) |
|
| 547 | 547 | return $this->_items->itemAt($index); |
| 548 | 548 | else |
| 549 | 549 | return null; |
@@ -581,7 +581,7 @@ discard block |
||
| 581 | 581 | public function getSelectedValue() |
| 582 | 582 | { |
| 583 | 583 | $index=$this->getSelectedIndex(); |
| 584 | - return $index>=0?$this->getItems()->itemAt($index)->getValue():''; |
|
| 584 | + return $index >= 0 ? $this->getItems()->itemAt($index)->getValue() : ''; |
|
| 585 | 585 | } |
| 586 | 586 | |
| 587 | 587 | /** |
@@ -649,7 +649,7 @@ discard block |
||
| 649 | 649 | $this->_cachedSelectedValues=$values; |
| 650 | 650 | } |
| 651 | 651 | else |
| 652 | - throw new TNotSupportedException('listcontrol_multiselect_unsupported',get_class($this)); |
|
| 652 | + throw new TNotSupportedException('listcontrol_multiselect_unsupported', get_class($this)); |
|
| 653 | 653 | |
| 654 | 654 | if($this->getAdapter() instanceof IListControlAdapter) |
| 655 | 655 | $this->getAdapter()->setSelectedValues($values); |
@@ -691,7 +691,7 @@ discard block |
||
| 691 | 691 | */ |
| 692 | 692 | public function getValidationGroup() |
| 693 | 693 | { |
| 694 | - return $this->getViewState('ValidationGroup',''); |
|
| 694 | + return $this->getViewState('ValidationGroup', ''); |
|
| 695 | 695 | } |
| 696 | 696 | |
| 697 | 697 | /** |
@@ -699,7 +699,7 @@ discard block |
||
| 699 | 699 | */ |
| 700 | 700 | public function setValidationGroup($value) |
| 701 | 701 | { |
| 702 | - $this->setViewState('ValidationGroup',$value,''); |
|
| 702 | + $this->setViewState('ValidationGroup', $value, ''); |
|
| 703 | 703 | } |
| 704 | 704 | |
| 705 | 705 | /** |
@@ -708,7 +708,7 @@ discard block |
||
| 708 | 708 | */ |
| 709 | 709 | public function getPromptText() |
| 710 | 710 | { |
| 711 | - return $this->getViewState('PromptText',''); |
|
| 711 | + return $this->getViewState('PromptText', ''); |
|
| 712 | 712 | } |
| 713 | 713 | |
| 714 | 714 | /** |
@@ -717,7 +717,7 @@ discard block |
||
| 717 | 717 | */ |
| 718 | 718 | public function setPromptText($value) |
| 719 | 719 | { |
| 720 | - $this->setViewState('PromptText',$value,''); |
|
| 720 | + $this->setViewState('PromptText', $value, ''); |
|
| 721 | 721 | } |
| 722 | 722 | |
| 723 | 723 | /** |
@@ -727,7 +727,7 @@ discard block |
||
| 727 | 727 | */ |
| 728 | 728 | public function getPromptValue() |
| 729 | 729 | { |
| 730 | - return $this->getViewState('PromptValue',''); |
|
| 730 | + return $this->getViewState('PromptValue', ''); |
|
| 731 | 731 | } |
| 732 | 732 | |
| 733 | 733 | /** |
@@ -737,7 +737,7 @@ discard block |
||
| 737 | 737 | */ |
| 738 | 738 | public function setPromptValue($value) |
| 739 | 739 | { |
| 740 | - $this->setViewState('PromptValue',(string)$value,''); |
|
| 740 | + $this->setViewState('PromptValue', (string) $value, ''); |
|
| 741 | 741 | } |
| 742 | 742 | |
| 743 | 743 | /** |
@@ -748,7 +748,7 @@ discard block |
||
| 748 | 748 | */ |
| 749 | 749 | public function onSelectedIndexChanged($param) |
| 750 | 750 | { |
| 751 | - $this->raiseEvent('OnSelectedIndexChanged',$this,$param); |
|
| 751 | + $this->raiseEvent('OnSelectedIndexChanged', $this, $param); |
|
| 752 | 752 | $this->onTextChanged($param); |
| 753 | 753 | } |
| 754 | 754 | |
@@ -760,7 +760,7 @@ discard block |
||
| 760 | 760 | */ |
| 761 | 761 | public function onTextChanged($param) |
| 762 | 762 | { |
| 763 | - $this->raiseEvent('OnTextChanged',$this,$param); |
|
| 763 | + $this->raiseEvent('OnTextChanged', $this, $param); |
|
| 764 | 764 | } |
| 765 | 765 | |
| 766 | 766 | /** |
@@ -776,7 +776,7 @@ discard block |
||
| 776 | 776 | $value=$text; |
| 777 | 777 | if($value!=='') |
| 778 | 778 | { |
| 779 | - $writer->addAttribute('value',$value); |
|
| 779 | + $writer->addAttribute('value', $value); |
|
| 780 | 780 | $writer->renderBeginTag('option'); |
| 781 | 781 | $writer->write(THttpUtility::htmlEncode($text)); |
| 782 | 782 | $writer->renderEndTag(); |
@@ -814,14 +814,14 @@ discard block |
||
| 814 | 814 | } |
| 815 | 815 | if($group!==null) |
| 816 | 816 | { |
| 817 | - $writer->addAttribute('label',$group); |
|
| 817 | + $writer->addAttribute('label', $group); |
|
| 818 | 818 | $writer->renderBeginTag('optgroup'); |
| 819 | 819 | $writer->writeLine(); |
| 820 | 820 | $previousGroup=$group; |
| 821 | 821 | } |
| 822 | 822 | } |
| 823 | 823 | foreach($item->getAttributes() as $name=>$value) |
| 824 | - $writer->addAttribute($name,$value); |
|
| 824 | + $writer->addAttribute($name, $value); |
|
| 825 | 825 | } |
| 826 | 826 | else if($previousGroup!==null) |
| 827 | 827 | { |
@@ -830,8 +830,8 @@ discard block |
||
| 830 | 830 | $previousGroup=null; |
| 831 | 831 | } |
| 832 | 832 | if($item->getSelected()) |
| 833 | - $writer->addAttribute('selected','selected'); |
|
| 834 | - $writer->addAttribute('value',$item->getValue()); |
|
| 833 | + $writer->addAttribute('selected', 'selected'); |
|
| 834 | + $writer->addAttribute('value', $item->getValue()); |
|
| 835 | 835 | $writer->renderBeginTag('option'); |
| 836 | 836 | $writer->write(THttpUtility::htmlEncode($item->getText())); |
| 837 | 837 | $writer->renderEndTag(); |
@@ -858,13 +858,13 @@ discard block |
||
| 858 | 858 | * @param mixed the data to be formatted |
| 859 | 859 | * @return string the formatted result |
| 860 | 860 | */ |
| 861 | - protected function formatDataValue($formatString,$value) |
|
| 861 | + protected function formatDataValue($formatString, $value) |
|
| 862 | 862 | { |
| 863 | 863 | if($formatString==='') |
| 864 | 864 | return TPropertyValue::ensureString($value); |
| 865 | 865 | else if($formatString[0]==='#') |
| 866 | 866 | { |
| 867 | - $expression=strtr(substr($formatString,1),array('{0}'=>'$value')); |
|
| 867 | + $expression=strtr(substr($formatString, 1), array('{0}'=>'$value')); |
|
| 868 | 868 | try |
| 869 | 869 | { |
| 870 | 870 | if(eval("\$result=$expression;")===false) |
@@ -873,11 +873,11 @@ discard block |
||
| 873 | 873 | } |
| 874 | 874 | catch(Exception $e) |
| 875 | 875 | { |
| 876 | - throw new TInvalidDataValueException('listcontrol_expression_invalid',get_class($this),$expression,$e->getMessage()); |
|
| 876 | + throw new TInvalidDataValueException('listcontrol_expression_invalid', get_class($this), $expression, $e->getMessage()); |
|
| 877 | 877 | } |
| 878 | 878 | } |
| 879 | 879 | else |
| 880 | - return sprintf($formatString,$value); |
|
| 880 | + return sprintf($formatString, $value); |
|
| 881 | 881 | } |
| 882 | 882 | } |
| 883 | 883 | |
@@ -142,8 +142,7 @@ discard block |
||
| 142 | 142 | { |
| 143 | 143 | $this->renderClientControlScript($writer); |
| 144 | 144 | } |
| 145 | - } |
|
| 146 | - else if($this->getEnabled()) |
|
| 145 | + } else if($this->getEnabled()) |
|
| 147 | 146 | $writer->addAttribute('disabled','disabled'); |
| 148 | 147 | parent::addAttributesToRender($writer); |
| 149 | 148 | } |
@@ -229,8 +228,7 @@ discard block |
||
| 229 | 228 | $item->setValue($value); |
| 230 | 229 | if($groupField!=='') |
| 231 | 230 | $item->setAttribute('Group',TDataFieldAccessor::getDataFieldValue($object,$groupField)); |
| 232 | - } |
|
| 233 | - else |
|
| 231 | + } else |
|
| 234 | 232 | { |
| 235 | 233 | $text=$object; |
| 236 | 234 | $item->setValue("$key"); |
@@ -243,18 +241,15 @@ discard block |
||
| 243 | 241 | { |
| 244 | 242 | $this->setSelectedValue($this->_cachedSelectedValue); |
| 245 | 243 | $this->resetCachedSelections(); |
| 246 | - } |
|
| 247 | - else if($this->_cachedSelectedIndex!==-1) |
|
| 244 | + } else if($this->_cachedSelectedIndex!==-1) |
|
| 248 | 245 | { |
| 249 | 246 | $this->setSelectedIndex($this->_cachedSelectedIndex); |
| 250 | 247 | $this->resetCachedSelections(); |
| 251 | - } |
|
| 252 | - else if($this->_cachedSelectedValues!==null) |
|
| 248 | + } else if($this->_cachedSelectedValues!==null) |
|
| 253 | 249 | { |
| 254 | 250 | $this->setSelectedValues($this->_cachedSelectedValues); |
| 255 | 251 | $this->resetCachedSelections(); |
| 256 | - } |
|
| 257 | - else if($this->_cachedSelectedIndices!==null) |
|
| 252 | + } else if($this->_cachedSelectedIndices!==null) |
|
| 258 | 253 | { |
| 259 | 254 | $this->setSelectedIndices($this->_cachedSelectedIndices); |
| 260 | 255 | $this->resetCachedSelections(); |
@@ -530,8 +525,7 @@ discard block |
||
| 530 | 525 | } |
| 531 | 526 | } |
| 532 | 527 | $this->_cachedSelectedIndices=$indices; |
| 533 | - } |
|
| 534 | - else |
|
| 528 | + } else |
|
| 535 | 529 | throw new TNotSupportedException('listcontrol_multiselect_unsupported',get_class($this)); |
| 536 | 530 | |
| 537 | 531 | if($this->getAdapter() instanceof IListControlAdapter) |
@@ -600,8 +594,7 @@ discard block |
||
| 600 | 594 | { |
| 601 | 595 | $this->clearSelection(); |
| 602 | 596 | $item->setSelected(true); |
| 603 | - } |
|
| 604 | - else |
|
| 597 | + } else |
|
| 605 | 598 | $this->clearSelection(); |
| 606 | 599 | } |
| 607 | 600 | $this->_cachedSelectedValue=$value; |
@@ -647,8 +640,7 @@ discard block |
||
| 647 | 640 | } |
| 648 | 641 | } |
| 649 | 642 | $this->_cachedSelectedValues=$values; |
| 650 | - } |
|
| 651 | - else |
|
| 643 | + } else |
|
| 652 | 644 | throw new TNotSupportedException('listcontrol_multiselect_unsupported',get_class($this)); |
| 653 | 645 | |
| 654 | 646 | if($this->getAdapter() instanceof IListControlAdapter) |
@@ -822,8 +814,7 @@ discard block |
||
| 822 | 814 | } |
| 823 | 815 | foreach($item->getAttributes() as $name=>$value) |
| 824 | 816 | $writer->addAttribute($name,$value); |
| 825 | - } |
|
| 826 | - else if($previousGroup!==null) |
|
| 817 | + } else if($previousGroup!==null) |
|
| 827 | 818 | { |
| 828 | 819 | $writer->renderEndTag(); |
| 829 | 820 | $writer->writeLine(); |
@@ -870,13 +861,11 @@ discard block |
||
| 870 | 861 | if(eval("\$result=$expression;")===false) |
| 871 | 862 | throw new Exception(''); |
| 872 | 863 | return $result; |
| 873 | - } |
|
| 874 | - catch(Exception $e) |
|
| 864 | + } catch(Exception $e) |
|
| 875 | 865 | { |
| 876 | 866 | throw new TInvalidDataValueException('listcontrol_expression_invalid',get_class($this),$expression,$e->getMessage()); |
| 877 | 867 | } |
| 878 | - } |
|
| 879 | - else |
|
| 868 | + } else |
|
| 880 | 869 | return sprintf($formatString,$value); |
| 881 | 870 | } |
| 882 | 871 | } |
@@ -180,24 +180,24 @@ discard block |
||
| 180 | 180 | } |
| 181 | 181 | |
| 182 | 182 | /** |
| 183 | - * @return string URL for the CSS file including all relevant CSS class definitions. Defaults to ''. |
|
| 184 | - */ |
|
| 183 | + * @return string URL for the CSS file including all relevant CSS class definitions. Defaults to ''. |
|
| 184 | + */ |
|
| 185 | 185 | public function getCssUrl() |
| 186 | 186 | { |
| 187 | 187 | return $this->getViewState('CssUrl','default'); |
| 188 | 188 | } |
| 189 | 189 | |
| 190 | 190 | /** |
| 191 | - * @param string URL for the CSS file including all relevant CSS class definitions. |
|
| 192 | - */ |
|
| 191 | + * @param string URL for the CSS file including all relevant CSS class definitions. |
|
| 192 | + */ |
|
| 193 | 193 | public function setCssUrl($value) |
| 194 | 194 | { |
| 195 | 195 | $this->setViewState('CssUrl',TPropertyValue::ensureString($value),''); |
| 196 | 196 | } |
| 197 | 197 | |
| 198 | 198 | /** |
| 199 | - * @return string CSS class for the whole accordion control div. |
|
| 200 | - */ |
|
| 199 | + * @return string CSS class for the whole accordion control div. |
|
| 200 | + */ |
|
| 201 | 201 | public function getCssClass() |
| 202 | 202 | { |
| 203 | 203 | $cssClass=parent::getCssClass(); |
@@ -205,32 +205,32 @@ discard block |
||
| 205 | 205 | } |
| 206 | 206 | |
| 207 | 207 | /** |
| 208 | - * @return string CSS class for the currently displayed view div. Defaults to 'accordion-view'. |
|
| 209 | - */ |
|
| 208 | + * @return string CSS class for the currently displayed view div. Defaults to 'accordion-view'. |
|
| 209 | + */ |
|
| 210 | 210 | public function getViewCssClass() |
| 211 | 211 | { |
| 212 | 212 | return $this->getViewStyle()->getCssClass(); |
| 213 | 213 | } |
| 214 | 214 | |
| 215 | 215 | /** |
| 216 | - * @param string CSS class for the currently displayed view div. |
|
| 217 | - */ |
|
| 216 | + * @param string CSS class for the currently displayed view div. |
|
| 217 | + */ |
|
| 218 | 218 | public function setViewCssClass($value) |
| 219 | 219 | { |
| 220 | 220 | $this->getViewStyle()->setCssClass($value); |
| 221 | 221 | } |
| 222 | 222 | |
| 223 | 223 | /** |
| 224 | - * @return string CSS class for the currently displayed view div. Defaults to 'accordion-view'. |
|
| 225 | - */ |
|
| 224 | + * @return string CSS class for the currently displayed view div. Defaults to 'accordion-view'. |
|
| 225 | + */ |
|
| 226 | 226 | public function getAnimationDuration() |
| 227 | 227 | { |
| 228 | 228 | return $this->getViewState('AnimationDuration','1'); |
| 229 | 229 | } |
| 230 | 230 | |
| 231 | 231 | /** |
| 232 | - * @param string CSS class for the currently displayed view div. |
|
| 233 | - */ |
|
| 232 | + * @param string CSS class for the currently displayed view div. |
|
| 233 | + */ |
|
| 234 | 234 | public function setAnimationDuration($value) |
| 235 | 235 | { |
| 236 | 236 | $this->setViewState('AnimationDuration',$value); |
@@ -546,7 +546,7 @@ discard block |
||
| 546 | 546 | private $_active=false; |
| 547 | 547 | |
| 548 | 548 | /** |
| 549 | - * @return the tag name for the view element |
|
| 549 | + * @return string tag name for the view element |
|
| 550 | 550 | */ |
| 551 | 551 | protected function getTagName() |
| 552 | 552 | { |
@@ -714,6 +714,7 @@ discard block |
||
| 714 | 714 | /** |
| 715 | 715 | * Finds the index of the tab view whose ID is the same as the one being looked for. |
| 716 | 716 | * @param string the explicit ID of the tab view to be looked for |
| 717 | + * @param string $id |
|
| 717 | 718 | * @return integer the index of the tab view found, -1 if not found. |
| 718 | 719 | */ |
| 719 | 720 | public function findIndexByID($id) |
@@ -94,7 +94,7 @@ discard block |
||
| 94 | 94 | */ |
| 95 | 95 | public function getActiveViewIndex() |
| 96 | 96 | { |
| 97 | - return $this->getViewState('ActiveViewIndex',0); |
|
| 97 | + return $this->getViewState('ActiveViewIndex', 0); |
|
| 98 | 98 | } |
| 99 | 99 | |
| 100 | 100 | /** |
@@ -103,7 +103,7 @@ discard block |
||
| 103 | 103 | */ |
| 104 | 104 | public function setActiveViewIndex($value) |
| 105 | 105 | { |
| 106 | - $this->setViewState('ActiveViewIndex',TPropertyValue::ensureInteger($value),0); |
|
| 106 | + $this->setViewState('ActiveViewIndex', TPropertyValue::ensureInteger($value), 0); |
|
| 107 | 107 | $this->setActiveViewID(''); |
| 108 | 108 | } |
| 109 | 109 | |
@@ -115,7 +115,7 @@ discard block |
||
| 115 | 115 | */ |
| 116 | 116 | public function getActiveViewID() |
| 117 | 117 | { |
| 118 | - return $this->getViewState('ActiveViewID',''); |
|
| 118 | + return $this->getViewState('ActiveViewID', ''); |
|
| 119 | 119 | } |
| 120 | 120 | |
| 121 | 121 | /** |
@@ -123,7 +123,7 @@ discard block |
||
| 123 | 123 | */ |
| 124 | 124 | public function setActiveViewID($value) |
| 125 | 125 | { |
| 126 | - $this->setViewState('ActiveViewID',$value,''); |
|
| 126 | + $this->setViewState('ActiveViewID', $value, ''); |
|
| 127 | 127 | } |
| 128 | 128 | |
| 129 | 129 | /** |
@@ -139,17 +139,17 @@ discard block |
||
| 139 | 139 | $views=$this->getViews(); |
| 140 | 140 | if(($id=$this->getActiveViewID())!=='') |
| 141 | 141 | { |
| 142 | - if(($index=$views->findIndexByID($id))>=0) |
|
| 142 | + if(($index=$views->findIndexByID($id)) >= 0) |
|
| 143 | 143 | $activeView=$views->itemAt($index); |
| 144 | 144 | else |
| 145 | - throw new TInvalidDataValueException('accordion_activeviewid_invalid',$id); |
|
| 145 | + throw new TInvalidDataValueException('accordion_activeviewid_invalid', $id); |
|
| 146 | 146 | } |
| 147 | - else if(($index=$this->getActiveViewIndex())>=0) |
|
| 147 | + else if(($index=$this->getActiveViewIndex()) >= 0) |
|
| 148 | 148 | { |
| 149 | - if($index<$views->getCount()) |
|
| 149 | + if($index < $views->getCount()) |
|
| 150 | 150 | $activeView=$views->itemAt($index); |
| 151 | 151 | else |
| 152 | - throw new TInvalidDataValueException('accordion_activeviewindex_invalid',$index); |
|
| 152 | + throw new TInvalidDataValueException('accordion_activeviewindex_invalid', $index); |
|
| 153 | 153 | } |
| 154 | 154 | else |
| 155 | 155 | { |
@@ -173,7 +173,7 @@ discard block |
||
| 173 | 173 | */ |
| 174 | 174 | public function setActiveView($view) |
| 175 | 175 | { |
| 176 | - if($this->getViews()->indexOf($view)>=0) |
|
| 176 | + if($this->getViews()->indexOf($view) >= 0) |
|
| 177 | 177 | $this->activateView($view); |
| 178 | 178 | else |
| 179 | 179 | throw new TInvalidOperationException('accordion_view_inexistent'); |
@@ -184,7 +184,7 @@ discard block |
||
| 184 | 184 | */ |
| 185 | 185 | public function getCssUrl() |
| 186 | 186 | { |
| 187 | - return $this->getViewState('CssUrl','default'); |
|
| 187 | + return $this->getViewState('CssUrl', 'default'); |
|
| 188 | 188 | } |
| 189 | 189 | |
| 190 | 190 | /** |
@@ -192,7 +192,7 @@ discard block |
||
| 192 | 192 | */ |
| 193 | 193 | public function setCssUrl($value) |
| 194 | 194 | { |
| 195 | - $this->setViewState('CssUrl',TPropertyValue::ensureString($value),''); |
|
| 195 | + $this->setViewState('CssUrl', TPropertyValue::ensureString($value), ''); |
|
| 196 | 196 | } |
| 197 | 197 | |
| 198 | 198 | /** |
@@ -201,7 +201,7 @@ discard block |
||
| 201 | 201 | public function getCssClass() |
| 202 | 202 | { |
| 203 | 203 | $cssClass=parent::getCssClass(); |
| 204 | - return $cssClass===''?'accordion':$cssClass; |
|
| 204 | + return $cssClass==='' ? 'accordion' : $cssClass; |
|
| 205 | 205 | } |
| 206 | 206 | |
| 207 | 207 | /** |
@@ -225,7 +225,7 @@ discard block |
||
| 225 | 225 | */ |
| 226 | 226 | public function getAnimationDuration() |
| 227 | 227 | { |
| 228 | - return $this->getViewState('AnimationDuration','1'); |
|
| 228 | + return $this->getViewState('AnimationDuration', '1'); |
|
| 229 | 229 | } |
| 230 | 230 | |
| 231 | 231 | /** |
@@ -233,7 +233,7 @@ discard block |
||
| 233 | 233 | */ |
| 234 | 234 | public function setAnimationDuration($value) |
| 235 | 235 | { |
| 236 | - $this->setViewState('AnimationDuration',$value); |
|
| 236 | + $this->setViewState('AnimationDuration', $value); |
|
| 237 | 237 | } |
| 238 | 238 | |
| 239 | 239 | /** |
@@ -241,11 +241,11 @@ discard block |
||
| 241 | 241 | */ |
| 242 | 242 | public function getViewStyle() |
| 243 | 243 | { |
| 244 | - if(($style=$this->getViewState('ViewStyle',null))===null) |
|
| 244 | + if(($style=$this->getViewState('ViewStyle', null))===null) |
|
| 245 | 245 | { |
| 246 | 246 | $style=new TStyle; |
| 247 | 247 | $style->setCssClass('accordion-view'); |
| 248 | - $this->setViewState('ViewStyle',$style,null); |
|
| 248 | + $this->setViewState('ViewStyle', $style, null); |
|
| 249 | 249 | } |
| 250 | 250 | return $style; |
| 251 | 251 | } |
@@ -271,11 +271,11 @@ discard block |
||
| 271 | 271 | */ |
| 272 | 272 | public function getHeaderStyle() |
| 273 | 273 | { |
| 274 | - if(($style=$this->getViewState('HeaderStyle',null))===null) |
|
| 274 | + if(($style=$this->getViewState('HeaderStyle', null))===null) |
|
| 275 | 275 | { |
| 276 | 276 | $style=new TStyle; |
| 277 | 277 | $style->setCssClass('accordion-header'); |
| 278 | - $this->setViewState('HeaderStyle',$style,null); |
|
| 278 | + $this->setViewState('HeaderStyle', $style, null); |
|
| 279 | 279 | } |
| 280 | 280 | return $style; |
| 281 | 281 | } |
@@ -301,11 +301,11 @@ discard block |
||
| 301 | 301 | */ |
| 302 | 302 | public function getActiveHeaderStyle() |
| 303 | 303 | { |
| 304 | - if(($style=$this->getViewState('ActiveHeaderStyle',null))===null) |
|
| 304 | + if(($style=$this->getViewState('ActiveHeaderStyle', null))===null) |
|
| 305 | 305 | { |
| 306 | 306 | $style=new TStyle; |
| 307 | 307 | $style->setCssClass('accordion-header-active'); |
| 308 | - $this->setViewState('ActiveHeaderStyle',$style,null); |
|
| 308 | + $this->setViewState('ActiveHeaderStyle', $style, null); |
|
| 309 | 309 | } |
| 310 | 310 | return $style; |
| 311 | 311 | } |
@@ -355,11 +355,11 @@ discard block |
||
| 355 | 355 | * @param array the input data collection |
| 356 | 356 | * @return boolean whether the data of the control has been changed |
| 357 | 357 | */ |
| 358 | - public function loadPostData($key,$values) |
|
| 358 | + public function loadPostData($key, $values) |
|
| 359 | 359 | { |
| 360 | 360 | if(($index=$values[$this->getClientID().'_1'])!==null) |
| 361 | 361 | { |
| 362 | - $index=(int)$index; |
|
| 362 | + $index=(int) $index; |
|
| 363 | 363 | $currentIndex=$this->getActiveViewIndex(); |
| 364 | 364 | if($currentIndex!==$index) |
| 365 | 365 | { |
@@ -399,7 +399,7 @@ discard block |
||
| 399 | 399 | */ |
| 400 | 400 | protected function addAttributesToRender($writer) |
| 401 | 401 | { |
| 402 | - $writer->addAttribute('id',$this->getClientID()); |
|
| 402 | + $writer->addAttribute('id', $this->getClientID()); |
|
| 403 | 403 | $this->setCssClass($this->getCssClass()); |
| 404 | 404 | parent::addAttributesToRender($writer); |
| 405 | 405 | } |
@@ -412,7 +412,7 @@ discard block |
||
| 412 | 412 | public function onPreRender($param) |
| 413 | 413 | { |
| 414 | 414 | parent::onPreRender($param); |
| 415 | - $this->getActiveView(); // determine the active view |
|
| 415 | + $this->getActiveView(); // determine the active view |
|
| 416 | 416 | $this->registerStyleSheet(); |
| 417 | 417 | } |
| 418 | 418 | |
@@ -423,17 +423,17 @@ discard block |
||
| 423 | 423 | */ |
| 424 | 424 | protected function registerStyleSheet() |
| 425 | 425 | { |
| 426 | - $url = $this->getCssUrl(); |
|
| 426 | + $url=$this->getCssUrl(); |
|
| 427 | 427 | |
| 428 | - if($url === '') { |
|
| 428 | + if($url==='') { |
|
| 429 | 429 | return; |
| 430 | 430 | } |
| 431 | 431 | |
| 432 | - if($url === 'default') { |
|
| 433 | - $url = $this->getApplication()->getAssetManager()->publishFilePath(dirname(__FILE__).DIRECTORY_SEPARATOR.'assets'.DIRECTORY_SEPARATOR.'accordion.css'); |
|
| 432 | + if($url==='default') { |
|
| 433 | + $url=$this->getApplication()->getAssetManager()->publishFilePath(dirname(__FILE__).DIRECTORY_SEPARATOR.'assets'.DIRECTORY_SEPARATOR.'accordion.css'); |
|
| 434 | 434 | } |
| 435 | 435 | |
| 436 | - if($url !== '') { |
|
| 436 | + if($url!=='') { |
|
| 437 | 437 | $this->getPage()->getClientScript()->registerStyleSheetFile($url, $url); |
| 438 | 438 | } |
| 439 | 439 | } |
@@ -452,7 +452,7 @@ discard block |
||
| 452 | 452 | $code="new $className($options);"; |
| 453 | 453 | $cs->registerEndScript("prado:$id", $code); |
| 454 | 454 | // ensure an item is always active and visible |
| 455 | - $index = $this->getActiveViewIndex(); |
|
| 455 | + $index=$this->getActiveViewIndex(); |
|
| 456 | 456 | if(!$this->getViews()->itemAt($index)->Visible) |
| 457 | 457 | $index=0; |
| 458 | 458 | $cs->registerHiddenField($id.'_1', $index); |
@@ -475,17 +475,17 @@ discard block |
||
| 475 | 475 | */ |
| 476 | 476 | protected function getClientOptions() |
| 477 | 477 | { |
| 478 | - $options['ID'] = $this->getClientID(); |
|
| 479 | - $options['ActiveHeaderCssClass'] = $this->getActiveHeaderCssClass(); |
|
| 480 | - $options['HeaderCssClass'] = $this->getHeaderCssClass(); |
|
| 481 | - $options['Duration'] = $this->getAnimationDuration(); |
|
| 478 | + $options['ID']=$this->getClientID(); |
|
| 479 | + $options['ActiveHeaderCssClass']=$this->getActiveHeaderCssClass(); |
|
| 480 | + $options['HeaderCssClass']=$this->getHeaderCssClass(); |
|
| 481 | + $options['Duration']=$this->getAnimationDuration(); |
|
| 482 | 482 | |
| 483 | - if (($viewheight = $this->getViewHeight())>0) |
|
| 484 | - $options['maxHeight'] = $viewheight; |
|
| 485 | - $views = array(); |
|
| 483 | + if(($viewheight=$this->getViewHeight()) > 0) |
|
| 484 | + $options['maxHeight']=$viewheight; |
|
| 485 | + $views=array(); |
|
| 486 | 486 | foreach($this->getViews() as $view) |
| 487 | - $views[$view->getClientID()] = $view->getVisible() ? '1': '0'; |
|
| 488 | - $options['Views'] = $views; |
|
| 487 | + $views[$view->getClientID()]=$view->getVisible() ? '1' : '0'; |
|
| 488 | + $options['Views']=$views; |
|
| 489 | 489 | |
| 490 | 490 | return $options; |
| 491 | 491 | } |
@@ -520,7 +520,7 @@ discard block |
||
| 520 | 520 | public function renderContents($writer) |
| 521 | 521 | { |
| 522 | 522 | $views=$this->getViews(); |
| 523 | - if($views->getCount()>0) |
|
| 523 | + if($views->getCount() > 0) |
|
| 524 | 524 | { |
| 525 | 525 | $writer->writeLine(); |
| 526 | 526 | foreach($views as $view) |
@@ -566,13 +566,13 @@ discard block |
||
| 566 | 566 | protected function addAttributesToRender($writer) |
| 567 | 567 | { |
| 568 | 568 | if(!$this->getActive() && $this->getPage()->getClientSupportsJavaScript()) |
| 569 | - $this->getStyle()->setStyleField('display','none'); |
|
| 569 | + $this->getStyle()->setStyleField('display', 'none'); |
|
| 570 | 570 | |
| 571 | 571 | $this->getStyle()->mergeWith($this->getParent()->getViewStyle()); |
| 572 | 572 | |
| 573 | 573 | parent::addAttributesToRender($writer); |
| 574 | 574 | |
| 575 | - $writer->addAttribute('id',$this->getClientID()); |
|
| 575 | + $writer->addAttribute('id', $this->getClientID()); |
|
| 576 | 576 | } |
| 577 | 577 | |
| 578 | 578 | /** |
@@ -580,7 +580,7 @@ discard block |
||
| 580 | 580 | */ |
| 581 | 581 | public function getCaption() |
| 582 | 582 | { |
| 583 | - return $this->getViewState('Caption',''); |
|
| 583 | + return $this->getViewState('Caption', ''); |
|
| 584 | 584 | } |
| 585 | 585 | |
| 586 | 586 | /** |
@@ -588,7 +588,7 @@ discard block |
||
| 588 | 588 | */ |
| 589 | 589 | public function setCaption($value) |
| 590 | 590 | { |
| 591 | - $this->setViewState('Caption',TPropertyValue::ensureString($value),''); |
|
| 591 | + $this->setViewState('Caption', TPropertyValue::ensureString($value), ''); |
|
| 592 | 592 | } |
| 593 | 593 | |
| 594 | 594 | /** |
@@ -596,7 +596,7 @@ discard block |
||
| 596 | 596 | */ |
| 597 | 597 | public function getNavigateUrl() |
| 598 | 598 | { |
| 599 | - return $this->getViewState('NavigateUrl',''); |
|
| 599 | + return $this->getViewState('NavigateUrl', ''); |
|
| 600 | 600 | } |
| 601 | 601 | |
| 602 | 602 | /** |
@@ -606,7 +606,7 @@ discard block |
||
| 606 | 606 | */ |
| 607 | 607 | public function setNavigateUrl($value) |
| 608 | 608 | { |
| 609 | - $this->setViewState('NavigateUrl',TPropertyValue::ensureString($value),''); |
|
| 609 | + $this->setViewState('NavigateUrl', TPropertyValue::ensureString($value), ''); |
|
| 610 | 610 | } |
| 611 | 611 | |
| 612 | 612 | /** |
@@ -614,7 +614,7 @@ discard block |
||
| 614 | 614 | */ |
| 615 | 615 | public function getText() |
| 616 | 616 | { |
| 617 | - return $this->getViewState('Text',''); |
|
| 617 | + return $this->getViewState('Text', ''); |
|
| 618 | 618 | } |
| 619 | 619 | |
| 620 | 620 | /** |
@@ -624,7 +624,7 @@ discard block |
||
| 624 | 624 | */ |
| 625 | 625 | public function setText($value) |
| 626 | 626 | { |
| 627 | - $this->setViewState('Text',TPropertyValue::ensureString($value),''); |
|
| 627 | + $this->setViewState('Text', TPropertyValue::ensureString($value), ''); |
|
| 628 | 628 | } |
| 629 | 629 | |
| 630 | 630 | /** |
@@ -663,9 +663,9 @@ discard block |
||
| 663 | 663 | { |
| 664 | 664 | if($this->getVisible(false) && $this->getPage()->getClientSupportsJavaScript()) |
| 665 | 665 | { |
| 666 | - $writer->addAttribute('id',$this->getClientID().'_0'); |
|
| 666 | + $writer->addAttribute('id', $this->getClientID().'_0'); |
|
| 667 | 667 | |
| 668 | - $style=$this->getActive()?$this->getParent()->getActiveHeaderStyle():$this->getParent()->getHeaderStyle(); |
|
| 668 | + $style=$this->getActive() ? $this->getParent()->getActiveHeaderStyle() : $this->getParent()->getHeaderStyle(); |
|
| 669 | 669 | |
| 670 | 670 | $style->addAttributesToRender($writer); |
| 671 | 671 | |
@@ -684,14 +684,14 @@ discard block |
||
| 684 | 684 | */ |
| 685 | 685 | protected function renderHeaderContent($writer) |
| 686 | 686 | { |
| 687 | - $url = $this->getNavigateUrl(); |
|
| 687 | + $url=$this->getNavigateUrl(); |
|
| 688 | 688 | if(($caption=$this->getCaption())==='') |
| 689 | 689 | $caption=' '; |
| 690 | 690 | |
| 691 | - if ($url!='') |
|
| 691 | + if($url!='') |
|
| 692 | 692 | $writer->write("<a href=\"{$url}\">"); |
| 693 | 693 | $writer->write("{$caption}"); |
| 694 | - if ($url!='') |
|
| 694 | + if($url!='') |
|
| 695 | 695 | $writer->write("</a>"); |
| 696 | 696 | } |
| 697 | 697 | } |
@@ -714,10 +714,10 @@ discard block |
||
| 714 | 714 | * @param mixed new item |
| 715 | 715 | * @throws TInvalidDataTypeException if the item to be inserted is not a {@link TAccordionView} object. |
| 716 | 716 | */ |
| 717 | - public function insertAt($index,$item) |
|
| 717 | + public function insertAt($index, $item) |
|
| 718 | 718 | { |
| 719 | 719 | if($item instanceof TAccordionView) |
| 720 | - parent::insertAt($index,$item); |
|
| 720 | + parent::insertAt($index, $item); |
|
| 721 | 721 | else |
| 722 | 722 | throw new TInvalidDataTypeException('tabviewcollection_tabview_required'); |
| 723 | 723 | } |
@@ -136,15 +136,13 @@ discard block |
||
| 136 | 136 | $activeView=$views->itemAt($index); |
| 137 | 137 | else |
| 138 | 138 | throw new TInvalidDataValueException('tabpanel_activeviewid_invalid',$id); |
| 139 | - } |
|
| 140 | - else if(($index=$this->getActiveViewIndex())>=0) |
|
| 139 | + } else if(($index=$this->getActiveViewIndex())>=0) |
|
| 141 | 140 | { |
| 142 | 141 | if($index<$views->getCount()) |
| 143 | 142 | $activeView=$views->itemAt($index); |
| 144 | 143 | else |
| 145 | 144 | throw new TInvalidDataValueException('tabpanel_activeviewindex_invalid',$index); |
| 146 | - } |
|
| 147 | - else |
|
| 145 | + } else |
|
| 148 | 146 | { |
| 149 | 147 | foreach($views as $index=>$view) |
| 150 | 148 | { |
@@ -320,8 +318,7 @@ discard block |
||
| 320 | 318 | $this->setActiveViewIndex($index); |
| 321 | 319 | $this->setActiveViewID($view->getID(false)); |
| 322 | 320 | $view->setActive(true); |
| 323 | - } |
|
| 324 | - else |
|
| 321 | + } else |
|
| 325 | 322 | $v->setActive(false); |
| 326 | 323 | } |
| 327 | 324 | } |
@@ -46,50 +46,50 @@ discard block |
||
| 46 | 46 | * @throws TConfigurationException If XSL extension is not available |
| 47 | 47 | */ |
| 48 | 48 | public function __construct() { |
| 49 | - if(!class_exists('XSLTProcessor', false)) { |
|
| 50 | - throw new TConfigurationException('xmltransform_xslextension_required'); |
|
| 51 | - } |
|
| 49 | + if(!class_exists('XSLTProcessor', false)) { |
|
| 50 | + throw new TConfigurationException('xmltransform_xslextension_required'); |
|
| 51 | + } |
|
| 52 | 52 | } |
| 53 | 53 | |
| 54 | 54 | /** |
| 55 | 55 | * @return string The path to the XML style sheet. |
| 56 | 56 | */ |
| 57 | 57 | public function getTransformPath() { |
| 58 | - return $this->getViewState('TransformPath', ''); |
|
| 58 | + return $this->getViewState('TransformPath', ''); |
|
| 59 | 59 | } |
| 60 | 60 | |
| 61 | 61 | /** |
| 62 | 62 | * @param string The path to the XML style sheet. It must be in namespace format. |
| 63 | 63 | */ |
| 64 | 64 | public function setTransformPath($value) { |
| 65 | - if(!is_file($value)) { |
|
| 66 | - $value = Prado::getPathOfNamespace($value, self::EXT_XSL_FILE); |
|
| 67 | - if($value === null) { |
|
| 65 | + if(!is_file($value)) { |
|
| 66 | + $value = Prado::getPathOfNamespace($value, self::EXT_XSL_FILE); |
|
| 67 | + if($value === null) { |
|
| 68 | 68 | throw new TInvalidDataValueException('xmltransform_transformpath_invalid', $value); |
| 69 | - } |
|
| 70 | - } |
|
| 71 | - $this->setViewState('TransformPath', $value, ''); |
|
| 69 | + } |
|
| 70 | + } |
|
| 71 | + $this->setViewState('TransformPath', $value, ''); |
|
| 72 | 72 | } |
| 73 | 73 | |
| 74 | 74 | /** |
| 75 | 75 | * @return string XML style sheet as string |
| 76 | 76 | */ |
| 77 | 77 | public function getTransformContent() { |
| 78 | - return $this->getViewState('TransformContent', ''); |
|
| 78 | + return $this->getViewState('TransformContent', ''); |
|
| 79 | 79 | } |
| 80 | 80 | |
| 81 | 81 | /** |
| 82 | 82 | * @param string $value XML style sheet as string |
| 83 | 83 | */ |
| 84 | 84 | public function setTransformContent($value) { |
| 85 | - $this->setViewState('TransformContent', $value, ''); |
|
| 85 | + $this->setViewState('TransformContent', $value, ''); |
|
| 86 | 86 | } |
| 87 | 87 | |
| 88 | 88 | /** |
| 89 | 89 | * @return string The path to the XML document. It must be in namespace format. |
| 90 | 90 | */ |
| 91 | 91 | public function getDocumentPath() { |
| 92 | - return $this->getViewState('DocumentPath', ''); |
|
| 92 | + return $this->getViewState('DocumentPath', ''); |
|
| 93 | 93 | } |
| 94 | 94 | |
| 95 | 95 | /** |
@@ -97,27 +97,27 @@ discard block |
||
| 97 | 97 | * @throws TInvalidDataValueException |
| 98 | 98 | */ |
| 99 | 99 | public function setDocumentPath($value) { |
| 100 | - if(!is_file($value)) { |
|
| 101 | - $value = Prado::getPathOfNamespace($value, self::EXT_XML_FILE); |
|
| 102 | - if($value === null) { |
|
| 100 | + if(!is_file($value)) { |
|
| 101 | + $value = Prado::getPathOfNamespace($value, self::EXT_XML_FILE); |
|
| 102 | + if($value === null) { |
|
| 103 | 103 | throw new TInvalidDataValueException('xmltransform_documentpath_invalid', $value); |
| 104 | - } |
|
| 105 | - } |
|
| 106 | - $this->setViewState('DocumentPath', $value, ''); |
|
| 104 | + } |
|
| 105 | + } |
|
| 106 | + $this->setViewState('DocumentPath', $value, ''); |
|
| 107 | 107 | } |
| 108 | 108 | |
| 109 | 109 | /** |
| 110 | 110 | * @return string XML data |
| 111 | 111 | */ |
| 112 | 112 | public function getDocumentContent() { |
| 113 | - return $this->getViewState('DocumentContent', ''); |
|
| 113 | + return $this->getViewState('DocumentContent', ''); |
|
| 114 | 114 | } |
| 115 | 115 | |
| 116 | 116 | /** |
| 117 | 117 | * @param string $value XML data. If not empty, it takes precedence over {@link setDocumentPath DocumentPath}. |
| 118 | 118 | */ |
| 119 | 119 | public function setDocumentContent($value) { |
| 120 | - $this->setViewState('DocumentContent', $value, ''); |
|
| 120 | + $this->setViewState('DocumentContent', $value, ''); |
|
| 121 | 121 | } |
| 122 | 122 | |
| 123 | 123 | /** |
@@ -125,41 +125,41 @@ discard block |
||
| 125 | 125 | * @return TAttributeCollection the list of custom parameters |
| 126 | 126 | */ |
| 127 | 127 | public function getParameters() { |
| 128 | - if($params = $this->getViewState('Parameters',null)) { |
|
| 129 | - return $params; |
|
| 130 | - } else { |
|
| 131 | - $params = new TAttributeCollection(); |
|
| 132 | - $this->setViewState('Parameters', $params, null); |
|
| 133 | - return $params; |
|
| 134 | - } |
|
| 128 | + if($params = $this->getViewState('Parameters',null)) { |
|
| 129 | + return $params; |
|
| 130 | + } else { |
|
| 131 | + $params = new TAttributeCollection(); |
|
| 132 | + $this->setViewState('Parameters', $params, null); |
|
| 133 | + return $params; |
|
| 134 | + } |
|
| 135 | 135 | } |
| 136 | 136 | |
| 137 | 137 | private function getTransformXmlDocument() { |
| 138 | - if(($content = $this->getTransformContent()) !== '') { |
|
| 139 | - $document = new DOMDocument(); |
|
| 140 | - $document->loadXML($content); |
|
| 141 | - return $document; |
|
| 142 | - } else if(($path = $this->getTransformPath()) !== '') { |
|
| 143 | - $document = new DOMDocument(); |
|
| 144 | - $document->load($path); |
|
| 145 | - return $document; |
|
| 146 | - } else { |
|
| 147 | - throw new TConfigurationException('xmltransform_transform_required'); |
|
| 148 | - } |
|
| 138 | + if(($content = $this->getTransformContent()) !== '') { |
|
| 139 | + $document = new DOMDocument(); |
|
| 140 | + $document->loadXML($content); |
|
| 141 | + return $document; |
|
| 142 | + } else if(($path = $this->getTransformPath()) !== '') { |
|
| 143 | + $document = new DOMDocument(); |
|
| 144 | + $document->load($path); |
|
| 145 | + return $document; |
|
| 146 | + } else { |
|
| 147 | + throw new TConfigurationException('xmltransform_transform_required'); |
|
| 148 | + } |
|
| 149 | 149 | } |
| 150 | 150 | |
| 151 | 151 | private function getSourceXmlDocument() { |
| 152 | - if(($content = $this->getDocumentContent()) !== '') { |
|
| 153 | - $document = new DOMDocument(); |
|
| 154 | - $document->loadXML($content); |
|
| 155 | - return $document; |
|
| 156 | - } else if(($path = $this->getDocumentPath()) !== '') { |
|
| 157 | - $document = new DOMDocument(); |
|
| 158 | - $document->load($path); |
|
| 159 | - return $document; |
|
| 160 | - } else { |
|
| 161 | - return null; |
|
| 162 | - } |
|
| 152 | + if(($content = $this->getDocumentContent()) !== '') { |
|
| 153 | + $document = new DOMDocument(); |
|
| 154 | + $document->loadXML($content); |
|
| 155 | + return $document; |
|
| 156 | + } else if(($path = $this->getDocumentPath()) !== '') { |
|
| 157 | + $document = new DOMDocument(); |
|
| 158 | + $document->load($path); |
|
| 159 | + return $document; |
|
| 160 | + } else { |
|
| 161 | + return null; |
|
| 162 | + } |
|
| 163 | 163 | } |
| 164 | 164 | |
| 165 | 165 | /** |
@@ -167,27 +167,27 @@ discard block |
||
| 167 | 167 | * @param THtmlWriter The writer used for the rendering purpose |
| 168 | 168 | */ |
| 169 | 169 | public function render($writer) { |
| 170 | - if(($document=$this->getSourceXmlDocument()) === null) { |
|
| 170 | + if(($document=$this->getSourceXmlDocument()) === null) { |
|
| 171 | 171 | $htmlWriter = Prado::createComponent($this->GetResponse()->getHtmlWriterType(), new TTextWriter()); |
| 172 | 172 | parent::render($htmlWriter); |
| 173 | - $document = new DOMDocument(); |
|
| 174 | - $document->loadXML($htmlWriter->flush()); |
|
| 175 | - } |
|
| 176 | - $stylesheet = $this->getTransformXmlDocument(); |
|
| 177 | - |
|
| 178 | - // Perform XSL transformation |
|
| 179 | - $xslt = new XSLTProcessor(); |
|
| 180 | - $xslt->importStyleSheet($stylesheet); |
|
| 181 | - |
|
| 182 | - // Check for parameters |
|
| 183 | - $parameters = $this->getParameters(); |
|
| 184 | - foreach($parameters as $name => $value) { |
|
| 185 | - $xslt->setParameter('', $name, $value); |
|
| 186 | - } |
|
| 187 | - $output = $xslt->transformToXML($document); |
|
| 188 | - |
|
| 189 | - // Write output |
|
| 190 | - $writer->write($output); |
|
| 173 | + $document = new DOMDocument(); |
|
| 174 | + $document->loadXML($htmlWriter->flush()); |
|
| 175 | + } |
|
| 176 | + $stylesheet = $this->getTransformXmlDocument(); |
|
| 177 | + |
|
| 178 | + // Perform XSL transformation |
|
| 179 | + $xslt = new XSLTProcessor(); |
|
| 180 | + $xslt->importStyleSheet($stylesheet); |
|
| 181 | + |
|
| 182 | + // Check for parameters |
|
| 183 | + $parameters = $this->getParameters(); |
|
| 184 | + foreach($parameters as $name => $value) { |
|
| 185 | + $xslt->setParameter('', $name, $value); |
|
| 186 | + } |
|
| 187 | + $output = $xslt->transformToXML($document); |
|
| 188 | + |
|
| 189 | + // Write output |
|
| 190 | + $writer->write($output); |
|
| 191 | 191 | } |
| 192 | 192 | } |
| 193 | 193 | |
@@ -36,8 +36,8 @@ discard block |
||
| 36 | 36 | */ |
| 37 | 37 | class TXmlTransform extends TControl { |
| 38 | 38 | |
| 39 | - const EXT_XML_FILE = '.xml'; |
|
| 40 | - const EXT_XSL_FILE = '.xsl'; |
|
| 39 | + const EXT_XML_FILE='.xml'; |
|
| 40 | + const EXT_XSL_FILE='.xsl'; |
|
| 41 | 41 | |
| 42 | 42 | /** |
| 43 | 43 | * Constructor |
@@ -63,8 +63,8 @@ discard block |
||
| 63 | 63 | */ |
| 64 | 64 | public function setTransformPath($value) { |
| 65 | 65 | if(!is_file($value)) { |
| 66 | - $value = Prado::getPathOfNamespace($value, self::EXT_XSL_FILE); |
|
| 67 | - if($value === null) { |
|
| 66 | + $value=Prado::getPathOfNamespace($value, self::EXT_XSL_FILE); |
|
| 67 | + if($value===null) { |
|
| 68 | 68 | throw new TInvalidDataValueException('xmltransform_transformpath_invalid', $value); |
| 69 | 69 | } |
| 70 | 70 | } |
@@ -98,8 +98,8 @@ discard block |
||
| 98 | 98 | */ |
| 99 | 99 | public function setDocumentPath($value) { |
| 100 | 100 | if(!is_file($value)) { |
| 101 | - $value = Prado::getPathOfNamespace($value, self::EXT_XML_FILE); |
|
| 102 | - if($value === null) { |
|
| 101 | + $value=Prado::getPathOfNamespace($value, self::EXT_XML_FILE); |
|
| 102 | + if($value===null) { |
|
| 103 | 103 | throw new TInvalidDataValueException('xmltransform_documentpath_invalid', $value); |
| 104 | 104 | } |
| 105 | 105 | } |
@@ -125,22 +125,22 @@ discard block |
||
| 125 | 125 | * @return TAttributeCollection the list of custom parameters |
| 126 | 126 | */ |
| 127 | 127 | public function getParameters() { |
| 128 | - if($params = $this->getViewState('Parameters',null)) { |
|
| 128 | + if($params=$this->getViewState('Parameters', null)) { |
|
| 129 | 129 | return $params; |
| 130 | 130 | } else { |
| 131 | - $params = new TAttributeCollection(); |
|
| 131 | + $params=new TAttributeCollection(); |
|
| 132 | 132 | $this->setViewState('Parameters', $params, null); |
| 133 | 133 | return $params; |
| 134 | 134 | } |
| 135 | 135 | } |
| 136 | 136 | |
| 137 | 137 | private function getTransformXmlDocument() { |
| 138 | - if(($content = $this->getTransformContent()) !== '') { |
|
| 139 | - $document = new DOMDocument(); |
|
| 138 | + if(($content=$this->getTransformContent())!=='') { |
|
| 139 | + $document=new DOMDocument(); |
|
| 140 | 140 | $document->loadXML($content); |
| 141 | 141 | return $document; |
| 142 | - } else if(($path = $this->getTransformPath()) !== '') { |
|
| 143 | - $document = new DOMDocument(); |
|
| 142 | + } else if(($path=$this->getTransformPath())!=='') { |
|
| 143 | + $document=new DOMDocument(); |
|
| 144 | 144 | $document->load($path); |
| 145 | 145 | return $document; |
| 146 | 146 | } else { |
@@ -149,12 +149,12 @@ discard block |
||
| 149 | 149 | } |
| 150 | 150 | |
| 151 | 151 | private function getSourceXmlDocument() { |
| 152 | - if(($content = $this->getDocumentContent()) !== '') { |
|
| 153 | - $document = new DOMDocument(); |
|
| 152 | + if(($content=$this->getDocumentContent())!=='') { |
|
| 153 | + $document=new DOMDocument(); |
|
| 154 | 154 | $document->loadXML($content); |
| 155 | 155 | return $document; |
| 156 | - } else if(($path = $this->getDocumentPath()) !== '') { |
|
| 157 | - $document = new DOMDocument(); |
|
| 156 | + } else if(($path=$this->getDocumentPath())!=='') { |
|
| 157 | + $document=new DOMDocument(); |
|
| 158 | 158 | $document->load($path); |
| 159 | 159 | return $document; |
| 160 | 160 | } else { |
@@ -167,24 +167,24 @@ discard block |
||
| 167 | 167 | * @param THtmlWriter The writer used for the rendering purpose |
| 168 | 168 | */ |
| 169 | 169 | public function render($writer) { |
| 170 | - if(($document=$this->getSourceXmlDocument()) === null) { |
|
| 171 | - $htmlWriter = Prado::createComponent($this->GetResponse()->getHtmlWriterType(), new TTextWriter()); |
|
| 170 | + if(($document=$this->getSourceXmlDocument())===null) { |
|
| 171 | + $htmlWriter=Prado::createComponent($this->GetResponse()->getHtmlWriterType(), new TTextWriter()); |
|
| 172 | 172 | parent::render($htmlWriter); |
| 173 | - $document = new DOMDocument(); |
|
| 173 | + $document=new DOMDocument(); |
|
| 174 | 174 | $document->loadXML($htmlWriter->flush()); |
| 175 | 175 | } |
| 176 | - $stylesheet = $this->getTransformXmlDocument(); |
|
| 176 | + $stylesheet=$this->getTransformXmlDocument(); |
|
| 177 | 177 | |
| 178 | 178 | // Perform XSL transformation |
| 179 | - $xslt = new XSLTProcessor(); |
|
| 179 | + $xslt=new XSLTProcessor(); |
|
| 180 | 180 | $xslt->importStyleSheet($stylesheet); |
| 181 | 181 | |
| 182 | 182 | // Check for parameters |
| 183 | - $parameters = $this->getParameters(); |
|
| 183 | + $parameters=$this->getParameters(); |
|
| 184 | 184 | foreach($parameters as $name => $value) { |
| 185 | 185 | $xslt->setParameter('', $name, $value); |
| 186 | 186 | } |
| 187 | - $output = $xslt->transformToXML($document); |
|
| 187 | + $output=$xslt->transformToXML($document); |
|
| 188 | 188 | |
| 189 | 189 | // Write output |
| 190 | 190 | $writer->write($output); |
@@ -170,12 +170,12 @@ |
||
| 170 | 170 | public function validate() |
| 171 | 171 | { |
| 172 | 172 | if (! |
| 173 | - ( |
|
| 173 | + ( |
|
| 174 | 174 | ($challenge = @$_POST[$this->getChallengeFieldName()]) |
| 175 | 175 | and |
| 176 | 176 | ($response = @$_POST[$this->getResponseFieldName()]) |
| 177 | - ) |
|
| 178 | - ) |
|
| 177 | + ) |
|
| 178 | + ) |
|
| 179 | 179 | return false; |
| 180 | 180 | |
| 181 | 181 | $resp = recaptcha_check_answer( |
@@ -246,8 +246,7 @@ |
||
| 246 | 246 | $writer->write($html); |
| 247 | 247 | |
| 248 | 248 | $cs->registerEndScript('ReCaptcha::EventScript', 'jQuery(document).ready(function() { '.$readyscript.'; } );'); |
| 249 | - } |
|
| 250 | - else |
|
| 249 | + } else |
|
| 251 | 250 | { |
| 252 | 251 | $options = $this->getClientSideOptions(); |
| 253 | 252 | $options['callback'] = new TJavaScriptLiteral('function() { '.$readyscript.'; '.$this->getCallbackScript().'; }'); |
@@ -55,8 +55,8 @@ discard block |
||
| 55 | 55 | { |
| 56 | 56 | private $_isValid=true; |
| 57 | 57 | |
| 58 | - const ChallengeFieldName = 'recaptcha_challenge_field'; |
|
| 59 | - const ResponseFieldName = 'recaptcha_response_field'; |
|
| 58 | + const ChallengeFieldName='recaptcha_challenge_field'; |
|
| 59 | + const ResponseFieldName='recaptcha_response_field'; |
|
| 60 | 60 | |
| 61 | 61 | public function getTagName() |
| 62 | 62 | { |
@@ -157,28 +157,27 @@ discard block |
||
| 157 | 157 | |
| 158 | 158 | public function getClientSideOptions() |
| 159 | 159 | { |
| 160 | - $options = array(); |
|
| 161 | - if ($theme = $this->getThemeName()) |
|
| 162 | - $options['theme'] = $theme; |
|
| 163 | - if ($lang = $this->getLanguage()) |
|
| 164 | - $options['lang'] = $lang; |
|
| 165 | - if ($trans = $this->getCustomTranslations()) |
|
| 166 | - $options['custom_translations'] = $trans; |
|
| 160 | + $options=array(); |
|
| 161 | + if($theme=$this->getThemeName()) |
|
| 162 | + $options['theme']=$theme; |
|
| 163 | + if($lang=$this->getLanguage()) |
|
| 164 | + $options['lang']=$lang; |
|
| 165 | + if($trans=$this->getCustomTranslations()) |
|
| 166 | + $options['custom_translations']=$trans; |
|
| 167 | 167 | return $options; |
| 168 | 168 | } |
| 169 | 169 | |
| 170 | 170 | public function validate() |
| 171 | 171 | { |
| 172 | - if (! |
|
| 173 | - ( |
|
| 174 | - ($challenge = @$_POST[$this->getChallengeFieldName()]) |
|
| 172 | + if(!( |
|
| 173 | + ($challenge=@$_POST[$this->getChallengeFieldName()]) |
|
| 175 | 174 | and |
| 176 | - ($response = @$_POST[$this->getResponseFieldName()]) |
|
| 175 | + ($response=@$_POST[$this->getResponseFieldName()]) |
|
| 177 | 176 | ) |
| 178 | 177 | ) |
| 179 | 178 | return false; |
| 180 | 179 | |
| 181 | - $resp = recaptcha_check_answer( |
|
| 180 | + $resp=recaptcha_check_answer( |
|
| 182 | 181 | $this->getPrivateKey(), |
| 183 | 182 | $_SERVER["REMOTE_ADDR"], |
| 184 | 183 | $challenge, |
@@ -195,13 +194,13 @@ discard block |
||
| 195 | 194 | { |
| 196 | 195 | parent::onPreRender($param); |
| 197 | 196 | |
| 198 | - if("" == $this->getPublicKey()) |
|
| 197 | + if(""==$this->getPublicKey()) |
|
| 199 | 198 | throw new TConfigurationException('recaptcha_publickey_unknown'); |
| 200 | - if("" == $this->getPrivateKey()) |
|
| 199 | + if(""==$this->getPrivateKey()) |
|
| 201 | 200 | throw new TConfigurationException('recaptcha_privatekey_unknown'); |
| 202 | 201 | |
| 203 | 202 | // need to register captcha fields so they will be sent back also in callbacks |
| 204 | - $page = $this->getPage(); |
|
| 203 | + $page=$this->getPage(); |
|
| 205 | 204 | $page->registerRequiresPostData($this->getChallengeFieldName()); |
| 206 | 205 | $page->registerRequiresPostData($this->getResponseFieldName()); |
| 207 | 206 | } |
@@ -209,32 +208,32 @@ discard block |
||
| 209 | 208 | protected function addAttributesToRender($writer) |
| 210 | 209 | { |
| 211 | 210 | parent::addAttributesToRender($writer); |
| 212 | - $writer->addAttribute('id',$this->getClientID()); |
|
| 211 | + $writer->addAttribute('id', $this->getClientID()); |
|
| 213 | 212 | } |
| 214 | 213 | |
| 215 | 214 | public function regenerateToken() |
| 216 | 215 | { |
| 217 | 216 | // if we're in a callback, then schedule re-rendering of the control |
| 218 | 217 | // if not, don't do anything, because a new challenge will be rendered anyway |
| 219 | - if ($this->Page->IsCallback) |
|
| 220 | - $this->Page->CallbackClient->jQuery($this->getClientID().' #recaptcha_reload','click'); |
|
| 218 | + if($this->Page->IsCallback) |
|
| 219 | + $this->Page->CallbackClient->jQuery($this->getClientID().' #recaptcha_reload', 'click'); |
|
| 221 | 220 | } |
| 222 | 221 | |
| 223 | 222 | public function renderContents($writer) |
| 224 | 223 | { |
| 225 | - $readyscript = 'jQuery(document).trigger('.TJavaScript::quoteString('captchaready:'.$this->getClientID()).')'; |
|
| 226 | - $cs = $this->Page->ClientScript; |
|
| 227 | - $id = $this->getClientID(); |
|
| 228 | - $divid = $id.'_1_recaptchadiv'; |
|
| 224 | + $readyscript='jQuery(document).trigger('.TJavaScript::quoteString('captchaready:'.$this->getClientID()).')'; |
|
| 225 | + $cs=$this->Page->ClientScript; |
|
| 226 | + $id=$this->getClientID(); |
|
| 227 | + $divid=$id.'_1_recaptchadiv'; |
|
| 229 | 228 | $writer->write('<div id="'.htmlspecialchars($divid).'">'); |
| 230 | 229 | |
| 231 | - if (!$this->Page->IsCallback) |
|
| 230 | + if(!$this->Page->IsCallback) |
|
| 232 | 231 | { |
| 233 | 232 | $writer->write(TJavaScript::renderScriptBlock( |
| 234 | 233 | 'var RecaptchaOptions = '.TJavaScript::jsonEncode($this->getClientSideOptions()).';' |
| 235 | 234 | )); |
| 236 | 235 | |
| 237 | - $html = recaptcha_get_html($this->getPublicKey()); |
|
| 236 | + $html=recaptcha_get_html($this->getPublicKey()); |
|
| 238 | 237 | /* |
| 239 | 238 | reCAPTCHA currently does not support multiple validations per page |
| 240 | 239 | $html = str_replace( |
@@ -249,8 +248,8 @@ discard block |
||
| 249 | 248 | } |
| 250 | 249 | else |
| 251 | 250 | { |
| 252 | - $options = $this->getClientSideOptions(); |
|
| 253 | - $options['callback'] = new TJavaScriptLiteral('function() { '.$readyscript.'; '.$this->getCallbackScript().'; }'); |
|
| 251 | + $options=$this->getClientSideOptions(); |
|
| 252 | + $options['callback']=new TJavaScriptLiteral('function() { '.$readyscript.'; '.$this->getCallbackScript().'; }'); |
|
| 254 | 253 | $cs->registerScriptFile('ReCaptcha::AjaxScript', 'http://www.google.com/recaptcha/api/js/recaptcha_ajax.js'); |
| 255 | 254 | $cs->registerEndScript('ReCaptcha::CreateScript::'.$id, implode(' ', array( |
| 256 | 255 | 'if (!jQuery('.TJavaScript::quoteString('#'.$this->getResponseFieldName()).'))', |