@@ -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 | } |
@@ -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 | } |
@@ -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 |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | $this->loadConfig($dom); |
121 | 121 | } |
122 | 122 | else |
123 | - throw new TConfigurationException('soapservice_configfile_invalid',$this->_configFile); |
|
123 | + throw new TConfigurationException('soapservice_configfile_invalid', $this->_configFile); |
|
124 | 124 | } |
125 | 125 | $this->loadConfig($config); |
126 | 126 | |
@@ -137,16 +137,16 @@ discard block |
||
137 | 137 | protected function resolveRequest() |
138 | 138 | { |
139 | 139 | $serverID=$this->getRequest()->getServiceParameter(); |
140 | - if(($pos=strrpos($serverID,'.wsdl'))===strlen($serverID)-5) |
|
140 | + if(($pos=strrpos($serverID, '.wsdl'))===strlen($serverID) - 5) |
|
141 | 141 | { |
142 | - $serverID=substr($serverID,0,$pos); |
|
142 | + $serverID=substr($serverID, 0, $pos); |
|
143 | 143 | $this->_wsdlRequest=true; |
144 | 144 | } |
145 | 145 | else |
146 | 146 | $this->_wsdlRequest=false; |
147 | 147 | $this->_serverID=$serverID; |
148 | 148 | if(!isset($this->_servers[$serverID])) |
149 | - throw new THttpException(400,'soapservice_request_invalid',$serverID); |
|
149 | + throw new THttpException(400, 'soapservice_request_invalid', $serverID); |
|
150 | 150 | } |
151 | 151 | |
152 | 152 | /** |
@@ -162,9 +162,9 @@ discard block |
||
162 | 162 | { |
163 | 163 | foreach($config['soap'] as $id => $server) |
164 | 164 | { |
165 | - $properties = isset($server['properties'])?$server['properties']:array(); |
|
165 | + $properties=isset($server['properties']) ? $server['properties'] : array(); |
|
166 | 166 | if(isset($this->_servers[$id])) |
167 | - throw new TConfigurationException('soapservice_serverid_duplicated',$id); |
|
167 | + throw new TConfigurationException('soapservice_serverid_duplicated', $id); |
|
168 | 168 | $this->_servers[$id]=$properties; |
169 | 169 | } |
170 | 170 | } |
@@ -177,7 +177,7 @@ discard block |
||
177 | 177 | if(($id=$properties->remove('id'))===null) |
178 | 178 | throw new TConfigurationException('soapservice_serverid_required'); |
179 | 179 | if(isset($this->_servers[$id])) |
180 | - throw new TConfigurationException('soapservice_serverid_duplicated',$id); |
|
180 | + throw new TConfigurationException('soapservice_serverid_duplicated', $id); |
|
181 | 181 | $this->_servers[$id]=$properties; |
182 | 182 | } |
183 | 183 | } |
@@ -198,8 +198,8 @@ discard block |
||
198 | 198 | */ |
199 | 199 | public function setConfigFile($value) |
200 | 200 | { |
201 | - if(($this->_configFile=Prado::getPathOfNamespace($value,Prado::getApplication()->getConfigurationFileExt()))===null) |
|
202 | - throw new TConfigurationException('soapservice_configfile_invalid',$value); |
|
201 | + if(($this->_configFile=Prado::getPathOfNamespace($value, Prado::getApplication()->getConfigurationFileExt()))===null) |
|
202 | + throw new TConfigurationException('soapservice_configfile_invalid', $value); |
|
203 | 203 | } |
204 | 204 | |
205 | 205 | /** |
@@ -210,9 +210,9 @@ discard block |
||
210 | 210 | * @param boolean whether to encode the GET parameters (their names and values), defaults to true. |
211 | 211 | * @return string URL for the page and GET parameters |
212 | 212 | */ |
213 | - public function constructUrl($serverID,$getParams=null,$encodeAmpersand=true,$encodeGetItems=true) |
|
213 | + public function constructUrl($serverID, $getParams=null, $encodeAmpersand=true, $encodeGetItems=true) |
|
214 | 214 | { |
215 | - return $this->getRequest()->constructUrl($this->getID(),$serverID,$getParams,$encodeAmpersand,$encodeGetItems); |
|
215 | + return $this->getRequest()->constructUrl($this->getID(), $serverID, $getParams, $encodeAmpersand, $encodeGetItems); |
|
216 | 216 | } |
217 | 217 | |
218 | 218 | /** |
@@ -248,13 +248,13 @@ discard block |
||
248 | 248 | if($serverClass===null) |
249 | 249 | $serverClass=self::DEFAULT_SOAP_SERVER; |
250 | 250 | Prado::using($serverClass); |
251 | - $className=($pos=strrpos($serverClass,'.'))!==false?substr($serverClass,$pos+1):$serverClass; |
|
252 | - if($className!==self::DEFAULT_SOAP_SERVER && !is_subclass_of($className,self::DEFAULT_SOAP_SERVER)) |
|
253 | - throw new TConfigurationException('soapservice_server_invalid',$serverClass); |
|
251 | + $className=($pos=strrpos($serverClass, '.'))!==false ? substr($serverClass, $pos + 1) : $serverClass; |
|
252 | + if($className!==self::DEFAULT_SOAP_SERVER && !is_subclass_of($className, self::DEFAULT_SOAP_SERVER)) |
|
253 | + throw new TConfigurationException('soapservice_server_invalid', $serverClass); |
|
254 | 254 | $server=new $className; |
255 | 255 | $server->setID($this->_serverID); |
256 | 256 | foreach($properties as $name=>$value) |
257 | - $server->setSubproperty($name,$value); |
|
257 | + $server->setSubproperty($name, $value); |
|
258 | 258 | return $server; |
259 | 259 | } |
260 | 260 | |
@@ -266,21 +266,21 @@ discard block |
||
266 | 266 | */ |
267 | 267 | public function run() |
268 | 268 | { |
269 | - Prado::trace("Running SOAP service",'System.Web.Services.TSoapService'); |
|
269 | + Prado::trace("Running SOAP service", 'System.Web.Services.TSoapService'); |
|
270 | 270 | $server=$this->createServer(); |
271 | 271 | $this->getResponse()->setContentType('text/xml'); |
272 | 272 | $this->getResponse()->setCharset($server->getEncoding()); |
273 | 273 | if($this->getIsWsdlRequest()) |
274 | 274 | { |
275 | 275 | // server WSDL file |
276 | - Prado::trace("Generating WSDL",'System.Web.Services.TSoapService'); |
|
276 | + Prado::trace("Generating WSDL", 'System.Web.Services.TSoapService'); |
|
277 | 277 | $this->getResponse()->clear(); |
278 | 278 | $this->getResponse()->write($server->getWsdl()); |
279 | 279 | } |
280 | 280 | else |
281 | 281 | { |
282 | 282 | // provide SOAP service |
283 | - Prado::trace("Handling SOAP request",'System.Web.Services.TSoapService'); |
|
283 | + Prado::trace("Handling SOAP request", 'System.Web.Services.TSoapService'); |
|
284 | 284 | $server->run(); |
285 | 285 | } |
286 | 286 | } |
@@ -331,8 +331,8 @@ discard block |
||
331 | 331 | */ |
332 | 332 | public function setID($id) |
333 | 333 | { |
334 | - if(strrpos($this->_id,'.wsdl')===strlen($this->_id)-5) |
|
335 | - throw new TInvalidDataValueException('soapserver_id_invalid',$id); |
|
334 | + if(strrpos($this->_id, '.wsdl')===strlen($this->_id) - 5) |
|
335 | + throw new TInvalidDataValueException('soapserver_id_invalid', $id); |
|
336 | 336 | $this->_id=$id; |
337 | 337 | } |
338 | 338 | |
@@ -344,7 +344,7 @@ discard block |
||
344 | 344 | if(($provider=$this->getProvider())!==null) |
345 | 345 | { |
346 | 346 | Prado::using($provider); |
347 | - $providerClass=($pos=strrpos($provider,'.'))!==false?substr($provider,$pos+1):$provider; |
|
347 | + $providerClass=($pos=strrpos($provider, '.'))!==false ? substr($provider, $pos + 1) : $provider; |
|
348 | 348 | $this->guessMethodCallRequested($providerClass); |
349 | 349 | $server=$this->createServer(); |
350 | 350 | $server->setClass($providerClass, $this); |
@@ -357,7 +357,7 @@ discard block |
||
357 | 357 | { |
358 | 358 | $server->handle(); |
359 | 359 | } |
360 | - catch (Exception $e) |
|
360 | + catch(Exception $e) |
|
361 | 361 | { |
362 | 362 | if($this->getApplication()->getMode()===TApplicationMode::Debug) |
363 | 363 | $this->fault($e->getMessage(), $e->__toString()); |
@@ -376,7 +376,7 @@ discard block |
||
376 | 376 | */ |
377 | 377 | public function fault($title, $details='', $code='SERVER', $actor='', $name='') |
378 | 378 | { |
379 | - Prado::trace('SOAP-Fault '.$code. ' '.$title.' : '.$details, 'System.Web.Services.TSoapService'); |
|
379 | + Prado::trace('SOAP-Fault '.$code.' '.$title.' : '.$details, 'System.Web.Services.TSoapService'); |
|
380 | 380 | $this->_server->fault($code, $title, $actor, $details, $name); |
381 | 381 | } |
382 | 382 | |
@@ -387,14 +387,14 @@ discard block |
||
387 | 387 | */ |
388 | 388 | protected function guessMethodCallRequested($class) |
389 | 389 | { |
390 | - $namespace = $class.'wsdl'; |
|
391 | - $message = file_get_contents("php://input"); |
|
392 | - $matches= array(); |
|
390 | + $namespace=$class.'wsdl'; |
|
391 | + $message=file_get_contents("php://input"); |
|
392 | + $matches=array(); |
|
393 | 393 | if(preg_match('/xmlns:([^=]+)="urn:'.$namespace.'"/', $message, $matches)) |
394 | 394 | { |
395 | 395 | if(preg_match('/<'.$matches[1].':([a-zA-Z_]+[a-zA-Z0-9_]+)/', $message, $method)) |
396 | 396 | { |
397 | - $this->_requestedMethod = $method[1]; |
|
397 | + $this->_requestedMethod=$method[1]; |
|
398 | 398 | } |
399 | 399 | } |
400 | 400 | } |
@@ -417,8 +417,8 @@ discard block |
||
417 | 417 | if($this->_server===null) |
418 | 418 | { |
419 | 419 | if($this->getApplication()->getMode()===TApplicationMode::Debug) |
420 | - ini_set("soap.wsdl_cache_enabled",0); |
|
421 | - $this->_server = new SoapServer($this->getWsdlUri(),$this->getOptions()); |
|
420 | + ini_set("soap.wsdl_cache_enabled", 0); |
|
421 | + $this->_server=new SoapServer($this->getWsdlUri(), $this->getOptions()); |
|
422 | 422 | } |
423 | 423 | return $this->_server; |
424 | 424 | } |
@@ -459,7 +459,7 @@ discard block |
||
459 | 459 | if($this->_wsdlUri==='') |
460 | 460 | { |
461 | 461 | $provider=$this->getProvider(); |
462 | - $providerClass=($pos=strrpos($provider,'.'))!==false?substr($provider,$pos+1):$provider; |
|
462 | + $providerClass=($pos=strrpos($provider, '.'))!==false ? substr($provider, $pos + 1) : $provider; |
|
463 | 463 | Prado::using($provider); |
464 | 464 | if($this->getApplication()->getMode()===TApplicationMode::Performance && ($cache=$this->getApplication()->getCache())!==null) |
465 | 465 | { |
@@ -468,7 +468,7 @@ discard block |
||
468 | 468 | return $wsdl; |
469 | 469 | Prado::using('System.3rdParty.WsdlGen.WsdlGenerator'); |
470 | 470 | $wsdl=WsdlGenerator::generate($providerClass, $this->getUri(), $this->getEncoding()); |
471 | - $cache->set(self::WSDL_CACHE_PREFIX.$providerClass,$wsdl); |
|
471 | + $cache->set(self::WSDL_CACHE_PREFIX.$providerClass, $wsdl); |
|
472 | 472 | return $wsdl; |
473 | 473 | } |
474 | 474 | else |
@@ -487,7 +487,7 @@ discard block |
||
487 | 487 | public function getWsdlUri() |
488 | 488 | { |
489 | 489 | if($this->_wsdlUri==='') |
490 | - return $this->getRequest()->getBaseUrl().$this->getService()->constructUrl($this->getID().'.wsdl',false); |
|
490 | + return $this->getRequest()->getBaseUrl().$this->getService()->constructUrl($this->getID().'.wsdl', false); |
|
491 | 491 | else |
492 | 492 | return $this->_wsdlUri; |
493 | 493 | } |
@@ -506,7 +506,7 @@ discard block |
||
506 | 506 | public function getUri() |
507 | 507 | { |
508 | 508 | if($this->_uri==='') |
509 | - return $this->getRequest()->getBaseUrl().$this->getService()->constructUrl($this->getID(),false); |
|
509 | + return $this->getRequest()->getBaseUrl().$this->getService()->constructUrl($this->getID(), false); |
|
510 | 510 | else |
511 | 511 | return $this->_uri; |
512 | 512 | } |
@@ -552,7 +552,7 @@ discard block |
||
552 | 552 | if($value==='1.1' || $value==='1.2' || $value==='') |
553 | 553 | $this->_version=$value; |
554 | 554 | else |
555 | - throw new TInvalidDataValueException('soapserver_version_invalid',$value); |
|
555 | + throw new TInvalidDataValueException('soapserver_version_invalid', $value); |
|
556 | 556 | } |
557 | 557 | |
558 | 558 | /** |
@@ -616,7 +616,7 @@ discard block |
||
616 | 616 | */ |
617 | 617 | public function setClassMaps($classes) |
618 | 618 | { |
619 | - $this->_classMap = $classes; |
|
619 | + $this->_classMap=$classes; |
|
620 | 620 | } |
621 | 621 | } |
622 | 622 |