@@ -55,11 +55,11 @@ discard block |
||
55 | 55 | if($this->_cacheModuleID==='') |
56 | 56 | throw new TConfigurationException('cachesession_cachemoduleid_required'); |
57 | 57 | else if(($cache=$this->getApplication()->getModule($this->_cacheModuleID))===null) |
58 | - throw new TConfigurationException('cachesession_cachemodule_inexistent',$this->_cacheModuleID); |
|
58 | + throw new TConfigurationException('cachesession_cachemodule_inexistent', $this->_cacheModuleID); |
|
59 | 59 | else if($cache instanceof ICache) |
60 | 60 | $this->_cache=$cache; |
61 | 61 | else |
62 | - throw new TConfigurationException('cachesession_cachemodule_invalid',$this->_cacheModuleID); |
|
62 | + throw new TConfigurationException('cachesession_cachemodule_invalid', $this->_cacheModuleID); |
|
63 | 63 | $this->setUseCustomStorage(true); |
64 | 64 | parent::init($config); |
65 | 65 | } |
@@ -104,9 +104,9 @@ discard block |
||
104 | 104 | * @param string session data |
105 | 105 | * @return boolean whether session write is successful |
106 | 106 | */ |
107 | - public function _write($id,$data) |
|
107 | + public function _write($id, $data) |
|
108 | 108 | { |
109 | - return $this->_cache->set($this->calculateKey($id),$data,$this->getTimeout()); |
|
109 | + return $this->_cache->set($this->calculateKey($id), $data, $this->getTimeout()); |
|
110 | 110 | } |
111 | 111 | |
112 | 112 | /** |
@@ -18,9 +18,9 @@ discard block |
||
18 | 18 | */ |
19 | 19 | class THttpUtility |
20 | 20 | { |
21 | - private static $_encodeTable=array('<'=>'<','>'=>'>','"'=>'"'); |
|
22 | - private static $_decodeTable=array('<'=>'<','>'=>'>','"'=>'"'); |
|
23 | - private static $_stripTable=array('<'=>'','>'=>'','"'=>''); |
|
21 | + private static $_encodeTable=array('<'=>'<', '>'=>'>', '"'=>'"'); |
|
22 | + private static $_decodeTable=array('<'=>'<', '>'=>'>', '"'=>'"'); |
|
23 | + private static $_stripTable=array('<'=>'', '>'=>'', '"'=>''); |
|
24 | 24 | |
25 | 25 | /** |
26 | 26 | * HTML-encodes a string. |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | */ |
33 | 33 | public static function htmlEncode($s) |
34 | 34 | { |
35 | - return strtr($s,self::$_encodeTable); |
|
35 | + return strtr($s, self::$_encodeTable); |
|
36 | 36 | } |
37 | 37 | |
38 | 38 | /** |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | */ |
44 | 44 | public static function htmlDecode($s) |
45 | 45 | { |
46 | - return strtr($s,self::$_decodeTable); |
|
46 | + return strtr($s, self::$_decodeTable); |
|
47 | 47 | } |
48 | 48 | |
49 | 49 | /** |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | */ |
55 | 55 | public static function htmlStrip($s) |
56 | 56 | { |
57 | - return strtr($s,self::$_stripTable); |
|
57 | + return strtr($s, self::$_stripTable); |
|
58 | 58 | } |
59 | 59 | } |
60 | 60 |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | /** |
26 | 26 | * Defines Prado class if not defined. |
27 | 27 | */ |
28 | -if(!class_exists('Prado',false)) |
|
28 | +if(!class_exists('Prado', false)) |
|
29 | 29 | { |
30 | 30 | /** |
31 | 31 | * Prado class. |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | * cannot be found, if you have multiple autoloaders, Prado::autoload |
46 | 46 | * should be registered in the last. |
47 | 47 | */ |
48 | -spl_autoload_register(array('Prado','autoload')); |
|
48 | +spl_autoload_register(array('Prado', 'autoload')); |
|
49 | 49 | |
50 | 50 | /** |
51 | 51 | * Initializes error and exception handlers |
@@ -200,7 +200,7 @@ discard block |
||
200 | 200 | * @param ICacheDependency dependency of the cached item. If the dependency changes, the item is labelled invalid. |
201 | 201 | * @return boolean true if the value is successfully stored into cache, false otherwise |
202 | 202 | */ |
203 | - public function set($id,$value,$expire=0,$dependency=null); |
|
203 | + public function set($id, $value, $expire=0, $dependency=null); |
|
204 | 204 | /** |
205 | 205 | * Stores a value identified by a key into cache if the cache does not contain this key. |
206 | 206 | * Nothing will be done if the cache already contains the key. |
@@ -210,7 +210,7 @@ discard block |
||
210 | 210 | * @param ICacheDependency dependency of the cached item. If the dependency changes, the item is labelled invalid. |
211 | 211 | * @return boolean true if the value is successfully stored into cache, false otherwise |
212 | 212 | */ |
213 | - public function add($id,$value,$expire=0,$dependency=null); |
|
213 | + public function add($id, $value, $expire=0, $dependency=null); |
|
214 | 214 | /** |
215 | 215 | * Deletes a value with the specified key from cache |
216 | 216 | * @param string the key of the value to be deleted |
@@ -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'), |
@@ -44,9 +44,9 @@ discard block |
||
44 | 44 | * the object and method name as string |
45 | 45 | * @param array The array of arguments to the function call chain |
46 | 46 | */ |
47 | - public function addCall($method,$args) |
|
47 | + public function addCall($method, $args) |
|
48 | 48 | { |
49 | - $this->add(array($method,$args)); |
|
49 | + $this->add(array($method, $args)); |
|
50 | 50 | } |
51 | 51 | |
52 | 52 | /** |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | { |
93 | 93 | $args=func_get_args(); |
94 | 94 | if($this->getCount()===0) |
95 | - return isset($args[0])?$args[0]:null; |
|
95 | + return isset($args[0]) ? $args[0] : null; |
|
96 | 96 | |
97 | 97 | if(!$this->_iterator) |
98 | 98 | { |
@@ -103,15 +103,15 @@ discard block |
||
103 | 103 | do { |
104 | 104 | $handler=$this->_iterator->current(); |
105 | 105 | $this->_iterator->next(); |
106 | - if(is_array($handler[0])&&$handler[0][0] instanceof IClassBehavior) |
|
107 | - array_splice($handler[1],1,count($args),$args); |
|
106 | + if(is_array($handler[0]) && $handler[0][0] instanceof IClassBehavior) |
|
107 | + array_splice($handler[1], 1, count($args), $args); |
|
108 | 108 | else |
109 | - array_splice($handler[1],0,count($args),$args); |
|
109 | + array_splice($handler[1], 0, count($args), $args); |
|
110 | 110 | $handler[1][]=$this; |
111 | - $result=call_user_func_array($handler[0],$handler[1]); |
|
111 | + $result=call_user_func_array($handler[0], $handler[1]); |
|
112 | 112 | } while($this->_iterator->valid()); |
113 | 113 | else |
114 | - $result = $args[0]; |
|
114 | + $result=$args[0]; |
|
115 | 115 | return $result; |
116 | 116 | } |
117 | 117 | |
@@ -137,10 +137,10 @@ discard block |
||
137 | 137 | * @param string method name of the unspecified object method |
138 | 138 | * @param array arguments to the unspecified object method |
139 | 139 | */ |
140 | - public function __dycall($method,$args) |
|
140 | + public function __dycall($method, $args) |
|
141 | 141 | { |
142 | 142 | if($this->_method==$method) |
143 | - return call_user_func_array(array($this,'call'),$args); |
|
143 | + return call_user_func_array(array($this, 'call'), $args); |
|
144 | 144 | return null; |
145 | 145 | } |
146 | 146 | } |
147 | 147 | \ No newline at end of file |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | * Charset, default is 'UTF-8' |
55 | 55 | * @var string |
56 | 56 | */ |
57 | - private $charset = 'UTF-8'; |
|
57 | + private $charset='UTF-8'; |
|
58 | 58 | |
59 | 59 | /** |
60 | 60 | * Constructor, create a new date time formatter. |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | */ |
81 | 81 | public function setPattern($pattern) |
82 | 82 | { |
83 | - $this->pattern = $pattern; |
|
83 | + $this->pattern=$pattern; |
|
84 | 84 | } |
85 | 85 | |
86 | 86 | /** |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | */ |
97 | 97 | public function setCharset($charset) |
98 | 98 | { |
99 | - $this->charset = $charset; |
|
99 | + $this->charset=$charset; |
|
100 | 100 | } |
101 | 101 | |
102 | 102 | /** |
@@ -106,17 +106,17 @@ discard block |
||
106 | 106 | */ |
107 | 107 | public function format($value) |
108 | 108 | { |
109 | - $date = $this->getDate($value); |
|
110 | - $bits['yyyy'] = $date['year']; |
|
111 | - $bits['yy'] = substr("{$date['year']}", -2); |
|
109 | + $date=$this->getDate($value); |
|
110 | + $bits['yyyy']=$date['year']; |
|
111 | + $bits['yy']=substr("{$date['year']}", -2); |
|
112 | 112 | |
113 | - $bits['MM'] = str_pad("{$date['mon']}", 2, '0', STR_PAD_LEFT); |
|
114 | - $bits['M'] = $date['mon']; |
|
113 | + $bits['MM']=str_pad("{$date['mon']}", 2, '0', STR_PAD_LEFT); |
|
114 | + $bits['M']=$date['mon']; |
|
115 | 115 | |
116 | - $bits['dd'] = str_pad("{$date['mday']}", 2, '0', STR_PAD_LEFT); |
|
117 | - $bits['d'] = $date['mday']; |
|
116 | + $bits['dd']=str_pad("{$date['mday']}", 2, '0', STR_PAD_LEFT); |
|
117 | + $bits['d']=$date['mday']; |
|
118 | 118 | |
119 | - $pattern = preg_replace('/M{3,4}/', 'MM', $this->pattern); |
|
119 | + $pattern=preg_replace('/M{3,4}/', 'MM', $this->pattern); |
|
120 | 120 | return str_replace(array_keys($bits), $bits, $pattern); |
121 | 121 | } |
122 | 122 | |
@@ -153,13 +153,13 @@ discard block |
||
153 | 153 | |
154 | 154 | public function getDayMonthYearOrdering() |
155 | 155 | { |
156 | - $ordering = array(); |
|
157 | - if(is_int($day= strpos($this->pattern, 'd'))) |
|
158 | - $ordering['day'] = $day; |
|
159 | - if(is_int($month= strpos($this->pattern, 'M'))) |
|
160 | - $ordering['month'] = $month; |
|
161 | - if(is_int($year= strpos($this->pattern, 'yy'))) |
|
162 | - $ordering['year'] = $year; |
|
156 | + $ordering=array(); |
|
157 | + if(is_int($day=strpos($this->pattern, 'd'))) |
|
158 | + $ordering['day']=$day; |
|
159 | + if(is_int($month=strpos($this->pattern, 'M'))) |
|
160 | + $ordering['month']=$month; |
|
161 | + if(is_int($year=strpos($this->pattern, 'yy'))) |
|
162 | + $ordering['year']=$year; |
|
163 | 163 | asort($ordering); |
164 | 164 | return array_keys($ordering); |
165 | 165 | } |
@@ -171,7 +171,7 @@ discard block |
||
171 | 171 | */ |
172 | 172 | private function getDate($value) |
173 | 173 | { |
174 | - $s = Prado::createComponent('System.Util.TDateTimeStamp'); |
|
174 | + $s=Prado::createComponent('System.Util.TDateTimeStamp'); |
|
175 | 175 | if(is_numeric($value)) |
176 | 176 | return $s->getDate($value); |
177 | 177 | else |
@@ -183,10 +183,10 @@ discard block |
||
183 | 183 | */ |
184 | 184 | public function isValidDate($value) |
185 | 185 | { |
186 | - if($value === null) { |
|
186 | + if($value===null) { |
|
187 | 187 | return false; |
188 | 188 | } else { |
189 | - return $this->parse($value, false) !== null; |
|
189 | + return $this->parse($value, false)!==null; |
|
190 | 190 | } |
191 | 191 | } |
192 | 192 | |
@@ -196,7 +196,7 @@ discard block |
||
196 | 196 | * @return int date time stamp |
197 | 197 | * @throws TInvalidDataValueException if date string is malformed. |
198 | 198 | */ |
199 | - public function parse($value,$defaultToCurrentTime=true) |
|
199 | + public function parse($value, $defaultToCurrentTime=true) |
|
200 | 200 | { |
201 | 201 | if(is_int($value) || is_float($value)) |
202 | 202 | return $value; |
@@ -205,108 +205,108 @@ discard block |
||
205 | 205 | |
206 | 206 | if(empty($this->pattern)) return time(); |
207 | 207 | |
208 | - $date = time(); |
|
208 | + $date=time(); |
|
209 | 209 | |
210 | 210 | if($this->length(trim($value)) < 1) |
211 | 211 | return $defaultToCurrentTime ? $date : null; |
212 | 212 | |
213 | - $pattern = $this->pattern; |
|
213 | + $pattern=$this->pattern; |
|
214 | 214 | |
215 | - $i_val = 0; |
|
216 | - $i_format = 0; |
|
217 | - $pattern_length = $this->length($pattern); |
|
218 | - $c = ''; |
|
215 | + $i_val=0; |
|
216 | + $i_format=0; |
|
217 | + $pattern_length=$this->length($pattern); |
|
218 | + $c=''; |
|
219 | 219 | $token=''; |
220 | 220 | $x=null; $y=null; |
221 | 221 | |
222 | 222 | |
223 | 223 | if($defaultToCurrentTime) |
224 | 224 | { |
225 | - $year = "{$date['year']}"; |
|
226 | - $month = $date['mon']; |
|
227 | - $day = $date['mday']; |
|
225 | + $year="{$date['year']}"; |
|
226 | + $month=$date['mon']; |
|
227 | + $day=$date['mday']; |
|
228 | 228 | } |
229 | 229 | else |
230 | 230 | { |
231 | - $year = null; |
|
232 | - $month = null; |
|
233 | - $day = null; |
|
231 | + $year=null; |
|
232 | + $month=null; |
|
233 | + $day=null; |
|
234 | 234 | } |
235 | 235 | |
236 | - while ($i_format < $pattern_length) |
|
236 | + while($i_format < $pattern_length) |
|
237 | 237 | { |
238 | - $c = $this->charAt($pattern,$i_format); |
|
238 | + $c=$this->charAt($pattern, $i_format); |
|
239 | 239 | $token=''; |
240 | - while ($this->charEqual($pattern, $i_format, $c) |
|
240 | + while($this->charEqual($pattern, $i_format, $c) |
|
241 | 241 | && ($i_format < $pattern_length)) |
242 | 242 | { |
243 | - $token .= $this->charAt($pattern, $i_format++); |
|
243 | + $token.=$this->charAt($pattern, $i_format++); |
|
244 | 244 | } |
245 | 245 | |
246 | - if ($token=='yyyy' || $token=='yy' || $token=='y') |
|
246 | + if($token=='yyyy' || $token=='yy' || $token=='y') |
|
247 | 247 | { |
248 | - if ($token=='yyyy') { $x=4;$y=4; } |
|
249 | - if ($token=='yy') { $x=2;$y=2; } |
|
250 | - if ($token=='y') { $x=2;$y=4; } |
|
251 | - $year = $this->getInteger($value,$i_val,$x,$y); |
|
252 | - if($year === null) |
|
248 | + if($token=='yyyy') { $x=4; $y=4; } |
|
249 | + if($token=='yy') { $x=2; $y=2; } |
|
250 | + if($token=='y') { $x=2; $y=4; } |
|
251 | + $year=$this->getInteger($value, $i_val, $x, $y); |
|
252 | + if($year===null) |
|
253 | 253 | return null; |
254 | 254 | //throw new TInvalidDataValueException('Invalid year', $value); |
255 | - $i_val += strlen($year); |
|
256 | - if(strlen($year) == 2) |
|
255 | + $i_val+=strlen($year); |
|
256 | + if(strlen($year)==2) |
|
257 | 257 | { |
258 | - $iYear = (int)$year; |
|
258 | + $iYear=(int) $year; |
|
259 | 259 | if($iYear > 70) |
260 | - $year = $iYear + 1900; |
|
260 | + $year=$iYear + 1900; |
|
261 | 261 | else |
262 | - $year = $iYear + 2000; |
|
262 | + $year=$iYear + 2000; |
|
263 | 263 | } |
264 | - $year = (int)$year; |
|
264 | + $year=(int) $year; |
|
265 | 265 | } |
266 | 266 | elseif($token=='MM' || $token=='M') |
267 | 267 | { |
268 | - $month=$this->getInteger($value,$i_val, |
|
269 | - $this->length($token),2); |
|
270 | - $iMonth = (int)$month; |
|
271 | - if($month === null || $iMonth < 1 || $iMonth > 12 ) |
|
268 | + $month=$this->getInteger($value, $i_val, |
|
269 | + $this->length($token), 2); |
|
270 | + $iMonth=(int) $month; |
|
271 | + if($month===null || $iMonth < 1 || $iMonth > 12) |
|
272 | 272 | return null; |
273 | 273 | //throw new TInvalidDataValueException('Invalid month', $value); |
274 | - $i_val += strlen($month); |
|
275 | - $month = $iMonth; |
|
274 | + $i_val+=strlen($month); |
|
275 | + $month=$iMonth; |
|
276 | 276 | } |
277 | - elseif ($token=='dd' || $token=='d') |
|
277 | + elseif($token=='dd' || $token=='d') |
|
278 | 278 | { |
279 | - $day = $this->getInteger($value,$i_val, |
|
279 | + $day=$this->getInteger($value, $i_val, |
|
280 | 280 | $this->length($token), 2); |
281 | - $iDay = (int)$day; |
|
282 | - if($day === null || $iDay < 1 || $iDay >31) |
|
281 | + $iDay=(int) $day; |
|
282 | + if($day===null || $iDay < 1 || $iDay > 31) |
|
283 | 283 | return null; |
284 | 284 | //throw new TInvalidDataValueException('Invalid day', $value); |
285 | - $i_val += strlen($day); |
|
286 | - $day = $iDay; |
|
285 | + $i_val+=strlen($day); |
|
286 | + $day=$iDay; |
|
287 | 287 | } |
288 | 288 | else |
289 | 289 | { |
290 | - if($this->substring($value, $i_val, $this->length($token)) != $token) |
|
290 | + if($this->substring($value, $i_val, $this->length($token))!=$token) |
|
291 | 291 | return null; |
292 | 292 | //throw new TInvalidDataValueException("Subpattern '{$this->pattern}' mismatch", $value); |
293 | 293 | else |
294 | - $i_val += $this->length($token); |
|
294 | + $i_val+=$this->length($token); |
|
295 | 295 | } |
296 | 296 | } |
297 | - if ($i_val != $this->length($value)) |
|
297 | + if($i_val!=$this->length($value)) |
|
298 | 298 | return null; |
299 | 299 | //throw new TInvalidDataValueException("Pattern '{$this->pattern}' mismatch", $value); |
300 | - if(!$defaultToCurrentTime && ($month === null || $day === null || $year === null)) |
|
300 | + if(!$defaultToCurrentTime && ($month===null || $day===null || $year===null)) |
|
301 | 301 | return null; |
302 | 302 | else |
303 | 303 | { |
304 | 304 | if(empty($year)) { |
305 | - $year = date('Y'); |
|
305 | + $year=date('Y'); |
|
306 | 306 | } |
307 | - $day = (int)$day <= 0 ? 1 : (int)$day; |
|
308 | - $month = (int)$month <= 0 ? 1 : (int)$month; |
|
309 | - $s = Prado::createComponent('System.Util.TDateTimeStamp'); |
|
307 | + $day=(int) $day <= 0 ? 1 : (int) $day; |
|
308 | + $month=(int) $month <= 0 ? 1 : (int) $month; |
|
309 | + $s=Prado::createComponent('System.Util.TDateTimeStamp'); |
|
310 | 310 | return $s->getTimeStamp(0, 0, 0, $month, $day, $year); |
311 | 311 | } |
312 | 312 | } |
@@ -341,7 +341,7 @@ discard block |
||
341 | 341 | */ |
342 | 342 | private function charEqual($string, $pos, $char) |
343 | 343 | { |
344 | - return $this->charAt($string, $pos) == $char; |
|
344 | + return $this->charAt($string, $pos)==$char; |
|
345 | 345 | } |
346 | 346 | |
347 | 347 | /** |
@@ -352,15 +352,15 @@ discard block |
||
352 | 352 | * @param int maximum integer length |
353 | 353 | * @return string integer portion of the string, null otherwise |
354 | 354 | */ |
355 | - private function getInteger($str,$i,$minlength,$maxlength) |
|
355 | + private function getInteger($str, $i, $minlength, $maxlength) |
|
356 | 356 | { |
357 | 357 | //match for digits backwards |
358 | - for ($x = $maxlength; $x >= $minlength; $x--) |
|
358 | + for($x=$maxlength; $x >= $minlength; $x--) |
|
359 | 359 | { |
360 | - $token= $this->substring($str, $i,$x); |
|
361 | - if ($this->length($token) < $minlength) |
|
360 | + $token=$this->substring($str, $i, $x); |
|
361 | + if($this->length($token) < $minlength) |
|
362 | 362 | return null; |
363 | - if (preg_match('/^\d+$/', $token)) |
|
363 | + if(preg_match('/^\d+$/', $token)) |
|
364 | 364 | return $token; |
365 | 365 | } |
366 | 366 | return null; |
@@ -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 | } |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | /** |
56 | 56 | * @var boolean whether the request is a notification and therefore should not care about the result (default: false) |
57 | 57 | */ |
58 | - private $_isNotification = false; |
|
58 | + private $_isNotification=false; |
|
59 | 59 | |
60 | 60 | // magics |
61 | 61 | |
@@ -63,10 +63,10 @@ discard block |
||
63 | 63 | * @param string url to RPC server |
64 | 64 | * @param boolean whether requests are considered to be notifications (completely ignoring the response) (default: false) |
65 | 65 | */ |
66 | - public function __construct($serverUrl, $isNotification = false) |
|
66 | + public function __construct($serverUrl, $isNotification=false) |
|
67 | 67 | { |
68 | - $this->_serverUrl = $serverUrl; |
|
69 | - $this->_isNotification = TPropertyValue::ensureBoolean($isNotification); |
|
68 | + $this->_serverUrl=$serverUrl; |
|
69 | + $this->_isNotification=TPropertyValue::ensureBoolean($isNotification); |
|
70 | 70 | } |
71 | 71 | |
72 | 72 | // methods |
@@ -76,9 +76,9 @@ discard block |
||
76 | 76 | * @return TRpcClient instance |
77 | 77 | * @throws TApplicationException if an unsupported RPC client type was specified |
78 | 78 | */ |
79 | - public static function create($type, $serverUrl, $isNotification = false) |
|
79 | + public static function create($type, $serverUrl, $isNotification=false) |
|
80 | 80 | { |
81 | - if(($_handler = constant('TRpcClientTypesEnumerable::'.strtoupper($type))) === null) |
|
81 | + if(($_handler=constant('TRpcClientTypesEnumerable::'.strtoupper($type)))===null) |
|
82 | 82 | throw new TApplicationException('rpcclient_unsupported_handler'); |
83 | 83 | |
84 | 84 | return new $_handler($serverUrl, $isNotification); |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | */ |
109 | 109 | protected function performRequest($serverUrl, $payload, $mimeType) |
110 | 110 | { |
111 | - if(($_response = @file_get_contents($serverUrl, false, $this->createStreamContext($payload, $mimeType))) === false) |
|
111 | + if(($_response=@file_get_contents($serverUrl, false, $this->createStreamContext($payload, $mimeType)))===false) |
|
112 | 112 | throw new TRpcClientRequestException('Request failed ("'.$http_response_header[0].'")'); |
113 | 113 | |
114 | 114 | return $_response; |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | */ |
130 | 130 | public function setIsNotification($bool) |
131 | 131 | { |
132 | - $this->_isNotification = TPropertyValue::ensureBoolean($bool); |
|
132 | + $this->_isNotification=TPropertyValue::ensureBoolean($bool); |
|
133 | 133 | } |
134 | 134 | |
135 | 135 | /** |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | */ |
146 | 146 | public function setServerUrl($value) |
147 | 147 | { |
148 | - $this->_serverUrl = $value; |
|
148 | + $this->_serverUrl=$value; |
|
149 | 149 | } |
150 | 150 | } |
151 | 151 | |
@@ -160,8 +160,8 @@ discard block |
||
160 | 160 | |
161 | 161 | class TRpcClientTypesEnumerable extends TEnumerable |
162 | 162 | { |
163 | - const JSON = 'TJsonRpcClient'; |
|
164 | - const XML = 'TXmlRpcClient'; |
|
163 | + const JSON='TJsonRpcClient'; |
|
164 | + const XML='TXmlRpcClient'; |
|
165 | 165 | } |
166 | 166 | |
167 | 167 | /** |
@@ -197,7 +197,7 @@ discard block |
||
197 | 197 | * @param string error message |
198 | 198 | * @param integer error code (optional) |
199 | 199 | */ |
200 | - public function __construct($errorMessage, $errorCode = null) |
|
200 | + public function __construct($errorMessage, $errorCode=null) |
|
201 | 201 | { |
202 | 202 | $this->setErrorCode($errorCode); |
203 | 203 | |
@@ -239,14 +239,14 @@ discard block |
||
239 | 239 | public function __call($method, $parameters) |
240 | 240 | { |
241 | 241 | // send request |
242 | - $_response = $this->performRequest($this->getServerUrl(), $this->encodeRequest($method, $parameters), 'application/json'); |
|
242 | + $_response=$this->performRequest($this->getServerUrl(), $this->encodeRequest($method, $parameters), 'application/json'); |
|
243 | 243 | |
244 | 244 | // skip response handling if the request was just a notification request |
245 | 245 | if($this->isNotification) |
246 | 246 | return true; |
247 | 247 | |
248 | 248 | // decode response |
249 | - if(($_response = json_decode($_response, true)) === null) |
|
249 | + if(($_response=json_decode($_response, true))===null) |
|
250 | 250 | throw new TRpcClientResponseException('Empty response received'); |
251 | 251 | |
252 | 252 | // handle error response |
@@ -265,7 +265,7 @@ discard block |
||
265 | 265 | public function encodeRequest($method, $parameters) |
266 | 266 | { |
267 | 267 | static $_requestId; |
268 | - $_requestId = ($_requestId === null) ? 1 : $_requestId + 1; |
|
268 | + $_requestId=($_requestId===null) ? 1 : $_requestId + 1; |
|
269 | 269 | |
270 | 270 | return json_encode(array( |
271 | 271 | 'method' => $method, |
@@ -279,7 +279,7 @@ discard block |
||
279 | 279 | * @param string url of the rpc server |
280 | 280 | * @param boolean whether the requests are considered to be notifications (completely ignoring the response) (default: false) |
281 | 281 | */ |
282 | - public static function create($type, $serverUrl, $isNotification = false) |
|
282 | + public static function create($type, $serverUrl, $isNotification=false) |
|
283 | 283 | { |
284 | 284 | return new self($serverUrl, $isNotification); |
285 | 285 | } |
@@ -317,14 +317,14 @@ discard block |
||
317 | 317 | public function __call($method, $parameters) |
318 | 318 | { |
319 | 319 | // send request |
320 | - $_response = $this->performRequest($this->getServerUrl(), $this->encodeRequest($method, $parameters), 'text/xml'); |
|
320 | + $_response=$this->performRequest($this->getServerUrl(), $this->encodeRequest($method, $parameters), 'text/xml'); |
|
321 | 321 | |
322 | 322 | // skip response handling if the request was just a notification request |
323 | 323 | if($this->isNotification) |
324 | 324 | return true; |
325 | 325 | |
326 | 326 | // decode response |
327 | - if(($_response = xmlrpc_decode($_response)) === null) |
|
327 | + if(($_response=xmlrpc_decode($_response))===null) |
|
328 | 328 | throw new TRpcClientResponseException('Empty response received'); |
329 | 329 | |
330 | 330 | // handle error response |
@@ -350,7 +350,7 @@ discard block |
||
350 | 350 | * @param string url of the rpc server |
351 | 351 | * @param boolean whether the requests are considered to be notifications (completely ignoring the response) (default: false) |
352 | 352 | */ |
353 | - public static function create($type, $serverUrl, $isNotification = false) |
|
353 | + public static function create($type, $serverUrl, $isNotification=false) |
|
354 | 354 | { |
355 | 355 | return new self($serverUrl, $isNotification); |
356 | 356 | } |