@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | { |
31 | 31 | $str=''; |
32 | 32 | foreach($files as $file) |
33 | - $str.= self::renderScriptFile($file); |
|
33 | + $str.=self::renderScriptFile($file); |
|
34 | 34 | return $str; |
35 | 35 | } |
36 | 36 | |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | public static function renderScriptBlocks($scripts) |
53 | 53 | { |
54 | 54 | if(count($scripts)) |
55 | - return "<script type=\"text/javascript\">\n/*<![CDATA[*/\n".implode("\n",$scripts)."\n/*]]>*/\n</script>\n"; |
|
55 | + return "<script type=\"text/javascript\">\n/*<![CDATA[*/\n".implode("\n", $scripts)."\n/*]]>*/\n</script>\n"; |
|
56 | 56 | else |
57 | 57 | return ''; |
58 | 58 | } |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | public static function renderScriptBlocksCallback($scripts) |
66 | 66 | { |
67 | 67 | if(count($scripts)) |
68 | - return implode("\n",$scripts)."\n"; |
|
68 | + return implode("\n", $scripts)."\n"; |
|
69 | 69 | else |
70 | 70 | return ''; |
71 | 71 | } |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | */ |
90 | 90 | public static function quoteString($js) |
91 | 91 | { |
92 | - return self::jsonEncode($js,JSON_HEX_QUOT | JSON_HEX_APOS | JSON_HEX_TAG); |
|
92 | + return self::jsonEncode($js, JSON_HEX_QUOT | JSON_HEX_APOS | JSON_HEX_TAG); |
|
93 | 93 | } |
94 | 94 | |
95 | 95 | /** |
@@ -150,16 +150,16 @@ discard block |
||
150 | 150 | * @param boolean wether to encode empty strings too. Default to false for BC. |
151 | 151 | * @return string the encoded string |
152 | 152 | */ |
153 | - public static function encode($value,$toMap=true,$encodeEmptyStrings=false) |
|
153 | + public static function encode($value, $toMap=true, $encodeEmptyStrings=false) |
|
154 | 154 | { |
155 | 155 | if(is_string($value)) |
156 | 156 | return self::quoteString($value); |
157 | 157 | else if(is_bool($value)) |
158 | - return $value?'true':'false'; |
|
158 | + return $value ? 'true' : 'false'; |
|
159 | 159 | else if(is_array($value)) |
160 | 160 | { |
161 | 161 | $results=''; |
162 | - if(($n=count($value))>0 && array_keys($value)!==range(0,$n-1)) |
|
162 | + if(($n=count($value)) > 0 && array_keys($value)!==range(0, $n - 1)) |
|
163 | 163 | { |
164 | 164 | foreach($value as $k=>$v) |
165 | 165 | { |
@@ -167,7 +167,7 @@ discard block |
||
167 | 167 | { |
168 | 168 | if($results!=='') |
169 | 169 | $results.=','; |
170 | - $results.="'$k':".self::encode($v,$toMap,$encodeEmptyStrings); |
|
170 | + $results.="'$k':".self::encode($v, $toMap, $encodeEmptyStrings); |
|
171 | 171 | } |
172 | 172 | } |
173 | 173 | return '{'.$results.'}'; |
@@ -180,7 +180,7 @@ discard block |
||
180 | 180 | { |
181 | 181 | if($results!=='') |
182 | 182 | $results.=','; |
183 | - $results.=self::encode($v,$toMap, $encodeEmptyStrings); |
|
183 | + $results.=self::encode($v, $toMap, $encodeEmptyStrings); |
|
184 | 184 | } |
185 | 185 | } |
186 | 186 | return '['.$results.']'; |
@@ -208,10 +208,10 @@ discard block |
||
208 | 208 | } |
209 | 209 | } |
210 | 210 | else if(is_object($value)) |
211 | - if ($value instanceof TJavaScriptLiteral) |
|
211 | + if($value instanceof TJavaScriptLiteral) |
|
212 | 212 | return $value->toJavaScriptLiteral(); |
213 | 213 | else |
214 | - return self::encode(get_object_vars($value),$toMap); |
|
214 | + return self::encode(get_object_vars($value), $toMap); |
|
215 | 215 | else if($value===null) |
216 | 216 | return 'null'; |
217 | 217 | else |
@@ -223,14 +223,14 @@ discard block |
||
223 | 223 | * @param mixed variable to be encoded |
224 | 224 | * @return string encoded string |
225 | 225 | */ |
226 | - public static function jsonEncode($value, $options = 0) |
|
226 | + public static function jsonEncode($value, $options=0) |
|
227 | 227 | { |
228 | - if (($g=Prado::getApplication()->getGlobalization(false))!==null && |
|
228 | + if(($g=Prado::getApplication()->getGlobalization(false))!==null && |
|
229 | 229 | strtoupper($enc=$g->getCharset())!='UTF-8') { |
230 | 230 | self::convertToUtf8($value, $enc); |
231 | 231 | } |
232 | 232 | |
233 | - $s = @json_encode($value,$options); |
|
233 | + $s=@json_encode($value, $options); |
|
234 | 234 | self::checkJsonError(); |
235 | 235 | return $s; |
236 | 236 | } |
@@ -243,7 +243,7 @@ discard block |
||
243 | 243 | private static function convertToUtf8(&$value, $sourceEncoding) { |
244 | 244 | if(is_string($value)) |
245 | 245 | $value=iconv($sourceEncoding, 'UTF-8', $value); |
246 | - else if (is_array($value)) |
|
246 | + else if(is_array($value)) |
|
247 | 247 | { |
248 | 248 | foreach($value as &$element) |
249 | 249 | self::convertToUtf8($element, $sourceEncoding); |
@@ -258,37 +258,37 @@ discard block |
||
258 | 258 | * @param int recursion depth |
259 | 259 | * @return mixed decoded variable |
260 | 260 | */ |
261 | - public static function jsonDecode($value, $assoc = false, $depth = 512) |
|
261 | + public static function jsonDecode($value, $assoc=false, $depth=512) |
|
262 | 262 | { |
263 | - $s= @json_decode($value, $assoc, $depth); |
|
263 | + $s=@json_decode($value, $assoc, $depth); |
|
264 | 264 | self::checkJsonError(); |
265 | 265 | return $s; |
266 | 266 | } |
267 | 267 | |
268 | 268 | private static function checkJsonError() |
269 | 269 | { |
270 | - switch ($err = json_last_error()) |
|
270 | + switch($err=json_last_error()) |
|
271 | 271 | { |
272 | 272 | case JSON_ERROR_NONE: |
273 | 273 | return; |
274 | 274 | break; |
275 | 275 | case JSON_ERROR_DEPTH: |
276 | - $msg = 'Maximum stack depth exceeded'; |
|
276 | + $msg='Maximum stack depth exceeded'; |
|
277 | 277 | break; |
278 | 278 | case JSON_ERROR_STATE_MISMATCH: |
279 | - $msg = 'Underflow or the modes mismatch'; |
|
279 | + $msg='Underflow or the modes mismatch'; |
|
280 | 280 | break; |
281 | 281 | case JSON_ERROR_CTRL_CHAR: |
282 | - $msg = 'Unexpected control character found'; |
|
282 | + $msg='Unexpected control character found'; |
|
283 | 283 | break; |
284 | 284 | case JSON_ERROR_SYNTAX: |
285 | - $msg = 'Syntax error, malformed JSON'; |
|
285 | + $msg='Syntax error, malformed JSON'; |
|
286 | 286 | break; |
287 | 287 | case JSON_ERROR_UTF8: |
288 | - $msg = 'Malformed UTF-8 characters, possibly incorrectly encoded'; |
|
288 | + $msg='Malformed UTF-8 characters, possibly incorrectly encoded'; |
|
289 | 289 | break; |
290 | 290 | default: |
291 | - $msg = 'Unknown error'; |
|
291 | + $msg='Unknown error'; |
|
292 | 292 | break; |
293 | 293 | } |
294 | 294 | throw new Exception("JSON error ($err): $msg"); |
@@ -64,10 +64,10 @@ discard block |
||
64 | 64 | * @return string URL |
65 | 65 | * @see parseUrl |
66 | 66 | */ |
67 | - public function constructUrl($serviceID,$serviceParam,$getItems,$encodeAmpersand,$encodeGetItems) |
|
67 | + public function constructUrl($serviceID, $serviceParam, $getItems, $encodeAmpersand, $encodeGetItems) |
|
68 | 68 | { |
69 | 69 | $url=$serviceID.'='.urlencode($serviceParam); |
70 | - $amp=$encodeAmpersand?'&':'&'; |
|
70 | + $amp=$encodeAmpersand ? '&' : '&'; |
|
71 | 71 | $request=$this->getRequest(); |
72 | 72 | if(is_array($getItems) || $getItems instanceof Traversable) |
73 | 73 | { |
@@ -103,9 +103,9 @@ discard block |
||
103 | 103 | switch($request->getUrlFormat()) |
104 | 104 | { |
105 | 105 | case THttpRequestUrlFormat::Path: |
106 | - return $request->getApplicationUrl().'/'.strtr($url,array($amp=>'/','?'=>'/','='=>$request->getUrlParamSeparator())); |
|
106 | + return $request->getApplicationUrl().'/'.strtr($url, array($amp=>'/', '?'=>'/', '='=>$request->getUrlParamSeparator())); |
|
107 | 107 | case THttpRequestUrlFormat::HiddenPath: |
108 | - return rtrim(dirname($request->getApplicationUrl()), '/').'/'.strtr($url,array($amp=>'/','?'=>'/','='=>$request->getUrlParamSeparator())); |
|
108 | + return rtrim(dirname($request->getApplicationUrl()), '/').'/'.strtr($url, array($amp=>'/', '?'=>'/', '='=>$request->getUrlParamSeparator())); |
|
109 | 109 | default: |
110 | 110 | return $request->getApplicationUrl().'?'.$url; |
111 | 111 | } |
@@ -127,24 +127,24 @@ discard block |
||
127 | 127 | public function parseUrl() |
128 | 128 | { |
129 | 129 | $request=$this->getRequest(); |
130 | - $pathInfo=trim($request->getPathInfo(),'/'); |
|
130 | + $pathInfo=trim($request->getPathInfo(), '/'); |
|
131 | 131 | if(($request->getUrlFormat()===THttpRequestUrlFormat::Path || |
132 | 132 | $request->getUrlFormat()===THttpRequestUrlFormat::HiddenPath) && |
133 | 133 | $pathInfo!=='') |
134 | 134 | { |
135 | 135 | $separator=$request->getUrlParamSeparator(); |
136 | - $paths=explode('/',$pathInfo); |
|
136 | + $paths=explode('/', $pathInfo); |
|
137 | 137 | $getVariables=array(); |
138 | 138 | foreach($paths as $path) |
139 | 139 | { |
140 | 140 | if(($path=trim($path))!=='') |
141 | 141 | { |
142 | - if(($pos=strpos($path,$separator))!==false) |
|
142 | + if(($pos=strpos($path, $separator))!==false) |
|
143 | 143 | { |
144 | - $name=substr($path,0,$pos); |
|
145 | - $value=substr($path,$pos+1); |
|
146 | - if(($pos=strpos($name,'[]'))!==false) |
|
147 | - $getVariables[substr($name,0,$pos)][]=$value; |
|
144 | + $name=substr($path, 0, $pos); |
|
145 | + $value=substr($path, $pos + 1); |
|
146 | + if(($pos=strpos($name, '[]'))!==false) |
|
147 | + $getVariables[substr($name, 0, $pos)][]=$value; |
|
148 | 148 | else |
149 | 149 | $getVariables[$name]=$value; |
150 | 150 | } |
@@ -64,13 +64,13 @@ discard block |
||
64 | 64 | */ |
65 | 65 | class THttpResponse extends TModule implements ITextWriter |
66 | 66 | { |
67 | - const DEFAULT_CONTENTTYPE = 'text/html'; |
|
68 | - const DEFAULT_CHARSET = 'UTF-8'; |
|
67 | + const DEFAULT_CONTENTTYPE='text/html'; |
|
68 | + const DEFAULT_CHARSET='UTF-8'; |
|
69 | 69 | |
70 | 70 | /** |
71 | 71 | * @var The differents defined status code by RFC 2616 {@link http://www.faqs.org/rfcs/rfc2616} |
72 | 72 | */ |
73 | - private static $HTTP_STATUS_CODES = array( |
|
73 | + private static $HTTP_STATUS_CODES=array( |
|
74 | 74 | 100 => 'Continue', 101 => 'Switching Protocols', |
75 | 75 | 200 => 'OK', 201 => 'Created', 202 => 'Accepted', 203 => 'Non-Authoritative Information', 204 => 'No Content', 205 => 'Reset Content', 206 => 'Partial Content', |
76 | 76 | 300 => 'Multiple Choices', 301 => 'Moved Permanently', 302 => 'Found', 303 => 'See Other', 304 => 'Not Modified', 305 => 'Use Proxy', 307 => 'Temporary Redirect', |
@@ -201,7 +201,7 @@ discard block |
||
201 | 201 | */ |
202 | 202 | public function setCacheControl($value) |
203 | 203 | { |
204 | - session_cache_limiter(TPropertyValue::ensureEnum($value,array('none','nocache','private','private_no_expire','public'))); |
|
204 | + session_cache_limiter(TPropertyValue::ensureEnum($value, array('none', 'nocache', 'private', 'private_no_expire', 'public'))); |
|
205 | 205 | } |
206 | 206 | |
207 | 207 | /** |
@@ -209,9 +209,9 @@ discard block |
||
209 | 209 | */ |
210 | 210 | public function setContentType($type) |
211 | 211 | { |
212 | - if ($this->_contentTypeHeaderSent) |
|
212 | + if($this->_contentTypeHeaderSent) |
|
213 | 213 | throw new Exception('Unable to alter content-type as it has been already sent'); |
214 | - $this->_contentType = $type; |
|
214 | + $this->_contentType=$type; |
|
215 | 215 | } |
216 | 216 | |
217 | 217 | /** |
@@ -235,7 +235,7 @@ discard block |
||
235 | 235 | */ |
236 | 236 | public function setCharset($charset) |
237 | 237 | { |
238 | - $this->_charset = (strToLower($charset) === 'false') ? false : (string)$charset; |
|
238 | + $this->_charset=(strToLower($charset)==='false') ? false : (string) $charset; |
|
239 | 239 | } |
240 | 240 | |
241 | 241 | /** |
@@ -276,12 +276,12 @@ discard block |
||
276 | 276 | */ |
277 | 277 | public function setStatusCode($status, $reason=null) |
278 | 278 | { |
279 | - if ($this->_httpHeaderSent) |
|
279 | + if($this->_httpHeaderSent) |
|
280 | 280 | throw new Exception('Unable to alter response as HTTP header already sent'); |
281 | 281 | $status=TPropertyValue::ensureInteger($status); |
282 | 282 | if(isset(self::$HTTP_STATUS_CODES[$status])) { |
283 | 283 | $this->_reason=self::$HTTP_STATUS_CODES[$status]; |
284 | - }else{ |
|
284 | + } else { |
|
285 | 285 | if($reason===null || $reason==='') { |
286 | 286 | throw new TInvalidDataValueException("response_status_reason_missing"); |
287 | 287 | } |
@@ -319,7 +319,7 @@ discard block |
||
319 | 319 | public function write($str) |
320 | 320 | { |
321 | 321 | // when starting output make sure we send the headers first |
322 | - if (!$this->_bufferOutput and !$this->_httpHeaderSent) |
|
322 | + if(!$this->_bufferOutput and !$this->_httpHeaderSent) |
|
323 | 323 | $this->ensureHeadersSent(); |
324 | 324 | echo $str; |
325 | 325 | } |
@@ -336,7 +336,7 @@ discard block |
||
336 | 336 | * @param integer size of file or content in bytes if already known. Defaults to 'null' means auto-detect. |
337 | 337 | * @throws TInvalidDataValueException if the file cannot be found |
338 | 338 | */ |
339 | - public function writeFile($fileName,$content=null,$mimeType=null,$headers=null,$forceDownload=true,$clientFileName=null,$fileSize=null) |
|
339 | + public function writeFile($fileName, $content=null, $mimeType=null, $headers=null, $forceDownload=true, $clientFileName=null, $fileSize=null) |
|
340 | 340 | { |
341 | 341 | static $defaultMimeTypes=array( |
342 | 342 | 'css'=>'text/css', |
@@ -356,9 +356,9 @@ discard block |
||
356 | 356 | $mimeType='text/plain'; |
357 | 357 | if(function_exists('mime_content_type')) |
358 | 358 | $mimeType=mime_content_type($fileName); |
359 | - else if(($ext=strrchr($fileName,'.'))!==false) |
|
359 | + else if(($ext=strrchr($fileName, '.'))!==false) |
|
360 | 360 | { |
361 | - $ext=substr($ext,1); |
|
361 | + $ext=substr($ext, 1); |
|
362 | 362 | if(isset($defaultMimeTypes[$ext])) |
363 | 363 | $mimeType=$defaultMimeTypes[$ext]; |
364 | 364 | } |
@@ -370,7 +370,7 @@ discard block |
||
370 | 370 | $clientFileName=basename($clientFileName); |
371 | 371 | |
372 | 372 | if($fileSize===null || $fileSize < 0) |
373 | - $fileSize = ($content===null?filesize($fileName):strlen($content)); |
|
373 | + $fileSize=($content===null ? filesize($fileName) : strlen($content)); |
|
374 | 374 | |
375 | 375 | $this->sendHttpHeader(); |
376 | 376 | if(is_array($headers)) |
@@ -384,11 +384,11 @@ discard block |
||
384 | 384 | header('Expires: 0'); |
385 | 385 | header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); |
386 | 386 | header("Content-Type: $mimeType"); |
387 | - $this->_contentTypeHeaderSent = true; |
|
387 | + $this->_contentTypeHeaderSent=true; |
|
388 | 388 | } |
389 | 389 | |
390 | 390 | header('Content-Length: '.$fileSize); |
391 | - header("Content-Disposition: " . ($forceDownload ? 'attachment' : 'inline') . "; filename=\"$clientFileName\""); |
|
391 | + header("Content-Disposition: ".($forceDownload ? 'attachment' : 'inline')."; filename=\"$clientFileName\""); |
|
392 | 392 | header('Content-Transfer-Encoding: binary'); |
393 | 393 | if($content===null) |
394 | 394 | readfile($fileName); |
@@ -428,11 +428,11 @@ discard block |
||
428 | 428 | |
429 | 429 | if($url[0]==='/') |
430 | 430 | $url=$this->getRequest()->getBaseUrl().$url; |
431 | - if ($this->_status >= 300 && $this->_status < 400) |
|
431 | + if($this->_status >= 300 && $this->_status < 400) |
|
432 | 432 | // The status code has been modified to a valid redirection status, send it |
433 | - header('Location: '.str_replace('&','&',$url), true, $this->_status); |
|
433 | + header('Location: '.str_replace('&', '&', $url), true, $this->_status); |
|
434 | 434 | else |
435 | - header('Location: '.str_replace('&','&',$url)); |
|
435 | + header('Location: '.str_replace('&', '&', $url)); |
|
436 | 436 | |
437 | 437 | if(!$this->getApplication()->getRequestCompleted()) |
438 | 438 | $this->getApplication()->onEndRequest(); |
@@ -453,7 +453,7 @@ discard block |
||
453 | 453 | /** |
454 | 454 | * Flush the response contents and headers. |
455 | 455 | */ |
456 | - public function flush($continueBuffering = true) |
|
456 | + public function flush($continueBuffering=true) |
|
457 | 457 | { |
458 | 458 | if($this->getHasAdapter()) |
459 | 459 | $this->_adapter->flushContent($continueBuffering); |
@@ -475,18 +475,18 @@ discard block |
||
475 | 475 | * This method is used internally. Please use {@link flush} instead. |
476 | 476 | * @param boolean whether to continue buffering after flush if buffering was active |
477 | 477 | */ |
478 | - public function flushContent($continueBuffering = true) |
|
478 | + public function flushContent($continueBuffering=true) |
|
479 | 479 | { |
480 | - Prado::trace("Flushing output",'System.Web.THttpResponse'); |
|
480 | + Prado::trace("Flushing output", 'System.Web.THttpResponse'); |
|
481 | 481 | $this->ensureHeadersSent(); |
482 | 482 | if($this->_bufferOutput) |
483 | 483 | { |
484 | 484 | // avoid forced send of http headers (ob_flush() does that) if there's no output yet |
485 | - if (ob_get_length()>0) |
|
485 | + if(ob_get_length() > 0) |
|
486 | 486 | { |
487 | - if (!$continueBuffering) |
|
487 | + if(!$continueBuffering) |
|
488 | 488 | { |
489 | - $this->_bufferOutput = false; |
|
489 | + $this->_bufferOutput=false; |
|
490 | 490 | ob_end_flush(); |
491 | 491 | } |
492 | 492 | else |
@@ -503,7 +503,7 @@ discard block |
||
503 | 503 | */ |
504 | 504 | protected function ensureHttpHeaderSent() |
505 | 505 | { |
506 | - if (!$this->_httpHeaderSent) |
|
506 | + if(!$this->_httpHeaderSent) |
|
507 | 507 | $this->sendHttpHeader(); |
508 | 508 | } |
509 | 509 | |
@@ -513,15 +513,15 @@ discard block |
||
513 | 513 | protected function sendHttpHeader() |
514 | 514 | { |
515 | 515 | $protocol=$this->getRequest()->getHttpProtocolVersion(); |
516 | - if($this->getRequest()->getHttpProtocolVersion() === null) |
|
516 | + if($this->getRequest()->getHttpProtocolVersion()===null) |
|
517 | 517 | $protocol='HTTP/1.1'; |
518 | 518 | |
519 | - $phpSapiName = substr(php_sapi_name(), 0, 3); |
|
520 | - $cgi = $phpSapiName == 'cgi' || $phpSapiName == 'fpm'; |
|
519 | + $phpSapiName=substr(php_sapi_name(), 0, 3); |
|
520 | + $cgi=$phpSapiName=='cgi' || $phpSapiName=='fpm'; |
|
521 | 521 | |
522 | 522 | header(($cgi ? 'Status:' : $protocol).' '.$this->_status.' '.$this->_reason, true, TPropertyValue::ensureInteger($this->_status)); |
523 | 523 | |
524 | - $this->_httpHeaderSent = true; |
|
524 | + $this->_httpHeaderSent=true; |
|
525 | 525 | } |
526 | 526 | |
527 | 527 | /** |
@@ -529,7 +529,7 @@ discard block |
||
529 | 529 | */ |
530 | 530 | protected function ensureContentTypeHeaderSent() |
531 | 531 | { |
532 | - if (!$this->_contentTypeHeaderSent) |
|
532 | + if(!$this->_contentTypeHeaderSent) |
|
533 | 533 | $this->sendContentTypeHeader(); |
534 | 534 | } |
535 | 535 | |
@@ -538,9 +538,9 @@ discard block |
||
538 | 538 | */ |
539 | 539 | protected function sendContentTypeHeader() |
540 | 540 | { |
541 | - $contentType=$this->_contentType===null?self::DEFAULT_CONTENTTYPE:$this->_contentType; |
|
541 | + $contentType=$this->_contentType===null ? self::DEFAULT_CONTENTTYPE : $this->_contentType; |
|
542 | 542 | $charset=$this->getCharset(); |
543 | - if($charset === false) { |
|
543 | + if($charset===false) { |
|
544 | 544 | $this->appendHeader('Content-Type: '.$contentType); |
545 | 545 | return; |
546 | 546 | } |
@@ -548,10 +548,10 @@ discard block |
||
548 | 548 | if($charset==='' && ($globalization=$this->getApplication()->getGlobalization(false))!==null) |
549 | 549 | $charset=$globalization->getCharset(); |
550 | 550 | |
551 | - if($charset==='') $charset = self::DEFAULT_CHARSET; |
|
551 | + if($charset==='') $charset=self::DEFAULT_CHARSET; |
|
552 | 552 | $this->appendHeader('Content-Type: '.$contentType.';charset='.$charset); |
553 | 553 | |
554 | - $this->_contentTypeHeaderSent = true; |
|
554 | + $this->_contentTypeHeaderSent=true; |
|
555 | 555 | } |
556 | 556 | |
557 | 557 | /** |
@@ -562,8 +562,8 @@ discard block |
||
562 | 562 | */ |
563 | 563 | public function getContents() |
564 | 564 | { |
565 | - Prado::trace("Retrieving output",'System.Web.THttpResponse'); |
|
566 | - return $this->_bufferOutput?ob_get_contents():''; |
|
565 | + Prado::trace("Retrieving output", 'System.Web.THttpResponse'); |
|
566 | + return $this->_bufferOutput ? ob_get_contents() : ''; |
|
567 | 567 | } |
568 | 568 | |
569 | 569 | /** |
@@ -573,7 +573,7 @@ discard block |
||
573 | 573 | { |
574 | 574 | if($this->_bufferOutput) |
575 | 575 | ob_clean(); |
576 | - Prado::trace("Clearing output",'System.Web.THttpResponse'); |
|
576 | + Prado::trace("Clearing output", 'System.Web.THttpResponse'); |
|
577 | 577 | } |
578 | 578 | |
579 | 579 | /** |
@@ -582,19 +582,19 @@ discard block |
||
582 | 582 | */ |
583 | 583 | public function getHeaders($case=null) |
584 | 584 | { |
585 | - $result = array(); |
|
586 | - $headers = headers_list(); |
|
585 | + $result=array(); |
|
586 | + $headers=headers_list(); |
|
587 | 587 | foreach($headers as $header) { |
588 | - $tmp = explode(':', $header); |
|
589 | - $key = trim(array_shift($tmp)); |
|
590 | - $value = trim(implode(':', $tmp)); |
|
588 | + $tmp=explode(':', $header); |
|
589 | + $key=trim(array_shift($tmp)); |
|
590 | + $value=trim(implode(':', $tmp)); |
|
591 | 591 | if(isset($result[$key])) |
592 | - $result[$key] .= ', ' . $value; |
|
592 | + $result[$key].=', '.$value; |
|
593 | 593 | else |
594 | - $result[$key] = $value; |
|
594 | + $result[$key]=$value; |
|
595 | 595 | } |
596 | 596 | |
597 | - if($case !== null) |
|
597 | + if($case!==null) |
|
598 | 598 | return array_change_key_case($result, $case); |
599 | 599 | |
600 | 600 | return $result; |
@@ -607,7 +607,7 @@ discard block |
||
607 | 607 | */ |
608 | 608 | public function appendHeader($value, $replace=true) |
609 | 609 | { |
610 | - Prado::trace("Sending header '$value'",'System.Web.THttpResponse'); |
|
610 | + Prado::trace("Sending header '$value'", 'System.Web.THttpResponse'); |
|
611 | 611 | header($value, $replace); |
612 | 612 | } |
613 | 613 | |
@@ -620,9 +620,9 @@ discard block |
||
620 | 620 | * @param string The extra headers. It's used when the message parameter is set to 1. This message type uses the same internal function as mail() does. |
621 | 621 | * @see http://us2.php.net/manual/en/function.error-log.php |
622 | 622 | */ |
623 | - public function appendLog($message,$messageType=0,$destination='',$extraHeaders='') |
|
623 | + public function appendLog($message, $messageType=0, $destination='', $extraHeaders='') |
|
624 | 624 | { |
625 | - error_log($message,$messageType,$destination,$extraHeaders); |
|
625 | + error_log($message, $messageType, $destination, $extraHeaders); |
|
626 | 626 | } |
627 | 627 | |
628 | 628 | /** |
@@ -71,7 +71,7 @@ |
||
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 |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | if(is_array($config)) |
78 | 78 | { |
79 | 79 | foreach($config['json'] as $id => $json) |
80 | - $this->_services[$id] = $json; |
|
80 | + $this->_services[$id]=$json; |
|
81 | 81 | } |
82 | 82 | } |
83 | 83 | else |
@@ -109,14 +109,14 @@ discard block |
||
109 | 109 | $service=Prado::createComponent($serviceConfig['class']); |
110 | 110 | if($service instanceof TJsonResponse) |
111 | 111 | { |
112 | - $properties = isset($serviceConfig['properties'])?$serviceConfig['properties']:array(); |
|
113 | - $this->createJsonResponse($service,$properties,$serviceConfig); |
|
112 | + $properties=isset($serviceConfig['properties']) ? $serviceConfig['properties'] : array(); |
|
113 | + $this->createJsonResponse($service, $properties, $serviceConfig); |
|
114 | 114 | } |
115 | 115 | else |
116 | - throw new TConfigurationException('jsonservice_response_type_invalid',$id); |
|
116 | + throw new TConfigurationException('jsonservice_response_type_invalid', $id); |
|
117 | 117 | } |
118 | 118 | else |
119 | - throw new TConfigurationException('jsonservice_class_required',$id); |
|
119 | + throw new TConfigurationException('jsonservice_class_required', $id); |
|
120 | 120 | } |
121 | 121 | else |
122 | 122 | { |
@@ -125,33 +125,33 @@ discard block |
||
125 | 125 | { |
126 | 126 | $service=Prado::createComponent($class); |
127 | 127 | if($service instanceof TJsonResponse) |
128 | - $this->createJsonResponse($service,$properties,$serviceConfig); |
|
128 | + $this->createJsonResponse($service, $properties, $serviceConfig); |
|
129 | 129 | else |
130 | - throw new TConfigurationException('jsonservice_response_type_invalid',$id); |
|
130 | + throw new TConfigurationException('jsonservice_response_type_invalid', $id); |
|
131 | 131 | } |
132 | 132 | else |
133 | - throw new TConfigurationException('jsonservice_class_required',$id); |
|
133 | + throw new TConfigurationException('jsonservice_class_required', $id); |
|
134 | 134 | } |
135 | 135 | } |
136 | 136 | else |
137 | - throw new THttpException(404,'jsonservice_provider_unknown',$id); |
|
137 | + throw new THttpException(404, 'jsonservice_provider_unknown', $id); |
|
138 | 138 | } |
139 | 139 | |
140 | 140 | /** |
141 | 141 | * Renders content provided by TJsonResponse::getJsonContent() as |
142 | 142 | * javascript in JSON format. |
143 | 143 | */ |
144 | - protected function createJsonResponse($service,$properties,$config) |
|
144 | + protected function createJsonResponse($service, $properties, $config) |
|
145 | 145 | { |
146 | 146 | // init service properties |
147 | 147 | foreach($properties as $name=>$value) |
148 | - $service->setSubproperty($name,$value); |
|
148 | + $service->setSubproperty($name, $value); |
|
149 | 149 | $service->init($config); |
150 | 150 | |
151 | 151 | //send content if not null |
152 | 152 | if(($content=$service->getJsonContent())!==null) |
153 | 153 | { |
154 | - $response = $this->getResponse(); |
|
154 | + $response=$this->getResponse(); |
|
155 | 155 | $response->setContentType('application/json'); |
156 | 156 | $response->setCharset('UTF-8'); |
157 | 157 | //send content |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | if($cache===null || !($cache instanceof ICache)) |
111 | 111 | { |
112 | 112 | if($this->_cacheModuleID!=='') |
113 | - throw new TConfigurationException('cachepagestatepersister_cachemoduleid_invalid',$this->_cacheModuleID); |
|
113 | + throw new TConfigurationException('cachepagestatepersister_cachemoduleid_invalid', $this->_cacheModuleID); |
|
114 | 114 | else |
115 | 115 | throw new TConfigurationException('cachepagestatepersister_cache_required'); |
116 | 116 | } |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | */ |
134 | 134 | public function setCacheTimeout($value) |
135 | 135 | { |
136 | - if(($value=TPropertyValue::ensureInteger($value))>=0) |
|
136 | + if(($value=TPropertyValue::ensureInteger($value)) >= 0) |
|
137 | 137 | $this->_timeout=$value; |
138 | 138 | else |
139 | 139 | throw new TInvalidDataValueException('cachepagestatepersister_timeout_invalid'); |
@@ -173,10 +173,10 @@ discard block |
||
173 | 173 | */ |
174 | 174 | public function save($data) |
175 | 175 | { |
176 | - $timestamp=(string)microtime(true); |
|
176 | + $timestamp=(string) microtime(true); |
|
177 | 177 | $key=$this->calculateKey($timestamp); |
178 | - $this->getCache()->add($key,$data,$this->_timeout); |
|
179 | - $this->_page->setClientState(TPageStateFormatter::serialize($this->_page,$timestamp)); |
|
178 | + $this->getCache()->add($key, $data, $this->_timeout); |
|
179 | + $this->_page->setClientState(TPageStateFormatter::serialize($this->_page, $timestamp)); |
|
180 | 180 | } |
181 | 181 | |
182 | 182 | /** |
@@ -186,13 +186,13 @@ discard block |
||
186 | 186 | */ |
187 | 187 | public function load() |
188 | 188 | { |
189 | - if(($timestamp=TPageStateFormatter::unserialize($this->_page,$this->_page->getRequestClientState()))!==null) |
|
189 | + if(($timestamp=TPageStateFormatter::unserialize($this->_page, $this->_page->getRequestClientState()))!==null) |
|
190 | 190 | { |
191 | 191 | $key=$this->calculateKey($timestamp); |
192 | 192 | if(($data=$this->getCache()->get($key))!==false) |
193 | 193 | return $data; |
194 | 194 | } |
195 | - throw new THttpException(400,'cachepagestatepersister_pagestate_corrupted'); |
|
195 | + throw new THttpException(400, 'cachepagestatepersister_pagestate_corrupted'); |
|
196 | 196 | } |
197 | 197 | } |
198 | 198 |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | */ |
69 | 69 | public function __construct() |
70 | 70 | { |
71 | - $this->_actions = new TList; |
|
71 | + $this->_actions=new TList; |
|
72 | 72 | } |
73 | 73 | |
74 | 74 | /** |
@@ -88,14 +88,14 @@ discard block |
||
88 | 88 | public function callClientFunction($function, $params=array()) |
89 | 89 | { |
90 | 90 | if(!is_array($params)) |
91 | - $params = array($params); |
|
91 | + $params=array($params); |
|
92 | 92 | |
93 | 93 | if(count($params) > 0) |
94 | 94 | { |
95 | - if ($params[0] instanceof ISurroundable) |
|
96 | - $params[0] = $params[0]->getSurroundingTagID(); |
|
95 | + if($params[0] instanceof ISurroundable) |
|
96 | + $params[0]=$params[0]->getSurroundingTagID(); |
|
97 | 97 | elseif($params[0] instanceof TControl) |
98 | - $params[0] = $params[0]->getClientID(); |
|
98 | + $params[0]=$params[0]->getClientID(); |
|
99 | 99 | } |
100 | 100 | $this->_actions->add(array($function => $params)); |
101 | 101 | } |
@@ -108,13 +108,13 @@ discard block |
||
108 | 108 | */ |
109 | 109 | public function jQuery($element, $method, $params=array()) |
110 | 110 | { |
111 | - if ($element instanceof ISurroundable) |
|
112 | - $element = $element->getSurroundingTagID(); |
|
111 | + if($element instanceof ISurroundable) |
|
112 | + $element=$element->getSurroundingTagID(); |
|
113 | 113 | elseif($element instanceof TControl) |
114 | - $element = $element->getClientID(); |
|
114 | + $element=$element->getClientID(); |
|
115 | 115 | |
116 | 116 | if(!is_array($params)) |
117 | - $params = array($params); |
|
117 | + $params=array($params); |
|
118 | 118 | |
119 | 119 | $this->_actions->add(array('Prado.Element.j' => array($element, $method, $params))); |
120 | 120 | } |
@@ -147,14 +147,14 @@ discard block |
||
147 | 147 | */ |
148 | 148 | public function select($control, $method='Value', $value=null, $type=null) |
149 | 149 | { |
150 | - $method = TPropertyValue::ensureEnum($method, |
|
150 | + $method=TPropertyValue::ensureEnum($method, |
|
151 | 151 | 'Value', 'Index', 'Clear', 'Indices', 'Values', 'All', 'Invert'); |
152 | - $type = ($type===null) ? $this->getSelectionControlType($control) : $type; |
|
153 | - $total = $this->getSelectionControlIsListType($control) ? $control->getItemCount() : 1; |
|
152 | + $type=($type===null) ? $this->getSelectionControlType($control) : $type; |
|
153 | + $total=$this->getSelectionControlIsListType($control) ? $control->getItemCount() : 1; |
|
154 | 154 | |
155 | 155 | // pass the ID to avoid getting the surrounding elements (ISurroundable) |
156 | 156 | if($control instanceof TControl) |
157 | - $control = $control->getClientID(); |
|
157 | + $control=$control->getClientID(); |
|
158 | 158 | |
159 | 159 | $this->callClientFunction('Prado.Element.select', |
160 | 160 | array($control, $type.$method, $value, $total)); |
@@ -214,9 +214,9 @@ discard block |
||
214 | 214 | public function setAttribute($control, $name, $value) |
215 | 215 | { |
216 | 216 | // Attributes should be applied on Surrounding tag, except for 'disabled' attribute |
217 | - if ($control instanceof ISurroundable && strtolower($name)!=='disabled') |
|
217 | + if($control instanceof ISurroundable && strtolower($name)!=='disabled') |
|
218 | 218 | $control=$control->getSurroundingTagID(); |
219 | - $this->callClientFunction('Prado.Element.setAttribute',array($control, $name, $value)); |
|
219 | + $this->callClientFunction('Prado.Element.setAttribute', array($control, $name, $value)); |
|
220 | 220 | } |
221 | 221 | |
222 | 222 | /** |
@@ -226,25 +226,25 @@ discard block |
||
226 | 226 | */ |
227 | 227 | public function setListItems($control, $items) |
228 | 228 | { |
229 | - $options = array(); |
|
229 | + $options=array(); |
|
230 | 230 | if($control instanceof TListControl) |
231 | 231 | { |
232 | - $promptText = $control->getPromptText(); |
|
233 | - $promptValue = $control->getPromptValue(); |
|
232 | + $promptText=$control->getPromptText(); |
|
233 | + $promptValue=$control->getPromptValue(); |
|
234 | 234 | |
235 | 235 | if($promptValue==='') |
236 | - $promptValue = $promptText; |
|
236 | + $promptValue=$promptText; |
|
237 | 237 | |
238 | 238 | if($promptValue!=='') |
239 | - $options[] = array($promptText, $promptValue); |
|
239 | + $options[]=array($promptText, $promptValue); |
|
240 | 240 | } |
241 | 241 | |
242 | 242 | foreach($items as $item) |
243 | 243 | { |
244 | 244 | if($item->getHasAttributes()) |
245 | - $options[] = array($item->getText(),$item->getValue(), $item->getAttributes()->itemAt('Group')); |
|
245 | + $options[]=array($item->getText(), $item->getValue(), $item->getAttributes()->itemAt('Group')); |
|
246 | 246 | else |
247 | - $options[] = array($item->getText(),$item->getValue()); |
|
247 | + $options[]=array($item->getText(), $item->getValue()); |
|
248 | 248 | } |
249 | 249 | $this->callClientFunction('Prado.Element.setOptions', array($control, $options)); |
250 | 250 | } |
@@ -422,16 +422,16 @@ discard block |
||
422 | 422 | { |
423 | 423 | if($content instanceof TControl) |
424 | 424 | { |
425 | - $boundary = $this->getRenderedContentBoundary($content); |
|
426 | - $content = null; |
|
425 | + $boundary=$this->getRenderedContentBoundary($content); |
|
426 | + $content=null; |
|
427 | 427 | } |
428 | 428 | else if($content instanceof THtmlWriter) |
429 | 429 | { |
430 | - $boundary = $this->getResponseContentBoundary($content); |
|
431 | - $content = null; |
|
430 | + $boundary=$this->getResponseContentBoundary($content); |
|
431 | + $content=null; |
|
432 | 432 | } |
433 | 433 | else |
434 | - $boundary = null; |
|
434 | + $boundary=null; |
|
435 | 435 | |
436 | 436 | $this->callClientFunction('Prado.Element.replace', array($element, $content, $boundary, $self)); |
437 | 437 | } |
@@ -456,11 +456,11 @@ discard block |
||
456 | 456 | { |
457 | 457 | if($writer instanceof THtmlWriter) |
458 | 458 | { |
459 | - $boundary = $this->getResponseContentBoundary($writer); |
|
460 | - $content = null; |
|
459 | + $boundary=$this->getResponseContentBoundary($writer); |
|
460 | + $content=null; |
|
461 | 461 | } else { |
462 | - $boundary = null; |
|
463 | - $content = $writer; |
|
462 | + $boundary=null; |
|
463 | + $content=$writer; |
|
464 | 464 | } |
465 | 465 | |
466 | 466 | $this->callClientFunction('Prado.Element.evaluateScript', array($content, $boundary)); |
@@ -476,11 +476,11 @@ discard block |
||
476 | 476 | { |
477 | 477 | if($content instanceof TControl) |
478 | 478 | { |
479 | - $boundary = $this->getRenderedContentBoundary($content); |
|
479 | + $boundary=$this->getRenderedContentBoundary($content); |
|
480 | 480 | } |
481 | 481 | elseif($content instanceof THtmlWriter) |
482 | 482 | { |
483 | - $boundary = $this->getResponseContentBoundary($content); |
|
483 | + $boundary=$this->getResponseContentBoundary($content); |
|
484 | 484 | } |
485 | 485 | |
486 | 486 | $this->callClientFunction('Prado.Element.appendScriptBlock', array($boundary)); |
@@ -496,8 +496,8 @@ discard block |
||
496 | 496 | */ |
497 | 497 | private function getRenderedContentBoundary($control) |
498 | 498 | { |
499 | - $writer = $this->getResponse()->createHtmlWriter(); |
|
500 | - $adapter = $control->getPage()->getAdapter(); |
|
499 | + $writer=$this->getResponse()->createHtmlWriter(); |
|
500 | + $adapter=$control->getPage()->getAdapter(); |
|
501 | 501 | $adapter->registerControlToRender($control, $writer); |
502 | 502 | return $writer->getWriter()->getBoundary(); |
503 | 503 | } |
@@ -561,7 +561,7 @@ discard block |
||
561 | 561 | */ |
562 | 562 | public function fadeTo($element, $value, $duration=500) |
563 | 563 | { |
564 | - $value = TPropertyValue::ensureFloat($value); |
|
564 | + $value=TPropertyValue::ensureFloat($value); |
|
565 | 565 | $this->visualEffect('fadeTo', $element, array($duration, $value)); |
566 | 566 | } |
567 | 567 |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | */ |
80 | 80 | public function setDecayRate($value) |
81 | 81 | { |
82 | - $decay = TPropertyValue::ensureFloat($value); |
|
82 | + $decay=TPropertyValue::ensureFloat($value); |
|
83 | 83 | if($decay < 0) |
84 | 84 | throw new TConfigurationException('callback_decay_be_not_negative', $this->getID()); |
85 | 85 | $this->setViewState('Decay', $decay); |
@@ -90,10 +90,10 @@ discard block |
||
90 | 90 | */ |
91 | 91 | protected function getTriggerOptions() |
92 | 92 | { |
93 | - $options = parent::getTriggerOptions(); |
|
94 | - $options['PropertyName'] = $this->getPropertyName(); |
|
95 | - $options['Interval'] = $this->getInterval(); |
|
96 | - $options['Decay'] = $this->getDecayRate(); |
|
93 | + $options=parent::getTriggerOptions(); |
|
94 | + $options['PropertyName']=$this->getPropertyName(); |
|
95 | + $options['Interval']=$this->getInterval(); |
|
96 | + $options['Decay']=$this->getDecayRate(); |
|
97 | 97 | return $options; |
98 | 98 | } |
99 | 99 |
@@ -41,11 +41,11 @@ discard block |
||
41 | 41 | */ |
42 | 42 | protected function renderCustomScriptFile($writer) |
43 | 43 | { |
44 | - if(($scriptUrl = $this->getScriptUrl())!=='') |
|
44 | + if(($scriptUrl=$this->getScriptUrl())!=='') |
|
45 | 45 | { |
46 | 46 | if($this->getPage()->getIsCallback()) |
47 | 47 | { |
48 | - $cs = $this->getPage()->getClientScript(); |
|
48 | + $cs=$this->getPage()->getClientScript(); |
|
49 | 49 | $uniqueid=$this->ClientID.'_custom'; |
50 | 50 | if(!$cs->isScriptFileRegistered($uniqueid)) |
51 | 51 | $cs->registerScriptFile($uniqueid, $scriptUrl); |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | { |
66 | 66 | if($this->getPage()->getIsCallback()) |
67 | 67 | { |
68 | - $extWriter= $this->getPage()->getResponse()->createHtmlWriter(); |
|
68 | + $extWriter=$this->getPage()->getResponse()->createHtmlWriter(); |
|
69 | 69 | $extWriter->write("/*<![CDATA[*/\n"); |
70 | 70 | $this->renderChildren($extWriter); |
71 | 71 | $extWriter->write("\n/*]]>*/"); |