@@ -105,7 +105,7 @@ |
||
| 105 | 105 | * |
| 106 | 106 | * @param array $aArgs An array containing the event specification |
| 107 | 107 | * |
| 108 | - * @return \Jaxon\Request\Request |
|
| 108 | + * @return boolean |
|
| 109 | 109 | */ |
| 110 | 110 | public function register($aArgs) |
| 111 | 111 | { |
@@ -49,12 +49,12 @@ discard block |
||
| 49 | 49 | $this->aUserFiles = []; |
| 50 | 50 | $this->aFiles = []; |
| 51 | 51 | |
| 52 | - foreach($_FILES as $var => $aFile) |
|
| 52 | + foreach ($_FILES as $var => $aFile) |
|
| 53 | 53 | { |
| 54 | 54 | $this->aFiles[$var] = []; |
| 55 | - if(is_array($aFile['name'])) |
|
| 55 | + if (is_array($aFile['name'])) |
|
| 56 | 56 | { |
| 57 | - for($i = 0; $i < count($aFile['name']); $i++) |
|
| 57 | + for ($i = 0; $i < count($aFile['name']); $i++) |
|
| 58 | 58 | { |
| 59 | 59 | // Copy the file data into the local array |
| 60 | 60 | $this->aFiles[$var][] = [ |
@@ -154,25 +154,25 @@ discard block |
||
| 154 | 154 | // Default upload dir |
| 155 | 155 | $sDefaultUploadDir = $this->getOption('upload.dir'); |
| 156 | 156 | // Check validity of the uploaded files |
| 157 | - foreach($this->aFiles as $var => &$aFiles) |
|
| 157 | + foreach ($this->aFiles as $var => &$aFiles) |
|
| 158 | 158 | { |
| 159 | 159 | $this->aUserFiles[$var] = []; |
| 160 | - foreach($aFiles as &$aFile) |
|
| 160 | + foreach ($aFiles as &$aFile) |
|
| 161 | 161 | { |
| 162 | 162 | // Verify upload result |
| 163 | - if($aFile['error'] != 0) |
|
| 163 | + if ($aFile['error'] != 0) |
|
| 164 | 164 | { |
| 165 | 165 | throw new \Jaxon\Exception\Error($this->trans('errors.upload.failed', $aFile)); |
| 166 | 166 | } |
| 167 | 167 | // Verify file validity (format, size) |
| 168 | - if(!$this->validateUploadedFile($aFile)) |
|
| 168 | + if (!$this->validateUploadedFile($aFile)) |
|
| 169 | 169 | { |
| 170 | 170 | throw new \Jaxon\Exception\Error($this->trans('errors.upload.invalid', $aFile)); |
| 171 | 171 | } |
| 172 | 172 | // Verify that the upload dir exists and is writable |
| 173 | 173 | $sUploadDir = trim($this->getOption('upload.files.' . $var . '.dir', $sDefaultUploadDir)); |
| 174 | 174 | $sUploadDir = rtrim($sUploadDir, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR; |
| 175 | - if(!is_writable($sUploadDir)) |
|
| 175 | + if (!is_writable($sUploadDir)) |
|
| 176 | 176 | { |
| 177 | 177 | throw new \Jaxon\Exception\Error($this->trans('errors.upload.access')); |
| 178 | 178 | } |
@@ -186,9 +186,9 @@ discard block |
||
| 186 | 186 | } |
| 187 | 187 | } |
| 188 | 188 | // Copy the uploaded files from the temp dir to the user dir |
| 189 | - foreach($this->aFiles as $var => $aFiles) |
|
| 189 | + foreach ($this->aFiles as $var => $aFiles) |
|
| 190 | 190 | { |
| 191 | - for($i = 0; $i < count($aFiles); $i++) |
|
| 191 | + for ($i = 0; $i < count($aFiles); $i++) |
|
| 192 | 192 | { |
| 193 | 193 | // All's right, move the file to the user dir. |
| 194 | 194 | move_uploaded_file($aFiles[$i]["tmp_name"], $this->aUserFiles[$var][$i]["path"]); |
@@ -65,8 +65,7 @@ |
||
| 65 | 65 | 'size' => $aFile['size'][$i], |
| 66 | 66 | ]; |
| 67 | 67 | } |
| 68 | - } |
|
| 69 | - else |
|
| 68 | + } else |
|
| 70 | 69 | { |
| 71 | 70 | // Copy the file data into the local array |
| 72 | 71 | $this->aFiles[$var][] = [ |
@@ -28,7 +28,7 @@ discard block |
||
| 28 | 28 | * |
| 29 | 29 | * @param string $sName The function name |
| 30 | 30 | * |
| 31 | - * @return bool True if the function name is valid, and false if not |
|
| 31 | + * @return integer True if the function name is valid, and false if not |
|
| 32 | 32 | */ |
| 33 | 33 | public function validateFunction($sName) |
| 34 | 34 | { |
@@ -40,7 +40,7 @@ discard block |
||
| 40 | 40 | * |
| 41 | 41 | * @param string $sName The event name |
| 42 | 42 | * |
| 43 | - * @return bool True if the event name is valid, and false if not |
|
| 43 | + * @return integer True if the event name is valid, and false if not |
|
| 44 | 44 | */ |
| 45 | 45 | public function validateEvent($sName) |
| 46 | 46 | { |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | * |
| 53 | 53 | * @param string $sName The class name |
| 54 | 54 | * |
| 55 | - * @return bool True if the class name is valid, and false if not |
|
| 55 | + * @return integer True if the class name is valid, and false if not |
|
| 56 | 56 | */ |
| 57 | 57 | public function validateClass($sName) |
| 58 | 58 | { |
@@ -64,7 +64,7 @@ discard block |
||
| 64 | 64 | * |
| 65 | 65 | * @param string $sName The function name |
| 66 | 66 | * |
| 67 | - * @return bool True if the method name is valid, and false if not |
|
| 67 | + * @return integer True if the method name is valid, and false if not |
|
| 68 | 68 | */ |
| 69 | 69 | public function validateMethod($sName) |
| 70 | 70 | { |
@@ -612,7 +612,7 @@ |
||
| 612 | 612 | $this->addViewNamespace('pagination', $sDirectory, '.php'); |
| 613 | 613 | } |
| 614 | 614 | |
| 615 | - /** |
|
| 615 | + /** |
|
| 616 | 616 | * Get the uploaded files |
| 617 | 617 | * |
| 618 | 618 | * @return array |
@@ -129,7 +129,7 @@ discard block |
||
| 129 | 129 | 'core.prefix.event' => 'jaxon_event_', |
| 130 | 130 | // 'core.request.uri' => '', |
| 131 | 131 | 'core.request.mode' => 'asynchronous', |
| 132 | - 'core.request.method' => 'POST', // W3C: Method is case sensitive |
|
| 132 | + 'core.request.method' => 'POST', // W3C: Method is case sensitive |
|
| 133 | 133 | 'core.debug.on' => false, |
| 134 | 134 | 'core.debug.verbose' => false, |
| 135 | 135 | 'core.process.exit' => true, |
@@ -206,13 +206,13 @@ discard block |
||
| 206 | 206 | $aArgs = func_get_args(); |
| 207 | 207 | $nArgs = func_num_args(); |
| 208 | 208 | |
| 209 | - if(self::PROCESSING_EVENT == $sType) |
|
| 209 | + if (self::PROCESSING_EVENT == $sType) |
|
| 210 | 210 | { |
| 211 | - if($nArgs > 2) |
|
| 211 | + if ($nArgs > 2) |
|
| 212 | 212 | { |
| 213 | 213 | $sEvent = $xArgs; |
| 214 | 214 | $xUserFunction = $aArgs[2]; |
| 215 | - if(!is_a($xUserFunction, 'Request\\Support\\UserFunction')) |
|
| 215 | + if (!is_a($xUserFunction, 'Request\\Support\\UserFunction')) |
|
| 216 | 216 | $xUserFunction = new Request\Support\UserFunction($xUserFunction); |
| 217 | 217 | $this->aProcessingEvents[$sEvent] = $xUserFunction; |
| 218 | 218 | } |
@@ -298,7 +298,7 @@ discard block |
||
| 298 | 298 | public function processRequest() |
| 299 | 299 | { |
| 300 | 300 | // Check to see if headers have already been sent out, in which case we can't do our job |
| 301 | - if(headers_sent($filename, $linenumber)) |
|
| 301 | + if (headers_sent($filename, $linenumber)) |
|
| 302 | 302 | { |
| 303 | 303 | echo $this->trans('errors.output.already-sent', array( |
| 304 | 304 | 'location' => $filename . ':' . $linenumber |
@@ -307,7 +307,7 @@ discard block |
||
| 307 | 307 | } |
| 308 | 308 | |
| 309 | 309 | // Check if there is a plugin to process this request |
| 310 | - if(!$this->canProcessRequest()) |
|
| 310 | + if (!$this->canProcessRequest()) |
|
| 311 | 311 | { |
| 312 | 312 | return; |
| 313 | 313 | } |
@@ -316,18 +316,18 @@ discard block |
||
| 316 | 316 | $mResult = true; |
| 317 | 317 | |
| 318 | 318 | // Handle before processing event |
| 319 | - if(isset($this->aProcessingEvents[self::PROCESSING_EVENT_BEFORE])) |
|
| 319 | + if (isset($this->aProcessingEvents[self::PROCESSING_EVENT_BEFORE])) |
|
| 320 | 320 | { |
| 321 | 321 | $this->aProcessingEvents[self::PROCESSING_EVENT_BEFORE]->call(array(&$bEndRequest)); |
| 322 | 322 | } |
| 323 | 323 | |
| 324 | - if(!$bEndRequest) |
|
| 324 | + if (!$bEndRequest) |
|
| 325 | 325 | { |
| 326 | 326 | try |
| 327 | 327 | { |
| 328 | 328 | $mResult = $this->getPluginManager()->processRequest(); |
| 329 | 329 | } |
| 330 | - catch(Exception $e) |
|
| 330 | + catch (Exception $e) |
|
| 331 | 331 | { |
| 332 | 332 | // An exception was thrown while processing the request. |
| 333 | 333 | // The request missed the corresponding handler function, |
@@ -340,7 +340,7 @@ discard block |
||
| 340 | 340 | $xResponseManager->debug($e->getMessage()); |
| 341 | 341 | $mResult = false; |
| 342 | 342 | |
| 343 | - if($e instanceof \Jaxon\Exception\Error) |
|
| 343 | + if ($e instanceof \Jaxon\Exception\Error) |
|
| 344 | 344 | { |
| 345 | 345 | $sEvent = self::PROCESSING_EVENT_INVALID; |
| 346 | 346 | $aParams = array($e->getMessage()); |
@@ -351,7 +351,7 @@ discard block |
||
| 351 | 351 | $aParams = array($e); |
| 352 | 352 | } |
| 353 | 353 | |
| 354 | - if(isset($this->aProcessingEvents[$sEvent])) |
|
| 354 | + if (isset($this->aProcessingEvents[$sEvent])) |
|
| 355 | 355 | { |
| 356 | 356 | // Call the processing event |
| 357 | 357 | $this->aProcessingEvents[$sEvent]->call($aParams); |
@@ -364,7 +364,7 @@ discard block |
||
| 364 | 364 | } |
| 365 | 365 | } |
| 366 | 366 | // Clean the processing buffer |
| 367 | - if(($this->getOption('core.process.clean'))) |
|
| 367 | + if (($this->getOption('core.process.clean'))) |
|
| 368 | 368 | { |
| 369 | 369 | $er = error_reporting(0); |
| 370 | 370 | while (ob_get_level() > 0) |
@@ -374,10 +374,10 @@ discard block |
||
| 374 | 374 | error_reporting($er); |
| 375 | 375 | } |
| 376 | 376 | |
| 377 | - if($mResult === true) |
|
| 377 | + if ($mResult === true) |
|
| 378 | 378 | { |
| 379 | 379 | // Handle after processing event |
| 380 | - if(isset($this->aProcessingEvents[self::PROCESSING_EVENT_AFTER])) |
|
| 380 | + if (isset($this->aProcessingEvents[self::PROCESSING_EVENT_AFTER])) |
|
| 381 | 381 | { |
| 382 | 382 | $bEndRequest = false; |
| 383 | 383 | $this->aProcessingEvents[self::PROCESSING_EVENT_AFTER]->call(array($bEndRequest)); |
@@ -386,7 +386,7 @@ discard block |
||
| 386 | 386 | |
| 387 | 387 | $this->getResponseManager()->printDebug(); |
| 388 | 388 | |
| 389 | - if(($this->getOption('core.process.exit'))) |
|
| 389 | + if (($this->getOption('core.process.exit'))) |
|
| 390 | 390 | { |
| 391 | 391 | $this->getResponseManager()->sendOutput(); |
| 392 | 392 | exit(); |
@@ -436,16 +436,16 @@ discard block |
||
| 436 | 436 | */ |
| 437 | 437 | public function getScript($bIncludeJs = false, $bIncludeCss = false) |
| 438 | 438 | { |
| 439 | - if(!$this->getOption('core.request.uri')) |
|
| 439 | + if (!$this->getOption('core.request.uri')) |
|
| 440 | 440 | { |
| 441 | 441 | $this->setOption('core.request.uri', URI::detect()); |
| 442 | 442 | } |
| 443 | 443 | $sCode = ''; |
| 444 | - if(($bIncludeCss)) |
|
| 444 | + if (($bIncludeCss)) |
|
| 445 | 445 | { |
| 446 | 446 | $sCode .= $this->getPluginManager()->getCss() . "\n"; |
| 447 | 447 | } |
| 448 | - if(($bIncludeJs)) |
|
| 448 | + if (($bIncludeJs)) |
|
| 449 | 449 | { |
| 450 | 450 | $sCode .= $this->getPluginManager()->getJs() . "\n"; |
| 451 | 451 | } |
@@ -543,7 +543,7 @@ discard block |
||
| 543 | 543 | public function readConfigFile($sConfigFile, $sLibKey = '', $sAppKey = null) |
| 544 | 544 | { |
| 545 | 545 | $sExt = pathinfo($sConfigFile, PATHINFO_EXTENSION); |
| 546 | - switch($sExt) |
|
| 546 | + switch ($sExt) |
|
| 547 | 547 | { |
| 548 | 548 | case 'php': |
| 549 | 549 | return $this->readPhpConfigFile($sConfigFile, $sLibKey, $sAppKey); |
@@ -619,7 +619,7 @@ discard block |
||
| 619 | 619 | */ |
| 620 | 620 | public function getUploadedFiles() |
| 621 | 621 | { |
| 622 | - if(($xUploadPlugin = $this->getPluginManager()->getRequestPlugin('FileUpload')) == null) |
|
| 622 | + if (($xUploadPlugin = $this->getPluginManager()->getRequestPlugin('FileUpload')) == null) |
|
| 623 | 623 | { |
| 624 | 624 | return []; |
| 625 | 625 | } |
@@ -262,32 +262,32 @@ discard block |
||
| 262 | 262 | { |
| 263 | 263 | $bIsAlert = ($xPlugin instanceof \Jaxon\Request\Interfaces\Alert); |
| 264 | 264 | $bIsConfirm = ($xPlugin instanceof \Jaxon\Request\Interfaces\Confirm); |
| 265 | - if($xPlugin instanceof Request) |
|
| 265 | + if ($xPlugin instanceof Request) |
|
| 266 | 266 | { |
| 267 | 267 | // The name of a request plugin is used as key in the plugin table |
| 268 | 268 | $this->aRequestPlugins[$xPlugin->getName()] = $xPlugin; |
| 269 | 269 | } |
| 270 | - elseif($xPlugin instanceof Response) |
|
| 270 | + elseif ($xPlugin instanceof Response) |
|
| 271 | 271 | { |
| 272 | 272 | // The name of a response plugin is used as key in the plugin table |
| 273 | 273 | $this->aResponsePlugins[$xPlugin->getName()] = $xPlugin; |
| 274 | 274 | } |
| 275 | - elseif(!$bIsConfirm && !$bIsAlert) |
|
| 275 | + elseif (!$bIsConfirm && !$bIsAlert) |
|
| 276 | 276 | { |
| 277 | 277 | throw new \Jaxon\Exception\Error($this->trans('errors.register.invalid', array('name' => get_class($xPlugin)))); |
| 278 | 278 | } |
| 279 | 279 | // This plugin implements the Alert interface |
| 280 | - if($bIsAlert) |
|
| 280 | + if ($bIsAlert) |
|
| 281 | 281 | { |
| 282 | 282 | $this->setAlert($xPlugin); |
| 283 | 283 | } |
| 284 | 284 | // This plugin implements the Confirm interface |
| 285 | - if($bIsConfirm) |
|
| 285 | + if ($bIsConfirm) |
|
| 286 | 286 | { |
| 287 | 287 | $this->setConfirm($xPlugin); |
| 288 | 288 | } |
| 289 | 289 | // Register the plugin as an event listener |
| 290 | - if($xPlugin instanceof \Jaxon\Utils\Interfaces\EventListener) |
|
| 290 | + if ($xPlugin instanceof \Jaxon\Utils\Interfaces\EventListener) |
|
| 291 | 291 | { |
| 292 | 292 | $this->addEventListener($xPlugin); |
| 293 | 293 | } |
@@ -303,7 +303,7 @@ discard block |
||
| 303 | 303 | private function generateHash() |
| 304 | 304 | { |
| 305 | 305 | $sHash = $this->getVersion(); |
| 306 | - foreach($this->aPlugins as $xPlugin) |
|
| 306 | + foreach ($this->aPlugins as $xPlugin) |
|
| 307 | 307 | { |
| 308 | 308 | $sHash .= $xPlugin->generateHash(); |
| 309 | 309 | } |
@@ -320,9 +320,9 @@ discard block |
||
| 320 | 320 | */ |
| 321 | 321 | public function canProcessRequest() |
| 322 | 322 | { |
| 323 | - foreach($this->aRequestPlugins as $xPlugin) |
|
| 323 | + foreach ($this->aRequestPlugins as $xPlugin) |
|
| 324 | 324 | { |
| 325 | - if($xPlugin->canProcessRequest()) |
|
| 325 | + if ($xPlugin->canProcessRequest()) |
|
| 326 | 326 | { |
| 327 | 327 | return true; |
| 328 | 328 | } |
@@ -341,12 +341,12 @@ discard block |
||
| 341 | 341 | public function processRequest() |
| 342 | 342 | { |
| 343 | 343 | $xUploadPlugin = $this->getRequestPlugin('FileUpload'); |
| 344 | - foreach($this->aRequestPlugins as $xPlugin) |
|
| 344 | + foreach ($this->aRequestPlugins as $xPlugin) |
|
| 345 | 345 | { |
| 346 | - if($xPlugin->canProcessRequest()) |
|
| 346 | + if ($xPlugin->canProcessRequest()) |
|
| 347 | 347 | { |
| 348 | 348 | // Process uploaded files |
| 349 | - if($xUploadPlugin != null) |
|
| 349 | + if ($xUploadPlugin != null) |
|
| 350 | 350 | { |
| 351 | 351 | $xUploadPlugin->processRequest(); |
| 352 | 352 | } |
@@ -370,10 +370,10 @@ discard block |
||
| 370 | 370 | */ |
| 371 | 371 | public function register($aArgs) |
| 372 | 372 | { |
| 373 | - foreach($this->aRequestPlugins as $xPlugin) |
|
| 373 | + foreach ($this->aRequestPlugins as $xPlugin) |
|
| 374 | 374 | { |
| 375 | 375 | $mResult = $xPlugin->register($aArgs); |
| 376 | - if($mResult instanceof \Jaxon\Request\Request || is_array($mResult) || $mResult === true) |
|
| 376 | + if ($mResult instanceof \Jaxon\Request\Request || is_array($mResult) || $mResult === true) |
|
| 377 | 377 | { |
| 378 | 378 | return $mResult; |
| 379 | 379 | } |
@@ -393,37 +393,37 @@ discard block |
||
| 393 | 393 | */ |
| 394 | 394 | public function addClassDir($sDirectory, $sNamespace = '', $sSeparator = '.', array $aProtected = array()) |
| 395 | 395 | { |
| 396 | - if(!is_dir(($sDirectory = trim($sDirectory)))) |
|
| 396 | + if (!is_dir(($sDirectory = trim($sDirectory)))) |
|
| 397 | 397 | { |
| 398 | 398 | return false; |
| 399 | 399 | } |
| 400 | 400 | // Only '.' and '_' are allowed to be used as separator. Any other value is ignored and '.' is used instead. |
| 401 | - if(($sSeparator = trim($sSeparator)) != '_') |
|
| 401 | + if (($sSeparator = trim($sSeparator)) != '_') |
|
| 402 | 402 | { |
| 403 | 403 | $sSeparator = '.'; |
| 404 | 404 | } |
| 405 | - if(!($sNamespace = trim($sNamespace, ' \\'))) |
|
| 405 | + if (!($sNamespace = trim($sNamespace, ' \\'))) |
|
| 406 | 406 | { |
| 407 | 407 | $sNamespace = ''; |
| 408 | 408 | } |
| 409 | - if(($sNamespace)) |
|
| 409 | + if (($sNamespace)) |
|
| 410 | 410 | { |
| 411 | 411 | // If there is an autoloader, register the dir with PSR4 autoloading |
| 412 | - if(($this->xAutoloader)) |
|
| 412 | + if (($this->xAutoloader)) |
|
| 413 | 413 | { |
| 414 | 414 | $this->xAutoloader->setPsr4($sNamespace . '\\', $sDirectory); |
| 415 | 415 | } |
| 416 | 416 | } |
| 417 | - elseif(($this->xAutoloader)) |
|
| 417 | + elseif (($this->xAutoloader)) |
|
| 418 | 418 | { |
| 419 | 419 | // If there is an autoloader, register the dir with classmap autoloading |
| 420 | 420 | $itDir = new RecursiveDirectoryIterator($sDirectory); |
| 421 | 421 | $itFile = new RecursiveIteratorIterator($itDir); |
| 422 | 422 | // Iterate on dir content |
| 423 | - foreach($itFile as $xFile) |
|
| 423 | + foreach ($itFile as $xFile) |
|
| 424 | 424 | { |
| 425 | 425 | // skip everything except PHP files |
| 426 | - if(!$xFile->isFile() || $xFile->getExtension() != 'php') |
|
| 426 | + if (!$xFile->isFile() || $xFile->getExtension() != 'php') |
|
| 427 | 427 | { |
| 428 | 428 | continue; |
| 429 | 429 | } |
@@ -459,33 +459,33 @@ discard block |
||
| 459 | 459 | $sClassPath = substr($xFile->getPath(), strlen($sDirectory)); |
| 460 | 460 | $sClassPath = str_replace($sDS, '\\', trim($sClassPath, $sDS)); |
| 461 | 461 | $sClassName = $xFile->getBasename('.php'); |
| 462 | - if(($sNamespace)) |
|
| 462 | + if (($sNamespace)) |
|
| 463 | 463 | { |
| 464 | 464 | $sClassPath = ($sClassPath) ? $sNamespace . '\\' . $sClassPath : $sNamespace; |
| 465 | 465 | $sClassName = '\\' . $sClassPath . '\\' . $sClassName; |
| 466 | 466 | } |
| 467 | 467 | // Require the file only if autoload is enabled but there is no autoloader |
| 468 | - if(($this->bAutoloadEnabled) && !($this->xAutoloader)) |
|
| 468 | + if (($this->bAutoloadEnabled) && !($this->xAutoloader)) |
|
| 469 | 469 | { |
| 470 | 470 | require_once($xFile->getPathname()); |
| 471 | 471 | } |
| 472 | 472 | // Create and register an instance of the class |
| 473 | - if(!array_key_exists('*', $aOptions) || !is_array($aOptions['*'])) |
|
| 473 | + if (!array_key_exists('*', $aOptions) || !is_array($aOptions['*'])) |
|
| 474 | 474 | { |
| 475 | 475 | $aOptions['*'] = array(); |
| 476 | 476 | } |
| 477 | 477 | $aOptions['*']['separator'] = $sSeparator; |
| 478 | - if(($sNamespace)) |
|
| 478 | + if (($sNamespace)) |
|
| 479 | 479 | { |
| 480 | 480 | $aOptions['*']['namespace'] = $sNamespace; |
| 481 | 481 | } |
| 482 | - if(($sClassPath)) |
|
| 482 | + if (($sClassPath)) |
|
| 483 | 483 | { |
| 484 | 484 | $aOptions['*']['classpath'] = $sClassPath; |
| 485 | 485 | } |
| 486 | 486 | // Filter excluded methods |
| 487 | - $aProtected = array_filter($aProtected, function ($sName) {return is_string($sName);}); |
|
| 488 | - if(count($aProtected) > 0) |
|
| 487 | + $aProtected = array_filter($aProtected, function($sName) {return is_string($sName); }); |
|
| 488 | + if (count($aProtected) > 0) |
|
| 489 | 489 | { |
| 490 | 490 | $aOptions['*']['protected'] = $aProtected; |
| 491 | 491 | } |
@@ -504,13 +504,13 @@ discard block |
||
| 504 | 504 | $sDS = DIRECTORY_SEPARATOR; |
| 505 | 505 | // Change the keys in $aOptions to have "\" as separator |
| 506 | 506 | $aNewOptions = array(); |
| 507 | - foreach($aOptions as $key => $aOption) |
|
| 507 | + foreach ($aOptions as $key => $aOption) |
|
| 508 | 508 | { |
| 509 | 509 | $key = trim(str_replace(['.', '_'], ['\\', '\\'], $key), ' \\'); |
| 510 | 510 | $aNewOptions[$key] = $aOption; |
| 511 | 511 | } |
| 512 | 512 | |
| 513 | - foreach($this->aClassDirs as $aClassDir) |
|
| 513 | + foreach ($this->aClassDirs as $aClassDir) |
|
| 514 | 514 | { |
| 515 | 515 | // Get the directory |
| 516 | 516 | $sDirectory = $aClassDir['directory']; |
@@ -520,10 +520,10 @@ discard block |
||
| 520 | 520 | $itDir = new RecursiveDirectoryIterator($sDirectory); |
| 521 | 521 | $itFile = new RecursiveIteratorIterator($itDir); |
| 522 | 522 | // Iterate on dir content |
| 523 | - foreach($itFile as $xFile) |
|
| 523 | + foreach ($itFile as $xFile) |
|
| 524 | 524 | { |
| 525 | 525 | // skip everything except PHP files |
| 526 | - if(!$xFile->isFile() || $xFile->getExtension() != 'php') |
|
| 526 | + if (!$xFile->isFile() || $xFile->getExtension() != 'php') |
|
| 527 | 527 | { |
| 528 | 528 | continue; |
| 529 | 529 | } |
@@ -532,13 +532,13 @@ discard block |
||
| 532 | 532 | $sClassPath = substr($xFile->getPath(), strlen($sDirectory)); |
| 533 | 533 | $sClassPath = trim(str_replace($sDS, '\\', $sClassPath), '\\'); |
| 534 | 534 | $sClassName = $sClassPath . '\\' . $xFile->getBasename('.php'); |
| 535 | - if(($sNamespace)) |
|
| 535 | + if (($sNamespace)) |
|
| 536 | 536 | { |
| 537 | 537 | $sClassName = $sNamespace . '\\' . $sClassName; |
| 538 | 538 | } |
| 539 | 539 | // Get the class options |
| 540 | 540 | $aClassOptions = []; |
| 541 | - if(array_key_exists($sClassName, $aNewOptions)) |
|
| 541 | + if (array_key_exists($sClassName, $aNewOptions)) |
|
| 542 | 542 | { |
| 543 | 543 | $aClassOptions = $aNewOptions[$sClassName]; |
| 544 | 544 | } |
@@ -559,7 +559,7 @@ discard block |
||
| 559 | 559 | */ |
| 560 | 560 | public function registerClass($sClassName, array $aOptions = array()) |
| 561 | 561 | { |
| 562 | - if(!($sClassName = trim($sClassName, ' \\._'))) |
|
| 562 | + if (!($sClassName = trim($sClassName, ' \\._'))) |
|
| 563 | 563 | { |
| 564 | 564 | return false; |
| 565 | 565 | } |
@@ -568,7 +568,7 @@ discard block |
||
| 568 | 568 | // Replace "." and "_" with antislashes, and set the class path. |
| 569 | 569 | $sClassName = str_replace(['.', '_'], ['\\', '\\'], $sClassName); |
| 570 | 570 | $sClassPath = ''; |
| 571 | - if(($nLastSlashPosition = strrpos($sClassName, '\\')) !== false) |
|
| 571 | + if (($nLastSlashPosition = strrpos($sClassName, '\\')) !== false) |
|
| 572 | 572 | { |
| 573 | 573 | $sClassPath = substr($sClassName, 0, $nLastSlashPosition); |
| 574 | 574 | $sClassName = substr($sClassName, $nLastSlashPosition + 1); |
@@ -577,7 +577,7 @@ discard block |
||
| 577 | 577 | $sPartPath = str_replace('\\', $sDS, $sClassPath) . $sDS . $sClassName . '.php'; |
| 578 | 578 | |
| 579 | 579 | // Search for the class file in all directories. |
| 580 | - foreach($this->aClassDirs as $aClassDir) |
|
| 580 | + foreach ($this->aClassDirs as $aClassDir) |
|
| 581 | 581 | { |
| 582 | 582 | // Get the separator |
| 583 | 583 | $sSeparator = $aClassDir['separator']; |
@@ -586,15 +586,15 @@ discard block |
||
| 586 | 586 | $nLen = strlen($sNamespace); |
| 587 | 587 | $sFullPath = ''; |
| 588 | 588 | // Check if the class belongs to the namespace |
| 589 | - if(($sNamespace) && substr($sClassPath, 0, $nLen) == $sNamespace) |
|
| 589 | + if (($sNamespace) && substr($sClassPath, 0, $nLen) == $sNamespace) |
|
| 590 | 590 | { |
| 591 | 591 | $sFullPath = $aClassDir['directory'] . $sDS . substr($sPartPath, $nLen + 1); |
| 592 | 592 | } |
| 593 | - elseif(!($sNamespace)) |
|
| 593 | + elseif (!($sNamespace)) |
|
| 594 | 594 | { |
| 595 | 595 | $sFullPath = $aClassDir['directory'] . $sDS . $sPartPath; |
| 596 | 596 | } |
| 597 | - if(($sFullPath) && is_file($sFullPath)) |
|
| 597 | + if (($sFullPath) && is_file($sFullPath)) |
|
| 598 | 598 | { |
| 599 | 599 | // Found the file in this directory |
| 600 | 600 | $xFileInfo = new \SplFileInfo($sFullPath); |
@@ -618,7 +618,7 @@ discard block |
||
| 618 | 618 | { |
| 619 | 619 | $xObject = null; // The user registered object |
| 620 | 620 | $xPlugin = $this->getRequestPlugin('CallableObject'); // The CallableObject plugin |
| 621 | - if(($xPlugin)) |
|
| 621 | + if (($xPlugin)) |
|
| 622 | 622 | { |
| 623 | 623 | $xObject = $xPlugin->getRegisteredObject($sClassName); |
| 624 | 624 | } |
@@ -632,7 +632,7 @@ discard block |
||
| 632 | 632 | */ |
| 633 | 633 | private function getJsLibUri() |
| 634 | 634 | { |
| 635 | - if(!$this->hasOption('js.lib.uri')) |
|
| 635 | + if (!$this->hasOption('js.lib.uri')) |
|
| 636 | 636 | { |
| 637 | 637 | return 'https://cdn.jsdelivr.net/jaxon/1.2.0/'; |
| 638 | 638 | } |
@@ -652,7 +652,7 @@ discard block |
||
| 652 | 652 | $jsDelivrUri = 'https://cdn.jsdelivr.net'; |
| 653 | 653 | $nLen = strlen($jsDelivrUri); |
| 654 | 654 | // The jsDelivr CDN only hosts minified files |
| 655 | - if(($this->getOption('js.app.minify')) || substr($this->getJsLibUri(), 0, $nLen) == $jsDelivrUri) |
|
| 655 | + if (($this->getOption('js.app.minify')) || substr($this->getJsLibUri(), 0, $nLen) == $jsDelivrUri) |
|
| 656 | 656 | { |
| 657 | 657 | return '.min.js'; |
| 658 | 658 | } |
@@ -669,7 +669,7 @@ discard block |
||
| 669 | 669 | // Check config options |
| 670 | 670 | // - The js.app.extern option must be set to true |
| 671 | 671 | // - The js.app.uri and js.app.dir options must be set to non null values |
| 672 | - if(!$this->getOption('js.app.extern') || |
|
| 672 | + if (!$this->getOption('js.app.extern') || |
|
| 673 | 673 | !$this->getOption('js.app.uri') || |
| 674 | 674 | !$this->getOption('js.app.dir')) |
| 675 | 675 | { |
@@ -678,7 +678,7 @@ discard block |
||
| 678 | 678 | // Check dir access |
| 679 | 679 | // - The js.app.dir must be writable |
| 680 | 680 | $sJsAppDir = $this->getOption('js.app.dir'); |
| 681 | - if(!is_dir($sJsAppDir) || !is_writable($sJsAppDir)) |
|
| 681 | + if (!is_dir($sJsAppDir) || !is_writable($sJsAppDir)) |
|
| 682 | 682 | { |
| 683 | 683 | return false; |
| 684 | 684 | } |
@@ -692,7 +692,7 @@ discard block |
||
| 692 | 692 | */ |
| 693 | 693 | private function setTemplateCacheDir() |
| 694 | 694 | { |
| 695 | - if($this->hasOption('core.template.cache_dir')) |
|
| 695 | + if ($this->hasOption('core.template.cache_dir')) |
|
| 696 | 696 | { |
| 697 | 697 | $this->setCacheDir($this->getOption('core.template.cache_dir')); |
| 698 | 698 | } |
@@ -714,11 +714,11 @@ discard block |
||
| 714 | 714 | |
| 715 | 715 | // Add component files to the javascript file array; |
| 716 | 716 | $aJsFiles = array($sJsCoreUrl); |
| 717 | - if($this->getOption('core.debug.on')) |
|
| 717 | + if ($this->getOption('core.debug.on')) |
|
| 718 | 718 | { |
| 719 | 719 | $aJsFiles[] = $sJsDebugUrl; |
| 720 | 720 | $aJsFiles[] = $sJsLanguageUrl; |
| 721 | - if($this->getOption('core.debug.verbose')) |
|
| 721 | + if ($this->getOption('core.debug.verbose')) |
|
| 722 | 722 | { |
| 723 | 723 | $aJsFiles[] = $sJsVerboseUrl; |
| 724 | 724 | } |
@@ -730,7 +730,7 @@ discard block |
||
| 730 | 730 | 'sJsOptions' => $this->getOption('js.app.options'), |
| 731 | 731 | 'aUrls' => $aJsFiles, |
| 732 | 732 | )); |
| 733 | - foreach($this->aResponsePlugins as $xPlugin) |
|
| 733 | + foreach ($this->aResponsePlugins as $xPlugin) |
|
| 734 | 734 | { |
| 735 | 735 | $sCode .= rtrim($xPlugin->getJs(), " \n") . "\n"; |
| 736 | 736 | } |
@@ -748,7 +748,7 @@ discard block |
||
| 748 | 748 | $this->setTemplateCacheDir(); |
| 749 | 749 | |
| 750 | 750 | $sCode = ''; |
| 751 | - foreach($this->aResponsePlugins as $xPlugin) |
|
| 751 | + foreach ($this->aResponsePlugins as $xPlugin) |
|
| 752 | 752 | { |
| 753 | 753 | $sCode .= rtrim($xPlugin->getCss(), " \n") . "\n"; |
| 754 | 754 | } |
@@ -836,7 +836,7 @@ discard block |
||
| 836 | 836 | )); |
| 837 | 837 | |
| 838 | 838 | $sPluginScript = ''; |
| 839 | - foreach($this->aResponsePlugins as $xPlugin) |
|
| 839 | + foreach ($this->aResponsePlugins as $xPlugin) |
|
| 840 | 840 | { |
| 841 | 841 | $sPluginScript .= "\n" . trim($xPlugin->getScript(), " \n"); |
| 842 | 842 | } |
@@ -868,11 +868,11 @@ discard block |
||
| 868 | 868 | |
| 869 | 869 | // Get the config and plugins scripts |
| 870 | 870 | $sScript = $this->getConfigScript() . "\n" . $this->getReadyScript() . "\n"; |
| 871 | - foreach($this->aRequestPlugins as $xPlugin) |
|
| 871 | + foreach ($this->aRequestPlugins as $xPlugin) |
|
| 872 | 872 | { |
| 873 | 873 | $sScript .= "\n" . trim($xPlugin->getScript(), " \n"); |
| 874 | 874 | } |
| 875 | - if($this->canExportJavascript()) |
|
| 875 | + if ($this->canExportJavascript()) |
|
| 876 | 876 | { |
| 877 | 877 | $sJsAppURI = rtrim($this->getOption('js.app.uri'), '/') . '/'; |
| 878 | 878 | $sJsAppDir = rtrim($this->getOption('js.app.dir'), '/') . '/'; |
@@ -881,13 +881,13 @@ discard block |
||
| 881 | 881 | $sHash = $this->generateHash(); |
| 882 | 882 | $sOutFile = $sHash . '.js'; |
| 883 | 883 | $sMinFile = $sHash . '.min.js'; |
| 884 | - if(!is_file($sJsAppDir . $sOutFile)) |
|
| 884 | + if (!is_file($sJsAppDir . $sOutFile)) |
|
| 885 | 885 | { |
| 886 | 886 | file_put_contents($sJsAppDir . $sOutFile, $sScript); |
| 887 | 887 | } |
| 888 | - if(($this->getOption('js.app.minify'))) |
|
| 888 | + if (($this->getOption('js.app.minify'))) |
|
| 889 | 889 | { |
| 890 | - if(($this->minify($sJsAppDir . $sOutFile, $sJsAppDir . $sMinFile))) |
|
| 890 | + if (($this->minify($sJsAppDir . $sOutFile, $sJsAppDir . $sMinFile))) |
|
| 891 | 891 | { |
| 892 | 892 | $sOutFile = $sMinFile; |
| 893 | 893 | } |
@@ -920,7 +920,7 @@ discard block |
||
| 920 | 920 | */ |
| 921 | 921 | public function getResponsePlugin($sName) |
| 922 | 922 | { |
| 923 | - if(array_key_exists($sName, $this->aResponsePlugins)) |
|
| 923 | + if (array_key_exists($sName, $this->aResponsePlugins)) |
|
| 924 | 924 | { |
| 925 | 925 | return $this->aResponsePlugins[$sName]; |
| 926 | 926 | } |
@@ -936,7 +936,7 @@ discard block |
||
| 936 | 936 | */ |
| 937 | 937 | public function getRequestPlugin($sName) |
| 938 | 938 | { |
| 939 | - if(array_key_exists($sName, $this->aRequestPlugins)) |
|
| 939 | + if (array_key_exists($sName, $this->aRequestPlugins)) |
|
| 940 | 940 | { |
| 941 | 941 | return $this->aRequestPlugins[$sName]; |
| 942 | 942 | } |