@@ -361,7 +361,7 @@ |
||
361 | 361 | /** |
362 | 362 | * Create a new Jaxon response object |
363 | 363 | * |
364 | - * @return Jaxon\Response\Response |
|
364 | + * @return \Jaxon\Response\Response |
|
365 | 365 | */ |
366 | 366 | public function newResponse() |
367 | 367 | { |
@@ -16,7 +16,6 @@ |
||
16 | 16 | |
17 | 17 | use Lemon\Event\EventDispatcher; |
18 | 18 | use Jaxon\Sentry\View\Renderer; |
19 | - |
|
20 | 19 | use Jaxon\Config\Config; |
21 | 20 | use Jaxon\Config\Reader as ConfigReader; |
22 | 21 | use Jaxon\Request\Support\CallableRepository; |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | |
35 | 35 | public static function getInstance() |
36 | 36 | { |
37 | - if(!self::$xInstance) |
|
37 | + if (!self::$xInstance) |
|
38 | 38 | { |
39 | 39 | self::$xInstance = new Container(); |
40 | 40 | } |
@@ -94,37 +94,37 @@ discard block |
||
94 | 94 | * Managers |
95 | 95 | */ |
96 | 96 | // Callable objects repository |
97 | - $this->coreContainer[CallableRepository::class] = function ($c) { |
|
97 | + $this->coreContainer[CallableRepository::class] = function($c) { |
|
98 | 98 | return new CallableRepository(); |
99 | 99 | }; |
100 | 100 | // Plugin Manager |
101 | - $this->coreContainer['jaxon.core.plugin_manager'] = function ($c) { |
|
101 | + $this->coreContainer['jaxon.core.plugin_manager'] = function($c) { |
|
102 | 102 | return new \Jaxon\Plugin\Manager(); |
103 | 103 | }; |
104 | 104 | // Request Manager |
105 | - $this->coreContainer['jaxon.core.request_manager'] = function ($c) { |
|
105 | + $this->coreContainer['jaxon.core.request_manager'] = function($c) { |
|
106 | 106 | return new \Jaxon\Request\Manager(); |
107 | 107 | }; |
108 | 108 | // Request Factory |
109 | - $this->coreContainer['jaxon.core.request_factory'] = function ($c) { |
|
109 | + $this->coreContainer['jaxon.core.request_factory'] = function($c) { |
|
110 | 110 | return new \Jaxon\Factory\Request($c[CallableRepository::class]); |
111 | 111 | }; |
112 | 112 | // Parameter Factory |
113 | - $this->coreContainer['jaxon.core.parameter_factory'] = function ($c) { |
|
113 | + $this->coreContainer['jaxon.core.parameter_factory'] = function($c) { |
|
114 | 114 | return new \Jaxon\Factory\Parameter(); |
115 | 115 | }; |
116 | 116 | // Response Manager |
117 | - $this->coreContainer['jaxon.core.response_manager'] = function ($c) { |
|
117 | + $this->coreContainer['jaxon.core.response_manager'] = function($c) { |
|
118 | 118 | return new \Jaxon\Response\Manager(); |
119 | 119 | }; |
120 | 120 | |
121 | 121 | /* |
122 | 122 | * Config |
123 | 123 | */ |
124 | - $this->coreContainer[Config::class] = function ($c) { |
|
124 | + $this->coreContainer[Config::class] = function($c) { |
|
125 | 125 | return new Config(); |
126 | 126 | }; |
127 | - $this->coreContainer[ConfigReader::class] = function ($c) { |
|
127 | + $this->coreContainer[ConfigReader::class] = function($c) { |
|
128 | 128 | return new ConfigReader(); |
129 | 129 | }; |
130 | 130 | |
@@ -132,31 +132,31 @@ discard block |
||
132 | 132 | * Services |
133 | 133 | */ |
134 | 134 | // Minifier |
135 | - $this->coreContainer['jaxon.core.minifier'] = function ($c) { |
|
135 | + $this->coreContainer['jaxon.core.minifier'] = function($c) { |
|
136 | 136 | return new \Jaxon\Utils\Template\Minifier(); |
137 | 137 | }; |
138 | 138 | // Translator |
139 | - $this->coreContainer['jaxon.core.translator'] = function ($c) { |
|
139 | + $this->coreContainer['jaxon.core.translator'] = function($c) { |
|
140 | 140 | return new \Jaxon\Utils\Translation\Translator($c['jaxon.core.translation_dir'], $c[Config::class]); |
141 | 141 | }; |
142 | 142 | // Template engine |
143 | - $this->coreContainer['jaxon.core.template'] = function ($c) { |
|
143 | + $this->coreContainer['jaxon.core.template'] = function($c) { |
|
144 | 144 | return new \Jaxon\Utils\Template\Template($c['jaxon.core.template_dir']); |
145 | 145 | }; |
146 | 146 | // Validator |
147 | - $this->coreContainer['jaxon.core.validator'] = function ($c) { |
|
147 | + $this->coreContainer['jaxon.core.validator'] = function($c) { |
|
148 | 148 | return new \Jaxon\Utils\Validation\Validator($c['jaxon.core.translator'], $c[Config::class]); |
149 | 149 | }; |
150 | 150 | // Pagination Renderer |
151 | - $this->coreContainer['jaxon.pagination.renderer'] = function ($c) { |
|
151 | + $this->coreContainer['jaxon.pagination.renderer'] = function($c) { |
|
152 | 152 | return new \Jaxon\Utils\Pagination\Renderer($c['jaxon.core.template']); |
153 | 153 | }; |
154 | 154 | // Pagination Paginator |
155 | - $this->coreContainer['jaxon.pagination.paginator'] = function ($c) { |
|
155 | + $this->coreContainer['jaxon.pagination.paginator'] = function($c) { |
|
156 | 156 | return new \Jaxon\Utils\Pagination\Paginator($c['jaxon.pagination.renderer']); |
157 | 157 | }; |
158 | 158 | // Event Dispatcher |
159 | - $this->coreContainer['jaxon.core.events'] = function ($c) { |
|
159 | + $this->coreContainer['jaxon.core.events'] = function($c) { |
|
160 | 160 | return new EventDispatcher(); |
161 | 161 | }; |
162 | 162 | |
@@ -164,15 +164,15 @@ discard block |
||
164 | 164 | * Core library objects |
165 | 165 | */ |
166 | 166 | // Global Response |
167 | - $this->coreContainer['jaxon.core.response'] = function ($c) { |
|
167 | + $this->coreContainer['jaxon.core.response'] = function($c) { |
|
168 | 168 | return new \Jaxon\Response\Response(); |
169 | 169 | }; |
170 | 170 | // Jaxon Core |
171 | - $this->coreContainer['jaxon.core.jaxon'] = function ($c) { |
|
171 | + $this->coreContainer['jaxon.core.jaxon'] = function($c) { |
|
172 | 172 | return new \Jaxon\Jaxon(); |
173 | 173 | }; |
174 | 174 | // View Renderer Facade |
175 | - $this->coreContainer['jaxon.sentry.view.renderer'] = function ($c) { |
|
175 | + $this->coreContainer['jaxon.sentry.view.renderer'] = function($c) { |
|
176 | 176 | $aRenderers = $c['jaxon.view.data.renderers']; |
177 | 177 | $sDefaultNamespace = $c['jaxon.view.data.namespace.default']; |
178 | 178 | return new \Jaxon\Sentry\View\Facade($aRenderers, $sDefaultNamespace); |
@@ -186,7 +186,7 @@ discard block |
||
186 | 186 | */ |
187 | 187 | public function get($sClass) |
188 | 188 | { |
189 | - if($this->sentryContainer != null && $this->sentryContainer->has($sClass)) |
|
189 | + if ($this->sentryContainer != null && $this->sentryContainer->has($sClass)) |
|
190 | 190 | { |
191 | 191 | return $this->sentryContainer->get($sClass); |
192 | 192 | } |
@@ -471,14 +471,14 @@ discard block |
||
471 | 471 | $this->coreContainer['jaxon.sentry.view.base.' . $sId] = $xClosure; |
472 | 472 | |
473 | 473 | // Return the initialized view renderer |
474 | - $this->coreContainer['jaxon.sentry.view.' . $sId] = function ($c) use ($sId) { |
|
474 | + $this->coreContainer['jaxon.sentry.view.' . $sId] = function($c) use ($sId) { |
|
475 | 475 | // Get the defined renderer |
476 | 476 | $renderer = $c['jaxon.sentry.view.base.' . $sId]; |
477 | 477 | // Init the renderer with the template namespaces |
478 | 478 | $aNamespaces = $this->coreContainer['jaxon.view.data.namespaces']; |
479 | - if(key_exists($sId, $aNamespaces)) |
|
479 | + if (key_exists($sId, $aNamespaces)) |
|
480 | 480 | { |
481 | - foreach($aNamespaces[$sId] as $ns) |
|
481 | + foreach ($aNamespaces[$sId] as $ns) |
|
482 | 482 | { |
483 | 483 | $renderer->addNamespace($ns['namespace'], $ns['directory'], $ns['extension']); |
484 | 484 | } |
@@ -496,7 +496,7 @@ discard block |
||
496 | 496 | */ |
497 | 497 | public function getViewRenderer($sId = '') |
498 | 498 | { |
499 | - if(!$sId) |
|
499 | + if (!$sId) |
|
500 | 500 | { |
501 | 501 | // Return the view renderer facade |
502 | 502 | return $this->coreContainer['jaxon.sentry.view.renderer']; |
@@ -25,16 +25,10 @@ |
||
25 | 25 | |
26 | 26 | namespace Jaxon; |
27 | 27 | |
28 | -use Jaxon\Plugin\Manager as PluginManager; |
|
29 | -use Jaxon\Request\Manager as RequestManager; |
|
30 | -use Jaxon\Response\Manager as ResponseManager; |
|
31 | - |
|
32 | 28 | use Jaxon\Config\Reader as ConfigReader; |
33 | 29 | use Jaxon\DI\Container; |
34 | 30 | use Jaxon\Utils\URI; |
35 | - |
|
36 | 31 | use Exception; |
37 | -use Closure; |
|
38 | 32 | |
39 | 33 | class Jaxon |
40 | 34 | { |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | 'core.prefix.class' => 'Jaxon', |
157 | 157 | // 'core.request.uri' => '', |
158 | 158 | 'core.request.mode' => 'asynchronous', |
159 | - 'core.request.method' => 'POST', // W3C: Method is case sensitive |
|
159 | + 'core.request.method' => 'POST', // W3C: Method is case sensitive |
|
160 | 160 | 'core.response.merge.ap' => true, |
161 | 161 | 'core.response.merge.js' => true, |
162 | 162 | 'core.debug.on' => false, |
@@ -242,16 +242,16 @@ discard block |
||
242 | 242 | */ |
243 | 243 | public function getScript($bIncludeJs = false, $bIncludeCss = false) |
244 | 244 | { |
245 | - if(!$this->getOption('core.request.uri')) |
|
245 | + if (!$this->getOption('core.request.uri')) |
|
246 | 246 | { |
247 | 247 | $this->setOption('core.request.uri', URI::detect()); |
248 | 248 | } |
249 | 249 | $sCode = ''; |
250 | - if(($bIncludeCss)) |
|
250 | + if (($bIncludeCss)) |
|
251 | 251 | { |
252 | 252 | $sCode .= $this->getPluginManager()->getCss() . "\n"; |
253 | 253 | } |
254 | - if(($bIncludeJs)) |
|
254 | + if (($bIncludeJs)) |
|
255 | 255 | { |
256 | 256 | $sCode .= $this->getPluginManager()->getJs() . "\n"; |
257 | 257 | } |
@@ -322,7 +322,7 @@ discard block |
||
322 | 322 | public function processRequest() |
323 | 323 | { |
324 | 324 | // Check to see if headers have already been sent out, in which case we can't do our job |
325 | - if(headers_sent($filename, $linenumber)) |
|
325 | + if (headers_sent($filename, $linenumber)) |
|
326 | 326 | { |
327 | 327 | echo $this->trans('errors.output.already-sent', array( |
328 | 328 | 'location' => $filename . ':' . $linenumber |
@@ -331,7 +331,7 @@ discard block |
||
331 | 331 | } |
332 | 332 | |
333 | 333 | // Check if there is a plugin to process this request |
334 | - if(!$this->canProcessRequest()) |
|
334 | + if (!$this->canProcessRequest()) |
|
335 | 335 | { |
336 | 336 | return; |
337 | 337 | } |
@@ -341,18 +341,18 @@ discard block |
||
341 | 341 | $xResponseManager = $this->getResponseManager(); |
342 | 342 | |
343 | 343 | // Handle before processing event |
344 | - if(isset($this->aProcessingEvents[self::PROCESSING_EVENT_BEFORE])) |
|
344 | + if (isset($this->aProcessingEvents[self::PROCESSING_EVENT_BEFORE])) |
|
345 | 345 | { |
346 | 346 | $this->aProcessingEvents[self::PROCESSING_EVENT_BEFORE]->call(array(&$bEndRequest)); |
347 | 347 | } |
348 | 348 | |
349 | - if(!$bEndRequest) |
|
349 | + if (!$bEndRequest) |
|
350 | 350 | { |
351 | 351 | try |
352 | 352 | { |
353 | 353 | $mResult = $this->getPluginManager()->processRequest(); |
354 | 354 | } |
355 | - catch(Exception $e) |
|
355 | + catch (Exception $e) |
|
356 | 356 | { |
357 | 357 | // An exception was thrown while processing the request. |
358 | 358 | // The request missed the corresponding handler function, |
@@ -364,7 +364,7 @@ discard block |
||
364 | 364 | $xResponseManager->debug($e->getMessage()); |
365 | 365 | $mResult = false; |
366 | 366 | |
367 | - if($e instanceof \Jaxon\Exception\Error) |
|
367 | + if ($e instanceof \Jaxon\Exception\Error) |
|
368 | 368 | { |
369 | 369 | $sEvent = self::PROCESSING_EVENT_INVALID; |
370 | 370 | $aParams = array($e->getMessage()); |
@@ -375,7 +375,7 @@ discard block |
||
375 | 375 | $aParams = array($e); |
376 | 376 | } |
377 | 377 | |
378 | - if(isset($this->aProcessingEvents[$sEvent])) |
|
378 | + if (isset($this->aProcessingEvents[$sEvent])) |
|
379 | 379 | { |
380 | 380 | // Call the processing event |
381 | 381 | $this->aProcessingEvents[$sEvent]->call($aParams); |
@@ -388,7 +388,7 @@ discard block |
||
388 | 388 | } |
389 | 389 | } |
390 | 390 | // Clean the processing buffer |
391 | - if(($this->getOption('core.process.clean'))) |
|
391 | + if (($this->getOption('core.process.clean'))) |
|
392 | 392 | { |
393 | 393 | $er = error_reporting(0); |
394 | 394 | while (ob_get_level() > 0) |
@@ -398,16 +398,16 @@ discard block |
||
398 | 398 | error_reporting($er); |
399 | 399 | } |
400 | 400 | |
401 | - if($mResult === true) |
|
401 | + if ($mResult === true) |
|
402 | 402 | { |
403 | 403 | // Handle after processing event |
404 | - if(isset($this->aProcessingEvents[self::PROCESSING_EVENT_AFTER])) |
|
404 | + if (isset($this->aProcessingEvents[self::PROCESSING_EVENT_AFTER])) |
|
405 | 405 | { |
406 | 406 | $bEndRequest = false; |
407 | 407 | $this->aProcessingEvents[self::PROCESSING_EVENT_AFTER]->call(array($bEndRequest)); |
408 | 408 | } |
409 | 409 | // If the called function returned no response, give the the global response instead |
410 | - if($xResponseManager->hasNoResponse()) |
|
410 | + if ($xResponseManager->hasNoResponse()) |
|
411 | 411 | { |
412 | 412 | $xResponseManager->append($this->getResponse()); |
413 | 413 | } |
@@ -415,7 +415,7 @@ discard block |
||
415 | 415 | |
416 | 416 | $xResponseManager->printDebug(); |
417 | 417 | |
418 | - if(($this->getOption('core.process.exit'))) |
|
418 | + if (($this->getOption('core.process.exit'))) |
|
419 | 419 | { |
420 | 420 | $xResponseManager->sendOutput(); |
421 | 421 | exit(); |
@@ -22,13 +22,7 @@ |
||
22 | 22 | namespace Jaxon\Plugin; |
23 | 23 | |
24 | 24 | use Jaxon\Jaxon; |
25 | -use Jaxon\Plugin\Package; |
|
26 | 25 | use Jaxon\Config\Config; |
27 | - |
|
28 | -use RecursiveDirectoryIterator; |
|
29 | -use RecursiveIteratorIterator; |
|
30 | -use RegexIterator; |
|
31 | -use RecursiveRegexIterator; |
|
32 | 26 | use Closure; |
33 | 27 | |
34 | 28 | class Manager |
@@ -221,32 +221,32 @@ discard block |
||
221 | 221 | { |
222 | 222 | $bIsAlert = ($xPlugin instanceof Dialogs\Interfaces\Alert); |
223 | 223 | $bIsConfirm = ($xPlugin instanceof Dialogs\Interfaces\Confirm); |
224 | - if($xPlugin instanceof Request) |
|
224 | + if ($xPlugin instanceof Request) |
|
225 | 225 | { |
226 | 226 | // The name of a request plugin is used as key in the plugin table |
227 | 227 | $this->aRequestPlugins[$xPlugin->getName()] = $xPlugin; |
228 | 228 | } |
229 | - elseif($xPlugin instanceof Response) |
|
229 | + elseif ($xPlugin instanceof Response) |
|
230 | 230 | { |
231 | 231 | // The name of a response plugin is used as key in the plugin table |
232 | 232 | $this->aResponsePlugins[$xPlugin->getName()] = $xPlugin; |
233 | 233 | } |
234 | - elseif(!$bIsConfirm && !$bIsAlert) |
|
234 | + elseif (!$bIsConfirm && !$bIsAlert) |
|
235 | 235 | { |
236 | 236 | throw new \Jaxon\Exception\Error($this->trans('errors.register.invalid', array('name' => get_class($xPlugin)))); |
237 | 237 | } |
238 | 238 | // This plugin implements the Alert interface |
239 | - if($bIsAlert) |
|
239 | + if ($bIsAlert) |
|
240 | 240 | { |
241 | 241 | $this->setAlert($xPlugin); |
242 | 242 | } |
243 | 243 | // This plugin implements the Confirm interface |
244 | - if($bIsConfirm) |
|
244 | + if ($bIsConfirm) |
|
245 | 245 | { |
246 | 246 | $this->setConfirm($xPlugin); |
247 | 247 | } |
248 | 248 | // Register the plugin as an event listener |
249 | - if($xPlugin instanceof \Jaxon\Utils\Interfaces\EventListener) |
|
249 | + if ($xPlugin instanceof \Jaxon\Utils\Interfaces\EventListener) |
|
250 | 250 | { |
251 | 251 | $this->addEventListener($xPlugin); |
252 | 252 | } |
@@ -276,7 +276,7 @@ discard block |
||
276 | 276 | private function generateHash() |
277 | 277 | { |
278 | 278 | $sHash = $this->getVersion(); |
279 | - foreach($this->aPlugins as $xPlugin) |
|
279 | + foreach ($this->aPlugins as $xPlugin) |
|
280 | 280 | { |
281 | 281 | $sHash .= $xPlugin->generateHash(); |
282 | 282 | } |
@@ -293,9 +293,9 @@ discard block |
||
293 | 293 | */ |
294 | 294 | public function canProcessRequest() |
295 | 295 | { |
296 | - foreach($this->aRequestPlugins as $xPlugin) |
|
296 | + foreach ($this->aRequestPlugins as $xPlugin) |
|
297 | 297 | { |
298 | - if($xPlugin->getName() != Jaxon::FILE_UPLOAD && $xPlugin->canProcessRequest()) |
|
298 | + if ($xPlugin->getName() != Jaxon::FILE_UPLOAD && $xPlugin->canProcessRequest()) |
|
299 | 299 | { |
300 | 300 | return true; |
301 | 301 | } |
@@ -314,12 +314,12 @@ discard block |
||
314 | 314 | public function processRequest() |
315 | 315 | { |
316 | 316 | $xUploadPlugin = $this->getRequestPlugin(Jaxon::FILE_UPLOAD); |
317 | - foreach($this->aRequestPlugins as $xPlugin) |
|
317 | + foreach ($this->aRequestPlugins as $xPlugin) |
|
318 | 318 | { |
319 | - if($xPlugin->getName() != Jaxon::FILE_UPLOAD && $xPlugin->canProcessRequest()) |
|
319 | + if ($xPlugin->getName() != Jaxon::FILE_UPLOAD && $xPlugin->canProcessRequest()) |
|
320 | 320 | { |
321 | 321 | // Process uploaded files |
322 | - if($xUploadPlugin != null) |
|
322 | + if ($xUploadPlugin != null) |
|
323 | 323 | { |
324 | 324 | $xUploadPlugin->processRequest(); |
325 | 325 | } |
@@ -344,7 +344,7 @@ discard block |
||
344 | 344 | */ |
345 | 345 | public function register($sType, $sCallable, $aOptions) |
346 | 346 | { |
347 | - if(!key_exists($sType, $this->aRequestPlugins)) |
|
347 | + if (!key_exists($sType, $this->aRequestPlugins)) |
|
348 | 348 | { |
349 | 349 | throw new \Jaxon\Exception\Error($this->trans('errors.register.plugin', ['name' => $sType])); |
350 | 350 | } |
@@ -372,15 +372,15 @@ discard block |
||
372 | 372 | { |
373 | 373 | // Register user functions |
374 | 374 | $aFunctionsConfig = $xAppConfig->getOption('functions', []); |
375 | - foreach($aFunctionsConfig as $xKey => $xValue) |
|
375 | + foreach ($aFunctionsConfig as $xKey => $xValue) |
|
376 | 376 | { |
377 | - if(is_integer($xKey) && is_string($xValue)) |
|
377 | + if (is_integer($xKey) && is_string($xValue)) |
|
378 | 378 | { |
379 | 379 | $sFunction = $xValue; |
380 | 380 | // Register a function without options |
381 | 381 | $this->register(Jaxon::USER_FUNCTION, $sFunction); |
382 | 382 | } |
383 | - elseif(is_string($xKey) && is_array($xValue)) |
|
383 | + elseif (is_string($xKey) && is_array($xValue)) |
|
384 | 384 | { |
385 | 385 | $sFunction = $xKey; |
386 | 386 | $aOptions = $xValue; |
@@ -396,25 +396,25 @@ discard block |
||
396 | 396 | |
397 | 397 | // Register classes and directories |
398 | 398 | $aClassesConfig = $xAppConfig->getOption('classes', []); |
399 | - foreach($aClassesConfig as $xKey => $xValue) |
|
399 | + foreach ($aClassesConfig as $xKey => $xValue) |
|
400 | 400 | { |
401 | - if(is_integer($xKey) && is_string($xValue)) |
|
401 | + if (is_integer($xKey) && is_string($xValue)) |
|
402 | 402 | { |
403 | 403 | $sClass = $xValue; |
404 | 404 | // Register a class without options |
405 | 405 | $this->register(Jaxon::CALLABLE_CLASS, $sClass); |
406 | 406 | } |
407 | - elseif(is_string($xKey) && is_array($xValue)) |
|
407 | + elseif (is_string($xKey) && is_array($xValue)) |
|
408 | 408 | { |
409 | 409 | $sClass = $xKey; |
410 | 410 | $aOptions = $xValue; |
411 | 411 | // Register a class with options |
412 | 412 | $this->register(Jaxon::CALLABLE_CLASS, $sClass, $aOptions); |
413 | 413 | } |
414 | - elseif(is_integer($xKey) && is_array($xValue)) |
|
414 | + elseif (is_integer($xKey) && is_array($xValue)) |
|
415 | 415 | { |
416 | 416 | // The directory path is required |
417 | - if(!key_exists('directory', $xValue)) |
|
417 | + if (!key_exists('directory', $xValue)) |
|
418 | 418 | { |
419 | 419 | continue; |
420 | 420 | // Todo: throw an exception |
@@ -422,17 +422,17 @@ discard block |
||
422 | 422 | // Registering a directory |
423 | 423 | $sDirectory = $xValue['directory']; |
424 | 424 | $aOptions = []; |
425 | - if(key_exists('options', $xValue) && |
|
425 | + if (key_exists('options', $xValue) && |
|
426 | 426 | is_array($xValue['options']) || is_string($xValue['options'])) |
427 | 427 | { |
428 | 428 | $aOptions = $xValue['options']; |
429 | 429 | } |
430 | 430 | // Setup directory options |
431 | - if(key_exists('namespace', $xValue)) |
|
431 | + if (key_exists('namespace', $xValue)) |
|
432 | 432 | { |
433 | 433 | $aOptions['namespace'] = $xValue['namespace']; |
434 | 434 | } |
435 | - if(key_exists('separator', $xValue)) |
|
435 | + if (key_exists('separator', $xValue)) |
|
436 | 436 | { |
437 | 437 | $aOptions['separator'] = $xValue['separator']; |
438 | 438 | } |
@@ -454,7 +454,7 @@ discard block |
||
454 | 454 | */ |
455 | 455 | private function getJsLibUri() |
456 | 456 | { |
457 | - if(!$this->hasOption('js.lib.uri')) |
|
457 | + if (!$this->hasOption('js.lib.uri')) |
|
458 | 458 | { |
459 | 459 | // return 'https://cdn.jsdelivr.net/jaxon/1.2.0/'; |
460 | 460 | return 'https://cdn.jsdelivr.net/gh/jaxon-php/[email protected]/dist/'; |
@@ -477,7 +477,7 @@ discard block |
||
477 | 477 | // The jsDelivr CDN only hosts minified files |
478 | 478 | // if(($this->getOption('js.app.minify')) || substr($this->getJsLibUri(), 0, $nLen) == $jsDelivrUri) |
479 | 479 | // Starting from version 2.0.0 of the js lib, the jsDelivr CDN also hosts non minified files. |
480 | - if(($this->getOption('js.app.minify'))) |
|
480 | + if (($this->getOption('js.app.minify'))) |
|
481 | 481 | { |
482 | 482 | return '.min.js'; |
483 | 483 | } |
@@ -494,7 +494,7 @@ discard block |
||
494 | 494 | // Check config options |
495 | 495 | // - The js.app.extern option must be set to true |
496 | 496 | // - The js.app.uri and js.app.dir options must be set to non null values |
497 | - if(!$this->getOption('js.app.extern') || |
|
497 | + if (!$this->getOption('js.app.extern') || |
|
498 | 498 | !$this->getOption('js.app.uri') || |
499 | 499 | !$this->getOption('js.app.dir')) |
500 | 500 | { |
@@ -503,7 +503,7 @@ discard block |
||
503 | 503 | // Check dir access |
504 | 504 | // - The js.app.dir must be writable |
505 | 505 | $sJsAppDir = $this->getOption('js.app.dir'); |
506 | - if(!is_dir($sJsAppDir) || !is_writable($sJsAppDir)) |
|
506 | + if (!is_dir($sJsAppDir) || !is_writable($sJsAppDir)) |
|
507 | 507 | { |
508 | 508 | return false; |
509 | 509 | } |
@@ -517,7 +517,7 @@ discard block |
||
517 | 517 | */ |
518 | 518 | private function setTemplateCacheDir() |
519 | 519 | { |
520 | - if($this->hasOption('core.template.cache_dir')) |
|
520 | + if ($this->hasOption('core.template.cache_dir')) |
|
521 | 521 | { |
522 | 522 | $this->setCacheDir($this->getOption('core.template.cache_dir')); |
523 | 523 | } |
@@ -539,7 +539,7 @@ discard block |
||
539 | 539 | |
540 | 540 | // Add component files to the javascript file array; |
541 | 541 | $aJsFiles = array($sJsCoreUrl); |
542 | - if($this->getOption('core.debug.on')) |
|
542 | + if ($this->getOption('core.debug.on')) |
|
543 | 543 | { |
544 | 544 | $aJsFiles[] = $sJsDebugUrl; |
545 | 545 | $aJsFiles[] = $sJsLanguageUrl; |
@@ -555,17 +555,17 @@ discard block |
||
555 | 555 | 'sJsOptions' => $this->getOption('js.app.options'), |
556 | 556 | 'aUrls' => $aJsFiles, |
557 | 557 | )); |
558 | - foreach($this->aResponsePlugins as $xPlugin) |
|
558 | + foreach ($this->aResponsePlugins as $xPlugin) |
|
559 | 559 | { |
560 | - if(($str = trim($xPlugin->getJs()))) |
|
560 | + if (($str = trim($xPlugin->getJs()))) |
|
561 | 561 | { |
562 | 562 | $sCode .= rtrim($str, " \n") . "\n"; |
563 | 563 | } |
564 | 564 | } |
565 | - foreach($this->aPackages as $sClass) |
|
565 | + foreach ($this->aPackages as $sClass) |
|
566 | 566 | { |
567 | 567 | $xPackage = jaxon()->di()->get($sClass); |
568 | - if(($str = trim($xPackage->js()))) |
|
568 | + if (($str = trim($xPackage->js()))) |
|
569 | 569 | { |
570 | 570 | $sCode .= rtrim($str, " \n") . "\n"; |
571 | 571 | } |
@@ -584,17 +584,17 @@ discard block |
||
584 | 584 | $this->setTemplateCacheDir(); |
585 | 585 | |
586 | 586 | $sCode = ''; |
587 | - foreach($this->aResponsePlugins as $xPlugin) |
|
587 | + foreach ($this->aResponsePlugins as $xPlugin) |
|
588 | 588 | { |
589 | - if(($str = trim($xPlugin->getCss()))) |
|
589 | + if (($str = trim($xPlugin->getCss()))) |
|
590 | 590 | { |
591 | 591 | $sCode .= rtrim($str, " \n") . "\n"; |
592 | 592 | } |
593 | 593 | } |
594 | - foreach($this->aPackages as $sClass) |
|
594 | + foreach ($this->aPackages as $sClass) |
|
595 | 595 | { |
596 | 596 | $xPackage = jaxon()->di()->get($sClass); |
597 | - if(($str = trim($xPackage->css()))) |
|
597 | + if (($str = trim($xPackage->css()))) |
|
598 | 598 | { |
599 | 599 | $sCode .= rtrim($str, " \n") . "\n"; |
600 | 600 | } |
@@ -658,17 +658,17 @@ discard block |
||
658 | 658 | private function getReadyScript() |
659 | 659 | { |
660 | 660 | $sPluginScript = ''; |
661 | - foreach($this->aResponsePlugins as $xPlugin) |
|
661 | + foreach ($this->aResponsePlugins as $xPlugin) |
|
662 | 662 | { |
663 | - if(($str = trim($xPlugin->getScript()))) |
|
663 | + if (($str = trim($xPlugin->getScript()))) |
|
664 | 664 | { |
665 | 665 | $sPluginScript .= "\n" . trim($str, " \n"); |
666 | 666 | } |
667 | 667 | } |
668 | - foreach($this->aPackages as $sClass) |
|
668 | + foreach ($this->aPackages as $sClass) |
|
669 | 669 | { |
670 | 670 | $xPackage = jaxon()->di()->get($sClass); |
671 | - if(($str = trim($xPackage->ready()))) |
|
671 | + if (($str = trim($xPackage->ready()))) |
|
672 | 672 | { |
673 | 673 | $sPluginScript .= "\n" . trim($str, " \n"); |
674 | 674 | } |
@@ -691,7 +691,7 @@ discard block |
||
691 | 691 | { |
692 | 692 | // Get the config and plugins scripts |
693 | 693 | $sScript = $this->getConfigScript() . "\n" . $this->getReadyScript() . "\n"; |
694 | - foreach($this->aRequestPlugins as $xPlugin) |
|
694 | + foreach ($this->aRequestPlugins as $xPlugin) |
|
695 | 695 | { |
696 | 696 | $sScript .= "\n" . trim($xPlugin->getScript(), " \n"); |
697 | 697 | } |
@@ -713,7 +713,7 @@ discard block |
||
713 | 713 | // Set the template engine cache dir |
714 | 714 | $this->setTemplateCacheDir(); |
715 | 715 | |
716 | - if($this->canExportJavascript()) |
|
716 | + if ($this->canExportJavascript()) |
|
717 | 717 | { |
718 | 718 | $sJsAppURI = rtrim($this->getOption('js.app.uri'), '/') . '/'; |
719 | 719 | $sJsAppDir = rtrim($this->getOption('js.app.dir'), '/') . '/'; |
@@ -722,13 +722,13 @@ discard block |
||
722 | 722 | $sHash = $this->generateHash(); |
723 | 723 | $sOutFile = $sHash . '.js'; |
724 | 724 | $sMinFile = $sHash . '.min.js'; |
725 | - if(!is_file($sJsAppDir . $sOutFile)) |
|
725 | + if (!is_file($sJsAppDir . $sOutFile)) |
|
726 | 726 | { |
727 | 727 | file_put_contents($sJsAppDir . $sOutFile, $this->getAllScripts()); |
728 | 728 | } |
729 | - if(($this->getOption('js.app.minify')) && !is_file($sJsAppDir . $sMinFile)) |
|
729 | + if (($this->getOption('js.app.minify')) && !is_file($sJsAppDir . $sMinFile)) |
|
730 | 730 | { |
731 | - if(($this->minify($sJsAppDir . $sOutFile, $sJsAppDir . $sMinFile))) |
|
731 | + if (($this->minify($sJsAppDir . $sOutFile, $sJsAppDir . $sMinFile))) |
|
732 | 732 | { |
733 | 733 | $sOutFile = $sMinFile; |
734 | 734 | } |
@@ -761,7 +761,7 @@ discard block |
||
761 | 761 | */ |
762 | 762 | public function getResponsePlugin($sName) |
763 | 763 | { |
764 | - if(array_key_exists($sName, $this->aResponsePlugins)) |
|
764 | + if (array_key_exists($sName, $this->aResponsePlugins)) |
|
765 | 765 | { |
766 | 766 | return $this->aResponsePlugins[$sName]; |
767 | 767 | } |
@@ -777,7 +777,7 @@ discard block |
||
777 | 777 | */ |
778 | 778 | public function getRequestPlugin($sName) |
779 | 779 | { |
780 | - if(array_key_exists($sName, $this->aRequestPlugins)) |
|
780 | + if (array_key_exists($sName, $this->aRequestPlugins)) |
|
781 | 781 | { |
782 | 782 | return $this->aRequestPlugins[$sName]; |
783 | 783 | } |
@@ -225,13 +225,11 @@ discard block |
||
225 | 225 | { |
226 | 226 | // The name of a request plugin is used as key in the plugin table |
227 | 227 | $this->aRequestPlugins[$xPlugin->getName()] = $xPlugin; |
228 | - } |
|
229 | - elseif($xPlugin instanceof Response) |
|
228 | + } elseif($xPlugin instanceof Response) |
|
230 | 229 | { |
231 | 230 | // The name of a response plugin is used as key in the plugin table |
232 | 231 | $this->aResponsePlugins[$xPlugin->getName()] = $xPlugin; |
233 | - } |
|
234 | - elseif(!$bIsConfirm && !$bIsAlert) |
|
232 | + } elseif(!$bIsConfirm && !$bIsAlert) |
|
235 | 233 | { |
236 | 234 | throw new \Jaxon\Exception\Error($this->trans('errors.register.invalid', array('name' => get_class($xPlugin)))); |
237 | 235 | } |
@@ -379,15 +377,13 @@ discard block |
||
379 | 377 | $sFunction = $xValue; |
380 | 378 | // Register a function without options |
381 | 379 | $this->register(Jaxon::USER_FUNCTION, $sFunction); |
382 | - } |
|
383 | - elseif(is_string($xKey) && is_array($xValue)) |
|
380 | + } elseif(is_string($xKey) && is_array($xValue)) |
|
384 | 381 | { |
385 | 382 | $sFunction = $xKey; |
386 | 383 | $aOptions = $xValue; |
387 | 384 | // Register a function with options |
388 | 385 | $this->register(Jaxon::USER_FUNCTION, $sFunction, $aOptions); |
389 | - } |
|
390 | - else |
|
386 | + } else |
|
391 | 387 | { |
392 | 388 | continue; |
393 | 389 | // Todo: throw an exception |
@@ -403,15 +399,13 @@ discard block |
||
403 | 399 | $sClass = $xValue; |
404 | 400 | // Register a class without options |
405 | 401 | $this->register(Jaxon::CALLABLE_CLASS, $sClass); |
406 | - } |
|
407 | - elseif(is_string($xKey) && is_array($xValue)) |
|
402 | + } elseif(is_string($xKey) && is_array($xValue)) |
|
408 | 403 | { |
409 | 404 | $sClass = $xKey; |
410 | 405 | $aOptions = $xValue; |
411 | 406 | // Register a class with options |
412 | 407 | $this->register(Jaxon::CALLABLE_CLASS, $sClass, $aOptions); |
413 | - } |
|
414 | - elseif(is_integer($xKey) && is_array($xValue)) |
|
408 | + } elseif(is_integer($xKey) && is_array($xValue)) |
|
415 | 409 | { |
416 | 410 | // The directory path is required |
417 | 411 | if(!key_exists('directory', $xValue)) |
@@ -438,8 +432,7 @@ discard block |
||
438 | 432 | } |
439 | 433 | // Register a class without options |
440 | 434 | $this->register(Jaxon::CALLABLE_DIR, $sDirectory, $aOptions); |
441 | - } |
|
442 | - else |
|
435 | + } else |
|
443 | 436 | { |
444 | 437 | continue; |
445 | 438 | // Todo: throw an exception |
@@ -739,8 +732,7 @@ discard block |
||
739 | 732 | 'sJsOptions' => $this->getOption('js.app.options'), |
740 | 733 | 'sUrl' => $sJsAppURI . $sOutFile, |
741 | 734 | )); |
742 | - } |
|
743 | - else |
|
735 | + } else |
|
744 | 736 | { |
745 | 737 | // The plugins scripts are wrapped with javascript tags |
746 | 738 | $sScript = $this->render('jaxon::plugins/wrapper.js', array( |
@@ -26,12 +26,12 @@ |
||
26 | 26 | public static function read($sConfigFile) |
27 | 27 | { |
28 | 28 | $sConfigFile = realpath($sConfigFile); |
29 | - if(!is_readable($sConfigFile)) |
|
29 | + if (!is_readable($sConfigFile)) |
|
30 | 30 | { |
31 | 31 | throw new \Jaxon\Config\Exception\File(jaxon_trans('config.errors.file.access', array('path' => $sConfigFile))); |
32 | 32 | } |
33 | 33 | $aConfigOptions = include($sConfigFile); |
34 | - if(!is_array($aConfigOptions)) |
|
34 | + if (!is_array($aConfigOptions)) |
|
35 | 35 | { |
36 | 36 | throw new \Jaxon\Config\Exception\File(jaxon_trans('config.errors.file.content', array('path' => $sConfigFile))); |
37 | 37 | } |
@@ -45,14 +45,14 @@ discard block |
||
45 | 45 | $sPrefix = trim((string)$sPrefix); |
46 | 46 | $nDepth = intval($nDepth); |
47 | 47 | // Check the max depth |
48 | - if($nDepth < 0 || $nDepth > 9) |
|
48 | + if ($nDepth < 0 || $nDepth > 9) |
|
49 | 49 | { |
50 | 50 | throw new \Jaxon\Config\Exception\Data(jaxon_trans('config.errors.data.depth', |
51 | 51 | array('key' => $sPrefix, 'depth' => $nDepth))); |
52 | 52 | } |
53 | - foreach($aOptions as $sName => $xOption) |
|
53 | + foreach ($aOptions as $sName => $xOption) |
|
54 | 54 | { |
55 | - if(is_int($sName)) |
|
55 | + if (is_int($sName)) |
|
56 | 56 | { |
57 | 57 | continue; |
58 | 58 | } |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | // Save the value of this option |
63 | 63 | $this->aOptions[$sFullName] = $xOption; |
64 | 64 | // Save the values of its sub-options |
65 | - if(is_array($xOption)) |
|
65 | + if (is_array($xOption)) |
|
66 | 66 | { |
67 | 67 | // Recursively read the options in the array |
68 | 68 | $this->_setOptions($xOption, $sFullName, $nDepth + 1); |
@@ -84,9 +84,9 @@ discard block |
||
84 | 84 | $aKeys = explode('.', (string)$sKeys); |
85 | 85 | foreach ($aKeys as $sKey) |
86 | 86 | { |
87 | - if(($sKey)) |
|
87 | + if (($sKey)) |
|
88 | 88 | { |
89 | - if(!array_key_exists($sKey, $aOptions) || !is_array($aOptions[$sKey])) |
|
89 | + if (!array_key_exists($sKey, $aOptions) || !is_array($aOptions[$sKey])) |
|
90 | 90 | { |
91 | 91 | return; |
92 | 92 | } |
@@ -134,13 +134,12 @@ discard block |
||
134 | 134 | $sPrefix = rtrim($sPrefix, '.') . '.'; |
135 | 135 | $sPrefixLen = strlen($sPrefix); |
136 | 136 | $aOptions = []; |
137 | - foreach($this->aOptions as $sName => $xValue) |
|
137 | + foreach ($this->aOptions as $sName => $xValue) |
|
138 | 138 | { |
139 | - if(substr($sName, 0, $sPrefixLen) == $sPrefix) |
|
139 | + if (substr($sName, 0, $sPrefixLen) == $sPrefix) |
|
140 | 140 | { |
141 | 141 | $iNextDotPos = strpos($sName, '.', $sPrefixLen); |
142 | - $sOptionName = $iNextDotPos === false ? substr($sName, $sPrefixLen) : |
|
143 | - substr($sName, $sPrefixLen, $iNextDotPos - $sPrefixLen); |
|
142 | + $sOptionName = $iNextDotPos === false ? substr($sName, $sPrefixLen) : substr($sName, $sPrefixLen, $iNextDotPos - $sPrefixLen); |
|
144 | 143 | $aOptions[$sOptionName] = $sPrefix . $sOptionName; |
145 | 144 | } |
146 | 145 | } |
@@ -26,16 +26,16 @@ |
||
26 | 26 | public static function read($sConfigFile) |
27 | 27 | { |
28 | 28 | $sConfigFile = realpath($sConfigFile); |
29 | - if(!extension_loaded('yaml')) |
|
29 | + if (!extension_loaded('yaml')) |
|
30 | 30 | { |
31 | 31 | throw new \Jaxon\Config\Exception\Yaml(jaxon_trans('config.errors.yaml.install')); |
32 | 32 | } |
33 | - if(!is_readable($sConfigFile)) |
|
33 | + if (!is_readable($sConfigFile)) |
|
34 | 34 | { |
35 | 35 | throw new \Jaxon\Config\Exception\File(jaxon_trans('config.errors.file.access', array('path' => $sConfigFile))); |
36 | 36 | } |
37 | 37 | $aConfigOptions = yaml_parse_file($sConfigFile); |
38 | - if(!is_array($aConfigOptions)) |
|
38 | + if (!is_array($aConfigOptions)) |
|
39 | 39 | { |
40 | 40 | throw new \Jaxon\Config\Exception\File(jaxon_trans('config.errors.file.content', array('path' => $sConfigFile))); |
41 | 41 | } |
@@ -24,7 +24,7 @@ |
||
24 | 24 | public function read($sConfigFile) |
25 | 25 | { |
26 | 26 | $sExt = pathinfo($sConfigFile, PATHINFO_EXTENSION); |
27 | - switch($sExt) |
|
27 | + switch ($sExt) |
|
28 | 28 | { |
29 | 29 | case 'php': |
30 | 30 | $aConfigOptions = Php::read($sConfigFile); |
@@ -26,13 +26,13 @@ |
||
26 | 26 | public static function read($sConfigFile) |
27 | 27 | { |
28 | 28 | $sConfigFile = realpath($sConfigFile); |
29 | - if(!is_readable($sConfigFile)) |
|
29 | + if (!is_readable($sConfigFile)) |
|
30 | 30 | { |
31 | 31 | throw new \Jaxon\Config\Exception\File(jaxon_trans('config.errors.file.access', array('path' => $sConfigFile))); |
32 | 32 | } |
33 | 33 | $sFileContent = file_get_contents($sConfigFile); |
34 | 34 | $aConfigOptions = json_decode($sFileContent, true); |
35 | - if(!is_array($aConfigOptions)) |
|
35 | + if (!is_array($aConfigOptions)) |
|
36 | 36 | { |
37 | 37 | throw new \Jaxon\Config\Exception\File(jaxon_trans('config.errors.file.content', array('path' => $sConfigFile))); |
38 | 38 | } |