@@ -215,6 +215,7 @@ discard block |
||
215 | 215 | * This method does not perform any publishing. It merely tells you |
216 | 216 | * if the file path is published, what the URL will be to access it. |
217 | 217 | * @param string directory or file path being published |
218 | + * @param string $path |
|
218 | 219 | * @return string the published URL for the file path |
219 | 220 | */ |
220 | 221 | public function getPublishedUrl($path) |
@@ -230,6 +231,7 @@ discard block |
||
230 | 231 | * Generate a CRC32 hash for the directory path. Collisions are higher |
231 | 232 | * than MD5 but generates a much smaller hash string. |
232 | 233 | * @param string string to be hashed. |
234 | + * @param string $dir |
|
233 | 235 | * @return string hashed string. |
234 | 236 | */ |
235 | 237 | protected function hash($dir) |
@@ -243,6 +245,8 @@ discard block |
||
243 | 245 | * or has an older file modification time. |
244 | 246 | * @param string source file path |
245 | 247 | * @param string destination directory (if not exists, it will be created) |
248 | + * @param string $src |
|
249 | + * @param string $dst |
|
246 | 250 | */ |
247 | 251 | protected function copyFile($src,$dst) |
248 | 252 | { |
@@ -265,6 +269,8 @@ discard block |
||
265 | 269 | * File modification time is used to ensure the copied files are latest. |
266 | 270 | * @param string the source directory |
267 | 271 | * @param string the destination directory |
272 | + * @param string $src |
|
273 | + * @param string $dst |
|
268 | 274 | * @todo a generic solution to ignore certain directories and files |
269 | 275 | */ |
270 | 276 | public function copyDirectory($src,$dst) |
@@ -306,6 +312,8 @@ discard block |
||
306 | 312 | * @param string tar filename |
307 | 313 | * @param string MD5 checksum for the corresponding tar file. |
308 | 314 | * @param boolean Wether or not to check the time stamp of the file for publishing. Defaults to false. |
315 | + * @param string $tarfile |
|
316 | + * @param string $md5sum |
|
309 | 317 | * @return string URL path to the directory where the tar file was extracted. |
310 | 318 | */ |
311 | 319 | public function publishTarFile($tarfile, $md5sum, $checkTimestamp=false) |
@@ -336,6 +344,7 @@ discard block |
||
336 | 344 | * N.B Tar file must not be compressed. |
337 | 345 | * @param string tar file |
338 | 346 | * @param string path where the contents of tar file are to be extracted |
347 | + * @param string $destination |
|
339 | 348 | * @return boolean true if extract successful, false otherwise. |
340 | 349 | */ |
341 | 350 | protected function deployTarFile($path,$destination) |
@@ -163,8 +163,7 @@ discard block |
||
163 | 163 | if(!is_file($dst.DIRECTORY_SEPARATOR.$fileName) || $checkTimestamp || $this->getApplication()->getMode()!==TApplicationMode::Performance) |
164 | 164 | $this->copyFile($fullpath,$dst); |
165 | 165 | return $this->_published[$path]=$this->_baseUrl.'/'.$dir.'/'.$fileName; |
166 | - } |
|
167 | - else |
|
166 | + } else |
|
168 | 167 | { |
169 | 168 | $dir=$this->hash($fullpath); |
170 | 169 | if(!is_dir($this->_basePath.DIRECTORY_SEPARATOR.$dir) || $checkTimestamp || $this->getApplication()->getMode()!==TApplicationMode::Performance) |
@@ -287,8 +286,7 @@ discard block |
||
287 | 286 | @copy($src.DIRECTORY_SEPARATOR.$file,$dst.DIRECTORY_SEPARATOR.$file); |
288 | 287 | @chmod($dst.DIRECTORY_SEPARATOR.$file, PRADO_CHMOD); |
289 | 288 | } |
290 | - } |
|
291 | - else |
|
289 | + } else |
|
292 | 290 | $this->copyDirectory($src.DIRECTORY_SEPARATOR.$file,$dst.DIRECTORY_SEPARATOR.$file); |
293 | 291 | } |
294 | 292 | closedir($folder); |
@@ -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 | } |
@@ -258,6 +258,7 @@ discard block |
||
258 | 258 | |
259 | 259 | /** |
260 | 260 | * Saves the current UrlManager instance to cache. |
261 | + * @param TUrlManager $manager |
|
261 | 262 | * @return boolean true if UrlManager instance was cached, false otherwise. |
262 | 263 | */ |
263 | 264 | protected function cacheUrlManager($manager) |
@@ -349,7 +350,7 @@ discard block |
||
349 | 350 | } |
350 | 351 | |
351 | 352 | /** |
352 | - * @return THttpRequestUrlFormat the format of URLs. Defaults to THttpRequestUrlFormat::Get. |
|
353 | + * @return string the format of URLs. Defaults to THttpRequestUrlFormat::Get. |
|
353 | 354 | */ |
354 | 355 | public function getUrlFormat() |
355 | 356 | { |
@@ -710,6 +711,7 @@ discard block |
||
710 | 711 | * @param array GET parameters, null if not needed |
711 | 712 | * @param boolean whether to encode the ampersand in URL, defaults to true. |
712 | 713 | * @param boolean whether to encode the GET parameters (their names and values), defaults to false. |
714 | + * @param string $serviceID |
|
713 | 715 | * @return string URL |
714 | 716 | * @see TUrlManager::constructUrl |
715 | 717 | */ |
@@ -980,6 +982,7 @@ discard block |
||
980 | 982 | /** |
981 | 983 | * Constructor. |
982 | 984 | * @param mixed owner of this collection. |
985 | + * @param THttpResponse $owner |
|
983 | 986 | */ |
984 | 987 | public function __construct($owner=null) |
985 | 988 | { |
@@ -1125,6 +1128,7 @@ discard block |
||
1125 | 1128 | |
1126 | 1129 | /** |
1127 | 1130 | * @param integer the time the cookie expires. This is a Unix timestamp so is in number of seconds since the epoch. |
1131 | + * @param integer $value |
|
1128 | 1132 | */ |
1129 | 1133 | public function setExpire($value) |
1130 | 1134 | { |
@@ -1287,6 +1291,7 @@ discard block |
||
1287 | 1291 | * Constructor. |
1288 | 1292 | * Decomposes the specified URI into parts. |
1289 | 1293 | * @param string URI to be represented |
1294 | + * @param string $uri |
|
1290 | 1295 | * @throws TInvalidDataValueException if URI is of bad format |
1291 | 1296 | */ |
1292 | 1297 | public function __construct($uri) |
@@ -224,8 +224,7 @@ discard block |
||
224 | 224 | $port=$_SERVER['SERVER_PORT']; |
225 | 225 | if(($port!=80 && !$secure) || ($port!=443 && $secure)) |
226 | 226 | $url.=':'.$port; |
227 | - } |
|
228 | - else |
|
227 | + } else |
|
229 | 228 | $url.=$_SERVER['HTTP_HOST']; |
230 | 229 | $url.=$this->getRequestUri(); |
231 | 230 | $this->_url=new TUri($url); |
@@ -333,8 +332,7 @@ discard block |
||
333 | 332 | { |
334 | 333 | $this->_urlManager=new TUrlManager; |
335 | 334 | $this->_urlManager->init(null); |
336 | - } |
|
337 | - else |
|
335 | + } else |
|
338 | 336 | { |
339 | 337 | $this->_urlManager=$this->getApplication()->getModule($this->_urlManagerID); |
340 | 338 | if($this->_urlManager===null) |
@@ -454,8 +452,7 @@ discard block |
||
454 | 452 | |
455 | 453 | if($result === null && function_exists('apache_request_headers')) { |
456 | 454 | $result = apache_request_headers(); |
457 | - } |
|
458 | - elseif($result === null) { |
|
455 | + } elseif($result === null) { |
|
459 | 456 | $result = array(); |
460 | 457 | foreach($_SERVER as $key=>$value) { |
461 | 458 | if(strncasecmp($key, 'HTTP_', 5) !== 0) continue; |
@@ -558,8 +555,7 @@ discard block |
||
558 | 555 | try |
559 | 556 | { |
560 | 557 | return get_browser(); |
561 | - } |
|
562 | - catch(TPhpErrorException $e) |
|
558 | + } catch(TPhpErrorException $e) |
|
563 | 559 | { |
564 | 560 | throw new TConfigurationException('httprequest_browscap_required'); |
565 | 561 | } |
@@ -662,8 +658,7 @@ discard block |
||
662 | 658 | if(($value=$sm->validateData($value))!==false) |
663 | 659 | $this->_cookies->add(new THttpCookie($key,$value)); |
664 | 660 | } |
665 | - } |
|
666 | - else |
|
661 | + } else |
|
667 | 662 | { |
668 | 663 | foreach($_COOKIE as $key=>$value) |
669 | 664 | $this->_cookies->add(new THttpCookie($key,$value)); |
@@ -880,8 +875,7 @@ discard block |
||
880 | 875 | $value=$this->_items[$key]; |
881 | 876 | unset($this->_items[$key]); |
882 | 877 | return $value; |
883 | - } |
|
884 | - else |
|
878 | + } else |
|
885 | 879 | return null; |
886 | 880 | } |
887 | 881 | |
@@ -1001,8 +995,7 @@ discard block |
||
1001 | 995 | parent::insertAt($index,$item); |
1002 | 996 | if($this->_o instanceof THttpResponse) |
1003 | 997 | $this->_o->addCookie($item); |
1004 | - } |
|
1005 | - else |
|
998 | + } else |
|
1006 | 999 | throw new TInvalidDataTypeException('httpcookiecollection_httpcookie_required'); |
1007 | 1000 | } |
1008 | 1001 | |
@@ -1303,8 +1296,7 @@ discard block |
||
1303 | 1296 | $this->_query=isset($ret['query'])?$ret['query']:''; |
1304 | 1297 | $this->_fragment=isset($ret['fragment'])?$ret['fragment']:''; |
1305 | 1298 | $this->_uri=$uri; |
1306 | - } |
|
1307 | - else |
|
1299 | + } else |
|
1308 | 1300 | { |
1309 | 1301 | throw new TInvalidDataValueException('uri_format_invalid',$uri); |
1310 | 1302 | } |
@@ -66,10 +66,10 @@ discard block |
||
66 | 66 | * @package System.Web |
67 | 67 | * @since 3.0 |
68 | 68 | */ |
69 | -class THttpRequest extends TApplicationComponent implements IteratorAggregate,ArrayAccess,Countable,IModule |
|
69 | +class THttpRequest extends TApplicationComponent implements IteratorAggregate, ArrayAccess, Countable, IModule |
|
70 | 70 | { |
71 | - const CGIFIX__PATH_INFO = 1; |
|
72 | - const CGIFIX__SCRIPT_NAME = 2; |
|
71 | + const CGIFIX__PATH_INFO=1; |
|
72 | + const CGIFIX__SCRIPT_NAME=2; |
|
73 | 73 | /** |
74 | 74 | * @var TUrlManager the URL manager module |
75 | 75 | */ |
@@ -172,14 +172,14 @@ discard block |
||
172 | 172 | if(isset($_SERVER['REQUEST_URI'])) |
173 | 173 | $this->_requestUri=$_SERVER['REQUEST_URI']; |
174 | 174 | else // TBD: in this case, SCRIPT_NAME need to be escaped |
175 | - $this->_requestUri=$_SERVER['SCRIPT_NAME'].(empty($_SERVER['QUERY_STRING'])?'':'?'.$_SERVER['QUERY_STRING']); |
|
175 | + $this->_requestUri=$_SERVER['SCRIPT_NAME'].(empty($_SERVER['QUERY_STRING']) ? '' : '?'.$_SERVER['QUERY_STRING']); |
|
176 | 176 | |
177 | - if($this->_cgiFix&self::CGIFIX__PATH_INFO && isset($_SERVER['ORIG_PATH_INFO'])) |
|
177 | + if($this->_cgiFix & self::CGIFIX__PATH_INFO && isset($_SERVER['ORIG_PATH_INFO'])) |
|
178 | 178 | $this->_pathInfo=substr($_SERVER['ORIG_PATH_INFO'], strlen($_SERVER['SCRIPT_NAME'])); |
179 | 179 | elseif(isset($_SERVER['PATH_INFO'])) |
180 | 180 | $this->_pathInfo=$_SERVER['PATH_INFO']; |
181 | - else if(strpos($_SERVER['PHP_SELF'],$_SERVER['SCRIPT_NAME'])===0 && $_SERVER['PHP_SELF']!==$_SERVER['SCRIPT_NAME']) |
|
182 | - $this->_pathInfo=substr($_SERVER['PHP_SELF'],strlen($_SERVER['SCRIPT_NAME'])); |
|
181 | + else if(strpos($_SERVER['PHP_SELF'], $_SERVER['SCRIPT_NAME'])===0 && $_SERVER['PHP_SELF']!==$_SERVER['SCRIPT_NAME']) |
|
182 | + $this->_pathInfo=substr($_SERVER['PHP_SELF'], strlen($_SERVER['SCRIPT_NAME'])); |
|
183 | 183 | else |
184 | 184 | $this->_pathInfo=''; |
185 | 185 | |
@@ -206,7 +206,7 @@ discard block |
||
206 | 206 | */ |
207 | 207 | public function stripSlashes(&$data) |
208 | 208 | { |
209 | - return is_array($data)?array_map(array($this,'stripSlashes'),$data):stripslashes($data); |
|
209 | + return is_array($data) ? array_map(array($this, 'stripSlashes'), $data) : stripslashes($data); |
|
210 | 210 | } |
211 | 211 | |
212 | 212 | /** |
@@ -217,7 +217,7 @@ discard block |
||
217 | 217 | if($this->_url===null) |
218 | 218 | { |
219 | 219 | $secure=$this->getIsSecureConnection(); |
220 | - $url=$secure?'https://':'http://'; |
|
220 | + $url=$secure ? 'https://' : 'http://'; |
|
221 | 221 | if(empty($_SERVER['HTTP_HOST'])) |
222 | 222 | { |
223 | 223 | $url.=$_SERVER['SERVER_NAME']; |
@@ -240,7 +240,7 @@ discard block |
||
240 | 240 | */ |
241 | 241 | public function setEnableCache($value) |
242 | 242 | { |
243 | - $this->_enableCache = TPropertyValue::ensureBoolean($value); |
|
243 | + $this->_enableCache=TPropertyValue::ensureBoolean($value); |
|
244 | 244 | } |
245 | 245 | |
246 | 246 | /** |
@@ -264,15 +264,15 @@ discard block |
||
264 | 264 | { |
265 | 265 | if($this->getEnableCache()) |
266 | 266 | { |
267 | - $cache = $this->getApplication()->getCache(); |
|
268 | - if($cache !== null) |
|
267 | + $cache=$this->getApplication()->getCache(); |
|
268 | + if($cache!==null) |
|
269 | 269 | { |
270 | - $dependencies = null; |
|
271 | - if($this->getApplication()->getMode() !== TApplicationMode::Performance) |
|
272 | - if ($manager instanceof TUrlMapping && $fn = $manager->getConfigFile()) |
|
270 | + $dependencies=null; |
|
271 | + if($this->getApplication()->getMode()!==TApplicationMode::Performance) |
|
272 | + if($manager instanceof TUrlMapping && $fn=$manager->getConfigFile()) |
|
273 | 273 | { |
274 | - $fn = Prado::getPathOfNamespace($fn,$this->getApplication()->getConfigurationFileExt()); |
|
275 | - $dependencies = new TFileCacheDependency($fn); |
|
274 | + $fn=Prado::getPathOfNamespace($fn, $this->getApplication()->getConfigurationFileExt()); |
|
275 | + $dependencies=new TFileCacheDependency($fn); |
|
276 | 276 | } |
277 | 277 | return $cache->set($this->getCacheKey(), $manager, 0, $dependencies); |
278 | 278 | } |
@@ -288,10 +288,10 @@ discard block |
||
288 | 288 | { |
289 | 289 | if($this->getEnableCache()) |
290 | 290 | { |
291 | - $cache = $this->getApplication()->getCache(); |
|
292 | - if($cache !== null) |
|
291 | + $cache=$this->getApplication()->getCache(); |
|
292 | + if($cache!==null) |
|
293 | 293 | { |
294 | - $manager = $cache->get($this->getCacheKey()); |
|
294 | + $manager=$cache->get($this->getCacheKey()); |
|
295 | 295 | if($manager instanceof TUrlManager) |
296 | 296 | return $manager; |
297 | 297 | } |
@@ -327,7 +327,7 @@ discard block |
||
327 | 327 | { |
328 | 328 | if($this->_urlManager===null) |
329 | 329 | { |
330 | - if(($this->_urlManager = $this->loadCachedUrlManager())===null) |
|
330 | + if(($this->_urlManager=$this->loadCachedUrlManager())===null) |
|
331 | 331 | { |
332 | 332 | if(empty($this->_urlManagerID)) |
333 | 333 | { |
@@ -338,9 +338,9 @@ discard block |
||
338 | 338 | { |
339 | 339 | $this->_urlManager=$this->getApplication()->getModule($this->_urlManagerID); |
340 | 340 | if($this->_urlManager===null) |
341 | - throw new TConfigurationException('httprequest_urlmanager_inexist',$this->_urlManagerID); |
|
341 | + throw new TConfigurationException('httprequest_urlmanager_inexist', $this->_urlManagerID); |
|
342 | 342 | if(!($this->_urlManager instanceof TUrlManager)) |
343 | - throw new TConfigurationException('httprequest_urlmanager_invalid',$this->_urlManagerID); |
|
343 | + throw new TConfigurationException('httprequest_urlmanager_invalid', $this->_urlManagerID); |
|
344 | 344 | } |
345 | 345 | $this->cacheUrlManager($this->_urlManager); |
346 | 346 | } |
@@ -366,7 +366,7 @@ discard block |
||
366 | 366 | */ |
367 | 367 | public function setUrlFormat($value) |
368 | 368 | { |
369 | - $this->_urlFormat=TPropertyValue::ensureEnum($value,'THttpRequestUrlFormat'); |
|
369 | + $this->_urlFormat=TPropertyValue::ensureEnum($value, 'THttpRequestUrlFormat'); |
|
370 | 370 | } |
371 | 371 | |
372 | 372 | /** |
@@ -394,19 +394,19 @@ discard block |
||
394 | 394 | */ |
395 | 395 | public function getRequestType() |
396 | 396 | { |
397 | - return isset($_SERVER['REQUEST_METHOD'])?$_SERVER['REQUEST_METHOD']:null; |
|
397 | + return isset($_SERVER['REQUEST_METHOD']) ? $_SERVER['REQUEST_METHOD'] : null; |
|
398 | 398 | } |
399 | 399 | |
400 | 400 | /** |
401 | 401 | * @param boolean $mimetypeOnly whether to return only the mimetype (default: true) |
402 | 402 | * @return string content type (e.g. 'application/json' or 'text/html; encoding=gzip') or null if not specified |
403 | 403 | */ |
404 | - public function getContentType($mimetypeOnly = true) |
|
404 | + public function getContentType($mimetypeOnly=true) |
|
405 | 405 | { |
406 | 406 | if(!isset($_SERVER['CONTENT_TYPE'])) |
407 | 407 | return null; |
408 | 408 | |
409 | - if($mimetypeOnly === true && ($_pos = strpos(';', $_SERVER['CONTENT_TYPE'])) !== false) |
|
409 | + if($mimetypeOnly===true && ($_pos=strpos(';', $_SERVER['CONTENT_TYPE']))!==false) |
|
410 | 410 | return substr($_SERVER['CONTENT_TYPE'], 0, $_pos); |
411 | 411 | |
412 | 412 | return $_SERVER['CONTENT_TYPE']; |
@@ -417,7 +417,7 @@ discard block |
||
417 | 417 | */ |
418 | 418 | public function getIsSecureConnection() |
419 | 419 | { |
420 | - return isset($_SERVER['HTTPS']) && strcasecmp($_SERVER['HTTPS'],'off'); |
|
420 | + return isset($_SERVER['HTTPS']) && strcasecmp($_SERVER['HTTPS'], 'off'); |
|
421 | 421 | } |
422 | 422 | |
423 | 423 | /** |
@@ -433,7 +433,7 @@ discard block |
||
433 | 433 | */ |
434 | 434 | public function getQueryString() |
435 | 435 | { |
436 | - return isset($_SERVER['QUERY_STRING'])?$_SERVER['QUERY_STRING']:null; |
|
436 | + return isset($_SERVER['QUERY_STRING']) ? $_SERVER['QUERY_STRING'] : null; |
|
437 | 437 | } |
438 | 438 | |
439 | 439 | /** |
@@ -441,7 +441,7 @@ discard block |
||
441 | 441 | */ |
442 | 442 | public function getHttpProtocolVersion() |
443 | 443 | { |
444 | - return isset($_SERVER['SERVER_PROTOCOL'])?$_SERVER['SERVER_PROTOCOL']:null; |
|
444 | + return isset($_SERVER['SERVER_PROTOCOL']) ? $_SERVER['SERVER_PROTOCOL'] : null; |
|
445 | 445 | } |
446 | 446 | |
447 | 447 | /** |
@@ -452,19 +452,19 @@ discard block |
||
452 | 452 | { |
453 | 453 | static $result; |
454 | 454 | |
455 | - if($result === null && function_exists('apache_request_headers')) { |
|
456 | - $result = apache_request_headers(); |
|
455 | + if($result===null && function_exists('apache_request_headers')) { |
|
456 | + $result=apache_request_headers(); |
|
457 | 457 | } |
458 | - elseif($result === null) { |
|
459 | - $result = array(); |
|
458 | + elseif($result===null) { |
|
459 | + $result=array(); |
|
460 | 460 | foreach($_SERVER as $key=>$value) { |
461 | - if(strncasecmp($key, 'HTTP_', 5) !== 0) continue; |
|
462 | - $key = str_replace(' ','-', ucwords(strtolower(str_replace('_',' ', substr($key, 5))))); |
|
463 | - $result[$key] = $value; |
|
461 | + if(strncasecmp($key, 'HTTP_', 5)!==0) continue; |
|
462 | + $key=str_replace(' ', '-', ucwords(strtolower(str_replace('_', ' ', substr($key, 5))))); |
|
463 | + $result[$key]=$value; |
|
464 | 464 | } |
465 | 465 | } |
466 | 466 | |
467 | - if($case !== null) |
|
467 | + if($case!==null) |
|
468 | 468 | return array_change_key_case($result, $case); |
469 | 469 | |
470 | 470 | return $result; |
@@ -488,9 +488,9 @@ discard block |
||
488 | 488 | public function getBaseUrl($forceSecureConnection=null) |
489 | 489 | { |
490 | 490 | $url=$this->getUrl(); |
491 | - $scheme=($forceSecureConnection)?"https": (($forceSecureConnection === null)?$url->getScheme():'http'); |
|
491 | + $scheme=($forceSecureConnection) ? "https" : (($forceSecureConnection===null) ? $url->getScheme() : 'http'); |
|
492 | 492 | $host=$url->getHost(); |
493 | - if (($port=$url->getPort())) $host.=':'.$port; |
|
493 | + if(($port=$url->getPort())) $host.=':'.$port; |
|
494 | 494 | return $scheme.'://'.$host; |
495 | 495 | } |
496 | 496 | |
@@ -499,10 +499,10 @@ discard block |
||
499 | 499 | */ |
500 | 500 | public function getApplicationUrl() |
501 | 501 | { |
502 | - if($this->_cgiFix&self::CGIFIX__SCRIPT_NAME && isset($_SERVER['ORIG_SCRIPT_NAME'])) |
|
502 | + if($this->_cgiFix & self::CGIFIX__SCRIPT_NAME && isset($_SERVER['ORIG_SCRIPT_NAME'])) |
|
503 | 503 | return $_SERVER['ORIG_SCRIPT_NAME']; |
504 | 504 | |
505 | - return isset($_SERVER['SCRIPT_NAME'])?$_SERVER['SCRIPT_NAME']:null; |
|
505 | + return isset($_SERVER['SCRIPT_NAME']) ? $_SERVER['SCRIPT_NAME'] : null; |
|
506 | 506 | } |
507 | 507 | |
508 | 508 | /** |
@@ -514,7 +514,7 @@ discard block |
||
514 | 514 | */ |
515 | 515 | public function getAbsoluteApplicationUrl($forceSecureConnection=null) |
516 | 516 | { |
517 | - return $this->getBaseUrl($forceSecureConnection) . $this->getApplicationUrl(); |
|
517 | + return $this->getBaseUrl($forceSecureConnection).$this->getApplicationUrl(); |
|
518 | 518 | } |
519 | 519 | |
520 | 520 | /** |
@@ -522,7 +522,7 @@ discard block |
||
522 | 522 | */ |
523 | 523 | public function getApplicationFilePath() |
524 | 524 | { |
525 | - return realpath(isset($_SERVER['SCRIPT_FILENAME'])?$_SERVER['SCRIPT_FILENAME']:null); |
|
525 | + return realpath(isset($_SERVER['SCRIPT_FILENAME']) ? $_SERVER['SCRIPT_FILENAME'] : null); |
|
526 | 526 | } |
527 | 527 | |
528 | 528 | /** |
@@ -530,7 +530,7 @@ discard block |
||
530 | 530 | */ |
531 | 531 | public function getServerName() |
532 | 532 | { |
533 | - return isset($_SERVER['SERVER_NAME'])?$_SERVER['SERVER_NAME']:null; |
|
533 | + return isset($_SERVER['SERVER_NAME']) ? $_SERVER['SERVER_NAME'] : null; |
|
534 | 534 | } |
535 | 535 | |
536 | 536 | /** |
@@ -539,7 +539,7 @@ discard block |
||
539 | 539 | */ |
540 | 540 | public function getServerSoftware() |
541 | 541 | { |
542 | - return isset($_SERVER['SERVER_SOFTWARE'])?$_SERVER['SERVER_SOFTWARE']:null; |
|
542 | + return isset($_SERVER['SERVER_SOFTWARE']) ? $_SERVER['SERVER_SOFTWARE'] : null; |
|
543 | 543 | } |
544 | 544 | |
545 | 545 | /** |
@@ -547,7 +547,7 @@ discard block |
||
547 | 547 | */ |
548 | 548 | public function getServerPort() |
549 | 549 | { |
550 | - return isset($_SERVER['SERVER_PORT'])?$_SERVER['SERVER_PORT']:null; |
|
550 | + return isset($_SERVER['SERVER_PORT']) ? $_SERVER['SERVER_PORT'] : null; |
|
551 | 551 | } |
552 | 552 | |
553 | 553 | /** |
@@ -555,7 +555,7 @@ discard block |
||
555 | 555 | */ |
556 | 556 | public function getUrlReferrer() |
557 | 557 | { |
558 | - return isset($_SERVER['HTTP_REFERER'])?$_SERVER['HTTP_REFERER']:null; |
|
558 | + return isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : null; |
|
559 | 559 | } |
560 | 560 | |
561 | 561 | /** |
@@ -579,7 +579,7 @@ discard block |
||
579 | 579 | */ |
580 | 580 | public function getUserAgent() |
581 | 581 | { |
582 | - return isset($_SERVER['HTTP_USER_AGENT'])?$_SERVER['HTTP_USER_AGENT']:null; |
|
582 | + return isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : null; |
|
583 | 583 | } |
584 | 584 | |
585 | 585 | /** |
@@ -587,7 +587,7 @@ discard block |
||
587 | 587 | */ |
588 | 588 | public function getUserHostAddress() |
589 | 589 | { |
590 | - return isset($_SERVER['REMOTE_ADDR'])?$_SERVER['REMOTE_ADDR']:null; |
|
590 | + return isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : null; |
|
591 | 591 | } |
592 | 592 | |
593 | 593 | /** |
@@ -595,7 +595,7 @@ discard block |
||
595 | 595 | */ |
596 | 596 | public function getUserHost() |
597 | 597 | { |
598 | - return isset($_SERVER['REMOTE_HOST'])?$_SERVER['REMOTE_HOST']:null; |
|
598 | + return isset($_SERVER['REMOTE_HOST']) ? $_SERVER['REMOTE_HOST'] : null; |
|
599 | 599 | } |
600 | 600 | |
601 | 601 | /** |
@@ -604,7 +604,7 @@ discard block |
||
604 | 604 | public function getAcceptTypes() |
605 | 605 | { |
606 | 606 | // TBD: break it into array?? |
607 | - return isset($_SERVER['HTTP_ACCEPT'])?$_SERVER['HTTP_ACCEPT']:null; |
|
607 | + return isset($_SERVER['HTTP_ACCEPT']) ? $_SERVER['HTTP_ACCEPT'] : null; |
|
608 | 608 | } |
609 | 609 | |
610 | 610 | /** |
@@ -669,13 +669,13 @@ discard block |
||
669 | 669 | foreach($_COOKIE as $key=>$value) |
670 | 670 | { |
671 | 671 | if(($value=$sm->validateData($value))!==false) |
672 | - $this->_cookies->add(new THttpCookie($key,$value)); |
|
672 | + $this->_cookies->add(new THttpCookie($key, $value)); |
|
673 | 673 | } |
674 | 674 | } |
675 | 675 | else |
676 | 676 | { |
677 | 677 | foreach($_COOKIE as $key=>$value) |
678 | - $this->_cookies->add(new THttpCookie($key,$value)); |
|
678 | + $this->_cookies->add(new THttpCookie($key, $value)); |
|
679 | 679 | } |
680 | 680 | } |
681 | 681 | return $this->_cookies; |
@@ -722,13 +722,13 @@ discard block |
||
722 | 722 | * @return string URL |
723 | 723 | * @see TUrlManager::constructUrl |
724 | 724 | */ |
725 | - public function constructUrl($serviceID,$serviceParam,$getItems=null,$encodeAmpersand=true,$encodeGetItems=true) |
|
725 | + public function constructUrl($serviceID, $serviceParam, $getItems=null, $encodeAmpersand=true, $encodeGetItems=true) |
|
726 | 726 | { |
727 | - if ($this->_cookieOnly===null) |
|
728 | - $this->_cookieOnly=(int)ini_get('session.use_cookies') && (int)ini_get('session.use_only_cookies'); |
|
729 | - $url=$this->getUrlManagerModule()->constructUrl($serviceID,$serviceParam,$getItems,$encodeAmpersand,$encodeGetItems); |
|
730 | - if(defined('SID') && SID != '' && !$this->_cookieOnly) |
|
731 | - return $url . (strpos($url,'?')===false? '?' : ($encodeAmpersand?'&':'&')) . SID; |
|
727 | + if($this->_cookieOnly===null) |
|
728 | + $this->_cookieOnly=(int) ini_get('session.use_cookies') && (int) ini_get('session.use_only_cookies'); |
|
729 | + $url=$this->getUrlManagerModule()->constructUrl($serviceID, $serviceParam, $getItems, $encodeAmpersand, $encodeGetItems); |
|
730 | + if(defined('SID') && SID!='' && !$this->_cookieOnly) |
|
731 | + return $url.(strpos($url, '?')===false ? '?' : ($encodeAmpersand ? '&' : '&')).SID; |
|
732 | 732 | else |
733 | 733 | return $url; |
734 | 734 | } |
@@ -756,11 +756,11 @@ discard block |
||
756 | 756 | */ |
757 | 757 | public function resolveRequest($serviceIDs) |
758 | 758 | { |
759 | - Prado::trace("Resolving request from ".$_SERVER['REMOTE_ADDR'],'System.Web.THttpRequest'); |
|
759 | + Prado::trace("Resolving request from ".$_SERVER['REMOTE_ADDR'], 'System.Web.THttpRequest'); |
|
760 | 760 | $getParams=$this->parseUrl(); |
761 | 761 | foreach($getParams as $name=>$value) |
762 | 762 | $_GET[$name]=$value; |
763 | - $this->_items=array_merge($_GET,$_POST); |
|
763 | + $this->_items=array_merge($_GET, $_POST); |
|
764 | 764 | $this->_requestResolved=true; |
765 | 765 | foreach($serviceIDs as $serviceID) |
766 | 766 | { |
@@ -871,7 +871,7 @@ discard block |
||
871 | 871 | * @param mixed key |
872 | 872 | * @param mixed value |
873 | 873 | */ |
874 | - public function add($key,$value) |
|
874 | + public function add($key, $value) |
|
875 | 875 | { |
876 | 876 | $this->_items[$key]=$value; |
877 | 877 | } |
@@ -884,7 +884,7 @@ discard block |
||
884 | 884 | */ |
885 | 885 | public function remove($key) |
886 | 886 | { |
887 | - if(isset($this->_items[$key]) || array_key_exists($key,$this->_items)) |
|
887 | + if(isset($this->_items[$key]) || array_key_exists($key, $this->_items)) |
|
888 | 888 | { |
889 | 889 | $value=$this->_items[$key]; |
890 | 890 | unset($this->_items[$key]); |
@@ -909,7 +909,7 @@ discard block |
||
909 | 909 | */ |
910 | 910 | public function contains($key) |
911 | 911 | { |
912 | - return isset($this->_items[$key]) || array_key_exists($key,$this->_items); |
|
912 | + return isset($this->_items[$key]) || array_key_exists($key, $this->_items); |
|
913 | 913 | } |
914 | 914 | |
915 | 915 | /** |
@@ -948,9 +948,9 @@ discard block |
||
948 | 948 | * @param integer the offset to set element |
949 | 949 | * @param mixed the element value |
950 | 950 | */ |
951 | - public function offsetSet($offset,$item) |
|
951 | + public function offsetSet($offset, $item) |
|
952 | 952 | { |
953 | - $this->add($offset,$item); |
|
953 | + $this->add($offset, $item); |
|
954 | 954 | } |
955 | 955 | |
956 | 956 | /** |
@@ -1003,11 +1003,11 @@ discard block |
||
1003 | 1003 | * @param mixed new item |
1004 | 1004 | * @throws TInvalidDataTypeException if the item to be inserted is not a THttpCookie object. |
1005 | 1005 | */ |
1006 | - public function insertAt($index,$item) |
|
1006 | + public function insertAt($index, $item) |
|
1007 | 1007 | { |
1008 | 1008 | if($item instanceof THttpCookie) |
1009 | 1009 | { |
1010 | - parent::insertAt($index,$item); |
|
1010 | + parent::insertAt($index, $item); |
|
1011 | 1011 | if($this->_o instanceof THttpResponse) |
1012 | 1012 | $this->_o->addCookie($item); |
1013 | 1013 | } |
@@ -1102,7 +1102,7 @@ discard block |
||
1102 | 1102 | * @param string name of this cookie |
1103 | 1103 | * @param string value of this cookie |
1104 | 1104 | */ |
1105 | - public function __construct($name,$value) |
|
1105 | + public function __construct($name, $value) |
|
1106 | 1106 | { |
1107 | 1107 | $this->_name=$name; |
1108 | 1108 | $this->_value=$value; |
@@ -1153,7 +1153,7 @@ discard block |
||
1153 | 1153 | */ |
1154 | 1154 | public function setHttpOnly($value) |
1155 | 1155 | { |
1156 | - $this->_httpOnly = TPropertyValue::ensureBoolean($value); |
|
1156 | + $this->_httpOnly=TPropertyValue::ensureBoolean($value); |
|
1157 | 1157 | } |
1158 | 1158 | |
1159 | 1159 | /** |
@@ -1303,19 +1303,19 @@ discard block |
||
1303 | 1303 | if(($ret=@parse_url($uri))!==false) |
1304 | 1304 | { |
1305 | 1305 | // decoding??? |
1306 | - $this->_scheme=isset($ret['scheme'])?$ret['scheme']:''; |
|
1307 | - $this->_host=isset($ret['host'])?$ret['host']:''; |
|
1308 | - $this->_port=isset($ret['port'])?$ret['port']:''; |
|
1309 | - $this->_user=isset($ret['user'])?$ret['user']:''; |
|
1310 | - $this->_pass=isset($ret['pass'])?$ret['pass']:''; |
|
1311 | - $this->_path=isset($ret['path'])?$ret['path']:''; |
|
1312 | - $this->_query=isset($ret['query'])?$ret['query']:''; |
|
1313 | - $this->_fragment=isset($ret['fragment'])?$ret['fragment']:''; |
|
1306 | + $this->_scheme=isset($ret['scheme']) ? $ret['scheme'] : ''; |
|
1307 | + $this->_host=isset($ret['host']) ? $ret['host'] : ''; |
|
1308 | + $this->_port=isset($ret['port']) ? $ret['port'] : ''; |
|
1309 | + $this->_user=isset($ret['user']) ? $ret['user'] : ''; |
|
1310 | + $this->_pass=isset($ret['pass']) ? $ret['pass'] : ''; |
|
1311 | + $this->_path=isset($ret['path']) ? $ret['path'] : ''; |
|
1312 | + $this->_query=isset($ret['query']) ? $ret['query'] : ''; |
|
1313 | + $this->_fragment=isset($ret['fragment']) ? $ret['fragment'] : ''; |
|
1314 | 1314 | $this->_uri=$uri; |
1315 | 1315 | } |
1316 | 1316 | else |
1317 | 1317 | { |
1318 | - throw new TInvalidDataValueException('uri_format_invalid',$uri); |
|
1318 | + throw new TInvalidDataValueException('uri_format_invalid', $uri); |
|
1319 | 1319 | } |
1320 | 1320 | } |
1321 | 1321 |
@@ -606,6 +606,7 @@ discard block |
||
606 | 606 | |
607 | 607 | /** |
608 | 608 | * @param string full regular expression mapping pattern. |
609 | + * @param string $value |
|
609 | 610 | */ |
610 | 611 | public function setRegularExpression($value) |
611 | 612 | { |
@@ -715,6 +716,7 @@ discard block |
||
715 | 716 | * Uses URL pattern (or full regular expression if available) to |
716 | 717 | * match the given url path. |
717 | 718 | * @param THttpRequest the request module |
719 | + * @param THttpRequest $request |
|
718 | 720 | * @return array matched parameters, empty if no matches. |
719 | 721 | */ |
720 | 722 | public function getPatternMatches($request) |
@@ -785,7 +787,7 @@ discard block |
||
785 | 787 | } |
786 | 788 | |
787 | 789 | /** |
788 | - * @return THttpRequestUrlFormat the format of URLs. Defaults to THttpRequestUrlFormat::Get. |
|
790 | + * @return string the format of URLs. Defaults to THttpRequestUrlFormat::Get. |
|
789 | 791 | */ |
790 | 792 | public function getUrlFormat() |
791 | 793 | { |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | $this->_urlPrefix=$request->getApplicationUrl(); |
117 | 117 | } |
118 | 118 | } |
119 | - $this->_urlPrefix=rtrim($this->_urlPrefix,'/'); |
|
119 | + $this->_urlPrefix=rtrim($this->_urlPrefix, '/'); |
|
120 | 120 | } |
121 | 121 | |
122 | 122 | /** |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | { |
130 | 130 | if($this->getApplication()->getConfigurationType()==TApplication::CONFIG_TYPE_PHP) |
131 | 131 | { |
132 | - $config = include $this->_configFile; |
|
132 | + $config=include $this->_configFile; |
|
133 | 133 | $this->loadUrlMappings($dom); |
134 | 134 | } |
135 | 135 | else |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | } |
141 | 141 | } |
142 | 142 | else |
143 | - throw new TConfigurationException('urlmapping_configfile_inexistent',$this->_configFile); |
|
143 | + throw new TConfigurationException('urlmapping_configfile_inexistent', $this->_configFile); |
|
144 | 144 | } |
145 | 145 | |
146 | 146 | /** |
@@ -201,8 +201,8 @@ discard block |
||
201 | 201 | */ |
202 | 202 | public function setConfigFile($value) |
203 | 203 | { |
204 | - if(($this->_configFile=Prado::getPathOfNamespace($value,$this->getApplication()->getConfigurationFileExt()))===null) |
|
205 | - throw new TConfigurationException('urlmapping_configfile_invalid',$value); |
|
204 | + if(($this->_configFile=Prado::getPathOfNamespace($value, $this->getApplication()->getConfigurationFileExt()))===null) |
|
205 | + throw new TConfigurationException('urlmapping_configfile_invalid', $value); |
|
206 | 206 | } |
207 | 207 | |
208 | 208 | /** |
@@ -233,7 +233,7 @@ discard block |
||
233 | 233 | */ |
234 | 234 | protected function loadUrlMappings($config) |
235 | 235 | { |
236 | - $defaultClass = $this->getDefaultMappingClass(); |
|
236 | + $defaultClass=$this->getDefaultMappingClass(); |
|
237 | 237 | |
238 | 238 | if(is_array($config)) |
239 | 239 | { |
@@ -241,9 +241,9 @@ discard block |
||
241 | 241 | { |
242 | 242 | foreach($config['urls'] as $url) |
243 | 243 | { |
244 | - $class=isset($url['class'])?$url['class']:$defaultClass; |
|
245 | - $properties = isset($url['properties'])?$url['properties']:array(); |
|
246 | - $this->buildUrlMapping($class,$properties,$url); |
|
244 | + $class=isset($url['class']) ? $url['class'] : $defaultClass; |
|
245 | + $properties=isset($url['properties']) ? $url['properties'] : array(); |
|
246 | + $this->buildUrlMapping($class, $properties, $url); |
|
247 | 247 | } |
248 | 248 | } |
249 | 249 | } |
@@ -254,24 +254,24 @@ discard block |
||
254 | 254 | $properties=$url->getAttributes(); |
255 | 255 | if(($class=$properties->remove('class'))===null) |
256 | 256 | $class=$defaultClass; |
257 | - $this->buildUrlMapping($class,$properties,$url); |
|
257 | + $this->buildUrlMapping($class, $properties, $url); |
|
258 | 258 | } |
259 | 259 | } |
260 | 260 | } |
261 | 261 | |
262 | 262 | private function buildUrlMapping($class, $properties, $url) |
263 | 263 | { |
264 | - $pattern=Prado::createComponent($class,$this); |
|
264 | + $pattern=Prado::createComponent($class, $this); |
|
265 | 265 | if(!($pattern instanceof TUrlMappingPattern)) |
266 | 266 | throw new TConfigurationException('urlmapping_urlmappingpattern_required'); |
267 | 267 | foreach($properties as $name=>$value) |
268 | - $pattern->setSubproperty($name,$value); |
|
268 | + $pattern->setSubproperty($name, $value); |
|
269 | 269 | |
270 | 270 | if($url instanceof TXmlElement) { |
271 | - $text = $url -> getValue(); |
|
271 | + $text=$url -> getValue(); |
|
272 | 272 | if($text) { |
273 | - $text = preg_replace('/(\s+)/S', '', $text); |
|
274 | - if(($regExp = $pattern->getRegularExpression()) !== '') |
|
273 | + $text=preg_replace('/(\s+)/S', '', $text); |
|
274 | + if(($regExp=$pattern->getRegularExpression())!=='') |
|
275 | 275 | trigger_error(sPrintF('%s.RegularExpression property value "%s" for ServiceID="%s" and ServiceParameter="%s" was replaced by node value "%s"', |
276 | 276 | get_class($pattern), |
277 | 277 | $regExp, |
@@ -304,7 +304,7 @@ discard block |
||
304 | 304 | foreach($this->_patterns as $pattern) |
305 | 305 | { |
306 | 306 | $matches=$pattern->getPatternMatches($request); |
307 | - if(count($matches)>0) |
|
307 | + if(count($matches) > 0) |
|
308 | 308 | { |
309 | 309 | $this->_matched=$pattern; |
310 | 310 | $params=array(); |
@@ -313,7 +313,7 @@ discard block |
||
313 | 313 | if(is_string($key)) |
314 | 314 | $params[$key]=$value; |
315 | 315 | } |
316 | - if (!$pattern->getIsWildCardPattern()) |
|
316 | + if(!$pattern->getIsWildCardPattern()) |
|
317 | 317 | $params[$pattern->getServiceID()]=$pattern->getServiceParameter(); |
318 | 318 | return $params; |
319 | 319 | } |
@@ -345,21 +345,21 @@ discard block |
||
345 | 345 | * @see parseUrl |
346 | 346 | * @since 3.1.1 |
347 | 347 | */ |
348 | - public function constructUrl($serviceID,$serviceParam,$getItems,$encodeAmpersand,$encodeGetItems) |
|
348 | + public function constructUrl($serviceID, $serviceParam, $getItems, $encodeAmpersand, $encodeGetItems) |
|
349 | 349 | { |
350 | 350 | if($this->_customUrl) |
351 | 351 | { |
352 | 352 | if(!(is_array($getItems) || ($getItems instanceof Traversable))) |
353 | 353 | $getItems=array(); |
354 | 354 | $key=$serviceID.':'.$serviceParam; |
355 | - $wildCardKey = ($pos=strrpos($serviceParam,'.'))!==false ? |
|
356 | - $serviceID.':'.substr($serviceParam,0,$pos).'.*' : $serviceID.':*'; |
|
355 | + $wildCardKey=($pos=strrpos($serviceParam, '.'))!==false ? |
|
356 | + $serviceID.':'.substr($serviceParam, 0, $pos).'.*' : $serviceID.':*'; |
|
357 | 357 | if(isset($this->_constructRules[$key])) |
358 | 358 | { |
359 | 359 | foreach($this->_constructRules[$key] as $rule) |
360 | 360 | { |
361 | 361 | if($rule->supportCustomUrl($getItems)) |
362 | - return $rule->constructUrl($getItems,$encodeAmpersand,$encodeGetItems); |
|
362 | + return $rule->constructUrl($getItems, $encodeAmpersand, $encodeGetItems); |
|
363 | 363 | } |
364 | 364 | } |
365 | 365 | elseif(isset($this->_constructRules[$wildCardKey])) |
@@ -368,13 +368,13 @@ discard block |
||
368 | 368 | { |
369 | 369 | if($rule->supportCustomUrl($getItems)) |
370 | 370 | { |
371 | - $getItems['*']= $pos ? substr($serviceParam,$pos+1) : $serviceParam; |
|
372 | - return $rule->constructUrl($getItems,$encodeAmpersand,$encodeGetItems); |
|
371 | + $getItems['*']=$pos ? substr($serviceParam, $pos + 1) : $serviceParam; |
|
372 | + return $rule->constructUrl($getItems, $encodeAmpersand, $encodeGetItems); |
|
373 | 373 | } |
374 | 374 | } |
375 | 375 | } |
376 | 376 | } |
377 | - return parent::constructUrl($serviceID,$serviceParam,$getItems,$encodeAmpersand,$encodeGetItems); |
|
377 | + return parent::constructUrl($serviceID, $serviceParam, $getItems, $encodeAmpersand, $encodeGetItems); |
|
378 | 378 | } |
379 | 379 | |
380 | 380 | /** |
@@ -528,7 +528,7 @@ discard block |
||
528 | 528 | * @var TUrlMappingPatternSecureConnection |
529 | 529 | * @since 3.2 |
530 | 530 | */ |
531 | - private $_secureConnection = TUrlMappingPatternSecureConnection::Automatic; |
|
531 | + private $_secureConnection=TUrlMappingPatternSecureConnection::Automatic; |
|
532 | 532 | |
533 | 533 | /** |
534 | 534 | * Constructor. |
@@ -556,7 +556,7 @@ discard block |
||
556 | 556 | { |
557 | 557 | if($this->_serviceParameter===null) |
558 | 558 | throw new TConfigurationException('urlmappingpattern_serviceparameter_required', $this->getPattern()); |
559 | - if(strpos($this->_serviceParameter,'*')!==false) |
|
559 | + if(strpos($this->_serviceParameter, '*')!==false) |
|
560 | 560 | $this->_isWildCardPattern=true; |
561 | 561 | } |
562 | 562 | |
@@ -569,7 +569,7 @@ discard block |
||
569 | 569 | { |
570 | 570 | $params=array(); |
571 | 571 | $values=array(); |
572 | - if ($this->_parameters) |
|
572 | + if($this->_parameters) |
|
573 | 573 | { |
574 | 574 | foreach($this->_parameters as $key=>$value) |
575 | 575 | { |
@@ -577,7 +577,7 @@ discard block |
||
577 | 577 | $values[]='(?P<'.$key.'>'.$value.')'; |
578 | 578 | } |
579 | 579 | } |
580 | - if ($this->getIsWildCardPattern()) |
|
580 | + if($this->getIsWildCardPattern()) |
|
581 | 581 | { |
582 | 582 | $params[]='{*}'; |
583 | 583 | // service parameter must not contain '=' and '/' |
@@ -585,8 +585,8 @@ discard block |
||
585 | 585 | } |
586 | 586 | $params[]='/'; |
587 | 587 | $values[]='\\/'; |
588 | - $regexp=str_replace($params,$values,trim($this->getPattern(),'/').'/'); |
|
589 | - if ($this->_urlFormat===THttpRequestUrlFormat::Get) |
|
588 | + $regexp=str_replace($params, $values, trim($this->getPattern(), '/').'/'); |
|
589 | + if($this->_urlFormat===THttpRequestUrlFormat::Get) |
|
590 | 590 | $regexp='/^'.$regexp.'$/u'; |
591 | 591 | else |
592 | 592 | $regexp='/^'.$regexp.'(?P<urlparams>.*)$/u'; |
@@ -673,7 +673,7 @@ discard block |
||
673 | 673 | */ |
674 | 674 | public function setPattern($value) |
675 | 675 | { |
676 | - $this->_pattern = $value; |
|
676 | + $this->_pattern=$value; |
|
677 | 677 | } |
678 | 678 | |
679 | 679 | /** |
@@ -681,7 +681,7 @@ discard block |
||
681 | 681 | */ |
682 | 682 | public function getParameters() |
683 | 683 | { |
684 | - if (!$this->_parameters) |
|
684 | + if(!$this->_parameters) |
|
685 | 685 | { |
686 | 686 | $this->_parameters=new TAttributeCollection; |
687 | 687 | $this->_parameters->setCaseSensitive(true); |
@@ -703,9 +703,9 @@ discard block |
||
703 | 703 | */ |
704 | 704 | public function getConstants() |
705 | 705 | { |
706 | - if (!$this->_constants) |
|
706 | + if(!$this->_constants) |
|
707 | 707 | { |
708 | - $this->_constants = new TAttributeCollection; |
|
708 | + $this->_constants=new TAttributeCollection; |
|
709 | 709 | $this->_constants->setCaseSensitive(true); |
710 | 710 | } |
711 | 711 | return $this->_constants; |
@@ -721,17 +721,17 @@ discard block |
||
721 | 721 | { |
722 | 722 | $matches=array(); |
723 | 723 | if(($pattern=$this->getRegularExpression())!=='') |
724 | - preg_match($pattern,$request->getPathInfo(),$matches); |
|
724 | + preg_match($pattern, $request->getPathInfo(), $matches); |
|
725 | 725 | else |
726 | - preg_match($this->getParameterizedPattern(),trim($request->getPathInfo(),'/').'/',$matches); |
|
726 | + preg_match($this->getParameterizedPattern(), trim($request->getPathInfo(), '/').'/', $matches); |
|
727 | 727 | |
728 | 728 | if($this->getIsWildCardPattern() && isset($matches[$this->_serviceID])) |
729 | - $matches[$this->_serviceID]=str_replace('*',$matches[$this->_serviceID],$this->_serviceParameter); |
|
729 | + $matches[$this->_serviceID]=str_replace('*', $matches[$this->_serviceID], $this->_serviceParameter); |
|
730 | 730 | |
731 | - if (isset($matches['urlparams'])) |
|
731 | + if(isset($matches['urlparams'])) |
|
732 | 732 | { |
733 | - $params=explode('/',$matches['urlparams']); |
|
734 | - if ($this->_separator==='/') |
|
733 | + $params=explode('/', $matches['urlparams']); |
|
734 | + if($this->_separator==='/') |
|
735 | 735 | { |
736 | 736 | while($key=array_shift($params)) |
737 | 737 | $matches[$key]=($value=array_shift($params)) ? $value : ''; |
@@ -741,7 +741,7 @@ discard block |
||
741 | 741 | array_pop($params); |
742 | 742 | foreach($params as $param) |
743 | 743 | { |
744 | - list($key,$value)=explode($this->_separator,$param,2); |
|
744 | + list($key, $value)=explode($this->_separator, $param, 2); |
|
745 | 745 | $matches[$key]=$value; |
746 | 746 | } |
747 | 747 | } |
@@ -751,7 +751,7 @@ discard block |
||
751 | 751 | if(count($matches) > 0 && $this->_constants) |
752 | 752 | { |
753 | 753 | foreach($this->_constants->toArray() as $key=>$value) |
754 | - $matches[$key] = $value; |
|
754 | + $matches[$key]=$value; |
|
755 | 755 | } |
756 | 756 | |
757 | 757 | return $matches; |
@@ -805,7 +805,7 @@ discard block |
||
805 | 805 | */ |
806 | 806 | public function setUrlFormat($value) |
807 | 807 | { |
808 | - $this->_urlFormat=TPropertyValue::ensureEnum($value,'THttpRequestUrlFormat'); |
|
808 | + $this->_urlFormat=TPropertyValue::ensureEnum($value, 'THttpRequestUrlFormat'); |
|
809 | 809 | } |
810 | 810 | |
811 | 811 | /** |
@@ -843,7 +843,7 @@ discard block |
||
843 | 843 | */ |
844 | 844 | public function setSecureConnection($value) |
845 | 845 | { |
846 | - $this->_secureConnection = TPropertyValue::ensureEnum($value, 'TUrlMappingPatternSecureConnection'); |
|
846 | + $this->_secureConnection=TPropertyValue::ensureEnum($value, 'TUrlMappingPatternSecureConnection'); |
|
847 | 847 | } |
848 | 848 | |
849 | 849 | /** |
@@ -855,7 +855,7 @@ discard block |
||
855 | 855 | { |
856 | 856 | if(!$this->_customUrl || $this->getPattern()===null) |
857 | 857 | return false; |
858 | - if ($this->_parameters) |
|
858 | + if($this->_parameters) |
|
859 | 859 | { |
860 | 860 | foreach($this->_parameters as $key=>$value) |
861 | 861 | { |
@@ -864,13 +864,13 @@ discard block |
||
864 | 864 | } |
865 | 865 | } |
866 | 866 | |
867 | - if ($this->_constants) |
|
867 | + if($this->_constants) |
|
868 | 868 | { |
869 | 869 | foreach($this->_constants->toArray() as $key=>$value) |
870 | 870 | { |
871 | - if (!isset($getItems[$key])) |
|
871 | + if(!isset($getItems[$key])) |
|
872 | 872 | return false; |
873 | - if ($getItems[$key]!=$value) |
|
873 | + if($getItems[$key]!=$value) |
|
874 | 874 | return false; |
875 | 875 | } |
876 | 876 | } |
@@ -885,9 +885,9 @@ discard block |
||
885 | 885 | * @return string the constructed URL |
886 | 886 | * @since 3.1.1 |
887 | 887 | */ |
888 | - public function constructUrl($getItems,$encodeAmpersand,$encodeGetItems) |
|
888 | + public function constructUrl($getItems, $encodeAmpersand, $encodeGetItems) |
|
889 | 889 | { |
890 | - if ($this->_constants) |
|
890 | + if($this->_constants) |
|
891 | 891 | { |
892 | 892 | foreach($this->_constants->toArray() as $key=>$value) |
893 | 893 | { |
@@ -906,19 +906,19 @@ discard block |
||
906 | 906 | $extra[$key]=$value; |
907 | 907 | } |
908 | 908 | |
909 | - $url=$this->_manager->getUrlPrefix().'/'.ltrim(strtr($this->getPattern(),$replace),'/'); |
|
909 | + $url=$this->_manager->getUrlPrefix().'/'.ltrim(strtr($this->getPattern(), $replace), '/'); |
|
910 | 910 | |
911 | 911 | // for the rest of the GET variables, put them in the query string |
912 | - if(count($extra)>0) |
|
912 | + if(count($extra) > 0) |
|
913 | 913 | { |
914 | - if ($this->_urlFormat===THttpRequestUrlFormat::Path && $this->getIsWildCardPattern()) { |
|
915 | - foreach ($extra as $name=>$value) |
|
916 | - $url.='/'.$name.$this->_separator.($encodeGetItems?rawurlencode($value):$value); |
|
914 | + if($this->_urlFormat===THttpRequestUrlFormat::Path && $this->getIsWildCardPattern()) { |
|
915 | + foreach($extra as $name=>$value) |
|
916 | + $url.='/'.$name.$this->_separator.($encodeGetItems ? rawurlencode($value) : $value); |
|
917 | 917 | return $url; |
918 | 918 | } |
919 | 919 | |
920 | 920 | $url2=''; |
921 | - $amp=$encodeAmpersand?'&':'&'; |
|
921 | + $amp=$encodeAmpersand ? '&' : '&'; |
|
922 | 922 | if($encodeGetItems) |
923 | 923 | { |
924 | 924 | foreach($extra as $name=>$value) |
@@ -946,7 +946,7 @@ discard block |
||
946 | 946 | $url2.=$amp.$name.'='.$value; |
947 | 947 | } |
948 | 948 | } |
949 | - $url=$url.'?'.substr($url2,strlen($amp)); |
|
949 | + $url=$url.'?'.substr($url2, strlen($amp)); |
|
950 | 950 | } |
951 | 951 | return $this -> applySecureConnectionPrefix($url); |
952 | 952 | } |
@@ -962,26 +962,26 @@ discard block |
||
962 | 962 | protected function applySecureConnectionPrefix($url) |
963 | 963 | { |
964 | 964 | static $request; |
965 | - if($request === null) $request = Prado::getApplication() -> getRequest(); |
|
965 | + if($request===null) $request=Prado::getApplication() -> getRequest(); |
|
966 | 966 | |
967 | 967 | static $isSecureConnection; |
968 | - if($isSecureConnection === null) $isSecureConnection = $request -> getIsSecureConnection(); |
|
968 | + if($isSecureConnection===null) $isSecureConnection=$request -> getIsSecureConnection(); |
|
969 | 969 | |
970 | 970 | switch($this -> getSecureConnection()) |
971 | 971 | { |
972 | 972 | case TUrlMappingPatternSecureConnection::EnableIfNotSecure: |
973 | 973 | if($isSecureConnection) return $url; |
974 | - return $request -> getBaseUrl(true) . $url; |
|
974 | + return $request -> getBaseUrl(true).$url; |
|
975 | 975 | break; |
976 | 976 | case TUrlMappingPatternSecureConnection::DisableIfSecure: |
977 | 977 | if(!$isSecureConnection) return $url; |
978 | - return $request -> getBaseUrl(false) . $url; |
|
978 | + return $request -> getBaseUrl(false).$url; |
|
979 | 979 | break; |
980 | 980 | case TUrlMappingPatternSecureConnection::Enable: |
981 | - return $request -> getBaseUrl(true) . $url; |
|
981 | + return $request -> getBaseUrl(true).$url; |
|
982 | 982 | break; |
983 | 983 | case TUrlMappingPatternSecureConnection::Disable: |
984 | - return $request -> getBaseUrl(false) . $url; |
|
984 | + return $request -> getBaseUrl(false).$url; |
|
985 | 985 | break; |
986 | 986 | case TUrlMappingPatternSecureConnection::Automatic: |
987 | 987 | default: |
@@ -1007,29 +1007,29 @@ discard block |
||
1007 | 1007 | * Keep current SecureConnection status |
1008 | 1008 | * means no prefixing |
1009 | 1009 | */ |
1010 | - const Automatic = 'Automatic'; |
|
1010 | + const Automatic='Automatic'; |
|
1011 | 1011 | |
1012 | 1012 | /** |
1013 | 1013 | * Force use secured connection |
1014 | 1014 | * always prefixing with https://example.com/path/to/app |
1015 | 1015 | */ |
1016 | - const Enable = 'Enable'; |
|
1016 | + const Enable='Enable'; |
|
1017 | 1017 | |
1018 | 1018 | /** |
1019 | 1019 | * Force use unsecured connection |
1020 | 1020 | * always prefixing with http://example.com/path/to/app |
1021 | 1021 | */ |
1022 | - const Disable = 'Disable'; |
|
1022 | + const Disable='Disable'; |
|
1023 | 1023 | |
1024 | 1024 | /** |
1025 | 1025 | * Force use secured connection, if in unsecured mode |
1026 | 1026 | * prefixing with https://example.com/path/to/app |
1027 | 1027 | */ |
1028 | - const EnableIfNotSecure = 'EnableIfNotSecure'; |
|
1028 | + const EnableIfNotSecure='EnableIfNotSecure'; |
|
1029 | 1029 | |
1030 | 1030 | /** |
1031 | 1031 | * Force use unsecured connection, if in secured mode |
1032 | 1032 | * prefixing with https://example.com/path/to/app |
1033 | 1033 | */ |
1034 | - const DisableIfSecure = 'DisableIfSecure'; |
|
1034 | + const DisableIfSecure='DisableIfSecure'; |
|
1035 | 1035 | } |
@@ -131,15 +131,13 @@ discard block |
||
131 | 131 | { |
132 | 132 | $config = include $this->_configFile; |
133 | 133 | $this->loadUrlMappings($dom); |
134 | - } |
|
135 | - else |
|
134 | + } else |
|
136 | 135 | { |
137 | 136 | $dom=new TXmlDocument; |
138 | 137 | $dom->loadFromFile($this->_configFile); |
139 | 138 | $this->loadUrlMappings($dom); |
140 | 139 | } |
141 | - } |
|
142 | - else |
|
140 | + } else |
|
143 | 141 | throw new TConfigurationException('urlmapping_configfile_inexistent',$this->_configFile); |
144 | 142 | } |
145 | 143 | |
@@ -246,8 +244,7 @@ discard block |
||
246 | 244 | $this->buildUrlMapping($class,$properties,$url); |
247 | 245 | } |
248 | 246 | } |
249 | - } |
|
250 | - else |
|
247 | + } else |
|
251 | 248 | { |
252 | 249 | foreach($config->getElementsByTagName('url') as $url) |
253 | 250 | { |
@@ -361,8 +358,7 @@ discard block |
||
361 | 358 | if($rule->supportCustomUrl($getItems)) |
362 | 359 | return $rule->constructUrl($getItems,$encodeAmpersand,$encodeGetItems); |
363 | 360 | } |
364 | - } |
|
365 | - elseif(isset($this->_constructRules[$wildCardKey])) |
|
361 | + } elseif(isset($this->_constructRules[$wildCardKey])) |
|
366 | 362 | { |
367 | 363 | foreach($this->_constructRules[$wildCardKey] as $rule) |
368 | 364 | { |
@@ -733,10 +729,10 @@ discard block |
||
733 | 729 | $params=explode('/',$matches['urlparams']); |
734 | 730 | if ($this->_separator==='/') |
735 | 731 | { |
736 | - while($key=array_shift($params)) |
|
737 | - $matches[$key]=($value=array_shift($params)) ? $value : ''; |
|
738 | - } |
|
739 | - else |
|
732 | + while($key=array_shift($params)) { |
|
733 | + $matches[$key]=($value=array_shift($params)) ? $value : ''; |
|
734 | + } |
|
735 | + } else |
|
740 | 736 | { |
741 | 737 | array_pop($params); |
742 | 738 | foreach($params as $param) |
@@ -928,12 +924,10 @@ discard block |
||
928 | 924 | $name=rawurlencode($name.'[]'); |
929 | 925 | foreach($value as $v) |
930 | 926 | $url2.=$amp.$name.'='.rawurlencode($v); |
931 | - } |
|
932 | - else |
|
927 | + } else |
|
933 | 928 | $url2.=$amp.rawurlencode($name).'='.rawurlencode($value); |
934 | 929 | } |
935 | - } |
|
936 | - else |
|
930 | + } else |
|
937 | 931 | { |
938 | 932 | foreach($extra as $name=>$value) |
939 | 933 | { |
@@ -941,8 +935,7 @@ discard block |
||
941 | 935 | { |
942 | 936 | foreach($value as $v) |
943 | 937 | $url2.=$amp.$name.'[]='.$v; |
944 | - } |
|
945 | - else |
|
938 | + } else |
|
946 | 939 | $url2.=$amp.$name.'='.$value; |
947 | 940 | } |
948 | 941 | } |
@@ -220,6 +220,7 @@ discard block |
||
220 | 220 | * If you override this method, be sure to call the parent implementation |
221 | 221 | * so that the event handler can be invoked. |
222 | 222 | * @param TImageClickEventParameter event parameter to be passed to the event handlers |
223 | + * @param TImageClickEventParameter $param |
|
223 | 224 | */ |
224 | 225 | public function onClick($param) |
225 | 226 | { |
@@ -232,6 +233,7 @@ discard block |
||
232 | 233 | * If you override this method, be sure to call the parent implementation |
233 | 234 | * so that the event handlers can be invoked. |
234 | 235 | * @param TCommandEventParameter event parameter to be passed to the event handlers |
236 | + * @param TCommandEventParameter $param |
|
235 | 237 | */ |
236 | 238 | public function onCommand($param) |
237 | 239 | { |
@@ -324,6 +326,7 @@ discard block |
||
324 | 326 | |
325 | 327 | /** |
326 | 328 | * @param string the group of validators which the button causes validation upon postback |
329 | + * @param string $value |
|
327 | 330 | */ |
328 | 331 | public function setValidationGroup($value) |
329 | 332 | { |
@@ -396,6 +399,8 @@ discard block |
||
396 | 399 | * Constructor. |
397 | 400 | * @param integer X coordinate of the clicking point |
398 | 401 | * @param integer Y coordinate of the clicking point |
402 | + * @param integer $x |
|
403 | + * @param integer $y |
|
399 | 404 | */ |
400 | 405 | public function __construct($x,$y) |
401 | 406 | { |
@@ -106,8 +106,7 @@ discard block |
||
106 | 106 | { |
107 | 107 | if($this->getEnableClientScript() && $this->needPostBackScript()) |
108 | 108 | $this->renderClientControlScript($writer); |
109 | - } |
|
110 | - else if($this->getEnabled()) // in this case, parent will not render 'disabled' |
|
109 | + } else if($this->getEnabled()) // in this case, parent will not render 'disabled' |
|
111 | 110 | $writer->addAttribute('disabled','disabled'); |
112 | 111 | parent::addAttributesToRender($writer); |
113 | 112 | } |
@@ -141,8 +140,7 @@ discard block |
||
141 | 140 | { |
142 | 141 | $group=$this->getValidationGroup(); |
143 | 142 | return $this->getPage()->getValidators($group)->getCount()>0; |
144 | - } |
|
145 | - else |
|
143 | + } else |
|
146 | 144 | return false; |
147 | 145 | } |
148 | 146 |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | */ |
80 | 80 | public function getEnableClientScript() |
81 | 81 | { |
82 | - return $this->getViewState('EnableClientScript',true); |
|
82 | + return $this->getViewState('EnableClientScript', true); |
|
83 | 83 | } |
84 | 84 | |
85 | 85 | /** |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | */ |
88 | 88 | public function setEnableClientScript($value) |
89 | 89 | { |
90 | - $this->setViewState('EnableClientScript',TPropertyValue::ensureBoolean($value),true); |
|
90 | + $this->setViewState('EnableClientScript', TPropertyValue::ensureBoolean($value), true); |
|
91 | 91 | } |
92 | 92 | |
93 | 93 | /** |
@@ -99,16 +99,16 @@ discard block |
||
99 | 99 | { |
100 | 100 | $page=$this->getPage(); |
101 | 101 | $page->ensureRenderInForm($this); |
102 | - $writer->addAttribute('type','image'); |
|
102 | + $writer->addAttribute('type', 'image'); |
|
103 | 103 | if(($uniqueID=$this->getUniqueID())!=='') |
104 | - $writer->addAttribute('name',$uniqueID); |
|
104 | + $writer->addAttribute('name', $uniqueID); |
|
105 | 105 | if($this->getEnabled(true)) |
106 | 106 | { |
107 | 107 | if($this->getEnableClientScript() && $this->needPostBackScript()) |
108 | 108 | $this->renderClientControlScript($writer); |
109 | 109 | } |
110 | 110 | else if($this->getEnabled()) // in this case, parent will not render 'disabled' |
111 | - $writer->addAttribute('disabled','disabled'); |
|
111 | + $writer->addAttribute('disabled', 'disabled'); |
|
112 | 112 | parent::addAttributesToRender($writer); |
113 | 113 | } |
114 | 114 | |
@@ -117,9 +117,9 @@ discard block |
||
117 | 117 | */ |
118 | 118 | protected function renderClientControlScript($writer) |
119 | 119 | { |
120 | - $writer->addAttribute('id',$this->getClientID()); |
|
121 | - $cs = $this->getPage()->getClientScript(); |
|
122 | - $cs->registerPostBackControl($this->getClientClassName(),$this->getPostBackOptions()); |
|
120 | + $writer->addAttribute('id', $this->getClientID()); |
|
121 | + $cs=$this->getPage()->getClientScript(); |
|
122 | + $cs->registerPostBackControl($this->getClientClassName(), $this->getPostBackOptions()); |
|
123 | 123 | } |
124 | 124 | |
125 | 125 | /** |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | if($this->getCausesValidation()) |
141 | 141 | { |
142 | 142 | $group=$this->getValidationGroup(); |
143 | - return $this->getPage()->getValidators($group)->getCount()>0; |
|
143 | + return $this->getPage()->getValidators($group)->getCount() > 0; |
|
144 | 144 | } |
145 | 145 | else |
146 | 146 | return false; |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | */ |
152 | 152 | public function setIsDefaultButton($value) |
153 | 153 | { |
154 | - $this->setViewState('IsDefaultButton', TPropertyValue::ensureBoolean($value),false); |
|
154 | + $this->setViewState('IsDefaultButton', TPropertyValue::ensureBoolean($value), false); |
|
155 | 155 | } |
156 | 156 | |
157 | 157 | /** |
@@ -177,10 +177,10 @@ discard block |
||
177 | 177 | */ |
178 | 178 | protected function getPostBackOptions() |
179 | 179 | { |
180 | - $options['ID'] = $this->getClientID(); |
|
181 | - $options['CausesValidation'] = $this->getCausesValidation(); |
|
182 | - $options['ValidationGroup'] = $this->getValidationGroup(); |
|
183 | - $options['EventTarget'] = $this->getUniqueID(); |
|
180 | + $options['ID']=$this->getClientID(); |
|
181 | + $options['CausesValidation']=$this->getCausesValidation(); |
|
182 | + $options['ValidationGroup']=$this->getValidationGroup(); |
|
183 | + $options['EventTarget']=$this->getUniqueID(); |
|
184 | 184 | |
185 | 185 | return $options; |
186 | 186 | } |
@@ -192,7 +192,7 @@ discard block |
||
192 | 192 | * @param array the input data collection |
193 | 193 | * @return boolean whether the data of the component has been changed |
194 | 194 | */ |
195 | - public function loadPostData($key,$values) |
|
195 | + public function loadPostData($key, $values) |
|
196 | 196 | { |
197 | 197 | $uid=$this->getUniqueID(); |
198 | 198 | if(isset($values["{$uid}_x"]) && isset($values["{$uid}_y"])) |
@@ -223,7 +223,7 @@ discard block |
||
223 | 223 | */ |
224 | 224 | public function onClick($param) |
225 | 225 | { |
226 | - $this->raiseEvent('OnClick',$this,$param); |
|
226 | + $this->raiseEvent('OnClick', $this, $param); |
|
227 | 227 | } |
228 | 228 | |
229 | 229 | /** |
@@ -235,8 +235,8 @@ discard block |
||
235 | 235 | */ |
236 | 236 | public function onCommand($param) |
237 | 237 | { |
238 | - $this->raiseEvent('OnCommand',$this,$param); |
|
239 | - $this->raiseBubbleEvent($this,$param); |
|
238 | + $this->raiseEvent('OnCommand', $this, $param); |
|
239 | + $this->raiseBubbleEvent($this, $param); |
|
240 | 240 | } |
241 | 241 | |
242 | 242 | /** |
@@ -252,8 +252,8 @@ discard block |
||
252 | 252 | { |
253 | 253 | if($this->getCausesValidation()) |
254 | 254 | $this->getPage()->validate($this->getValidationGroup()); |
255 | - $this->onClick(new TImageClickEventParameter($this->_x,$this->_y)); |
|
256 | - $this->onCommand(new TCommandEventParameter($this->getCommandName(),$this->getCommandParameter())); |
|
255 | + $this->onClick(new TImageClickEventParameter($this->_x, $this->_y)); |
|
256 | + $this->onCommand(new TCommandEventParameter($this->getCommandName(), $this->getCommandParameter())); |
|
257 | 257 | } |
258 | 258 | |
259 | 259 | /** |
@@ -271,7 +271,7 @@ discard block |
||
271 | 271 | */ |
272 | 272 | public function getCausesValidation() |
273 | 273 | { |
274 | - return $this->getViewState('CausesValidation',true); |
|
274 | + return $this->getViewState('CausesValidation', true); |
|
275 | 275 | } |
276 | 276 | |
277 | 277 | /** |
@@ -279,7 +279,7 @@ discard block |
||
279 | 279 | */ |
280 | 280 | public function setCausesValidation($value) |
281 | 281 | { |
282 | - $this->setViewState('CausesValidation',TPropertyValue::ensureBoolean($value),true); |
|
282 | + $this->setViewState('CausesValidation', TPropertyValue::ensureBoolean($value), true); |
|
283 | 283 | } |
284 | 284 | |
285 | 285 | /** |
@@ -287,7 +287,7 @@ discard block |
||
287 | 287 | */ |
288 | 288 | public function getCommandName() |
289 | 289 | { |
290 | - return $this->getViewState('CommandName',''); |
|
290 | + return $this->getViewState('CommandName', ''); |
|
291 | 291 | } |
292 | 292 | |
293 | 293 | /** |
@@ -295,7 +295,7 @@ discard block |
||
295 | 295 | */ |
296 | 296 | public function setCommandName($value) |
297 | 297 | { |
298 | - $this->setViewState('CommandName',$value,''); |
|
298 | + $this->setViewState('CommandName', $value, ''); |
|
299 | 299 | } |
300 | 300 | |
301 | 301 | /** |
@@ -303,7 +303,7 @@ discard block |
||
303 | 303 | */ |
304 | 304 | public function getCommandParameter() |
305 | 305 | { |
306 | - return $this->getViewState('CommandParameter',''); |
|
306 | + return $this->getViewState('CommandParameter', ''); |
|
307 | 307 | } |
308 | 308 | |
309 | 309 | /** |
@@ -311,7 +311,7 @@ discard block |
||
311 | 311 | */ |
312 | 312 | public function setCommandParameter($value) |
313 | 313 | { |
314 | - $this->setViewState('CommandParameter',$value,''); |
|
314 | + $this->setViewState('CommandParameter', $value, ''); |
|
315 | 315 | } |
316 | 316 | |
317 | 317 | /** |
@@ -319,7 +319,7 @@ discard block |
||
319 | 319 | */ |
320 | 320 | public function getValidationGroup() |
321 | 321 | { |
322 | - return $this->getViewState('ValidationGroup',''); |
|
322 | + return $this->getViewState('ValidationGroup', ''); |
|
323 | 323 | } |
324 | 324 | |
325 | 325 | /** |
@@ -327,7 +327,7 @@ discard block |
||
327 | 327 | */ |
328 | 328 | public function setValidationGroup($value) |
329 | 329 | { |
330 | - $this->setViewState('ValidationGroup',$value,''); |
|
330 | + $this->setViewState('ValidationGroup', $value, ''); |
|
331 | 331 | } |
332 | 332 | |
333 | 333 | /** |
@@ -397,7 +397,7 @@ discard block |
||
397 | 397 | * @param integer X coordinate of the clicking point |
398 | 398 | * @param integer Y coordinate of the clicking point |
399 | 399 | */ |
400 | - public function __construct($x,$y) |
|
400 | + public function __construct($x, $y) |
|
401 | 401 | { |
402 | 402 | $this->_x=$x; |
403 | 403 | $this->_y=$y; |
@@ -92,6 +92,7 @@ discard block |
||
92 | 92 | |
93 | 93 | /** |
94 | 94 | * @param boolean whether the item is enabled |
95 | + * @param boolean $value |
|
95 | 96 | */ |
96 | 97 | public function setEnabled($value) |
97 | 98 | { |
@@ -108,6 +109,7 @@ discard block |
||
108 | 109 | |
109 | 110 | /** |
110 | 111 | * @param boolean whether the item is selected |
112 | + * @param boolean $value |
|
111 | 113 | */ |
112 | 114 | public function setSelected($value) |
113 | 115 | { |
@@ -184,6 +186,7 @@ discard block |
||
184 | 186 | /** |
185 | 187 | * @param string attribute name |
186 | 188 | * @param string value of the attribute |
189 | + * @param string $name |
|
187 | 190 | */ |
188 | 191 | public function setAttribute($name,$value) |
189 | 192 | { |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | * @param boolean whether the item is enabled |
54 | 54 | * @param boolean whether the item is selected |
55 | 55 | */ |
56 | - public function __construct($text='',$value='',$enabled=true,$selected=false) |
|
56 | + public function __construct($text='', $value='', $enabled=true, $selected=false) |
|
57 | 57 | { |
58 | 58 | $this->setText($text); |
59 | 59 | $this->setValue($value); |
@@ -70,16 +70,16 @@ discard block |
||
70 | 70 | protected function __getZappableSleepProps(&$exprops) |
71 | 71 | { |
72 | 72 | parent::__getZappableSleepProps($exprops); |
73 | - if ($this->_attributes===null) |
|
74 | - $exprops[] = "\0TListItem\0_attributes"; |
|
73 | + if($this->_attributes===null) |
|
74 | + $exprops[]="\0TListItem\0_attributes"; |
|
75 | 75 | if($this->_text==='') |
76 | - $exprops[] = "\0TListItem\0_text"; |
|
76 | + $exprops[]="\0TListItem\0_text"; |
|
77 | 77 | if($this->_value==='') |
78 | - $exprops[] = "\0TListItem\0_value"; |
|
79 | - if ($this->_enabled===true) |
|
80 | - $exprops[] = "\0TListItem\0_enabled"; |
|
81 | - if ($this->_selected===false) |
|
82 | - $exprops[] = "\0TListItem\0_selected"; |
|
78 | + $exprops[]="\0TListItem\0_value"; |
|
79 | + if($this->_enabled===true) |
|
80 | + $exprops[]="\0TListItem\0_enabled"; |
|
81 | + if($this->_selected===false) |
|
82 | + $exprops[]="\0TListItem\0_selected"; |
|
83 | 83 | } |
84 | 84 | |
85 | 85 | /** |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | */ |
120 | 120 | public function getText() |
121 | 121 | { |
122 | - return $this->_text===''?$this->_value:$this->_text; |
|
122 | + return $this->_text==='' ? $this->_value : $this->_text; |
|
123 | 123 | } |
124 | 124 | |
125 | 125 | /** |
@@ -135,7 +135,7 @@ discard block |
||
135 | 135 | */ |
136 | 136 | public function getValue() |
137 | 137 | { |
138 | - return $this->_value===''?$this->_text:$this->_value; |
|
138 | + return $this->_value==='' ? $this->_text : $this->_value; |
|
139 | 139 | } |
140 | 140 | |
141 | 141 | /** |
@@ -161,7 +161,7 @@ discard block |
||
161 | 161 | */ |
162 | 162 | public function getHasAttributes() |
163 | 163 | { |
164 | - return $this->_attributes && $this->_attributes->getCount()>0; |
|
164 | + return $this->_attributes && $this->_attributes->getCount() > 0; |
|
165 | 165 | } |
166 | 166 | |
167 | 167 | /** |
@@ -170,7 +170,7 @@ discard block |
||
170 | 170 | */ |
171 | 171 | public function hasAttribute($name) |
172 | 172 | { |
173 | - return $this->_attributes?$this->_attributes->contains($name):false; |
|
173 | + return $this->_attributes ? $this->_attributes->contains($name) : false; |
|
174 | 174 | } |
175 | 175 | |
176 | 176 | /** |
@@ -178,16 +178,16 @@ discard block |
||
178 | 178 | */ |
179 | 179 | public function getAttribute($name) |
180 | 180 | { |
181 | - return $this->_attributes?$this->_attributes->itemAt($name):null; |
|
181 | + return $this->_attributes ? $this->_attributes->itemAt($name) : null; |
|
182 | 182 | } |
183 | 183 | |
184 | 184 | /** |
185 | 185 | * @param string attribute name |
186 | 186 | * @param string value of the attribute |
187 | 187 | */ |
188 | - public function setAttribute($name,$value) |
|
188 | + public function setAttribute($name, $value) |
|
189 | 189 | { |
190 | - $this->getAttributes()->add($name,$value); |
|
190 | + $this->getAttributes()->add($name, $value); |
|
191 | 191 | } |
192 | 192 | |
193 | 193 | /** |
@@ -197,7 +197,7 @@ discard block |
||
197 | 197 | */ |
198 | 198 | public function removeAttribute($name) |
199 | 199 | { |
200 | - return $this->_attributes?$this->_attributes->remove($name):null; |
|
200 | + return $this->_attributes ? $this->_attributes->remove($name) : null; |
|
201 | 201 | } |
202 | 202 | } |
203 | 203 |
@@ -58,8 +58,7 @@ |
||
58 | 58 | if ($this->sourcepath === NULL) |
59 | 59 | { |
60 | 60 | $this->sourcepath = $sourcepath; |
61 | - } |
|
62 | - else |
|
61 | + } else |
|
63 | 62 | { |
64 | 63 | $this->sourcepath->append($sourcepath); |
65 | 64 | } |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | case 'datetime': case 'timestamp': |
34 | 34 | return $this->createDateTimeControl($container, $column, $record); |
35 | 35 | default: |
36 | - return $this->createDefaultControl($container,$column, $record); |
|
36 | + return $this->createDefaultControl($container, $column, $record); |
|
37 | 37 | } |
38 | 38 | } |
39 | 39 | |
@@ -50,16 +50,16 @@ discard block |
||
50 | 50 | case 'time': |
51 | 51 | return $this->getTimeValue($container, $column, $record); |
52 | 52 | case 'datetime': case 'timestamp': |
53 | - return $this->getDateTimeValue($container,$column, $record); |
|
53 | + return $this->getDateTimeValue($container, $column, $record); |
|
54 | 54 | default: |
55 | - return $this->getDefaultControlValue($container,$column, $record); |
|
55 | + return $this->getDefaultControlValue($container, $column, $record); |
|
56 | 56 | } |
57 | 57 | } |
58 | 58 | |
59 | 59 | protected function createDateControl($container, $column, $record) |
60 | 60 | { |
61 | - $control = parent::createDateControl($container, $column, $record); |
|
62 | - $value = $this->getRecordPropertyValue($column, $record); |
|
61 | + $control=parent::createDateControl($container, $column, $record); |
|
62 | + $value=$this->getRecordPropertyValue($column, $record); |
|
63 | 63 | if(!empty($value) && preg_match('/timestamp/i', $column->getDbType())) |
64 | 64 | $control->setTimestamp(intval($value)); |
65 | 65 | return $control; |
@@ -67,12 +67,12 @@ discard block |
||
67 | 67 | |
68 | 68 | protected function createDateTimeControl($container, $column, $record) |
69 | 69 | { |
70 | - $value = $this->getRecordPropertyValue($column, $record); |
|
71 | - $time = parent::createDateTimeControl($container, $column, $record); |
|
70 | + $value=$this->getRecordPropertyValue($column, $record); |
|
71 | + $time=parent::createDateTimeControl($container, $column, $record); |
|
72 | 72 | if(!empty($value) && preg_match('/timestamp/i', $column->getDbType())) |
73 | 73 | { |
74 | - $s = Prado::createComponent('System.Util.TDateTimeStamp'); |
|
75 | - $date = $s->getDate(intval($value)); |
|
74 | + $s=Prado::createComponent('System.Util.TDateTimeStamp'); |
|
75 | + $date=$s->getDate(intval($value)); |
|
76 | 76 | $time[1]->setSelectedValue($date['hours']); |
77 | 77 | $time[2]->setSelectedValue($date['minutes']); |
78 | 78 | $time[3]->setSelectedValue($date['seconds']); |
@@ -84,13 +84,13 @@ discard block |
||
84 | 84 | { |
85 | 85 | if(preg_match('/timestamp/i', $column->getDbType())) |
86 | 86 | { |
87 | - $time = $container->findControl(self::DEFAULT_ID)->getTimestamp(); |
|
88 | - $s = Prado::createComponent('System.Util.TDateTimeStamp'); |
|
89 | - $date = $s->getDate($time); |
|
90 | - $hour = $container->findControl('scaffold_time_hour')->getSelectedValue(); |
|
91 | - $mins = $container->findControl('scaffold_time_min')->getSelectedValue(); |
|
92 | - $secs = $container->findControl('scaffold_time_sec')->getSelectedValue(); |
|
93 | - return $s->getTimeStamp($hour,$mins,$secs,$date['mon'],$date['mday'],$date['year']); |
|
87 | + $time=$container->findControl(self::DEFAULT_ID)->getTimestamp(); |
|
88 | + $s=Prado::createComponent('System.Util.TDateTimeStamp'); |
|
89 | + $date=$s->getDate($time); |
|
90 | + $hour=$container->findControl('scaffold_time_hour')->getSelectedValue(); |
|
91 | + $mins=$container->findControl('scaffold_time_min')->getSelectedValue(); |
|
92 | + $secs=$container->findControl('scaffold_time_sec')->getSelectedValue(); |
|
93 | + return $s->getTimeStamp($hour, $mins, $secs, $date['mon'], $date['mday'], $date['year']); |
|
94 | 94 | } |
95 | 95 | else |
96 | 96 | return parent::getDateTimeValue($container, $column, $record); |
@@ -61,8 +61,7 @@ discard block |
||
61 | 61 | $object = $object[$prop]; |
62 | 62 | else |
63 | 63 | throw new TInvalidPropertyException('sqlmap_invalid_property',$path); |
64 | - } |
|
65 | - else if(is_object($object)) |
|
64 | + } else if(is_object($object)) |
|
66 | 65 | { |
67 | 66 | $getter = 'get'.$prop; |
68 | 67 | if(method_exists($object, $getter) && is_callable(array($object, $getter))) |
@@ -73,8 +72,7 @@ discard block |
||
73 | 72 | $object = $object->{$prop}; |
74 | 73 | else |
75 | 74 | throw new TInvalidPropertyException('sqlmap_invalid_property',$path); |
76 | - } |
|
77 | - else |
|
75 | + } else |
|
78 | 76 | throw new TInvalidPropertyException('sqlmap_invalid_property',$path); |
79 | 77 | } |
80 | 78 | return $object; |
@@ -98,8 +96,7 @@ discard block |
||
98 | 96 | $object = $object[$prop]; |
99 | 97 | else |
100 | 98 | return false; |
101 | - } |
|
102 | - else if(is_object($object)) |
|
99 | + } else if(is_object($object)) |
|
103 | 100 | { |
104 | 101 | $getter = 'get'.$prop; |
105 | 102 | if(method_exists($object, $getter) && is_callable(array($object, $getter))) |
@@ -110,8 +107,7 @@ discard block |
||
110 | 107 | $object = $object->{$prop}; |
111 | 108 | else |
112 | 109 | return false; |
113 | - } |
|
114 | - else |
|
110 | + } else |
|
115 | 111 | return false; |
116 | 112 | } |
117 | 113 | return true; |
@@ -136,16 +132,14 @@ discard block |
||
136 | 132 | if(is_array($object) || $object instanceof ArrayAccess) |
137 | 133 | { |
138 | 134 | $object[$prop] = $value; |
139 | - } |
|
140 | - else if(is_object($object)) |
|
135 | + } else if(is_object($object)) |
|
141 | 136 | { |
142 | 137 | $setter = 'set'.$prop; |
143 | 138 | if (method_exists($object, $setter) && is_callable(array($object, $setter))) |
144 | 139 | $object->{$setter}($value); |
145 | 140 | else |
146 | 141 | $object->{$prop} = $value; |
147 | - } |
|
148 | - else |
|
142 | + } else |
|
149 | 143 | throw new TInvalidPropertyException('sqlmap_invalid_property_type',$path); |
150 | 144 | } |
151 | 145 |
@@ -48,34 +48,34 @@ discard block |
||
48 | 48 | * @return mixed property value. |
49 | 49 | * @throws TInvalidDataValueException if property path is invalid. |
50 | 50 | */ |
51 | - public static function get($object,$path) |
|
51 | + public static function get($object, $path) |
|
52 | 52 | { |
53 | 53 | if(!is_array($object) && !is_object($object)) |
54 | 54 | return $object; |
55 | - $properties = explode('.', $path); |
|
55 | + $properties=explode('.', $path); |
|
56 | 56 | foreach($properties as $prop) |
57 | 57 | { |
58 | 58 | if(is_array($object) || $object instanceof ArrayAccess) |
59 | 59 | { |
60 | 60 | if(array_key_exists($prop, $object)) |
61 | - $object = $object[$prop]; |
|
61 | + $object=$object[$prop]; |
|
62 | 62 | else |
63 | - throw new TInvalidPropertyException('sqlmap_invalid_property',$path); |
|
63 | + throw new TInvalidPropertyException('sqlmap_invalid_property', $path); |
|
64 | 64 | } |
65 | 65 | else if(is_object($object)) |
66 | 66 | { |
67 | - $getter = 'get'.$prop; |
|
67 | + $getter='get'.$prop; |
|
68 | 68 | if(method_exists($object, $getter) && is_callable(array($object, $getter))) |
69 | - $object = $object->{$getter}(); |
|
69 | + $object=$object->{$getter}(); |
|
70 | 70 | else if(in_array($prop, array_keys(get_object_vars($object)))) |
71 | - $object = $object->{$prop}; |
|
71 | + $object=$object->{$prop}; |
|
72 | 72 | elseif(method_exists($object, '__get') && is_callable(array($object, '__get'))) |
73 | - $object = $object->{$prop}; |
|
73 | + $object=$object->{$prop}; |
|
74 | 74 | else |
75 | - throw new TInvalidPropertyException('sqlmap_invalid_property',$path); |
|
75 | + throw new TInvalidPropertyException('sqlmap_invalid_property', $path); |
|
76 | 76 | } |
77 | 77 | else |
78 | - throw new TInvalidPropertyException('sqlmap_invalid_property',$path); |
|
78 | + throw new TInvalidPropertyException('sqlmap_invalid_property', $path); |
|
79 | 79 | } |
80 | 80 | return $object; |
81 | 81 | } |
@@ -89,25 +89,25 @@ discard block |
||
89 | 89 | { |
90 | 90 | if(!is_array($object) && !is_object($object)) |
91 | 91 | return false; |
92 | - $properties = explode('.', $path); |
|
92 | + $properties=explode('.', $path); |
|
93 | 93 | foreach($properties as $prop) |
94 | 94 | { |
95 | 95 | if(is_array($object) || $object instanceof ArrayAccess) |
96 | 96 | { |
97 | 97 | if(array_key_exists($prop, $object)) |
98 | - $object = $object[$prop]; |
|
98 | + $object=$object[$prop]; |
|
99 | 99 | else |
100 | 100 | return false; |
101 | 101 | } |
102 | 102 | else if(is_object($object)) |
103 | 103 | { |
104 | - $getter = 'get'.$prop; |
|
104 | + $getter='get'.$prop; |
|
105 | 105 | if(method_exists($object, $getter) && is_callable(array($object, $getter))) |
106 | - $object = $object->{$getter}(); |
|
106 | + $object=$object->{$getter}(); |
|
107 | 107 | else if(in_array($prop, array_keys(get_object_vars($object)))) |
108 | - $object = $object->{$prop}; |
|
108 | + $object=$object->{$prop}; |
|
109 | 109 | elseif(method_exists($object, '__get') && is_callable(array($object, '__get'))) |
110 | - $object = $object->{$prop}; |
|
110 | + $object=$object->{$prop}; |
|
111 | 111 | else |
112 | 112 | return false; |
113 | 113 | } |
@@ -126,27 +126,27 @@ discard block |
||
126 | 126 | */ |
127 | 127 | public static function set(&$originalObject, $path, $value) |
128 | 128 | { |
129 | - $properties = explode('.', $path); |
|
130 | - $prop = array_pop($properties); |
|
129 | + $properties=explode('.', $path); |
|
130 | + $prop=array_pop($properties); |
|
131 | 131 | if(count($properties) > 0) |
132 | - $object = self::get($originalObject, implode('.',$properties)); |
|
132 | + $object=self::get($originalObject, implode('.', $properties)); |
|
133 | 133 | else |
134 | - $object = &$originalObject; |
|
134 | + $object=&$originalObject; |
|
135 | 135 | |
136 | 136 | if(is_array($object) || $object instanceof ArrayAccess) |
137 | 137 | { |
138 | - $object[$prop] = $value; |
|
138 | + $object[$prop]=$value; |
|
139 | 139 | } |
140 | 140 | else if(is_object($object)) |
141 | 141 | { |
142 | - $setter = 'set'.$prop; |
|
143 | - if (method_exists($object, $setter) && is_callable(array($object, $setter))) |
|
142 | + $setter='set'.$prop; |
|
143 | + if(method_exists($object, $setter) && is_callable(array($object, $setter))) |
|
144 | 144 | $object->{$setter}($value); |
145 | 145 | else |
146 | - $object->{$prop} = $value; |
|
146 | + $object->{$prop}=$value; |
|
147 | 147 | } |
148 | 148 | else |
149 | - throw new TInvalidPropertyException('sqlmap_invalid_property_type',$path); |
|
149 | + throw new TInvalidPropertyException('sqlmap_invalid_property_type', $path); |
|
150 | 150 | } |
151 | 151 | |
152 | 152 | } |
@@ -164,8 +164,7 @@ |
||
164 | 164 | return $handler->createNewInstance(); |
165 | 165 | else |
166 | 166 | return $registry->createInstanceOf($this->getClass()); |
167 | - } |
|
168 | - catch (TSqlMapException $e) |
|
167 | + } catch (TSqlMapException $e) |
|
169 | 168 | { |
170 | 169 | throw new TSqlMapException( |
171 | 170 | 'sqlmap_unable_to_create_new_instance', |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | */ |
82 | 82 | public function setClass($value) |
83 | 83 | { |
84 | - $this->_class = $value; |
|
84 | + $this->_class=$value; |
|
85 | 85 | } |
86 | 86 | |
87 | 87 | /** |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | */ |
106 | 106 | public function setExtends($value) |
107 | 107 | { |
108 | - $this->_extends = $value; |
|
108 | + $this->_extends=$value; |
|
109 | 109 | } |
110 | 110 | |
111 | 111 | /** |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | */ |
122 | 122 | public function setGroupBy($value) |
123 | 123 | { |
124 | - $this->_groupBy = $value; |
|
124 | + $this->_groupBy=$value; |
|
125 | 125 | } |
126 | 126 | |
127 | 127 | /** |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | */ |
138 | 138 | public function setDiscriminator(TDiscriminator $value) |
139 | 139 | { |
140 | - $this->_discriminator = $value; |
|
140 | + $this->_discriminator=$value; |
|
141 | 141 | } |
142 | 142 | |
143 | 143 | /** |
@@ -146,7 +146,7 @@ discard block |
||
146 | 146 | */ |
147 | 147 | public function addResultProperty(TResultProperty $property) |
148 | 148 | { |
149 | - $this->_columns[$property->getProperty()] = $property; |
|
149 | + $this->_columns[$property->getProperty()]=$property; |
|
150 | 150 | } |
151 | 151 | |
152 | 152 | /** |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | */ |
158 | 158 | public function createInstanceOfResult($registry) |
159 | 159 | { |
160 | - $handler = $registry->getTypeHandler($this->getClass()); |
|
160 | + $handler=$registry->getTypeHandler($this->getClass()); |
|
161 | 161 | try |
162 | 162 | { |
163 | 163 | if($handler!==null) |
@@ -165,7 +165,7 @@ discard block |
||
165 | 165 | else |
166 | 166 | return $registry->createInstanceOf($this->getClass()); |
167 | 167 | } |
168 | - catch (TSqlMapException $e) |
|
168 | + catch(TSqlMapException $e) |
|
169 | 169 | { |
170 | 170 | throw new TSqlMapException( |
171 | 171 | 'sqlmap_unable_to_create_new_instance', |
@@ -179,18 +179,18 @@ discard block |
||
179 | 179 | * @param array row data. |
180 | 180 | * @return TResultMap result sub-map. |
181 | 181 | */ |
182 | - public function resolveSubMap($registry,$row) |
|
182 | + public function resolveSubMap($registry, $row) |
|
183 | 183 | { |
184 | - $subMap = $this; |
|
185 | - if(($disc = $this->getDiscriminator())!==null) |
|
184 | + $subMap=$this; |
|
185 | + if(($disc=$this->getDiscriminator())!==null) |
|
186 | 186 | { |
187 | - $value = $disc->getMapping()->getPropertyValue($registry,$row); |
|
188 | - $subMap = $disc->getSubMap((string)$value); |
|
187 | + $value=$disc->getMapping()->getPropertyValue($registry, $row); |
|
188 | + $subMap=$disc->getSubMap((string) $value); |
|
189 | 189 | |
190 | 190 | if($subMap===null) |
191 | - $subMap = $this; |
|
192 | - else if($subMap !== $this) |
|
193 | - $subMap = $subMap->resolveSubMap($registry,$row); |
|
191 | + $subMap=$this; |
|
192 | + else if($subMap!==$this) |
|
193 | + $subMap=$subMap->resolveSubMap($registry, $row); |
|
194 | 194 | } |
195 | 195 | return $subMap; |
196 | 196 | } |
@@ -58,8 +58,7 @@ |
||
58 | 58 | if ($this->sourcepath === NULL) |
59 | 59 | { |
60 | 60 | $this->sourcepath = $sourcepath; |
61 | - } |
|
62 | - else |
|
61 | + } else |
|
63 | 62 | { |
64 | 63 | $this->sourcepath->append($sourcepath); |
65 | 64 | } |
@@ -30,12 +30,12 @@ |
||
30 | 30 | */ |
31 | 31 | public function applyLimitOffset($sql, $limit=-1, $offset=-1) |
32 | 32 | { |
33 | - $limit = $limit!==null ? intval($limit) : -1; |
|
34 | - $offset = $offset!==null ? intval($offset) : -1; |
|
33 | + $limit=$limit!==null ? intval($limit) : -1; |
|
34 | + $offset=$offset!==null ? intval($offset) : -1; |
|
35 | 35 | if($limit > 0 || $offset > 0) |
36 | 36 | { |
37 | - $limitStr = ' LIMIT '.$limit; |
|
38 | - $offsetStr = $offset >= 0 ? ' OFFSET '.$offset : ''; |
|
37 | + $limitStr=' LIMIT '.$limit; |
|
38 | + $offsetStr=$offset >= 0 ? ' OFFSET '.$offset : ''; |
|
39 | 39 | return $sql.$limitStr.$offsetStr; |
40 | 40 | } |
41 | 41 | else |