@@ -82,9 +82,9 @@ discard block |
||
82 | 82 | if($this->_basePath===null) |
83 | 83 | $this->_basePath=dirname($application->getRequest()->getApplicationFilePath()).DIRECTORY_SEPARATOR.self::DEFAULT_BASEPATH; |
84 | 84 | if(!is_writable($this->_basePath) || !is_dir($this->_basePath)) |
85 | - throw new TConfigurationException('assetmanager_basepath_invalid',$this->_basePath); |
|
85 | + throw new TConfigurationException('assetmanager_basepath_invalid', $this->_basePath); |
|
86 | 86 | if($this->_baseUrl===null) |
87 | - $this->_baseUrl=rtrim(dirname($application->getRequest()->getApplicationUrl()),'/\\').'/'.self::DEFAULT_BASEPATH; |
|
87 | + $this->_baseUrl=rtrim(dirname($application->getRequest()->getApplicationUrl()), '/\\').'/'.self::DEFAULT_BASEPATH; |
|
88 | 88 | $application->setAssetManager($this); |
89 | 89 | $this->_initialized=true; |
90 | 90 | } |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | { |
112 | 112 | $this->_basePath=Prado::getPathOfNamespace($value); |
113 | 113 | if($this->_basePath===null || !is_dir($this->_basePath) || !is_writable($this->_basePath)) |
114 | - throw new TInvalidDataValueException('assetmanager_basepath_invalid',$value); |
|
114 | + throw new TInvalidDataValueException('assetmanager_basepath_invalid', $value); |
|
115 | 115 | } |
116 | 116 | } |
117 | 117 | |
@@ -132,7 +132,7 @@ discard block |
||
132 | 132 | if($this->_initialized) |
133 | 133 | throw new TInvalidOperationException('assetmanager_baseurl_unchangeable'); |
134 | 134 | else |
135 | - $this->_baseUrl=rtrim($value,'/'); |
|
135 | + $this->_baseUrl=rtrim($value, '/'); |
|
136 | 136 | } |
137 | 137 | |
138 | 138 | /** |
@@ -149,19 +149,19 @@ discard block |
||
149 | 149 | * @throws TInvalidDataValueException if the file path to be published is |
150 | 150 | * invalid |
151 | 151 | */ |
152 | - public function publishFilePath($path,$checkTimestamp=false) |
|
152 | + public function publishFilePath($path, $checkTimestamp=false) |
|
153 | 153 | { |
154 | 154 | if(isset($this->_published[$path])) |
155 | 155 | return $this->_published[$path]; |
156 | 156 | else if(empty($path) || ($fullpath=realpath($path))===false) |
157 | - throw new TInvalidDataValueException('assetmanager_filepath_invalid',$path); |
|
157 | + throw new TInvalidDataValueException('assetmanager_filepath_invalid', $path); |
|
158 | 158 | else if(is_file($fullpath)) |
159 | 159 | { |
160 | 160 | $dir=$this->hash(dirname($fullpath)); |
161 | 161 | $fileName=basename($fullpath); |
162 | 162 | $dst=$this->_basePath.DIRECTORY_SEPARATOR.$dir; |
163 | 163 | if(!is_file($dst.DIRECTORY_SEPARATOR.$fileName) || $checkTimestamp || $this->getApplication()->getMode()!==TApplicationMode::Performance) |
164 | - $this->copyFile($fullpath,$dst); |
|
164 | + $this->copyFile($fullpath, $dst); |
|
165 | 165 | return $this->_published[$path]=$this->_baseUrl.'/'.$dir.'/'.$fileName; |
166 | 166 | } |
167 | 167 | else |
@@ -169,8 +169,8 @@ discard block |
||
169 | 169 | $dir=$this->hash($fullpath); |
170 | 170 | if(!is_dir($this->_basePath.DIRECTORY_SEPARATOR.$dir) || $checkTimestamp || $this->getApplication()->getMode()!==TApplicationMode::Performance) |
171 | 171 | { |
172 | - Prado::trace("Publishing directory $fullpath",'System.Web.UI.TAssetManager'); |
|
173 | - $this->copyDirectory($fullpath,$this->_basePath.DIRECTORY_SEPARATOR.$dir); |
|
172 | + Prado::trace("Publishing directory $fullpath", 'System.Web.UI.TAssetManager'); |
|
173 | + $this->copyDirectory($fullpath, $this->_basePath.DIRECTORY_SEPARATOR.$dir); |
|
174 | 174 | } |
175 | 175 | return $this->_published[$path]=$this->_baseUrl.'/'.$dir; |
176 | 176 | } |
@@ -191,7 +191,7 @@ discard block |
||
191 | 191 | */ |
192 | 192 | protected function setPublished($values=array()) |
193 | 193 | { |
194 | - $this->_published = $values; |
|
194 | + $this->_published=$values; |
|
195 | 195 | } |
196 | 196 | |
197 | 197 | /** |
@@ -234,7 +234,7 @@ discard block |
||
234 | 234 | */ |
235 | 235 | protected function hash($dir) |
236 | 236 | { |
237 | - return sprintf('%x',crc32($dir.Prado::getVersion())); |
|
237 | + return sprintf('%x', crc32($dir.Prado::getVersion())); |
|
238 | 238 | } |
239 | 239 | |
240 | 240 | /** |
@@ -244,7 +244,7 @@ discard block |
||
244 | 244 | * @param string source file path |
245 | 245 | * @param string destination directory (if not exists, it will be created) |
246 | 246 | */ |
247 | - protected function copyFile($src,$dst) |
|
247 | + protected function copyFile($src, $dst) |
|
248 | 248 | { |
249 | 249 | if(!is_dir($dst)) |
250 | 250 | { |
@@ -252,10 +252,10 @@ discard block |
||
252 | 252 | @chmod($dst, PRADO_CHMOD); |
253 | 253 | } |
254 | 254 | $dstFile=$dst.DIRECTORY_SEPARATOR.basename($src); |
255 | - if(@filemtime($dstFile)<@filemtime($src)) |
|
255 | + if(@filemtime($dstFile) < @filemtime($src)) |
|
256 | 256 | { |
257 | - Prado::trace("Publishing file $src to $dstFile",'System.Web.TAssetManager'); |
|
258 | - @copy($src,$dstFile); |
|
257 | + Prado::trace("Publishing file $src to $dstFile", 'System.Web.TAssetManager'); |
|
258 | + @copy($src, $dstFile); |
|
259 | 259 | } |
260 | 260 | } |
261 | 261 | |
@@ -267,7 +267,7 @@ discard block |
||
267 | 267 | * @param string the destination directory |
268 | 268 | * @todo a generic solution to ignore certain directories and files |
269 | 269 | */ |
270 | - public function copyDirectory($src,$dst) |
|
270 | + public function copyDirectory($src, $dst) |
|
271 | 271 | { |
272 | 272 | if(!is_dir($dst)) |
273 | 273 | { |
@@ -282,14 +282,14 @@ discard block |
||
282 | 282 | continue; |
283 | 283 | else if(is_file($src.DIRECTORY_SEPARATOR.$file)) |
284 | 284 | { |
285 | - if(@filemtime($dst.DIRECTORY_SEPARATOR.$file)<@filemtime($src.DIRECTORY_SEPARATOR.$file)) |
|
285 | + if(@filemtime($dst.DIRECTORY_SEPARATOR.$file) < @filemtime($src.DIRECTORY_SEPARATOR.$file)) |
|
286 | 286 | { |
287 | - @copy($src.DIRECTORY_SEPARATOR.$file,$dst.DIRECTORY_SEPARATOR.$file); |
|
287 | + @copy($src.DIRECTORY_SEPARATOR.$file, $dst.DIRECTORY_SEPARATOR.$file); |
|
288 | 288 | @chmod($dst.DIRECTORY_SEPARATOR.$file, PRADO_CHMOD); |
289 | 289 | } |
290 | 290 | } |
291 | 291 | else |
292 | - $this->copyDirectory($src.DIRECTORY_SEPARATOR.$file,$dst.DIRECTORY_SEPARATOR.$file); |
|
292 | + $this->copyDirectory($src.DIRECTORY_SEPARATOR.$file, $dst.DIRECTORY_SEPARATOR.$file); |
|
293 | 293 | } |
294 | 294 | closedir($folder); |
295 | 295 | } else { |
@@ -313,7 +313,7 @@ discard block |
||
313 | 313 | if(isset($this->_published[$md5sum])) |
314 | 314 | return $this->_published[$md5sum]; |
315 | 315 | else if(($fullpath=realpath($md5sum))===false || !is_file($fullpath)) |
316 | - throw new TInvalidDataValueException('assetmanager_tarchecksum_invalid',$md5sum); |
|
316 | + throw new TInvalidDataValueException('assetmanager_tarchecksum_invalid', $md5sum); |
|
317 | 317 | else |
318 | 318 | { |
319 | 319 | $dir=$this->hash(dirname($fullpath)); |
@@ -321,10 +321,10 @@ discard block |
||
321 | 321 | $dst=$this->_basePath.DIRECTORY_SEPARATOR.$dir; |
322 | 322 | if(!is_file($dst.DIRECTORY_SEPARATOR.$fileName) || $checkTimestamp || $this->getApplication()->getMode()!==TApplicationMode::Performance) |
323 | 323 | { |
324 | - if(@filemtime($dst.DIRECTORY_SEPARATOR.$fileName)<@filemtime($fullpath)) |
|
324 | + if(@filemtime($dst.DIRECTORY_SEPARATOR.$fileName) < @filemtime($fullpath)) |
|
325 | 325 | { |
326 | - $this->copyFile($fullpath,$dst); |
|
327 | - $this->deployTarFile($tarfile,$dst); |
|
326 | + $this->copyFile($fullpath, $dst); |
|
327 | + $this->deployTarFile($tarfile, $dst); |
|
328 | 328 | } |
329 | 329 | } |
330 | 330 | return $this->_published[$md5sum]=$this->_baseUrl.'/'.$dir; |
@@ -338,14 +338,14 @@ discard block |
||
338 | 338 | * @param string path where the contents of tar file are to be extracted |
339 | 339 | * @return boolean true if extract successful, false otherwise. |
340 | 340 | */ |
341 | - protected function deployTarFile($path,$destination) |
|
341 | + protected function deployTarFile($path, $destination) |
|
342 | 342 | { |
343 | 343 | if(($fullpath=realpath($path))===false || !is_file($fullpath)) |
344 | - throw new TIOException('assetmanager_tarfile_invalid',$path); |
|
344 | + throw new TIOException('assetmanager_tarfile_invalid', $path); |
|
345 | 345 | else |
346 | 346 | { |
347 | 347 | Prado::using('System.IO.TTarFileExtractor'); |
348 | - $tar = new TTarFileExtractor($fullpath); |
|
348 | + $tar=new TTarFileExtractor($fullpath); |
|
349 | 349 | return $tar->extract($destination); |
350 | 350 | } |
351 | 351 | } |
@@ -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,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 | } |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | { |
44 | 44 | $this->_owner=$owner; |
45 | 45 | foreach($this->events() as $event=>$handler) |
46 | - $owner->attachEventHandler($event,array($this,$handler)); |
|
46 | + $owner->attachEventHandler($event, array($this, $handler)); |
|
47 | 47 | } |
48 | 48 | |
49 | 49 | /** |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | public function detach($owner) |
57 | 57 | { |
58 | 58 | foreach($this->events() as $event=>$handler) |
59 | - $owner->detachEventHandler($event,array($this,$handler)); |
|
59 | + $owner->detachEventHandler($event, array($this, $handler)); |
|
60 | 60 | $this->_owner=null; |
61 | 61 | } |
62 | 62 |
@@ -63,16 +63,16 @@ discard block |
||
63 | 63 | * @param string category of the message |
64 | 64 | * @param string|TControl control of the message |
65 | 65 | */ |
66 | - public function log($message,$level,$category='Uncategorized', $ctl=null) |
|
66 | + public function log($message, $level, $category='Uncategorized', $ctl=null) |
|
67 | 67 | { |
68 | 68 | if($ctl) { |
69 | 69 | if($ctl instanceof TControl) |
70 | - $ctl = $ctl->ClientId; |
|
70 | + $ctl=$ctl->ClientId; |
|
71 | 71 | else if(!is_string($ctl)) |
72 | - $ctl = null; |
|
72 | + $ctl=null; |
|
73 | 73 | } else |
74 | - $ctl = null; |
|
75 | - $this->_logs[]=array($message,$level,$category,microtime(true),memory_get_usage(),$ctl); |
|
74 | + $ctl=null; |
|
75 | + $this->_logs[]=array($message, $level, $category, microtime(true), memory_get_usage(), $ctl); |
|
76 | 76 | } |
77 | 77 | |
78 | 78 | /** |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | * [4] => memory in bytes |
109 | 109 | * [5] => control client id |
110 | 110 | */ |
111 | - public function getLogs($levels=null,$categories=null,$controls=null,$timestamp=null) |
|
111 | + public function getLogs($levels=null, $categories=null, $controls=null, $timestamp=null) |
|
112 | 112 | { |
113 | 113 | $this->_levels=$levels; |
114 | 114 | $this->_categories=$categories; |
@@ -116,15 +116,15 @@ discard block |
||
116 | 116 | $this->_timestamp=$timestamp; |
117 | 117 | if(empty($levels) && empty($categories) && empty($controls) && is_null($timestamp)) |
118 | 118 | return $this->_logs; |
119 | - $logs = $this->_logs; |
|
119 | + $logs=$this->_logs; |
|
120 | 120 | if(!empty($levels)) |
121 | - $logs = array_values(array_filter( array_filter($logs,array($this,'filterByLevels')) )); |
|
121 | + $logs=array_values(array_filter(array_filter($logs, array($this, 'filterByLevels')))); |
|
122 | 122 | if(!empty($categories)) |
123 | - $logs = array_values(array_filter( array_filter($logs,array($this,'filterByCategories')) )); |
|
123 | + $logs=array_values(array_filter(array_filter($logs, array($this, 'filterByCategories')))); |
|
124 | 124 | if(!empty($controls)) |
125 | - $logs = array_values(array_filter( array_filter($logs,array($this,'filterByControl')) )); |
|
125 | + $logs=array_values(array_filter(array_filter($logs, array($this, 'filterByControl')))); |
|
126 | 126 | if(!is_null($timestamp)) |
127 | - $logs = array_values(array_filter( array_filter($logs,array($this,'filterByTimeStamp')) )); |
|
127 | + $logs=array_values(array_filter(array_filter($logs, array($this, 'filterByTimeStamp')))); |
|
128 | 128 | return $logs; |
129 | 129 | } |
130 | 130 | |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | * @param array category filter |
153 | 153 | * @param array control filter |
154 | 154 | */ |
155 | - public function deleteLogs($levels=null,$categories=null,$controls=null,$timestamp=null) |
|
155 | + public function deleteLogs($levels=null, $categories=null, $controls=null, $timestamp=null) |
|
156 | 156 | { |
157 | 157 | $this->_levels=$levels; |
158 | 158 | $this->_categories=$categories; |
@@ -163,16 +163,16 @@ discard block |
||
163 | 163 | $this->_logs=array(); |
164 | 164 | return; |
165 | 165 | } |
166 | - $logs = $this->_logs; |
|
166 | + $logs=$this->_logs; |
|
167 | 167 | if(!empty($levels)) |
168 | - $logs = array_filter( array_filter($logs,array($this,'filterByLevels')) ); |
|
168 | + $logs=array_filter(array_filter($logs, array($this, 'filterByLevels'))); |
|
169 | 169 | if(!empty($categories)) |
170 | - $logs = array_filter( array_filter($logs,array($this,'filterByCategories')) ); |
|
170 | + $logs=array_filter(array_filter($logs, array($this, 'filterByCategories'))); |
|
171 | 171 | if(!empty($controls)) |
172 | - $logs = array_filter( array_filter($logs,array($this,'filterByControl')) ); |
|
172 | + $logs=array_filter(array_filter($logs, array($this, 'filterByControl'))); |
|
173 | 173 | if(!is_null($timestamp)) |
174 | - $logs = array_filter( array_filter($logs,array($this,'filterByTimeStamp')) ); |
|
175 | - $this->_logs = array_values( array_diff_key($this->_logs, $logs) ); |
|
174 | + $logs=array_filter(array_filter($logs, array($this, 'filterByTimeStamp'))); |
|
175 | + $this->_logs=array_values(array_diff_key($this->_logs, $logs)); |
|
176 | 176 | } |
177 | 177 | |
178 | 178 | /** |
@@ -184,7 +184,7 @@ discard block |
||
184 | 184 | foreach($this->_categories as $category) |
185 | 185 | { |
186 | 186 | // element 2 is the category |
187 | - if($value[2]===$category || strpos($value[2],$category.'.')===0) |
|
187 | + if($value[2]===$category || strpos($value[2], $category.'.')===0) |
|
188 | 188 | return $value; |
189 | 189 | } |
190 | 190 | return false; |
@@ -212,7 +212,7 @@ discard block |
||
212 | 212 | // element 5 are the control client ids |
213 | 213 | foreach($this->_controls as $control) |
214 | 214 | { |
215 | - if($value[5]===$control || strpos($value[5],$control)===0) |
|
215 | + if($value[5]===$control || strpos($value[5], $control)===0) |
|
216 | 216 | return $value; |
217 | 217 | } |
218 | 218 | return false; |