@@ -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 | } |
@@ -219,32 +219,32 @@ discard block |
||
| 219 | 219 | { |
| 220 | 220 | $bIsAlert = ($xPlugin instanceof \Jaxon\Request\Interfaces\Alert); |
| 221 | 221 | $bIsConfirm = ($xPlugin instanceof \Jaxon\Request\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 | } |
@@ -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( |