@@ -31,6 +31,7 @@ |
||
31 | 31 | /** |
32 | 32 | * Constructor. Attach a response to be adapted. |
33 | 33 | * @param THttpResponse the response object the adapter is to attach to. |
34 | + * @param THttpResponse $response |
|
34 | 35 | */ |
35 | 36 | public function __construct($response) |
36 | 37 | { |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | */ |
35 | 35 | public function __construct($response) |
36 | 36 | { |
37 | - $this->_response=$response; |
|
37 | + $this->_response = $response; |
|
38 | 38 | } |
39 | 39 | |
40 | 40 | /** |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | */ |
72 | 72 | public function createNewHtmlWriter($type, $writer) |
73 | 73 | { |
74 | - return $this->_response->createNewHtmlWriter($type,$writer); |
|
74 | + return $this->_response->createNewHtmlWriter($type, $writer); |
|
75 | 75 | } |
76 | 76 | } |
77 | 77 |
@@ -265,6 +265,7 @@ discard block |
||
265 | 265 | * If true, make sure the methods {@link _open}, {@link _close}, {@link _read}, |
266 | 266 | * {@link _write}, {@link _destroy}, and {@link _gc} are overridden in child |
267 | 267 | * class, because they will be used as the callback handlers. |
268 | + * @param boolean $value |
|
268 | 269 | */ |
269 | 270 | public function setUseCustomStorage($value) |
270 | 271 | { |
@@ -527,6 +528,7 @@ discard block |
||
527 | 528 | * Returns the session variable value with the session variable name. |
528 | 529 | * This method is exactly the same as {@link offsetGet}. |
529 | 530 | * @param mixed the session variable name |
531 | + * @param string $key |
|
530 | 532 | * @return mixed the session variable value, null if no such variable exists |
531 | 533 | */ |
532 | 534 | public function itemAt($key) |
@@ -539,6 +541,7 @@ discard block |
||
539 | 541 | * Note, if the specified name already exists, the old value will be removed first. |
540 | 542 | * @param mixed session variable name |
541 | 543 | * @param mixed session variable value |
544 | + * @param string $key |
|
542 | 545 | */ |
543 | 546 | public function add($key,$value) |
544 | 547 | { |
@@ -306,10 +306,10 @@ |
||
306 | 306 | { |
307 | 307 | $value=TPropertyValue::ensureEnum($value,'THttpSessionCookieMode'); |
308 | 308 | if($value===THttpSessionCookieMode::None) |
309 | - { |
|
309 | + { |
|
310 | 310 | ini_set('session.use_cookies','0'); |
311 | 311 | ini_set('session.use_only_cookies','0'); |
312 | - } |
|
312 | + } |
|
313 | 313 | else if($value===THttpSessionCookieMode::Allow) |
314 | 314 | { |
315 | 315 | ini_set('session.use_cookies','1'); |
@@ -67,24 +67,24 @@ discard block |
||
67 | 67 | * @package System.Web |
68 | 68 | * @since 3.0 |
69 | 69 | */ |
70 | -class THttpSession extends TApplicationComponent implements IteratorAggregate,ArrayAccess,Countable,IModule |
|
70 | +class THttpSession extends TApplicationComponent implements IteratorAggregate, ArrayAccess, Countable, IModule |
|
71 | 71 | { |
72 | 72 | /** |
73 | 73 | * @var boolean whether this module has been initialized |
74 | 74 | */ |
75 | - private $_initialized=false; |
|
75 | + private $_initialized = false; |
|
76 | 76 | /** |
77 | 77 | * @var boolean whether the session has started |
78 | 78 | */ |
79 | - private $_started=false; |
|
79 | + private $_started = false; |
|
80 | 80 | /** |
81 | 81 | * @var boolean whether the session should be started when the module is initialized |
82 | 82 | */ |
83 | - private $_autoStart=false; |
|
83 | + private $_autoStart = false; |
|
84 | 84 | /** |
85 | 85 | * @var THttpCookie cookie to be used to store session ID and other data |
86 | 86 | */ |
87 | - private $_cookie=null; |
|
87 | + private $_cookie = null; |
|
88 | 88 | /** |
89 | 89 | * @var string module id |
90 | 90 | */ |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | /** |
93 | 93 | * @var boolean |
94 | 94 | */ |
95 | - private $_customStorage=false; |
|
95 | + private $_customStorage = false; |
|
96 | 96 | |
97 | 97 | /** |
98 | 98 | * @return string id of this module |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | */ |
108 | 108 | public function setID($value) |
109 | 109 | { |
110 | - $this->_id=$value; |
|
110 | + $this->_id = $value; |
|
111 | 111 | } |
112 | 112 | |
113 | 113 | /** |
@@ -118,9 +118,9 @@ discard block |
||
118 | 118 | */ |
119 | 119 | public function init($config) |
120 | 120 | { |
121 | - if($this->_autoStart) |
|
121 | + if ($this->_autoStart) |
|
122 | 122 | $this->open(); |
123 | - $this->_initialized=true; |
|
123 | + $this->_initialized = true; |
|
124 | 124 | $this->getApplication()->setSession($this); |
125 | 125 | register_shutdown_function(array($this, "close")); |
126 | 126 | } |
@@ -130,15 +130,15 @@ discard block |
||
130 | 130 | */ |
131 | 131 | public function open() |
132 | 132 | { |
133 | - if(!$this->_started) |
|
133 | + if (!$this->_started) |
|
134 | 134 | { |
135 | - if($this->_customStorage) |
|
136 | - session_set_save_handler(array($this,'_open'),array($this,'_close'),array($this,'_read'),array($this,'_write'),array($this,'_destroy'),array($this,'_gc')); |
|
137 | - if($this->_cookie!==null) |
|
138 | - session_set_cookie_params($this->_cookie->getExpire(),$this->_cookie->getPath(),$this->_cookie->getDomain(),$this->_cookie->getSecure(),$this->_cookie->getHttpOnly()); |
|
139 | - if(ini_get('session.auto_start')!=='1') |
|
135 | + if ($this->_customStorage) |
|
136 | + session_set_save_handler(array($this, '_open'), array($this, '_close'), array($this, '_read'), array($this, '_write'), array($this, '_destroy'), array($this, '_gc')); |
|
137 | + if ($this->_cookie !== null) |
|
138 | + session_set_cookie_params($this->_cookie->getExpire(), $this->_cookie->getPath(), $this->_cookie->getDomain(), $this->_cookie->getSecure(), $this->_cookie->getHttpOnly()); |
|
139 | + if (ini_get('session.auto_start') !== '1') |
|
140 | 140 | session_start(); |
141 | - $this->_started=true; |
|
141 | + $this->_started = true; |
|
142 | 142 | } |
143 | 143 | } |
144 | 144 | |
@@ -147,10 +147,10 @@ discard block |
||
147 | 147 | */ |
148 | 148 | public function close() |
149 | 149 | { |
150 | - if($this->_started) |
|
150 | + if ($this->_started) |
|
151 | 151 | { |
152 | 152 | session_write_close(); |
153 | - $this->_started=false; |
|
153 | + $this->_started = false; |
|
154 | 154 | } |
155 | 155 | } |
156 | 156 | |
@@ -159,10 +159,10 @@ discard block |
||
159 | 159 | */ |
160 | 160 | public function destroy() |
161 | 161 | { |
162 | - if($this->_started) |
|
162 | + if ($this->_started) |
|
163 | 163 | { |
164 | 164 | session_destroy(); |
165 | - $this->_started=false; |
|
165 | + $this->_started = false; |
|
166 | 166 | } |
167 | 167 | } |
168 | 168 | |
@@ -173,7 +173,7 @@ discard block |
||
173 | 173 | * @return string old session id |
174 | 174 | * @link http://php.net/manual/en/function.session-regenerate-id.php |
175 | 175 | */ |
176 | - public function regenerate($deleteOld=false) |
|
176 | + public function regenerate($deleteOld = false) |
|
177 | 177 | { |
178 | 178 | $old = $this->getSessionID(); |
179 | 179 | session_regenerate_id($deleteOld); |
@@ -202,7 +202,7 @@ discard block |
||
202 | 202 | */ |
203 | 203 | public function setSessionID($value) |
204 | 204 | { |
205 | - if($this->_started) |
|
205 | + if ($this->_started) |
|
206 | 206 | throw new TInvalidOperationException('httpsession_sessionid_unchangeable'); |
207 | 207 | else |
208 | 208 | session_id($value); |
@@ -222,12 +222,12 @@ discard block |
||
222 | 222 | */ |
223 | 223 | public function setSessionName($value) |
224 | 224 | { |
225 | - if($this->_started) |
|
225 | + if ($this->_started) |
|
226 | 226 | throw new TInvalidOperationException('httpsession_sessionname_unchangeable'); |
227 | - else if(ctype_alnum($value)) |
|
227 | + else if (ctype_alnum($value)) |
|
228 | 228 | session_name($value); |
229 | 229 | else |
230 | - throw new TInvalidDataValueException('httpsession_sessionname_invalid',$value); |
|
230 | + throw new TInvalidDataValueException('httpsession_sessionname_invalid', $value); |
|
231 | 231 | } |
232 | 232 | |
233 | 233 | /** |
@@ -244,12 +244,12 @@ discard block |
||
244 | 244 | */ |
245 | 245 | public function setSavePath($value) |
246 | 246 | { |
247 | - if($this->_started) |
|
247 | + if ($this->_started) |
|
248 | 248 | throw new TInvalidOperationException('httpsession_savepath_unchangeable'); |
249 | - else if(is_dir($value)) |
|
249 | + else if (is_dir($value)) |
|
250 | 250 | session_save_path($value); |
251 | 251 | else |
252 | - throw new TInvalidDataValueException('httpsession_savepath_invalid',$value); |
|
252 | + throw new TInvalidDataValueException('httpsession_savepath_invalid', $value); |
|
253 | 253 | } |
254 | 254 | |
255 | 255 | /** |
@@ -268,7 +268,7 @@ discard block |
||
268 | 268 | */ |
269 | 269 | public function setUseCustomStorage($value) |
270 | 270 | { |
271 | - $this->_customStorage=TPropertyValue::ensureBoolean($value); |
|
271 | + $this->_customStorage = TPropertyValue::ensureBoolean($value); |
|
272 | 272 | } |
273 | 273 | |
274 | 274 | /** |
@@ -276,8 +276,8 @@ discard block |
||
276 | 276 | */ |
277 | 277 | public function getCookie() |
278 | 278 | { |
279 | - if($this->_cookie===null) |
|
280 | - $this->_cookie=new THttpCookie($this->getSessionName(),$this->getSessionID()); |
|
279 | + if ($this->_cookie === null) |
|
280 | + $this->_cookie = new THttpCookie($this->getSessionName(), $this->getSessionID()); |
|
281 | 281 | return $this->_cookie; |
282 | 282 | } |
283 | 283 | |
@@ -286,9 +286,9 @@ discard block |
||
286 | 286 | */ |
287 | 287 | public function getCookieMode() |
288 | 288 | { |
289 | - if(ini_get('session.use_cookies')==='0') |
|
289 | + if (ini_get('session.use_cookies') === '0') |
|
290 | 290 | return THttpSessionCookieMode::None; |
291 | - else if(ini_get('session.use_only_cookies')==='0') |
|
291 | + else if (ini_get('session.use_only_cookies') === '0') |
|
292 | 292 | return THttpSessionCookieMode::Allow; |
293 | 293 | else |
294 | 294 | return THttpSessionCookieMode::Only; |
@@ -300,25 +300,25 @@ discard block |
||
300 | 300 | */ |
301 | 301 | public function setCookieMode($value) |
302 | 302 | { |
303 | - if($this->_started) |
|
303 | + if ($this->_started) |
|
304 | 304 | throw new TInvalidOperationException('httpsession_cookiemode_unchangeable'); |
305 | 305 | else |
306 | 306 | { |
307 | - $value=TPropertyValue::ensureEnum($value,'THttpSessionCookieMode'); |
|
308 | - if($value===THttpSessionCookieMode::None) |
|
307 | + $value = TPropertyValue::ensureEnum($value, 'THttpSessionCookieMode'); |
|
308 | + if ($value === THttpSessionCookieMode::None) |
|
309 | 309 | { |
310 | - ini_set('session.use_cookies','0'); |
|
311 | - ini_set('session.use_only_cookies','0'); |
|
310 | + ini_set('session.use_cookies', '0'); |
|
311 | + ini_set('session.use_only_cookies', '0'); |
|
312 | 312 | } |
313 | - else if($value===THttpSessionCookieMode::Allow) |
|
313 | + else if ($value === THttpSessionCookieMode::Allow) |
|
314 | 314 | { |
315 | - ini_set('session.use_cookies','1'); |
|
316 | - ini_set('session.use_only_cookies','0'); |
|
315 | + ini_set('session.use_cookies', '1'); |
|
316 | + ini_set('session.use_only_cookies', '0'); |
|
317 | 317 | } |
318 | 318 | else |
319 | 319 | { |
320 | - ini_set('session.use_cookies','1'); |
|
321 | - ini_set('session.use_only_cookies','1'); |
|
320 | + ini_set('session.use_cookies', '1'); |
|
321 | + ini_set('session.use_only_cookies', '1'); |
|
322 | 322 | ini_set('session.use_trans_sid', 0); |
323 | 323 | } |
324 | 324 | } |
@@ -338,10 +338,10 @@ discard block |
||
338 | 338 | */ |
339 | 339 | public function setAutoStart($value) |
340 | 340 | { |
341 | - if($this->_initialized) |
|
341 | + if ($this->_initialized) |
|
342 | 342 | throw new TInvalidOperationException('httpsession_autostart_unchangeable'); |
343 | 343 | else |
344 | - $this->_autoStart=TPropertyValue::ensureBoolean($value); |
|
344 | + $this->_autoStart = TPropertyValue::ensureBoolean($value); |
|
345 | 345 | } |
346 | 346 | |
347 | 347 | /** |
@@ -359,18 +359,18 @@ discard block |
||
359 | 359 | */ |
360 | 360 | public function setGCProbability($value) |
361 | 361 | { |
362 | - if($this->_started) |
|
362 | + if ($this->_started) |
|
363 | 363 | throw new TInvalidOperationException('httpsession_gcprobability_unchangeable'); |
364 | 364 | else |
365 | 365 | { |
366 | - $value=TPropertyValue::ensureInteger($value); |
|
367 | - if($value>=0 && $value<=100) |
|
366 | + $value = TPropertyValue::ensureInteger($value); |
|
367 | + if ($value >= 0 && $value <= 100) |
|
368 | 368 | { |
369 | - ini_set('session.gc_probability',$value); |
|
370 | - ini_set('session.gc_divisor','100'); |
|
369 | + ini_set('session.gc_probability', $value); |
|
370 | + ini_set('session.gc_divisor', '100'); |
|
371 | 371 | } |
372 | 372 | else |
373 | - throw new TInvalidDataValueException('httpsession_gcprobability_invalid',$value); |
|
373 | + throw new TInvalidDataValueException('httpsession_gcprobability_invalid', $value); |
|
374 | 374 | } |
375 | 375 | } |
376 | 376 | |
@@ -379,7 +379,7 @@ discard block |
||
379 | 379 | */ |
380 | 380 | public function getUseTransparentSessionID() |
381 | 381 | { |
382 | - return ini_get('session.use_trans_sid')==='1'; |
|
382 | + return ini_get('session.use_trans_sid') === '1'; |
|
383 | 383 | } |
384 | 384 | |
385 | 385 | /** |
@@ -387,14 +387,14 @@ discard block |
||
387 | 387 | */ |
388 | 388 | public function setUseTransparentSessionID($value) |
389 | 389 | { |
390 | - if($this->_started) |
|
390 | + if ($this->_started) |
|
391 | 391 | throw new TInvalidOperationException('httpsession_transid_unchangeable'); |
392 | 392 | else |
393 | 393 | { |
394 | - $value=TPropertyValue::ensureBoolean($value); |
|
395 | - if ($value && $this->getCookieMode()==THttpSessionCookieMode::Only) |
|
394 | + $value = TPropertyValue::ensureBoolean($value); |
|
395 | + if ($value && $this->getCookieMode() == THttpSessionCookieMode::Only) |
|
396 | 396 | throw new TInvalidOperationException('httpsession_transid_cookieonly'); |
397 | - ini_set('session.use_trans_sid',$value?'1':'0'); |
|
397 | + ini_set('session.use_trans_sid', $value ? '1' : '0'); |
|
398 | 398 | } |
399 | 399 | } |
400 | 400 | |
@@ -412,10 +412,10 @@ discard block |
||
412 | 412 | */ |
413 | 413 | public function setTimeout($value) |
414 | 414 | { |
415 | - if($this->_started) |
|
415 | + if ($this->_started) |
|
416 | 416 | throw new TInvalidOperationException('httpsession_maxlifetime_unchangeable'); |
417 | 417 | else |
418 | - ini_set('session.gc_maxlifetime',$value); |
|
418 | + ini_set('session.gc_maxlifetime', $value); |
|
419 | 419 | } |
420 | 420 | |
421 | 421 | /** |
@@ -425,7 +425,7 @@ discard block |
||
425 | 425 | * @param string session name |
426 | 426 | * @return boolean whether session is opened successfully |
427 | 427 | */ |
428 | - public function _open($savePath,$sessionName) |
|
428 | + public function _open($savePath, $sessionName) |
|
429 | 429 | { |
430 | 430 | return true; |
431 | 431 | } |
@@ -458,7 +458,7 @@ discard block |
||
458 | 458 | * @param string session data |
459 | 459 | * @return boolean whether session write is successful |
460 | 460 | */ |
461 | - public function _write($id,$data) |
|
461 | + public function _write($id, $data) |
|
462 | 462 | { |
463 | 463 | return true; |
464 | 464 | } |
@@ -540,9 +540,9 @@ discard block |
||
540 | 540 | * @param mixed session variable name |
541 | 541 | * @param mixed session variable value |
542 | 542 | */ |
543 | - public function add($key,$value) |
|
543 | + public function add($key, $value) |
|
544 | 544 | { |
545 | - $_SESSION[$key]=$value; |
|
545 | + $_SESSION[$key] = $value; |
|
546 | 546 | } |
547 | 547 | |
548 | 548 | /** |
@@ -552,9 +552,9 @@ discard block |
||
552 | 552 | */ |
553 | 553 | public function remove($key) |
554 | 554 | { |
555 | - if(isset($_SESSION[$key])) |
|
555 | + if (isset($_SESSION[$key])) |
|
556 | 556 | { |
557 | - $value=$_SESSION[$key]; |
|
557 | + $value = $_SESSION[$key]; |
|
558 | 558 | unset($_SESSION[$key]); |
559 | 559 | return $value; |
560 | 560 | } |
@@ -567,7 +567,7 @@ discard block |
||
567 | 567 | */ |
568 | 568 | public function clear() |
569 | 569 | { |
570 | - foreach(array_keys($_SESSION) as $key) |
|
570 | + foreach (array_keys($_SESSION) as $key) |
|
571 | 571 | unset($_SESSION[$key]); |
572 | 572 | } |
573 | 573 | |
@@ -613,9 +613,9 @@ discard block |
||
613 | 613 | * @param integer the offset to set element |
614 | 614 | * @param mixed the element value |
615 | 615 | */ |
616 | - public function offsetSet($offset,$item) |
|
616 | + public function offsetSet($offset, $item) |
|
617 | 617 | { |
618 | - $_SESSION[$offset]=$item; |
|
618 | + $_SESSION[$offset] = $item; |
|
619 | 619 | } |
620 | 620 | |
621 | 621 | /** |
@@ -657,7 +657,7 @@ discard block |
||
657 | 657 | */ |
658 | 658 | public function __construct() |
659 | 659 | { |
660 | - $this->_keys=array_keys($_SESSION); |
|
660 | + $this->_keys = array_keys($_SESSION); |
|
661 | 661 | } |
662 | 662 | |
663 | 663 | /** |
@@ -666,7 +666,7 @@ discard block |
||
666 | 666 | */ |
667 | 667 | public function rewind() |
668 | 668 | { |
669 | - $this->_key=reset($this->_keys); |
|
669 | + $this->_key = reset($this->_keys); |
|
670 | 670 | } |
671 | 671 | |
672 | 672 | /** |
@@ -686,7 +686,7 @@ discard block |
||
686 | 686 | */ |
687 | 687 | public function current() |
688 | 688 | { |
689 | - return isset($_SESSION[$this->_key])?$_SESSION[$this->_key]:null; |
|
689 | + return isset($_SESSION[$this->_key]) ? $_SESSION[$this->_key] : null; |
|
690 | 690 | } |
691 | 691 | |
692 | 692 | /** |
@@ -697,9 +697,9 @@ discard block |
||
697 | 697 | { |
698 | 698 | do |
699 | 699 | { |
700 | - $this->_key=next($this->_keys); |
|
700 | + $this->_key = next($this->_keys); |
|
701 | 701 | } |
702 | - while(!isset($_SESSION[$this->_key]) && $this->_key!==false); |
|
702 | + while (!isset($_SESSION[$this->_key]) && $this->_key !== false); |
|
703 | 703 | } |
704 | 704 | |
705 | 705 | /** |
@@ -709,7 +709,7 @@ discard block |
||
709 | 709 | */ |
710 | 710 | public function valid() |
711 | 711 | { |
712 | - return $this->_key!==false; |
|
712 | + return $this->_key !== false; |
|
713 | 713 | } |
714 | 714 | } |
715 | 715 | |
@@ -730,8 +730,8 @@ discard block |
||
730 | 730 | */ |
731 | 731 | class THttpSessionCookieMode extends TEnumerable |
732 | 732 | { |
733 | - const None='None'; |
|
734 | - const Allow='Allow'; |
|
735 | - const Only='Only'; |
|
733 | + const None = 'None'; |
|
734 | + const Allow = 'Allow'; |
|
735 | + const Only = 'Only'; |
|
736 | 736 | } |
737 | 737 |
@@ -118,8 +118,9 @@ discard block |
||
118 | 118 | */ |
119 | 119 | public function init($config) |
120 | 120 | { |
121 | - if($this->_autoStart) |
|
122 | - $this->open(); |
|
121 | + if($this->_autoStart) { |
|
122 | + $this->open(); |
|
123 | + } |
|
123 | 124 | $this->_initialized=true; |
124 | 125 | $this->getApplication()->setSession($this); |
125 | 126 | register_shutdown_function(array($this, "close")); |
@@ -132,12 +133,15 @@ discard block |
||
132 | 133 | { |
133 | 134 | if(!$this->_started) |
134 | 135 | { |
135 | - if($this->_customStorage) |
|
136 | - session_set_save_handler(array($this,'_open'),array($this,'_close'),array($this,'_read'),array($this,'_write'),array($this,'_destroy'),array($this,'_gc')); |
|
137 | - if($this->_cookie!==null) |
|
138 | - session_set_cookie_params($this->_cookie->getExpire(),$this->_cookie->getPath(),$this->_cookie->getDomain(),$this->_cookie->getSecure(),$this->_cookie->getHttpOnly()); |
|
139 | - if(ini_get('session.auto_start')!=='1') |
|
140 | - session_start(); |
|
136 | + if($this->_customStorage) { |
|
137 | + session_set_save_handler(array($this,'_open'),array($this,'_close'),array($this,'_read'),array($this,'_write'),array($this,'_destroy'),array($this,'_gc')); |
|
138 | + } |
|
139 | + if($this->_cookie!==null) { |
|
140 | + session_set_cookie_params($this->_cookie->getExpire(),$this->_cookie->getPath(),$this->_cookie->getDomain(),$this->_cookie->getSecure(),$this->_cookie->getHttpOnly()); |
|
141 | + } |
|
142 | + if(ini_get('session.auto_start')!=='1') { |
|
143 | + session_start(); |
|
144 | + } |
|
141 | 145 | $this->_started=true; |
142 | 146 | } |
143 | 147 | } |
@@ -202,10 +206,11 @@ discard block |
||
202 | 206 | */ |
203 | 207 | public function setSessionID($value) |
204 | 208 | { |
205 | - if($this->_started) |
|
206 | - throw new TInvalidOperationException('httpsession_sessionid_unchangeable'); |
|
207 | - else |
|
208 | - session_id($value); |
|
209 | + if($this->_started) { |
|
210 | + throw new TInvalidOperationException('httpsession_sessionid_unchangeable'); |
|
211 | + } else { |
|
212 | + session_id($value); |
|
213 | + } |
|
209 | 214 | } |
210 | 215 | |
211 | 216 | /** |
@@ -222,12 +227,13 @@ discard block |
||
222 | 227 | */ |
223 | 228 | public function setSessionName($value) |
224 | 229 | { |
225 | - if($this->_started) |
|
226 | - throw new TInvalidOperationException('httpsession_sessionname_unchangeable'); |
|
227 | - else if(ctype_alnum($value)) |
|
228 | - session_name($value); |
|
229 | - else |
|
230 | - throw new TInvalidDataValueException('httpsession_sessionname_invalid',$value); |
|
230 | + if($this->_started) { |
|
231 | + throw new TInvalidOperationException('httpsession_sessionname_unchangeable'); |
|
232 | + } else if(ctype_alnum($value)) { |
|
233 | + session_name($value); |
|
234 | + } else { |
|
235 | + throw new TInvalidDataValueException('httpsession_sessionname_invalid',$value); |
|
236 | + } |
|
231 | 237 | } |
232 | 238 | |
233 | 239 | /** |
@@ -244,12 +250,13 @@ discard block |
||
244 | 250 | */ |
245 | 251 | public function setSavePath($value) |
246 | 252 | { |
247 | - if($this->_started) |
|
248 | - throw new TInvalidOperationException('httpsession_savepath_unchangeable'); |
|
249 | - else if(is_dir($value)) |
|
250 | - session_save_path($value); |
|
251 | - else |
|
252 | - throw new TInvalidDataValueException('httpsession_savepath_invalid',$value); |
|
253 | + if($this->_started) { |
|
254 | + throw new TInvalidOperationException('httpsession_savepath_unchangeable'); |
|
255 | + } else if(is_dir($value)) { |
|
256 | + session_save_path($value); |
|
257 | + } else { |
|
258 | + throw new TInvalidDataValueException('httpsession_savepath_invalid',$value); |
|
259 | + } |
|
253 | 260 | } |
254 | 261 | |
255 | 262 | /** |
@@ -276,8 +283,9 @@ discard block |
||
276 | 283 | */ |
277 | 284 | public function getCookie() |
278 | 285 | { |
279 | - if($this->_cookie===null) |
|
280 | - $this->_cookie=new THttpCookie($this->getSessionName(),$this->getSessionID()); |
|
286 | + if($this->_cookie===null) { |
|
287 | + $this->_cookie=new THttpCookie($this->getSessionName(),$this->getSessionID()); |
|
288 | + } |
|
281 | 289 | return $this->_cookie; |
282 | 290 | } |
283 | 291 | |
@@ -286,12 +294,13 @@ discard block |
||
286 | 294 | */ |
287 | 295 | public function getCookieMode() |
288 | 296 | { |
289 | - if(ini_get('session.use_cookies')==='0') |
|
290 | - return THttpSessionCookieMode::None; |
|
291 | - else if(ini_get('session.use_only_cookies')==='0') |
|
292 | - return THttpSessionCookieMode::Allow; |
|
293 | - else |
|
294 | - return THttpSessionCookieMode::Only; |
|
297 | + if(ini_get('session.use_cookies')==='0') { |
|
298 | + return THttpSessionCookieMode::None; |
|
299 | + } else if(ini_get('session.use_only_cookies')==='0') { |
|
300 | + return THttpSessionCookieMode::Allow; |
|
301 | + } else { |
|
302 | + return THttpSessionCookieMode::Only; |
|
303 | + } |
|
295 | 304 | } |
296 | 305 | |
297 | 306 | /** |
@@ -300,22 +309,20 @@ discard block |
||
300 | 309 | */ |
301 | 310 | public function setCookieMode($value) |
302 | 311 | { |
303 | - if($this->_started) |
|
304 | - throw new TInvalidOperationException('httpsession_cookiemode_unchangeable'); |
|
305 | - else |
|
312 | + if($this->_started) { |
|
313 | + throw new TInvalidOperationException('httpsession_cookiemode_unchangeable'); |
|
314 | + } else |
|
306 | 315 | { |
307 | 316 | $value=TPropertyValue::ensureEnum($value,'THttpSessionCookieMode'); |
308 | 317 | if($value===THttpSessionCookieMode::None) |
309 | 318 | { |
310 | 319 | ini_set('session.use_cookies','0'); |
311 | 320 | ini_set('session.use_only_cookies','0'); |
312 | - } |
|
313 | - else if($value===THttpSessionCookieMode::Allow) |
|
321 | + } else if($value===THttpSessionCookieMode::Allow) |
|
314 | 322 | { |
315 | 323 | ini_set('session.use_cookies','1'); |
316 | 324 | ini_set('session.use_only_cookies','0'); |
317 | - } |
|
318 | - else |
|
325 | + } else |
|
319 | 326 | { |
320 | 327 | ini_set('session.use_cookies','1'); |
321 | 328 | ini_set('session.use_only_cookies','1'); |
@@ -338,10 +345,11 @@ discard block |
||
338 | 345 | */ |
339 | 346 | public function setAutoStart($value) |
340 | 347 | { |
341 | - if($this->_initialized) |
|
342 | - throw new TInvalidOperationException('httpsession_autostart_unchangeable'); |
|
343 | - else |
|
344 | - $this->_autoStart=TPropertyValue::ensureBoolean($value); |
|
348 | + if($this->_initialized) { |
|
349 | + throw new TInvalidOperationException('httpsession_autostart_unchangeable'); |
|
350 | + } else { |
|
351 | + $this->_autoStart=TPropertyValue::ensureBoolean($value); |
|
352 | + } |
|
345 | 353 | } |
346 | 354 | |
347 | 355 | /** |
@@ -359,18 +367,18 @@ discard block |
||
359 | 367 | */ |
360 | 368 | public function setGCProbability($value) |
361 | 369 | { |
362 | - if($this->_started) |
|
363 | - throw new TInvalidOperationException('httpsession_gcprobability_unchangeable'); |
|
364 | - else |
|
370 | + if($this->_started) { |
|
371 | + throw new TInvalidOperationException('httpsession_gcprobability_unchangeable'); |
|
372 | + } else |
|
365 | 373 | { |
366 | 374 | $value=TPropertyValue::ensureInteger($value); |
367 | 375 | if($value>=0 && $value<=100) |
368 | 376 | { |
369 | 377 | ini_set('session.gc_probability',$value); |
370 | 378 | ini_set('session.gc_divisor','100'); |
379 | + } else { |
|
380 | + throw new TInvalidDataValueException('httpsession_gcprobability_invalid',$value); |
|
371 | 381 | } |
372 | - else |
|
373 | - throw new TInvalidDataValueException('httpsession_gcprobability_invalid',$value); |
|
374 | 382 | } |
375 | 383 | } |
376 | 384 | |
@@ -387,13 +395,14 @@ discard block |
||
387 | 395 | */ |
388 | 396 | public function setUseTransparentSessionID($value) |
389 | 397 | { |
390 | - if($this->_started) |
|
391 | - throw new TInvalidOperationException('httpsession_transid_unchangeable'); |
|
392 | - else |
|
398 | + if($this->_started) { |
|
399 | + throw new TInvalidOperationException('httpsession_transid_unchangeable'); |
|
400 | + } else |
|
393 | 401 | { |
394 | 402 | $value=TPropertyValue::ensureBoolean($value); |
395 | - if ($value && $this->getCookieMode()==THttpSessionCookieMode::Only) |
|
396 | - throw new TInvalidOperationException('httpsession_transid_cookieonly'); |
|
403 | + if ($value && $this->getCookieMode()==THttpSessionCookieMode::Only) { |
|
404 | + throw new TInvalidOperationException('httpsession_transid_cookieonly'); |
|
405 | + } |
|
397 | 406 | ini_set('session.use_trans_sid',$value?'1':'0'); |
398 | 407 | } |
399 | 408 | } |
@@ -412,10 +421,11 @@ discard block |
||
412 | 421 | */ |
413 | 422 | public function setTimeout($value) |
414 | 423 | { |
415 | - if($this->_started) |
|
416 | - throw new TInvalidOperationException('httpsession_maxlifetime_unchangeable'); |
|
417 | - else |
|
418 | - ini_set('session.gc_maxlifetime',$value); |
|
424 | + if($this->_started) { |
|
425 | + throw new TInvalidOperationException('httpsession_maxlifetime_unchangeable'); |
|
426 | + } else { |
|
427 | + ini_set('session.gc_maxlifetime',$value); |
|
428 | + } |
|
419 | 429 | } |
420 | 430 | |
421 | 431 | /** |
@@ -557,9 +567,9 @@ discard block |
||
557 | 567 | $value=$_SESSION[$key]; |
558 | 568 | unset($_SESSION[$key]); |
559 | 569 | return $value; |
570 | + } else { |
|
571 | + return null; |
|
560 | 572 | } |
561 | - else |
|
562 | - return null; |
|
563 | 573 | } |
564 | 574 | |
565 | 575 | /** |
@@ -567,8 +577,9 @@ discard block |
||
567 | 577 | */ |
568 | 578 | public function clear() |
569 | 579 | { |
570 | - foreach(array_keys($_SESSION) as $key) |
|
571 | - unset($_SESSION[$key]); |
|
580 | + foreach(array_keys($_SESSION) as $key) { |
|
581 | + unset($_SESSION[$key]); |
|
582 | + } |
|
572 | 583 | } |
573 | 584 | |
574 | 585 | /** |
@@ -39,6 +39,7 @@ |
||
39 | 39 | * HTML-decodes a string. |
40 | 40 | * It is the inverse of {@link htmlEncode}. |
41 | 41 | * @param string string to be decoded |
42 | + * @param string $s |
|
42 | 43 | * @return string decoded string |
43 | 44 | */ |
44 | 45 | public static function htmlDecode($s) |
@@ -1,13 +1,13 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * THttpUtility class file |
|
4 | - * |
|
5 | - * @author Qiang Xue <[email protected]> |
|
6 | - * @link https://github.com/pradosoft/prado |
|
7 | - * @copyright Copyright © 2005-2015 The PRADO Group |
|
8 | - * @license https://github.com/pradosoft/prado/blob/master/COPYRIGHT |
|
9 | - * @package System.Web |
|
10 | - */ |
|
3 | + * THttpUtility class file |
|
4 | + * |
|
5 | + * @author Qiang Xue <[email protected]> |
|
6 | + * @link https://github.com/pradosoft/prado |
|
7 | + * @copyright Copyright © 2005-2015 The PRADO Group |
|
8 | + * @license https://github.com/pradosoft/prado/blob/master/COPYRIGHT |
|
9 | + * @package System.Web |
|
10 | + */ |
|
11 | 11 | |
12 | 12 | /** |
13 | 13 | * THttpUtility class |
@@ -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 |
@@ -96,6 +96,7 @@ discard block |
||
96 | 96 | * Initializes this module. |
97 | 97 | * This method is required by the IModule interface. |
98 | 98 | * @param mixed configuration for this module, can be null |
99 | + * @param TXmlDocument $config |
|
99 | 100 | * @throws TConfigurationException if module is configured in the global scope. |
100 | 101 | */ |
101 | 102 | public function init($config) |
@@ -606,6 +607,7 @@ discard block |
||
606 | 607 | |
607 | 608 | /** |
608 | 609 | * @param string full regular expression mapping pattern. |
610 | + * @param string $value |
|
609 | 611 | */ |
610 | 612 | public function setRegularExpression($value) |
611 | 613 | { |
@@ -715,6 +717,7 @@ discard block |
||
715 | 717 | * Uses URL pattern (or full regular expression if available) to |
716 | 718 | * match the given url path. |
717 | 719 | * @param THttpRequest the request module |
720 | + * @param THttpRequest $request |
|
718 | 721 | * @return array matched parameters, empty if no matches. |
719 | 722 | */ |
720 | 723 | public function getPatternMatches($request) |
@@ -785,7 +788,7 @@ discard block |
||
785 | 788 | } |
786 | 789 | |
787 | 790 | /** |
788 | - * @return THttpRequestUrlFormat the format of URLs. Defaults to THttpRequestUrlFormat::Get. |
|
791 | + * @return string the format of URLs. Defaults to THttpRequestUrlFormat::Get. |
|
789 | 792 | */ |
790 | 793 | public function getUrlFormat() |
791 | 794 | { |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | /** |
71 | 71 | * @var TUrlMappingPattern[] list of patterns. |
72 | 72 | */ |
73 | - protected $_patterns=array(); |
|
73 | + protected $_patterns = array(); |
|
74 | 74 | /** |
75 | 75 | * @var TUrlMappingPattern matched pattern. |
76 | 76 | */ |
@@ -78,19 +78,19 @@ discard block |
||
78 | 78 | /** |
79 | 79 | * @var string external configuration file |
80 | 80 | */ |
81 | - private $_configFile=null; |
|
81 | + private $_configFile = null; |
|
82 | 82 | /** |
83 | 83 | * @var boolean whether to enable custom contructUrl |
84 | 84 | */ |
85 | - private $_customUrl=false; |
|
85 | + private $_customUrl = false; |
|
86 | 86 | /** |
87 | 87 | * @var array rules for constructing URLs |
88 | 88 | */ |
89 | - protected $_constructRules=array(); |
|
89 | + protected $_constructRules = array(); |
|
90 | 90 | |
91 | - private $_urlPrefix=''; |
|
91 | + private $_urlPrefix = ''; |
|
92 | 92 | |
93 | - private $_defaultMappingClass='TUrlMappingPattern'; |
|
93 | + private $_defaultMappingClass = 'TUrlMappingPattern'; |
|
94 | 94 | |
95 | 95 | /** |
96 | 96 | * Initializes this module. |
@@ -101,22 +101,22 @@ discard block |
||
101 | 101 | public function init($config) |
102 | 102 | { |
103 | 103 | parent::init($config); |
104 | - if($this->getRequest()->getRequestResolved()) |
|
104 | + if ($this->getRequest()->getRequestResolved()) |
|
105 | 105 | throw new TConfigurationException('urlmapping_global_required'); |
106 | - if($this->_configFile!==null) |
|
106 | + if ($this->_configFile !== null) |
|
107 | 107 | $this->loadConfigFile(); |
108 | 108 | $this->loadUrlMappings($config); |
109 | - if($this->_urlPrefix==='') |
|
109 | + if ($this->_urlPrefix === '') |
|
110 | 110 | { |
111 | - $request=$this->getRequest(); |
|
112 | - if($request->getUrlFormat()===THttpRequestUrlFormat::HiddenPath) |
|
111 | + $request = $this->getRequest(); |
|
112 | + if ($request->getUrlFormat() === THttpRequestUrlFormat::HiddenPath) |
|
113 | 113 | { |
114 | - $this->_urlPrefix=dirname($request->getApplicationUrl()); |
|
114 | + $this->_urlPrefix = dirname($request->getApplicationUrl()); |
|
115 | 115 | } else { |
116 | - $this->_urlPrefix=$request->getApplicationUrl(); |
|
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 | /** |
@@ -125,22 +125,22 @@ discard block |
||
125 | 125 | */ |
126 | 126 | protected function loadConfigFile() |
127 | 127 | { |
128 | - if(is_file($this->_configFile)) |
|
128 | + if (is_file($this->_configFile)) |
|
129 | 129 | { |
130 | - if($this->getApplication()->getConfigurationType()==TApplication::CONFIG_TYPE_PHP) |
|
130 | + if ($this->getApplication()->getConfigurationType() == TApplication::CONFIG_TYPE_PHP) |
|
131 | 131 | { |
132 | 132 | $config = include $this->_configFile; |
133 | 133 | $this->loadUrlMappings($dom); |
134 | 134 | } |
135 | 135 | else |
136 | 136 | { |
137 | - $dom=new TXmlDocument; |
|
137 | + $dom = new TXmlDocument; |
|
138 | 138 | $dom->loadFromFile($this->_configFile); |
139 | 139 | $this->loadUrlMappings($dom); |
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 | /** |
@@ -164,7 +164,7 @@ discard block |
||
164 | 164 | */ |
165 | 165 | public function setEnableCustomUrl($value) |
166 | 166 | { |
167 | - $this->_customUrl=TPropertyValue::ensureBoolean($value); |
|
167 | + $this->_customUrl = TPropertyValue::ensureBoolean($value); |
|
168 | 168 | } |
169 | 169 | |
170 | 170 | /** |
@@ -183,7 +183,7 @@ discard block |
||
183 | 183 | */ |
184 | 184 | public function setUrlPrefix($value) |
185 | 185 | { |
186 | - $this->_urlPrefix=$value; |
|
186 | + $this->_urlPrefix = $value; |
|
187 | 187 | } |
188 | 188 | |
189 | 189 | /** |
@@ -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 | /** |
@@ -223,7 +223,7 @@ discard block |
||
223 | 223 | */ |
224 | 224 | public function setDefaultMappingClass($value) |
225 | 225 | { |
226 | - $this->_defaultMappingClass=$value; |
|
226 | + $this->_defaultMappingClass = $value; |
|
227 | 227 | } |
228 | 228 | |
229 | 229 | /** |
@@ -235,43 +235,43 @@ discard block |
||
235 | 235 | { |
236 | 236 | $defaultClass = $this->getDefaultMappingClass(); |
237 | 237 | |
238 | - if(is_array($config)) |
|
238 | + if (is_array($config)) |
|
239 | 239 | { |
240 | - if(isset($config['urls']) && is_array($config['urls'])) |
|
240 | + if (isset($config['urls']) && is_array($config['urls'])) |
|
241 | 241 | { |
242 | - foreach($config['urls'] as $url) |
|
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 | } |
250 | 250 | else |
251 | 251 | { |
252 | - foreach($config->getElementsByTagName('url') as $url) |
|
252 | + foreach ($config->getElementsByTagName('url') as $url) |
|
253 | 253 | { |
254 | - $properties=$url->getAttributes(); |
|
255 | - if(($class=$properties->remove('class'))===null) |
|
256 | - $class=$defaultClass; |
|
257 | - $this->buildUrlMapping($class,$properties,$url); |
|
254 | + $properties = $url->getAttributes(); |
|
255 | + if (($class = $properties->remove('class')) === null) |
|
256 | + $class = $defaultClass; |
|
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); |
|
265 | - if(!($pattern instanceof TUrlMappingPattern)) |
|
264 | + $pattern = Prado::createComponent($class, $this); |
|
265 | + if (!($pattern instanceof TUrlMappingPattern)) |
|
266 | 266 | throw new TConfigurationException('urlmapping_urlmappingpattern_required'); |
267 | - foreach($properties as $name=>$value) |
|
268 | - $pattern->setSubproperty($name,$value); |
|
267 | + foreach ($properties as $name=>$value) |
|
268 | + $pattern->setSubproperty($name, $value); |
|
269 | 269 | |
270 | - if($url instanceof TXmlElement) { |
|
270 | + if ($url instanceof TXmlElement) { |
|
271 | 271 | $text = $url -> getValue(); |
272 | - if($text) { |
|
272 | + if ($text) { |
|
273 | 273 | $text = preg_replace('/(\s+)/S', '', $text); |
274 | - if(($regExp = $pattern->getRegularExpression()) !== '') |
|
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, |
@@ -283,11 +283,11 @@ discard block |
||
283 | 283 | } |
284 | 284 | } |
285 | 285 | |
286 | - $this->_patterns[]=$pattern; |
|
286 | + $this->_patterns[] = $pattern; |
|
287 | 287 | $pattern->init($url); |
288 | 288 | |
289 | - $key=$pattern->getServiceID().':'.$pattern->getServiceParameter(); |
|
290 | - $this->_constructRules[$key][]=$pattern; |
|
289 | + $key = $pattern->getServiceID() . ':' . $pattern->getServiceParameter(); |
|
290 | + $this->_constructRules[$key][] = $pattern; |
|
291 | 291 | } |
292 | 292 | |
293 | 293 | /** |
@@ -300,21 +300,21 @@ discard block |
||
300 | 300 | */ |
301 | 301 | public function parseUrl() |
302 | 302 | { |
303 | - $request=$this->getRequest(); |
|
304 | - foreach($this->_patterns as $pattern) |
|
303 | + $request = $this->getRequest(); |
|
304 | + foreach ($this->_patterns as $pattern) |
|
305 | 305 | { |
306 | - $matches=$pattern->getPatternMatches($request); |
|
307 | - if(count($matches)>0) |
|
306 | + $matches = $pattern->getPatternMatches($request); |
|
307 | + if (count($matches) > 0) |
|
308 | 308 | { |
309 | - $this->_matched=$pattern; |
|
310 | - $params=array(); |
|
311 | - foreach($matches as $key=>$value) |
|
309 | + $this->_matched = $pattern; |
|
310 | + $params = array(); |
|
311 | + foreach ($matches as $key=>$value) |
|
312 | 312 | { |
313 | - if(is_string($key)) |
|
314 | - $params[$key]=$value; |
|
313 | + if (is_string($key)) |
|
314 | + $params[$key] = $value; |
|
315 | 315 | } |
316 | 316 | if (!$pattern->getIsWildCardPattern()) |
317 | - $params[$pattern->getServiceID()]=$pattern->getServiceParameter(); |
|
317 | + $params[$pattern->getServiceID()] = $pattern->getServiceParameter(); |
|
318 | 318 | return $params; |
319 | 319 | } |
320 | 320 | } |
@@ -345,36 +345,36 @@ 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 | - if($this->_customUrl) |
|
350 | + if ($this->_customUrl) |
|
351 | 351 | { |
352 | - if(!(is_array($getItems) || ($getItems instanceof Traversable))) |
|
353 | - $getItems=array(); |
|
354 | - $key=$serviceID.':'.$serviceParam; |
|
355 | - $wildCardKey = ($pos=strrpos($serviceParam,'.'))!==false ? |
|
356 | - $serviceID.':'.substr($serviceParam,0,$pos).'.*' : $serviceID.':*'; |
|
357 | - if(isset($this->_constructRules[$key])) |
|
352 | + if (!(is_array($getItems) || ($getItems instanceof Traversable))) |
|
353 | + $getItems = array(); |
|
354 | + $key = $serviceID . ':' . $serviceParam; |
|
355 | + $wildCardKey = ($pos = strrpos($serviceParam, '.')) !== false ? |
|
356 | + $serviceID . ':' . substr($serviceParam, 0, $pos) . '.*' : $serviceID . ':*'; |
|
357 | + if (isset($this->_constructRules[$key])) |
|
358 | 358 | { |
359 | - foreach($this->_constructRules[$key] as $rule) |
|
359 | + foreach ($this->_constructRules[$key] as $rule) |
|
360 | 360 | { |
361 | - if($rule->supportCustomUrl($getItems)) |
|
362 | - return $rule->constructUrl($getItems,$encodeAmpersand,$encodeGetItems); |
|
361 | + if ($rule->supportCustomUrl($getItems)) |
|
362 | + return $rule->constructUrl($getItems, $encodeAmpersand, $encodeGetItems); |
|
363 | 363 | } |
364 | 364 | } |
365 | - elseif(isset($this->_constructRules[$wildCardKey])) |
|
365 | + elseif (isset($this->_constructRules[$wildCardKey])) |
|
366 | 366 | { |
367 | - foreach($this->_constructRules[$wildCardKey] as $rule) |
|
367 | + foreach ($this->_constructRules[$wildCardKey] as $rule) |
|
368 | 368 | { |
369 | - if($rule->supportCustomUrl($getItems)) |
|
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 | /** |
@@ -494,7 +494,7 @@ discard block |
||
494 | 494 | /** |
495 | 495 | * @var string service ID, default is 'page'. |
496 | 496 | */ |
497 | - private $_serviceID='page'; |
|
497 | + private $_serviceID = 'page'; |
|
498 | 498 | /** |
499 | 499 | * @var string url pattern to match. |
500 | 500 | */ |
@@ -510,19 +510,19 @@ discard block |
||
510 | 510 | /** |
511 | 511 | * @var string regular expression pattern. |
512 | 512 | */ |
513 | - private $_regexp=''; |
|
513 | + private $_regexp = ''; |
|
514 | 514 | |
515 | - private $_customUrl=true; |
|
515 | + private $_customUrl = true; |
|
516 | 516 | |
517 | 517 | private $_manager; |
518 | 518 | |
519 | - private $_caseSensitive=true; |
|
519 | + private $_caseSensitive = true; |
|
520 | 520 | |
521 | - private $_isWildCardPattern=false; |
|
521 | + private $_isWildCardPattern = false; |
|
522 | 522 | |
523 | - private $_urlFormat=THttpRequestUrlFormat::Get; |
|
523 | + private $_urlFormat = THttpRequestUrlFormat::Get; |
|
524 | 524 | |
525 | - private $_separator='/'; |
|
525 | + private $_separator = '/'; |
|
526 | 526 | |
527 | 527 | /** |
528 | 528 | * @var TUrlMappingPatternSecureConnection |
@@ -536,7 +536,7 @@ discard block |
||
536 | 536 | */ |
537 | 537 | public function __construct(TUrlManager $manager) |
538 | 538 | { |
539 | - $this->_manager=$manager; |
|
539 | + $this->_manager = $manager; |
|
540 | 540 | } |
541 | 541 | |
542 | 542 | /** |
@@ -554,10 +554,10 @@ discard block |
||
554 | 554 | */ |
555 | 555 | public function init($config) |
556 | 556 | { |
557 | - if($this->_serviceParameter===null) |
|
557 | + if ($this->_serviceParameter === null) |
|
558 | 558 | throw new TConfigurationException('urlmappingpattern_serviceparameter_required', $this->getPattern()); |
559 | - if(strpos($this->_serviceParameter,'*')!==false) |
|
560 | - $this->_isWildCardPattern=true; |
|
559 | + if (strpos($this->_serviceParameter, '*') !== false) |
|
560 | + $this->_isWildCardPattern = true; |
|
561 | 561 | } |
562 | 562 | |
563 | 563 | /** |
@@ -567,32 +567,32 @@ discard block |
||
567 | 567 | */ |
568 | 568 | protected function getParameterizedPattern() |
569 | 569 | { |
570 | - $params=array(); |
|
571 | - $values=array(); |
|
570 | + $params = array(); |
|
571 | + $values = array(); |
|
572 | 572 | if ($this->_parameters) |
573 | 573 | { |
574 | - foreach($this->_parameters as $key=>$value) |
|
574 | + foreach ($this->_parameters as $key=>$value) |
|
575 | 575 | { |
576 | - $params[]='{'.$key.'}'; |
|
577 | - $values[]='(?P<'.$key.'>'.$value.')'; |
|
576 | + $params[] = '{' . $key . '}'; |
|
577 | + $values[] = '(?P<' . $key . '>' . $value . ')'; |
|
578 | 578 | } |
579 | 579 | } |
580 | 580 | if ($this->getIsWildCardPattern()) |
581 | 581 | { |
582 | - $params[]='{*}'; |
|
582 | + $params[] = '{*}'; |
|
583 | 583 | // service parameter must not contain '=' and '/' |
584 | - $values[]='(?P<'.$this->getServiceID().'>[^=/]+)'; |
|
584 | + $values[] = '(?P<' . $this->getServiceID() . '>[^=/]+)'; |
|
585 | 585 | } |
586 | - $params[]='/'; |
|
587 | - $values[]='\\/'; |
|
588 | - $regexp=str_replace($params,$values,trim($this->getPattern(),'/').'/'); |
|
589 | - if ($this->_urlFormat===THttpRequestUrlFormat::Get) |
|
590 | - $regexp='/^'.$regexp.'$/u'; |
|
586 | + $params[] = '/'; |
|
587 | + $values[] = '\\/'; |
|
588 | + $regexp = str_replace($params, $values, trim($this->getPattern(), '/') . '/'); |
|
589 | + if ($this->_urlFormat === THttpRequestUrlFormat::Get) |
|
590 | + $regexp = '/^' . $regexp . '$/u'; |
|
591 | 591 | else |
592 | - $regexp='/^'.$regexp.'(?P<urlparams>.*)$/u'; |
|
592 | + $regexp = '/^' . $regexp . '(?P<urlparams>.*)$/u'; |
|
593 | 593 | |
594 | - if(!$this->getCaseSensitive()) |
|
595 | - $regexp.='i'; |
|
594 | + if (!$this->getCaseSensitive()) |
|
595 | + $regexp .= 'i'; |
|
596 | 596 | return $regexp; |
597 | 597 | } |
598 | 598 | |
@@ -609,7 +609,7 @@ discard block |
||
609 | 609 | */ |
610 | 610 | public function setRegularExpression($value) |
611 | 611 | { |
612 | - $this->_regexp=$value; |
|
612 | + $this->_regexp = $value; |
|
613 | 613 | } |
614 | 614 | |
615 | 615 | /** |
@@ -625,7 +625,7 @@ discard block |
||
625 | 625 | */ |
626 | 626 | public function setCaseSensitive($value) |
627 | 627 | { |
628 | - $this->_caseSensitive=TPropertyValue::ensureBoolean($value); |
|
628 | + $this->_caseSensitive = TPropertyValue::ensureBoolean($value); |
|
629 | 629 | } |
630 | 630 | |
631 | 631 | /** |
@@ -633,7 +633,7 @@ discard block |
||
633 | 633 | */ |
634 | 634 | public function setServiceParameter($value) |
635 | 635 | { |
636 | - $this->_serviceParameter=$value; |
|
636 | + $this->_serviceParameter = $value; |
|
637 | 637 | } |
638 | 638 | |
639 | 639 | /** |
@@ -649,7 +649,7 @@ discard block |
||
649 | 649 | */ |
650 | 650 | public function setServiceID($value) |
651 | 651 | { |
652 | - $this->_serviceID=$value; |
|
652 | + $this->_serviceID = $value; |
|
653 | 653 | } |
654 | 654 | |
655 | 655 | /** |
@@ -683,7 +683,7 @@ discard block |
||
683 | 683 | { |
684 | 684 | if (!$this->_parameters) |
685 | 685 | { |
686 | - $this->_parameters=new TAttributeCollection; |
|
686 | + $this->_parameters = new TAttributeCollection; |
|
687 | 687 | $this->_parameters->setCaseSensitive(true); |
688 | 688 | } |
689 | 689 | return $this->_parameters; |
@@ -694,7 +694,7 @@ discard block |
||
694 | 694 | */ |
695 | 695 | public function setParameters($value) |
696 | 696 | { |
697 | - $this->_parameters=$value; |
|
697 | + $this->_parameters = $value; |
|
698 | 698 | } |
699 | 699 | |
700 | 700 | /** |
@@ -719,38 +719,38 @@ discard block |
||
719 | 719 | */ |
720 | 720 | public function getPatternMatches($request) |
721 | 721 | { |
722 | - $matches=array(); |
|
723 | - if(($pattern=$this->getRegularExpression())!=='') |
|
724 | - preg_match($pattern,$request->getPathInfo(),$matches); |
|
722 | + $matches = array(); |
|
723 | + if (($pattern = $this->getRegularExpression()) !== '') |
|
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 | - if($this->getIsWildCardPattern() && isset($matches[$this->_serviceID])) |
|
729 | - $matches[$this->_serviceID]=str_replace('*',$matches[$this->_serviceID],$this->_serviceParameter); |
|
728 | + if ($this->getIsWildCardPattern() && isset($matches[$this->_serviceID])) |
|
729 | + $matches[$this->_serviceID] = str_replace('*', $matches[$this->_serviceID], $this->_serviceParameter); |
|
730 | 730 | |
731 | 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 | - while($key=array_shift($params)) |
|
737 | - $matches[$key]=($value=array_shift($params)) ? $value : ''; |
|
736 | + while ($key = array_shift($params)) |
|
737 | + $matches[$key] = ($value = array_shift($params)) ? $value : ''; |
|
738 | 738 | } |
739 | 739 | else |
740 | 740 | { |
741 | 741 | array_pop($params); |
742 | - foreach($params as $param) |
|
742 | + foreach ($params as $param) |
|
743 | 743 | { |
744 | - list($key,$value)=explode($this->_separator,$param,2); |
|
745 | - $matches[$key]=$value; |
|
744 | + list($key, $value) = explode($this->_separator, $param, 2); |
|
745 | + $matches[$key] = $value; |
|
746 | 746 | } |
747 | 747 | } |
748 | 748 | unset($matches['urlparams']); |
749 | 749 | } |
750 | 750 | |
751 | - if(count($matches) > 0 && $this->_constants) |
|
751 | + if (count($matches) > 0 && $this->_constants) |
|
752 | 752 | { |
753 | - foreach($this->_constants->toArray() as $key=>$value) |
|
753 | + foreach ($this->_constants->toArray() as $key=>$value) |
|
754 | 754 | $matches[$key] = $value; |
755 | 755 | } |
756 | 756 | |
@@ -773,7 +773,7 @@ discard block |
||
773 | 773 | */ |
774 | 774 | public function setEnableCustomUrl($value) |
775 | 775 | { |
776 | - $this->_customUrl=TPropertyValue::ensureBoolean($value); |
|
776 | + $this->_customUrl = TPropertyValue::ensureBoolean($value); |
|
777 | 777 | } |
778 | 778 | |
779 | 779 | /** |
@@ -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 | /** |
@@ -822,8 +822,8 @@ discard block |
||
822 | 822 | */ |
823 | 823 | public function setUrlParamSeparator($value) |
824 | 824 | { |
825 | - if(strlen($value)===1) |
|
826 | - $this->_separator=$value; |
|
825 | + if (strlen($value) === 1) |
|
826 | + $this->_separator = $value; |
|
827 | 827 | else |
828 | 828 | throw new TInvalidDataValueException('httprequest_separator_invalid'); |
829 | 829 | } |
@@ -853,24 +853,24 @@ discard block |
||
853 | 853 | */ |
854 | 854 | public function supportCustomUrl($getItems) |
855 | 855 | { |
856 | - if(!$this->_customUrl || $this->getPattern()===null) |
|
856 | + if (!$this->_customUrl || $this->getPattern() === null) |
|
857 | 857 | return false; |
858 | 858 | if ($this->_parameters) |
859 | 859 | { |
860 | - foreach($this->_parameters as $key=>$value) |
|
860 | + foreach ($this->_parameters as $key=>$value) |
|
861 | 861 | { |
862 | - if(!isset($getItems[$key])) |
|
862 | + if (!isset($getItems[$key])) |
|
863 | 863 | return false; |
864 | 864 | } |
865 | 865 | } |
866 | 866 | |
867 | 867 | if ($this->_constants) |
868 | 868 | { |
869 | - foreach($this->_constants->toArray() as $key=>$value) |
|
869 | + foreach ($this->_constants->toArray() as $key=>$value) |
|
870 | 870 | { |
871 | 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,68 +885,68 @@ 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 | 890 | if ($this->_constants) |
891 | 891 | { |
892 | - foreach($this->_constants->toArray() as $key=>$value) |
|
892 | + foreach ($this->_constants->toArray() as $key=>$value) |
|
893 | 893 | { |
894 | 894 | unset($getItems[$key]); |
895 | 895 | } |
896 | 896 | } |
897 | 897 | |
898 | - $extra=array(); |
|
899 | - $replace=array(); |
|
898 | + $extra = array(); |
|
899 | + $replace = array(); |
|
900 | 900 | // for the GET variables matching the pattern, put them in the URL path |
901 | - foreach($getItems as $key=>$value) |
|
901 | + foreach ($getItems as $key=>$value) |
|
902 | 902 | { |
903 | - if(($this->_parameters && $this->_parameters->contains($key)) || ($key==='*' && $this->getIsWildCardPattern())) |
|
904 | - $replace['{'.$key.'}']=$encodeGetItems ? rawurlencode($value) : $value; |
|
903 | + if (($this->_parameters && $this->_parameters->contains($key)) || ($key === '*' && $this->getIsWildCardPattern())) |
|
904 | + $replace['{' . $key . '}'] = $encodeGetItems ? rawurlencode($value) : $value; |
|
905 | 905 | else |
906 | - $extra[$key]=$value; |
|
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()) { |
|
914 | + if ($this->_urlFormat === THttpRequestUrlFormat::Path && $this->getIsWildCardPattern()) { |
|
915 | 915 | foreach ($extra as $name=>$value) |
916 | - $url.='/'.$name.$this->_separator.($encodeGetItems?rawurlencode($value):$value); |
|
916 | + $url .= '/' . $name . $this->_separator . ($encodeGetItems ? rawurlencode($value) : $value); |
|
917 | 917 | return $url; |
918 | 918 | } |
919 | 919 | |
920 | - $url2=''; |
|
921 | - $amp=$encodeAmpersand?'&':'&'; |
|
922 | - if($encodeGetItems) |
|
920 | + $url2 = ''; |
|
921 | + $amp = $encodeAmpersand ? '&' : '&'; |
|
922 | + if ($encodeGetItems) |
|
923 | 923 | { |
924 | - foreach($extra as $name=>$value) |
|
924 | + foreach ($extra as $name=>$value) |
|
925 | 925 | { |
926 | - if(is_array($value)) |
|
926 | + if (is_array($value)) |
|
927 | 927 | { |
928 | - $name=rawurlencode($name.'[]'); |
|
929 | - foreach($value as $v) |
|
930 | - $url2.=$amp.$name.'='.rawurlencode($v); |
|
928 | + $name = rawurlencode($name . '[]'); |
|
929 | + foreach ($value as $v) |
|
930 | + $url2 .= $amp . $name . '=' . rawurlencode($v); |
|
931 | 931 | } |
932 | 932 | else |
933 | - $url2.=$amp.rawurlencode($name).'='.rawurlencode($value); |
|
933 | + $url2 .= $amp . rawurlencode($name) . '=' . rawurlencode($value); |
|
934 | 934 | } |
935 | 935 | } |
936 | 936 | else |
937 | 937 | { |
938 | - foreach($extra as $name=>$value) |
|
938 | + foreach ($extra as $name=>$value) |
|
939 | 939 | { |
940 | - if(is_array($value)) |
|
940 | + if (is_array($value)) |
|
941 | 941 | { |
942 | - foreach($value as $v) |
|
943 | - $url2.=$amp.$name.'[]='.$v; |
|
942 | + foreach ($value as $v) |
|
943 | + $url2 .= $amp . $name . '[]=' . $v; |
|
944 | 944 | } |
945 | 945 | else |
946 | - $url2.=$amp.$name.'='.$value; |
|
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,19 +962,19 @@ 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 | - switch($this -> getSecureConnection()) |
|
970 | + switch ($this -> getSecureConnection()) |
|
971 | 971 | { |
972 | 972 | case TUrlMappingPatternSecureConnection::EnableIfNotSecure: |
973 | - if($isSecureConnection) return $url; |
|
973 | + if ($isSecureConnection) return $url; |
|
974 | 974 | return $request -> getBaseUrl(true) . $url; |
975 | 975 | break; |
976 | 976 | case TUrlMappingPatternSecureConnection::DisableIfSecure: |
977 | - if(!$isSecureConnection) return $url; |
|
977 | + if (!$isSecureConnection) return $url; |
|
978 | 978 | return $request -> getBaseUrl(false) . $url; |
979 | 979 | break; |
980 | 980 | case TUrlMappingPatternSecureConnection::Enable: |
@@ -101,10 +101,12 @@ discard block |
||
101 | 101 | public function init($config) |
102 | 102 | { |
103 | 103 | parent::init($config); |
104 | - if($this->getRequest()->getRequestResolved()) |
|
105 | - throw new TConfigurationException('urlmapping_global_required'); |
|
106 | - if($this->_configFile!==null) |
|
107 | - $this->loadConfigFile(); |
|
104 | + if($this->getRequest()->getRequestResolved()) { |
|
105 | + throw new TConfigurationException('urlmapping_global_required'); |
|
106 | + } |
|
107 | + if($this->_configFile!==null) { |
|
108 | + $this->loadConfigFile(); |
|
109 | + } |
|
108 | 110 | $this->loadUrlMappings($config); |
109 | 111 | if($this->_urlPrefix==='') |
110 | 112 | { |
@@ -131,16 +133,15 @@ discard block |
||
131 | 133 | { |
132 | 134 | $config = include $this->_configFile; |
133 | 135 | $this->loadUrlMappings($dom); |
134 | - } |
|
135 | - else |
|
136 | + } else |
|
136 | 137 | { |
137 | 138 | $dom=new TXmlDocument; |
138 | 139 | $dom->loadFromFile($this->_configFile); |
139 | 140 | $this->loadUrlMappings($dom); |
140 | 141 | } |
142 | + } else { |
|
143 | + throw new TConfigurationException('urlmapping_configfile_inexistent',$this->_configFile); |
|
141 | 144 | } |
142 | - else |
|
143 | - throw new TConfigurationException('urlmapping_configfile_inexistent',$this->_configFile); |
|
144 | 145 | } |
145 | 146 | |
146 | 147 | /** |
@@ -201,8 +202,9 @@ discard block |
||
201 | 202 | */ |
202 | 203 | public function setConfigFile($value) |
203 | 204 | { |
204 | - if(($this->_configFile=Prado::getPathOfNamespace($value,$this->getApplication()->getConfigurationFileExt()))===null) |
|
205 | - throw new TConfigurationException('urlmapping_configfile_invalid',$value); |
|
205 | + if(($this->_configFile=Prado::getPathOfNamespace($value,$this->getApplication()->getConfigurationFileExt()))===null) { |
|
206 | + throw new TConfigurationException('urlmapping_configfile_invalid',$value); |
|
207 | + } |
|
206 | 208 | } |
207 | 209 | |
208 | 210 | /** |
@@ -246,14 +248,14 @@ discard block |
||
246 | 248 | $this->buildUrlMapping($class,$properties,$url); |
247 | 249 | } |
248 | 250 | } |
249 | - } |
|
250 | - else |
|
251 | + } else |
|
251 | 252 | { |
252 | 253 | foreach($config->getElementsByTagName('url') as $url) |
253 | 254 | { |
254 | 255 | $properties=$url->getAttributes(); |
255 | - if(($class=$properties->remove('class'))===null) |
|
256 | - $class=$defaultClass; |
|
256 | + if(($class=$properties->remove('class'))===null) { |
|
257 | + $class=$defaultClass; |
|
258 | + } |
|
257 | 259 | $this->buildUrlMapping($class,$properties,$url); |
258 | 260 | } |
259 | 261 | } |
@@ -262,23 +264,26 @@ discard block |
||
262 | 264 | private function buildUrlMapping($class, $properties, $url) |
263 | 265 | { |
264 | 266 | $pattern=Prado::createComponent($class,$this); |
265 | - if(!($pattern instanceof TUrlMappingPattern)) |
|
266 | - throw new TConfigurationException('urlmapping_urlmappingpattern_required'); |
|
267 | - foreach($properties as $name=>$value) |
|
268 | - $pattern->setSubproperty($name,$value); |
|
267 | + if(!($pattern instanceof TUrlMappingPattern)) { |
|
268 | + throw new TConfigurationException('urlmapping_urlmappingpattern_required'); |
|
269 | + } |
|
270 | + foreach($properties as $name=>$value) { |
|
271 | + $pattern->setSubproperty($name,$value); |
|
272 | + } |
|
269 | 273 | |
270 | 274 | if($url instanceof TXmlElement) { |
271 | 275 | $text = $url -> getValue(); |
272 | 276 | if($text) { |
273 | 277 | $text = preg_replace('/(\s+)/S', '', $text); |
274 | - if(($regExp = $pattern->getRegularExpression()) !== '') |
|
275 | - trigger_error(sPrintF('%s.RegularExpression property value "%s" for ServiceID="%s" and ServiceParameter="%s" was replaced by node value "%s"', |
|
278 | + if(($regExp = $pattern->getRegularExpression()) !== '') { |
|
279 | + trigger_error(sPrintF('%s.RegularExpression property value "%s" for ServiceID="%s" and ServiceParameter="%s" was replaced by node value "%s"', |
|
276 | 280 | get_class($pattern), |
277 | 281 | $regExp, |
278 | 282 | $pattern->getServiceID(), |
279 | 283 | $pattern->getServiceParameter(), |
280 | 284 | $text), |
281 | 285 | E_USER_NOTICE); |
286 | + } |
|
282 | 287 | $pattern->setRegularExpression($text); |
283 | 288 | } |
284 | 289 | } |
@@ -310,11 +315,13 @@ discard block |
||
310 | 315 | $params=array(); |
311 | 316 | foreach($matches as $key=>$value) |
312 | 317 | { |
313 | - if(is_string($key)) |
|
314 | - $params[$key]=$value; |
|
318 | + if(is_string($key)) { |
|
319 | + $params[$key]=$value; |
|
320 | + } |
|
321 | + } |
|
322 | + if (!$pattern->getIsWildCardPattern()) { |
|
323 | + $params[$pattern->getServiceID()]=$pattern->getServiceParameter(); |
|
315 | 324 | } |
316 | - if (!$pattern->getIsWildCardPattern()) |
|
317 | - $params[$pattern->getServiceID()]=$pattern->getServiceParameter(); |
|
318 | 325 | return $params; |
319 | 326 | } |
320 | 327 | } |
@@ -349,8 +356,9 @@ discard block |
||
349 | 356 | { |
350 | 357 | if($this->_customUrl) |
351 | 358 | { |
352 | - if(!(is_array($getItems) || ($getItems instanceof Traversable))) |
|
353 | - $getItems=array(); |
|
359 | + if(!(is_array($getItems) || ($getItems instanceof Traversable))) { |
|
360 | + $getItems=array(); |
|
361 | + } |
|
354 | 362 | $key=$serviceID.':'.$serviceParam; |
355 | 363 | $wildCardKey = ($pos=strrpos($serviceParam,'.'))!==false ? |
356 | 364 | $serviceID.':'.substr($serviceParam,0,$pos).'.*' : $serviceID.':*'; |
@@ -358,11 +366,11 @@ discard block |
||
358 | 366 | { |
359 | 367 | foreach($this->_constructRules[$key] as $rule) |
360 | 368 | { |
361 | - if($rule->supportCustomUrl($getItems)) |
|
362 | - return $rule->constructUrl($getItems,$encodeAmpersand,$encodeGetItems); |
|
369 | + if($rule->supportCustomUrl($getItems)) { |
|
370 | + return $rule->constructUrl($getItems,$encodeAmpersand,$encodeGetItems); |
|
371 | + } |
|
363 | 372 | } |
364 | - } |
|
365 | - elseif(isset($this->_constructRules[$wildCardKey])) |
|
373 | + } elseif(isset($this->_constructRules[$wildCardKey])) |
|
366 | 374 | { |
367 | 375 | foreach($this->_constructRules[$wildCardKey] as $rule) |
368 | 376 | { |
@@ -554,10 +562,12 @@ discard block |
||
554 | 562 | */ |
555 | 563 | public function init($config) |
556 | 564 | { |
557 | - if($this->_serviceParameter===null) |
|
558 | - throw new TConfigurationException('urlmappingpattern_serviceparameter_required', $this->getPattern()); |
|
559 | - if(strpos($this->_serviceParameter,'*')!==false) |
|
560 | - $this->_isWildCardPattern=true; |
|
565 | + if($this->_serviceParameter===null) { |
|
566 | + throw new TConfigurationException('urlmappingpattern_serviceparameter_required', $this->getPattern()); |
|
567 | + } |
|
568 | + if(strpos($this->_serviceParameter,'*')!==false) { |
|
569 | + $this->_isWildCardPattern=true; |
|
570 | + } |
|
561 | 571 | } |
562 | 572 | |
563 | 573 | /** |
@@ -586,13 +596,15 @@ discard block |
||
586 | 596 | $params[]='/'; |
587 | 597 | $values[]='\\/'; |
588 | 598 | $regexp=str_replace($params,$values,trim($this->getPattern(),'/').'/'); |
589 | - if ($this->_urlFormat===THttpRequestUrlFormat::Get) |
|
590 | - $regexp='/^'.$regexp.'$/u'; |
|
591 | - else |
|
592 | - $regexp='/^'.$regexp.'(?P<urlparams>.*)$/u'; |
|
599 | + if ($this->_urlFormat===THttpRequestUrlFormat::Get) { |
|
600 | + $regexp='/^'.$regexp.'$/u'; |
|
601 | + } else { |
|
602 | + $regexp='/^'.$regexp.'(?P<urlparams>.*)$/u'; |
|
603 | + } |
|
593 | 604 | |
594 | - if(!$this->getCaseSensitive()) |
|
595 | - $regexp.='i'; |
|
605 | + if(!$this->getCaseSensitive()) { |
|
606 | + $regexp.='i'; |
|
607 | + } |
|
596 | 608 | return $regexp; |
597 | 609 | } |
598 | 610 | |
@@ -720,23 +732,25 @@ discard block |
||
720 | 732 | public function getPatternMatches($request) |
721 | 733 | { |
722 | 734 | $matches=array(); |
723 | - if(($pattern=$this->getRegularExpression())!=='') |
|
724 | - preg_match($pattern,$request->getPathInfo(),$matches); |
|
725 | - else |
|
726 | - preg_match($this->getParameterizedPattern(),trim($request->getPathInfo(),'/').'/',$matches); |
|
735 | + if(($pattern=$this->getRegularExpression())!=='') { |
|
736 | + preg_match($pattern,$request->getPathInfo(),$matches); |
|
737 | + } else { |
|
738 | + preg_match($this->getParameterizedPattern(),trim($request->getPathInfo(),'/').'/',$matches); |
|
739 | + } |
|
727 | 740 | |
728 | - if($this->getIsWildCardPattern() && isset($matches[$this->_serviceID])) |
|
729 | - $matches[$this->_serviceID]=str_replace('*',$matches[$this->_serviceID],$this->_serviceParameter); |
|
741 | + if($this->getIsWildCardPattern() && isset($matches[$this->_serviceID])) { |
|
742 | + $matches[$this->_serviceID]=str_replace('*',$matches[$this->_serviceID],$this->_serviceParameter); |
|
743 | + } |
|
730 | 744 | |
731 | 745 | if (isset($matches['urlparams'])) |
732 | 746 | { |
733 | 747 | $params=explode('/',$matches['urlparams']); |
734 | 748 | if ($this->_separator==='/') |
735 | 749 | { |
736 | - while($key=array_shift($params)) |
|
737 | - $matches[$key]=($value=array_shift($params)) ? $value : ''; |
|
738 | - } |
|
739 | - else |
|
750 | + while($key=array_shift($params)) { |
|
751 | + $matches[$key]=($value=array_shift($params)) ? $value : ''; |
|
752 | + } |
|
753 | + } else |
|
740 | 754 | { |
741 | 755 | array_pop($params); |
742 | 756 | foreach($params as $param) |
@@ -750,8 +764,9 @@ discard block |
||
750 | 764 | |
751 | 765 | if(count($matches) > 0 && $this->_constants) |
752 | 766 | { |
753 | - foreach($this->_constants->toArray() as $key=>$value) |
|
754 | - $matches[$key] = $value; |
|
767 | + foreach($this->_constants->toArray() as $key=>$value) { |
|
768 | + $matches[$key] = $value; |
|
769 | + } |
|
755 | 770 | } |
756 | 771 | |
757 | 772 | return $matches; |
@@ -822,10 +837,11 @@ discard block |
||
822 | 837 | */ |
823 | 838 | public function setUrlParamSeparator($value) |
824 | 839 | { |
825 | - if(strlen($value)===1) |
|
826 | - $this->_separator=$value; |
|
827 | - else |
|
828 | - throw new TInvalidDataValueException('httprequest_separator_invalid'); |
|
840 | + if(strlen($value)===1) { |
|
841 | + $this->_separator=$value; |
|
842 | + } else { |
|
843 | + throw new TInvalidDataValueException('httprequest_separator_invalid'); |
|
844 | + } |
|
829 | 845 | } |
830 | 846 | |
831 | 847 | /** |
@@ -853,14 +869,16 @@ discard block |
||
853 | 869 | */ |
854 | 870 | public function supportCustomUrl($getItems) |
855 | 871 | { |
856 | - if(!$this->_customUrl || $this->getPattern()===null) |
|
857 | - return false; |
|
872 | + if(!$this->_customUrl || $this->getPattern()===null) { |
|
873 | + return false; |
|
874 | + } |
|
858 | 875 | if ($this->_parameters) |
859 | 876 | { |
860 | 877 | foreach($this->_parameters as $key=>$value) |
861 | 878 | { |
862 | - if(!isset($getItems[$key])) |
|
863 | - return false; |
|
879 | + if(!isset($getItems[$key])) { |
|
880 | + return false; |
|
881 | + } |
|
864 | 882 | } |
865 | 883 | } |
866 | 884 | |
@@ -868,10 +886,12 @@ discard block |
||
868 | 886 | { |
869 | 887 | foreach($this->_constants->toArray() as $key=>$value) |
870 | 888 | { |
871 | - if (!isset($getItems[$key])) |
|
872 | - return false; |
|
873 | - if ($getItems[$key]!=$value) |
|
874 | - return false; |
|
889 | + if (!isset($getItems[$key])) { |
|
890 | + return false; |
|
891 | + } |
|
892 | + if ($getItems[$key]!=$value) { |
|
893 | + return false; |
|
894 | + } |
|
875 | 895 | } |
876 | 896 | } |
877 | 897 | return true; |
@@ -900,10 +920,11 @@ discard block |
||
900 | 920 | // for the GET variables matching the pattern, put them in the URL path |
901 | 921 | foreach($getItems as $key=>$value) |
902 | 922 | { |
903 | - if(($this->_parameters && $this->_parameters->contains($key)) || ($key==='*' && $this->getIsWildCardPattern())) |
|
904 | - $replace['{'.$key.'}']=$encodeGetItems ? rawurlencode($value) : $value; |
|
905 | - else |
|
906 | - $extra[$key]=$value; |
|
923 | + if(($this->_parameters && $this->_parameters->contains($key)) || ($key==='*' && $this->getIsWildCardPattern())) { |
|
924 | + $replace['{'.$key.'}']=$encodeGetItems ? rawurlencode($value) : $value; |
|
925 | + } else { |
|
926 | + $extra[$key]=$value; |
|
927 | + } |
|
907 | 928 | } |
908 | 929 | |
909 | 930 | $url=$this->_manager->getUrlPrefix().'/'.ltrim(strtr($this->getPattern(),$replace),'/'); |
@@ -912,8 +933,9 @@ discard block |
||
912 | 933 | if(count($extra)>0) |
913 | 934 | { |
914 | 935 | if ($this->_urlFormat===THttpRequestUrlFormat::Path && $this->getIsWildCardPattern()) { |
915 | - foreach ($extra as $name=>$value) |
|
916 | - $url.='/'.$name.$this->_separator.($encodeGetItems?rawurlencode($value):$value); |
|
936 | + foreach ($extra as $name=>$value) { |
|
937 | + $url.='/'.$name.$this->_separator.($encodeGetItems?rawurlencode($value):$value); |
|
938 | + } |
|
917 | 939 | return $url; |
918 | 940 | } |
919 | 941 | |
@@ -926,24 +948,25 @@ discard block |
||
926 | 948 | if(is_array($value)) |
927 | 949 | { |
928 | 950 | $name=rawurlencode($name.'[]'); |
929 | - foreach($value as $v) |
|
930 | - $url2.=$amp.$name.'='.rawurlencode($v); |
|
951 | + foreach($value as $v) { |
|
952 | + $url2.=$amp.$name.'='.rawurlencode($v); |
|
953 | + } |
|
954 | + } else { |
|
955 | + $url2.=$amp.rawurlencode($name).'='.rawurlencode($value); |
|
931 | 956 | } |
932 | - else |
|
933 | - $url2.=$amp.rawurlencode($name).'='.rawurlencode($value); |
|
934 | 957 | } |
935 | - } |
|
936 | - else |
|
958 | + } else |
|
937 | 959 | { |
938 | 960 | foreach($extra as $name=>$value) |
939 | 961 | { |
940 | 962 | if(is_array($value)) |
941 | 963 | { |
942 | - foreach($value as $v) |
|
943 | - $url2.=$amp.$name.'[]='.$v; |
|
964 | + foreach($value as $v) { |
|
965 | + $url2.=$amp.$name.'[]='.$v; |
|
966 | + } |
|
967 | + } else { |
|
968 | + $url2.=$amp.$name.'='.$value; |
|
944 | 969 | } |
945 | - else |
|
946 | - $url2.=$amp.$name.'='.$value; |
|
947 | 970 | } |
948 | 971 | } |
949 | 972 | $url=$url.'?'.substr($url2,strlen($amp)); |
@@ -962,19 +985,27 @@ discard block |
||
962 | 985 | protected function applySecureConnectionPrefix($url) |
963 | 986 | { |
964 | 987 | static $request; |
965 | - if($request === null) $request = Prado::getApplication() -> getRequest(); |
|
988 | + if($request === null) { |
|
989 | + $request = Prado::getApplication() -> getRequest(); |
|
990 | + } |
|
966 | 991 | |
967 | 992 | static $isSecureConnection; |
968 | - if($isSecureConnection === null) $isSecureConnection = $request -> getIsSecureConnection(); |
|
993 | + if($isSecureConnection === null) { |
|
994 | + $isSecureConnection = $request -> getIsSecureConnection(); |
|
995 | + } |
|
969 | 996 | |
970 | 997 | switch($this -> getSecureConnection()) |
971 | 998 | { |
972 | 999 | case TUrlMappingPatternSecureConnection::EnableIfNotSecure: |
973 | - if($isSecureConnection) return $url; |
|
1000 | + if($isSecureConnection) { |
|
1001 | + return $url; |
|
1002 | + } |
|
974 | 1003 | return $request -> getBaseUrl(true) . $url; |
975 | 1004 | break; |
976 | 1005 | case TUrlMappingPatternSecureConnection::DisableIfSecure: |
977 | - if(!$isSecureConnection) return $url; |
|
1006 | + if(!$isSecureConnection) { |
|
1007 | + return $url; |
|
1008 | + } |
|
978 | 1009 | return $request -> getBaseUrl(false) . $url; |
979 | 1010 | break; |
980 | 1011 | case TUrlMappingPatternSecureConnection::Enable: |
@@ -252,7 +252,7 @@ |
||
252 | 252 | } |
253 | 253 | |
254 | 254 | /** |
255 | - * @return boolean true to observe changes. |
|
255 | + * @return boolean|string true to observe changes. |
|
256 | 256 | */ |
257 | 257 | public function getObserveChanges() |
258 | 258 | { |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | public function setIsValid($value) |
106 | 106 | { |
107 | 107 | parent::setIsValid($value); |
108 | - if($this->getActiveControl()->canUpdateClientSide()) |
|
108 | + if ($this->getActiveControl()->canUpdateClientSide()) |
|
109 | 109 | { |
110 | 110 | $client = $this->getPage()->getCallbackClient(); |
111 | 111 | $func = 'Prado.Validation.updateActiveCustomValidator'; |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | */ |
132 | 132 | protected function getClientScriptOptions() |
133 | 133 | { |
134 | - $options=TBaseValidator::getClientScriptOptions(); |
|
134 | + $options = TBaseValidator::getClientScriptOptions(); |
|
135 | 135 | $options['EventTarget'] = $this->getUniqueID(); |
136 | 136 | return $options; |
137 | 137 | } |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | public function setErrorMessage($value) |
144 | 144 | { |
145 | 145 | parent::setErrorMessage($value); |
146 | - if($this->getActiveControl()->canUpdateClientSide()) |
|
146 | + if ($this->getActiveControl()->canUpdateClientSide()) |
|
147 | 147 | { |
148 | 148 | $client = $this->getPage()->getCallbackClient(); |
149 | 149 | $func = 'Prado.Validation.setErrorMessage'; |
@@ -257,6 +257,6 @@ discard block |
||
257 | 257 | public function getObserveChanges() |
258 | 258 | { |
259 | 259 | $changes = $this->getOption('ObserveChanges'); |
260 | - return ($changes===null) ? true : $changes; |
|
260 | + return ($changes === null) ? true : $changes; |
|
261 | 261 | } |
262 | 262 | } |
@@ -70,7 +70,7 @@ |
||
70 | 70 | /** |
71 | 71 | * Javascript client class for this control. |
72 | 72 | * This method overrides the parent implementation. |
73 | - * @return null no javascript class name. |
|
73 | + * @return string no javascript class name. |
|
74 | 74 | */ |
75 | 75 | protected function getClientClassName() |
76 | 76 | { |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | */ |
63 | 63 | protected function createListItemCollection() |
64 | 64 | { |
65 | - $collection = new TActiveListItemCollection; |
|
65 | + $collection = new TActiveListItemCollection; |
|
66 | 66 | $collection->setControl($this); |
67 | 67 | return $collection; |
68 | 68 | } |
@@ -87,8 +87,8 @@ discard block |
||
87 | 87 | { |
88 | 88 | parent::setSelectionMode($value); |
89 | 89 | $multiple = $this->getIsMultiSelect(); |
90 | - $id = $this->getUniqueID(); $multi_id = $id.'[]'; |
|
91 | - if($this->getActiveControl()->canUpdateClientSide()) |
|
90 | + $id = $this->getUniqueID(); $multi_id = $id . '[]'; |
|
91 | + if ($this->getActiveControl()->canUpdateClientSide()) |
|
92 | 92 | { |
93 | 93 | $client = $this->getPage()->getCallbackClient(); |
94 | 94 | $client->setAttribute($this, 'multiple', $multiple ? 'multiple' : false); |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | protected function addAttributesToRender($writer) |
144 | 144 | { |
145 | 145 | parent::addAttributesToRender($writer); |
146 | - $writer->addAttribute('id',$this->getClientID()); |
|
146 | + $writer->addAttribute('id', $this->getClientID()); |
|
147 | 147 | if ($this->getAutoPostBack()) |
148 | 148 | $this->getActiveControl()->registerCallbackClientScript( |
149 | 149 | $this->getClientClassName(), $this->getPostBackOptions()); |
@@ -144,9 +144,10 @@ |
||
144 | 144 | { |
145 | 145 | parent::addAttributesToRender($writer); |
146 | 146 | $writer->addAttribute('id',$this->getClientID()); |
147 | - if ($this->getAutoPostBack()) |
|
148 | - $this->getActiveControl()->registerCallbackClientScript( |
|
147 | + if ($this->getAutoPostBack()) { |
|
148 | + $this->getActiveControl()->registerCallbackClientScript( |
|
149 | 149 | $this->getClientClassName(), $this->getPostBackOptions()); |
150 | + } |
|
150 | 151 | } |
151 | 152 | } |
152 | 153 |
@@ -228,6 +228,8 @@ |
||
228 | 228 | |
229 | 229 | /** |
230 | 230 | * Appends data or javascript code to the body content surrounded with delimiters |
231 | + * @param THttpResponse $response |
|
232 | + * @param string $delimiter |
|
231 | 233 | */ |
232 | 234 | private function appendContentPart($response, $delimiter, $data) |
233 | 235 | { |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | */ |
81 | 81 | private $_callbackClient; |
82 | 82 | |
83 | - private $_controlsToRender=array(); |
|
83 | + private $_controlsToRender = array(); |
|
84 | 84 | |
85 | 85 | /** |
86 | 86 | * Constructor, trap errors and exception to let the callback response |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | */ |
104 | 104 | public function processCallbackEvent($writer) |
105 | 105 | { |
106 | - Prado::trace("ActivePage raiseCallbackEvent()",'System.Web.UI.ActiveControls.TActivePageAdapter'); |
|
106 | + Prado::trace("ActivePage raiseCallbackEvent()", 'System.Web.UI.ActiveControls.TActivePageAdapter'); |
|
107 | 107 | $this->raiseCallbackEvent(); |
108 | 108 | } |
109 | 109 | |
@@ -112,11 +112,11 @@ discard block |
||
112 | 112 | * @param TControl control for defered rendering |
113 | 113 | * @param THtmlWriter the renderer |
114 | 114 | */ |
115 | - public function registerControlToRender($control,$writer) |
|
115 | + public function registerControlToRender($control, $writer) |
|
116 | 116 | { |
117 | 117 | $id = $control->getUniqueID(); |
118 | - if(!isset($this->_controlsToRender[$id])) |
|
119 | - $this->_controlsToRender[$id] = array($control,$writer); |
|
118 | + if (!isset($this->_controlsToRender[$id])) |
|
119 | + $this->_controlsToRender[$id] = array($control, $writer); |
|
120 | 120 | } |
121 | 121 | |
122 | 122 | /** |
@@ -133,8 +133,8 @@ discard block |
||
133 | 133 | */ |
134 | 134 | public function renderCallbackResponse($writer) |
135 | 135 | { |
136 | - Prado::trace("ActivePage renderCallbackResponse()",'System.Web.UI.ActiveControls.TActivePageAdapter'); |
|
137 | - if(($url = $this->getResponse()->getAdapter()->getRedirectedUrl())===null) |
|
136 | + Prado::trace("ActivePage renderCallbackResponse()", 'System.Web.UI.ActiveControls.TActivePageAdapter'); |
|
137 | + if (($url = $this->getResponse()->getAdapter()->getRedirectedUrl()) === null) |
|
138 | 138 | $this->renderResponse($writer); |
139 | 139 | else |
140 | 140 | $this->redirect($url); |
@@ -146,7 +146,7 @@ discard block |
||
146 | 146 | */ |
147 | 147 | protected function redirect($url) |
148 | 148 | { |
149 | - Prado::trace("ActivePage redirect()",'System.Web.UI.ActiveControls.TActivePageAdapter'); |
|
149 | + Prado::trace("ActivePage redirect()", 'System.Web.UI.ActiveControls.TActivePageAdapter'); |
|
150 | 150 | $this->appendContentPart($this->getResponse(), self::CALLBACK_REDIRECT, $url); |
151 | 151 | } |
152 | 152 | |
@@ -157,18 +157,18 @@ discard block |
||
157 | 157 | */ |
158 | 158 | protected function renderResponse($writer) |
159 | 159 | { |
160 | - Prado::trace("ActivePage renderResponse()",'System.Web.UI.ActiveControls.TActivePageAdapter'); |
|
160 | + Prado::trace("ActivePage renderResponse()", 'System.Web.UI.ActiveControls.TActivePageAdapter'); |
|
161 | 161 | //renders all the defered render() calls. |
162 | - foreach($this->_controlsToRender as $rid => $forRender) |
|
162 | + foreach ($this->_controlsToRender as $rid => $forRender) |
|
163 | 163 | $forRender[0]->render($forRender[1]); |
164 | 164 | |
165 | 165 | $response = $this->getResponse(); |
166 | 166 | |
167 | 167 | //send response data in header |
168 | - if($response->getHasAdapter()) |
|
168 | + if ($response->getHasAdapter()) |
|
169 | 169 | { |
170 | 170 | $responseData = $response->getAdapter()->getResponseData(); |
171 | - if($responseData!==null) |
|
171 | + if ($responseData !== null) |
|
172 | 172 | { |
173 | 173 | $data = TJavaScript::jsonEncode($responseData); |
174 | 174 | |
@@ -177,9 +177,9 @@ discard block |
||
177 | 177 | } |
178 | 178 | |
179 | 179 | //sends page state in header |
180 | - if(($handler = $this->getCallbackEventTarget()) !== null) |
|
180 | + if (($handler = $this->getCallbackEventTarget()) !== null) |
|
181 | 181 | { |
182 | - if($handler->getActiveControl()->getClientSide()->getEnablePageStateUpdate()) |
|
182 | + if ($handler->getActiveControl()->getClientSide()->getEnablePageStateUpdate()) |
|
183 | 183 | { |
184 | 184 | $pagestate = $this->getPage()->getClientState(); |
185 | 185 | $this->appendContentPart($response, self::CALLBACK_PAGESTATE_HEADER, $pagestate); |
@@ -190,7 +190,7 @@ discard block |
||
190 | 190 | $writer->write(" "); |
191 | 191 | |
192 | 192 | //output the end javascript |
193 | - if($this->getPage()->getClientScript()->hasEndScripts()) |
|
193 | + if ($this->getPage()->getClientScript()->hasEndScripts()) |
|
194 | 194 | { |
195 | 195 | $writer = $response->createHtmlWriter(); |
196 | 196 | $this->getPage()->getClientScript()->renderEndScriptsCallback($writer); |
@@ -207,22 +207,22 @@ discard block |
||
207 | 207 | |
208 | 208 | // collect all stylesheet file references |
209 | 209 | $stylesheets = $cs->getStyleSheetUrls(); |
210 | - if (count($stylesheets)>0) |
|
210 | + if (count($stylesheets) > 0) |
|
211 | 211 | $this->appendContentPart($response, self::CALLBACK_STYLESHEETLIST_HEADER, TJavaScript::jsonEncode($stylesheets)); |
212 | 212 | |
213 | 213 | // collect all stylesheet snippets references |
214 | 214 | $stylesheets = $cs->getStyleSheetCodes(); |
215 | - if (count($stylesheets)>0) |
|
215 | + if (count($stylesheets) > 0) |
|
216 | 216 | $this->appendContentPart($response, self::CALLBACK_STYLESHEET_HEADER, TJavaScript::jsonEncode($stylesheets)); |
217 | 217 | |
218 | 218 | // collect all script file references |
219 | 219 | $scripts = $cs->getScriptUrls(); |
220 | - if (count($scripts)>0) |
|
220 | + if (count($scripts) > 0) |
|
221 | 221 | $this->appendContentPart($response, self::CALLBACK_SCRIPTLIST_HEADER, TJavaScript::jsonEncode($scripts)); |
222 | 222 | |
223 | 223 | // collect all hidden field references |
224 | 224 | $fields = $cs->getHiddenFields(); |
225 | - if (count($fields)>0) |
|
225 | + if (count($fields) > 0) |
|
226 | 226 | $this->appendContentPart($response, self::CALLBACK_HIDDENFIELDLIST_HEADER, TJavaScript::jsonEncode($fields)); |
227 | 227 | } |
228 | 228 | |
@@ -244,9 +244,9 @@ discard block |
||
244 | 244 | */ |
245 | 245 | private function raiseCallbackEvent() |
246 | 246 | { |
247 | - if(($callbackHandler=$this->getCallbackEventTarget())!==null) |
|
247 | + if (($callbackHandler = $this->getCallbackEventTarget()) !== null) |
|
248 | 248 | { |
249 | - if($callbackHandler instanceof ICallbackEventHandler) |
|
249 | + if ($callbackHandler instanceof ICallbackEventHandler) |
|
250 | 250 | { |
251 | 251 | $param = $this->getCallbackEventParameter(); |
252 | 252 | $result = new TCallbackEventParameter($this->getResponse(), $param); |
@@ -271,11 +271,11 @@ discard block |
||
271 | 271 | */ |
272 | 272 | public function getCallbackEventTarget() |
273 | 273 | { |
274 | - if($this->_callbackEventTarget===null) |
|
274 | + if ($this->_callbackEventTarget === null) |
|
275 | 275 | { |
276 | - $eventTarget=$this->getRequest()->itemAt(TPage::FIELD_CALLBACK_TARGET); |
|
277 | - if(!empty($eventTarget)) |
|
278 | - $this->_callbackEventTarget=$this->getPage()->findControl($eventTarget); |
|
276 | + $eventTarget = $this->getRequest()->itemAt(TPage::FIELD_CALLBACK_TARGET); |
|
277 | + if (!empty($eventTarget)) |
|
278 | + $this->_callbackEventTarget = $this->getPage()->findControl($eventTarget); |
|
279 | 279 | } |
280 | 280 | return $this->_callbackEventTarget; |
281 | 281 | } |
@@ -286,7 +286,7 @@ discard block |
||
286 | 286 | */ |
287 | 287 | public function setCallbackEventTarget(TControl $control) |
288 | 288 | { |
289 | - $this->_callbackEventTarget=$control; |
|
289 | + $this->_callbackEventTarget = $control; |
|
290 | 290 | } |
291 | 291 | |
292 | 292 | /** |
@@ -295,10 +295,10 @@ discard block |
||
295 | 295 | */ |
296 | 296 | public function getCallbackEventParameter() |
297 | 297 | { |
298 | - if($this->_callbackEventParameter===null) |
|
298 | + if ($this->_callbackEventParameter === null) |
|
299 | 299 | { |
300 | 300 | $param = $this->getRequest()->itemAt(TPage::FIELD_CALLBACK_PARAMETER); |
301 | - $this->_callbackEventParameter=$param; |
|
301 | + $this->_callbackEventParameter = $param; |
|
302 | 302 | } |
303 | 303 | return $this->_callbackEventParameter; |
304 | 304 | } |
@@ -308,7 +308,7 @@ discard block |
||
308 | 308 | */ |
309 | 309 | public function setCallbackEventParameter($value) |
310 | 310 | { |
311 | - $this->_callbackEventParameter=$value; |
|
311 | + $this->_callbackEventParameter = $value; |
|
312 | 312 | } |
313 | 313 | |
314 | 314 | /** |
@@ -318,7 +318,7 @@ discard block |
||
318 | 318 | */ |
319 | 319 | public function getCallbackClientHandler() |
320 | 320 | { |
321 | - if($this->_callbackClient===null) |
|
321 | + if ($this->_callbackClient === null) |
|
322 | 322 | $this->_callbackClient = new TCallbackClientScript; |
323 | 323 | return $this->_callbackClient; |
324 | 324 | } |
@@ -345,7 +345,7 @@ discard block |
||
345 | 345 | */ |
346 | 346 | protected function displayException($exception) |
347 | 347 | { |
348 | - if($this->getApplication()->getMode()===TApplication::STATE_DEBUG) |
|
348 | + if ($this->getApplication()->getMode() === TApplication::STATE_DEBUG) |
|
349 | 349 | { |
350 | 350 | $response = $this->getApplication()->getResponse(); |
351 | 351 | $trace = $this->getExceptionStackTrace($exception); |
@@ -354,7 +354,7 @@ discard block |
||
354 | 354 | $trace = TJavaScript::jsonEncode($trace); |
355 | 355 | } catch (Exception $e) { |
356 | 356 | // strip everythin not 7bit ascii |
357 | - $trace = preg_replace('/[^(\x20-\x7F)]*/','', serialize($trace)); |
|
357 | + $trace = preg_replace('/[^(\x20-\x7F)]*/', '', serialize($trace)); |
|
358 | 358 | } |
359 | 359 | |
360 | 360 | // avoid exception loop if headers have already been sent |
@@ -368,7 +368,7 @@ discard block |
||
368 | 368 | } |
369 | 369 | else |
370 | 370 | { |
371 | - error_log("Error happened while processing an existing error:\n".$exception->__toString()); |
|
371 | + error_log("Error happened while processing an existing error:\n" . $exception->__toString()); |
|
372 | 372 | header('HTTP/1.0 500 Internal Server Error', true, 500); |
373 | 373 | } |
374 | 374 | $this->getApplication()->getResponse()->flush(); |
@@ -380,24 +380,24 @@ discard block |
||
380 | 380 | */ |
381 | 381 | private function getExceptionStackTrace($exception) |
382 | 382 | { |
383 | - $data['code']=$exception->getCode() > 0 ? $exception->getCode() : 500; |
|
384 | - $data['file']=$exception->getFile(); |
|
385 | - $data['line']=$exception->getLine(); |
|
386 | - $data['trace']=$exception->getTrace(); |
|
387 | - if($exception instanceof TPhpErrorException) |
|
383 | + $data['code'] = $exception->getCode() > 0 ? $exception->getCode() : 500; |
|
384 | + $data['file'] = $exception->getFile(); |
|
385 | + $data['line'] = $exception->getLine(); |
|
386 | + $data['trace'] = $exception->getTrace(); |
|
387 | + if ($exception instanceof TPhpErrorException) |
|
388 | 388 | { |
389 | 389 | // if PHP exception, we want to show the 2nd stack level context |
390 | 390 | // because the 1st stack level is of little use (it's in error handler) |
391 | - if(isset($trace[0]) && isset($trace[0]['file']) && isset($trace[0]['line'])) |
|
391 | + if (isset($trace[0]) && isset($trace[0]['file']) && isset($trace[0]['line'])) |
|
392 | 392 | { |
393 | - $data['file']=$trace[0]['file']; |
|
394 | - $data['line']=$trace[0]['line']; |
|
393 | + $data['file'] = $trace[0]['file']; |
|
394 | + $data['line'] = $trace[0]['line']; |
|
395 | 395 | } |
396 | 396 | } |
397 | - $data['type']=get_class($exception); |
|
398 | - $data['message']=$exception->getMessage(); |
|
399 | - $data['version']=$_SERVER['SERVER_SOFTWARE'].' '.Prado::getVersion(); |
|
400 | - $data['time']=@strftime('%Y-%m-%d %H:%M',time()); |
|
397 | + $data['type'] = get_class($exception); |
|
398 | + $data['message'] = $exception->getMessage(); |
|
399 | + $data['version'] = $_SERVER['SERVER_SOFTWARE'] . ' ' . Prado::getVersion(); |
|
400 | + $data['time'] = @strftime('%Y-%m-%d %H:%M', time()); |
|
401 | 401 | return $data; |
402 | 402 | } |
403 | 403 | } |
@@ -115,8 +115,9 @@ discard block |
||
115 | 115 | public function registerControlToRender($control,$writer) |
116 | 116 | { |
117 | 117 | $id = $control->getUniqueID(); |
118 | - if(!isset($this->_controlsToRender[$id])) |
|
119 | - $this->_controlsToRender[$id] = array($control,$writer); |
|
118 | + if(!isset($this->_controlsToRender[$id])) { |
|
119 | + $this->_controlsToRender[$id] = array($control,$writer); |
|
120 | + } |
|
120 | 121 | } |
121 | 122 | |
122 | 123 | /** |
@@ -134,10 +135,11 @@ discard block |
||
134 | 135 | public function renderCallbackResponse($writer) |
135 | 136 | { |
136 | 137 | Prado::trace("ActivePage renderCallbackResponse()",'System.Web.UI.ActiveControls.TActivePageAdapter'); |
137 | - if(($url = $this->getResponse()->getAdapter()->getRedirectedUrl())===null) |
|
138 | - $this->renderResponse($writer); |
|
139 | - else |
|
140 | - $this->redirect($url); |
|
138 | + if(($url = $this->getResponse()->getAdapter()->getRedirectedUrl())===null) { |
|
139 | + $this->renderResponse($writer); |
|
140 | + } else { |
|
141 | + $this->redirect($url); |
|
142 | + } |
|
141 | 143 | } |
142 | 144 | |
143 | 145 | /** |
@@ -159,8 +161,9 @@ discard block |
||
159 | 161 | { |
160 | 162 | Prado::trace("ActivePage renderResponse()",'System.Web.UI.ActiveControls.TActivePageAdapter'); |
161 | 163 | //renders all the defered render() calls. |
162 | - foreach($this->_controlsToRender as $rid => $forRender) |
|
163 | - $forRender[0]->render($forRender[1]); |
|
164 | + foreach($this->_controlsToRender as $rid => $forRender) { |
|
165 | + $forRender[0]->render($forRender[1]); |
|
166 | + } |
|
164 | 167 | |
165 | 168 | $response = $this->getResponse(); |
166 | 169 | |
@@ -207,23 +210,27 @@ discard block |
||
207 | 210 | |
208 | 211 | // collect all stylesheet file references |
209 | 212 | $stylesheets = $cs->getStyleSheetUrls(); |
210 | - if (count($stylesheets)>0) |
|
211 | - $this->appendContentPart($response, self::CALLBACK_STYLESHEETLIST_HEADER, TJavaScript::jsonEncode($stylesheets)); |
|
213 | + if (count($stylesheets)>0) { |
|
214 | + $this->appendContentPart($response, self::CALLBACK_STYLESHEETLIST_HEADER, TJavaScript::jsonEncode($stylesheets)); |
|
215 | + } |
|
212 | 216 | |
213 | 217 | // collect all stylesheet snippets references |
214 | 218 | $stylesheets = $cs->getStyleSheetCodes(); |
215 | - if (count($stylesheets)>0) |
|
216 | - $this->appendContentPart($response, self::CALLBACK_STYLESHEET_HEADER, TJavaScript::jsonEncode($stylesheets)); |
|
219 | + if (count($stylesheets)>0) { |
|
220 | + $this->appendContentPart($response, self::CALLBACK_STYLESHEET_HEADER, TJavaScript::jsonEncode($stylesheets)); |
|
221 | + } |
|
217 | 222 | |
218 | 223 | // collect all script file references |
219 | 224 | $scripts = $cs->getScriptUrls(); |
220 | - if (count($scripts)>0) |
|
221 | - $this->appendContentPart($response, self::CALLBACK_SCRIPTLIST_HEADER, TJavaScript::jsonEncode($scripts)); |
|
225 | + if (count($scripts)>0) { |
|
226 | + $this->appendContentPart($response, self::CALLBACK_SCRIPTLIST_HEADER, TJavaScript::jsonEncode($scripts)); |
|
227 | + } |
|
222 | 228 | |
223 | 229 | // collect all hidden field references |
224 | 230 | $fields = $cs->getHiddenFields(); |
225 | - if (count($fields)>0) |
|
226 | - $this->appendContentPart($response, self::CALLBACK_HIDDENFIELDLIST_HEADER, TJavaScript::jsonEncode($fields)); |
|
231 | + if (count($fields)>0) { |
|
232 | + $this->appendContentPart($response, self::CALLBACK_HIDDENFIELDLIST_HEADER, TJavaScript::jsonEncode($fields)); |
|
233 | + } |
|
227 | 234 | } |
228 | 235 | |
229 | 236 | /** |
@@ -251,14 +258,12 @@ discard block |
||
251 | 258 | $param = $this->getCallbackEventParameter(); |
252 | 259 | $result = new TCallbackEventParameter($this->getResponse(), $param); |
253 | 260 | $callbackHandler->raiseCallbackEvent($result); |
254 | - } |
|
255 | - else |
|
261 | + } else |
|
256 | 262 | { |
257 | 263 | throw new TInvalidCallbackException( |
258 | 264 | 'callback_invalid_handler', $callbackHandler->getUniqueID()); |
259 | 265 | } |
260 | - } |
|
261 | - else |
|
266 | + } else |
|
262 | 267 | { |
263 | 268 | $target = $this->getRequest()->itemAt(TPage::FIELD_CALLBACK_TARGET); |
264 | 269 | throw new TInvalidCallbackException('callback_invalid_target', $target); |
@@ -274,8 +279,9 @@ discard block |
||
274 | 279 | if($this->_callbackEventTarget===null) |
275 | 280 | { |
276 | 281 | $eventTarget=$this->getRequest()->itemAt(TPage::FIELD_CALLBACK_TARGET); |
277 | - if(!empty($eventTarget)) |
|
278 | - $this->_callbackEventTarget=$this->getPage()->findControl($eventTarget); |
|
282 | + if(!empty($eventTarget)) { |
|
283 | + $this->_callbackEventTarget=$this->getPage()->findControl($eventTarget); |
|
284 | + } |
|
279 | 285 | } |
280 | 286 | return $this->_callbackEventTarget; |
281 | 287 | } |
@@ -318,8 +324,9 @@ discard block |
||
318 | 324 | */ |
319 | 325 | public function getCallbackClientHandler() |
320 | 326 | { |
321 | - if($this->_callbackClient===null) |
|
322 | - $this->_callbackClient = new TCallbackClientScript; |
|
327 | + if($this->_callbackClient===null) { |
|
328 | + $this->_callbackClient = new TCallbackClientScript; |
|
329 | + } |
|
323 | 330 | return $this->_callbackClient; |
324 | 331 | } |
325 | 332 | } |
@@ -365,8 +372,7 @@ discard block |
||
365 | 372 | $content = $response->createHtmlWriter(); |
366 | 373 | $content->getWriter()->setBoundary(TActivePageAdapter::CALLBACK_ERROR_HEADER); |
367 | 374 | $content->write($trace); |
368 | - } |
|
369 | - else |
|
375 | + } else |
|
370 | 376 | { |
371 | 377 | error_log("Error happened while processing an existing error:\n".$exception->__toString()); |
372 | 378 | header('HTTP/1.0 500 Internal Server Error', true, 500); |
@@ -99,6 +99,7 @@ |
||
99 | 99 | * Calls the client-side static method for this control class. |
100 | 100 | * @param string static method name |
101 | 101 | * @param mixed method parmaeter |
102 | + * @param string $func |
|
102 | 103 | */ |
103 | 104 | protected function callClientFunction($func,$value) |
104 | 105 | { |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | { |
83 | 83 | parent::setReadOnly($value); |
84 | 84 | $value = $this->getReadOnly(); |
85 | - $this->callClientFunction('setReadOnly',$value); |
|
85 | + $this->callClientFunction('setReadOnly', $value); |
|
86 | 86 | } |
87 | 87 | |
88 | 88 | /** |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | { |
93 | 93 | parent::setRating($value); |
94 | 94 | $value = $this->getRating(); |
95 | - $this->callClientFunction('setRating',$value); |
|
95 | + $this->callClientFunction('setRating', $value); |
|
96 | 96 | } |
97 | 97 | |
98 | 98 | /** |
@@ -100,13 +100,13 @@ discard block |
||
100 | 100 | * @param string static method name |
101 | 101 | * @param mixed method parmaeter |
102 | 102 | */ |
103 | - protected function callClientFunction($func,$value) |
|
103 | + protected function callClientFunction($func, $value) |
|
104 | 104 | { |
105 | - if($this->getActiveControl()->canUpdateClientSide()) |
|
105 | + if ($this->getActiveControl()->canUpdateClientSide()) |
|
106 | 106 | { |
107 | 107 | $client = $this->getPage()->getCallbackClient(); |
108 | - $code = 'Prado.Registry[\''.$this->ClientID.'\'].'.$func.'('.$value.')'; |
|
109 | - $client->evaluateScript($code,array($value)); |
|
108 | + $code = 'Prado.Registry[\'' . $this->ClientID . '\'].' . $func . '(' . $value . ')'; |
|
109 | + $client->evaluateScript($code, array($value)); |
|
110 | 110 | } |
111 | 111 | } |
112 | 112 | |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | { |
118 | 118 | parent::setCaption($value); |
119 | 119 | // if it's an active control, this should not be needed. |
120 | - $this->callClientFunction('setCaption',$value); |
|
120 | + $this->callClientFunction('setCaption', $value); |
|
121 | 121 | } |
122 | 122 | |
123 | 123 | /** |
@@ -111,6 +111,7 @@ discard block |
||
111 | 111 | * method, be sure to call the parent implementation so that the event |
112 | 112 | * handler can be invoked. |
113 | 113 | * @param TActiveTableCellEventParameter event parameter to be passed to the event handlers |
114 | + * @param TActiveTableCellEventParameter $param |
|
114 | 115 | */ |
115 | 116 | public function onCellSelected($param) |
116 | 117 | { |
@@ -232,6 +233,7 @@ discard block |
||
232 | 233 | |
233 | 234 | /** |
234 | 235 | * Creates a new TActiveTableRowEventParameter. |
236 | + * @param THttpResponse $response |
|
235 | 237 | */ |
236 | 238 | public function __construct($response, $parameter, $index=-1) |
237 | 239 | { |
@@ -53,8 +53,8 @@ discard block |
||
53 | 53 | { |
54 | 54 | |
55 | 55 | /** |
56 | - * @var TTable parent row control containing the cell |
|
57 | - */ |
|
56 | + * @var TTable parent row control containing the cell |
|
57 | + */ |
|
58 | 58 | private $_row; |
59 | 59 | |
60 | 60 | /** |
@@ -226,8 +226,8 @@ discard block |
||
226 | 226 | { |
227 | 227 | |
228 | 228 | /** |
229 | - * @var integer the zero-based index of the cell. |
|
230 | - */ |
|
229 | + * @var integer the zero-based index of the cell. |
|
230 | + */ |
|
231 | 231 | private $_selectedCellIndex = -1; |
232 | 232 | |
233 | 233 | /** |
@@ -127,8 +127,9 @@ discard block |
||
127 | 127 | { |
128 | 128 | parent::addAttributesToRender($writer); |
129 | 129 | $writer->addAttribute('id', $this->getClientID()); |
130 | - if ($this->hasEventHandler('OnCellSelected')) |
|
131 | - $this->getActiveControl()->registerCallbackClientScript($this->getClientClassName(), $this->getPostBackOptions()); |
|
130 | + if ($this->hasEventHandler('OnCellSelected')) { |
|
131 | + $this->getActiveControl()->registerCallbackClientScript($this->getClientClassName(), $this->getPostBackOptions()); |
|
132 | + } |
|
132 | 133 | } |
133 | 134 | |
134 | 135 | /** |
@@ -143,17 +144,18 @@ discard block |
||
143 | 144 | if ($this->getHasPreRendered()) |
144 | 145 | { |
145 | 146 | parent::render($writer); |
146 | - if ($this->getActiveControl()->canUpdateClientSide()) |
|
147 | - $this->getPage()->getCallbackClient()->replaceContent($this, $writer); |
|
148 | - } |
|
149 | - else { |
|
147 | + if ($this->getActiveControl()->canUpdateClientSide()) { |
|
148 | + $this->getPage()->getCallbackClient()->replaceContent($this, $writer); |
|
149 | + } |
|
150 | + } else { |
|
150 | 151 | $this->getPage()->getAdapter()->registerControlToRender($this, $writer); |
151 | 152 | // If we update a TActiveTableCell on callback, we shouldn't update all childs, |
152 | 153 | // because the whole content will be replaced by the parent. |
153 | 154 | if ($this->getHasControls()) |
154 | 155 | { |
155 | - foreach ($this->findControlsByType('IActiveControl', false) as $control) |
|
156 | - $control->getActiveControl()->setEnableUpdate(false); |
|
156 | + foreach ($this->findControlsByType('IActiveControl', false) as $control) { |
|
157 | + $control->getActiveControl()->setEnableUpdate(false); |
|
158 | + } |
|
157 | 159 | } |
158 | 160 | } |
159 | 161 | } |
@@ -178,8 +180,9 @@ discard block |
||
178 | 180 | */ |
179 | 181 | public function getCellIndex() |
180 | 182 | { |
181 | - foreach ($this->getRow()->getCells() as $key => $row) |
|
182 | - if ($row == $this) return $key; |
|
183 | + foreach ($this->getRow()->getCells() as $key => $row) { |
|
184 | + if ($row == $this) return $key; |
|
185 | + } |
|
183 | 186 | throw new TConfigurationException('tactivetablecell_control_notincollection', get_class($this), $this->getUniqueID()); |
184 | 187 | } |
185 | 188 | |
@@ -197,8 +200,11 @@ discard block |
||
197 | 200 | { |
198 | 201 | $row = $row->getParent(); |
199 | 202 | } |
200 | - if ($row instanceof TTableRow) $this->_row = $row; |
|
201 | - else throw new TConfigurationException('tactivetablecell_control_outoftable', get_class($this), $this->getUniqueID()); |
|
203 | + if ($row instanceof TTableRow) { |
|
204 | + $this->_row = $row; |
|
205 | + } else { |
|
206 | + throw new TConfigurationException('tactivetablecell_control_outoftable', get_class($this), $this->getUniqueID()); |
|
207 | + } |
|
202 | 208 | } |
203 | 209 | return $this->_row; |
204 | 210 | } |
@@ -251,7 +251,7 @@ |
||
251 | 251 | /** |
252 | 252 | * Creates a new TActiveTableRowEventParameter. |
253 | 253 | */ |
254 | - public function __construct($response, $parameter, $index=-1) |
|
254 | + public function __construct($response, $parameter, $index = -1) |
|
255 | 255 | { |
256 | 256 | parent::__construct($response, $parameter); |
257 | 257 | $this->_selectedRowIndex = $index; |