@@ -241,7 +241,7 @@ |
||
| 241 | 241 | /** |
| 242 | 242 | * Create a new the config manager |
| 243 | 243 | * |
| 244 | - * @return Jaxon\Utils\Config\Config The config manager |
|
| 244 | + * @return \Jaxon\Utils\Config\Config The config manager |
|
| 245 | 245 | */ |
| 246 | 246 | public function newConfig() |
| 247 | 247 | { |
@@ -30,7 +30,7 @@ discard block |
||
| 30 | 30 | |
| 31 | 31 | public static function getInstance() |
| 32 | 32 | { |
| 33 | - if(!self::$xInstance) |
|
| 33 | + if (!self::$xInstance) |
|
| 34 | 34 | { |
| 35 | 35 | self::$xInstance = new Container(); |
| 36 | 36 | } |
@@ -90,19 +90,19 @@ discard block |
||
| 90 | 90 | * Managers |
| 91 | 91 | */ |
| 92 | 92 | // Plugin Manager |
| 93 | - $this->coreContainer['jaxon.core.plugin_manager'] = function ($c) { |
|
| 93 | + $this->coreContainer['jaxon.core.plugin_manager'] = function($c) { |
|
| 94 | 94 | return new \Jaxon\Plugin\Manager(); |
| 95 | 95 | }; |
| 96 | 96 | // Request Manager |
| 97 | - $this->coreContainer['jaxon.core.request_manager'] = function ($c) { |
|
| 97 | + $this->coreContainer['jaxon.core.request_manager'] = function($c) { |
|
| 98 | 98 | return new \Jaxon\Request\Manager(); |
| 99 | 99 | }; |
| 100 | 100 | // Request Factory |
| 101 | - $this->coreContainer['jaxon.core.request_factory'] = function ($c) { |
|
| 101 | + $this->coreContainer['jaxon.core.request_factory'] = function($c) { |
|
| 102 | 102 | return new \Jaxon\Factory\Request(); |
| 103 | 103 | }; |
| 104 | 104 | // Response Manager |
| 105 | - $this->coreContainer['jaxon.core.response_manager'] = function ($c) { |
|
| 105 | + $this->coreContainer['jaxon.core.response_manager'] = function($c) { |
|
| 106 | 106 | return new \Jaxon\Response\Manager(); |
| 107 | 107 | }; |
| 108 | 108 | |
@@ -110,35 +110,35 @@ discard block |
||
| 110 | 110 | * Services |
| 111 | 111 | */ |
| 112 | 112 | // Config manager |
| 113 | - $this->coreContainer['jaxon.core.config'] = function ($c) { |
|
| 113 | + $this->coreContainer['jaxon.core.config'] = function($c) { |
|
| 114 | 114 | return new \Jaxon\Utils\Config\Config(); |
| 115 | 115 | }; |
| 116 | 116 | // Minifier |
| 117 | - $this->coreContainer['jaxon.core.minifier'] = function ($c) { |
|
| 117 | + $this->coreContainer['jaxon.core.minifier'] = function($c) { |
|
| 118 | 118 | return new \Jaxon\Utils\Template\Minifier(); |
| 119 | 119 | }; |
| 120 | 120 | // Translator |
| 121 | - $this->coreContainer['jaxon.core.translator'] = function ($c) { |
|
| 121 | + $this->coreContainer['jaxon.core.translator'] = function($c) { |
|
| 122 | 122 | return new \Jaxon\Utils\Translation\Translator($c['jaxon.core.translation_dir'], $c['jaxon.core.config']); |
| 123 | 123 | }; |
| 124 | 124 | // Template engine |
| 125 | - $this->coreContainer['jaxon.core.template'] = function ($c) { |
|
| 125 | + $this->coreContainer['jaxon.core.template'] = function($c) { |
|
| 126 | 126 | return new \Jaxon\Utils\Template\Template($c['jaxon.core.template_dir']); |
| 127 | 127 | }; |
| 128 | 128 | // Validator |
| 129 | - $this->coreContainer['jaxon.core.validator'] = function ($c) { |
|
| 129 | + $this->coreContainer['jaxon.core.validator'] = function($c) { |
|
| 130 | 130 | return new \Jaxon\Utils\Validation\Validator($c['jaxon.core.translator'], $c['jaxon.core.config']); |
| 131 | 131 | }; |
| 132 | 132 | // Pagination Renderer |
| 133 | - $this->coreContainer['jaxon.pagination.renderer'] = function ($c) { |
|
| 133 | + $this->coreContainer['jaxon.pagination.renderer'] = function($c) { |
|
| 134 | 134 | return new \Jaxon\Utils\Pagination\Renderer(); |
| 135 | 135 | }; |
| 136 | 136 | // Pagination Paginator |
| 137 | - $this->coreContainer['jaxon.pagination.paginator'] = function ($c) { |
|
| 137 | + $this->coreContainer['jaxon.pagination.paginator'] = function($c) { |
|
| 138 | 138 | return new \Jaxon\Utils\Pagination\Paginator($c['jaxon.pagination.renderer']); |
| 139 | 139 | }; |
| 140 | 140 | // Event Dispatcher |
| 141 | - $this->coreContainer['jaxon.core.events'] = function ($c) { |
|
| 141 | + $this->coreContainer['jaxon.core.events'] = function($c) { |
|
| 142 | 142 | return new EventDispatcher(); |
| 143 | 143 | }; |
| 144 | 144 | |
@@ -146,15 +146,15 @@ discard block |
||
| 146 | 146 | * Core library objects |
| 147 | 147 | */ |
| 148 | 148 | // Global Response |
| 149 | - $this->coreContainer['jaxon.core.response'] = function ($c) { |
|
| 149 | + $this->coreContainer['jaxon.core.response'] = function($c) { |
|
| 150 | 150 | return new \Jaxon\Response\Response(); |
| 151 | 151 | }; |
| 152 | 152 | // Jaxon Core |
| 153 | - $this->coreContainer['jaxon.core.jaxon'] = function ($c) { |
|
| 153 | + $this->coreContainer['jaxon.core.jaxon'] = function($c) { |
|
| 154 | 154 | return new \Jaxon\Jaxon(); |
| 155 | 155 | }; |
| 156 | 156 | // View Renderer Facade |
| 157 | - $this->coreContainer['jaxon.sentry.view.renderer'] = function ($c) { |
|
| 157 | + $this->coreContainer['jaxon.sentry.view.renderer'] = function($c) { |
|
| 158 | 158 | $aRenderers = $c['jaxon.view.data.renderers']; |
| 159 | 159 | $sDefaultNamespace = $c['jaxon.view.data.namespace.default']; |
| 160 | 160 | return new \Jaxon\Sentry\View\Facade($aRenderers, $sDefaultNamespace); |
@@ -168,7 +168,7 @@ discard block |
||
| 168 | 168 | */ |
| 169 | 169 | public function get($sClass) |
| 170 | 170 | { |
| 171 | - if($this->sentryContainer != null && $this->sentryContainer->has($sClass)) |
|
| 171 | + if ($this->sentryContainer != null && $this->sentryContainer->has($sClass)) |
|
| 172 | 172 | { |
| 173 | 173 | return $this->sentryContainer->get($sClass); |
| 174 | 174 | } |
@@ -443,14 +443,14 @@ discard block |
||
| 443 | 443 | $this->coreContainer['jaxon.sentry.view.base.' . $sId] = $xClosure; |
| 444 | 444 | |
| 445 | 445 | // Return the initialized view renderer |
| 446 | - $this->coreContainer['jaxon.sentry.view.' . $sId] = function ($c) use ($sId) { |
|
| 446 | + $this->coreContainer['jaxon.sentry.view.' . $sId] = function($c) use ($sId) { |
|
| 447 | 447 | // Get the defined renderer |
| 448 | 448 | $renderer = $c['jaxon.sentry.view.base.' . $sId]; |
| 449 | 449 | // Init the renderer with the template namespaces |
| 450 | 450 | $aNamespaces = $this->coreContainer['jaxon.view.data.namespaces']; |
| 451 | - if(key_exists($sId, $aNamespaces)) |
|
| 451 | + if (key_exists($sId, $aNamespaces)) |
|
| 452 | 452 | { |
| 453 | - foreach($aNamespaces[$sId] as $ns) |
|
| 453 | + foreach ($aNamespaces[$sId] as $ns) |
|
| 454 | 454 | { |
| 455 | 455 | $renderer->addNamespace($ns['namespace'], $ns['directory'], $ns['extension']); |
| 456 | 456 | } |
@@ -468,7 +468,7 @@ discard block |
||
| 468 | 468 | */ |
| 469 | 469 | public function getViewRenderer($sId = '') |
| 470 | 470 | { |
| 471 | - if(!$sId) |
|
| 471 | + if (!$sId) |
|
| 472 | 472 | { |
| 473 | 473 | // Return the view renderer facade |
| 474 | 474 | return $this->coreContainer['jaxon.sentry.view.renderer']; |
@@ -25,14 +25,9 @@ |
||
| 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\Utils\URI; |
| 33 | 29 | use Jaxon\DI\Container; |
| 34 | 30 | use Exception; |
| 35 | -use Closure; |
|
| 36 | 31 | |
| 37 | 32 | class Jaxon |
| 38 | 33 | { |
@@ -135,14 +135,6 @@ |
||
| 135 | 135 | * Options include: |
| 136 | 136 | * - Jaxon::USER_FUNCTION: a function declared at global scope |
| 137 | 137 | * - Jaxon::CALLABLE_OBJECT: an object who's methods are to be registered |
| 138 | - * @param mixed $sFunction | $objObject |
|
| 139 | - * When registering a function, this is the name of the function |
|
| 140 | - * When registering a callable object, this is the object being registered |
|
| 141 | - * @param mixed $sIncludeFile | $aCallOptions |
|
| 142 | - * When registering a function, this is an (optional) array |
|
| 143 | - * of call options, or the (optional) include file |
|
| 144 | - * When registering a callable object, this is an (optional) array |
|
| 145 | - * of call options for the functions being registered |
|
| 146 | 138 | * |
| 147 | 139 | * @return mixed |
| 148 | 140 | */ |
@@ -211,16 +211,16 @@ discard block |
||
| 211 | 211 | */ |
| 212 | 212 | public function getScript($bIncludeJs = false, $bIncludeCss = false) |
| 213 | 213 | { |
| 214 | - if(!$this->getOption('core.request.uri')) |
|
| 214 | + if (!$this->getOption('core.request.uri')) |
|
| 215 | 215 | { |
| 216 | 216 | $this->setOption('core.request.uri', URI::detect()); |
| 217 | 217 | } |
| 218 | 218 | $sCode = ''; |
| 219 | - if(($bIncludeCss)) |
|
| 219 | + if (($bIncludeCss)) |
|
| 220 | 220 | { |
| 221 | 221 | $sCode .= $this->getPluginManager()->getCss() . "\n"; |
| 222 | 222 | } |
| 223 | - if(($bIncludeJs)) |
|
| 223 | + if (($bIncludeJs)) |
|
| 224 | 224 | { |
| 225 | 225 | $sCode .= $this->getPluginManager()->getJs() . "\n"; |
| 226 | 226 | } |
@@ -291,7 +291,7 @@ discard block |
||
| 291 | 291 | public function processRequest() |
| 292 | 292 | { |
| 293 | 293 | // Check to see if headers have already been sent out, in which case we can't do our job |
| 294 | - if(headers_sent($filename, $linenumber)) |
|
| 294 | + if (headers_sent($filename, $linenumber)) |
|
| 295 | 295 | { |
| 296 | 296 | echo $this->trans('errors.output.already-sent', array( |
| 297 | 297 | 'location' => $filename . ':' . $linenumber |
@@ -300,7 +300,7 @@ discard block |
||
| 300 | 300 | } |
| 301 | 301 | |
| 302 | 302 | // Check if there is a plugin to process this request |
| 303 | - if(!$this->canProcessRequest()) |
|
| 303 | + if (!$this->canProcessRequest()) |
|
| 304 | 304 | { |
| 305 | 305 | return; |
| 306 | 306 | } |
@@ -310,18 +310,18 @@ discard block |
||
| 310 | 310 | $xResponseManager = $this->getResponseManager(); |
| 311 | 311 | |
| 312 | 312 | // Handle before processing event |
| 313 | - if(isset($this->aProcessingEvents[self::PROCESSING_EVENT_BEFORE])) |
|
| 313 | + if (isset($this->aProcessingEvents[self::PROCESSING_EVENT_BEFORE])) |
|
| 314 | 314 | { |
| 315 | 315 | $this->aProcessingEvents[self::PROCESSING_EVENT_BEFORE]->call(array(&$bEndRequest)); |
| 316 | 316 | } |
| 317 | 317 | |
| 318 | - if(!$bEndRequest) |
|
| 318 | + if (!$bEndRequest) |
|
| 319 | 319 | { |
| 320 | 320 | try |
| 321 | 321 | { |
| 322 | 322 | $mResult = $this->getPluginManager()->processRequest(); |
| 323 | 323 | } |
| 324 | - catch(Exception $e) |
|
| 324 | + catch (Exception $e) |
|
| 325 | 325 | { |
| 326 | 326 | // An exception was thrown while processing the request. |
| 327 | 327 | // The request missed the corresponding handler function, |
@@ -333,7 +333,7 @@ discard block |
||
| 333 | 333 | $xResponseManager->debug($e->getMessage()); |
| 334 | 334 | $mResult = false; |
| 335 | 335 | |
| 336 | - if($e instanceof \Jaxon\Exception\Error) |
|
| 336 | + if ($e instanceof \Jaxon\Exception\Error) |
|
| 337 | 337 | { |
| 338 | 338 | $sEvent = self::PROCESSING_EVENT_INVALID; |
| 339 | 339 | $aParams = array($e->getMessage()); |
@@ -344,7 +344,7 @@ discard block |
||
| 344 | 344 | $aParams = array($e); |
| 345 | 345 | } |
| 346 | 346 | |
| 347 | - if(isset($this->aProcessingEvents[$sEvent])) |
|
| 347 | + if (isset($this->aProcessingEvents[$sEvent])) |
|
| 348 | 348 | { |
| 349 | 349 | // Call the processing event |
| 350 | 350 | $this->aProcessingEvents[$sEvent]->call($aParams); |
@@ -357,7 +357,7 @@ discard block |
||
| 357 | 357 | } |
| 358 | 358 | } |
| 359 | 359 | // Clean the processing buffer |
| 360 | - if(($this->getOption('core.process.clean'))) |
|
| 360 | + if (($this->getOption('core.process.clean'))) |
|
| 361 | 361 | { |
| 362 | 362 | $er = error_reporting(0); |
| 363 | 363 | while (ob_get_level() > 0) |
@@ -367,16 +367,16 @@ discard block |
||
| 367 | 367 | error_reporting($er); |
| 368 | 368 | } |
| 369 | 369 | |
| 370 | - if($mResult === true) |
|
| 370 | + if ($mResult === true) |
|
| 371 | 371 | { |
| 372 | 372 | // Handle after processing event |
| 373 | - if(isset($this->aProcessingEvents[self::PROCESSING_EVENT_AFTER])) |
|
| 373 | + if (isset($this->aProcessingEvents[self::PROCESSING_EVENT_AFTER])) |
|
| 374 | 374 | { |
| 375 | 375 | $bEndRequest = false; |
| 376 | 376 | $this->aProcessingEvents[self::PROCESSING_EVENT_AFTER]->call(array($bEndRequest)); |
| 377 | 377 | } |
| 378 | 378 | // If the called function returned no response, give the the global response instead |
| 379 | - if($xResponseManager->hasNoResponse()) |
|
| 379 | + if ($xResponseManager->hasNoResponse()) |
|
| 380 | 380 | { |
| 381 | 381 | $xResponseManager->append($this->getResponse()); |
| 382 | 382 | } |
@@ -384,7 +384,7 @@ discard block |
||
| 384 | 384 | |
| 385 | 385 | $xResponseManager->printDebug(); |
| 386 | 386 | |
| 387 | - if(($this->getOption('core.process.exit'))) |
|
| 387 | + if (($this->getOption('core.process.exit'))) |
|
| 388 | 388 | { |
| 389 | 389 | $xResponseManager->sendOutput(); |
| 390 | 390 | exit(); |
@@ -320,8 +320,7 @@ discard block |
||
| 320 | 320 | try |
| 321 | 321 | { |
| 322 | 322 | $mResult = $this->getPluginManager()->processRequest(); |
| 323 | - } |
|
| 324 | - catch(Exception $e) |
|
| 323 | + } catch(Exception $e) |
|
| 325 | 324 | { |
| 326 | 325 | // An exception was thrown while processing the request. |
| 327 | 326 | // The request missed the corresponding handler function, |
@@ -337,8 +336,7 @@ discard block |
||
| 337 | 336 | { |
| 338 | 337 | $sEvent = self::PROCESSING_EVENT_INVALID; |
| 339 | 338 | $aParams = array($e->getMessage()); |
| 340 | - } |
|
| 341 | - else |
|
| 339 | + } else |
|
| 342 | 340 | { |
| 343 | 341 | $sEvent = self::PROCESSING_EVENT_ERROR; |
| 344 | 342 | $aParams = array($e); |
@@ -348,8 +346,7 @@ discard block |
||
| 348 | 346 | { |
| 349 | 347 | // Call the processing event |
| 350 | 348 | $this->aProcessingEvents[$sEvent]->call($aParams); |
| 351 | - } |
|
| 352 | - else |
|
| 349 | + } else |
|
| 353 | 350 | { |
| 354 | 351 | // The exception is not to be processed here. |
| 355 | 352 | throw $e; |
@@ -19,8 +19,6 @@ |
||
| 19 | 19 | |
| 20 | 20 | namespace Jaxon\Traits; |
| 21 | 21 | |
| 22 | -use Jaxon\DI\Container; |
|
| 23 | - |
|
| 24 | 22 | trait Autoload |
| 25 | 23 | { |
| 26 | 24 | /** |
@@ -77,7 +77,7 @@ discard block |
||
| 77 | 77 | public function getName() |
| 78 | 78 | { |
| 79 | 79 | // Do not use sAlias here! |
| 80 | - if(is_array($this->sUserFunction)) |
|
| 80 | + if (is_array($this->sUserFunction)) |
|
| 81 | 81 | { |
| 82 | 82 | return $this->sUserFunction[1]; |
| 83 | 83 | } |
@@ -94,7 +94,7 @@ discard block |
||
| 94 | 94 | */ |
| 95 | 95 | public function configure($sName, $sValue) |
| 96 | 96 | { |
| 97 | - switch($sName) |
|
| 97 | + switch ($sName) |
|
| 98 | 98 | { |
| 99 | 99 | case 'class': // The user function is a method in the given class |
| 100 | 100 | $this->sUserFunction = [$sValue, $this->sUserFunction]; |
@@ -151,12 +151,12 @@ discard block |
||
| 151 | 151 | */ |
| 152 | 152 | public function call($aArgs = []) |
| 153 | 153 | { |
| 154 | - if(($this->sInclude)) |
|
| 154 | + if (($this->sInclude)) |
|
| 155 | 155 | { |
| 156 | 156 | require_once $this->sInclude; |
| 157 | 157 | } |
| 158 | 158 | $response = call_user_func_array($this->sUserFunction, $aArgs); |
| 159 | - if(($response)) |
|
| 159 | + if (($response)) |
|
| 160 | 160 | { |
| 161 | 161 | $this->getResponseManager()->append($response); |
| 162 | 162 | } |
@@ -62,6 +62,9 @@ discard block |
||
| 62 | 62 | */ |
| 63 | 63 | private $aConfiguration; |
| 64 | 64 | |
| 65 | + /** |
|
| 66 | + * @param string $sUserFunction |
|
| 67 | + */ |
|
| 65 | 68 | public function __construct($sUserFunction) |
| 66 | 69 | { |
| 67 | 70 | $this->aConfiguration = []; |
@@ -114,7 +117,7 @@ discard block |
||
| 114 | 117 | /** |
| 115 | 118 | * Constructs and returns a <Jaxon\Request\Request> object which is capable of generating the javascript call to invoke this jaxon enabled function |
| 116 | 119 | * |
| 117 | - * @return Jaxon\Request\Request |
|
| 120 | + * @return Request |
|
| 118 | 121 | */ |
| 119 | 122 | public function generateRequest() |
| 120 | 123 | { |
@@ -58,11 +58,11 @@ discard block |
||
| 58 | 58 | $this->aCalls = []; |
| 59 | 59 | |
| 60 | 60 | $jQueryNs = jaxon()->getOption('core.jquery.no_conflict', false) ? 'jQuery' : '$'; |
| 61 | - if(!$sSelector) |
|
| 61 | + if (!$sSelector) |
|
| 62 | 62 | { |
| 63 | 63 | $this->sSelector = "$jQueryNs(this)"; // If an empty selector is given, use javascript "this" instead |
| 64 | 64 | } |
| 65 | - elseif(($sContext)) |
|
| 65 | + elseif (($sContext)) |
|
| 66 | 66 | { |
| 67 | 67 | $this->sSelector = "$jQueryNs('" . $sSelector . "', $jQueryNs('" . $sContext . "'))"; |
| 68 | 68 | } |
@@ -118,7 +118,7 @@ discard block |
||
| 118 | 118 | */ |
| 119 | 119 | public function getScript() |
| 120 | 120 | { |
| 121 | - if(count($this->aCalls) == 0) |
|
| 121 | + if (count($this->aCalls) == 0) |
|
| 122 | 122 | { |
| 123 | 123 | return $this->sSelector; |
| 124 | 124 | } |
@@ -57,12 +57,10 @@ |
||
| 57 | 57 | if(!$sSelector) |
| 58 | 58 | { |
| 59 | 59 | $this->sSelector = "$jQueryNs(this)"; // If an empty selector is given, use javascript "this" instead |
| 60 | - } |
|
| 61 | - elseif(($sContext)) |
|
| 60 | + } elseif(($sContext)) |
|
| 62 | 61 | { |
| 63 | 62 | $this->sSelector = "$jQueryNs('" . $sSelector . "', $jQueryNs('" . $sContext . "'))"; |
| 64 | - } |
|
| 65 | - else |
|
| 63 | + } else |
|
| 66 | 64 | { |
| 67 | 65 | $this->sSelector = "$jQueryNs('" . $sSelector . "')"; |
| 68 | 66 | } |
@@ -27,7 +27,7 @@ |
||
| 27 | 27 | public function render($sPath, array $aVars = []) |
| 28 | 28 | { |
| 29 | 29 | // Make the template vars available as attributes |
| 30 | - foreach($aVars as $sName => $xValue) |
|
| 30 | + foreach ($aVars as $sName => $xValue) |
|
| 31 | 31 | { |
| 32 | 32 | $sName = (string)$sName; |
| 33 | 33 | $this->$sName = $xValue; |
@@ -50,14 +50,14 @@ discard block |
||
| 50 | 50 | $sPrefix = trim((string)$sPrefix); |
| 51 | 51 | $nDepth = intval($nDepth); |
| 52 | 52 | // Check the max depth |
| 53 | - if($nDepth < 0 || $nDepth > 9) |
|
| 53 | + if ($nDepth < 0 || $nDepth > 9) |
|
| 54 | 54 | { |
| 55 | 55 | throw new \Jaxon\Exception\Config\Data(jaxon_trans('config.errors.data.depth', |
| 56 | 56 | array('key' => $sPrefix, 'depth' => $nDepth))); |
| 57 | 57 | } |
| 58 | - foreach($aOptions as $sName => $xOption) |
|
| 58 | + foreach ($aOptions as $sName => $xOption) |
|
| 59 | 59 | { |
| 60 | - if(is_int($sName)) |
|
| 60 | + if (is_int($sName)) |
|
| 61 | 61 | { |
| 62 | 62 | continue; |
| 63 | 63 | } |
@@ -67,7 +67,7 @@ discard block |
||
| 67 | 67 | // Save the value of this option |
| 68 | 68 | $this->aOptions[$sFullName] = $xOption; |
| 69 | 69 | // Save the values of its sub-options |
| 70 | - if(is_array($xOption)) |
|
| 70 | + if (is_array($xOption)) |
|
| 71 | 71 | { |
| 72 | 72 | // Recursively read the options in the array |
| 73 | 73 | $this->_setOptions($xOption, $sFullName, $nDepth + 1); |
@@ -89,9 +89,9 @@ discard block |
||
| 89 | 89 | $aKeys = explode('.', (string)$sKeys); |
| 90 | 90 | foreach ($aKeys as $sKey) |
| 91 | 91 | { |
| 92 | - if(($sKey)) |
|
| 92 | + if (($sKey)) |
|
| 93 | 93 | { |
| 94 | - if(!array_key_exists($sKey, $aOptions) || !is_array($aOptions[$sKey])) |
|
| 94 | + if (!array_key_exists($sKey, $aOptions) || !is_array($aOptions[$sKey])) |
|
| 95 | 95 | { |
| 96 | 96 | return; |
| 97 | 97 | } |
@@ -139,13 +139,12 @@ discard block |
||
| 139 | 139 | $sPrefix = rtrim($sPrefix, '.') . '.'; |
| 140 | 140 | $sPrefixLen = strlen($sPrefix); |
| 141 | 141 | $aOptions = []; |
| 142 | - foreach($this->aOptions as $sName => $xValue) |
|
| 142 | + foreach ($this->aOptions as $sName => $xValue) |
|
| 143 | 143 | { |
| 144 | - if(substr($sName, 0, $sPrefixLen) == $sPrefix) |
|
| 144 | + if (substr($sName, 0, $sPrefixLen) == $sPrefix) |
|
| 145 | 145 | { |
| 146 | 146 | $iNextDotPos = strpos($sName, '.', $sPrefixLen); |
| 147 | - $sOptionName = $iNextDotPos === false ? substr($sName, $sPrefixLen) : |
|
| 148 | - substr($sName, $sPrefixLen, $iNextDotPos - $sPrefixLen); |
|
| 147 | + $sOptionName = $iNextDotPos === false ? substr($sName, $sPrefixLen) : substr($sName, $sPrefixLen, $iNextDotPos - $sPrefixLen); |
|
| 149 | 148 | $aOptions[$sOptionName] = $sPrefix . $sOptionName; |
| 150 | 149 | } |
| 151 | 150 | } |
@@ -223,13 +223,11 @@ discard block |
||
| 223 | 223 | { |
| 224 | 224 | // The name of a request plugin is used as key in the plugin table |
| 225 | 225 | $this->aRequestPlugins[$xPlugin->getName()] = $xPlugin; |
| 226 | - } |
|
| 227 | - elseif($xPlugin instanceof Response) |
|
| 226 | + } elseif($xPlugin instanceof Response) |
|
| 228 | 227 | { |
| 229 | 228 | // The name of a response plugin is used as key in the plugin table |
| 230 | 229 | $this->aResponsePlugins[$xPlugin->getName()] = $xPlugin; |
| 231 | - } |
|
| 232 | - elseif(!$bIsConfirm && !$bIsAlert) |
|
| 230 | + } elseif(!$bIsConfirm && !$bIsAlert) |
|
| 233 | 231 | { |
| 234 | 232 | throw new \Jaxon\Exception\Error($this->trans('errors.register.invalid', array('name' => get_class($xPlugin)))); |
| 235 | 233 | } |
@@ -644,8 +642,7 @@ discard block |
||
| 644 | 642 | 'sJsOptions' => $this->getOption('js.app.options'), |
| 645 | 643 | 'sUrl' => $sJsAppURI . $sOutFile, |
| 646 | 644 | )); |
| 647 | - } |
|
| 648 | - else |
|
| 645 | + } else |
|
| 649 | 646 | { |
| 650 | 647 | // The plugins scripts are wrapped with javascript tags |
| 651 | 648 | $sScript = $this->render('jaxon::plugins/wrapper.js', array( |
@@ -219,32 +219,32 @@ discard block |
||
| 219 | 219 | { |
| 220 | 220 | $bIsAlert = ($xPlugin instanceof Dialogs\Interfaces\Alert); |
| 221 | 221 | $bIsConfirm = ($xPlugin instanceof Dialogs\Interfaces\Confirm); |
| 222 | - if($xPlugin instanceof Request) |
|
| 222 | + if ($xPlugin instanceof Request) |
|
| 223 | 223 | { |
| 224 | 224 | // The name of a request plugin is used as key in the plugin table |
| 225 | 225 | $this->aRequestPlugins[$xPlugin->getName()] = $xPlugin; |
| 226 | 226 | } |
| 227 | - elseif($xPlugin instanceof Response) |
|
| 227 | + elseif ($xPlugin instanceof Response) |
|
| 228 | 228 | { |
| 229 | 229 | // The name of a response plugin is used as key in the plugin table |
| 230 | 230 | $this->aResponsePlugins[$xPlugin->getName()] = $xPlugin; |
| 231 | 231 | } |
| 232 | - elseif(!$bIsConfirm && !$bIsAlert) |
|
| 232 | + elseif (!$bIsConfirm && !$bIsAlert) |
|
| 233 | 233 | { |
| 234 | 234 | throw new \Jaxon\Exception\Error($this->trans('errors.register.invalid', array('name' => get_class($xPlugin)))); |
| 235 | 235 | } |
| 236 | 236 | // This plugin implements the Alert interface |
| 237 | - if($bIsAlert) |
|
| 237 | + if ($bIsAlert) |
|
| 238 | 238 | { |
| 239 | 239 | $this->setAlert($xPlugin); |
| 240 | 240 | } |
| 241 | 241 | // This plugin implements the Confirm interface |
| 242 | - if($bIsConfirm) |
|
| 242 | + if ($bIsConfirm) |
|
| 243 | 243 | { |
| 244 | 244 | $this->setConfirm($xPlugin); |
| 245 | 245 | } |
| 246 | 246 | // Register the plugin as an event listener |
| 247 | - if($xPlugin instanceof \Jaxon\Utils\Interfaces\EventListener) |
|
| 247 | + if ($xPlugin instanceof \Jaxon\Utils\Interfaces\EventListener) |
|
| 248 | 248 | { |
| 249 | 249 | $this->addEventListener($xPlugin); |
| 250 | 250 | } |
@@ -274,7 +274,7 @@ discard block |
||
| 274 | 274 | private function generateHash() |
| 275 | 275 | { |
| 276 | 276 | $sHash = $this->getVersion(); |
| 277 | - foreach($this->aPlugins as $xPlugin) |
|
| 277 | + foreach ($this->aPlugins as $xPlugin) |
|
| 278 | 278 | { |
| 279 | 279 | $sHash .= $xPlugin->generateHash(); |
| 280 | 280 | } |
@@ -291,9 +291,9 @@ discard block |
||
| 291 | 291 | */ |
| 292 | 292 | public function canProcessRequest() |
| 293 | 293 | { |
| 294 | - foreach($this->aRequestPlugins as $xPlugin) |
|
| 294 | + foreach ($this->aRequestPlugins as $xPlugin) |
|
| 295 | 295 | { |
| 296 | - if($xPlugin->getName() != Jaxon::FILE_UPLOAD && $xPlugin->canProcessRequest()) |
|
| 296 | + if ($xPlugin->getName() != Jaxon::FILE_UPLOAD && $xPlugin->canProcessRequest()) |
|
| 297 | 297 | { |
| 298 | 298 | return true; |
| 299 | 299 | } |
@@ -312,12 +312,12 @@ discard block |
||
| 312 | 312 | public function processRequest() |
| 313 | 313 | { |
| 314 | 314 | $xUploadPlugin = $this->getRequestPlugin(Jaxon::FILE_UPLOAD); |
| 315 | - foreach($this->aRequestPlugins as $xPlugin) |
|
| 315 | + foreach ($this->aRequestPlugins as $xPlugin) |
|
| 316 | 316 | { |
| 317 | - if($xPlugin->getName() != Jaxon::FILE_UPLOAD && $xPlugin->canProcessRequest()) |
|
| 317 | + if ($xPlugin->getName() != Jaxon::FILE_UPLOAD && $xPlugin->canProcessRequest()) |
|
| 318 | 318 | { |
| 319 | 319 | // Process uploaded files |
| 320 | - if($xUploadPlugin != null) |
|
| 320 | + if ($xUploadPlugin != null) |
|
| 321 | 321 | { |
| 322 | 322 | $xUploadPlugin->processRequest(); |
| 323 | 323 | } |
@@ -341,10 +341,10 @@ discard block |
||
| 341 | 341 | */ |
| 342 | 342 | public function register($aArgs) |
| 343 | 343 | { |
| 344 | - foreach($this->aRequestPlugins as $xPlugin) |
|
| 344 | + foreach ($this->aRequestPlugins as $xPlugin) |
|
| 345 | 345 | { |
| 346 | 346 | $mResult = $xPlugin->register($aArgs); |
| 347 | - if($mResult instanceof \Jaxon\Request\Request || is_array($mResult) || $mResult === true) |
|
| 347 | + if ($mResult instanceof \Jaxon\Request\Request || is_array($mResult) || $mResult === true) |
|
| 348 | 348 | { |
| 349 | 349 | return $mResult; |
| 350 | 350 | } |
@@ -359,7 +359,7 @@ discard block |
||
| 359 | 359 | */ |
| 360 | 360 | private function getJsLibUri() |
| 361 | 361 | { |
| 362 | - if(!$this->hasOption('js.lib.uri')) |
|
| 362 | + if (!$this->hasOption('js.lib.uri')) |
|
| 363 | 363 | { |
| 364 | 364 | // return 'https://cdn.jsdelivr.net/jaxon/1.2.0/'; |
| 365 | 365 | return 'https://cdn.jsdelivr.net/gh/jaxon-php/[email protected]/dist/'; |
@@ -382,7 +382,7 @@ discard block |
||
| 382 | 382 | // The jsDelivr CDN only hosts minified files |
| 383 | 383 | // if(($this->getOption('js.app.minify')) || substr($this->getJsLibUri(), 0, $nLen) == $jsDelivrUri) |
| 384 | 384 | // Starting from version 2.0.0 of the js lib, the jsDelivr CDN also hosts non minified files. |
| 385 | - if(($this->getOption('js.app.minify'))) |
|
| 385 | + if (($this->getOption('js.app.minify'))) |
|
| 386 | 386 | { |
| 387 | 387 | return '.min.js'; |
| 388 | 388 | } |
@@ -399,7 +399,7 @@ discard block |
||
| 399 | 399 | // Check config options |
| 400 | 400 | // - The js.app.extern option must be set to true |
| 401 | 401 | // - The js.app.uri and js.app.dir options must be set to non null values |
| 402 | - if(!$this->getOption('js.app.extern') || |
|
| 402 | + if (!$this->getOption('js.app.extern') || |
|
| 403 | 403 | !$this->getOption('js.app.uri') || |
| 404 | 404 | !$this->getOption('js.app.dir')) |
| 405 | 405 | { |
@@ -408,7 +408,7 @@ discard block |
||
| 408 | 408 | // Check dir access |
| 409 | 409 | // - The js.app.dir must be writable |
| 410 | 410 | $sJsAppDir = $this->getOption('js.app.dir'); |
| 411 | - if(!is_dir($sJsAppDir) || !is_writable($sJsAppDir)) |
|
| 411 | + if (!is_dir($sJsAppDir) || !is_writable($sJsAppDir)) |
|
| 412 | 412 | { |
| 413 | 413 | return false; |
| 414 | 414 | } |
@@ -422,7 +422,7 @@ discard block |
||
| 422 | 422 | */ |
| 423 | 423 | private function setTemplateCacheDir() |
| 424 | 424 | { |
| 425 | - if($this->hasOption('core.template.cache_dir')) |
|
| 425 | + if ($this->hasOption('core.template.cache_dir')) |
|
| 426 | 426 | { |
| 427 | 427 | $this->setCacheDir($this->getOption('core.template.cache_dir')); |
| 428 | 428 | } |
@@ -444,7 +444,7 @@ discard block |
||
| 444 | 444 | |
| 445 | 445 | // Add component files to the javascript file array; |
| 446 | 446 | $aJsFiles = array($sJsCoreUrl); |
| 447 | - if($this->getOption('core.debug.on')) |
|
| 447 | + if ($this->getOption('core.debug.on')) |
|
| 448 | 448 | { |
| 449 | 449 | $aJsFiles[] = $sJsDebugUrl; |
| 450 | 450 | $aJsFiles[] = $sJsLanguageUrl; |
@@ -460,17 +460,17 @@ discard block |
||
| 460 | 460 | 'sJsOptions' => $this->getOption('js.app.options'), |
| 461 | 461 | 'aUrls' => $aJsFiles, |
| 462 | 462 | )); |
| 463 | - foreach($this->aResponsePlugins as $xPlugin) |
|
| 463 | + foreach ($this->aResponsePlugins as $xPlugin) |
|
| 464 | 464 | { |
| 465 | - if(($str = trim($xPlugin->getJs()))) |
|
| 465 | + if (($str = trim($xPlugin->getJs()))) |
|
| 466 | 466 | { |
| 467 | 467 | $sCode .= rtrim($str, " \n") . "\n"; |
| 468 | 468 | } |
| 469 | 469 | } |
| 470 | - foreach($this->aPackages as $sClass) |
|
| 470 | + foreach ($this->aPackages as $sClass) |
|
| 471 | 471 | { |
| 472 | 472 | $xPackage = jaxon()->di()->get($sClass); |
| 473 | - if(($str = trim($xPackage->js()))) |
|
| 473 | + if (($str = trim($xPackage->js()))) |
|
| 474 | 474 | { |
| 475 | 475 | $sCode .= rtrim($str, " \n") . "\n"; |
| 476 | 476 | } |
@@ -489,17 +489,17 @@ discard block |
||
| 489 | 489 | $this->setTemplateCacheDir(); |
| 490 | 490 | |
| 491 | 491 | $sCode = ''; |
| 492 | - foreach($this->aResponsePlugins as $xPlugin) |
|
| 492 | + foreach ($this->aResponsePlugins as $xPlugin) |
|
| 493 | 493 | { |
| 494 | - if(($str = trim($xPlugin->getCss()))) |
|
| 494 | + if (($str = trim($xPlugin->getCss()))) |
|
| 495 | 495 | { |
| 496 | 496 | $sCode .= rtrim($str, " \n") . "\n"; |
| 497 | 497 | } |
| 498 | 498 | } |
| 499 | - foreach($this->aPackages as $sClass) |
|
| 499 | + foreach ($this->aPackages as $sClass) |
|
| 500 | 500 | { |
| 501 | 501 | $xPackage = jaxon()->di()->get($sClass); |
| 502 | - if(($str = trim($xPackage->css()))) |
|
| 502 | + if (($str = trim($xPackage->css()))) |
|
| 503 | 503 | { |
| 504 | 504 | $sCode .= rtrim($str, " \n") . "\n"; |
| 505 | 505 | } |
@@ -563,17 +563,17 @@ discard block |
||
| 563 | 563 | private function getReadyScript() |
| 564 | 564 | { |
| 565 | 565 | $sPluginScript = ''; |
| 566 | - foreach($this->aResponsePlugins as $xPlugin) |
|
| 566 | + foreach ($this->aResponsePlugins as $xPlugin) |
|
| 567 | 567 | { |
| 568 | - if(($str = trim($xPlugin->getScript()))) |
|
| 568 | + if (($str = trim($xPlugin->getScript()))) |
|
| 569 | 569 | { |
| 570 | 570 | $sPluginScript .= "\n" . trim($str, " \n"); |
| 571 | 571 | } |
| 572 | 572 | } |
| 573 | - foreach($this->aPackages as $sClass) |
|
| 573 | + foreach ($this->aPackages as $sClass) |
|
| 574 | 574 | { |
| 575 | 575 | $xPackage = jaxon()->di()->get($sClass); |
| 576 | - if(($str = trim($xPackage->ready()))) |
|
| 576 | + if (($str = trim($xPackage->ready()))) |
|
| 577 | 577 | { |
| 578 | 578 | $sPluginScript .= "\n" . trim($str, " \n"); |
| 579 | 579 | } |
@@ -596,7 +596,7 @@ discard block |
||
| 596 | 596 | { |
| 597 | 597 | // Get the config and plugins scripts |
| 598 | 598 | $sScript = $this->getConfigScript() . "\n" . $this->getReadyScript() . "\n"; |
| 599 | - foreach($this->aRequestPlugins as $xPlugin) |
|
| 599 | + foreach ($this->aRequestPlugins as $xPlugin) |
|
| 600 | 600 | { |
| 601 | 601 | $sScript .= "\n" . trim($xPlugin->getScript(), " \n"); |
| 602 | 602 | } |
@@ -618,7 +618,7 @@ discard block |
||
| 618 | 618 | // Set the template engine cache dir |
| 619 | 619 | $this->setTemplateCacheDir(); |
| 620 | 620 | |
| 621 | - if($this->canExportJavascript()) |
|
| 621 | + if ($this->canExportJavascript()) |
|
| 622 | 622 | { |
| 623 | 623 | $sJsAppURI = rtrim($this->getOption('js.app.uri'), '/') . '/'; |
| 624 | 624 | $sJsAppDir = rtrim($this->getOption('js.app.dir'), '/') . '/'; |
@@ -627,13 +627,13 @@ discard block |
||
| 627 | 627 | $sHash = $this->generateHash(); |
| 628 | 628 | $sOutFile = $sHash . '.js'; |
| 629 | 629 | $sMinFile = $sHash . '.min.js'; |
| 630 | - if(!is_file($sJsAppDir . $sOutFile)) |
|
| 630 | + if (!is_file($sJsAppDir . $sOutFile)) |
|
| 631 | 631 | { |
| 632 | 632 | file_put_contents($sJsAppDir . $sOutFile, $this->getAllScripts()); |
| 633 | 633 | } |
| 634 | - if(($this->getOption('js.app.minify')) && !is_file($sJsAppDir . $sMinFile)) |
|
| 634 | + if (($this->getOption('js.app.minify')) && !is_file($sJsAppDir . $sMinFile)) |
|
| 635 | 635 | { |
| 636 | - if(($this->minify($sJsAppDir . $sOutFile, $sJsAppDir . $sMinFile))) |
|
| 636 | + if (($this->minify($sJsAppDir . $sOutFile, $sJsAppDir . $sMinFile))) |
|
| 637 | 637 | { |
| 638 | 638 | $sOutFile = $sMinFile; |
| 639 | 639 | } |
@@ -666,7 +666,7 @@ discard block |
||
| 666 | 666 | */ |
| 667 | 667 | public function getResponsePlugin($sName) |
| 668 | 668 | { |
| 669 | - if(array_key_exists($sName, $this->aResponsePlugins)) |
|
| 669 | + if (array_key_exists($sName, $this->aResponsePlugins)) |
|
| 670 | 670 | { |
| 671 | 671 | return $this->aResponsePlugins[$sName]; |
| 672 | 672 | } |
@@ -682,7 +682,7 @@ discard block |
||
| 682 | 682 | */ |
| 683 | 683 | public function getRequestPlugin($sName) |
| 684 | 684 | { |
| 685 | - if(array_key_exists($sName, $this->aRequestPlugins)) |
|
| 685 | + if (array_key_exists($sName, $this->aRequestPlugins)) |
|
| 686 | 686 | { |
| 687 | 687 | return $this->aRequestPlugins[$sName]; |
| 688 | 688 | } |
@@ -22,7 +22,7 @@ |
||
| 22 | 22 | */ |
| 23 | 23 | public function confirm($question, $yesScript, $noScript) |
| 24 | 24 | { |
| 25 | - if(!$noScript) |
|
| 25 | + if (!$noScript) |
|
| 26 | 26 | { |
| 27 | 27 | return 'if(confirm(' . $question . ')){' . $yesScript . ';}'; |
| 28 | 28 | } |
@@ -25,8 +25,7 @@ |
||
| 25 | 25 | if(!$noScript) |
| 26 | 26 | { |
| 27 | 27 | return 'if(confirm(' . $question . ')){' . $yesScript . ';}'; |
| 28 | - } |
|
| 29 | - else |
|
| 28 | + } else |
|
| 30 | 29 | { |
| 31 | 30 | return 'if(confirm(' . $question . ')){' . $yesScript . ';}else{' . $noScript . ';}'; |
| 32 | 31 | } |