@@ -243,8 +243,7 @@ |
||
| 243 | 243 | if($sName == 'separator' || $sName == 'protected') |
| 244 | 244 | { |
| 245 | 245 | $xCallableObject->configure($sName, $xValue); |
| 246 | - } |
|
| 247 | - elseif(is_array($xValue) && $sName != 'include') |
|
| 246 | + } elseif(is_array($xValue) && $sName != 'include') |
|
| 248 | 247 | { |
| 249 | 248 | // These options are to be included in javascript code. |
| 250 | 249 | $this->aCallableOptions[$sClassName][$sName] = $xValue; |
@@ -88,19 +88,19 @@ discard block |
||
| 88 | 88 | private function getClassOptions($sClassName, array $aDirectoryOptions, array $aDefaultOptions = []) |
| 89 | 89 | { |
| 90 | 90 | $aOptions = $aDefaultOptions; |
| 91 | - if(key_exists('separator', $aDirectoryOptions)) |
|
| 91 | + if (key_exists('separator', $aDirectoryOptions)) |
|
| 92 | 92 | { |
| 93 | 93 | $aOptions['separator'] = $aDirectoryOptions['separator']; |
| 94 | 94 | } |
| 95 | - if(key_exists('protected', $aDirectoryOptions)) |
|
| 95 | + if (key_exists('protected', $aDirectoryOptions)) |
|
| 96 | 96 | { |
| 97 | 97 | $aOptions['protected'] = $aDirectoryOptions['protected']; |
| 98 | 98 | } |
| 99 | - if(key_exists('*', $aDirectoryOptions)) |
|
| 99 | + if (key_exists('*', $aDirectoryOptions)) |
|
| 100 | 100 | { |
| 101 | 101 | $aOptions = array_merge($aOptions, $aDirectoryOptions['*']); |
| 102 | 102 | } |
| 103 | - if(key_exists($sClassName, $aDirectoryOptions)) |
|
| 103 | + if (key_exists($sClassName, $aDirectoryOptions)) |
|
| 104 | 104 | { |
| 105 | 105 | $aOptions = array_merge($aOptions, $aDirectoryOptions[$sClassName]); |
| 106 | 106 | } |
@@ -120,17 +120,17 @@ discard block |
||
| 120 | 120 | $itDir = new RecursiveDirectoryIterator($sDirectory); |
| 121 | 121 | $itFile = new RecursiveIteratorIterator($itDir); |
| 122 | 122 | // Iterate on dir content |
| 123 | - foreach($itFile as $xFile) |
|
| 123 | + foreach ($itFile as $xFile) |
|
| 124 | 124 | { |
| 125 | 125 | // skip everything except PHP files |
| 126 | - if(!$xFile->isFile() || $xFile->getExtension() != 'php') |
|
| 126 | + if (!$xFile->isFile() || $xFile->getExtension() != 'php') |
|
| 127 | 127 | { |
| 128 | 128 | continue; |
| 129 | 129 | } |
| 130 | 130 | |
| 131 | 131 | $aClassOptions = []; |
| 132 | 132 | // No more classmap autoloading. The file will be included when needed. |
| 133 | - if(($aOptions['autoload'])) |
|
| 133 | + if (($aOptions['autoload'])) |
|
| 134 | 134 | { |
| 135 | 135 | $aClassOptions['include'] = $xFile->getPathname(); |
| 136 | 136 | } |
@@ -162,7 +162,7 @@ discard block |
||
| 162 | 162 | */ |
| 163 | 163 | private function getOptionsFromClass($sClassName) |
| 164 | 164 | { |
| 165 | - if(!key_exists($sClassName, $this->aClassOptions)) |
|
| 165 | + if (!key_exists($sClassName, $this->aClassOptions)) |
|
| 166 | 166 | { |
| 167 | 167 | return null; // Class not registered |
| 168 | 168 | } |
@@ -180,15 +180,15 @@ discard block |
||
| 180 | 180 | { |
| 181 | 181 | // Find the corresponding namespace |
| 182 | 182 | $sNamespace = null; |
| 183 | - foreach(array_keys($this->aNamespaceOptions) as $_sNamespace) |
|
| 183 | + foreach (array_keys($this->aNamespaceOptions) as $_sNamespace) |
|
| 184 | 184 | { |
| 185 | - if(substr($sClassName, 0, strlen($_sNamespace) + 1) == $_sNamespace . '\\') |
|
| 185 | + if (substr($sClassName, 0, strlen($_sNamespace) + 1) == $_sNamespace . '\\') |
|
| 186 | 186 | { |
| 187 | 187 | $sNamespace = $_sNamespace; |
| 188 | 188 | break; |
| 189 | 189 | } |
| 190 | 190 | } |
| 191 | - if($sNamespace == null) |
|
| 191 | + if ($sNamespace == null) |
|
| 192 | 192 | { |
| 193 | 193 | return null; // Class not registered |
| 194 | 194 | } |
@@ -210,27 +210,27 @@ discard block |
||
| 210 | 210 | // at the beginning and the end of the class name. |
| 211 | 211 | $sClassName = trim(str_replace(['.', '_'], ['\\', '\\'], (string)$sClassName), '\\'); |
| 212 | 212 | |
| 213 | - if(key_exists($sClassName, $this->aCallableObjects)) |
|
| 213 | + if (key_exists($sClassName, $this->aCallableObjects)) |
|
| 214 | 214 | { |
| 215 | 215 | return $this->aCallableObjects[$sClassName]; |
| 216 | 216 | } |
| 217 | 217 | |
| 218 | 218 | $aOptions = $this->getOptionsFromClass($sClassName); |
| 219 | - if($aOptions === null) |
|
| 219 | + if ($aOptions === null) |
|
| 220 | 220 | { |
| 221 | 221 | $aOptions = $this->getOptionsFromNamespace($sClassName); |
| 222 | 222 | } |
| 223 | - if($aOptions === null) |
|
| 223 | + if ($aOptions === null) |
|
| 224 | 224 | { |
| 225 | 225 | return null; |
| 226 | 226 | } |
| 227 | 227 | |
| 228 | 228 | // Make sure the registered class exists |
| 229 | - if(key_exists('include', $aOptions)) |
|
| 229 | + if (key_exists('include', $aOptions)) |
|
| 230 | 230 | { |
| 231 | 231 | require_once($aOptions['include']); |
| 232 | 232 | } |
| 233 | - if(!class_exists('\\' . $sClassName)) |
|
| 233 | + if (!class_exists('\\' . $sClassName)) |
|
| 234 | 234 | { |
| 235 | 235 | return null; |
| 236 | 236 | } |
@@ -238,13 +238,13 @@ discard block |
||
| 238 | 238 | // Create the callable object |
| 239 | 239 | $xCallableObject = new \Jaxon\Request\Support\CallableObject($sClassName); |
| 240 | 240 | $this->aCallableOptions[$sClassName] = []; |
| 241 | - foreach($aOptions as $sName => $xValue) |
|
| 241 | + foreach ($aOptions as $sName => $xValue) |
|
| 242 | 242 | { |
| 243 | - if($sName == 'separator' || $sName == 'protected') |
|
| 243 | + if ($sName == 'separator' || $sName == 'protected') |
|
| 244 | 244 | { |
| 245 | 245 | $xCallableObject->configure($sName, $xValue); |
| 246 | 246 | } |
| 247 | - elseif(is_array($xValue) && $sName != 'include') |
|
| 247 | + elseif (is_array($xValue) && $sName != 'include') |
|
| 248 | 248 | { |
| 249 | 249 | // These options are to be included in javascript code. |
| 250 | 250 | $this->aCallableOptions[$sClassName][$sName] = $xValue; |
@@ -253,12 +253,12 @@ discard block |
||
| 253 | 253 | $this->aCallableObjects[$sClassName] = $xCallableObject; |
| 254 | 254 | |
| 255 | 255 | // Register the request factory for this callable object |
| 256 | - jaxon()->di()->set($sClassName . '_Factory_Rq', function () use ($sClassName) { |
|
| 256 | + jaxon()->di()->set($sClassName . '_Factory_Rq', function() use ($sClassName) { |
|
| 257 | 257 | $xCallableObject = $this->aCallableObjects[$sClassName]; |
| 258 | 258 | return new \Jaxon\Factory\Request\Portable($xCallableObject); |
| 259 | 259 | }); |
| 260 | 260 | // Register the paginator factory for this callable object |
| 261 | - jaxon()->di()->set($sClassName . '_Factory_Pg', function () use ($sClassName) { |
|
| 261 | + jaxon()->di()->set($sClassName . '_Factory_Pg', function() use ($sClassName) { |
|
| 262 | 262 | $xCallableObject = $this->aCallableObjects[$sClassName]; |
| 263 | 263 | return new \Jaxon\Factory\Request\Paginator($xCallableObject); |
| 264 | 264 | }); |
@@ -274,16 +274,16 @@ discard block |
||
| 274 | 274 | private function createCallableObjects() |
| 275 | 275 | { |
| 276 | 276 | // Create callable objects for registered classes |
| 277 | - foreach(array_keys($this->aClassOptions) as $sClassName) |
|
| 277 | + foreach (array_keys($this->aClassOptions) as $sClassName) |
|
| 278 | 278 | { |
| 279 | 279 | $this->getCallableObject($sClassName); |
| 280 | 280 | } |
| 281 | 281 | |
| 282 | 282 | // Create callable objects for registered namespaces |
| 283 | 283 | $sDS = DIRECTORY_SEPARATOR; |
| 284 | - foreach($this->aNamespaceOptions as $sNamespace => $aOptions) |
|
| 284 | + foreach ($this->aNamespaceOptions as $sNamespace => $aOptions) |
|
| 285 | 285 | { |
| 286 | - if(key_exists($sNamespace, $this->aNamespaces)) |
|
| 286 | + if (key_exists($sNamespace, $this->aNamespaces)) |
|
| 287 | 287 | { |
| 288 | 288 | continue; |
| 289 | 289 | } |
@@ -294,10 +294,10 @@ discard block |
||
| 294 | 294 | $sDirectory = $aOptions['directory']; |
| 295 | 295 | $itDir = new RecursiveDirectoryIterator($sDirectory); |
| 296 | 296 | $itFile = new RecursiveIteratorIterator($itDir); |
| 297 | - foreach($itFile as $xFile) |
|
| 297 | + foreach ($itFile as $xFile) |
|
| 298 | 298 | { |
| 299 | 299 | // skip everything except PHP files |
| 300 | - if(!$xFile->isFile() || $xFile->getExtension() != 'php') |
|
| 300 | + if (!$xFile->isFile() || $xFile->getExtension() != 'php') |
|
| 301 | 301 | { |
| 302 | 302 | continue; |
| 303 | 303 | } |
@@ -306,7 +306,7 @@ discard block |
||
| 306 | 306 | $sClassPath = $sNamespace; |
| 307 | 307 | $sRelativePath = substr($xFile->getPath(), strlen($sDirectory)); |
| 308 | 308 | $sRelativePath = trim(str_replace($sDS, '\\', $sRelativePath), '\\'); |
| 309 | - if($sRelativePath != '') |
|
| 309 | + if ($sRelativePath != '') |
|
| 310 | 310 | { |
| 311 | 311 | $sClassPath .= '\\' . $sRelativePath; |
| 312 | 312 | } |
@@ -342,11 +342,11 @@ discard block |
||
| 342 | 342 | $this->createCallableObjects(); |
| 343 | 343 | |
| 344 | 344 | $sHash = ''; |
| 345 | - foreach($this->aNamespaces as $sNamespace => $aOptions) |
|
| 345 | + foreach ($this->aNamespaces as $sNamespace => $aOptions) |
|
| 346 | 346 | { |
| 347 | 347 | $sHash .= $sNamespace . $aOptions['separator']; |
| 348 | 348 | } |
| 349 | - foreach($this->aCallableObjects as $sClassName => $xCallableObject) |
|
| 349 | + foreach ($this->aCallableObjects as $sClassName => $xCallableObject) |
|
| 350 | 350 | { |
| 351 | 351 | $sHash .= $sClassName . implode('|', $xCallableObject->getMethods()); |
| 352 | 352 | } |
@@ -367,16 +367,16 @@ discard block |
||
| 367 | 367 | |
| 368 | 368 | $aJsClasses = []; |
| 369 | 369 | $sCode = ''; |
| 370 | - foreach(array_keys($this->aNamespaces) as $sNamespace) |
|
| 370 | + foreach (array_keys($this->aNamespaces) as $sNamespace) |
|
| 371 | 371 | { |
| 372 | 372 | $offset = 0; |
| 373 | 373 | $sJsNamespace = str_replace('\\', '.', $sNamespace); |
| 374 | 374 | $sJsNamespace .= '.Null'; // This is a sentinel. The last token is not processed in the while loop. |
| 375 | - while(($dotPosition = strpos($sJsNamespace, '.', $offset)) !== false) |
|
| 375 | + while (($dotPosition = strpos($sJsNamespace, '.', $offset)) !== false) |
|
| 376 | 376 | { |
| 377 | 377 | $sJsClass = substr($sJsNamespace, 0, $dotPosition); |
| 378 | 378 | // Generate code for this object |
| 379 | - if(!key_exists($sJsClass, $aJsClasses)) |
|
| 379 | + if (!key_exists($sJsClass, $aJsClasses)) |
|
| 380 | 380 | { |
| 381 | 381 | $sCode .= "$sPrefix$sJsClass = {};\n"; |
| 382 | 382 | $aJsClasses[$sJsClass] = $sJsClass; |
@@ -385,13 +385,13 @@ discard block |
||
| 385 | 385 | } |
| 386 | 386 | } |
| 387 | 387 | |
| 388 | - foreach($this->aCallableObjects as $sClassName => $xCallableObject) |
|
| 388 | + foreach ($this->aCallableObjects as $sClassName => $xCallableObject) |
|
| 389 | 389 | { |
| 390 | 390 | $aConfig = $this->aCallableOptions[$sClassName]; |
| 391 | 391 | $aCommonConfig = key_exists('*', $aConfig) ? $aConfig['*'] : []; |
| 392 | 392 | |
| 393 | 393 | $aMethods = []; |
| 394 | - foreach($xCallableObject->getMethods() as $sMethodName) |
|
| 394 | + foreach ($xCallableObject->getMethods() as $sMethodName) |
|
| 395 | 395 | { |
| 396 | 396 | // Specific options for this method |
| 397 | 397 | $aMethodConfig = key_exists($sMethodName, $aConfig) ? |
@@ -164,7 +164,7 @@ |
||
| 164 | 164 | } |
| 165 | 165 | else |
| 166 | 166 | { |
| 167 | - // Use underscore as separator, so there's no need to deal with namespace |
|
| 167 | + // Use underscore as separator, so there's no need to deal with namespace |
|
| 168 | 168 | // when generating javascript code. |
| 169 | 169 | $aOptions['separator'] = '_'; |
| 170 | 170 | $aOptions['autoload'] = $this->bAutoloadEnabled; |
@@ -105,33 +105,33 @@ discard block |
||
| 105 | 105 | */ |
| 106 | 106 | public function register($sType, $sDirectory, $aOptions) |
| 107 | 107 | { |
| 108 | - if($sType != $this->getName()) |
|
| 108 | + if ($sType != $this->getName()) |
|
| 109 | 109 | { |
| 110 | 110 | return false; |
| 111 | 111 | } |
| 112 | 112 | |
| 113 | - if(!is_string($sDirectory) || !is_dir($sDirectory)) |
|
| 113 | + if (!is_string($sDirectory) || !is_dir($sDirectory)) |
|
| 114 | 114 | { |
| 115 | 115 | throw new \Jaxon\Exception\Error($this->trans('errors.objects.invalid-declaration')); |
| 116 | 116 | } |
| 117 | - if(is_string($aOptions)) |
|
| 117 | + if (is_string($aOptions)) |
|
| 118 | 118 | { |
| 119 | 119 | $aOptions = ['namespace' => $aOptions]; |
| 120 | 120 | } |
| 121 | - if(!is_array($aOptions)) |
|
| 121 | + if (!is_array($aOptions)) |
|
| 122 | 122 | { |
| 123 | 123 | throw new \Jaxon\Exception\Error($this->trans('errors.objects.invalid-declaration')); |
| 124 | 124 | } |
| 125 | 125 | |
| 126 | 126 | $sDirectory = rtrim(trim($sDirectory), DIRECTORY_SEPARATOR); |
| 127 | - if(!is_dir($sDirectory)) |
|
| 127 | + if (!is_dir($sDirectory)) |
|
| 128 | 128 | { |
| 129 | 129 | return false; |
| 130 | 130 | } |
| 131 | 131 | $aOptions['directory'] = $sDirectory; |
| 132 | 132 | |
| 133 | 133 | $sNamespace = key_exists('namespace', $aOptions) ? $aOptions['namespace'] : ''; |
| 134 | - if(!($sNamespace = trim($sNamespace, ' \\'))) |
|
| 134 | + if (!($sNamespace = trim($sNamespace, ' \\'))) |
|
| 135 | 135 | { |
| 136 | 136 | $sNamespace = ''; |
| 137 | 137 | } |
@@ -145,17 +145,17 @@ discard block |
||
| 145 | 145 | |
| 146 | 146 | // Change the keys in $aOptions to have "\" as separator |
| 147 | 147 | $_aOptions = []; |
| 148 | - foreach($aOptions as $sName => $aOption) |
|
| 148 | + foreach ($aOptions as $sName => $aOption) |
|
| 149 | 149 | { |
| 150 | 150 | $sName = trim(str_replace('.', '\\', $sName), ' \\'); |
| 151 | 151 | $_aOptions[$sName] = $aOption; |
| 152 | 152 | } |
| 153 | 153 | $aOptions = $_aOptions; |
| 154 | 154 | |
| 155 | - if(($sNamespace)) |
|
| 155 | + if (($sNamespace)) |
|
| 156 | 156 | { |
| 157 | 157 | // Register the dir with PSR4 autoloading |
| 158 | - if(($this->xAutoloader)) |
|
| 158 | + if (($this->xAutoloader)) |
|
| 159 | 159 | { |
| 160 | 160 | $this->xAutoloader->setPsr4($sNamespace . '\\', $sDirectory); |
| 161 | 161 | } |
@@ -161,8 +161,7 @@ |
||
| 161 | 161 | } |
| 162 | 162 | |
| 163 | 163 | $this->xRepository->addNamespace($sNamespace, $aOptions); |
| 164 | - } |
|
| 165 | - else |
|
| 164 | + } else |
|
| 166 | 165 | { |
| 167 | 166 | // Use underscore as separator, so there's no need to deal with namespace |
| 168 | 167 | // when generating javascript code. |
@@ -61,19 +61,19 @@ discard block |
||
| 61 | 61 | { |
| 62 | 62 | $this->xRepository = $xRepository; |
| 63 | 63 | |
| 64 | - if(!empty($_GET['jxncls'])) |
|
| 64 | + if (!empty($_GET['jxncls'])) |
|
| 65 | 65 | { |
| 66 | 66 | $this->sRequestedClass = $_GET['jxncls']; |
| 67 | 67 | } |
| 68 | - if(!empty($_GET['jxnmthd'])) |
|
| 68 | + if (!empty($_GET['jxnmthd'])) |
|
| 69 | 69 | { |
| 70 | 70 | $this->sRequestedMethod = $_GET['jxnmthd']; |
| 71 | 71 | } |
| 72 | - if(!empty($_POST['jxncls'])) |
|
| 72 | + if (!empty($_POST['jxncls'])) |
|
| 73 | 73 | { |
| 74 | 74 | $this->sRequestedClass = $_POST['jxncls']; |
| 75 | 75 | } |
| 76 | - if(!empty($_POST['jxnmthd'])) |
|
| 76 | + if (!empty($_POST['jxnmthd'])) |
|
| 77 | 77 | { |
| 78 | 78 | $this->sRequestedMethod = $_POST['jxnmthd']; |
| 79 | 79 | } |
@@ -100,20 +100,20 @@ discard block |
||
| 100 | 100 | */ |
| 101 | 101 | public function register($sType, $sClassName, $aOptions) |
| 102 | 102 | { |
| 103 | - if($sType != $this->getName()) |
|
| 103 | + if ($sType != $this->getName()) |
|
| 104 | 104 | { |
| 105 | 105 | return false; |
| 106 | 106 | } |
| 107 | 107 | |
| 108 | - if(!is_string($sClassName)) |
|
| 108 | + if (!is_string($sClassName)) |
|
| 109 | 109 | { |
| 110 | 110 | throw new \Jaxon\Exception\Error($this->trans('errors.objects.invalid-declaration')); |
| 111 | 111 | } |
| 112 | - if(is_string($aOptions)) |
|
| 112 | + if (is_string($aOptions)) |
|
| 113 | 113 | { |
| 114 | 114 | $aOptions = ['include' => $aOptions]; |
| 115 | 115 | } |
| 116 | - if(!is_array($aOptions)) |
|
| 116 | + if (!is_array($aOptions)) |
|
| 117 | 117 | { |
| 118 | 118 | throw new \Jaxon\Exception\Error($this->trans('errors.objects.invalid-declaration')); |
| 119 | 119 | } |
@@ -151,13 +151,13 @@ discard block |
||
| 151 | 151 | public function canProcessRequest() |
| 152 | 152 | { |
| 153 | 153 | // Check the validity of the class name |
| 154 | - if($this->sRequestedClass !== null && !$this->validateClass($this->sRequestedClass)) |
|
| 154 | + if ($this->sRequestedClass !== null && !$this->validateClass($this->sRequestedClass)) |
|
| 155 | 155 | { |
| 156 | 156 | $this->sRequestedClass = null; |
| 157 | 157 | $this->sRequestedMethod = null; |
| 158 | 158 | } |
| 159 | 159 | // Check the validity of the method name |
| 160 | - if($this->sRequestedMethod !== null && !$this->validateMethod($this->sRequestedMethod)) |
|
| 160 | + if ($this->sRequestedMethod !== null && !$this->validateMethod($this->sRequestedMethod)) |
|
| 161 | 161 | { |
| 162 | 162 | $this->sRequestedClass = null; |
| 163 | 163 | $this->sRequestedMethod = null; |
@@ -172,14 +172,14 @@ discard block |
||
| 172 | 172 | */ |
| 173 | 173 | public function processRequest() |
| 174 | 174 | { |
| 175 | - if(!$this->canProcessRequest()) |
|
| 175 | + if (!$this->canProcessRequest()) |
|
| 176 | 176 | { |
| 177 | 177 | return false; |
| 178 | 178 | } |
| 179 | 179 | |
| 180 | 180 | // Find the requested method |
| 181 | 181 | $xCallableObject = $this->xRepository->getCallableObject($this->sRequestedClass); |
| 182 | - if(!$xCallableObject || !$xCallableObject->hasMethod($this->sRequestedMethod)) |
|
| 182 | + if (!$xCallableObject || !$xCallableObject->hasMethod($this->sRequestedMethod)) |
|
| 183 | 183 | { |
| 184 | 184 | // Unable to find the requested object or method |
| 185 | 185 | throw new \Jaxon\Exception\Error($this->trans('errors.objects.invalid', |
@@ -189,7 +189,7 @@ discard block |
||
| 189 | 189 | // Call the requested method |
| 190 | 190 | $aArgs = $this->getRequestManager()->process(); |
| 191 | 191 | $xResponse = $xCallableObject->call($this->sRequestedMethod, $aArgs); |
| 192 | - if(($xResponse)) |
|
| 192 | + if (($xResponse)) |
|
| 193 | 193 | { |
| 194 | 194 | $this->getResponseManager()->append($xResponse); |
| 195 | 195 | } |
@@ -63,7 +63,7 @@ discard block |
||
| 63 | 63 | */ |
| 64 | 64 | protected function getPrevLink() |
| 65 | 65 | { |
| 66 | - if(!($sCall = $this->xPaginator->getPrevCall())) |
|
| 66 | + if (!($sCall = $this->xPaginator->getPrevCall())) |
|
| 67 | 67 | { |
| 68 | 68 | return ''; |
| 69 | 69 | } |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | */ |
| 79 | 79 | protected function getNextLink() |
| 80 | 80 | { |
| 81 | - if(!($sCall = $this->xPaginator->getNextCall())) |
|
| 81 | + if (!($sCall = $this->xPaginator->getNextCall())) |
|
| 82 | 82 | { |
| 83 | 83 | return ''; |
| 84 | 84 | } |
@@ -94,9 +94,9 @@ discard block |
||
| 94 | 94 | protected function getLinks() |
| 95 | 95 | { |
| 96 | 96 | $sLinks = ''; |
| 97 | - foreach($this->xPaginator->getPages() as $page) |
|
| 97 | + foreach ($this->xPaginator->getPages() as $page) |
|
| 98 | 98 | { |
| 99 | - if($page['call']) |
|
| 99 | + if ($page['call']) |
|
| 100 | 100 | { |
| 101 | 101 | $sTemplate = ($page['isCurrent'] ? 'pagination::links/current' : 'pagination::links/enabled'); |
| 102 | 102 | $sLinks .= $this->xTemplate->render($sTemplate, ['call' => $page['call'], 'text' => $page['num']]); |
@@ -100,8 +100,7 @@ |
||
| 100 | 100 | { |
| 101 | 101 | $sTemplate = ($page['isCurrent'] ? 'pagination::links/current' : 'pagination::links/enabled'); |
| 102 | 102 | $sLinks .= $this->xTemplate->render($sTemplate, ['call' => $page['call'], 'text' => $page['num']]); |
| 103 | - } |
|
| 104 | - else |
|
| 103 | + } else |
|
| 105 | 104 | { |
| 106 | 105 | $sLinks .= $this->xTemplate->render('pagination::links/disabled', ['text' => $page['num']]); |
| 107 | 106 | } |
@@ -84,7 +84,7 @@ discard block |
||
| 84 | 84 | */ |
| 85 | 85 | public function configure($sName, $sValue) |
| 86 | 86 | { |
| 87 | - switch($sName) |
|
| 87 | + switch ($sName) |
|
| 88 | 88 | { |
| 89 | 89 | case 'class': // The user function is a method in the given class |
| 90 | 90 | $this->xUserFunction = [$sValue, $this->xUserFunction]; |
@@ -139,13 +139,13 @@ discard block |
||
| 139 | 139 | */ |
| 140 | 140 | public function call($aArgs = []) |
| 141 | 141 | { |
| 142 | - if(($this->sInclude)) |
|
| 142 | + if (($this->sInclude)) |
|
| 143 | 143 | { |
| 144 | 144 | require_once $this->sInclude; |
| 145 | 145 | } |
| 146 | 146 | |
| 147 | 147 | // If the function is an alias for a class method, then instanciate the class |
| 148 | - if(is_array($this->xUserFunction) && is_string($this->xUserFunction[0])) |
|
| 148 | + if (is_array($this->xUserFunction) && is_string($this->xUserFunction[0])) |
|
| 149 | 149 | { |
| 150 | 150 | $sClassName = $this->xUserFunction[0]; |
| 151 | 151 | $this->xUserFunction[0] = new $sClassName; |
@@ -361,7 +361,7 @@ |
||
| 361 | 361 | /** |
| 362 | 362 | * Create a new Jaxon response object |
| 363 | 363 | * |
| 364 | - * @return Jaxon\Response\Response |
|
| 364 | + * @return \Jaxon\Response\Response |
|
| 365 | 365 | */ |
| 366 | 366 | public function newResponse() |
| 367 | 367 | { |
@@ -16,7 +16,6 @@ |
||
| 16 | 16 | |
| 17 | 17 | use Lemon\Event\EventDispatcher; |
| 18 | 18 | use Jaxon\Sentry\View\Renderer; |
| 19 | - |
|
| 20 | 19 | use Jaxon\Config\Config; |
| 21 | 20 | use Jaxon\Config\Reader as ConfigReader; |
| 22 | 21 | use Jaxon\Request\Support\CallableRepository; |
@@ -34,7 +34,7 @@ discard block |
||
| 34 | 34 | |
| 35 | 35 | public static function getInstance() |
| 36 | 36 | { |
| 37 | - if(!self::$xInstance) |
|
| 37 | + if (!self::$xInstance) |
|
| 38 | 38 | { |
| 39 | 39 | self::$xInstance = new Container(); |
| 40 | 40 | } |
@@ -94,37 +94,37 @@ discard block |
||
| 94 | 94 | * Managers |
| 95 | 95 | */ |
| 96 | 96 | // Callable objects repository |
| 97 | - $this->coreContainer[CallableRepository::class] = function ($c) { |
|
| 97 | + $this->coreContainer[CallableRepository::class] = function($c) { |
|
| 98 | 98 | return new CallableRepository(); |
| 99 | 99 | }; |
| 100 | 100 | // Plugin Manager |
| 101 | - $this->coreContainer['jaxon.core.plugin_manager'] = function ($c) { |
|
| 101 | + $this->coreContainer['jaxon.core.plugin_manager'] = function($c) { |
|
| 102 | 102 | return new \Jaxon\Plugin\Manager(); |
| 103 | 103 | }; |
| 104 | 104 | // Request Manager |
| 105 | - $this->coreContainer['jaxon.core.request_manager'] = function ($c) { |
|
| 105 | + $this->coreContainer['jaxon.core.request_manager'] = function($c) { |
|
| 106 | 106 | return new \Jaxon\Request\Manager(); |
| 107 | 107 | }; |
| 108 | 108 | // Request Factory |
| 109 | - $this->coreContainer['jaxon.core.request_factory'] = function ($c) { |
|
| 109 | + $this->coreContainer['jaxon.core.request_factory'] = function($c) { |
|
| 110 | 110 | return new \Jaxon\Factory\Request($c[CallableRepository::class]); |
| 111 | 111 | }; |
| 112 | 112 | // Parameter Factory |
| 113 | - $this->coreContainer['jaxon.core.parameter_factory'] = function ($c) { |
|
| 113 | + $this->coreContainer['jaxon.core.parameter_factory'] = function($c) { |
|
| 114 | 114 | return new \Jaxon\Factory\Parameter(); |
| 115 | 115 | }; |
| 116 | 116 | // Response Manager |
| 117 | - $this->coreContainer['jaxon.core.response_manager'] = function ($c) { |
|
| 117 | + $this->coreContainer['jaxon.core.response_manager'] = function($c) { |
|
| 118 | 118 | return new \Jaxon\Response\Manager(); |
| 119 | 119 | }; |
| 120 | 120 | |
| 121 | 121 | /* |
| 122 | 122 | * Config |
| 123 | 123 | */ |
| 124 | - $this->coreContainer[Config::class] = function ($c) { |
|
| 124 | + $this->coreContainer[Config::class] = function($c) { |
|
| 125 | 125 | return new Config(); |
| 126 | 126 | }; |
| 127 | - $this->coreContainer[ConfigReader::class] = function ($c) { |
|
| 127 | + $this->coreContainer[ConfigReader::class] = function($c) { |
|
| 128 | 128 | return new ConfigReader(); |
| 129 | 129 | }; |
| 130 | 130 | |
@@ -132,31 +132,31 @@ discard block |
||
| 132 | 132 | * Services |
| 133 | 133 | */ |
| 134 | 134 | // Minifier |
| 135 | - $this->coreContainer['jaxon.core.minifier'] = function ($c) { |
|
| 135 | + $this->coreContainer['jaxon.core.minifier'] = function($c) { |
|
| 136 | 136 | return new \Jaxon\Utils\Template\Minifier(); |
| 137 | 137 | }; |
| 138 | 138 | // Translator |
| 139 | - $this->coreContainer['jaxon.core.translator'] = function ($c) { |
|
| 139 | + $this->coreContainer['jaxon.core.translator'] = function($c) { |
|
| 140 | 140 | return new \Jaxon\Utils\Translation\Translator($c['jaxon.core.translation_dir'], $c[Config::class]); |
| 141 | 141 | }; |
| 142 | 142 | // Template engine |
| 143 | - $this->coreContainer['jaxon.core.template'] = function ($c) { |
|
| 143 | + $this->coreContainer['jaxon.core.template'] = function($c) { |
|
| 144 | 144 | return new \Jaxon\Utils\Template\Template($c['jaxon.core.template_dir']); |
| 145 | 145 | }; |
| 146 | 146 | // Validator |
| 147 | - $this->coreContainer['jaxon.core.validator'] = function ($c) { |
|
| 147 | + $this->coreContainer['jaxon.core.validator'] = function($c) { |
|
| 148 | 148 | return new \Jaxon\Utils\Validation\Validator($c['jaxon.core.translator'], $c[Config::class]); |
| 149 | 149 | }; |
| 150 | 150 | // Pagination Renderer |
| 151 | - $this->coreContainer['jaxon.pagination.renderer'] = function ($c) { |
|
| 151 | + $this->coreContainer['jaxon.pagination.renderer'] = function($c) { |
|
| 152 | 152 | return new \Jaxon\Utils\Pagination\Renderer($c['jaxon.core.template']); |
| 153 | 153 | }; |
| 154 | 154 | // Pagination Paginator |
| 155 | - $this->coreContainer['jaxon.pagination.paginator'] = function ($c) { |
|
| 155 | + $this->coreContainer['jaxon.pagination.paginator'] = function($c) { |
|
| 156 | 156 | return new \Jaxon\Utils\Pagination\Paginator($c['jaxon.pagination.renderer']); |
| 157 | 157 | }; |
| 158 | 158 | // Event Dispatcher |
| 159 | - $this->coreContainer['jaxon.core.events'] = function ($c) { |
|
| 159 | + $this->coreContainer['jaxon.core.events'] = function($c) { |
|
| 160 | 160 | return new EventDispatcher(); |
| 161 | 161 | }; |
| 162 | 162 | |
@@ -164,15 +164,15 @@ discard block |
||
| 164 | 164 | * Core library objects |
| 165 | 165 | */ |
| 166 | 166 | // Global Response |
| 167 | - $this->coreContainer['jaxon.core.response'] = function ($c) { |
|
| 167 | + $this->coreContainer['jaxon.core.response'] = function($c) { |
|
| 168 | 168 | return new \Jaxon\Response\Response(); |
| 169 | 169 | }; |
| 170 | 170 | // Jaxon Core |
| 171 | - $this->coreContainer['jaxon.core.jaxon'] = function ($c) { |
|
| 171 | + $this->coreContainer['jaxon.core.jaxon'] = function($c) { |
|
| 172 | 172 | return new \Jaxon\Jaxon(); |
| 173 | 173 | }; |
| 174 | 174 | // View Renderer Facade |
| 175 | - $this->coreContainer['jaxon.sentry.view.renderer'] = function ($c) { |
|
| 175 | + $this->coreContainer['jaxon.sentry.view.renderer'] = function($c) { |
|
| 176 | 176 | $aRenderers = $c['jaxon.view.data.renderers']; |
| 177 | 177 | $sDefaultNamespace = $c['jaxon.view.data.namespace.default']; |
| 178 | 178 | return new \Jaxon\Sentry\View\Facade($aRenderers, $sDefaultNamespace); |
@@ -186,7 +186,7 @@ discard block |
||
| 186 | 186 | */ |
| 187 | 187 | public function get($sClass) |
| 188 | 188 | { |
| 189 | - if($this->sentryContainer != null && $this->sentryContainer->has($sClass)) |
|
| 189 | + if ($this->sentryContainer != null && $this->sentryContainer->has($sClass)) |
|
| 190 | 190 | { |
| 191 | 191 | return $this->sentryContainer->get($sClass); |
| 192 | 192 | } |
@@ -471,14 +471,14 @@ discard block |
||
| 471 | 471 | $this->coreContainer['jaxon.sentry.view.base.' . $sId] = $xClosure; |
| 472 | 472 | |
| 473 | 473 | // Return the initialized view renderer |
| 474 | - $this->coreContainer['jaxon.sentry.view.' . $sId] = function ($c) use ($sId) { |
|
| 474 | + $this->coreContainer['jaxon.sentry.view.' . $sId] = function($c) use ($sId) { |
|
| 475 | 475 | // Get the defined renderer |
| 476 | 476 | $renderer = $c['jaxon.sentry.view.base.' . $sId]; |
| 477 | 477 | // Init the renderer with the template namespaces |
| 478 | 478 | $aNamespaces = $this->coreContainer['jaxon.view.data.namespaces']; |
| 479 | - if(key_exists($sId, $aNamespaces)) |
|
| 479 | + if (key_exists($sId, $aNamespaces)) |
|
| 480 | 480 | { |
| 481 | - foreach($aNamespaces[$sId] as $ns) |
|
| 481 | + foreach ($aNamespaces[$sId] as $ns) |
|
| 482 | 482 | { |
| 483 | 483 | $renderer->addNamespace($ns['namespace'], $ns['directory'], $ns['extension']); |
| 484 | 484 | } |
@@ -496,7 +496,7 @@ discard block |
||
| 496 | 496 | */ |
| 497 | 497 | public function getViewRenderer($sId = '') |
| 498 | 498 | { |
| 499 | - if(!$sId) |
|
| 499 | + if (!$sId) |
|
| 500 | 500 | { |
| 501 | 501 | // Return the view renderer facade |
| 502 | 502 | return $this->coreContainer['jaxon.sentry.view.renderer']; |
@@ -225,13 +225,11 @@ discard block |
||
| 225 | 225 | { |
| 226 | 226 | // The name of a request plugin is used as key in the plugin table |
| 227 | 227 | $this->aRequestPlugins[$xPlugin->getName()] = $xPlugin; |
| 228 | - } |
|
| 229 | - elseif($xPlugin instanceof Response) |
|
| 228 | + } elseif($xPlugin instanceof Response) |
|
| 230 | 229 | { |
| 231 | 230 | // The name of a response plugin is used as key in the plugin table |
| 232 | 231 | $this->aResponsePlugins[$xPlugin->getName()] = $xPlugin; |
| 233 | - } |
|
| 234 | - elseif(!$bIsConfirm && !$bIsAlert) |
|
| 232 | + } elseif(!$bIsConfirm && !$bIsAlert) |
|
| 235 | 233 | { |
| 236 | 234 | throw new \Jaxon\Exception\Error($this->trans('errors.register.invalid', array('name' => get_class($xPlugin)))); |
| 237 | 235 | } |
@@ -379,15 +377,13 @@ discard block |
||
| 379 | 377 | $sFunction = $xValue; |
| 380 | 378 | // Register a function without options |
| 381 | 379 | $this->register(Jaxon::USER_FUNCTION, $sFunction); |
| 382 | - } |
|
| 383 | - elseif(is_string($xKey) && is_array($xValue)) |
|
| 380 | + } elseif(is_string($xKey) && is_array($xValue)) |
|
| 384 | 381 | { |
| 385 | 382 | $sFunction = $xKey; |
| 386 | 383 | $aOptions = $xValue; |
| 387 | 384 | // Register a function with options |
| 388 | 385 | $this->register(Jaxon::USER_FUNCTION, $sFunction, $aOptions); |
| 389 | - } |
|
| 390 | - else |
|
| 386 | + } else |
|
| 391 | 387 | { |
| 392 | 388 | continue; |
| 393 | 389 | // Todo: throw an exception |
@@ -403,15 +399,13 @@ discard block |
||
| 403 | 399 | $sClass = $xValue; |
| 404 | 400 | // Register a class without options |
| 405 | 401 | $this->register(Jaxon::CALLABLE_CLASS, $sClass); |
| 406 | - } |
|
| 407 | - elseif(is_string($xKey) && is_array($xValue)) |
|
| 402 | + } elseif(is_string($xKey) && is_array($xValue)) |
|
| 408 | 403 | { |
| 409 | 404 | $sClass = $xKey; |
| 410 | 405 | $aOptions = $xValue; |
| 411 | 406 | // Register a class with options |
| 412 | 407 | $this->register(Jaxon::CALLABLE_CLASS, $sClass, $aOptions); |
| 413 | - } |
|
| 414 | - elseif(is_integer($xKey) && is_array($xValue)) |
|
| 408 | + } elseif(is_integer($xKey) && is_array($xValue)) |
|
| 415 | 409 | { |
| 416 | 410 | // The directory path is required |
| 417 | 411 | if(!key_exists('directory', $xValue)) |
@@ -438,8 +432,7 @@ discard block |
||
| 438 | 432 | } |
| 439 | 433 | // Register a class without options |
| 440 | 434 | $this->register(Jaxon::CALLABLE_DIR, $sDirectory, $aOptions); |
| 441 | - } |
|
| 442 | - else |
|
| 435 | + } else |
|
| 443 | 436 | { |
| 444 | 437 | continue; |
| 445 | 438 | // Todo: throw an exception |
@@ -739,8 +732,7 @@ discard block |
||
| 739 | 732 | 'sJsOptions' => $this->getOption('js.app.options'), |
| 740 | 733 | 'sUrl' => $sJsAppURI . $sOutFile, |
| 741 | 734 | )); |
| 742 | - } |
|
| 743 | - else |
|
| 735 | + } else |
|
| 744 | 736 | { |
| 745 | 737 | // The plugins scripts are wrapped with javascript tags |
| 746 | 738 | $sScript = $this->render('jaxon::plugins/wrapper.js', array( |
@@ -221,32 +221,32 @@ discard block |
||
| 221 | 221 | { |
| 222 | 222 | $bIsAlert = ($xPlugin instanceof Dialogs\Interfaces\Alert); |
| 223 | 223 | $bIsConfirm = ($xPlugin instanceof Dialogs\Interfaces\Confirm); |
| 224 | - if($xPlugin instanceof Request) |
|
| 224 | + if ($xPlugin instanceof Request) |
|
| 225 | 225 | { |
| 226 | 226 | // The name of a request plugin is used as key in the plugin table |
| 227 | 227 | $this->aRequestPlugins[$xPlugin->getName()] = $xPlugin; |
| 228 | 228 | } |
| 229 | - elseif($xPlugin instanceof Response) |
|
| 229 | + elseif ($xPlugin instanceof Response) |
|
| 230 | 230 | { |
| 231 | 231 | // The name of a response plugin is used as key in the plugin table |
| 232 | 232 | $this->aResponsePlugins[$xPlugin->getName()] = $xPlugin; |
| 233 | 233 | } |
| 234 | - elseif(!$bIsConfirm && !$bIsAlert) |
|
| 234 | + elseif (!$bIsConfirm && !$bIsAlert) |
|
| 235 | 235 | { |
| 236 | 236 | throw new \Jaxon\Exception\Error($this->trans('errors.register.invalid', array('name' => get_class($xPlugin)))); |
| 237 | 237 | } |
| 238 | 238 | // This plugin implements the Alert interface |
| 239 | - if($bIsAlert) |
|
| 239 | + if ($bIsAlert) |
|
| 240 | 240 | { |
| 241 | 241 | $this->setAlert($xPlugin); |
| 242 | 242 | } |
| 243 | 243 | // This plugin implements the Confirm interface |
| 244 | - if($bIsConfirm) |
|
| 244 | + if ($bIsConfirm) |
|
| 245 | 245 | { |
| 246 | 246 | $this->setConfirm($xPlugin); |
| 247 | 247 | } |
| 248 | 248 | // Register the plugin as an event listener |
| 249 | - if($xPlugin instanceof \Jaxon\Utils\Interfaces\EventListener) |
|
| 249 | + if ($xPlugin instanceof \Jaxon\Utils\Interfaces\EventListener) |
|
| 250 | 250 | { |
| 251 | 251 | $this->addEventListener($xPlugin); |
| 252 | 252 | } |
@@ -276,7 +276,7 @@ discard block |
||
| 276 | 276 | private function generateHash() |
| 277 | 277 | { |
| 278 | 278 | $sHash = jaxon()->getVersion(); |
| 279 | - foreach($this->aPlugins as $xPlugin) |
|
| 279 | + foreach ($this->aPlugins as $xPlugin) |
|
| 280 | 280 | { |
| 281 | 281 | $sHash .= $xPlugin->generateHash(); |
| 282 | 282 | } |
@@ -293,9 +293,9 @@ discard block |
||
| 293 | 293 | */ |
| 294 | 294 | public function canProcessRequest() |
| 295 | 295 | { |
| 296 | - foreach($this->aRequestPlugins as $xPlugin) |
|
| 296 | + foreach ($this->aRequestPlugins as $xPlugin) |
|
| 297 | 297 | { |
| 298 | - if($xPlugin->getName() != Jaxon::FILE_UPLOAD && $xPlugin->canProcessRequest()) |
|
| 298 | + if ($xPlugin->getName() != Jaxon::FILE_UPLOAD && $xPlugin->canProcessRequest()) |
|
| 299 | 299 | { |
| 300 | 300 | return true; |
| 301 | 301 | } |
@@ -314,12 +314,12 @@ discard block |
||
| 314 | 314 | public function processRequest() |
| 315 | 315 | { |
| 316 | 316 | $xUploadPlugin = $this->getRequestPlugin(Jaxon::FILE_UPLOAD); |
| 317 | - foreach($this->aRequestPlugins as $xPlugin) |
|
| 317 | + foreach ($this->aRequestPlugins as $xPlugin) |
|
| 318 | 318 | { |
| 319 | - if($xPlugin->getName() != Jaxon::FILE_UPLOAD && $xPlugin->canProcessRequest()) |
|
| 319 | + if ($xPlugin->getName() != Jaxon::FILE_UPLOAD && $xPlugin->canProcessRequest()) |
|
| 320 | 320 | { |
| 321 | 321 | // Process uploaded files |
| 322 | - if($xUploadPlugin != null) |
|
| 322 | + if ($xUploadPlugin != null) |
|
| 323 | 323 | { |
| 324 | 324 | $xUploadPlugin->processRequest(); |
| 325 | 325 | } |
@@ -344,7 +344,7 @@ discard block |
||
| 344 | 344 | */ |
| 345 | 345 | public function register($sType, $sCallable, $aOptions = []) |
| 346 | 346 | { |
| 347 | - if(!key_exists($sType, $this->aRequestPlugins)) |
|
| 347 | + if (!key_exists($sType, $this->aRequestPlugins)) |
|
| 348 | 348 | { |
| 349 | 349 | throw new \Jaxon\Exception\Error($this->trans('errors.register.plugin', ['name' => $sType])); |
| 350 | 350 | } |
@@ -372,15 +372,15 @@ discard block |
||
| 372 | 372 | { |
| 373 | 373 | // Register user functions |
| 374 | 374 | $aFunctionsConfig = $xAppConfig->getOption('functions', []); |
| 375 | - foreach($aFunctionsConfig as $xKey => $xValue) |
|
| 375 | + foreach ($aFunctionsConfig as $xKey => $xValue) |
|
| 376 | 376 | { |
| 377 | - if(is_integer($xKey) && is_string($xValue)) |
|
| 377 | + if (is_integer($xKey) && is_string($xValue)) |
|
| 378 | 378 | { |
| 379 | 379 | $sFunction = $xValue; |
| 380 | 380 | // Register a function without options |
| 381 | 381 | $this->register(Jaxon::USER_FUNCTION, $sFunction); |
| 382 | 382 | } |
| 383 | - elseif(is_string($xKey) && is_array($xValue)) |
|
| 383 | + elseif (is_string($xKey) && is_array($xValue)) |
|
| 384 | 384 | { |
| 385 | 385 | $sFunction = $xKey; |
| 386 | 386 | $aOptions = $xValue; |
@@ -396,25 +396,25 @@ discard block |
||
| 396 | 396 | |
| 397 | 397 | // Register classes and directories |
| 398 | 398 | $aClassesConfig = $xAppConfig->getOption('classes', []); |
| 399 | - foreach($aClassesConfig as $xKey => $xValue) |
|
| 399 | + foreach ($aClassesConfig as $xKey => $xValue) |
|
| 400 | 400 | { |
| 401 | - if(is_integer($xKey) && is_string($xValue)) |
|
| 401 | + if (is_integer($xKey) && is_string($xValue)) |
|
| 402 | 402 | { |
| 403 | 403 | $sClass = $xValue; |
| 404 | 404 | // Register a class without options |
| 405 | 405 | $this->register(Jaxon::CALLABLE_CLASS, $sClass); |
| 406 | 406 | } |
| 407 | - elseif(is_string($xKey) && is_array($xValue)) |
|
| 407 | + elseif (is_string($xKey) && is_array($xValue)) |
|
| 408 | 408 | { |
| 409 | 409 | $sClass = $xKey; |
| 410 | 410 | $aOptions = $xValue; |
| 411 | 411 | // Register a class with options |
| 412 | 412 | $this->register(Jaxon::CALLABLE_CLASS, $sClass, $aOptions); |
| 413 | 413 | } |
| 414 | - elseif(is_integer($xKey) && is_array($xValue)) |
|
| 414 | + elseif (is_integer($xKey) && is_array($xValue)) |
|
| 415 | 415 | { |
| 416 | 416 | // The directory path is required |
| 417 | - if(!key_exists('directory', $xValue)) |
|
| 417 | + if (!key_exists('directory', $xValue)) |
|
| 418 | 418 | { |
| 419 | 419 | continue; |
| 420 | 420 | // Todo: throw an exception |
@@ -422,17 +422,17 @@ discard block |
||
| 422 | 422 | // Registering a directory |
| 423 | 423 | $sDirectory = $xValue['directory']; |
| 424 | 424 | $aOptions = []; |
| 425 | - if(key_exists('options', $xValue) && |
|
| 425 | + if (key_exists('options', $xValue) && |
|
| 426 | 426 | is_array($xValue['options']) || is_string($xValue['options'])) |
| 427 | 427 | { |
| 428 | 428 | $aOptions = $xValue['options']; |
| 429 | 429 | } |
| 430 | 430 | // Setup directory options |
| 431 | - if(key_exists('namespace', $xValue)) |
|
| 431 | + if (key_exists('namespace', $xValue)) |
|
| 432 | 432 | { |
| 433 | 433 | $aOptions['namespace'] = $xValue['namespace']; |
| 434 | 434 | } |
| 435 | - if(key_exists('separator', $xValue)) |
|
| 435 | + if (key_exists('separator', $xValue)) |
|
| 436 | 436 | { |
| 437 | 437 | $aOptions['separator'] = $xValue['separator']; |
| 438 | 438 | } |
@@ -454,7 +454,7 @@ discard block |
||
| 454 | 454 | */ |
| 455 | 455 | private function getJsLibUri() |
| 456 | 456 | { |
| 457 | - if(!$this->hasOption('js.lib.uri')) |
|
| 457 | + if (!$this->hasOption('js.lib.uri')) |
|
| 458 | 458 | { |
| 459 | 459 | // return 'https://cdn.jsdelivr.net/jaxon/1.2.0/'; |
| 460 | 460 | return 'https://cdn.jsdelivr.net/gh/jaxon-php/[email protected]/dist/'; |
@@ -477,7 +477,7 @@ discard block |
||
| 477 | 477 | // The jsDelivr CDN only hosts minified files |
| 478 | 478 | // if(($this->getOption('js.app.minify')) || substr($this->getJsLibUri(), 0, $nLen) == $jsDelivrUri) |
| 479 | 479 | // Starting from version 2.0.0 of the js lib, the jsDelivr CDN also hosts non minified files. |
| 480 | - if(($this->getOption('js.app.minify'))) |
|
| 480 | + if (($this->getOption('js.app.minify'))) |
|
| 481 | 481 | { |
| 482 | 482 | return '.min.js'; |
| 483 | 483 | } |
@@ -494,7 +494,7 @@ discard block |
||
| 494 | 494 | // Check config options |
| 495 | 495 | // - The js.app.extern option must be set to true |
| 496 | 496 | // - The js.app.uri and js.app.dir options must be set to non null values |
| 497 | - if(!$this->getOption('js.app.extern') || |
|
| 497 | + if (!$this->getOption('js.app.extern') || |
|
| 498 | 498 | !$this->getOption('js.app.uri') || |
| 499 | 499 | !$this->getOption('js.app.dir')) |
| 500 | 500 | { |
@@ -503,7 +503,7 @@ discard block |
||
| 503 | 503 | // Check dir access |
| 504 | 504 | // - The js.app.dir must be writable |
| 505 | 505 | $sJsAppDir = $this->getOption('js.app.dir'); |
| 506 | - if(!is_dir($sJsAppDir) || !is_writable($sJsAppDir)) |
|
| 506 | + if (!is_dir($sJsAppDir) || !is_writable($sJsAppDir)) |
|
| 507 | 507 | { |
| 508 | 508 | return false; |
| 509 | 509 | } |
@@ -517,7 +517,7 @@ discard block |
||
| 517 | 517 | */ |
| 518 | 518 | private function setTemplateCacheDir() |
| 519 | 519 | { |
| 520 | - if($this->hasOption('core.template.cache_dir')) |
|
| 520 | + if ($this->hasOption('core.template.cache_dir')) |
|
| 521 | 521 | { |
| 522 | 522 | $this->setCacheDir($this->getOption('core.template.cache_dir')); |
| 523 | 523 | } |
@@ -539,7 +539,7 @@ discard block |
||
| 539 | 539 | |
| 540 | 540 | // Add component files to the javascript file array; |
| 541 | 541 | $aJsFiles = array($sJsCoreUrl); |
| 542 | - if($this->getOption('core.debug.on')) |
|
| 542 | + if ($this->getOption('core.debug.on')) |
|
| 543 | 543 | { |
| 544 | 544 | $aJsFiles[] = $sJsDebugUrl; |
| 545 | 545 | $aJsFiles[] = $sJsLanguageUrl; |
@@ -555,17 +555,17 @@ discard block |
||
| 555 | 555 | 'sJsOptions' => $this->getOption('js.app.options'), |
| 556 | 556 | 'aUrls' => $aJsFiles, |
| 557 | 557 | )); |
| 558 | - foreach($this->aResponsePlugins as $xPlugin) |
|
| 558 | + foreach ($this->aResponsePlugins as $xPlugin) |
|
| 559 | 559 | { |
| 560 | - if(($str = trim($xPlugin->getJs()))) |
|
| 560 | + if (($str = trim($xPlugin->getJs()))) |
|
| 561 | 561 | { |
| 562 | 562 | $sCode .= rtrim($str, " \n") . "\n"; |
| 563 | 563 | } |
| 564 | 564 | } |
| 565 | - foreach($this->aPackages as $sClass) |
|
| 565 | + foreach ($this->aPackages as $sClass) |
|
| 566 | 566 | { |
| 567 | 567 | $xPackage = jaxon()->di()->get($sClass); |
| 568 | - if(($str = trim($xPackage->js()))) |
|
| 568 | + if (($str = trim($xPackage->js()))) |
|
| 569 | 569 | { |
| 570 | 570 | $sCode .= rtrim($str, " \n") . "\n"; |
| 571 | 571 | } |
@@ -584,17 +584,17 @@ discard block |
||
| 584 | 584 | $this->setTemplateCacheDir(); |
| 585 | 585 | |
| 586 | 586 | $sCode = ''; |
| 587 | - foreach($this->aResponsePlugins as $xPlugin) |
|
| 587 | + foreach ($this->aResponsePlugins as $xPlugin) |
|
| 588 | 588 | { |
| 589 | - if(($str = trim($xPlugin->getCss()))) |
|
| 589 | + if (($str = trim($xPlugin->getCss()))) |
|
| 590 | 590 | { |
| 591 | 591 | $sCode .= rtrim($str, " \n") . "\n"; |
| 592 | 592 | } |
| 593 | 593 | } |
| 594 | - foreach($this->aPackages as $sClass) |
|
| 594 | + foreach ($this->aPackages as $sClass) |
|
| 595 | 595 | { |
| 596 | 596 | $xPackage = jaxon()->di()->get($sClass); |
| 597 | - if(($str = trim($xPackage->css()))) |
|
| 597 | + if (($str = trim($xPackage->css()))) |
|
| 598 | 598 | { |
| 599 | 599 | $sCode .= rtrim($str, " \n") . "\n"; |
| 600 | 600 | } |
@@ -658,17 +658,17 @@ discard block |
||
| 658 | 658 | private function getReadyScript() |
| 659 | 659 | { |
| 660 | 660 | $sPluginScript = ''; |
| 661 | - foreach($this->aResponsePlugins as $xPlugin) |
|
| 661 | + foreach ($this->aResponsePlugins as $xPlugin) |
|
| 662 | 662 | { |
| 663 | - if(($str = trim($xPlugin->getScript()))) |
|
| 663 | + if (($str = trim($xPlugin->getScript()))) |
|
| 664 | 664 | { |
| 665 | 665 | $sPluginScript .= "\n" . trim($str, " \n"); |
| 666 | 666 | } |
| 667 | 667 | } |
| 668 | - foreach($this->aPackages as $sClass) |
|
| 668 | + foreach ($this->aPackages as $sClass) |
|
| 669 | 669 | { |
| 670 | 670 | $xPackage = jaxon()->di()->get($sClass); |
| 671 | - if(($str = trim($xPackage->ready()))) |
|
| 671 | + if (($str = trim($xPackage->ready()))) |
|
| 672 | 672 | { |
| 673 | 673 | $sPluginScript .= "\n" . trim($str, " \n"); |
| 674 | 674 | } |
@@ -691,7 +691,7 @@ discard block |
||
| 691 | 691 | { |
| 692 | 692 | // Get the config and plugins scripts |
| 693 | 693 | $sScript = $this->getConfigScript() . "\n" . $this->getReadyScript() . "\n"; |
| 694 | - foreach($this->aRequestPlugins as $xPlugin) |
|
| 694 | + foreach ($this->aRequestPlugins as $xPlugin) |
|
| 695 | 695 | { |
| 696 | 696 | $sScript .= "\n" . trim($xPlugin->getScript(), " \n"); |
| 697 | 697 | } |
@@ -713,7 +713,7 @@ discard block |
||
| 713 | 713 | // Set the template engine cache dir |
| 714 | 714 | $this->setTemplateCacheDir(); |
| 715 | 715 | |
| 716 | - if($this->canExportJavascript()) |
|
| 716 | + if ($this->canExportJavascript()) |
|
| 717 | 717 | { |
| 718 | 718 | $sJsAppURI = rtrim($this->getOption('js.app.uri'), '/') . '/'; |
| 719 | 719 | $sJsAppDir = rtrim($this->getOption('js.app.dir'), '/') . '/'; |
@@ -722,13 +722,13 @@ discard block |
||
| 722 | 722 | $sHash = $this->generateHash(); |
| 723 | 723 | $sOutFile = $sHash . '.js'; |
| 724 | 724 | $sMinFile = $sHash . '.min.js'; |
| 725 | - if(!is_file($sJsAppDir . $sOutFile)) |
|
| 725 | + if (!is_file($sJsAppDir . $sOutFile)) |
|
| 726 | 726 | { |
| 727 | 727 | file_put_contents($sJsAppDir . $sOutFile, $this->getAllScripts()); |
| 728 | 728 | } |
| 729 | - if(($this->getOption('js.app.minify')) && !is_file($sJsAppDir . $sMinFile)) |
|
| 729 | + if (($this->getOption('js.app.minify')) && !is_file($sJsAppDir . $sMinFile)) |
|
| 730 | 730 | { |
| 731 | - if(($this->minify($sJsAppDir . $sOutFile, $sJsAppDir . $sMinFile))) |
|
| 731 | + if (($this->minify($sJsAppDir . $sOutFile, $sJsAppDir . $sMinFile))) |
|
| 732 | 732 | { |
| 733 | 733 | $sOutFile = $sMinFile; |
| 734 | 734 | } |
@@ -761,7 +761,7 @@ discard block |
||
| 761 | 761 | */ |
| 762 | 762 | public function getResponsePlugin($sName) |
| 763 | 763 | { |
| 764 | - if(array_key_exists($sName, $this->aResponsePlugins)) |
|
| 764 | + if (array_key_exists($sName, $this->aResponsePlugins)) |
|
| 765 | 765 | { |
| 766 | 766 | return $this->aResponsePlugins[$sName]; |
| 767 | 767 | } |
@@ -777,7 +777,7 @@ discard block |
||
| 777 | 777 | */ |
| 778 | 778 | public function getRequestPlugin($sName) |
| 779 | 779 | { |
| 780 | - if(array_key_exists($sName, $this->aRequestPlugins)) |
|
| 780 | + if (array_key_exists($sName, $this->aRequestPlugins)) |
|
| 781 | 781 | { |
| 782 | 782 | return $this->aRequestPlugins[$sName]; |
| 783 | 783 | } |
@@ -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\Config\Exception\File(jaxon_trans('config.errors.file.access', array('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\Config\Exception\File(jaxon_trans('config.errors.file.content', array('path' => $sConfigFile))); |
| 37 | 37 | } |
@@ -45,14 +45,14 @@ discard block |
||
| 45 | 45 | $sPrefix = trim((string)$sPrefix); |
| 46 | 46 | $nDepth = intval($nDepth); |
| 47 | 47 | // Check the max depth |
| 48 | - if($nDepth < 0 || $nDepth > 9) |
|
| 48 | + if ($nDepth < 0 || $nDepth > 9) |
|
| 49 | 49 | { |
| 50 | 50 | throw new \Jaxon\Config\Exception\Data(jaxon_trans('config.errors.data.depth', |
| 51 | 51 | array('key' => $sPrefix, 'depth' => $nDepth))); |
| 52 | 52 | } |
| 53 | - foreach($aOptions as $sName => $xOption) |
|
| 53 | + foreach ($aOptions as $sName => $xOption) |
|
| 54 | 54 | { |
| 55 | - if(is_int($sName)) |
|
| 55 | + if (is_int($sName)) |
|
| 56 | 56 | { |
| 57 | 57 | continue; |
| 58 | 58 | } |
@@ -62,7 +62,7 @@ discard block |
||
| 62 | 62 | // Save the value of this option |
| 63 | 63 | $this->aOptions[$sFullName] = $xOption; |
| 64 | 64 | // Save the values of its sub-options |
| 65 | - if(is_array($xOption)) |
|
| 65 | + if (is_array($xOption)) |
|
| 66 | 66 | { |
| 67 | 67 | // Recursively read the options in the array |
| 68 | 68 | $this->_setOptions($xOption, $sFullName, $nDepth + 1); |
@@ -84,9 +84,9 @@ discard block |
||
| 84 | 84 | $aKeys = explode('.', (string)$sKeys); |
| 85 | 85 | foreach ($aKeys as $sKey) |
| 86 | 86 | { |
| 87 | - if(($sKey)) |
|
| 87 | + if (($sKey)) |
|
| 88 | 88 | { |
| 89 | - if(!array_key_exists($sKey, $aOptions) || !is_array($aOptions[$sKey])) |
|
| 89 | + if (!array_key_exists($sKey, $aOptions) || !is_array($aOptions[$sKey])) |
|
| 90 | 90 | { |
| 91 | 91 | return; |
| 92 | 92 | } |
@@ -134,13 +134,12 @@ discard block |
||
| 134 | 134 | $sPrefix = rtrim($sPrefix, '.') . '.'; |
| 135 | 135 | $sPrefixLen = strlen($sPrefix); |
| 136 | 136 | $aOptions = []; |
| 137 | - foreach($this->aOptions as $sName => $xValue) |
|
| 137 | + foreach ($this->aOptions as $sName => $xValue) |
|
| 138 | 138 | { |
| 139 | - if(substr($sName, 0, $sPrefixLen) == $sPrefix) |
|
| 139 | + if (substr($sName, 0, $sPrefixLen) == $sPrefix) |
|
| 140 | 140 | { |
| 141 | 141 | $iNextDotPos = strpos($sName, '.', $sPrefixLen); |
| 142 | - $sOptionName = $iNextDotPos === false ? substr($sName, $sPrefixLen) : |
|
| 143 | - substr($sName, $sPrefixLen, $iNextDotPos - $sPrefixLen); |
|
| 142 | + $sOptionName = $iNextDotPos === false ? substr($sName, $sPrefixLen) : substr($sName, $sPrefixLen, $iNextDotPos - $sPrefixLen); |
|
| 144 | 143 | $aOptions[$sOptionName] = $sPrefix . $sOptionName; |
| 145 | 144 | } |
| 146 | 145 | } |