@@ -16,7 +16,6 @@ |
||
| 16 | 16 | use Jaxon\Plugin\Request as RequestPlugin; |
| 17 | 17 | use Jaxon\Request\Support\UploadedFile; |
| 18 | 18 | use Jaxon\Response\UploadResponse; |
| 19 | - |
|
| 20 | 19 | use Exception; |
| 21 | 20 | use Closure; |
| 22 | 21 | |
@@ -68,11 +68,11 @@ discard block |
||
| 68 | 68 | { |
| 69 | 69 | $this->sUploadSubdir = uniqid() . DIRECTORY_SEPARATOR; |
| 70 | 70 | |
| 71 | - if(array_key_exists('jxnupl', $_POST)) |
|
| 71 | + if (array_key_exists('jxnupl', $_POST)) |
|
| 72 | 72 | { |
| 73 | 73 | $this->sTempFile = $_POST['jxnupl']; |
| 74 | 74 | } |
| 75 | - elseif(array_key_exists('jxnupl', $_GET)) |
|
| 75 | + elseif (array_key_exists('jxnupl', $_GET)) |
|
| 76 | 76 | { |
| 77 | 77 | $this->sTempFile = $_GET['jxnupl']; |
| 78 | 78 | } |
@@ -100,7 +100,7 @@ discard block |
||
| 100 | 100 | */ |
| 101 | 101 | protected function filterFilename($sFilename, $sVarName) |
| 102 | 102 | { |
| 103 | - if(($this->cFileFilter)) |
|
| 103 | + if (($this->cFileFilter)) |
|
| 104 | 104 | { |
| 105 | 105 | $cFileFilter = $this->cFileFilter; |
| 106 | 106 | $sFilename = (string)$cFileFilter($sFilename, $sVarName); |
@@ -122,12 +122,12 @@ discard block |
||
| 122 | 122 | $sUploadDir = $this->getOption('upload.files.' . $sFieldId . '.dir', $sDefaultUploadDir); |
| 123 | 123 | $sUploadDir = rtrim(trim($sUploadDir), '/\\') . DIRECTORY_SEPARATOR; |
| 124 | 124 | // Verify that the upload dir exists and is writable |
| 125 | - if(!is_writable($sUploadDir)) |
|
| 125 | + if (!is_writable($sUploadDir)) |
|
| 126 | 126 | { |
| 127 | 127 | throw new \Jaxon\Exception\Error($this->trans('errors.upload.access')); |
| 128 | 128 | } |
| 129 | 129 | $sUploadDir .= $this->sUploadSubdir; |
| 130 | - if(!file_exists($sUploadDir) && !@mkdir($sUploadDir)) |
|
| 130 | + if (!file_exists($sUploadDir) && !@mkdir($sUploadDir)) |
|
| 131 | 131 | { |
| 132 | 132 | throw new \Jaxon\Exception\Error($this->trans('errors.upload.access')); |
| 133 | 133 | } |
@@ -145,12 +145,12 @@ discard block |
||
| 145 | 145 | $sUploadDir = $this->getOption('upload.default.dir'); |
| 146 | 146 | $sUploadDir = rtrim(trim($sUploadDir), '/\\') . DIRECTORY_SEPARATOR; |
| 147 | 147 | // Verify that the upload dir exists and is writable |
| 148 | - if(!is_writable($sUploadDir)) |
|
| 148 | + if (!is_writable($sUploadDir)) |
|
| 149 | 149 | { |
| 150 | 150 | throw new \Jaxon\Exception\Error($this->trans('errors.upload.access')); |
| 151 | 151 | } |
| 152 | 152 | $sUploadDir .= 'tmp' . DIRECTORY_SEPARATOR; |
| 153 | - if(!file_exists($sUploadDir) && !@mkdir($sUploadDir)) |
|
| 153 | + if (!file_exists($sUploadDir) && !@mkdir($sUploadDir)) |
|
| 154 | 154 | { |
| 155 | 155 | throw new \Jaxon\Exception\Error($this->trans('errors.upload.access')); |
| 156 | 156 | } |
@@ -168,7 +168,7 @@ discard block |
||
| 168 | 168 | $sUploadDir = rtrim(trim($sUploadDir), '/\\') . DIRECTORY_SEPARATOR; |
| 169 | 169 | $sUploadDir .= 'tmp' . DIRECTORY_SEPARATOR; |
| 170 | 170 | $sUploadTempFile = $sUploadDir . $this->sTempFile . '.json'; |
| 171 | - if(!is_readable($sUploadTempFile)) |
|
| 171 | + if (!is_readable($sUploadTempFile)) |
|
| 172 | 172 | { |
| 173 | 173 | throw new \Jaxon\Exception\Error($this->trans('errors.upload.access')); |
| 174 | 174 | } |
@@ -184,18 +184,18 @@ discard block |
||
| 184 | 184 | { |
| 185 | 185 | // Check validity of the uploaded files |
| 186 | 186 | $aTempFiles = []; |
| 187 | - foreach($_FILES as $sVarName => $aFile) |
|
| 187 | + foreach ($_FILES as $sVarName => $aFile) |
|
| 188 | 188 | { |
| 189 | - if(is_array($aFile['name'])) |
|
| 189 | + if (is_array($aFile['name'])) |
|
| 190 | 190 | { |
| 191 | 191 | $nFileCount = count($aFile['name']); |
| 192 | - for($i = 0; $i < $nFileCount; $i++) |
|
| 192 | + for ($i = 0; $i < $nFileCount; $i++) |
|
| 193 | 193 | { |
| 194 | - if(!$aFile['name'][$i]) |
|
| 194 | + if (!$aFile['name'][$i]) |
|
| 195 | 195 | { |
| 196 | 196 | continue; |
| 197 | 197 | } |
| 198 | - if(!array_key_exists($sVarName, $aTempFiles)) |
|
| 198 | + if (!array_key_exists($sVarName, $aTempFiles)) |
|
| 199 | 199 | { |
| 200 | 200 | $aTempFiles[$sVarName] = []; |
| 201 | 201 | } |
@@ -215,11 +215,11 @@ discard block |
||
| 215 | 215 | } |
| 216 | 216 | else |
| 217 | 217 | { |
| 218 | - if(!$aFile['name']) |
|
| 218 | + if (!$aFile['name']) |
|
| 219 | 219 | { |
| 220 | 220 | continue; |
| 221 | 221 | } |
| 222 | - if(!array_key_exists($sVarName, $aTempFiles)) |
|
| 222 | + if (!array_key_exists($sVarName, $aTempFiles)) |
|
| 223 | 223 | { |
| 224 | 224 | $aTempFiles[$sVarName] = []; |
| 225 | 225 | } |
@@ -239,17 +239,17 @@ discard block |
||
| 239 | 239 | } |
| 240 | 240 | |
| 241 | 241 | // Check uploaded files validity |
| 242 | - foreach($aTempFiles as $sVarName => $aFiles) |
|
| 242 | + foreach ($aTempFiles as $sVarName => $aFiles) |
|
| 243 | 243 | { |
| 244 | - foreach($aFiles as $aFile) |
|
| 244 | + foreach ($aFiles as $aFile) |
|
| 245 | 245 | { |
| 246 | 246 | // Verify upload result |
| 247 | - if($aFile['error'] != 0) |
|
| 247 | + if ($aFile['error'] != 0) |
|
| 248 | 248 | { |
| 249 | 249 | throw new \Jaxon\Exception\Error($this->trans('errors.upload.failed', $aFile)); |
| 250 | 250 | } |
| 251 | 251 | // Verify file validity (format, size) |
| 252 | - if(!$this->validateUploadedFile($sVarName, $aFile)) |
|
| 252 | + if (!$this->validateUploadedFile($sVarName, $aFile)) |
|
| 253 | 253 | { |
| 254 | 254 | throw new \Jaxon\Exception\Error($this->getValidatorMessage()); |
| 255 | 255 | } |
@@ -259,10 +259,10 @@ discard block |
||
| 259 | 259 | } |
| 260 | 260 | |
| 261 | 261 | // Copy the uploaded files from the temp dir to the user dir |
| 262 | - foreach($aTempFiles as $sVarName => $_aTempFiles) |
|
| 262 | + foreach ($aTempFiles as $sVarName => $_aTempFiles) |
|
| 263 | 263 | { |
| 264 | 264 | $this->aUserFiles[$sVarName] = []; |
| 265 | - foreach($_aTempFiles as $aFile) |
|
| 265 | + foreach ($_aTempFiles as $aFile) |
|
| 266 | 266 | { |
| 267 | 267 | // Get the path to the upload dir |
| 268 | 268 | $sUploadDir = $this->getUploadDir($sVarName); |
@@ -284,10 +284,10 @@ discard block |
||
| 284 | 284 | { |
| 285 | 285 | // Convert uploaded file to an array |
| 286 | 286 | $aFiles = []; |
| 287 | - foreach($this->aUserFiles as $sVarName => $aUserFiles) |
|
| 287 | + foreach ($this->aUserFiles as $sVarName => $aUserFiles) |
|
| 288 | 288 | { |
| 289 | 289 | $aFiles[$sVarName] = []; |
| 290 | - foreach($aUserFiles as $aUserFile) |
|
| 290 | + foreach ($aUserFiles as $aUserFile) |
|
| 291 | 291 | { |
| 292 | 292 | $aFiles[$sVarName][] = $aUserFile->toTempData(); |
| 293 | 293 | } |
@@ -308,10 +308,10 @@ discard block |
||
| 308 | 308 | // Upload temp file |
| 309 | 309 | $sUploadTempFile = $this->getUploadTempFile(); |
| 310 | 310 | $aFiles = json_decode(file_get_contents($sUploadTempFile), true); |
| 311 | - foreach($aFiles as $sVarName => $aUserFiles) |
|
| 311 | + foreach ($aFiles as $sVarName => $aUserFiles) |
|
| 312 | 312 | { |
| 313 | 313 | $this->aUserFiles[$sVarName] = []; |
| 314 | - foreach($aUserFiles as $aUserFile) |
|
| 314 | + foreach ($aUserFiles as $aUserFile) |
|
| 315 | 315 | { |
| 316 | 316 | $this->aUserFiles[$sVarName][] = UploadedFile::fromTempData($aUserFile); |
| 317 | 317 | } |
@@ -378,7 +378,7 @@ discard block |
||
| 378 | 378 | */ |
| 379 | 379 | public function noRequestPluginFound() |
| 380 | 380 | { |
| 381 | - if(count($_FILES) > 0) |
|
| 381 | + if (count($_FILES) > 0) |
|
| 382 | 382 | { |
| 383 | 383 | $this->bRequestIsHttpUpload = true; |
| 384 | 384 | } |
@@ -401,17 +401,17 @@ discard block |
||
| 401 | 401 | */ |
| 402 | 402 | public function processRequest() |
| 403 | 403 | { |
| 404 | - if(!$this->canProcessRequest()) |
|
| 404 | + if (!$this->canProcessRequest()) |
|
| 405 | 405 | { |
| 406 | 406 | return false; |
| 407 | 407 | } |
| 408 | 408 | |
| 409 | - if(count($_FILES) > 0) |
|
| 409 | + if (count($_FILES) > 0) |
|
| 410 | 410 | { |
| 411 | 411 | // Ajax request with upload |
| 412 | 412 | $this->readFromHttpData(); |
| 413 | 413 | |
| 414 | - if($this->bRequestIsHttpUpload) |
|
| 414 | + if ($this->bRequestIsHttpUpload) |
|
| 415 | 415 | { |
| 416 | 416 | // Process an HTTP upload request |
| 417 | 417 | // This requires to set the response to be returned. |
@@ -421,14 +421,14 @@ discard block |
||
| 421 | 421 | $this->saveToTempFile(); |
| 422 | 422 | $xResponse->setUploadedFile($this->sTempFile); |
| 423 | 423 | } |
| 424 | - catch(Exception $e) |
|
| 424 | + catch (Exception $e) |
|
| 425 | 425 | { |
| 426 | 426 | $xResponse->setErrorMessage($e->getMessage()); |
| 427 | 427 | } |
| 428 | 428 | jaxon()->di()->getResponseManager()->append($xResponse); |
| 429 | 429 | } |
| 430 | 430 | } |
| 431 | - elseif(($this->sTempFile)) |
|
| 431 | + elseif (($this->sTempFile)) |
|
| 432 | 432 | { |
| 433 | 433 | // Ajax request following and HTTP upload |
| 434 | 434 | $this->readFromTempFile(); |
@@ -71,8 +71,7 @@ discard block |
||
| 71 | 71 | if(array_key_exists('jxnupl', $_POST)) |
| 72 | 72 | { |
| 73 | 73 | $this->sTempFile = $_POST['jxnupl']; |
| 74 | - } |
|
| 75 | - elseif(array_key_exists('jxnupl', $_GET)) |
|
| 74 | + } elseif(array_key_exists('jxnupl', $_GET)) |
|
| 76 | 75 | { |
| 77 | 76 | $this->sTempFile = $_GET['jxnupl']; |
| 78 | 77 | } |
@@ -212,8 +211,7 @@ discard block |
||
| 212 | 211 | 'extension' => pathinfo($aFile['name'][$i], PATHINFO_EXTENSION), |
| 213 | 212 | ]; |
| 214 | 213 | } |
| 215 | - } |
|
| 216 | - else |
|
| 214 | + } else |
|
| 217 | 215 | { |
| 218 | 216 | if(!$aFile['name']) |
| 219 | 217 | { |
@@ -420,15 +418,13 @@ discard block |
||
| 420 | 418 | { |
| 421 | 419 | $this->saveToTempFile(); |
| 422 | 420 | $xResponse->setUploadedFile($this->sTempFile); |
| 423 | - } |
|
| 424 | - catch(Exception $e) |
|
| 421 | + } catch(Exception $e) |
|
| 425 | 422 | { |
| 426 | 423 | $xResponse->setErrorMessage($e->getMessage()); |
| 427 | 424 | } |
| 428 | 425 | jaxon()->di()->getResponseManager()->append($xResponse); |
| 429 | 426 | } |
| 430 | - } |
|
| 431 | - elseif(($this->sTempFile)) |
|
| 427 | + } elseif(($this->sTempFile)) |
|
| 432 | 428 | { |
| 433 | 429 | // Ajax request following and HTTP upload |
| 434 | 430 | $this->readFromTempFile(); |
@@ -41,6 +41,7 @@ discard block |
||
| 41 | 41 | |
| 42 | 42 | /** |
| 43 | 43 | * Set the path to the uploaded file |
| 44 | + * @param string $sUploadedFile |
|
| 44 | 45 | */ |
| 45 | 46 | public function setUploadedFile($sUploadedFile) |
| 46 | 47 | { |
@@ -49,6 +50,7 @@ discard block |
||
| 49 | 50 | |
| 50 | 51 | /** |
| 51 | 52 | * Set the error message |
| 53 | + * @param string $sErrorMessage |
|
| 52 | 54 | */ |
| 53 | 55 | public function setErrorMessage($sErrorMessage) |
| 54 | 56 | { |
@@ -86,7 +86,7 @@ discard block |
||
| 86 | 86 | { |
| 87 | 87 | $sCharacterSet = ''; |
| 88 | 88 | $sCharacterEncoding = trim($this->getOption('core.encoding')); |
| 89 | - if(($sCharacterEncoding) && strlen($sCharacterEncoding) > 0) |
|
| 89 | + if (($sCharacterEncoding) && strlen($sCharacterEncoding) > 0) |
|
| 90 | 90 | { |
| 91 | 91 | $sCharacterSet = '; charset="' . trim($sCharacterEncoding) . '"'; |
| 92 | 92 | } |
@@ -102,8 +102,7 @@ discard block |
||
| 102 | 102 | public function getOutput() |
| 103 | 103 | { |
| 104 | 104 | $aResponse = ($this->sUploadedFile) ? |
| 105 | - ['code' => 'success', 'upl' => $this->sUploadedFile] : |
|
| 106 | - ['code' => 'error', 'msg' => $this->sErrorMessage]; |
|
| 105 | + ['code' => 'success', 'upl' => $this->sUploadedFile] : ['code' => 'error', 'msg' => $this->sErrorMessage]; |
|
| 107 | 106 | return '<script>var res = ' . json_encode($aResponse) . '; </script>'; |
| 108 | 107 | } |
| 109 | 108 | |
@@ -3,9 +3,6 @@ |
||
| 3 | 3 | namespace Jaxon\Utils\View; |
| 4 | 4 | |
| 5 | 5 | use Jaxon\Utils\Config\Config; |
| 6 | - |
|
| 7 | -use stdClass; |
|
| 8 | -use Exception; |
|
| 9 | 6 | use Closure; |
| 10 | 7 | |
| 11 | 8 | class Manager |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | 'directory' => $sDirectory, |
| 79 | 79 | 'extension' => $sExtension, |
| 80 | 80 | ]; |
| 81 | - if(key_exists($sRenderer, $this->aNamespaces)) |
|
| 81 | + if (key_exists($sRenderer, $this->aNamespaces)) |
|
| 82 | 82 | { |
| 83 | 83 | $this->aNamespaces[$sRenderer][] = $aNamespace; |
| 84 | 84 | } |
@@ -99,12 +99,12 @@ discard block |
||
| 99 | 99 | public function addNamespaces($xAppConfig) |
| 100 | 100 | { |
| 101 | 101 | $this->sDefaultNamespace = $xAppConfig->getOption('options.views.default', false); |
| 102 | - if(is_array($namespaces = $xAppConfig->getOptionNames('views'))) |
|
| 102 | + if (is_array($namespaces = $xAppConfig->getOptionNames('views'))) |
|
| 103 | 103 | { |
| 104 | - foreach($namespaces as $namespace => $option) |
|
| 104 | + foreach ($namespaces as $namespace => $option) |
|
| 105 | 105 | { |
| 106 | 106 | // If no default namespace is defined, use the first one as default. |
| 107 | - if($this->sDefaultNamespace == false) |
|
| 107 | + if ($this->sDefaultNamespace == false) |
|
| 108 | 108 | { |
| 109 | 109 | $this->sDefaultNamespace = $namespace; |
| 110 | 110 | } |
@@ -126,7 +126,7 @@ discard block |
||
| 126 | 126 | */ |
| 127 | 127 | public function getRenderer($sId = '') |
| 128 | 128 | { |
| 129 | - if(!$sId) |
|
| 129 | + if (!$sId) |
|
| 130 | 130 | { |
| 131 | 131 | // Return the view renderer facade |
| 132 | 132 | return jaxon()->di()->get(\Jaxon\Utils\View\Renderer::class); |
@@ -149,14 +149,14 @@ discard block |
||
| 149 | 149 | jaxon()->di()->set('jaxon.app.view.base.' . $sId, $xClosure); |
| 150 | 150 | |
| 151 | 151 | // Return the initialized view renderer |
| 152 | - jaxon()->di()->set('jaxon.app.view.' . $sId, function ($c) use ($sId) { |
|
| 152 | + jaxon()->di()->set('jaxon.app.view.' . $sId, function($c) use ($sId) { |
|
| 153 | 153 | // Get the defined renderer |
| 154 | 154 | $renderer = $c['jaxon.app.view.base.' . $sId]; |
| 155 | 155 | |
| 156 | 156 | // Init the renderer with the template namespaces |
| 157 | - if(key_exists($sId, $this->aNamespaces)) |
|
| 157 | + if (key_exists($sId, $this->aNamespaces)) |
|
| 158 | 158 | { |
| 159 | - foreach($this->aNamespaces[$sId] as $ns) |
|
| 159 | + foreach ($this->aNamespaces[$sId] as $ns) |
|
| 160 | 160 | { |
| 161 | 161 | $renderer->addNamespace($ns['namespace'], $ns['directory'], $ns['extension']); |
| 162 | 162 | } |
@@ -81,8 +81,7 @@ |
||
| 81 | 81 | if(key_exists($sRenderer, $this->aNamespaces)) |
| 82 | 82 | { |
| 83 | 83 | $this->aNamespaces[$sRenderer][] = $aNamespace; |
| 84 | - } |
|
| 85 | - else |
|
| 84 | + } else |
|
| 86 | 85 | { |
| 87 | 86 | $this->aNamespaces[$sRenderer] = [$aNamespace]; |
| 88 | 87 | } |
@@ -97,7 +97,7 @@ |
||
| 97 | 97 | */ |
| 98 | 98 | public function delete($sKey) |
| 99 | 99 | { |
| 100 | - if(key_exists($sKey, $_SESSION)) |
|
| 100 | + if (key_exists($sKey, $_SESSION)) |
|
| 101 | 101 | { |
| 102 | 102 | unset($_SESSION[$sKey]); |
| 103 | 103 | } |
@@ -46,7 +46,7 @@ discard block |
||
| 46 | 46 | */ |
| 47 | 47 | protected function getPrevLink($xPaginator) |
| 48 | 48 | { |
| 49 | - if(!($sCall = $xPaginator->getPrevCall())) |
|
| 49 | + if (!($sCall = $xPaginator->getPrevCall())) |
|
| 50 | 50 | { |
| 51 | 51 | return $this->xRenderer->render('pagination::links/disabled', ['text' => $xPaginator->getPreviousText()]); |
| 52 | 52 | } |
@@ -63,7 +63,7 @@ discard block |
||
| 63 | 63 | */ |
| 64 | 64 | protected function getNextLink($xPaginator) |
| 65 | 65 | { |
| 66 | - if(!($sCall = $xPaginator->getNextCall())) |
|
| 66 | + if (!($sCall = $xPaginator->getNextCall())) |
|
| 67 | 67 | { |
| 68 | 68 | return $this->xRenderer->render('pagination::links/disabled', ['text' => $xPaginator->getNextText()]); |
| 69 | 69 | } |
@@ -81,9 +81,9 @@ discard block |
||
| 81 | 81 | protected function getLinks($xPaginator) |
| 82 | 82 | { |
| 83 | 83 | $sLinks = ''; |
| 84 | - foreach($xPaginator->getPages() as $page) |
|
| 84 | + foreach ($xPaginator->getPages() as $page) |
|
| 85 | 85 | { |
| 86 | - if($page['call']) |
|
| 86 | + if ($page['call']) |
|
| 87 | 87 | { |
| 88 | 88 | $sTemplate = ($page['isCurrent'] ? 'pagination::links/current' : 'pagination::links/enabled'); |
| 89 | 89 | $sLinks .= $this->xRenderer->render($sTemplate, ['call' => $page['call'], 'text' => $page['num']]); |
@@ -87,8 +87,7 @@ |
||
| 87 | 87 | { |
| 88 | 88 | $sTemplate = ($page['isCurrent'] ? 'pagination::links/current' : 'pagination::links/enabled'); |
| 89 | 89 | $sLinks .= $this->xRenderer->render($sTemplate, ['call' => $page['call'], 'text' => $page['num']]); |
| 90 | - } |
|
| 91 | - else |
|
| 90 | + } else |
|
| 92 | 91 | { |
| 93 | 92 | $sLinks .= $this->xRenderer->render('pagination::links/disabled', ['text' => $page['num']]); |
| 94 | 93 | } |
@@ -124,19 +124,19 @@ discard block |
||
| 124 | 124 | * Core library objects |
| 125 | 125 | */ |
| 126 | 126 | // Global Response |
| 127 | - $this->libContainer[Response::class] = function () { |
|
| 127 | + $this->libContainer[Response::class] = function() { |
|
| 128 | 128 | return new Response(); |
| 129 | 129 | }; |
| 130 | 130 | // Dialog |
| 131 | - $this->libContainer[Dialog::class] = function () { |
|
| 131 | + $this->libContainer[Dialog::class] = function() { |
|
| 132 | 132 | return new Dialog(); |
| 133 | 133 | }; |
| 134 | 134 | // Jaxon App |
| 135 | - $this->libContainer[App::class] = function () { |
|
| 135 | + $this->libContainer[App::class] = function() { |
|
| 136 | 136 | return new App(); |
| 137 | 137 | }; |
| 138 | 138 | // Jaxon App bootstrap |
| 139 | - $this->libContainer[Bootstrap::class] = function () { |
|
| 139 | + $this->libContainer[Bootstrap::class] = function() { |
|
| 140 | 140 | return new Bootstrap(); |
| 141 | 141 | }; |
| 142 | 142 | |
@@ -144,27 +144,27 @@ discard block |
||
| 144 | 144 | * Plugins |
| 145 | 145 | */ |
| 146 | 146 | // Callable objects repository |
| 147 | - $this->libContainer[CallableRepository::class] = function () { |
|
| 147 | + $this->libContainer[CallableRepository::class] = function() { |
|
| 148 | 148 | return new CallableRepository(); |
| 149 | 149 | }; |
| 150 | 150 | // Callable class plugin |
| 151 | - $this->libContainer[CallableClass::class] = function ($c) { |
|
| 151 | + $this->libContainer[CallableClass::class] = function($c) { |
|
| 152 | 152 | return new CallableClass($c[CallableRepository::class]); |
| 153 | 153 | }; |
| 154 | 154 | // Callable dir plugin |
| 155 | - $this->libContainer[CallableDir::class] = function ($c) { |
|
| 155 | + $this->libContainer[CallableDir::class] = function($c) { |
|
| 156 | 156 | return new CallableDir($c[CallableRepository::class]); |
| 157 | 157 | }; |
| 158 | 158 | // Callable function plugin |
| 159 | - $this->libContainer[CallableFunction::class] = function () { |
|
| 159 | + $this->libContainer[CallableFunction::class] = function() { |
|
| 160 | 160 | return new CallableFunction(); |
| 161 | 161 | }; |
| 162 | 162 | // File upload plugin |
| 163 | - $this->libContainer[FileUpload::class] = function () { |
|
| 163 | + $this->libContainer[FileUpload::class] = function() { |
|
| 164 | 164 | return new FileUpload(); |
| 165 | 165 | }; |
| 166 | 166 | // JQuery response plugin |
| 167 | - $this->libContainer[JQueryPlugin::class] = function () { |
|
| 167 | + $this->libContainer[JQueryPlugin::class] = function() { |
|
| 168 | 168 | return new JQueryPlugin(); |
| 169 | 169 | }; |
| 170 | 170 | |
@@ -172,45 +172,45 @@ discard block |
||
| 172 | 172 | * Managers |
| 173 | 173 | */ |
| 174 | 174 | // Plugin Manager |
| 175 | - $this->libContainer[PluginManager::class] = function () { |
|
| 175 | + $this->libContainer[PluginManager::class] = function() { |
|
| 176 | 176 | return new PluginManager(); |
| 177 | 177 | }; |
| 178 | 178 | // Request Handler |
| 179 | - $this->libContainer[RequestHandler::class] = function ($c) { |
|
| 179 | + $this->libContainer[RequestHandler::class] = function($c) { |
|
| 180 | 180 | return new RequestHandler($c[PluginManager::class], $c[ResponseManager::class], $c[FileUpload::class]); |
| 181 | 181 | }; |
| 182 | 182 | // Request Factory |
| 183 | - $this->libContainer[RequestFactory::class] = function ($c) { |
|
| 183 | + $this->libContainer[RequestFactory::class] = function($c) { |
|
| 184 | 184 | return new RequestFactory($c[CallableRepository::class]); |
| 185 | 185 | }; |
| 186 | 186 | // Parameter Factory |
| 187 | - $this->libContainer[ParameterFactory::class] = function () { |
|
| 187 | + $this->libContainer[ParameterFactory::class] = function() { |
|
| 188 | 188 | return new ParameterFactory(); |
| 189 | 189 | }; |
| 190 | 190 | // Response Manager |
| 191 | - $this->libContainer[ResponseManager::class] = function () { |
|
| 191 | + $this->libContainer[ResponseManager::class] = function() { |
|
| 192 | 192 | return new ResponseManager(); |
| 193 | 193 | }; |
| 194 | 194 | // Code Generator |
| 195 | - $this->libContainer[CodeGenerator::class] = function ($c) { |
|
| 195 | + $this->libContainer[CodeGenerator::class] = function($c) { |
|
| 196 | 196 | return new CodeGenerator($c[PluginManager::class], $c[TemplateEngine::class]); |
| 197 | 197 | }; |
| 198 | 198 | // View Manager |
| 199 | - $this->libContainer[ViewManager::class] = function () { |
|
| 199 | + $this->libContainer[ViewManager::class] = function() { |
|
| 200 | 200 | return new ViewManager(); |
| 201 | 201 | }; |
| 202 | 202 | // View Renderer |
| 203 | - $this->libContainer[ViewRenderer::class] = function ($c) { |
|
| 203 | + $this->libContainer[ViewRenderer::class] = function($c) { |
|
| 204 | 204 | return new ViewRenderer($c[ViewManager::class]); |
| 205 | 205 | }; |
| 206 | 206 | |
| 207 | 207 | /* |
| 208 | 208 | * Config |
| 209 | 209 | */ |
| 210 | - $this->libContainer[Config::class] = function () { |
|
| 210 | + $this->libContainer[Config::class] = function() { |
|
| 211 | 211 | return new Config(); |
| 212 | 212 | }; |
| 213 | - $this->libContainer[ConfigReader::class] = function () { |
|
| 213 | + $this->libContainer[ConfigReader::class] = function() { |
|
| 214 | 214 | return new ConfigReader(); |
| 215 | 215 | }; |
| 216 | 216 | |
@@ -218,35 +218,35 @@ discard block |
||
| 218 | 218 | * Services |
| 219 | 219 | */ |
| 220 | 220 | // Minifier |
| 221 | - $this->libContainer[Minifier::class] = function () { |
|
| 221 | + $this->libContainer[Minifier::class] = function() { |
|
| 222 | 222 | return new Minifier(); |
| 223 | 223 | }; |
| 224 | 224 | // Translator |
| 225 | - $this->libContainer[Translator::class] = function ($c) { |
|
| 225 | + $this->libContainer[Translator::class] = function($c) { |
|
| 226 | 226 | return new Translator($c['jaxon.core.translation_dir'], $c[Config::class]); |
| 227 | 227 | }; |
| 228 | 228 | // Template engine |
| 229 | - $this->libContainer[TemplateEngine::class] = function ($c) { |
|
| 229 | + $this->libContainer[TemplateEngine::class] = function($c) { |
|
| 230 | 230 | return new TemplateEngine($c['jaxon.core.template_dir']); |
| 231 | 231 | }; |
| 232 | 232 | // Template Renderer |
| 233 | - $this->libContainer[TemplateRenderer::class] = function ($c) { |
|
| 233 | + $this->libContainer[TemplateRenderer::class] = function($c) { |
|
| 234 | 234 | return $c[TemplateEngine::class]; |
| 235 | 235 | }; |
| 236 | 236 | // Validator |
| 237 | - $this->libContainer[Validator::class] = function ($c) { |
|
| 237 | + $this->libContainer[Validator::class] = function($c) { |
|
| 238 | 238 | return new Validator($c[Translator::class], $c[Config::class]); |
| 239 | 239 | }; |
| 240 | 240 | // Pagination Paginator |
| 241 | - $this->libContainer[Paginator::class] = function ($c) { |
|
| 241 | + $this->libContainer[Paginator::class] = function($c) { |
|
| 242 | 242 | return new Paginator($c[PaginationRenderer::class]); |
| 243 | 243 | }; |
| 244 | 244 | // Pagination Renderer |
| 245 | - $this->libContainer[PaginationRenderer::class] = function ($c) { |
|
| 245 | + $this->libContainer[PaginationRenderer::class] = function($c) { |
|
| 246 | 246 | return new PaginationRenderer($c[TemplateRenderer::class]); |
| 247 | 247 | }; |
| 248 | 248 | // Event Dispatcher |
| 249 | - $this->libContainer[EventDispatcher::class] = function () { |
|
| 249 | + $this->libContainer[EventDispatcher::class] = function() { |
|
| 250 | 250 | return new EventDispatcher(); |
| 251 | 251 | }; |
| 252 | 252 | } |
@@ -258,7 +258,7 @@ discard block |
||
| 258 | 258 | */ |
| 259 | 259 | public function get($sClass) |
| 260 | 260 | { |
| 261 | - if($this->appContainer != null && $this->appContainer->has($sClass)) |
|
| 261 | + if ($this->appContainer != null && $this->appContainer->has($sClass)) |
|
| 262 | 262 | { |
| 263 | 263 | return $this->appContainer->get($sClass); |
| 264 | 264 | } |
@@ -288,7 +288,7 @@ discard block |
||
| 288 | 288 | */ |
| 289 | 289 | public function alias($sClass, $sAlias) |
| 290 | 290 | { |
| 291 | - $this->libContainer[$sClass] = function ($c) use ($sAlias) { |
|
| 291 | + $this->libContainer[$sClass] = function($c) use ($sAlias) { |
|
| 292 | 292 | return $c[$sAlias]; |
| 293 | 293 | }; |
| 294 | 294 | } |
@@ -558,7 +558,7 @@ discard block |
||
| 558 | 558 | */ |
| 559 | 559 | public function setCallableClassRequestFactory($sClassName, CallableObject $xCallableObject) |
| 560 | 560 | { |
| 561 | - $this->libContainer[$sClassName . '_RequestFactory'] = function () use ($xCallableObject) { |
|
| 561 | + $this->libContainer[$sClassName . '_RequestFactory'] = function() use ($xCallableObject) { |
|
| 562 | 562 | // $xCallableObject = $c[CallableRepository::class]->getCallableObject($sClassName); |
| 563 | 563 | return new CallableClassRequestFactory($xCallableObject); |
| 564 | 564 | }; |
@@ -586,7 +586,7 @@ discard block |
||
| 586 | 586 | */ |
| 587 | 587 | public function setCallableClassPaginatorFactory($sClassName, CallableObject $xCallableObject) |
| 588 | 588 | { |
| 589 | - $this->libContainer[$sClassName . '_PaginatorFactory'] = function () use ($xCallableObject) { |
|
| 589 | + $this->libContainer[$sClassName . '_PaginatorFactory'] = function() use ($xCallableObject) { |
|
| 590 | 590 | // $xCallableObject = $c[CallableRepository::class]->getCallableObject($sClassName); |
| 591 | 591 | return new CallableClassPaginatorFactory($xCallableObject); |
| 592 | 592 | }; |
@@ -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\Utils\Config\Exception\File(jaxon_trans('config.errors.file.access', ['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\Utils\Config\Exception\File(jaxon_trans('config.errors.file.content', ['path' => $sConfigFile])); |
| 38 | 38 | } |
@@ -33,7 +33,7 @@ discard block |
||
| 33 | 33 | */ |
| 34 | 34 | public function __construct(array $aOptions = [], $sKeys = '') |
| 35 | 35 | { |
| 36 | - if(count($aOptions) > 0) |
|
| 36 | + if (count($aOptions) > 0) |
|
| 37 | 37 | { |
| 38 | 38 | $this->setOptions($aOptions, $sKeys); |
| 39 | 39 | } |
@@ -66,14 +66,14 @@ discard block |
||
| 66 | 66 | $sPrefix = trim((string)$sPrefix); |
| 67 | 67 | $nDepth = intval($nDepth); |
| 68 | 68 | // Check the max depth |
| 69 | - if($nDepth < 0 || $nDepth > 9) |
|
| 69 | + if ($nDepth < 0 || $nDepth > 9) |
|
| 70 | 70 | { |
| 71 | 71 | throw new \Jaxon\Utils\Config\Exception\Data(jaxon_trans('config.errors.data.depth', |
| 72 | 72 | ['key' => $sPrefix, 'depth' => $nDepth])); |
| 73 | 73 | } |
| 74 | - foreach($aOptions as $sName => $xOption) |
|
| 74 | + foreach ($aOptions as $sName => $xOption) |
|
| 75 | 75 | { |
| 76 | - if(is_int($sName)) |
|
| 76 | + if (is_int($sName)) |
|
| 77 | 77 | { |
| 78 | 78 | continue; |
| 79 | 79 | } |
@@ -83,7 +83,7 @@ discard block |
||
| 83 | 83 | // Save the value of this option |
| 84 | 84 | $this->aOptions[$sFullName] = $xOption; |
| 85 | 85 | // Save the values of its sub-options |
| 86 | - if(is_array($xOption)) |
|
| 86 | + if (is_array($xOption)) |
|
| 87 | 87 | { |
| 88 | 88 | // Recursively read the options in the array |
| 89 | 89 | $this->_setOptions($xOption, $sFullName, $nDepth + 1); |
@@ -105,9 +105,9 @@ discard block |
||
| 105 | 105 | $aKeys = explode('.', (string)$sKeys); |
| 106 | 106 | foreach ($aKeys as $sKey) |
| 107 | 107 | { |
| 108 | - if(($sKey)) |
|
| 108 | + if (($sKey)) |
|
| 109 | 109 | { |
| 110 | - if(!array_key_exists($sKey, $aOptions) || !is_array($aOptions[$sKey])) |
|
| 110 | + if (!array_key_exists($sKey, $aOptions) || !is_array($aOptions[$sKey])) |
|
| 111 | 111 | { |
| 112 | 112 | return; |
| 113 | 113 | } |
@@ -157,13 +157,12 @@ discard block |
||
| 157 | 157 | $sPrefix = rtrim($sPrefix, '.') . '.'; |
| 158 | 158 | $sPrefixLen = strlen($sPrefix); |
| 159 | 159 | $aOptions = []; |
| 160 | - foreach($this->aOptions as $sName => $xValue) |
|
| 160 | + foreach ($this->aOptions as $sName => $xValue) |
|
| 161 | 161 | { |
| 162 | - if(substr($sName, 0, $sPrefixLen) == $sPrefix) |
|
| 162 | + if (substr($sName, 0, $sPrefixLen) == $sPrefix) |
|
| 163 | 163 | { |
| 164 | 164 | $iNextDotPos = strpos($sName, '.', $sPrefixLen); |
| 165 | - $sOptionName = $iNextDotPos === false ? substr($sName, $sPrefixLen) : |
|
| 166 | - substr($sName, $sPrefixLen, $iNextDotPos - $sPrefixLen); |
|
| 165 | + $sOptionName = $iNextDotPos === false ? substr($sName, $sPrefixLen) : substr($sName, $sPrefixLen, $iNextDotPos - $sPrefixLen); |
|
| 167 | 166 | $aOptions[$sOptionName] = $sPrefix . $sOptionName; |
| 168 | 167 | } |
| 169 | 168 | } |
@@ -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\Utils\Config\Exception\File(jaxon_trans('config.errors.file.access', ['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\Utils\Config\Exception\File(jaxon_trans('config.errors.file.content', ['path' => $sConfigFile])); |
| 37 | 37 | } |