@@ -56,6 +56,7 @@ discard block |
||
56 | 56 | /** |
57 | 57 | * Constructor. |
58 | 58 | * @param string the currently request page in the format of Path.To.PageName |
59 | + * @param string $pagePath |
|
59 | 60 | */ |
60 | 61 | public function __construct($pagePath) |
61 | 62 | { |
@@ -103,6 +104,7 @@ discard block |
||
103 | 104 | /** |
104 | 105 | * Loads configuration for a page specified in a path format. |
105 | 106 | * @param string root path for pages |
107 | + * @param string $basePath |
|
106 | 108 | */ |
107 | 109 | public function loadFromFiles($basePath) |
108 | 110 | { |
@@ -130,6 +132,7 @@ discard block |
||
130 | 132 | * Loads a specific config file. |
131 | 133 | * @param string config file name |
132 | 134 | * @param string the page path that the config file is associated with. The page path doesn't include the page name. |
135 | + * @param string $fname |
|
133 | 136 | */ |
134 | 137 | public function loadFromFile($fname,$configPagePath) |
135 | 138 | { |
@@ -152,6 +155,9 @@ discard block |
||
152 | 155 | } |
153 | 156 | } |
154 | 157 | |
158 | + /** |
|
159 | + * @param string $configPath |
|
160 | + */ |
|
155 | 161 | public function loadFromPhp($config,$configPath,$configPagePath) |
156 | 162 | { |
157 | 163 | $this->loadApplicationConfigurationFromPhp($config,$configPath); |
@@ -165,6 +171,8 @@ discard block |
||
165 | 171 | * @param TXmlElement config xml element |
166 | 172 | * @param string the directory containing this configuration |
167 | 173 | * @param string the page path that the config XML is associated with. The page path doesn't include the page name. |
174 | + * @param TXmlDocument $dom |
|
175 | + * @param string $configPath |
|
168 | 176 | */ |
169 | 177 | public function loadFromXml($dom,$configPath,$configPagePath) |
170 | 178 | { |
@@ -141,8 +141,7 @@ |
||
141 | 141 | { |
142 | 142 | $fcontent = include $fname; |
143 | 143 | $this->loadFromPhp($fcontent,dirname($fname),$configPagePath); |
144 | - } |
|
145 | - else |
|
144 | + } else |
|
146 | 145 | { |
147 | 146 | $dom=new TXmlDocument; |
148 | 147 | if($dom->loadFromFile($fname)) |
@@ -106,23 +106,23 @@ discard block |
||
106 | 106 | */ |
107 | 107 | public function loadFromFiles($basePath) |
108 | 108 | { |
109 | - $paths=explode('.',$this->_pagePath); |
|
109 | + $paths=explode('.', $this->_pagePath); |
|
110 | 110 | $page=array_pop($paths); |
111 | 111 | $path=$basePath; |
112 | 112 | $configPagePath=''; |
113 | - $fileName = Prado::getApplication()->getConfigurationType()==TApplication::CONFIG_TYPE_PHP |
|
113 | + $fileName=Prado::getApplication()->getConfigurationType()==TApplication::CONFIG_TYPE_PHP |
|
114 | 114 | ? TPageService::CONFIG_FILE_PHP |
115 | 115 | : TPageService::CONFIG_FILE_XML; |
116 | 116 | foreach($paths as $p) |
117 | 117 | { |
118 | - $this->loadFromFile($path.DIRECTORY_SEPARATOR.$fileName,$configPagePath); |
|
118 | + $this->loadFromFile($path.DIRECTORY_SEPARATOR.$fileName, $configPagePath); |
|
119 | 119 | $path.=DIRECTORY_SEPARATOR.$p; |
120 | 120 | if($configPagePath==='') |
121 | 121 | $configPagePath=$p; |
122 | 122 | else |
123 | 123 | $configPagePath.='.'.$p; |
124 | 124 | } |
125 | - $this->loadFromFile($path.DIRECTORY_SEPARATOR.$fileName,$configPagePath); |
|
125 | + $this->loadFromFile($path.DIRECTORY_SEPARATOR.$fileName, $configPagePath); |
|
126 | 126 | $this->_rules=new TAuthorizationRuleCollection($this->_rules); |
127 | 127 | } |
128 | 128 | |
@@ -131,31 +131,31 @@ discard block |
||
131 | 131 | * @param string config file name |
132 | 132 | * @param string the page path that the config file is associated with. The page path doesn't include the page name. |
133 | 133 | */ |
134 | - public function loadFromFile($fname,$configPagePath) |
|
134 | + public function loadFromFile($fname, $configPagePath) |
|
135 | 135 | { |
136 | - Prado::trace("Loading page configuration file $fname",'System.Web.Services.TPageService'); |
|
136 | + Prado::trace("Loading page configuration file $fname", 'System.Web.Services.TPageService'); |
|
137 | 137 | if(empty($fname) || !is_file($fname)) |
138 | 138 | return; |
139 | 139 | |
140 | 140 | if(Prado::getApplication()->getConfigurationType()==TApplication::CONFIG_TYPE_PHP) |
141 | 141 | { |
142 | - $fcontent = include $fname; |
|
143 | - $this->loadFromPhp($fcontent,dirname($fname),$configPagePath); |
|
142 | + $fcontent=include $fname; |
|
143 | + $this->loadFromPhp($fcontent, dirname($fname), $configPagePath); |
|
144 | 144 | } |
145 | 145 | else |
146 | 146 | { |
147 | 147 | $dom=new TXmlDocument; |
148 | 148 | if($dom->loadFromFile($fname)) |
149 | - $this->loadFromXml($dom,dirname($fname),$configPagePath); |
|
149 | + $this->loadFromXml($dom, dirname($fname), $configPagePath); |
|
150 | 150 | else |
151 | - throw new TConfigurationException('pageserviceconf_file_invalid',$fname); |
|
151 | + throw new TConfigurationException('pageserviceconf_file_invalid', $fname); |
|
152 | 152 | } |
153 | 153 | } |
154 | 154 | |
155 | - public function loadFromPhp($config,$configPath,$configPagePath) |
|
155 | + public function loadFromPhp($config, $configPath, $configPagePath) |
|
156 | 156 | { |
157 | - $this->loadApplicationConfigurationFromPhp($config,$configPath); |
|
158 | - $this->loadPageConfigurationFromPhp($config,$configPath,$configPagePath); |
|
157 | + $this->loadApplicationConfigurationFromPhp($config, $configPath); |
|
158 | + $this->loadPageConfigurationFromPhp($config, $configPath, $configPagePath); |
|
159 | 159 | } |
160 | 160 | |
161 | 161 | /** |
@@ -166,16 +166,16 @@ discard block |
||
166 | 166 | * @param string the directory containing this configuration |
167 | 167 | * @param string the page path that the config XML is associated with. The page path doesn't include the page name. |
168 | 168 | */ |
169 | - public function loadFromXml($dom,$configPath,$configPagePath) |
|
169 | + public function loadFromXml($dom, $configPath, $configPagePath) |
|
170 | 170 | { |
171 | - $this->loadApplicationConfigurationFromXml($dom,$configPath); |
|
172 | - $this->loadPageConfigurationFromXml($dom,$configPath,$configPagePath); |
|
171 | + $this->loadApplicationConfigurationFromXml($dom, $configPath); |
|
172 | + $this->loadPageConfigurationFromXml($dom, $configPath, $configPagePath); |
|
173 | 173 | } |
174 | 174 | |
175 | - public function loadApplicationConfigurationFromPhp($config,$configPath) |
|
175 | + public function loadApplicationConfigurationFromPhp($config, $configPath) |
|
176 | 176 | { |
177 | 177 | $appConfig=new TApplicationConfiguration; |
178 | - $appConfig->loadFromPhp($config,$configPath); |
|
178 | + $appConfig->loadFromPhp($config, $configPath); |
|
179 | 179 | $this->_appConfigs[]=$appConfig; |
180 | 180 | } |
181 | 181 | |
@@ -184,10 +184,10 @@ discard block |
||
184 | 184 | * @param TXmlElement config xml element |
185 | 185 | * @param string base path corresponding to this xml element |
186 | 186 | */ |
187 | - public function loadApplicationConfigurationFromXml($dom,$configPath) |
|
187 | + public function loadApplicationConfigurationFromXml($dom, $configPath) |
|
188 | 188 | { |
189 | 189 | $appConfig=new TApplicationConfiguration; |
190 | - $appConfig->loadFromXml($dom,$configPath); |
|
190 | + $appConfig->loadFromXml($dom, $configPath); |
|
191 | 191 | $this->_appConfigs[]=$appConfig; |
192 | 192 | } |
193 | 193 | |
@@ -196,30 +196,30 @@ discard block |
||
196 | 196 | // authorization |
197 | 197 | if(isset($config['authorization']) && is_array($config['authorization'])) |
198 | 198 | { |
199 | - $rules = array(); |
|
199 | + $rules=array(); |
|
200 | 200 | foreach($config['authorization'] as $authorization) |
201 | 201 | { |
202 | - $patterns=isset($authorization['pages'])?$authorization['pages']:''; |
|
202 | + $patterns=isset($authorization['pages']) ? $authorization['pages'] : ''; |
|
203 | 203 | $ruleApplies=false; |
204 | 204 | if(empty($patterns) || trim($patterns)==='*') // null or empty string |
205 | 205 | $ruleApplies=true; |
206 | 206 | else |
207 | 207 | { |
208 | - foreach(explode(',',$patterns) as $pattern) |
|
208 | + foreach(explode(',', $patterns) as $pattern) |
|
209 | 209 | { |
210 | 210 | if(($pattern=trim($pattern))!=='') |
211 | 211 | { |
212 | 212 | // we know $configPagePath and $this->_pagePath |
213 | 213 | if($configPagePath!=='') // prepend the pattern with ConfigPagePath |
214 | 214 | $pattern=$configPagePath.'.'.$pattern; |
215 | - if(strcasecmp($pattern,$this->_pagePath)===0) |
|
215 | + if(strcasecmp($pattern, $this->_pagePath)===0) |
|
216 | 216 | { |
217 | 217 | $ruleApplies=true; |
218 | 218 | break; |
219 | 219 | } |
220 | - if($pattern[strlen($pattern)-1]==='*') // try wildcard matching |
|
220 | + if($pattern[strlen($pattern) - 1]==='*') // try wildcard matching |
|
221 | 221 | { |
222 | - if(strncasecmp($this->_pagePath,$pattern,strlen($pattern)-1)===0) |
|
222 | + if(strncasecmp($this->_pagePath, $pattern, strlen($pattern) - 1)===0) |
|
223 | 223 | { |
224 | 224 | $ruleApplies=true; |
225 | 225 | break; |
@@ -230,40 +230,40 @@ discard block |
||
230 | 230 | } |
231 | 231 | if($ruleApplies) |
232 | 232 | { |
233 | - $action = isset($authorization['action'])?$authorization['action']:''; |
|
234 | - $users = isset($authorization['users'])?$authorization['users']:''; |
|
235 | - $roles = isset($authorization['roles'])?$authorization['roles']:''; |
|
236 | - $verb = isset($authorization['verb'])?$authorization['verb']:''; |
|
237 | - $ips = isset($authorization['ips'])?$authorization['ips']:''; |
|
238 | - $rules[]=new TAuthorizationRule($action,$users,$roles,$verb,$ips); |
|
233 | + $action=isset($authorization['action']) ? $authorization['action'] : ''; |
|
234 | + $users=isset($authorization['users']) ? $authorization['users'] : ''; |
|
235 | + $roles=isset($authorization['roles']) ? $authorization['roles'] : ''; |
|
236 | + $verb=isset($authorization['verb']) ? $authorization['verb'] : ''; |
|
237 | + $ips=isset($authorization['ips']) ? $authorization['ips'] : ''; |
|
238 | + $rules[]=new TAuthorizationRule($action, $users, $roles, $verb, $ips); |
|
239 | 239 | } |
240 | 240 | } |
241 | - $this->_rules=array_merge($rules,$this->_rules); |
|
241 | + $this->_rules=array_merge($rules, $this->_rules); |
|
242 | 242 | } |
243 | 243 | // pages |
244 | 244 | if(isset($config['pages']) && is_array($config['pages'])) |
245 | 245 | { |
246 | 246 | if(isset($config['pages']['properties'])) |
247 | 247 | { |
248 | - $this->_properties = array_merge($this->_properties, $config['pages']['properties']); |
|
248 | + $this->_properties=array_merge($this->_properties, $config['pages']['properties']); |
|
249 | 249 | unset($config['pages']['properties']); |
250 | 250 | } |
251 | 251 | foreach($config['pages'] as $id => $page) |
252 | 252 | { |
253 | - $properties = array(); |
|
253 | + $properties=array(); |
|
254 | 254 | if(isset($page['properties'])) |
255 | 255 | { |
256 | 256 | $properties=$page['properties']; |
257 | 257 | unset($page['properties']); |
258 | 258 | } |
259 | 259 | $matching=false; |
260 | - $id=($configPagePath==='')?$id:$configPagePath.'.'.$id; |
|
261 | - if(strcasecmp($id,$this->_pagePath)===0) |
|
260 | + $id=($configPagePath==='') ? $id : $configPagePath.'.'.$id; |
|
261 | + if(strcasecmp($id, $this->_pagePath)===0) |
|
262 | 262 | $matching=true; |
263 | - else if($id[strlen($id)-1]==='*') // try wildcard matching |
|
264 | - $matching=strncasecmp($this->_pagePath,$id,strlen($id)-1)===0; |
|
263 | + else if($id[strlen($id) - 1]==='*') // try wildcard matching |
|
264 | + $matching=strncasecmp($this->_pagePath, $id, strlen($id) - 1)===0; |
|
265 | 265 | if($matching) |
266 | - $this->_properties=array_merge($this->_properties,$properties); |
|
266 | + $this->_properties=array_merge($this->_properties, $properties); |
|
267 | 267 | } |
268 | 268 | } |
269 | 269 | |
@@ -272,14 +272,14 @@ discard block |
||
272 | 272 | { |
273 | 273 | foreach($config['includes'] as $include) |
274 | 274 | { |
275 | - $when = isset($include['when'])?true:false; |
|
275 | + $when=isset($include['when']) ?true:false; |
|
276 | 276 | if(!isset($include['file'])) |
277 | 277 | throw new TConfigurationException('pageserviceconf_includefile_required'); |
278 | - $filePath = $include['file']; |
|
278 | + $filePath=$include['file']; |
|
279 | 279 | if(isset($this->_includes[$filePath])) |
280 | - $this->_includes[$filePath]=array($configPagePath,'('.$this->_includes[$filePath][1].') || ('.$when.')'); |
|
280 | + $this->_includes[$filePath]=array($configPagePath, '('.$this->_includes[$filePath][1].') || ('.$when.')'); |
|
281 | 281 | else |
282 | - $this->_includes[$filePath]=array($configPagePath,$when); |
|
282 | + $this->_includes[$filePath]=array($configPagePath, $when); |
|
283 | 283 | } |
284 | 284 | } |
285 | 285 | } |
@@ -290,7 +290,7 @@ discard block |
||
290 | 290 | * @param string base path corresponding to this xml element |
291 | 291 | * @param string the page path that the config XML is associated with. The page path doesn't include the page name. |
292 | 292 | */ |
293 | - public function loadPageConfigurationFromXml($dom,$configPath,$configPagePath) |
|
293 | + public function loadPageConfigurationFromXml($dom, $configPath, $configPagePath) |
|
294 | 294 | { |
295 | 295 | // authorization |
296 | 296 | if(($authorizationNode=$dom->getElementByTagName('authorization'))!==null) |
@@ -304,21 +304,21 @@ discard block |
||
304 | 304 | $ruleApplies=true; |
305 | 305 | else |
306 | 306 | { |
307 | - foreach(explode(',',$patterns) as $pattern) |
|
307 | + foreach(explode(',', $patterns) as $pattern) |
|
308 | 308 | { |
309 | 309 | if(($pattern=trim($pattern))!=='') |
310 | 310 | { |
311 | 311 | // we know $configPagePath and $this->_pagePath |
312 | 312 | if($configPagePath!=='') // prepend the pattern with ConfigPagePath |
313 | 313 | $pattern=$configPagePath.'.'.$pattern; |
314 | - if(strcasecmp($pattern,$this->_pagePath)===0) |
|
314 | + if(strcasecmp($pattern, $this->_pagePath)===0) |
|
315 | 315 | { |
316 | 316 | $ruleApplies=true; |
317 | 317 | break; |
318 | 318 | } |
319 | - if($pattern[strlen($pattern)-1]==='*') // try wildcard matching |
|
319 | + if($pattern[strlen($pattern) - 1]==='*') // try wildcard matching |
|
320 | 320 | { |
321 | - if(strncasecmp($this->_pagePath,$pattern,strlen($pattern)-1)===0) |
|
321 | + if(strncasecmp($this->_pagePath, $pattern, strlen($pattern) - 1)===0) |
|
322 | 322 | { |
323 | 323 | $ruleApplies=true; |
324 | 324 | break; |
@@ -328,30 +328,30 @@ discard block |
||
328 | 328 | } |
329 | 329 | } |
330 | 330 | if($ruleApplies) |
331 | - $rules[]=new TAuthorizationRule($node->getTagName(),$node->getAttribute('users'),$node->getAttribute('roles'),$node->getAttribute('verb'),$node->getAttribute('ips')); |
|
331 | + $rules[]=new TAuthorizationRule($node->getTagName(), $node->getAttribute('users'), $node->getAttribute('roles'), $node->getAttribute('verb'), $node->getAttribute('ips')); |
|
332 | 332 | } |
333 | - $this->_rules=array_merge($rules,$this->_rules); |
|
333 | + $this->_rules=array_merge($rules, $this->_rules); |
|
334 | 334 | } |
335 | 335 | |
336 | 336 | // pages |
337 | 337 | if(($pagesNode=$dom->getElementByTagName('pages'))!==null) |
338 | 338 | { |
339 | - $this->_properties=array_merge($this->_properties,$pagesNode->getAttributes()->toArray()); |
|
339 | + $this->_properties=array_merge($this->_properties, $pagesNode->getAttributes()->toArray()); |
|
340 | 340 | // at the page folder |
341 | 341 | foreach($pagesNode->getElementsByTagName('page') as $node) |
342 | 342 | { |
343 | 343 | $properties=$node->getAttributes(); |
344 | 344 | $id=$properties->remove('id'); |
345 | 345 | if(empty($id)) |
346 | - throw new TConfigurationException('pageserviceconf_page_invalid',$configPath); |
|
346 | + throw new TConfigurationException('pageserviceconf_page_invalid', $configPath); |
|
347 | 347 | $matching=false; |
348 | - $id=($configPagePath==='')?$id:$configPagePath.'.'.$id; |
|
349 | - if(strcasecmp($id,$this->_pagePath)===0) |
|
348 | + $id=($configPagePath==='') ? $id : $configPagePath.'.'.$id; |
|
349 | + if(strcasecmp($id, $this->_pagePath)===0) |
|
350 | 350 | $matching=true; |
351 | - else if($id[strlen($id)-1]==='*') // try wildcard matching |
|
352 | - $matching=strncasecmp($this->_pagePath,$id,strlen($id)-1)===0; |
|
351 | + else if($id[strlen($id) - 1]==='*') // try wildcard matching |
|
352 | + $matching=strncasecmp($this->_pagePath, $id, strlen($id) - 1)===0; |
|
353 | 353 | if($matching) |
354 | - $this->_properties=array_merge($this->_properties,$properties->toArray()); |
|
354 | + $this->_properties=array_merge($this->_properties, $properties->toArray()); |
|
355 | 355 | } |
356 | 356 | } |
357 | 357 | |
@@ -363,9 +363,9 @@ discard block |
||
363 | 363 | if(($filePath=$node->getAttribute('file'))===null) |
364 | 364 | throw new TConfigurationException('pageserviceconf_includefile_required'); |
365 | 365 | if(isset($this->_includes[$filePath])) |
366 | - $this->_includes[$filePath]=array($configPagePath,'('.$this->_includes[$filePath][1].') || ('.$when.')'); |
|
366 | + $this->_includes[$filePath]=array($configPagePath, '('.$this->_includes[$filePath][1].') || ('.$when.')'); |
|
367 | 367 | else |
368 | - $this->_includes[$filePath]=array($configPagePath,$when); |
|
368 | + $this->_includes[$filePath]=array($configPagePath, $when); |
|
369 | 369 | } |
370 | 370 | } |
371 | 371 | } |
372 | 372 | \ No newline at end of file |
@@ -169,6 +169,7 @@ discard block |
||
169 | 169 | * parameter initialization, module loadings, page initial properties |
170 | 170 | * and authorization rules. |
171 | 171 | * @param TPageConfiguration |
172 | + * @param TPageConfiguration $pageConfig |
|
172 | 173 | */ |
173 | 174 | protected function initPageContext($pageConfig) |
174 | 175 | { |
@@ -376,6 +377,7 @@ discard block |
||
376 | 377 | |
377 | 378 | /** |
378 | 379 | * @param string default page path to be served if no explicit page is request |
380 | + * @param string $value |
|
379 | 381 | * @throws TInvalidOperationException if the page service is initialized |
380 | 382 | */ |
381 | 383 | public function setDefaultPage($value) |
@@ -478,7 +480,8 @@ discard block |
||
478 | 480 | /** |
479 | 481 | * Creates a page instance based on requested page path. |
480 | 482 | * @param string requested page path |
481 | - * @return TPage the requested page instance |
|
483 | + * @param string $pagePath |
|
484 | + * @return \Prado\TComponent the requested page instance |
|
482 | 485 | * @throws THttpException if requested page path is invalid |
483 | 486 | * @throws TConfigurationException if the page class cannot be found |
484 | 487 | */ |
@@ -526,6 +529,7 @@ discard block |
||
526 | 529 | * Executes a page. |
527 | 530 | * @param TPage the page instance to be run |
528 | 531 | * @param array list of initial page properties |
532 | + * @param \Prado\TComponent $page |
|
529 | 533 | */ |
530 | 534 | protected function runPage($page,$properties) |
531 | 535 | { |
@@ -540,6 +544,7 @@ discard block |
||
540 | 544 | * @param array list of GET parameters, null if no GET parameters required |
541 | 545 | * @param boolean whether to encode the ampersand in URL, defaults to true. |
542 | 546 | * @param boolean whether to encode the GET parameters (their names and values), defaults to true. |
547 | + * @param string $pagePath |
|
543 | 548 | * @return string URL for the page and GET parameters |
544 | 549 | */ |
545 | 550 | public function constructUrl($pagePath,$getParams=null,$encodeAmpersand=true,$encodeGetItems=true) |
@@ -496,8 +496,8 @@ |
||
496 | 496 | $className=basename($path); |
497 | 497 | $namespacedClassName = static::PAGE_NAMESPACE_PREFIX .str_replace('.', '\\', $pagePath); |
498 | 498 | |
499 | - if(!class_exists($className,false) && !class_exists($namespacedClassName, false)) |
|
500 | - include_once($path.Prado::CLASS_FILE_EXT); |
|
499 | + if(!class_exists($className,false) && !class_exists($namespacedClassName, false)) |
|
500 | + include_once($path.Prado::CLASS_FILE_EXT); |
|
501 | 501 | |
502 | 502 | if(!class_exists($className,false)) |
503 | 503 | $className = $namespacedClassName; |
@@ -239,8 +239,7 @@ discard block |
||
239 | 239 | $pageConfig->loadPageConfigurationFromXml($config,$application->getBasePath(),''); |
240 | 240 | } |
241 | 241 | $pageConfig->loadFromFiles($this->getBasePath()); |
242 | - } |
|
243 | - else |
|
242 | + } else |
|
244 | 243 | { |
245 | 244 | $configCached=true; |
246 | 245 | $currentTimestamp=array(); |
@@ -258,8 +257,7 @@ discard block |
||
258 | 257 | $currentTimestamp[0]=$appConfigFile===null?0:@filemtime($appConfigFile); |
259 | 258 | if($currentTimestamp[0]>$timestamp || ($timestamp>0 && !$currentTimestamp[0])) |
260 | 259 | $configCached=false; |
261 | - } |
|
262 | - else |
|
260 | + } else |
|
263 | 261 | { |
264 | 262 | $currentTimestamp[$fileName]=@filemtime($fileName); |
265 | 263 | if($currentTimestamp[$fileName]>$timestamp || ($timestamp>0 && !$currentTimestamp[$fileName])) |
@@ -267,8 +265,7 @@ discard block |
||
267 | 265 | } |
268 | 266 | } |
269 | 267 | } |
270 | - } |
|
271 | - else |
|
268 | + } else |
|
272 | 269 | { |
273 | 270 | $configCached=false; |
274 | 271 | $paths=explode('.',$pagePath); |
@@ -501,8 +498,7 @@ discard block |
||
501 | 498 | |
502 | 499 | if(!class_exists($className,false)) |
503 | 500 | $className = $namespacedClassName; |
504 | - } |
|
505 | - else |
|
501 | + } else |
|
506 | 502 | { |
507 | 503 | $className=$this->getBasePageClass(); |
508 | 504 | Prado::using($className); |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | /** |
105 | 105 | * Prefix of Pages used for instantiating new pages |
106 | 106 | */ |
107 | - const PAGE_NAMESPACE_PREFIX = 'Application\\Pages\\'; |
|
107 | + const PAGE_NAMESPACE_PREFIX='Application\\Pages\\'; |
|
108 | 108 | /** |
109 | 109 | * @var string root path of pages |
110 | 110 | */ |
@@ -154,7 +154,7 @@ discard block |
||
154 | 154 | */ |
155 | 155 | public function init($config) |
156 | 156 | { |
157 | - Prado::trace("Initializing TPageService",'\Prado\Web\Services\TPageService'); |
|
157 | + Prado::trace("Initializing TPageService", '\Prado\Web\Services\TPageService'); |
|
158 | 158 | |
159 | 159 | $pageConfig=$this->loadPageConfig($config); |
160 | 160 | |
@@ -192,15 +192,15 @@ discard block |
||
192 | 192 | // external configurations |
193 | 193 | foreach($config->getExternalConfigurations() as $filePath=>$params) |
194 | 194 | { |
195 | - list($configPagePath,$condition)=$params; |
|
195 | + list($configPagePath, $condition)=$params; |
|
196 | 196 | if($condition!==true) |
197 | 197 | $condition=$this->evaluateExpression($condition); |
198 | 198 | if($condition) |
199 | 199 | { |
200 | - if(($path=Prado::getPathOfNamespace($filePath,Prado::getApplication()->getConfigurationFileExt()))===null || !is_file($path)) |
|
201 | - throw new TConfigurationException('pageservice_includefile_invalid',$filePath); |
|
200 | + if(($path=Prado::getPathOfNamespace($filePath, Prado::getApplication()->getConfigurationFileExt()))===null || !is_file($path)) |
|
201 | + throw new TConfigurationException('pageservice_includefile_invalid', $filePath); |
|
202 | 202 | $c=new TPageConfiguration($pagePath); |
203 | - $c->loadFromFile($path,$configPagePath); |
|
203 | + $c->loadFromFile($path, $configPagePath); |
|
204 | 204 | $this->applyConfiguration($c); |
205 | 205 | } |
206 | 206 | } |
@@ -234,9 +234,9 @@ discard block |
||
234 | 234 | if($config!==null) |
235 | 235 | { |
236 | 236 | if($application->getConfigurationType()==TApplication::CONFIG_TYPE_PHP) |
237 | - $pageConfig->loadPageConfigurationFromPhp($config,$application->getBasePath(),''); |
|
237 | + $pageConfig->loadPageConfigurationFromPhp($config, $application->getBasePath(), ''); |
|
238 | 238 | else |
239 | - $pageConfig->loadPageConfigurationFromXml($config,$application->getBasePath(),''); |
|
239 | + $pageConfig->loadPageConfigurationFromXml($config, $application->getBasePath(), ''); |
|
240 | 240 | } |
241 | 241 | $pageConfig->loadFromFiles($this->getBasePath()); |
242 | 242 | } |
@@ -247,7 +247,7 @@ discard block |
||
247 | 247 | $arr=$cache->get(self::CONFIG_CACHE_PREFIX.$this->getID().$pagePath); |
248 | 248 | if(is_array($arr)) |
249 | 249 | { |
250 | - list($pageConfig,$timestamps)=$arr; |
|
250 | + list($pageConfig, $timestamps)=$arr; |
|
251 | 251 | if($application->getMode()!==TApplicationMode::Performance) |
252 | 252 | { |
253 | 253 | foreach($timestamps as $fileName=>$timestamp) |
@@ -255,14 +255,14 @@ discard block |
||
255 | 255 | if($fileName===0) // application config file |
256 | 256 | { |
257 | 257 | $appConfigFile=$application->getConfigurationFile(); |
258 | - $currentTimestamp[0]=$appConfigFile===null?0:@filemtime($appConfigFile); |
|
259 | - if($currentTimestamp[0]>$timestamp || ($timestamp>0 && !$currentTimestamp[0])) |
|
258 | + $currentTimestamp[0]=$appConfigFile===null ? 0 : @filemtime($appConfigFile); |
|
259 | + if($currentTimestamp[0] > $timestamp || ($timestamp > 0 && !$currentTimestamp[0])) |
|
260 | 260 | $configCached=false; |
261 | 261 | } |
262 | 262 | else |
263 | 263 | { |
264 | 264 | $currentTimestamp[$fileName]=@filemtime($fileName); |
265 | - if($currentTimestamp[$fileName]>$timestamp || ($timestamp>0 && !$currentTimestamp[$fileName])) |
|
265 | + if($currentTimestamp[$fileName] > $timestamp || ($timestamp > 0 && !$currentTimestamp[$fileName])) |
|
266 | 266 | $configCached=false; |
267 | 267 | } |
268 | 268 | } |
@@ -271,9 +271,9 @@ discard block |
||
271 | 271 | else |
272 | 272 | { |
273 | 273 | $configCached=false; |
274 | - $paths=explode('.',$pagePath); |
|
274 | + $paths=explode('.', $pagePath); |
|
275 | 275 | $configPath=$this->getBasePath(); |
276 | - $fileName = $this->getApplication()->getConfigurationType()==TApplication::CONFIG_TYPE_PHP |
|
276 | + $fileName=$this->getApplication()->getConfigurationType()==TApplication::CONFIG_TYPE_PHP |
|
277 | 277 | ? self::CONFIG_FILE_PHP |
278 | 278 | : self::CONFIG_FILE_XML; |
279 | 279 | foreach($paths as $path) |
@@ -283,7 +283,7 @@ discard block |
||
283 | 283 | $configPath.=DIRECTORY_SEPARATOR.$path; |
284 | 284 | } |
285 | 285 | $appConfigFile=$application->getConfigurationFile(); |
286 | - $currentTimestamp[0]=$appConfigFile===null?0:@filemtime($appConfigFile); |
|
286 | + $currentTimestamp[0]=$appConfigFile===null ? 0 : @filemtime($appConfigFile); |
|
287 | 287 | } |
288 | 288 | if(!$configCached) |
289 | 289 | { |
@@ -291,12 +291,12 @@ discard block |
||
291 | 291 | if($config!==null) |
292 | 292 | { |
293 | 293 | if($application->getConfigurationType()==TApplication::CONFIG_TYPE_PHP) |
294 | - $pageConfig->loadPageConfigurationFromPhp($config,$application->getBasePath(),''); |
|
294 | + $pageConfig->loadPageConfigurationFromPhp($config, $application->getBasePath(), ''); |
|
295 | 295 | else |
296 | - $pageConfig->loadPageConfigurationFromXml($config,$application->getBasePath(),''); |
|
296 | + $pageConfig->loadPageConfigurationFromXml($config, $application->getBasePath(), ''); |
|
297 | 297 | } |
298 | 298 | $pageConfig->loadFromFiles($this->getBasePath()); |
299 | - $cache->set(self::CONFIG_CACHE_PREFIX.$this->getID().$pagePath,array($pageConfig,$currentTimestamp)); |
|
299 | + $cache->set(self::CONFIG_CACHE_PREFIX.$this->getID().$pagePath, array($pageConfig, $currentTimestamp)); |
|
300 | 300 | } |
301 | 301 | } |
302 | 302 | return $pageConfig; |
@@ -351,9 +351,9 @@ discard block |
||
351 | 351 | { |
352 | 352 | if($this->_pagePath===null) |
353 | 353 | { |
354 | - $this->_pagePath=strtr($this->determineRequestedPagePath(),'/\\','..'); |
|
354 | + $this->_pagePath=strtr($this->determineRequestedPagePath(), '/\\', '..'); |
|
355 | 355 | if(empty($this->_pagePath)) |
356 | - throw new THttpException(404,'pageservice_page_required'); |
|
356 | + throw new THttpException(404, 'pageservice_page_required'); |
|
357 | 357 | } |
358 | 358 | return $this->_pagePath; |
359 | 359 | } |
@@ -406,7 +406,7 @@ discard block |
||
406 | 406 | { |
407 | 407 | $basePath=$this->getApplication()->getBasePath().DIRECTORY_SEPARATOR.self::FALLBACK_BASEPATH; |
408 | 408 | if(($this->_basePath=realpath($basePath))===false || !is_dir($this->_basePath)) |
409 | - throw new TConfigurationException('pageservice_basepath_invalid',$basePath); |
|
409 | + throw new TConfigurationException('pageservice_basepath_invalid', $basePath); |
|
410 | 410 | } |
411 | 411 | } |
412 | 412 | return $this->_basePath; |
@@ -421,7 +421,7 @@ discard block |
||
421 | 421 | if($this->_initialized) |
422 | 422 | throw new TInvalidOperationException('pageservice_basepath_unchangeable'); |
423 | 423 | else if(($path=Prado::getPathOfNamespace($value))===null || !is_dir($path)) |
424 | - throw new TConfigurationException('pageservice_basepath_invalid',$value); |
|
424 | + throw new TConfigurationException('pageservice_basepath_invalid', $value); |
|
425 | 425 | $this->_basePath=realpath($path); |
426 | 426 | } |
427 | 427 | |
@@ -470,9 +470,9 @@ discard block |
||
470 | 470 | */ |
471 | 471 | public function run() |
472 | 472 | { |
473 | - Prado::trace("Running page service",'Prado\Web\Services\TPageService'); |
|
473 | + Prado::trace("Running page service", 'Prado\Web\Services\TPageService'); |
|
474 | 474 | $this->_page=$this->createPage($this->getRequestedPagePath()); |
475 | - $this->runPage($this->_page,$this->_properties); |
|
475 | + $this->runPage($this->_page, $this->_properties); |
|
476 | 476 | } |
477 | 477 | |
478 | 478 | /** |
@@ -484,34 +484,34 @@ discard block |
||
484 | 484 | */ |
485 | 485 | protected function createPage($pagePath) |
486 | 486 | { |
487 | - $path=$this->getBasePath().DIRECTORY_SEPARATOR.strtr($pagePath,'.',DIRECTORY_SEPARATOR); |
|
487 | + $path=$this->getBasePath().DIRECTORY_SEPARATOR.strtr($pagePath, '.', DIRECTORY_SEPARATOR); |
|
488 | 488 | $hasTemplateFile=is_file($path.self::PAGE_FILE_EXT); |
489 | 489 | $hasClassFile=is_file($path.Prado::CLASS_FILE_EXT); |
490 | 490 | |
491 | 491 | if(!$hasTemplateFile && !$hasClassFile) |
492 | - throw new THttpException(404,'pageservice_page_unknown',$pagePath); |
|
492 | + throw new THttpException(404, 'pageservice_page_unknown', $pagePath); |
|
493 | 493 | |
494 | 494 | if($hasClassFile) |
495 | 495 | { |
496 | 496 | $className=basename($path); |
497 | - $namespacedClassName = static::PAGE_NAMESPACE_PREFIX .str_replace('.', '\\', $pagePath); |
|
497 | + $namespacedClassName=static::PAGE_NAMESPACE_PREFIX.str_replace('.', '\\', $pagePath); |
|
498 | 498 | |
499 | - if(!class_exists($className,false) && !class_exists($namespacedClassName, false)) |
|
499 | + if(!class_exists($className, false) && !class_exists($namespacedClassName, false)) |
|
500 | 500 | include_once($path.Prado::CLASS_FILE_EXT); |
501 | 501 | |
502 | - if(!class_exists($className,false)) |
|
503 | - $className = $namespacedClassName; |
|
502 | + if(!class_exists($className, false)) |
|
503 | + $className=$namespacedClassName; |
|
504 | 504 | } |
505 | 505 | else |
506 | 506 | { |
507 | 507 | $className=$this->getBasePageClass(); |
508 | 508 | Prado::using($className); |
509 | - if(($pos=strrpos($className,'.'))!==false) |
|
510 | - $className=substr($className,$pos+1); |
|
509 | + if(($pos=strrpos($className, '.'))!==false) |
|
510 | + $className=substr($className, $pos + 1); |
|
511 | 511 | } |
512 | 512 | |
513 | - if($className!=='\Prado\Web\UI\TPage' && !is_subclass_of($className,'\Prado\Web\UI\TPage')) |
|
514 | - throw new THttpException(404,'pageservice_page_unknown',$pagePath); |
|
513 | + if($className!=='\Prado\Web\UI\TPage' && !is_subclass_of($className, '\Prado\Web\UI\TPage')) |
|
514 | + throw new THttpException(404, 'pageservice_page_unknown', $pagePath); |
|
515 | 515 | |
516 | 516 | $page=Prado::createComponent($className); |
517 | 517 | $page->setPagePath($pagePath); |
@@ -527,10 +527,10 @@ discard block |
||
527 | 527 | * @param TPage the page instance to be run |
528 | 528 | * @param array list of initial page properties |
529 | 529 | */ |
530 | - protected function runPage($page,$properties) |
|
530 | + protected function runPage($page, $properties) |
|
531 | 531 | { |
532 | 532 | foreach($properties as $name=>$value) |
533 | - $page->setSubProperty($name,$value); |
|
533 | + $page->setSubProperty($name, $value); |
|
534 | 534 | $page->run($this->getResponse()->createHtmlWriter()); |
535 | 535 | } |
536 | 536 | |
@@ -542,8 +542,8 @@ discard block |
||
542 | 542 | * @param boolean whether to encode the GET parameters (their names and values), defaults to true. |
543 | 543 | * @return string URL for the page and GET parameters |
544 | 544 | */ |
545 | - public function constructUrl($pagePath,$getParams=null,$encodeAmpersand=true,$encodeGetItems=true) |
|
545 | + public function constructUrl($pagePath, $getParams=null, $encodeAmpersand=true, $encodeGetItems=true) |
|
546 | 546 | { |
547 | - return $this->getRequest()->constructUrl($this->getID(),$pagePath,$getParams,$encodeAmpersand,$encodeGetItems); |
|
547 | + return $this->getRequest()->constructUrl($this->getID(), $pagePath, $getParams, $encodeAmpersand, $encodeGetItems); |
|
548 | 548 | } |
549 | 549 | } |
550 | 550 | \ No newline at end of file |
@@ -77,7 +77,7 @@ |
||
77 | 77 | } |
78 | 78 | |
79 | 79 | /** |
80 | - * @return rpc server instance |
|
80 | + * @return TRpcServer server instance |
|
81 | 81 | */ |
82 | 82 | public function getRpcServer() |
83 | 83 | { |
@@ -61,7 +61,7 @@ |
||
61 | 61 | */ |
62 | 62 | public function __construct(TRpcServer $rpcServer) |
63 | 63 | { |
64 | - $this->rpcServer = $rpcServer; |
|
64 | + $this->rpcServer=$rpcServer; |
|
65 | 65 | |
66 | 66 | foreach($this->registerMethods() as $_methodName => $_methodDetails) |
67 | 67 | $this->rpcServer->addRpcMethod($_methodName, $_methodDetails); |
@@ -33,6 +33,7 @@ |
||
33 | 33 | /** |
34 | 34 | * @param string request payload |
35 | 35 | * Processed the request ans returns the response, if any |
36 | + * @param string $requestPayload |
|
36 | 37 | * @return processed response |
37 | 38 | * @abstract |
38 | 39 | */ |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | /** |
27 | 27 | * @var array containing the mapping from RPC method names to the actual handlers |
28 | 28 | */ |
29 | - protected $rpcMethods = array(); |
|
29 | + protected $rpcMethods=array(); |
|
30 | 30 | |
31 | 31 | // abstracts |
32 | 32 | |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | */ |
75 | 75 | public function addMethod($methodName, $handlerDetails) |
76 | 76 | { |
77 | - $this->rpcMethods[$methodName] = $handlerDetails; |
|
77 | + $this->rpcMethods[$methodName]=$handlerDetails; |
|
78 | 78 | } |
79 | 79 | |
80 | 80 | /** |
@@ -88,11 +88,11 @@ discard block |
||
88 | 88 | if(!isset($this->rpcMethods[$methodName])) |
89 | 89 | throw new TRpcException('Method "'.$methodName.'" not found'); |
90 | 90 | |
91 | - if($parameters === null) |
|
92 | - $parameters = array(); |
|
91 | + if($parameters===null) |
|
92 | + $parameters=array(); |
|
93 | 93 | |
94 | 94 | if(!is_array($parameters)) |
95 | - $parameters = array($parameters); |
|
95 | + $parameters=array($parameters); |
|
96 | 96 | return call_user_func_array($this->rpcMethods[$methodName]['method'], $parameters); |
97 | 97 | } |
98 | 98 | } |
99 | 99 | \ No newline at end of file |
@@ -51,7 +51,6 @@ |
||
51 | 51 | /** |
52 | 52 | * Registers a new RPC method and handler details |
53 | 53 | * @param string $methodName |
54 | - * @param array $handlerDetails containing the callback handler |
|
55 | 54 | */ |
56 | 55 | public function addMethod($methodName, $methodDetails) |
57 | 56 | { |
@@ -35,7 +35,7 @@ |
||
35 | 35 | */ |
36 | 36 | public function __construct() |
37 | 37 | { |
38 | - $this->_xmlrpcServer = xmlrpc_server_create(); |
|
38 | + $this->_xmlrpcServer=xmlrpc_server_create(); |
|
39 | 39 | } |
40 | 40 | |
41 | 41 | /** |
@@ -72,16 +72,13 @@ |
||
72 | 72 | try |
73 | 73 | { |
74 | 74 | return xmlrpc_server_call_method($this->_xmlrpcServer, $requestPayload, null); |
75 | - } |
|
76 | - catch(TRpcException $e) |
|
75 | + } catch(TRpcException $e) |
|
77 | 76 | { |
78 | 77 | return $this->createErrorResponse($e); |
79 | - } |
|
80 | - catch(THttpException $e) |
|
78 | + } catch(THttpException $e) |
|
81 | 79 | { |
82 | 80 | throw $e; |
83 | - } |
|
84 | - catch(\Exception $e) |
|
81 | + } catch(\Exception $e) |
|
85 | 82 | { |
86 | 83 | return $this->createErrorResponse(new TRpcException('An internal error occured')); |
87 | 84 | } |
@@ -90,6 +90,7 @@ |
||
90 | 90 | |
91 | 91 | /** |
92 | 92 | * @param integer the time the cookie expires. This is a Unix timestamp so is in number of seconds since the epoch. |
93 | + * @param integer $value |
|
93 | 94 | */ |
94 | 95 | public function setExpire($value) |
95 | 96 | { |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | * @param string name of this cookie |
59 | 59 | * @param string value of this cookie |
60 | 60 | */ |
61 | - public function __construct($name,$value) |
|
61 | + public function __construct($name, $value) |
|
62 | 62 | { |
63 | 63 | $this->_name=$name; |
64 | 64 | $this->_value=$value; |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | */ |
110 | 110 | public function setHttpOnly($value) |
111 | 111 | { |
112 | - $this->_httpOnly = TPropertyValue::ensureBoolean($value); |
|
112 | + $this->_httpOnly=TPropertyValue::ensureBoolean($value); |
|
113 | 113 | } |
114 | 114 | |
115 | 115 | /** |
@@ -37,6 +37,7 @@ discard block |
||
37 | 37 | /** |
38 | 38 | * Constructor. |
39 | 39 | * @param mixed owner of this collection. |
40 | + * @param THttpResponse $owner |
|
40 | 41 | */ |
41 | 42 | public function __construct($owner=null) |
42 | 43 | { |
@@ -80,6 +81,7 @@ discard block |
||
80 | 81 | |
81 | 82 | /** |
82 | 83 | * @param integer|string index of the cookie in the collection or the cookie's name |
84 | + * @param string $index |
|
83 | 85 | * @return THttpCookie the cookie found |
84 | 86 | */ |
85 | 87 | public function itemAt($index) |
@@ -51,11 +51,11 @@ |
||
51 | 51 | * @param mixed new item |
52 | 52 | * @throws TInvalidDataTypeException if the item to be inserted is not a THttpCookie object. |
53 | 53 | */ |
54 | - public function insertAt($index,$item) |
|
54 | + public function insertAt($index, $item) |
|
55 | 55 | { |
56 | 56 | if($item instanceof THttpCookie) |
57 | 57 | { |
58 | - parent::insertAt($index,$item); |
|
58 | + parent::insertAt($index, $item); |
|
59 | 59 | if($this->_o instanceof THttpResponse) |
60 | 60 | $this->_o->addCookie($item); |
61 | 61 | } |
@@ -58,8 +58,7 @@ |
||
58 | 58 | parent::insertAt($index,$item); |
59 | 59 | if($this->_o instanceof THttpResponse) |
60 | 60 | $this->_o->addCookie($item); |
61 | - } |
|
62 | - else |
|
61 | + } else |
|
63 | 62 | throw new TInvalidDataTypeException('httpcookiecollection_httpcookie_required'); |
64 | 63 | } |
65 | 64 |
@@ -87,6 +87,7 @@ |
||
87 | 87 | * Constructor. |
88 | 88 | * Decomposes the specified URI into parts. |
89 | 89 | * @param string URI to be represented |
90 | + * @param string $uri |
|
90 | 91 | * @throws TInvalidDataValueException if URI is of bad format |
91 | 92 | */ |
92 | 93 | public function __construct($uri) |
@@ -94,19 +94,19 @@ |
||
94 | 94 | if(($ret=@parse_url($uri))!==false) |
95 | 95 | { |
96 | 96 | // decoding??? |
97 | - $this->_scheme=isset($ret['scheme'])?$ret['scheme']:''; |
|
98 | - $this->_host=isset($ret['host'])?$ret['host']:''; |
|
99 | - $this->_port=isset($ret['port'])?$ret['port']:''; |
|
100 | - $this->_user=isset($ret['user'])?$ret['user']:''; |
|
101 | - $this->_pass=isset($ret['pass'])?$ret['pass']:''; |
|
102 | - $this->_path=isset($ret['path'])?$ret['path']:''; |
|
103 | - $this->_query=isset($ret['query'])?$ret['query']:''; |
|
104 | - $this->_fragment=isset($ret['fragment'])?$ret['fragment']:''; |
|
97 | + $this->_scheme=isset($ret['scheme']) ? $ret['scheme'] : ''; |
|
98 | + $this->_host=isset($ret['host']) ? $ret['host'] : ''; |
|
99 | + $this->_port=isset($ret['port']) ? $ret['port'] : ''; |
|
100 | + $this->_user=isset($ret['user']) ? $ret['user'] : ''; |
|
101 | + $this->_pass=isset($ret['pass']) ? $ret['pass'] : ''; |
|
102 | + $this->_path=isset($ret['path']) ? $ret['path'] : ''; |
|
103 | + $this->_query=isset($ret['query']) ? $ret['query'] : ''; |
|
104 | + $this->_fragment=isset($ret['fragment']) ? $ret['fragment'] : ''; |
|
105 | 105 | $this->_uri=$uri; |
106 | 106 | } |
107 | 107 | else |
108 | 108 | { |
109 | - throw new TInvalidDataValueException('uri_format_invalid',$uri); |
|
109 | + throw new TInvalidDataValueException('uri_format_invalid', $uri); |
|
110 | 110 | } |
111 | 111 | } |
112 | 112 |
@@ -103,8 +103,7 @@ |
||
103 | 103 | $this->_query=isset($ret['query'])?$ret['query']:''; |
104 | 104 | $this->_fragment=isset($ret['fragment'])?$ret['fragment']:''; |
105 | 105 | $this->_uri=$uri; |
106 | - } |
|
107 | - else |
|
106 | + } else |
|
108 | 107 | { |
109 | 108 | throw new TInvalidDataValueException('uri_format_invalid',$uri); |
110 | 109 | } |
@@ -606,6 +606,7 @@ discard block |
||
606 | 606 | |
607 | 607 | /** |
608 | 608 | * @param string full regular expression mapping pattern. |
609 | + * @param string $value |
|
609 | 610 | */ |
610 | 611 | public function setRegularExpression($value) |
611 | 612 | { |
@@ -715,6 +716,7 @@ discard block |
||
715 | 716 | * Uses URL pattern (or full regular expression if available) to |
716 | 717 | * match the given url path. |
717 | 718 | * @param THttpRequest the request module |
719 | + * @param THttpRequest $request |
|
718 | 720 | * @return array matched parameters, empty if no matches. |
719 | 721 | */ |
720 | 722 | public function getPatternMatches($request) |
@@ -785,7 +787,7 @@ discard block |
||
785 | 787 | } |
786 | 788 | |
787 | 789 | /** |
788 | - * @return THttpRequestUrlFormat the format of URLs. Defaults to THttpRequestUrlFormat::Get. |
|
790 | + * @return string the format of URLs. Defaults to THttpRequestUrlFormat::Get. |
|
789 | 791 | */ |
790 | 792 | public function getUrlFormat() |
791 | 793 | { |
@@ -363,10 +363,10 @@ discard block |
||
363 | 363 | $params=explode('/',$matches['urlparams']); |
364 | 364 | if ($this->_separator==='/') |
365 | 365 | { |
366 | - while($key=array_shift($params)) |
|
367 | - $matches[$key]=($value=array_shift($params)) ? $value : ''; |
|
368 | - } |
|
369 | - else |
|
366 | + while($key=array_shift($params)) { |
|
367 | + $matches[$key]=($value=array_shift($params)) ? $value : ''; |
|
368 | + } |
|
369 | + } else |
|
370 | 370 | { |
371 | 371 | array_pop($params); |
372 | 372 | foreach($params as $param) |
@@ -558,12 +558,10 @@ discard block |
||
558 | 558 | $name=rawurlencode($name.'[]'); |
559 | 559 | foreach($value as $v) |
560 | 560 | $url2.=$amp.$name.'='.rawurlencode($v); |
561 | - } |
|
562 | - else |
|
561 | + } else |
|
563 | 562 | $url2.=$amp.rawurlencode($name).'='.rawurlencode($value); |
564 | 563 | } |
565 | - } |
|
566 | - else |
|
564 | + } else |
|
567 | 565 | { |
568 | 566 | foreach($extra as $name=>$value) |
569 | 567 | { |
@@ -571,8 +569,7 @@ discard block |
||
571 | 569 | { |
572 | 570 | foreach($value as $v) |
573 | 571 | $url2.=$amp.$name.'[]='.$v; |
574 | - } |
|
575 | - else |
|
572 | + } else |
|
576 | 573 | $url2.=$amp.$name.'='.$value; |
577 | 574 | } |
578 | 575 | } |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | * @var TUrlMappingPatternSecureConnection |
159 | 159 | * @since 3.2 |
160 | 160 | */ |
161 | - private $_secureConnection = TUrlMappingPatternSecureConnection::Automatic; |
|
161 | + private $_secureConnection=TUrlMappingPatternSecureConnection::Automatic; |
|
162 | 162 | |
163 | 163 | /** |
164 | 164 | * Constructor. |
@@ -186,7 +186,7 @@ discard block |
||
186 | 186 | { |
187 | 187 | if($this->_serviceParameter===null) |
188 | 188 | throw new TConfigurationException('urlmappingpattern_serviceparameter_required', $this->getPattern()); |
189 | - if(strpos($this->_serviceParameter,'*')!==false) |
|
189 | + if(strpos($this->_serviceParameter, '*')!==false) |
|
190 | 190 | $this->_isWildCardPattern=true; |
191 | 191 | } |
192 | 192 | |
@@ -199,7 +199,7 @@ discard block |
||
199 | 199 | { |
200 | 200 | $params=array(); |
201 | 201 | $values=array(); |
202 | - if ($this->_parameters) |
|
202 | + if($this->_parameters) |
|
203 | 203 | { |
204 | 204 | foreach($this->_parameters as $key=>$value) |
205 | 205 | { |
@@ -207,7 +207,7 @@ discard block |
||
207 | 207 | $values[]='(?P<'.$key.'>'.$value.')'; |
208 | 208 | } |
209 | 209 | } |
210 | - if ($this->getIsWildCardPattern()) |
|
210 | + if($this->getIsWildCardPattern()) |
|
211 | 211 | { |
212 | 212 | $params[]='{*}'; |
213 | 213 | // service parameter must not contain '=' and '/' |
@@ -215,8 +215,8 @@ discard block |
||
215 | 215 | } |
216 | 216 | $params[]='/'; |
217 | 217 | $values[]='\\/'; |
218 | - $regexp=str_replace($params,$values,trim($this->getPattern(),'/').'/'); |
|
219 | - if ($this->_urlFormat===THttpRequestUrlFormat::Get) |
|
218 | + $regexp=str_replace($params, $values, trim($this->getPattern(), '/').'/'); |
|
219 | + if($this->_urlFormat===THttpRequestUrlFormat::Get) |
|
220 | 220 | $regexp='/^'.$regexp.'$/u'; |
221 | 221 | else |
222 | 222 | $regexp='/^'.$regexp.'(?P<urlparams>.*)$/u'; |
@@ -303,7 +303,7 @@ discard block |
||
303 | 303 | */ |
304 | 304 | public function setPattern($value) |
305 | 305 | { |
306 | - $this->_pattern = $value; |
|
306 | + $this->_pattern=$value; |
|
307 | 307 | } |
308 | 308 | |
309 | 309 | /** |
@@ -311,7 +311,7 @@ discard block |
||
311 | 311 | */ |
312 | 312 | public function getParameters() |
313 | 313 | { |
314 | - if (!$this->_parameters) |
|
314 | + if(!$this->_parameters) |
|
315 | 315 | { |
316 | 316 | $this->_parameters=new TAttributeCollection; |
317 | 317 | $this->_parameters->setCaseSensitive(true); |
@@ -333,9 +333,9 @@ discard block |
||
333 | 333 | */ |
334 | 334 | public function getConstants() |
335 | 335 | { |
336 | - if (!$this->_constants) |
|
336 | + if(!$this->_constants) |
|
337 | 337 | { |
338 | - $this->_constants = new TAttributeCollection; |
|
338 | + $this->_constants=new TAttributeCollection; |
|
339 | 339 | $this->_constants->setCaseSensitive(true); |
340 | 340 | } |
341 | 341 | return $this->_constants; |
@@ -351,17 +351,17 @@ discard block |
||
351 | 351 | { |
352 | 352 | $matches=array(); |
353 | 353 | if(($pattern=$this->getRegularExpression())!=='') |
354 | - preg_match($pattern,$request->getPathInfo(),$matches); |
|
354 | + preg_match($pattern, $request->getPathInfo(), $matches); |
|
355 | 355 | else |
356 | - preg_match($this->getParameterizedPattern(),trim($request->getPathInfo(),'/').'/',$matches); |
|
356 | + preg_match($this->getParameterizedPattern(), trim($request->getPathInfo(), '/').'/', $matches); |
|
357 | 357 | |
358 | 358 | if($this->getIsWildCardPattern() && isset($matches[$this->_serviceID])) |
359 | - $matches[$this->_serviceID]=str_replace('*',$matches[$this->_serviceID],$this->_serviceParameter); |
|
359 | + $matches[$this->_serviceID]=str_replace('*', $matches[$this->_serviceID], $this->_serviceParameter); |
|
360 | 360 | |
361 | - if (isset($matches['urlparams'])) |
|
361 | + if(isset($matches['urlparams'])) |
|
362 | 362 | { |
363 | - $params=explode('/',$matches['urlparams']); |
|
364 | - if ($this->_separator==='/') |
|
363 | + $params=explode('/', $matches['urlparams']); |
|
364 | + if($this->_separator==='/') |
|
365 | 365 | { |
366 | 366 | while($key=array_shift($params)) |
367 | 367 | $matches[$key]=($value=array_shift($params)) ? $value : ''; |
@@ -371,7 +371,7 @@ discard block |
||
371 | 371 | array_pop($params); |
372 | 372 | foreach($params as $param) |
373 | 373 | { |
374 | - list($key,$value)=explode($this->_separator,$param,2); |
|
374 | + list($key, $value)=explode($this->_separator, $param, 2); |
|
375 | 375 | $matches[$key]=$value; |
376 | 376 | } |
377 | 377 | } |
@@ -381,7 +381,7 @@ discard block |
||
381 | 381 | if(count($matches) > 0 && $this->_constants) |
382 | 382 | { |
383 | 383 | foreach($this->_constants->toArray() as $key=>$value) |
384 | - $matches[$key] = $value; |
|
384 | + $matches[$key]=$value; |
|
385 | 385 | } |
386 | 386 | |
387 | 387 | return $matches; |
@@ -435,7 +435,7 @@ discard block |
||
435 | 435 | */ |
436 | 436 | public function setUrlFormat($value) |
437 | 437 | { |
438 | - $this->_urlFormat=TPropertyValue::ensureEnum($value,'Prado\\Web\\THttpRequestUrlFormat'); |
|
438 | + $this->_urlFormat=TPropertyValue::ensureEnum($value, 'Prado\\Web\\THttpRequestUrlFormat'); |
|
439 | 439 | } |
440 | 440 | |
441 | 441 | /** |
@@ -473,7 +473,7 @@ discard block |
||
473 | 473 | */ |
474 | 474 | public function setSecureConnection($value) |
475 | 475 | { |
476 | - $this->_secureConnection = TPropertyValue::ensureEnum($value, 'Prado\\Web\\TUrlMappingPatternSecureConnection'); |
|
476 | + $this->_secureConnection=TPropertyValue::ensureEnum($value, 'Prado\\Web\\TUrlMappingPatternSecureConnection'); |
|
477 | 477 | } |
478 | 478 | |
479 | 479 | /** |
@@ -485,7 +485,7 @@ discard block |
||
485 | 485 | { |
486 | 486 | if(!$this->_customUrl || $this->getPattern()===null) |
487 | 487 | return false; |
488 | - if ($this->_parameters) |
|
488 | + if($this->_parameters) |
|
489 | 489 | { |
490 | 490 | foreach($this->_parameters as $key=>$value) |
491 | 491 | { |
@@ -494,13 +494,13 @@ discard block |
||
494 | 494 | } |
495 | 495 | } |
496 | 496 | |
497 | - if ($this->_constants) |
|
497 | + if($this->_constants) |
|
498 | 498 | { |
499 | 499 | foreach($this->_constants->toArray() as $key=>$value) |
500 | 500 | { |
501 | - if (!isset($getItems[$key])) |
|
501 | + if(!isset($getItems[$key])) |
|
502 | 502 | return false; |
503 | - if ($getItems[$key]!=$value) |
|
503 | + if($getItems[$key]!=$value) |
|
504 | 504 | return false; |
505 | 505 | } |
506 | 506 | } |
@@ -515,9 +515,9 @@ discard block |
||
515 | 515 | * @return string the constructed URL |
516 | 516 | * @since 3.1.1 |
517 | 517 | */ |
518 | - public function constructUrl($getItems,$encodeAmpersand,$encodeGetItems) |
|
518 | + public function constructUrl($getItems, $encodeAmpersand, $encodeGetItems) |
|
519 | 519 | { |
520 | - if ($this->_constants) |
|
520 | + if($this->_constants) |
|
521 | 521 | { |
522 | 522 | foreach($this->_constants->toArray() as $key=>$value) |
523 | 523 | { |
@@ -536,19 +536,19 @@ discard block |
||
536 | 536 | $extra[$key]=$value; |
537 | 537 | } |
538 | 538 | |
539 | - $url=$this->_manager->getUrlPrefix().'/'.ltrim(strtr($this->getPattern(),$replace),'/'); |
|
539 | + $url=$this->_manager->getUrlPrefix().'/'.ltrim(strtr($this->getPattern(), $replace), '/'); |
|
540 | 540 | |
541 | 541 | // for the rest of the GET variables, put them in the query string |
542 | - if(count($extra)>0) |
|
542 | + if(count($extra) > 0) |
|
543 | 543 | { |
544 | - if ($this->_urlFormat===THttpRequestUrlFormat::Path && $this->getIsWildCardPattern()) { |
|
545 | - foreach ($extra as $name=>$value) |
|
546 | - $url.='/'.$name.$this->_separator.($encodeGetItems?rawurlencode($value):$value); |
|
544 | + if($this->_urlFormat===THttpRequestUrlFormat::Path && $this->getIsWildCardPattern()) { |
|
545 | + foreach($extra as $name=>$value) |
|
546 | + $url.='/'.$name.$this->_separator.($encodeGetItems ?rawurlencode($value) : $value); |
|
547 | 547 | return $url; |
548 | 548 | } |
549 | 549 | |
550 | 550 | $url2=''; |
551 | - $amp=$encodeAmpersand?'&':'&'; |
|
551 | + $amp=$encodeAmpersand ? '&' : '&'; |
|
552 | 552 | if($encodeGetItems) |
553 | 553 | { |
554 | 554 | foreach($extra as $name=>$value) |
@@ -576,7 +576,7 @@ discard block |
||
576 | 576 | $url2.=$amp.$name.'='.$value; |
577 | 577 | } |
578 | 578 | } |
579 | - $url=$url.'?'.substr($url2,strlen($amp)); |
|
579 | + $url=$url.'?'.substr($url2, strlen($amp)); |
|
580 | 580 | } |
581 | 581 | return $this -> applySecureConnectionPrefix($url); |
582 | 582 | } |
@@ -592,26 +592,26 @@ discard block |
||
592 | 592 | protected function applySecureConnectionPrefix($url) |
593 | 593 | { |
594 | 594 | static $request; |
595 | - if($request === null) $request = Prado::getApplication() -> getRequest(); |
|
595 | + if($request===null) $request=Prado::getApplication() -> getRequest(); |
|
596 | 596 | |
597 | 597 | static $isSecureConnection; |
598 | - if($isSecureConnection === null) $isSecureConnection = $request -> getIsSecureConnection(); |
|
598 | + if($isSecureConnection===null) $isSecureConnection=$request -> getIsSecureConnection(); |
|
599 | 599 | |
600 | 600 | switch($this -> getSecureConnection()) |
601 | 601 | { |
602 | 602 | case TUrlMappingPatternSecureConnection::EnableIfNotSecure: |
603 | 603 | if($isSecureConnection) return $url; |
604 | - return $request -> getBaseUrl(true) . $url; |
|
604 | + return $request -> getBaseUrl(true).$url; |
|
605 | 605 | break; |
606 | 606 | case TUrlMappingPatternSecureConnection::DisableIfSecure: |
607 | 607 | if(!$isSecureConnection) return $url; |
608 | - return $request -> getBaseUrl(false) . $url; |
|
608 | + return $request -> getBaseUrl(false).$url; |
|
609 | 609 | break; |
610 | 610 | case TUrlMappingPatternSecureConnection::Enable: |
611 | - return $request -> getBaseUrl(true) . $url; |
|
611 | + return $request -> getBaseUrl(true).$url; |
|
612 | 612 | break; |
613 | 613 | case TUrlMappingPatternSecureConnection::Disable: |
614 | - return $request -> getBaseUrl(false) . $url; |
|
614 | + return $request -> getBaseUrl(false).$url; |
|
615 | 615 | break; |
616 | 616 | case TUrlMappingPatternSecureConnection::Automatic: |
617 | 617 | default: |