@@ -3,13 +3,13 @@ discard block |
||
3 | 3 | //$Id: packages.php 3319 2013-09-08 20:59:44Z ctrlaltca $ |
4 | 4 | |
5 | 5 | // To make future upgrades easier |
6 | -if (!defined('PROTOTYPE_DIR')) define ('PROTOTYPE_DIR', 'prototype-1.7'); |
|
7 | -if (!defined('JQUERY_DIR')) define ('JQUERY_DIR', 'jquery'); |
|
8 | -if (!defined('BOOTSTRAP_DIR')) define ('BOOTSTRAP_DIR', 'bootstrap3'); |
|
9 | -if (!defined('SCRIPTACULOUS_DIR')) define ('SCRIPTACULOUS_DIR', 'scriptaculous-1.9.0'); |
|
6 | +if(!defined('PROTOTYPE_DIR')) define('PROTOTYPE_DIR', 'prototype-1.7'); |
|
7 | +if(!defined('JQUERY_DIR')) define('JQUERY_DIR', 'jquery'); |
|
8 | +if(!defined('BOOTSTRAP_DIR')) define('BOOTSTRAP_DIR', 'bootstrap3'); |
|
9 | +if(!defined('SCRIPTACULOUS_DIR')) define('SCRIPTACULOUS_DIR', 'scriptaculous-1.9.0'); |
|
10 | 10 | |
11 | 11 | //package names and its contents (files relative to the current directory) |
12 | -$packages = array( |
|
12 | +$packages=array( |
|
13 | 13 | // base prado scripts |
14 | 14 | 'prado' => array( |
15 | 15 | 'prado/prado.js', |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | |
116 | 116 | |
117 | 117 | //package names and their dependencies |
118 | -$dependencies = array( |
|
118 | +$dependencies=array( |
|
119 | 119 | 'jquery' => array('jquery'), |
120 | 120 | 'prado' => array('jquery', 'prado'), |
121 | 121 | 'bootstrap' => array('jquery', 'bootstrap'), |
@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | 'jqueryui' => array('jquery', 'jqueryui'), |
139 | 139 | 'prototype' => array('prototype'), |
140 | 140 | 'dragdrop' => array('prototype', 'jquery', 'prado', 'ajax', 'dragdrop'), |
141 | - 'dragdropextra' => array('prototype', 'jquery', 'prado', 'ajax', 'dragdrop','dragdropextra'), |
|
141 | + 'dragdropextra' => array('prototype', 'jquery', 'prado', 'ajax', 'dragdrop', 'dragdropextra'), |
|
142 | 142 | 'autocomplete' => array('prototype', 'jquery', 'prado', 'ajax', 'autocomplete'), |
143 | 143 | ); |
144 | 144 |
@@ -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"); |
@@ -46,29 +46,29 @@ discard block |
||
46 | 46 | */ |
47 | 47 | |
48 | 48 | class JSMin { |
49 | - const ORD_LF = 10; |
|
50 | - const ORD_SPACE = 32; |
|
49 | + const ORD_LF=10; |
|
50 | + const ORD_SPACE=32; |
|
51 | 51 | |
52 | - protected $a = ''; |
|
53 | - protected $b = ''; |
|
54 | - protected $input = ''; |
|
55 | - protected $inputIndex = 0; |
|
56 | - protected $inputLength = 0; |
|
57 | - protected $lookAhead = null; |
|
58 | - protected $output = ''; |
|
52 | + protected $a=''; |
|
53 | + protected $b=''; |
|
54 | + protected $input=''; |
|
55 | + protected $inputIndex=0; |
|
56 | + protected $inputLength=0; |
|
57 | + protected $lookAhead=null; |
|
58 | + protected $output=''; |
|
59 | 59 | |
60 | 60 | // -- Public Static Methods -------------------------------------------------- |
61 | 61 | |
62 | 62 | public static function minify($js) { |
63 | - $jsmin = new JSMin($js); |
|
63 | + $jsmin=new JSMin($js); |
|
64 | 64 | return $jsmin->min(); |
65 | 65 | } |
66 | 66 | |
67 | 67 | // -- Public Instance Methods ------------------------------------------------ |
68 | 68 | |
69 | 69 | public function __construct($input) { |
70 | - $this->input = str_replace("\r\n", "\n", $input); |
|
71 | - $this->inputLength = strlen($this->input); |
|
70 | + $this->input=str_replace("\r\n", "\n", $input); |
|
71 | + $this->inputLength=strlen($this->input); |
|
72 | 72 | } |
73 | 73 | |
74 | 74 | // -- Protected Instance Methods --------------------------------------------- |
@@ -76,80 +76,80 @@ discard block |
||
76 | 76 | protected function action($d) { |
77 | 77 | switch($d) { |
78 | 78 | case 1: |
79 | - $this->output .= $this->a; |
|
79 | + $this->output.=$this->a; |
|
80 | 80 | |
81 | 81 | case 2: |
82 | - $this->a = $this->b; |
|
82 | + $this->a=$this->b; |
|
83 | 83 | |
84 | - if ($this->a === "'" || $this->a === '"') { |
|
85 | - for (;;) { |
|
86 | - $this->output .= $this->a; |
|
87 | - $this->a = $this->get(); |
|
84 | + if($this->a==="'" || $this->a==='"') { |
|
85 | + for(;;) { |
|
86 | + $this->output.=$this->a; |
|
87 | + $this->a=$this->get(); |
|
88 | 88 | |
89 | - if ($this->a === $this->b) { |
|
89 | + if($this->a===$this->b) { |
|
90 | 90 | break; |
91 | 91 | } |
92 | 92 | |
93 | - if (ord($this->a) <= self::ORD_LF) { |
|
93 | + if(ord($this->a) <= self::ORD_LF) { |
|
94 | 94 | throw new JSMinException('Unterminated string literal.'); |
95 | 95 | } |
96 | 96 | |
97 | - if ($this->a === '\\') { |
|
98 | - $this->output .= $this->a; |
|
99 | - $this->a = $this->get(); |
|
97 | + if($this->a==='\\') { |
|
98 | + $this->output.=$this->a; |
|
99 | + $this->a=$this->get(); |
|
100 | 100 | } |
101 | 101 | } |
102 | 102 | } |
103 | 103 | |
104 | 104 | case 3: |
105 | - $this->b = $this->next(); |
|
105 | + $this->b=$this->next(); |
|
106 | 106 | |
107 | - if ($this->b === '/' && ( |
|
108 | - $this->a === '(' || $this->a === ',' || $this->a === '=' || |
|
109 | - $this->a === ':' || $this->a === '[' || $this->a === '!' || |
|
110 | - $this->a === '&' || $this->a === '|' || $this->a === '?')) { |
|
107 | + if($this->b==='/' && ( |
|
108 | + $this->a==='(' || $this->a===',' || $this->a==='=' || |
|
109 | + $this->a===':' || $this->a==='[' || $this->a==='!' || |
|
110 | + $this->a==='&' || $this->a==='|' || $this->a==='?')) { |
|
111 | 111 | |
112 | - $this->output .= $this->a . $this->b; |
|
112 | + $this->output.=$this->a.$this->b; |
|
113 | 113 | |
114 | - for (;;) { |
|
115 | - $this->a = $this->get(); |
|
114 | + for(;;) { |
|
115 | + $this->a=$this->get(); |
|
116 | 116 | |
117 | - if ($this->a === '/') { |
|
117 | + if($this->a==='/') { |
|
118 | 118 | break; |
119 | - } elseif ($this->a === '\\') { |
|
120 | - $this->output .= $this->a; |
|
121 | - $this->a = $this->get(); |
|
122 | - } elseif (ord($this->a) <= self::ORD_LF) { |
|
119 | + } elseif($this->a==='\\') { |
|
120 | + $this->output.=$this->a; |
|
121 | + $this->a=$this->get(); |
|
122 | + } elseif(ord($this->a) <= self::ORD_LF) { |
|
123 | 123 | throw new JSMinException('Unterminated regular expression '. |
124 | 124 | 'literal.'); |
125 | 125 | } |
126 | 126 | |
127 | - $this->output .= $this->a; |
|
127 | + $this->output.=$this->a; |
|
128 | 128 | } |
129 | 129 | |
130 | - $this->b = $this->next(); |
|
130 | + $this->b=$this->next(); |
|
131 | 131 | } |
132 | 132 | } |
133 | 133 | } |
134 | 134 | |
135 | 135 | protected function get() { |
136 | - $c = $this->lookAhead; |
|
137 | - $this->lookAhead = null; |
|
136 | + $c=$this->lookAhead; |
|
137 | + $this->lookAhead=null; |
|
138 | 138 | |
139 | - if ($c === null) { |
|
140 | - if ($this->inputIndex < $this->inputLength) { |
|
141 | - $c = $this->input[$this->inputIndex]; |
|
142 | - $this->inputIndex += 1; |
|
139 | + if($c===null) { |
|
140 | + if($this->inputIndex < $this->inputLength) { |
|
141 | + $c=$this->input[$this->inputIndex]; |
|
142 | + $this->inputIndex+=1; |
|
143 | 143 | } else { |
144 | - $c = null; |
|
144 | + $c=null; |
|
145 | 145 | } |
146 | 146 | } |
147 | 147 | |
148 | - if ($c === "\r") { |
|
148 | + if($c==="\r") { |
|
149 | 149 | return "\n"; |
150 | 150 | } |
151 | 151 | |
152 | - if ($c === null || $c === "\n" || ord($c) >= self::ORD_SPACE) { |
|
152 | + if($c===null || $c==="\n" || ord($c) >= self::ORD_SPACE) { |
|
153 | 153 | return $c; |
154 | 154 | } |
155 | 155 | |
@@ -157,17 +157,17 @@ discard block |
||
157 | 157 | } |
158 | 158 | |
159 | 159 | protected function isAlphaNum($c) { |
160 | - return ord($c) > 126 || $c === '\\' || preg_match('/^[\w\$]$/', $c) === 1; |
|
160 | + return ord($c) > 126 || $c==='\\' || preg_match('/^[\w\$]$/', $c)===1; |
|
161 | 161 | } |
162 | 162 | |
163 | 163 | protected function min() { |
164 | - $this->a = "\n"; |
|
164 | + $this->a="\n"; |
|
165 | 165 | $this->action(3); |
166 | 166 | |
167 | - while ($this->a !== null) { |
|
168 | - switch ($this->a) { |
|
167 | + while($this->a!==null) { |
|
168 | + switch($this->a) { |
|
169 | 169 | case ' ': |
170 | - if ($this->isAlphaNum($this->b)) { |
|
170 | + if($this->isAlphaNum($this->b)) { |
|
171 | 171 | $this->action(1); |
172 | 172 | } else { |
173 | 173 | $this->action(2); |
@@ -175,7 +175,7 @@ discard block |
||
175 | 175 | break; |
176 | 176 | |
177 | 177 | case "\n": |
178 | - switch ($this->b) { |
|
178 | + switch($this->b) { |
|
179 | 179 | case '{': |
180 | 180 | case '[': |
181 | 181 | case '(': |
@@ -189,7 +189,7 @@ discard block |
||
189 | 189 | break; |
190 | 190 | |
191 | 191 | default: |
192 | - if ($this->isAlphaNum($this->b)) { |
|
192 | + if($this->isAlphaNum($this->b)) { |
|
193 | 193 | $this->action(1); |
194 | 194 | } |
195 | 195 | else { |
@@ -199,9 +199,9 @@ discard block |
||
199 | 199 | break; |
200 | 200 | |
201 | 201 | default: |
202 | - switch ($this->b) { |
|
202 | + switch($this->b) { |
|
203 | 203 | case ' ': |
204 | - if ($this->isAlphaNum($this->a)) { |
|
204 | + if($this->isAlphaNum($this->a)) { |
|
205 | 205 | $this->action(1); |
206 | 206 | break; |
207 | 207 | } |
@@ -210,7 +210,7 @@ discard block |
||
210 | 210 | break; |
211 | 211 | |
212 | 212 | case "\n": |
213 | - switch ($this->a) { |
|
213 | + switch($this->a) { |
|
214 | 214 | case '}': |
215 | 215 | case ']': |
216 | 216 | case ')': |
@@ -222,7 +222,7 @@ discard block |
||
222 | 222 | break; |
223 | 223 | |
224 | 224 | default: |
225 | - if ($this->isAlphaNum($this->a)) { |
|
225 | + if($this->isAlphaNum($this->a)) { |
|
226 | 226 | $this->action(1); |
227 | 227 | } |
228 | 228 | else { |
@@ -242,15 +242,15 @@ discard block |
||
242 | 242 | } |
243 | 243 | |
244 | 244 | protected function next() { |
245 | - $c = $this->get(); |
|
245 | + $c=$this->get(); |
|
246 | 246 | |
247 | - if ($c === '/') { |
|
247 | + if($c==='/') { |
|
248 | 248 | switch($this->peek()) { |
249 | 249 | case '/': |
250 | - for (;;) { |
|
251 | - $c = $this->get(); |
|
250 | + for(;;) { |
|
251 | + $c=$this->get(); |
|
252 | 252 | |
253 | - if (ord($c) <= self::ORD_LF) { |
|
253 | + if(ord($c) <= self::ORD_LF) { |
|
254 | 254 | return $c; |
255 | 255 | } |
256 | 256 | } |
@@ -258,10 +258,10 @@ discard block |
||
258 | 258 | case '*': |
259 | 259 | $this->get(); |
260 | 260 | |
261 | - for (;;) { |
|
261 | + for(;;) { |
|
262 | 262 | switch($this->get()) { |
263 | 263 | case '*': |
264 | - if ($this->peek() === '/') { |
|
264 | + if($this->peek()==='/') { |
|
265 | 265 | $this->get(); |
266 | 266 | return ' '; |
267 | 267 | } |
@@ -281,7 +281,7 @@ discard block |
||
281 | 281 | } |
282 | 282 | |
283 | 283 | protected function peek() { |
284 | - $this->lookAhead = $this->get(); |
|
284 | + $this->lookAhead=$this->get(); |
|
285 | 285 | return $this->lookAhead; |
286 | 286 | } |
287 | 287 | } |
@@ -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 | /** |
@@ -66,10 +66,10 @@ discard block |
||
66 | 66 | * @package System.Web |
67 | 67 | * @since 3.0 |
68 | 68 | */ |
69 | -class THttpRequest extends TApplicationComponent implements IteratorAggregate,ArrayAccess,Countable,IModule |
|
69 | +class THttpRequest extends TApplicationComponent implements IteratorAggregate, ArrayAccess, Countable, IModule |
|
70 | 70 | { |
71 | - const CGIFIX__PATH_INFO = 1; |
|
72 | - const CGIFIX__SCRIPT_NAME = 2; |
|
71 | + const CGIFIX__PATH_INFO=1; |
|
72 | + const CGIFIX__SCRIPT_NAME=2; |
|
73 | 73 | /** |
74 | 74 | * @var TUrlManager the URL manager module |
75 | 75 | */ |
@@ -172,14 +172,14 @@ discard block |
||
172 | 172 | if(isset($_SERVER['REQUEST_URI'])) |
173 | 173 | $this->_requestUri=$_SERVER['REQUEST_URI']; |
174 | 174 | else // TBD: in this case, SCRIPT_NAME need to be escaped |
175 | - $this->_requestUri=$_SERVER['SCRIPT_NAME'].(empty($_SERVER['QUERY_STRING'])?'':'?'.$_SERVER['QUERY_STRING']); |
|
175 | + $this->_requestUri=$_SERVER['SCRIPT_NAME'].(empty($_SERVER['QUERY_STRING']) ? '' : '?'.$_SERVER['QUERY_STRING']); |
|
176 | 176 | |
177 | - if($this->_cgiFix&self::CGIFIX__PATH_INFO && isset($_SERVER['ORIG_PATH_INFO'])) |
|
177 | + if($this->_cgiFix & self::CGIFIX__PATH_INFO && isset($_SERVER['ORIG_PATH_INFO'])) |
|
178 | 178 | $this->_pathInfo=substr($_SERVER['ORIG_PATH_INFO'], strlen($_SERVER['SCRIPT_NAME'])); |
179 | 179 | elseif(isset($_SERVER['PATH_INFO'])) |
180 | 180 | $this->_pathInfo=$_SERVER['PATH_INFO']; |
181 | - else if(strpos($_SERVER['PHP_SELF'],$_SERVER['SCRIPT_NAME'])===0 && $_SERVER['PHP_SELF']!==$_SERVER['SCRIPT_NAME']) |
|
182 | - $this->_pathInfo=substr($_SERVER['PHP_SELF'],strlen($_SERVER['SCRIPT_NAME'])); |
|
181 | + else if(strpos($_SERVER['PHP_SELF'], $_SERVER['SCRIPT_NAME'])===0 && $_SERVER['PHP_SELF']!==$_SERVER['SCRIPT_NAME']) |
|
182 | + $this->_pathInfo=substr($_SERVER['PHP_SELF'], strlen($_SERVER['SCRIPT_NAME'])); |
|
183 | 183 | else |
184 | 184 | $this->_pathInfo=''; |
185 | 185 | |
@@ -206,7 +206,7 @@ discard block |
||
206 | 206 | */ |
207 | 207 | public function stripSlashes(&$data) |
208 | 208 | { |
209 | - return is_array($data)?array_map(array($this,'stripSlashes'),$data):stripslashes($data); |
|
209 | + return is_array($data) ? array_map(array($this, 'stripSlashes'), $data) : stripslashes($data); |
|
210 | 210 | } |
211 | 211 | |
212 | 212 | /** |
@@ -217,7 +217,7 @@ discard block |
||
217 | 217 | if($this->_url===null) |
218 | 218 | { |
219 | 219 | $secure=$this->getIsSecureConnection(); |
220 | - $url=$secure?'https://':'http://'; |
|
220 | + $url=$secure ? 'https://' : 'http://'; |
|
221 | 221 | if(empty($_SERVER['HTTP_HOST'])) |
222 | 222 | { |
223 | 223 | $url.=$_SERVER['SERVER_NAME']; |
@@ -240,7 +240,7 @@ discard block |
||
240 | 240 | */ |
241 | 241 | public function setEnableCache($value) |
242 | 242 | { |
243 | - $this->_enableCache = TPropertyValue::ensureBoolean($value); |
|
243 | + $this->_enableCache=TPropertyValue::ensureBoolean($value); |
|
244 | 244 | } |
245 | 245 | |
246 | 246 | /** |
@@ -264,15 +264,15 @@ discard block |
||
264 | 264 | { |
265 | 265 | if($this->getEnableCache()) |
266 | 266 | { |
267 | - $cache = $this->getApplication()->getCache(); |
|
268 | - if($cache !== null) |
|
267 | + $cache=$this->getApplication()->getCache(); |
|
268 | + if($cache!==null) |
|
269 | 269 | { |
270 | - $dependencies = null; |
|
271 | - if($this->getApplication()->getMode() !== TApplicationMode::Performance) |
|
272 | - if ($manager instanceof TUrlMapping && $fn = $manager->getConfigFile()) |
|
270 | + $dependencies=null; |
|
271 | + if($this->getApplication()->getMode()!==TApplicationMode::Performance) |
|
272 | + if($manager instanceof TUrlMapping && $fn=$manager->getConfigFile()) |
|
273 | 273 | { |
274 | - $fn = Prado::getPathOfNamespace($fn,$this->getApplication()->getConfigurationFileExt()); |
|
275 | - $dependencies = new TFileCacheDependency($fn); |
|
274 | + $fn=Prado::getPathOfNamespace($fn, $this->getApplication()->getConfigurationFileExt()); |
|
275 | + $dependencies=new TFileCacheDependency($fn); |
|
276 | 276 | } |
277 | 277 | return $cache->set($this->getCacheKey(), $manager, 0, $dependencies); |
278 | 278 | } |
@@ -288,10 +288,10 @@ discard block |
||
288 | 288 | { |
289 | 289 | if($this->getEnableCache()) |
290 | 290 | { |
291 | - $cache = $this->getApplication()->getCache(); |
|
292 | - if($cache !== null) |
|
291 | + $cache=$this->getApplication()->getCache(); |
|
292 | + if($cache!==null) |
|
293 | 293 | { |
294 | - $manager = $cache->get($this->getCacheKey()); |
|
294 | + $manager=$cache->get($this->getCacheKey()); |
|
295 | 295 | if($manager instanceof TUrlManager) |
296 | 296 | return $manager; |
297 | 297 | } |
@@ -327,7 +327,7 @@ discard block |
||
327 | 327 | { |
328 | 328 | if($this->_urlManager===null) |
329 | 329 | { |
330 | - if(($this->_urlManager = $this->loadCachedUrlManager())===null) |
|
330 | + if(($this->_urlManager=$this->loadCachedUrlManager())===null) |
|
331 | 331 | { |
332 | 332 | if(empty($this->_urlManagerID)) |
333 | 333 | { |
@@ -338,9 +338,9 @@ discard block |
||
338 | 338 | { |
339 | 339 | $this->_urlManager=$this->getApplication()->getModule($this->_urlManagerID); |
340 | 340 | if($this->_urlManager===null) |
341 | - throw new TConfigurationException('httprequest_urlmanager_inexist',$this->_urlManagerID); |
|
341 | + throw new TConfigurationException('httprequest_urlmanager_inexist', $this->_urlManagerID); |
|
342 | 342 | if(!($this->_urlManager instanceof TUrlManager)) |
343 | - throw new TConfigurationException('httprequest_urlmanager_invalid',$this->_urlManagerID); |
|
343 | + throw new TConfigurationException('httprequest_urlmanager_invalid', $this->_urlManagerID); |
|
344 | 344 | } |
345 | 345 | $this->cacheUrlManager($this->_urlManager); |
346 | 346 | } |
@@ -366,7 +366,7 @@ discard block |
||
366 | 366 | */ |
367 | 367 | public function setUrlFormat($value) |
368 | 368 | { |
369 | - $this->_urlFormat=TPropertyValue::ensureEnum($value,'THttpRequestUrlFormat'); |
|
369 | + $this->_urlFormat=TPropertyValue::ensureEnum($value, 'THttpRequestUrlFormat'); |
|
370 | 370 | } |
371 | 371 | |
372 | 372 | /** |
@@ -394,19 +394,19 @@ discard block |
||
394 | 394 | */ |
395 | 395 | public function getRequestType() |
396 | 396 | { |
397 | - return isset($_SERVER['REQUEST_METHOD'])?$_SERVER['REQUEST_METHOD']:null; |
|
397 | + return isset($_SERVER['REQUEST_METHOD']) ? $_SERVER['REQUEST_METHOD'] : null; |
|
398 | 398 | } |
399 | 399 | |
400 | 400 | /** |
401 | 401 | * @param boolean $mimetypeOnly whether to return only the mimetype (default: true) |
402 | 402 | * @return string content type (e.g. 'application/json' or 'text/html; encoding=gzip') or null if not specified |
403 | 403 | */ |
404 | - public function getContentType($mimetypeOnly = true) |
|
404 | + public function getContentType($mimetypeOnly=true) |
|
405 | 405 | { |
406 | 406 | if(!isset($_SERVER['CONTENT_TYPE'])) |
407 | 407 | return null; |
408 | 408 | |
409 | - if($mimetypeOnly === true && ($_pos = strpos(';', $_SERVER['CONTENT_TYPE'])) !== false) |
|
409 | + if($mimetypeOnly===true && ($_pos=strpos(';', $_SERVER['CONTENT_TYPE']))!==false) |
|
410 | 410 | return substr($_SERVER['CONTENT_TYPE'], 0, $_pos); |
411 | 411 | |
412 | 412 | return $_SERVER['CONTENT_TYPE']; |
@@ -417,7 +417,7 @@ discard block |
||
417 | 417 | */ |
418 | 418 | public function getIsSecureConnection() |
419 | 419 | { |
420 | - return isset($_SERVER['HTTPS']) && strcasecmp($_SERVER['HTTPS'],'off'); |
|
420 | + return isset($_SERVER['HTTPS']) && strcasecmp($_SERVER['HTTPS'], 'off'); |
|
421 | 421 | } |
422 | 422 | |
423 | 423 | /** |
@@ -433,7 +433,7 @@ discard block |
||
433 | 433 | */ |
434 | 434 | public function getQueryString() |
435 | 435 | { |
436 | - return isset($_SERVER['QUERY_STRING'])?$_SERVER['QUERY_STRING']:null; |
|
436 | + return isset($_SERVER['QUERY_STRING']) ? $_SERVER['QUERY_STRING'] : null; |
|
437 | 437 | } |
438 | 438 | |
439 | 439 | /** |
@@ -441,7 +441,7 @@ discard block |
||
441 | 441 | */ |
442 | 442 | public function getHttpProtocolVersion() |
443 | 443 | { |
444 | - return isset($_SERVER['SERVER_PROTOCOL'])?$_SERVER['SERVER_PROTOCOL']:null; |
|
444 | + return isset($_SERVER['SERVER_PROTOCOL']) ? $_SERVER['SERVER_PROTOCOL'] : null; |
|
445 | 445 | } |
446 | 446 | |
447 | 447 | /** |
@@ -452,19 +452,19 @@ discard block |
||
452 | 452 | { |
453 | 453 | static $result; |
454 | 454 | |
455 | - if($result === null && function_exists('apache_request_headers')) { |
|
456 | - $result = apache_request_headers(); |
|
455 | + if($result===null && function_exists('apache_request_headers')) { |
|
456 | + $result=apache_request_headers(); |
|
457 | 457 | } |
458 | - elseif($result === null) { |
|
459 | - $result = array(); |
|
458 | + elseif($result===null) { |
|
459 | + $result=array(); |
|
460 | 460 | foreach($_SERVER as $key=>$value) { |
461 | - if(strncasecmp($key, 'HTTP_', 5) !== 0) continue; |
|
462 | - $key = str_replace(' ','-', ucwords(strtolower(str_replace('_',' ', substr($key, 5))))); |
|
463 | - $result[$key] = $value; |
|
461 | + if(strncasecmp($key, 'HTTP_', 5)!==0) continue; |
|
462 | + $key=str_replace(' ', '-', ucwords(strtolower(str_replace('_', ' ', substr($key, 5))))); |
|
463 | + $result[$key]=$value; |
|
464 | 464 | } |
465 | 465 | } |
466 | 466 | |
467 | - if($case !== null) |
|
467 | + if($case!==null) |
|
468 | 468 | return array_change_key_case($result, $case); |
469 | 469 | |
470 | 470 | return $result; |
@@ -488,9 +488,9 @@ discard block |
||
488 | 488 | public function getBaseUrl($forceSecureConnection=null) |
489 | 489 | { |
490 | 490 | $url=$this->getUrl(); |
491 | - $scheme=($forceSecureConnection)?"https": (($forceSecureConnection === null)?$url->getScheme():'http'); |
|
491 | + $scheme=($forceSecureConnection) ? "https" : (($forceSecureConnection===null) ? $url->getScheme() : 'http'); |
|
492 | 492 | $host=$url->getHost(); |
493 | - if (($port=$url->getPort())) $host.=':'.$port; |
|
493 | + if(($port=$url->getPort())) $host.=':'.$port; |
|
494 | 494 | return $scheme.'://'.$host; |
495 | 495 | } |
496 | 496 | |
@@ -499,10 +499,10 @@ discard block |
||
499 | 499 | */ |
500 | 500 | public function getApplicationUrl() |
501 | 501 | { |
502 | - if($this->_cgiFix&self::CGIFIX__SCRIPT_NAME && isset($_SERVER['ORIG_SCRIPT_NAME'])) |
|
502 | + if($this->_cgiFix & self::CGIFIX__SCRIPT_NAME && isset($_SERVER['ORIG_SCRIPT_NAME'])) |
|
503 | 503 | return $_SERVER['ORIG_SCRIPT_NAME']; |
504 | 504 | |
505 | - return isset($_SERVER['SCRIPT_NAME'])?$_SERVER['SCRIPT_NAME']:null; |
|
505 | + return isset($_SERVER['SCRIPT_NAME']) ? $_SERVER['SCRIPT_NAME'] : null; |
|
506 | 506 | } |
507 | 507 | |
508 | 508 | /** |
@@ -514,7 +514,7 @@ discard block |
||
514 | 514 | */ |
515 | 515 | public function getAbsoluteApplicationUrl($forceSecureConnection=null) |
516 | 516 | { |
517 | - return $this->getBaseUrl($forceSecureConnection) . $this->getApplicationUrl(); |
|
517 | + return $this->getBaseUrl($forceSecureConnection).$this->getApplicationUrl(); |
|
518 | 518 | } |
519 | 519 | |
520 | 520 | /** |
@@ -522,7 +522,7 @@ discard block |
||
522 | 522 | */ |
523 | 523 | public function getApplicationFilePath() |
524 | 524 | { |
525 | - return realpath(isset($_SERVER['SCRIPT_FILENAME'])?$_SERVER['SCRIPT_FILENAME']:null); |
|
525 | + return realpath(isset($_SERVER['SCRIPT_FILENAME']) ? $_SERVER['SCRIPT_FILENAME'] : null); |
|
526 | 526 | } |
527 | 527 | |
528 | 528 | /** |
@@ -530,7 +530,7 @@ discard block |
||
530 | 530 | */ |
531 | 531 | public function getServerName() |
532 | 532 | { |
533 | - return isset($_SERVER['SERVER_NAME'])?$_SERVER['SERVER_NAME']:null; |
|
533 | + return isset($_SERVER['SERVER_NAME']) ? $_SERVER['SERVER_NAME'] : null; |
|
534 | 534 | } |
535 | 535 | |
536 | 536 | /** |
@@ -538,7 +538,7 @@ discard block |
||
538 | 538 | */ |
539 | 539 | public function getServerPort() |
540 | 540 | { |
541 | - return isset($_SERVER['SERVER_PORT'])?$_SERVER['SERVER_PORT']:null; |
|
541 | + return isset($_SERVER['SERVER_PORT']) ? $_SERVER['SERVER_PORT'] : null; |
|
542 | 542 | } |
543 | 543 | |
544 | 544 | /** |
@@ -546,7 +546,7 @@ discard block |
||
546 | 546 | */ |
547 | 547 | public function getUrlReferrer() |
548 | 548 | { |
549 | - return isset($_SERVER['HTTP_REFERER'])?$_SERVER['HTTP_REFERER']:null; |
|
549 | + return isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : null; |
|
550 | 550 | } |
551 | 551 | |
552 | 552 | /** |
@@ -570,7 +570,7 @@ discard block |
||
570 | 570 | */ |
571 | 571 | public function getUserAgent() |
572 | 572 | { |
573 | - return isset($_SERVER['HTTP_USER_AGENT'])?$_SERVER['HTTP_USER_AGENT']:null; |
|
573 | + return isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : null; |
|
574 | 574 | } |
575 | 575 | |
576 | 576 | /** |
@@ -578,7 +578,7 @@ discard block |
||
578 | 578 | */ |
579 | 579 | public function getUserHostAddress() |
580 | 580 | { |
581 | - return isset($_SERVER['REMOTE_ADDR'])?$_SERVER['REMOTE_ADDR']:null; |
|
581 | + return isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : null; |
|
582 | 582 | } |
583 | 583 | |
584 | 584 | /** |
@@ -586,7 +586,7 @@ discard block |
||
586 | 586 | */ |
587 | 587 | public function getUserHost() |
588 | 588 | { |
589 | - return isset($_SERVER['REMOTE_HOST'])?$_SERVER['REMOTE_HOST']:null; |
|
589 | + return isset($_SERVER['REMOTE_HOST']) ? $_SERVER['REMOTE_HOST'] : null; |
|
590 | 590 | } |
591 | 591 | |
592 | 592 | /** |
@@ -595,7 +595,7 @@ discard block |
||
595 | 595 | public function getAcceptTypes() |
596 | 596 | { |
597 | 597 | // TBD: break it into array?? |
598 | - return isset($_SERVER['HTTP_ACCEPT'])?$_SERVER['HTTP_ACCEPT']:null; |
|
598 | + return isset($_SERVER['HTTP_ACCEPT']) ? $_SERVER['HTTP_ACCEPT'] : null; |
|
599 | 599 | } |
600 | 600 | |
601 | 601 | /** |
@@ -660,13 +660,13 @@ discard block |
||
660 | 660 | foreach($_COOKIE as $key=>$value) |
661 | 661 | { |
662 | 662 | if(($value=$sm->validateData($value))!==false) |
663 | - $this->_cookies->add(new THttpCookie($key,$value)); |
|
663 | + $this->_cookies->add(new THttpCookie($key, $value)); |
|
664 | 664 | } |
665 | 665 | } |
666 | 666 | else |
667 | 667 | { |
668 | 668 | foreach($_COOKIE as $key=>$value) |
669 | - $this->_cookies->add(new THttpCookie($key,$value)); |
|
669 | + $this->_cookies->add(new THttpCookie($key, $value)); |
|
670 | 670 | } |
671 | 671 | } |
672 | 672 | return $this->_cookies; |
@@ -713,13 +713,13 @@ discard block |
||
713 | 713 | * @return string URL |
714 | 714 | * @see TUrlManager::constructUrl |
715 | 715 | */ |
716 | - public function constructUrl($serviceID,$serviceParam,$getItems=null,$encodeAmpersand=true,$encodeGetItems=true) |
|
716 | + public function constructUrl($serviceID, $serviceParam, $getItems=null, $encodeAmpersand=true, $encodeGetItems=true) |
|
717 | 717 | { |
718 | - if ($this->_cookieOnly===null) |
|
719 | - $this->_cookieOnly=(int)ini_get('session.use_cookies') && (int)ini_get('session.use_only_cookies'); |
|
720 | - $url=$this->getUrlManagerModule()->constructUrl($serviceID,$serviceParam,$getItems,$encodeAmpersand,$encodeGetItems); |
|
721 | - if(defined('SID') && SID != '' && !$this->_cookieOnly) |
|
722 | - return $url . (strpos($url,'?')===false? '?' : ($encodeAmpersand?'&':'&')) . SID; |
|
718 | + if($this->_cookieOnly===null) |
|
719 | + $this->_cookieOnly=(int) ini_get('session.use_cookies') && (int) ini_get('session.use_only_cookies'); |
|
720 | + $url=$this->getUrlManagerModule()->constructUrl($serviceID, $serviceParam, $getItems, $encodeAmpersand, $encodeGetItems); |
|
721 | + if(defined('SID') && SID!='' && !$this->_cookieOnly) |
|
722 | + return $url.(strpos($url, '?')===false ? '?' : ($encodeAmpersand ? '&' : '&')).SID; |
|
723 | 723 | else |
724 | 724 | return $url; |
725 | 725 | } |
@@ -747,11 +747,11 @@ discard block |
||
747 | 747 | */ |
748 | 748 | public function resolveRequest($serviceIDs) |
749 | 749 | { |
750 | - Prado::trace("Resolving request from ".$_SERVER['REMOTE_ADDR'],'System.Web.THttpRequest'); |
|
750 | + Prado::trace("Resolving request from ".$_SERVER['REMOTE_ADDR'], 'System.Web.THttpRequest'); |
|
751 | 751 | $getParams=$this->parseUrl(); |
752 | 752 | foreach($getParams as $name=>$value) |
753 | 753 | $_GET[$name]=$value; |
754 | - $this->_items=array_merge($_GET,$_POST); |
|
754 | + $this->_items=array_merge($_GET, $_POST); |
|
755 | 755 | $this->_requestResolved=true; |
756 | 756 | foreach($serviceIDs as $serviceID) |
757 | 757 | { |
@@ -862,7 +862,7 @@ discard block |
||
862 | 862 | * @param mixed key |
863 | 863 | * @param mixed value |
864 | 864 | */ |
865 | - public function add($key,$value) |
|
865 | + public function add($key, $value) |
|
866 | 866 | { |
867 | 867 | $this->_items[$key]=$value; |
868 | 868 | } |
@@ -875,7 +875,7 @@ discard block |
||
875 | 875 | */ |
876 | 876 | public function remove($key) |
877 | 877 | { |
878 | - if(isset($this->_items[$key]) || array_key_exists($key,$this->_items)) |
|
878 | + if(isset($this->_items[$key]) || array_key_exists($key, $this->_items)) |
|
879 | 879 | { |
880 | 880 | $value=$this->_items[$key]; |
881 | 881 | unset($this->_items[$key]); |
@@ -900,7 +900,7 @@ discard block |
||
900 | 900 | */ |
901 | 901 | public function contains($key) |
902 | 902 | { |
903 | - return isset($this->_items[$key]) || array_key_exists($key,$this->_items); |
|
903 | + return isset($this->_items[$key]) || array_key_exists($key, $this->_items); |
|
904 | 904 | } |
905 | 905 | |
906 | 906 | /** |
@@ -939,9 +939,9 @@ discard block |
||
939 | 939 | * @param integer the offset to set element |
940 | 940 | * @param mixed the element value |
941 | 941 | */ |
942 | - public function offsetSet($offset,$item) |
|
942 | + public function offsetSet($offset, $item) |
|
943 | 943 | { |
944 | - $this->add($offset,$item); |
|
944 | + $this->add($offset, $item); |
|
945 | 945 | } |
946 | 946 | |
947 | 947 | /** |
@@ -994,11 +994,11 @@ discard block |
||
994 | 994 | * @param mixed new item |
995 | 995 | * @throws TInvalidDataTypeException if the item to be inserted is not a THttpCookie object. |
996 | 996 | */ |
997 | - public function insertAt($index,$item) |
|
997 | + public function insertAt($index, $item) |
|
998 | 998 | { |
999 | 999 | if($item instanceof THttpCookie) |
1000 | 1000 | { |
1001 | - parent::insertAt($index,$item); |
|
1001 | + parent::insertAt($index, $item); |
|
1002 | 1002 | if($this->_o instanceof THttpResponse) |
1003 | 1003 | $this->_o->addCookie($item); |
1004 | 1004 | } |
@@ -1093,7 +1093,7 @@ discard block |
||
1093 | 1093 | * @param string name of this cookie |
1094 | 1094 | * @param string value of this cookie |
1095 | 1095 | */ |
1096 | - public function __construct($name,$value) |
|
1096 | + public function __construct($name, $value) |
|
1097 | 1097 | { |
1098 | 1098 | $this->_name=$name; |
1099 | 1099 | $this->_value=$value; |
@@ -1144,7 +1144,7 @@ discard block |
||
1144 | 1144 | */ |
1145 | 1145 | public function setHttpOnly($value) |
1146 | 1146 | { |
1147 | - $this->_httpOnly = TPropertyValue::ensureBoolean($value); |
|
1147 | + $this->_httpOnly=TPropertyValue::ensureBoolean($value); |
|
1148 | 1148 | } |
1149 | 1149 | |
1150 | 1150 | /** |
@@ -1294,19 +1294,19 @@ discard block |
||
1294 | 1294 | if(($ret=@parse_url($uri))!==false) |
1295 | 1295 | { |
1296 | 1296 | // decoding??? |
1297 | - $this->_scheme=isset($ret['scheme'])?$ret['scheme']:''; |
|
1298 | - $this->_host=isset($ret['host'])?$ret['host']:''; |
|
1299 | - $this->_port=isset($ret['port'])?$ret['port']:''; |
|
1300 | - $this->_user=isset($ret['user'])?$ret['user']:''; |
|
1301 | - $this->_pass=isset($ret['pass'])?$ret['pass']:''; |
|
1302 | - $this->_path=isset($ret['path'])?$ret['path']:''; |
|
1303 | - $this->_query=isset($ret['query'])?$ret['query']:''; |
|
1304 | - $this->_fragment=isset($ret['fragment'])?$ret['fragment']:''; |
|
1297 | + $this->_scheme=isset($ret['scheme']) ? $ret['scheme'] : ''; |
|
1298 | + $this->_host=isset($ret['host']) ? $ret['host'] : ''; |
|
1299 | + $this->_port=isset($ret['port']) ? $ret['port'] : ''; |
|
1300 | + $this->_user=isset($ret['user']) ? $ret['user'] : ''; |
|
1301 | + $this->_pass=isset($ret['pass']) ? $ret['pass'] : ''; |
|
1302 | + $this->_path=isset($ret['path']) ? $ret['path'] : ''; |
|
1303 | + $this->_query=isset($ret['query']) ? $ret['query'] : ''; |
|
1304 | + $this->_fragment=isset($ret['fragment']) ? $ret['fragment'] : ''; |
|
1305 | 1305 | $this->_uri=$uri; |
1306 | 1306 | } |
1307 | 1307 | else |
1308 | 1308 | { |
1309 | - throw new TInvalidDataValueException('uri_format_invalid',$uri); |
|
1309 | + throw new TInvalidDataValueException('uri_format_invalid', $uri); |
|
1310 | 1310 | } |
1311 | 1311 | } |
1312 | 1312 |
@@ -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 |
@@ -59,17 +59,17 @@ discard block |
||
59 | 59 | /** |
60 | 60 | * const string base api provider class which every API must extend |
61 | 61 | */ |
62 | - const BASE_API_PROVIDER = 'TRpcApiProvider'; |
|
62 | + const BASE_API_PROVIDER='TRpcApiProvider'; |
|
63 | 63 | |
64 | 64 | /** |
65 | 65 | * const string base RPC server implementation |
66 | 66 | */ |
67 | - const BASE_RPC_SERVER = 'TRpcServer'; |
|
67 | + const BASE_RPC_SERVER='TRpcServer'; |
|
68 | 68 | |
69 | 69 | /** |
70 | 70 | * @var array containing mimetype to protocol handler mappings |
71 | 71 | */ |
72 | - protected $protocolHandlers = array( |
|
72 | + protected $protocolHandlers=array( |
|
73 | 73 | 'application/json' => 'TJsonRpcProtocol', |
74 | 74 | 'text/xml' => 'TXmlRpcProtocol' |
75 | 75 | ); |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | /** |
78 | 78 | * @var array containing API provider and their configured properties |
79 | 79 | */ |
80 | - protected $apiProviders = array(); |
|
80 | + protected $apiProviders=array(); |
|
81 | 81 | |
82 | 82 | // methods |
83 | 83 | |
@@ -88,27 +88,27 @@ discard block |
||
88 | 88 | */ |
89 | 89 | public function createApiProvider(TRpcProtocol $protocolHandler, $providerId) |
90 | 90 | { |
91 | - $_properties = $this->apiProviders[$providerId]; |
|
91 | + $_properties=$this->apiProviders[$providerId]; |
|
92 | 92 | |
93 | - if(($_providerClass = $_properties->remove('class')) === null) |
|
93 | + if(($_providerClass=$_properties->remove('class'))===null) |
|
94 | 94 | throw new TConfigurationException('rpcservice_apiprovider_required'); |
95 | 95 | |
96 | 96 | Prado::using($_providerClass); |
97 | 97 | |
98 | - $_providerClassName = ($_pos = strrpos($_providerClass, '.')) !== false ? substr($_providerClass, $_pos + 1) : $_providerClass; |
|
98 | + $_providerClassName=($_pos=strrpos($_providerClass, '.'))!==false ? substr($_providerClass, $_pos + 1) : $_providerClass; |
|
99 | 99 | if(!is_subclass_of($_providerClassName, self::BASE_API_PROVIDER)) |
100 | 100 | throw new TConfigurationException('rpcservice_apiprovider_invalid'); |
101 | 101 | |
102 | - if(($_rpcServerClass = $_properties->remove('server')) === null) |
|
103 | - $_rpcServerClass = self::BASE_RPC_SERVER; |
|
102 | + if(($_rpcServerClass=$_properties->remove('server'))===null) |
|
103 | + $_rpcServerClass=self::BASE_RPC_SERVER; |
|
104 | 104 | |
105 | 105 | Prado::using($_rpcServerClass); |
106 | 106 | |
107 | - $_rpcServerClassName = ($_pos = strrpos($_rpcServerClass, '.')) !== false ? substr($_rpcServerClass, $_pos + 1) : $_rpcServerClass; |
|
107 | + $_rpcServerClassName=($_pos=strrpos($_rpcServerClass, '.'))!==false ? substr($_rpcServerClass, $_pos + 1) : $_rpcServerClass; |
|
108 | 108 | if($_rpcServerClassName!==self::BASE_RPC_SERVER && !is_subclass_of($_rpcServerClassName, self::BASE_RPC_SERVER)) |
109 | 109 | throw new TConfigurationException('rpcservice_rpcserver_invalid'); |
110 | 110 | |
111 | - $_apiProvider = new $_providerClassName(new $_rpcServerClassName($protocolHandler)); |
|
111 | + $_apiProvider=new $_providerClassName(new $_rpcServerClassName($protocolHandler)); |
|
112 | 112 | $_apiProvider->setId($providerId); |
113 | 113 | |
114 | 114 | foreach($_properties as $_key => $_value) |
@@ -134,15 +134,15 @@ discard block |
||
134 | 134 | { |
135 | 135 | foreach($xml->getElementsByTagName('rpcapi') as $_apiProviderXml) |
136 | 136 | { |
137 | - $_properties = $_apiProviderXml->getAttributes(); |
|
137 | + $_properties=$_apiProviderXml->getAttributes(); |
|
138 | 138 | |
139 | - if(($_id = $_properties->remove('id')) === null || $_id == "") |
|
139 | + if(($_id=$_properties->remove('id'))===null || $_id=="") |
|
140 | 140 | throw new TConfigurationException('rpcservice_apiproviderid_required'); |
141 | 141 | |
142 | 142 | if(isset($this->apiProviders[$_id])) |
143 | 143 | throw new TConfigurationException('rpcservice_apiproviderid_duplicated'); |
144 | 144 | |
145 | - $this->apiProviders[$_id] = $_properties; |
|
145 | + $this->apiProviders[$_id]=$_properties; |
|
146 | 146 | } |
147 | 147 | } |
148 | 148 | |
@@ -151,26 +151,26 @@ discard block |
||
151 | 151 | */ |
152 | 152 | public function run() |
153 | 153 | { |
154 | - $_request = $this->getRequest(); |
|
154 | + $_request=$this->getRequest(); |
|
155 | 155 | |
156 | - if(($_providerId = $_request->getServiceParameter()) == "") |
|
156 | + if(($_providerId=$_request->getServiceParameter())=="") |
|
157 | 157 | throw new THttpException(400, 'RPC API-Provider id required'); |
158 | 158 | |
159 | - if(($_method = $_request->getRequestType()) != 'POST') |
|
159 | + if(($_method=$_request->getRequestType())!='POST') |
|
160 | 160 | throw new THttpException(405, 'Invalid request method "'.$_method.'"!'); // TODO Exception muss "Allow POST" Header setzen |
161 | 161 | |
162 | - if(($_mimeType = $_request->getContentType()) === null) |
|
162 | + if(($_mimeType=$_request->getContentType())===null) |
|
163 | 163 | throw new THttpException(406, 'Content-Type is missing!'); // TODO Exception muss gültige Content-Type werte zurück geben |
164 | 164 | |
165 | 165 | if(!in_array($_mimeType, array_keys($this->protocolHandlers))) |
166 | 166 | throw new THttpException(406, 'Unsupported Content-Type!'); // TODO see previous |
167 | 167 | |
168 | - $_protocolHandlerClass = $this->protocolHandlers[$_mimeType]; |
|
169 | - $_protocolHandler = new $_protocolHandlerClass; |
|
168 | + $_protocolHandlerClass=$this->protocolHandlers[$_mimeType]; |
|
169 | + $_protocolHandler=new $_protocolHandlerClass; |
|
170 | 170 | |
171 | - if(($_result = $this->createApiProvider($_protocolHandler, $_providerId)->processRequest()) !== null) |
|
171 | + if(($_result=$this->createApiProvider($_protocolHandler, $_providerId)->processRequest())!==null) |
|
172 | 172 | { |
173 | - $_response = $this->getResponse(); |
|
173 | + $_response=$this->getResponse(); |
|
174 | 174 | $_protocolHandler->createResponseHeaders($_response); |
175 | 175 | $_response->write($_result); |
176 | 176 | } |
@@ -206,7 +206,7 @@ discard block |
||
206 | 206 | */ |
207 | 207 | public function __construct(TRpcProtocol $protocolHandler) |
208 | 208 | { |
209 | - $this->handler = $protocolHandler; |
|
209 | + $this->handler=$protocolHandler; |
|
210 | 210 | } |
211 | 211 | |
212 | 212 | /** |
@@ -258,7 +258,7 @@ discard block |
||
258 | 258 | */ |
259 | 259 | class TRpcException extends TException |
260 | 260 | { |
261 | - public function __construct($message, $errorCode = -1) |
|
261 | + public function __construct($message, $errorCode=-1) |
|
262 | 262 | { |
263 | 263 | $this->setErrorCode($errorCode); |
264 | 264 | |
@@ -318,7 +318,7 @@ discard block |
||
318 | 318 | */ |
319 | 319 | public function __construct(TRpcServer $rpcServer) |
320 | 320 | { |
321 | - $this->rpcServer = $rpcServer; |
|
321 | + $this->rpcServer=$rpcServer; |
|
322 | 322 | |
323 | 323 | foreach($this->registerMethods() as $_methodName => $_methodDetails) |
324 | 324 | $this->rpcServer->addRpcMethod($_methodName, $_methodDetails); |
@@ -359,7 +359,7 @@ discard block |
||
359 | 359 | /** |
360 | 360 | * @var array containing the mapping from RPC method names to the actual handlers |
361 | 361 | */ |
362 | - protected $rpcMethods = array(); |
|
362 | + protected $rpcMethods=array(); |
|
363 | 363 | |
364 | 364 | // abstracts |
365 | 365 | |
@@ -407,7 +407,7 @@ discard block |
||
407 | 407 | */ |
408 | 408 | public function addMethod($methodName, $handlerDetails) |
409 | 409 | { |
410 | - $this->rpcMethods[$methodName] = $handlerDetails; |
|
410 | + $this->rpcMethods[$methodName]=$handlerDetails; |
|
411 | 411 | } |
412 | 412 | |
413 | 413 | /** |
@@ -421,11 +421,11 @@ discard block |
||
421 | 421 | if(!isset($this->rpcMethods[$methodName])) |
422 | 422 | throw new TRpcException('Method "'.$methodName.'" not found'); |
423 | 423 | |
424 | - if($parameters === null) |
|
425 | - $parameters = array(); |
|
424 | + if($parameters===null) |
|
425 | + $parameters=array(); |
|
426 | 426 | |
427 | 427 | if(!is_array($parameters)) |
428 | - $parameters = array($parameters); |
|
428 | + $parameters=array($parameters); |
|
429 | 429 | return call_user_func_array($this->rpcMethods[$methodName]['method'], $parameters); |
430 | 430 | } |
431 | 431 | } |
@@ -457,7 +457,7 @@ discard block |
||
457 | 457 | { |
458 | 458 | try |
459 | 459 | { |
460 | - $_request = $this->decode($requestPayload); |
|
460 | + $_request=$this->decode($requestPayload); |
|
461 | 461 | |
462 | 462 | if(isset($_request['jsonrpc'])) |
463 | 463 | { |
@@ -473,15 +473,15 @@ discard block |
||
473 | 473 | throw new TRpcException('Missing request method', '-32600'); |
474 | 474 | |
475 | 475 | if(!isset($_request['params'])) |
476 | - $parameters = array(); |
|
476 | + $parameters=array(); |
|
477 | 477 | else |
478 | - $parameters = $_request['params']; |
|
478 | + $parameters=$_request['params']; |
|
479 | 479 | |
480 | 480 | if(!is_array($parameters)) |
481 | - $parameters = array($parameters); |
|
481 | + $parameters=array($parameters); |
|
482 | 482 | |
483 | 483 | // a request without an id is a notification that doesn't need a response |
484 | - if($this->_id !== null) |
|
484 | + if($this->_id!==null) |
|
485 | 485 | { |
486 | 486 | if($this->_specificationVersion==2.0) |
487 | 487 | { |
@@ -560,7 +560,7 @@ discard block |
||
560 | 560 | */ |
561 | 561 | public function decode($data) |
562 | 562 | { |
563 | - $s = json_decode($data, true); |
|
563 | + $s=json_decode($data, true); |
|
564 | 564 | self::checkJsonError(); |
565 | 565 | return $s; |
566 | 566 | } |
@@ -572,15 +572,15 @@ discard block |
||
572 | 572 | */ |
573 | 573 | public function encode($data) |
574 | 574 | { |
575 | - $s = json_encode($data); |
|
575 | + $s=json_encode($data); |
|
576 | 576 | self::checkJsonError(); |
577 | 577 | return $s; |
578 | 578 | } |
579 | 579 | |
580 | 580 | private static function checkJsonError() |
581 | 581 | { |
582 | - $errnum = json_last_error(); |
|
583 | - if($errnum != JSON_ERROR_NONE) |
|
582 | + $errnum=json_last_error(); |
|
583 | + if($errnum!=JSON_ERROR_NONE) |
|
584 | 584 | throw new Exception("JSON error: $msg", $err); |
585 | 585 | } |
586 | 586 | |
@@ -625,7 +625,7 @@ discard block |
||
625 | 625 | */ |
626 | 626 | public function __construct() |
627 | 627 | { |
628 | - $this->_xmlrpcServer = xmlrpc_server_create(); |
|
628 | + $this->_xmlrpcServer=xmlrpc_server_create(); |
|
629 | 629 | } |
630 | 630 | |
631 | 631 | /** |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | */ |
148 | 148 | public function init($config) |
149 | 149 | { |
150 | - Prado::trace("Initializing TPageService",'System.Web.Services.TPageService'); |
|
150 | + Prado::trace("Initializing TPageService", 'System.Web.Services.TPageService'); |
|
151 | 151 | |
152 | 152 | $pageConfig=$this->loadPageConfig($config); |
153 | 153 | |
@@ -185,15 +185,15 @@ discard block |
||
185 | 185 | // external configurations |
186 | 186 | foreach($config->getExternalConfigurations() as $filePath=>$params) |
187 | 187 | { |
188 | - list($configPagePath,$condition)=$params; |
|
188 | + list($configPagePath, $condition)=$params; |
|
189 | 189 | if($condition!==true) |
190 | 190 | $condition=$this->evaluateExpression($condition); |
191 | 191 | if($condition) |
192 | 192 | { |
193 | - if(($path=Prado::getPathOfNamespace($filePath,Prado::getApplication()->getConfigurationFileExt()))===null || !is_file($path)) |
|
194 | - throw new TConfigurationException('pageservice_includefile_invalid',$filePath); |
|
193 | + if(($path=Prado::getPathOfNamespace($filePath, Prado::getApplication()->getConfigurationFileExt()))===null || !is_file($path)) |
|
194 | + throw new TConfigurationException('pageservice_includefile_invalid', $filePath); |
|
195 | 195 | $c=new TPageConfiguration($pagePath); |
196 | - $c->loadFromFile($path,$configPagePath); |
|
196 | + $c->loadFromFile($path, $configPagePath); |
|
197 | 197 | $this->applyConfiguration($c); |
198 | 198 | } |
199 | 199 | } |
@@ -227,9 +227,9 @@ discard block |
||
227 | 227 | if($config!==null) |
228 | 228 | { |
229 | 229 | if($application->getConfigurationType()==TApplication::CONFIG_TYPE_PHP) |
230 | - $pageConfig->loadPageConfigurationFromPhp($config,$application->getBasePath(),''); |
|
230 | + $pageConfig->loadPageConfigurationFromPhp($config, $application->getBasePath(), ''); |
|
231 | 231 | else |
232 | - $pageConfig->loadPageConfigurationFromXml($config,$application->getBasePath(),''); |
|
232 | + $pageConfig->loadPageConfigurationFromXml($config, $application->getBasePath(), ''); |
|
233 | 233 | } |
234 | 234 | $pageConfig->loadFromFiles($this->getBasePath()); |
235 | 235 | } |
@@ -240,7 +240,7 @@ discard block |
||
240 | 240 | $arr=$cache->get(self::CONFIG_CACHE_PREFIX.$this->getID().$pagePath); |
241 | 241 | if(is_array($arr)) |
242 | 242 | { |
243 | - list($pageConfig,$timestamps)=$arr; |
|
243 | + list($pageConfig, $timestamps)=$arr; |
|
244 | 244 | if($application->getMode()!==TApplicationMode::Performance) |
245 | 245 | { |
246 | 246 | foreach($timestamps as $fileName=>$timestamp) |
@@ -248,14 +248,14 @@ discard block |
||
248 | 248 | if($fileName===0) // application config file |
249 | 249 | { |
250 | 250 | $appConfigFile=$application->getConfigurationFile(); |
251 | - $currentTimestamp[0]=$appConfigFile===null?0:@filemtime($appConfigFile); |
|
252 | - if($currentTimestamp[0]>$timestamp || ($timestamp>0 && !$currentTimestamp[0])) |
|
251 | + $currentTimestamp[0]=$appConfigFile===null ? 0 : @filemtime($appConfigFile); |
|
252 | + if($currentTimestamp[0] > $timestamp || ($timestamp > 0 && !$currentTimestamp[0])) |
|
253 | 253 | $configCached=false; |
254 | 254 | } |
255 | 255 | else |
256 | 256 | { |
257 | 257 | $currentTimestamp[$fileName]=@filemtime($fileName); |
258 | - if($currentTimestamp[$fileName]>$timestamp || ($timestamp>0 && !$currentTimestamp[$fileName])) |
|
258 | + if($currentTimestamp[$fileName] > $timestamp || ($timestamp > 0 && !$currentTimestamp[$fileName])) |
|
259 | 259 | $configCached=false; |
260 | 260 | } |
261 | 261 | } |
@@ -264,9 +264,9 @@ discard block |
||
264 | 264 | else |
265 | 265 | { |
266 | 266 | $configCached=false; |
267 | - $paths=explode('.',$pagePath); |
|
267 | + $paths=explode('.', $pagePath); |
|
268 | 268 | $configPath=$this->getBasePath(); |
269 | - $fileName = $this->getApplication()->getConfigurationType()==TApplication::CONFIG_TYPE_PHP |
|
269 | + $fileName=$this->getApplication()->getConfigurationType()==TApplication::CONFIG_TYPE_PHP |
|
270 | 270 | ? self::CONFIG_FILE_PHP |
271 | 271 | : self::CONFIG_FILE_XML; |
272 | 272 | foreach($paths as $path) |
@@ -276,7 +276,7 @@ discard block |
||
276 | 276 | $configPath.=DIRECTORY_SEPARATOR.$path; |
277 | 277 | } |
278 | 278 | $appConfigFile=$application->getConfigurationFile(); |
279 | - $currentTimestamp[0]=$appConfigFile===null?0:@filemtime($appConfigFile); |
|
279 | + $currentTimestamp[0]=$appConfigFile===null ? 0 : @filemtime($appConfigFile); |
|
280 | 280 | } |
281 | 281 | if(!$configCached) |
282 | 282 | { |
@@ -284,12 +284,12 @@ discard block |
||
284 | 284 | if($config!==null) |
285 | 285 | { |
286 | 286 | if($application->getConfigurationType()==TApplication::CONFIG_TYPE_PHP) |
287 | - $pageConfig->loadPageConfigurationFromPhp($config,$application->getBasePath(),''); |
|
287 | + $pageConfig->loadPageConfigurationFromPhp($config, $application->getBasePath(), ''); |
|
288 | 288 | else |
289 | - $pageConfig->loadPageConfigurationFromXml($config,$application->getBasePath(),''); |
|
289 | + $pageConfig->loadPageConfigurationFromXml($config, $application->getBasePath(), ''); |
|
290 | 290 | } |
291 | 291 | $pageConfig->loadFromFiles($this->getBasePath()); |
292 | - $cache->set(self::CONFIG_CACHE_PREFIX.$this->getID().$pagePath,array($pageConfig,$currentTimestamp)); |
|
292 | + $cache->set(self::CONFIG_CACHE_PREFIX.$this->getID().$pagePath, array($pageConfig, $currentTimestamp)); |
|
293 | 293 | } |
294 | 294 | } |
295 | 295 | return $pageConfig; |
@@ -344,9 +344,9 @@ discard block |
||
344 | 344 | { |
345 | 345 | if($this->_pagePath===null) |
346 | 346 | { |
347 | - $this->_pagePath=strtr($this->determineRequestedPagePath(),'/\\','..'); |
|
347 | + $this->_pagePath=strtr($this->determineRequestedPagePath(), '/\\', '..'); |
|
348 | 348 | if(empty($this->_pagePath)) |
349 | - throw new THttpException(404,'pageservice_page_required'); |
|
349 | + throw new THttpException(404, 'pageservice_page_required'); |
|
350 | 350 | } |
351 | 351 | return $this->_pagePath; |
352 | 352 | } |
@@ -399,7 +399,7 @@ discard block |
||
399 | 399 | { |
400 | 400 | $basePath=$this->getApplication()->getBasePath().DIRECTORY_SEPARATOR.self::FALLBACK_BASEPATH; |
401 | 401 | if(($this->_basePath=realpath($basePath))===false || !is_dir($this->_basePath)) |
402 | - throw new TConfigurationException('pageservice_basepath_invalid',$basePath); |
|
402 | + throw new TConfigurationException('pageservice_basepath_invalid', $basePath); |
|
403 | 403 | } |
404 | 404 | } |
405 | 405 | return $this->_basePath; |
@@ -414,7 +414,7 @@ discard block |
||
414 | 414 | if($this->_initialized) |
415 | 415 | throw new TInvalidOperationException('pageservice_basepath_unchangeable'); |
416 | 416 | else if(($path=Prado::getPathOfNamespace($value))===null || !is_dir($path)) |
417 | - throw new TConfigurationException('pageservice_basepath_invalid',$value); |
|
417 | + throw new TConfigurationException('pageservice_basepath_invalid', $value); |
|
418 | 418 | $this->_basePath=realpath($path); |
419 | 419 | } |
420 | 420 | |
@@ -463,9 +463,9 @@ discard block |
||
463 | 463 | */ |
464 | 464 | public function run() |
465 | 465 | { |
466 | - Prado::trace("Running page service",'System.Web.Services.TPageService'); |
|
466 | + Prado::trace("Running page service", 'System.Web.Services.TPageService'); |
|
467 | 467 | $this->_page=$this->createPage($this->getRequestedPagePath()); |
468 | - $this->runPage($this->_page,$this->_properties); |
|
468 | + $this->runPage($this->_page, $this->_properties); |
|
469 | 469 | } |
470 | 470 | |
471 | 471 | /** |
@@ -477,29 +477,29 @@ discard block |
||
477 | 477 | */ |
478 | 478 | protected function createPage($pagePath) |
479 | 479 | { |
480 | - $path=$this->getBasePath().DIRECTORY_SEPARATOR.strtr($pagePath,'.',DIRECTORY_SEPARATOR); |
|
480 | + $path=$this->getBasePath().DIRECTORY_SEPARATOR.strtr($pagePath, '.', DIRECTORY_SEPARATOR); |
|
481 | 481 | $hasTemplateFile=is_file($path.self::PAGE_FILE_EXT); |
482 | 482 | $hasClassFile=is_file($path.Prado::CLASS_FILE_EXT); |
483 | 483 | |
484 | 484 | if(!$hasTemplateFile && !$hasClassFile) |
485 | - throw new THttpException(404,'pageservice_page_unknown',$pagePath); |
|
485 | + throw new THttpException(404, 'pageservice_page_unknown', $pagePath); |
|
486 | 486 | |
487 | 487 | if($hasClassFile) |
488 | 488 | { |
489 | 489 | $className=basename($path); |
490 | - if(!class_exists($className,false)) |
|
490 | + if(!class_exists($className, false)) |
|
491 | 491 | include_once($path.Prado::CLASS_FILE_EXT); |
492 | 492 | } |
493 | 493 | else |
494 | 494 | { |
495 | 495 | $className=$this->getBasePageClass(); |
496 | 496 | Prado::using($className); |
497 | - if(($pos=strrpos($className,'.'))!==false) |
|
498 | - $className=substr($className,$pos+1); |
|
497 | + if(($pos=strrpos($className, '.'))!==false) |
|
498 | + $className=substr($className, $pos + 1); |
|
499 | 499 | } |
500 | 500 | |
501 | - if(!class_exists($className,false) || ($className!=='TPage' && !is_subclass_of($className,'TPage'))) |
|
502 | - throw new THttpException(404,'pageservice_page_unknown',$pagePath); |
|
501 | + if(!class_exists($className, false) || ($className!=='TPage' && !is_subclass_of($className, 'TPage'))) |
|
502 | + throw new THttpException(404, 'pageservice_page_unknown', $pagePath); |
|
503 | 503 | |
504 | 504 | $page=Prado::createComponent($className); |
505 | 505 | $page->setPagePath($pagePath); |
@@ -515,10 +515,10 @@ discard block |
||
515 | 515 | * @param TPage the page instance to be run |
516 | 516 | * @param array list of initial page properties |
517 | 517 | */ |
518 | - protected function runPage($page,$properties) |
|
518 | + protected function runPage($page, $properties) |
|
519 | 519 | { |
520 | 520 | foreach($properties as $name=>$value) |
521 | - $page->setSubProperty($name,$value); |
|
521 | + $page->setSubProperty($name, $value); |
|
522 | 522 | $page->run($this->getResponse()->createHtmlWriter()); |
523 | 523 | } |
524 | 524 | |
@@ -530,9 +530,9 @@ discard block |
||
530 | 530 | * @param boolean whether to encode the GET parameters (their names and values), defaults to true. |
531 | 531 | * @return string URL for the page and GET parameters |
532 | 532 | */ |
533 | - public function constructUrl($pagePath,$getParams=null,$encodeAmpersand=true,$encodeGetItems=true) |
|
533 | + public function constructUrl($pagePath, $getParams=null, $encodeAmpersand=true, $encodeGetItems=true) |
|
534 | 534 | { |
535 | - return $this->getRequest()->constructUrl($this->getID(),$pagePath,$getParams,$encodeAmpersand,$encodeGetItems); |
|
535 | + return $this->getRequest()->constructUrl($this->getID(), $pagePath, $getParams, $encodeAmpersand, $encodeGetItems); |
|
536 | 536 | } |
537 | 537 | } |
538 | 538 | |
@@ -624,23 +624,23 @@ discard block |
||
624 | 624 | */ |
625 | 625 | public function loadFromFiles($basePath) |
626 | 626 | { |
627 | - $paths=explode('.',$this->_pagePath); |
|
627 | + $paths=explode('.', $this->_pagePath); |
|
628 | 628 | $page=array_pop($paths); |
629 | 629 | $path=$basePath; |
630 | 630 | $configPagePath=''; |
631 | - $fileName = Prado::getApplication()->getConfigurationType()==TApplication::CONFIG_TYPE_PHP |
|
631 | + $fileName=Prado::getApplication()->getConfigurationType()==TApplication::CONFIG_TYPE_PHP |
|
632 | 632 | ? TPageService::CONFIG_FILE_PHP |
633 | 633 | : TPageService::CONFIG_FILE_XML; |
634 | 634 | foreach($paths as $p) |
635 | 635 | { |
636 | - $this->loadFromFile($path.DIRECTORY_SEPARATOR.$fileName,$configPagePath); |
|
636 | + $this->loadFromFile($path.DIRECTORY_SEPARATOR.$fileName, $configPagePath); |
|
637 | 637 | $path.=DIRECTORY_SEPARATOR.$p; |
638 | 638 | if($configPagePath==='') |
639 | 639 | $configPagePath=$p; |
640 | 640 | else |
641 | 641 | $configPagePath.='.'.$p; |
642 | 642 | } |
643 | - $this->loadFromFile($path.DIRECTORY_SEPARATOR.$fileName,$configPagePath); |
|
643 | + $this->loadFromFile($path.DIRECTORY_SEPARATOR.$fileName, $configPagePath); |
|
644 | 644 | $this->_rules=new TAuthorizationRuleCollection($this->_rules); |
645 | 645 | } |
646 | 646 | |
@@ -649,31 +649,31 @@ discard block |
||
649 | 649 | * @param string config file name |
650 | 650 | * @param string the page path that the config file is associated with. The page path doesn't include the page name. |
651 | 651 | */ |
652 | - public function loadFromFile($fname,$configPagePath) |
|
652 | + public function loadFromFile($fname, $configPagePath) |
|
653 | 653 | { |
654 | - Prado::trace("Loading page configuration file $fname",'System.Web.Services.TPageService'); |
|
654 | + Prado::trace("Loading page configuration file $fname", 'System.Web.Services.TPageService'); |
|
655 | 655 | if(empty($fname) || !is_file($fname)) |
656 | 656 | return; |
657 | 657 | |
658 | 658 | if(Prado::getApplication()->getConfigurationType()==TApplication::CONFIG_TYPE_PHP) |
659 | 659 | { |
660 | - $fcontent = include $fname; |
|
661 | - $this->loadFromPhp($fcontent,dirname($fname),$configPagePath); |
|
660 | + $fcontent=include $fname; |
|
661 | + $this->loadFromPhp($fcontent, dirname($fname), $configPagePath); |
|
662 | 662 | } |
663 | 663 | else |
664 | 664 | { |
665 | 665 | $dom=new TXmlDocument; |
666 | 666 | if($dom->loadFromFile($fname)) |
667 | - $this->loadFromXml($dom,dirname($fname),$configPagePath); |
|
667 | + $this->loadFromXml($dom, dirname($fname), $configPagePath); |
|
668 | 668 | else |
669 | - throw new TConfigurationException('pageserviceconf_file_invalid',$fname); |
|
669 | + throw new TConfigurationException('pageserviceconf_file_invalid', $fname); |
|
670 | 670 | } |
671 | 671 | } |
672 | 672 | |
673 | - public function loadFromPhp($config,$configPath,$configPagePath) |
|
673 | + public function loadFromPhp($config, $configPath, $configPagePath) |
|
674 | 674 | { |
675 | - $this->loadApplicationConfigurationFromPhp($config,$configPath); |
|
676 | - $this->loadPageConfigurationFromPhp($config,$configPath,$configPagePath); |
|
675 | + $this->loadApplicationConfigurationFromPhp($config, $configPath); |
|
676 | + $this->loadPageConfigurationFromPhp($config, $configPath, $configPagePath); |
|
677 | 677 | } |
678 | 678 | |
679 | 679 | /** |
@@ -684,16 +684,16 @@ discard block |
||
684 | 684 | * @param string the directory containing this configuration |
685 | 685 | * @param string the page path that the config XML is associated with. The page path doesn't include the page name. |
686 | 686 | */ |
687 | - public function loadFromXml($dom,$configPath,$configPagePath) |
|
687 | + public function loadFromXml($dom, $configPath, $configPagePath) |
|
688 | 688 | { |
689 | - $this->loadApplicationConfigurationFromXml($dom,$configPath); |
|
690 | - $this->loadPageConfigurationFromXml($dom,$configPath,$configPagePath); |
|
689 | + $this->loadApplicationConfigurationFromXml($dom, $configPath); |
|
690 | + $this->loadPageConfigurationFromXml($dom, $configPath, $configPagePath); |
|
691 | 691 | } |
692 | 692 | |
693 | - public function loadApplicationConfigurationFromPhp($config,$configPath) |
|
693 | + public function loadApplicationConfigurationFromPhp($config, $configPath) |
|
694 | 694 | { |
695 | 695 | $appConfig=new TApplicationConfiguration; |
696 | - $appConfig->loadFromPhp($config,$configPath); |
|
696 | + $appConfig->loadFromPhp($config, $configPath); |
|
697 | 697 | $this->_appConfigs[]=$appConfig; |
698 | 698 | } |
699 | 699 | |
@@ -702,10 +702,10 @@ discard block |
||
702 | 702 | * @param TXmlElement config xml element |
703 | 703 | * @param string base path corresponding to this xml element |
704 | 704 | */ |
705 | - public function loadApplicationConfigurationFromXml($dom,$configPath) |
|
705 | + public function loadApplicationConfigurationFromXml($dom, $configPath) |
|
706 | 706 | { |
707 | 707 | $appConfig=new TApplicationConfiguration; |
708 | - $appConfig->loadFromXml($dom,$configPath); |
|
708 | + $appConfig->loadFromXml($dom, $configPath); |
|
709 | 709 | $this->_appConfigs[]=$appConfig; |
710 | 710 | } |
711 | 711 | |
@@ -714,30 +714,30 @@ discard block |
||
714 | 714 | // authorization |
715 | 715 | if(isset($config['authorization']) && is_array($config['authorization'])) |
716 | 716 | { |
717 | - $rules = array(); |
|
717 | + $rules=array(); |
|
718 | 718 | foreach($config['authorization'] as $authorization) |
719 | 719 | { |
720 | - $patterns=isset($authorization['pages'])?$authorization['pages']:''; |
|
720 | + $patterns=isset($authorization['pages']) ? $authorization['pages'] : ''; |
|
721 | 721 | $ruleApplies=false; |
722 | 722 | if(empty($patterns) || trim($patterns)==='*') // null or empty string |
723 | 723 | $ruleApplies=true; |
724 | 724 | else |
725 | 725 | { |
726 | - foreach(explode(',',$patterns) as $pattern) |
|
726 | + foreach(explode(',', $patterns) as $pattern) |
|
727 | 727 | { |
728 | 728 | if(($pattern=trim($pattern))!=='') |
729 | 729 | { |
730 | 730 | // we know $configPagePath and $this->_pagePath |
731 | 731 | if($configPagePath!=='') // prepend the pattern with ConfigPagePath |
732 | 732 | $pattern=$configPagePath.'.'.$pattern; |
733 | - if(strcasecmp($pattern,$this->_pagePath)===0) |
|
733 | + if(strcasecmp($pattern, $this->_pagePath)===0) |
|
734 | 734 | { |
735 | 735 | $ruleApplies=true; |
736 | 736 | break; |
737 | 737 | } |
738 | - if($pattern[strlen($pattern)-1]==='*') // try wildcard matching |
|
738 | + if($pattern[strlen($pattern) - 1]==='*') // try wildcard matching |
|
739 | 739 | { |
740 | - if(strncasecmp($this->_pagePath,$pattern,strlen($pattern)-1)===0) |
|
740 | + if(strncasecmp($this->_pagePath, $pattern, strlen($pattern) - 1)===0) |
|
741 | 741 | { |
742 | 742 | $ruleApplies=true; |
743 | 743 | break; |
@@ -748,40 +748,40 @@ discard block |
||
748 | 748 | } |
749 | 749 | if($ruleApplies) |
750 | 750 | { |
751 | - $action = isset($authorization['action'])?$authorization['action']:''; |
|
752 | - $users = isset($authorization['users'])?$authorization['users']:''; |
|
753 | - $roles = isset($authorization['roles'])?$authorization['roles']:''; |
|
754 | - $verb = isset($authorization['verb'])?$authorization['verb']:''; |
|
755 | - $ips = isset($authorization['ips'])?$authorization['ips']:''; |
|
756 | - $rules[]=new TAuthorizationRule($action,$users,$roles,$verb,$ips); |
|
751 | + $action=isset($authorization['action']) ? $authorization['action'] : ''; |
|
752 | + $users=isset($authorization['users']) ? $authorization['users'] : ''; |
|
753 | + $roles=isset($authorization['roles']) ? $authorization['roles'] : ''; |
|
754 | + $verb=isset($authorization['verb']) ? $authorization['verb'] : ''; |
|
755 | + $ips=isset($authorization['ips']) ? $authorization['ips'] : ''; |
|
756 | + $rules[]=new TAuthorizationRule($action, $users, $roles, $verb, $ips); |
|
757 | 757 | } |
758 | 758 | } |
759 | - $this->_rules=array_merge($rules,$this->_rules); |
|
759 | + $this->_rules=array_merge($rules, $this->_rules); |
|
760 | 760 | } |
761 | 761 | // pages |
762 | 762 | if(isset($config['pages']) && is_array($config['pages'])) |
763 | 763 | { |
764 | 764 | if(isset($config['pages']['properties'])) |
765 | 765 | { |
766 | - $this->_properties = array_merge($this->_properties, $config['pages']['properties']); |
|
766 | + $this->_properties=array_merge($this->_properties, $config['pages']['properties']); |
|
767 | 767 | unset($config['pages']['properties']); |
768 | 768 | } |
769 | 769 | foreach($config['pages'] as $id => $page) |
770 | 770 | { |
771 | - $properties = array(); |
|
771 | + $properties=array(); |
|
772 | 772 | if(isset($page['properties'])) |
773 | 773 | { |
774 | 774 | $properties=$page['properties']; |
775 | 775 | unset($page['properties']); |
776 | 776 | } |
777 | 777 | $matching=false; |
778 | - $id=($configPagePath==='')?$id:$configPagePath.'.'.$id; |
|
779 | - if(strcasecmp($id,$this->_pagePath)===0) |
|
778 | + $id=($configPagePath==='') ? $id : $configPagePath.'.'.$id; |
|
779 | + if(strcasecmp($id, $this->_pagePath)===0) |
|
780 | 780 | $matching=true; |
781 | - else if($id[strlen($id)-1]==='*') // try wildcard matching |
|
782 | - $matching=strncasecmp($this->_pagePath,$id,strlen($id)-1)===0; |
|
781 | + else if($id[strlen($id) - 1]==='*') // try wildcard matching |
|
782 | + $matching=strncasecmp($this->_pagePath, $id, strlen($id) - 1)===0; |
|
783 | 783 | if($matching) |
784 | - $this->_properties=array_merge($this->_properties,$properties); |
|
784 | + $this->_properties=array_merge($this->_properties, $properties); |
|
785 | 785 | } |
786 | 786 | } |
787 | 787 | |
@@ -790,14 +790,14 @@ discard block |
||
790 | 790 | { |
791 | 791 | foreach($config['includes'] as $include) |
792 | 792 | { |
793 | - $when = isset($include['when'])?true:false; |
|
793 | + $when=isset($include['when']) ? true : false; |
|
794 | 794 | if(!isset($include['file'])) |
795 | 795 | throw new TConfigurationException('pageserviceconf_includefile_required'); |
796 | - $filePath = $include['file']; |
|
796 | + $filePath=$include['file']; |
|
797 | 797 | if(isset($this->_includes[$filePath])) |
798 | - $this->_includes[$filePath]=array($configPagePath,'('.$this->_includes[$filePath][1].') || ('.$when.')'); |
|
798 | + $this->_includes[$filePath]=array($configPagePath, '('.$this->_includes[$filePath][1].') || ('.$when.')'); |
|
799 | 799 | else |
800 | - $this->_includes[$filePath]=array($configPagePath,$when); |
|
800 | + $this->_includes[$filePath]=array($configPagePath, $when); |
|
801 | 801 | } |
802 | 802 | } |
803 | 803 | } |
@@ -808,7 +808,7 @@ discard block |
||
808 | 808 | * @param string base path corresponding to this xml element |
809 | 809 | * @param string the page path that the config XML is associated with. The page path doesn't include the page name. |
810 | 810 | */ |
811 | - public function loadPageConfigurationFromXml($dom,$configPath,$configPagePath) |
|
811 | + public function loadPageConfigurationFromXml($dom, $configPath, $configPagePath) |
|
812 | 812 | { |
813 | 813 | // authorization |
814 | 814 | if(($authorizationNode=$dom->getElementByTagName('authorization'))!==null) |
@@ -822,21 +822,21 @@ discard block |
||
822 | 822 | $ruleApplies=true; |
823 | 823 | else |
824 | 824 | { |
825 | - foreach(explode(',',$patterns) as $pattern) |
|
825 | + foreach(explode(',', $patterns) as $pattern) |
|
826 | 826 | { |
827 | 827 | if(($pattern=trim($pattern))!=='') |
828 | 828 | { |
829 | 829 | // we know $configPagePath and $this->_pagePath |
830 | 830 | if($configPagePath!=='') // prepend the pattern with ConfigPagePath |
831 | 831 | $pattern=$configPagePath.'.'.$pattern; |
832 | - if(strcasecmp($pattern,$this->_pagePath)===0) |
|
832 | + if(strcasecmp($pattern, $this->_pagePath)===0) |
|
833 | 833 | { |
834 | 834 | $ruleApplies=true; |
835 | 835 | break; |
836 | 836 | } |
837 | - if($pattern[strlen($pattern)-1]==='*') // try wildcard matching |
|
837 | + if($pattern[strlen($pattern) - 1]==='*') // try wildcard matching |
|
838 | 838 | { |
839 | - if(strncasecmp($this->_pagePath,$pattern,strlen($pattern)-1)===0) |
|
839 | + if(strncasecmp($this->_pagePath, $pattern, strlen($pattern) - 1)===0) |
|
840 | 840 | { |
841 | 841 | $ruleApplies=true; |
842 | 842 | break; |
@@ -846,30 +846,30 @@ discard block |
||
846 | 846 | } |
847 | 847 | } |
848 | 848 | if($ruleApplies) |
849 | - $rules[]=new TAuthorizationRule($node->getTagName(),$node->getAttribute('users'),$node->getAttribute('roles'),$node->getAttribute('verb'),$node->getAttribute('ips')); |
|
849 | + $rules[]=new TAuthorizationRule($node->getTagName(), $node->getAttribute('users'), $node->getAttribute('roles'), $node->getAttribute('verb'), $node->getAttribute('ips')); |
|
850 | 850 | } |
851 | - $this->_rules=array_merge($rules,$this->_rules); |
|
851 | + $this->_rules=array_merge($rules, $this->_rules); |
|
852 | 852 | } |
853 | 853 | |
854 | 854 | // pages |
855 | 855 | if(($pagesNode=$dom->getElementByTagName('pages'))!==null) |
856 | 856 | { |
857 | - $this->_properties=array_merge($this->_properties,$pagesNode->getAttributes()->toArray()); |
|
857 | + $this->_properties=array_merge($this->_properties, $pagesNode->getAttributes()->toArray()); |
|
858 | 858 | // at the page folder |
859 | 859 | foreach($pagesNode->getElementsByTagName('page') as $node) |
860 | 860 | { |
861 | 861 | $properties=$node->getAttributes(); |
862 | 862 | $id=$properties->remove('id'); |
863 | 863 | if(empty($id)) |
864 | - throw new TConfigurationException('pageserviceconf_page_invalid',$configPath); |
|
864 | + throw new TConfigurationException('pageserviceconf_page_invalid', $configPath); |
|
865 | 865 | $matching=false; |
866 | - $id=($configPagePath==='')?$id:$configPagePath.'.'.$id; |
|
867 | - if(strcasecmp($id,$this->_pagePath)===0) |
|
866 | + $id=($configPagePath==='') ? $id : $configPagePath.'.'.$id; |
|
867 | + if(strcasecmp($id, $this->_pagePath)===0) |
|
868 | 868 | $matching=true; |
869 | - else if($id[strlen($id)-1]==='*') // try wildcard matching |
|
870 | - $matching=strncasecmp($this->_pagePath,$id,strlen($id)-1)===0; |
|
869 | + else if($id[strlen($id) - 1]==='*') // try wildcard matching |
|
870 | + $matching=strncasecmp($this->_pagePath, $id, strlen($id) - 1)===0; |
|
871 | 871 | if($matching) |
872 | - $this->_properties=array_merge($this->_properties,$properties->toArray()); |
|
872 | + $this->_properties=array_merge($this->_properties, $properties->toArray()); |
|
873 | 873 | } |
874 | 874 | } |
875 | 875 | |
@@ -881,9 +881,9 @@ discard block |
||
881 | 881 | if(($filePath=$node->getAttribute('file'))===null) |
882 | 882 | throw new TConfigurationException('pageserviceconf_includefile_required'); |
883 | 883 | if(isset($this->_includes[$filePath])) |
884 | - $this->_includes[$filePath]=array($configPagePath,'('.$this->_includes[$filePath][1].') || ('.$when.')'); |
|
884 | + $this->_includes[$filePath]=array($configPagePath, '('.$this->_includes[$filePath][1].') || ('.$when.')'); |
|
885 | 885 | else |
886 | - $this->_includes[$filePath]=array($configPagePath,$when); |
|
886 | + $this->_includes[$filePath]=array($configPagePath, $when); |
|
887 | 887 | } |
888 | 888 | } |
889 | 889 | } |