@@ -49,12 +49,12 @@ discard block |
||
| 49 | 49 | $this->aUserFiles = []; |
| 50 | 50 | $this->aFiles = []; |
| 51 | 51 | |
| 52 | - foreach($_FILES as $sVarName => $aFile) |
|
| 52 | + foreach ($_FILES as $sVarName => $aFile) |
|
| 53 | 53 | { |
| 54 | 54 | $this->aFiles[$sVarName] = []; |
| 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[$sVarName][] = [ |
@@ -158,25 +158,25 @@ discard block |
||
| 158 | 158 | // Default upload dir |
| 159 | 159 | $sDefaultUploadDir = $this->getOption('upload.default.dir'); |
| 160 | 160 | // Check validity of the uploaded files |
| 161 | - foreach($this->aFiles as $sVarName => $aFiles) |
|
| 161 | + foreach ($this->aFiles as $sVarName => $aFiles) |
|
| 162 | 162 | { |
| 163 | 163 | $this->aUserFiles[$sVarName] = []; |
| 164 | - foreach($aFiles as $aFile) |
|
| 164 | + foreach ($aFiles as $aFile) |
|
| 165 | 165 | { |
| 166 | 166 | // Verify upload result |
| 167 | - if($aFile['error'] != 0) |
|
| 167 | + if ($aFile['error'] != 0) |
|
| 168 | 168 | { |
| 169 | 169 | throw new \Jaxon\Exception\Error($this->trans('errors.upload.failed', $aFile)); |
| 170 | 170 | } |
| 171 | 171 | // Verify file validity (format, size) |
| 172 | - if(!$this->validateUploadedFile($sVarName, $aFile)) |
|
| 172 | + if (!$this->validateUploadedFile($sVarName, $aFile)) |
|
| 173 | 173 | { |
| 174 | 174 | throw new \Jaxon\Exception\Error($this->getValidatorMessage()); |
| 175 | 175 | } |
| 176 | 176 | // Verify that the upload dir exists and is writable |
| 177 | 177 | $sUploadDir = trim($this->getOption('upload.files.' . $sVarName . '.dir', $sDefaultUploadDir)); |
| 178 | 178 | $sUploadDir = rtrim($sUploadDir, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR; |
| 179 | - if(!is_writable($sUploadDir)) |
|
| 179 | + if (!is_writable($sUploadDir)) |
|
| 180 | 180 | { |
| 181 | 181 | throw new \Jaxon\Exception\Error($this->trans('errors.upload.access')); |
| 182 | 182 | } |
@@ -192,9 +192,9 @@ discard block |
||
| 192 | 192 | } |
| 193 | 193 | } |
| 194 | 194 | // Copy the uploaded files from the temp dir to the user dir |
| 195 | - foreach($this->aFiles as $sVarName => $aFiles) |
|
| 195 | + foreach ($this->aFiles as $sVarName => $aFiles) |
|
| 196 | 196 | { |
| 197 | - for($i = 0; $i < count($aFiles); $i++) |
|
| 197 | + for ($i = 0; $i < count($aFiles); $i++) |
|
| 198 | 198 | { |
| 199 | 199 | // All's right, move the file to the user dir. |
| 200 | 200 | move_uploaded_file($aFiles[$i]["tmp_name"], $this->aUserFiles[$sVarName][$i]["path"]); |
@@ -67,8 +67,7 @@ |
||
| 67 | 67 | 'extension' => pathinfo($aFile['name'][$i], PATHINFO_EXTENSION), |
| 68 | 68 | ]; |
| 69 | 69 | } |
| 70 | - } |
|
| 71 | - else |
|
| 70 | + } else |
|
| 72 | 71 | { |
| 73 | 72 | // Copy the file data into the local array |
| 74 | 73 | $this->aFiles[$sVarName][] = [ |
@@ -90,13 +90,13 @@ discard block |
||
| 90 | 90 | { |
| 91 | 91 | $this->aConfiguration = array(); |
| 92 | 92 | $this->sAlias = ''; |
| 93 | - if(is_array($sUserFunction)) |
|
| 93 | + if (is_array($sUserFunction)) |
|
| 94 | 94 | { |
| 95 | - if(count($sUserFunction) != 2 && count($sUserFunction) != 3) |
|
| 95 | + if (count($sUserFunction) != 2 && count($sUserFunction) != 3) |
|
| 96 | 96 | { |
| 97 | 97 | throw new \Jaxon\Exception\Error($this->trans('errors.functions.invalid-declaration')); |
| 98 | 98 | } |
| 99 | - if(count($sUserFunction) == 3) |
|
| 99 | + if (count($sUserFunction) == 3) |
|
| 100 | 100 | { |
| 101 | 101 | $this->sAlias = $sUserFunction[0]; |
| 102 | 102 | $this->sUserFunction = array_slice($sUserFunction, 1); |
@@ -106,7 +106,7 @@ discard block |
||
| 106 | 106 | $this->sUserFunction = $sUserFunction; |
| 107 | 107 | } |
| 108 | 108 | } |
| 109 | - elseif(is_string($sUserFunction)) |
|
| 109 | + elseif (is_string($sUserFunction)) |
|
| 110 | 110 | { |
| 111 | 111 | $this->sUserFunction = $sUserFunction; |
| 112 | 112 | } |
@@ -124,7 +124,7 @@ discard block |
||
| 124 | 124 | public function getName() |
| 125 | 125 | { |
| 126 | 126 | // Do not use sAlias here! |
| 127 | - if(is_array($this->sUserFunction)) |
|
| 127 | + if (is_array($this->sUserFunction)) |
|
| 128 | 128 | { |
| 129 | 129 | return $this->sUserFunction[1]; |
| 130 | 130 | } |
@@ -141,7 +141,7 @@ discard block |
||
| 141 | 141 | */ |
| 142 | 142 | public function configure($sName, $sValue) |
| 143 | 143 | { |
| 144 | - switch($sName) |
|
| 144 | + switch ($sName) |
|
| 145 | 145 | { |
| 146 | 146 | case 'alias': |
| 147 | 147 | $this->sAlias = $sValue; |
@@ -195,7 +195,7 @@ discard block |
||
| 195 | 195 | */ |
| 196 | 196 | public function call($aArgs = array()) |
| 197 | 197 | { |
| 198 | - if(($this->sInclude)) |
|
| 198 | + if (($this->sInclude)) |
|
| 199 | 199 | { |
| 200 | 200 | require_once $this->sInclude; |
| 201 | 201 | } |
@@ -129,7 +129,7 @@ discard block |
||
| 129 | 129 | // Verify the file extension |
| 130 | 130 | $xDefault = $this->xConfig->getOption('upload.default.types'); |
| 131 | 131 | $aAllowed = $this->xConfig->getOption('upload.files.' . $sName . '.types', $xDefault); |
| 132 | - if(is_array($aAllowed) && !in_array($aUploadedFile['type'], $aAllowed)) |
|
| 132 | + if (is_array($aAllowed) && !in_array($aUploadedFile['type'], $aAllowed)) |
|
| 133 | 133 | { |
| 134 | 134 | $this->sErrorMessage = $this->xTranslator->trans('errors.upload.type', $aUploadedFile); |
| 135 | 135 | return false; |
@@ -137,7 +137,7 @@ discard block |
||
| 137 | 137 | // Verify the file extension |
| 138 | 138 | $xDefault = $this->xConfig->getOption('upload.default.extensions'); |
| 139 | 139 | $aAllowed = $this->xConfig->getOption('upload.files.' . $sName . '.extensions', $xDefault); |
| 140 | - if(is_array($aAllowed) && !in_array($aUploadedFile['extension'], $aAllowed)) |
|
| 140 | + if (is_array($aAllowed) && !in_array($aUploadedFile['extension'], $aAllowed)) |
|
| 141 | 141 | { |
| 142 | 142 | $this->sErrorMessage = $this->xTranslator->trans('errors.upload.extension', $aUploadedFile); |
| 143 | 143 | return false; |
@@ -145,7 +145,7 @@ discard block |
||
| 145 | 145 | // Verify the max size |
| 146 | 146 | $xDefault = $this->xConfig->getOption('upload.default.max-size', 0); |
| 147 | 147 | $iSize = $this->xConfig->getOption('upload.files.' . $sName . '.max-size', $xDefault); |
| 148 | - if($iSize > 0 && $aUploadedFile['size'] > $iSize) |
|
| 148 | + if ($iSize > 0 && $aUploadedFile['size'] > $iSize) |
|
| 149 | 149 | { |
| 150 | 150 | $this->sErrorMessage = $this->xTranslator->trans('errors.upload.max-size', $aUploadedFile); |
| 151 | 151 | return false; |
@@ -153,7 +153,7 @@ discard block |
||
| 153 | 153 | // Verify the min size |
| 154 | 154 | $xDefault = $this->xConfig->getOption('upload.default.min-size', 0); |
| 155 | 155 | $iSize = $this->xConfig->getOption('upload.files.' . $sName . '.min-size', $xDefault); |
| 156 | - if($iSize > 0 && $aUploadedFile['size'] < $iSize) |
|
| 156 | + if ($iSize > 0 && $aUploadedFile['size'] < $iSize) |
|
| 157 | 157 | { |
| 158 | 158 | $this->sErrorMessage = $this->xTranslator->trans('errors.upload.min-size', $aUploadedFile); |
| 159 | 159 | return false; |
@@ -121,7 +121,7 @@ |
||
| 121 | 121 | } |
| 122 | 122 | if(!array_key_exists($sLanguage, $this->aTranslations) || !array_key_exists($sText, $this->aTranslations[$sLanguage])) |
| 123 | 123 | { |
| 124 | - return $sText; |
|
| 124 | + return $sText; |
|
| 125 | 125 | } |
| 126 | 126 | $message = $this->aTranslations[$sLanguage][$sText]; |
| 127 | 127 | foreach($aPlaceHolders as $name => $value) |
@@ -55,11 +55,11 @@ discard block |
||
| 55 | 55 | */ |
| 56 | 56 | private function _loadTranslations($sLanguage, $sPrefix, array $aTranslations) |
| 57 | 57 | { |
| 58 | - foreach($aTranslations as $sName => $xTranslation) |
|
| 58 | + foreach ($aTranslations as $sName => $xTranslation) |
|
| 59 | 59 | { |
| 60 | 60 | $sName = trim($sName); |
| 61 | 61 | $sName = ($sPrefix) ? $sPrefix . '.' . $sName : $sName; |
| 62 | - if(!is_array($xTranslation)) |
|
| 62 | + if (!is_array($xTranslation)) |
|
| 63 | 63 | { |
| 64 | 64 | // Save this translation |
| 65 | 65 | $this->aTranslations[$sLanguage][$sName] = $xTranslation; |
@@ -82,17 +82,17 @@ discard block |
||
| 82 | 82 | */ |
| 83 | 83 | public function loadTranslations($sFilePath, $sLanguage) |
| 84 | 84 | { |
| 85 | - if(!file_exists($sFilePath)) |
|
| 85 | + if (!file_exists($sFilePath)) |
|
| 86 | 86 | { |
| 87 | 87 | return; |
| 88 | 88 | } |
| 89 | 89 | $aTranslations = require($sFilePath); |
| 90 | - if(!is_array($aTranslations)) |
|
| 90 | + if (!is_array($aTranslations)) |
|
| 91 | 91 | { |
| 92 | 92 | return; |
| 93 | 93 | } |
| 94 | 94 | // Load the translations |
| 95 | - if(!array_key_exists($sLanguage, $this->aTranslations)) |
|
| 95 | + if (!array_key_exists($sLanguage, $this->aTranslations)) |
|
| 96 | 96 | { |
| 97 | 97 | $this->aTranslations[$sLanguage] = []; |
| 98 | 98 | } |
@@ -111,20 +111,20 @@ discard block |
||
| 111 | 111 | public function trans($sText, array $aPlaceHolders = array(), $sLanguage = null) |
| 112 | 112 | { |
| 113 | 113 | $sText = trim((string)$sText); |
| 114 | - if(!$sLanguage) |
|
| 114 | + if (!$sLanguage) |
|
| 115 | 115 | { |
| 116 | 116 | $sLanguage = $this->xConfig->getOption('language'); |
| 117 | 117 | } |
| 118 | - if(!$sLanguage) |
|
| 118 | + if (!$sLanguage) |
|
| 119 | 119 | { |
| 120 | 120 | $sLanguage = $this->sDefaultLocale; |
| 121 | 121 | } |
| 122 | - if(!array_key_exists($sLanguage, $this->aTranslations) || !array_key_exists($sText, $this->aTranslations[$sLanguage])) |
|
| 122 | + if (!array_key_exists($sLanguage, $this->aTranslations) || !array_key_exists($sText, $this->aTranslations[$sLanguage])) |
|
| 123 | 123 | { |
| 124 | 124 | return $sText; |
| 125 | 125 | } |
| 126 | 126 | $message = $this->aTranslations[$sLanguage][$sText]; |
| 127 | - foreach($aPlaceHolders as $name => $value) |
|
| 127 | + foreach ($aPlaceHolders as $name => $value) |
|
| 128 | 128 | { |
| 129 | 129 | $message = str_replace(':' . $name, $value, $message); |
| 130 | 130 | } |
@@ -63,8 +63,7 @@ |
||
| 63 | 63 | { |
| 64 | 64 | // Save this translation |
| 65 | 65 | $this->aTranslations[$sLanguage][$sName] = $xTranslation; |
| 66 | - } |
|
| 67 | - else |
|
| 66 | + } else |
|
| 68 | 67 | { |
| 69 | 68 | // Recursively read the translations in the array |
| 70 | 69 | $this->_loadTranslations($sLanguage, $sName, $xTranslation); |
@@ -27,7 +27,7 @@ discard block |
||
| 27 | 27 | |
| 28 | 28 | public static function getInstance() |
| 29 | 29 | { |
| 30 | - if(!self::$xInstance) |
|
| 30 | + if (!self::$xInstance) |
|
| 31 | 31 | { |
| 32 | 32 | self::$xInstance = new Container(); |
| 33 | 33 | } |
@@ -65,19 +65,19 @@ discard block |
||
| 65 | 65 | * Managers |
| 66 | 66 | */ |
| 67 | 67 | // Plugin Manager |
| 68 | - $this->di['plugin_manager'] = function ($c) { |
|
| 68 | + $this->di['plugin_manager'] = function($c) { |
|
| 69 | 69 | return new \Jaxon\Plugin\Manager(); |
| 70 | 70 | }; |
| 71 | 71 | // Request Manager |
| 72 | - $this->di['request_manager'] = function ($c) { |
|
| 72 | + $this->di['request_manager'] = function($c) { |
|
| 73 | 73 | return new \Jaxon\Request\Manager(); |
| 74 | 74 | }; |
| 75 | 75 | // Request Factory |
| 76 | - $this->di['request_factory'] = function ($c) { |
|
| 76 | + $this->di['request_factory'] = function($c) { |
|
| 77 | 77 | return new \Jaxon\Request\Factory(); |
| 78 | 78 | }; |
| 79 | 79 | // Response Manager |
| 80 | - $this->di['response_manager'] = function ($c) { |
|
| 80 | + $this->di['response_manager'] = function($c) { |
|
| 81 | 81 | return new \Jaxon\Response\Manager(); |
| 82 | 82 | }; |
| 83 | 83 | |
@@ -85,35 +85,35 @@ discard block |
||
| 85 | 85 | * Services |
| 86 | 86 | */ |
| 87 | 87 | // Config manager |
| 88 | - $this->di['config'] = function ($c) { |
|
| 88 | + $this->di['config'] = function($c) { |
|
| 89 | 89 | return new Config\Config(); |
| 90 | 90 | }; |
| 91 | 91 | // Minifier |
| 92 | - $this->di['minifier'] = function ($c) { |
|
| 92 | + $this->di['minifier'] = function($c) { |
|
| 93 | 93 | return new Template\Minifier(); |
| 94 | 94 | }; |
| 95 | 95 | // Translator |
| 96 | - $this->di['translator'] = function ($c) { |
|
| 96 | + $this->di['translator'] = function($c) { |
|
| 97 | 97 | return new Translation\Translator($c['translation_dir'], $c['config']); |
| 98 | 98 | }; |
| 99 | 99 | // Template engine |
| 100 | - $this->di['template'] = function ($c) { |
|
| 100 | + $this->di['template'] = function($c) { |
|
| 101 | 101 | return new Template\Template($c['template_dir']); |
| 102 | 102 | }; |
| 103 | 103 | // Validator |
| 104 | - $this->di['validator'] = function ($c) { |
|
| 104 | + $this->di['validator'] = function($c) { |
|
| 105 | 105 | return new Validation\Validator($c['translator'], $c['config']); |
| 106 | 106 | }; |
| 107 | 107 | // Pagination Renderer |
| 108 | - $this->di['pagination.renderer'] = function ($c) { |
|
| 108 | + $this->di['pagination.renderer'] = function($c) { |
|
| 109 | 109 | return new Pagination\Renderer(); |
| 110 | 110 | }; |
| 111 | 111 | // Pagination Paginator |
| 112 | - $this->di['pagination.paginator'] = function ($c) { |
|
| 112 | + $this->di['pagination.paginator'] = function($c) { |
|
| 113 | 113 | return new Pagination\Paginator($c['pagination.renderer']); |
| 114 | 114 | }; |
| 115 | 115 | // Event Dispatcher |
| 116 | - $this->di['events'] = function ($c) { |
|
| 116 | + $this->di['events'] = function($c) { |
|
| 117 | 117 | return new EventDispatcher(); |
| 118 | 118 | }; |
| 119 | 119 | |
@@ -121,27 +121,27 @@ discard block |
||
| 121 | 121 | * Core library objects |
| 122 | 122 | */ |
| 123 | 123 | // Global Response |
| 124 | - $this->di['response'] = function ($c) { |
|
| 124 | + $this->di['response'] = function($c) { |
|
| 125 | 125 | return new \Jaxon\Response\Response(); |
| 126 | 126 | }; |
| 127 | 127 | // Jaxon Core |
| 128 | - $this->di['jaxon'] = function ($c) { |
|
| 128 | + $this->di['jaxon'] = function($c) { |
|
| 129 | 129 | return new \Jaxon\Jaxon(); |
| 130 | 130 | }; |
| 131 | 131 | // Jaxon Sentry |
| 132 | - $this->di['sentry'] = function ($c) { |
|
| 132 | + $this->di['sentry'] = function($c) { |
|
| 133 | 133 | // This class is not defined in this package |
| 134 | 134 | $sClass = '\\Jaxon\\Sentry\\Sentry'; |
| 135 | 135 | return new $sClass; |
| 136 | 136 | }; |
| 137 | 137 | // Armada |
| 138 | - $this->di['armada'] = function ($c) { |
|
| 138 | + $this->di['armada'] = function($c) { |
|
| 139 | 139 | // This class is not defined in this package |
| 140 | 140 | $sClass = '\\Jaxon\\Armada\\Armada'; |
| 141 | 141 | return new $sClass; |
| 142 | 142 | }; |
| 143 | 143 | // View Renderer Facade |
| 144 | - $this->di['sentry.view.renderer'] = function ($c) { |
|
| 144 | + $this->di['sentry.view.renderer'] = function($c) { |
|
| 145 | 145 | $aRenderers = $c['view.data.renderers']; |
| 146 | 146 | $sDefaultNamespace = $c['view.data.namespace.default']; |
| 147 | 147 | return new \Jaxon\Sentry\View\Facade($aRenderers, $sDefaultNamespace); |
@@ -391,14 +391,14 @@ discard block |
||
| 391 | 391 | $this->di['sentry.view.base.' . $sId] = $xClosure; |
| 392 | 392 | |
| 393 | 393 | // Return the initialized view renderer |
| 394 | - $this->di['sentry.view.' . $sId] = function ($c) use ($sId) { |
|
| 394 | + $this->di['sentry.view.' . $sId] = function($c) use ($sId) { |
|
| 395 | 395 | // Get the defined renderer |
| 396 | 396 | $renderer = $c['sentry.view.base.' . $sId]; |
| 397 | 397 | // Init the renderer with the template namespaces |
| 398 | 398 | $aNamespaces = $this->di['view.data.namespaces']; |
| 399 | - if(key_exists($sId, $aNamespaces)) |
|
| 399 | + if (key_exists($sId, $aNamespaces)) |
|
| 400 | 400 | { |
| 401 | - foreach($aNamespaces[$sId] as $ns) |
|
| 401 | + foreach ($aNamespaces[$sId] as $ns) |
|
| 402 | 402 | { |
| 403 | 403 | $renderer->addNamespace($ns['namespace'], $ns['directory'], $ns['extension']); |
| 404 | 404 | } |
@@ -416,7 +416,7 @@ discard block |
||
| 416 | 416 | */ |
| 417 | 417 | public function getViewRenderer($sId = '') |
| 418 | 418 | { |
| 419 | - if(!$sId) |
|
| 419 | + if (!$sId) |
|
| 420 | 420 | { |
| 421 | 421 | // Return the view renderer facade |
| 422 | 422 | return $this->di['sentry.view.renderer']; |