@@ -97,18 +97,18 @@ |
||
| 97 | 97 | // Get the namespace name |
| 98 | 98 | $sNamespace = ''; |
| 99 | 99 | $nSeparatorPosition = strrpos($sTemplate, '::'); |
| 100 | - if($nSeparatorPosition !== false) |
|
| 100 | + if ($nSeparatorPosition !== false) |
|
| 101 | 101 | { |
| 102 | 102 | $sNamespace = substr($sTemplate, 0, $nSeparatorPosition); |
| 103 | 103 | $sTemplate = substr($sTemplate, $nSeparatorPosition + 2); |
| 104 | 104 | } |
| 105 | 105 | // The default namespace is 'jaxon' |
| 106 | - if(!($sNamespace = trim($sNamespace))) |
|
| 106 | + if (!($sNamespace = trim($sNamespace))) |
|
| 107 | 107 | { |
| 108 | 108 | $sNamespace = 'jaxon'; |
| 109 | 109 | } |
| 110 | 110 | // Check if the namespace is defined |
| 111 | - if(!isset($this->aNamespaces[$sNamespace])) |
|
| 111 | + if (!isset($this->aNamespaces[$sNamespace])) |
|
| 112 | 112 | { |
| 113 | 113 | return ''; |
| 114 | 114 | } |
@@ -34,7 +34,7 @@ |
||
| 34 | 34 | public function __construct(Engine $engine, array $aVars) |
| 35 | 35 | { |
| 36 | 36 | $this->__engine__ = $engine; |
| 37 | - foreach($aVars as $sName => $xValue) |
|
| 37 | + foreach ($aVars as $sName => $xValue) |
|
| 38 | 38 | { |
| 39 | 39 | $sName = (string)$sName; |
| 40 | 40 | $this->$sName = $xValue; |
@@ -39,11 +39,11 @@ discard block |
||
| 39 | 39 | */ |
| 40 | 40 | private function setScheme(array $server) |
| 41 | 41 | { |
| 42 | - if(isset($this->aUrl['scheme'])) |
|
| 42 | + if (isset($this->aUrl['scheme'])) |
|
| 43 | 43 | { |
| 44 | 44 | return; |
| 45 | 45 | } |
| 46 | - if(isset($server['HTTP_SCHEME'])) |
|
| 46 | + if (isset($server['HTTP_SCHEME'])) |
|
| 47 | 47 | { |
| 48 | 48 | $this->aUrl['scheme'] = $server['HTTP_SCHEME']; |
| 49 | 49 | return; |
@@ -61,11 +61,11 @@ discard block |
||
| 61 | 61 | */ |
| 62 | 62 | private function setHostFromServer(array $server, string $sKey) |
| 63 | 63 | { |
| 64 | - if(isset($this->aUrl['host']) && isset($server[$sKey])) |
|
| 64 | + if (isset($this->aUrl['host']) && isset($server[$sKey])) |
|
| 65 | 65 | { |
| 66 | 66 | return; |
| 67 | 67 | } |
| 68 | - if(strpos($server[$sKey], ':') === false) |
|
| 68 | + if (strpos($server[$sKey], ':') === false) |
|
| 69 | 69 | { |
| 70 | 70 | $this->aUrl['host'] = $server[$sKey]; |
| 71 | 71 | return; |
@@ -84,11 +84,11 @@ discard block |
||
| 84 | 84 | $this->setHostFromServer($server, 'HTTP_X_FORWARDED_HOST'); |
| 85 | 85 | $this->setHostFromServer($server, 'HTTP_HOST'); |
| 86 | 86 | $this->setHostFromServer($server, 'SERVER_NAME'); |
| 87 | - if(empty($this->aUrl['host'])) |
|
| 87 | + if (empty($this->aUrl['host'])) |
|
| 88 | 88 | { |
| 89 | 89 | throw new UriException(); |
| 90 | 90 | } |
| 91 | - if(empty($this->aUrl['port']) && isset($server['SERVER_PORT'])) |
|
| 91 | + if (empty($this->aUrl['port']) && isset($server['SERVER_PORT'])) |
|
| 92 | 92 | { |
| 93 | 93 | $this->aUrl['port'] = $server['SERVER_PORT']; |
| 94 | 94 | } |
@@ -101,16 +101,16 @@ discard block |
||
| 101 | 101 | */ |
| 102 | 102 | private function setPath(array $server) |
| 103 | 103 | { |
| 104 | - if(isset($this->aUrl['path']) && strlen(basename($this->aUrl['path'])) === 0) |
|
| 104 | + if (isset($this->aUrl['path']) && strlen(basename($this->aUrl['path'])) === 0) |
|
| 105 | 105 | { |
| 106 | 106 | unset($this->aUrl['path']); |
| 107 | 107 | } |
| 108 | - if(isset($this->aUrl['path'])) |
|
| 108 | + if (isset($this->aUrl['path'])) |
|
| 109 | 109 | { |
| 110 | 110 | return; |
| 111 | 111 | } |
| 112 | 112 | $aPath = parse_url($server['PATH_INFO'] ?? $server['PHP_SELF']); |
| 113 | - if(isset($aPath['path'])) |
|
| 113 | + if (isset($aPath['path'])) |
|
| 114 | 114 | { |
| 115 | 115 | $this->aUrl['path'] = str_replace(['"', "'", '<', '>'], ['%22', '%27', '%3C', '%3E'], $aPath['path']); |
| 116 | 116 | } |
@@ -121,12 +121,12 @@ discard block |
||
| 121 | 121 | */ |
| 122 | 122 | private function getUser(): string |
| 123 | 123 | { |
| 124 | - if(empty($this->aUrl['user'])) |
|
| 124 | + if (empty($this->aUrl['user'])) |
|
| 125 | 125 | { |
| 126 | 126 | return ''; |
| 127 | 127 | } |
| 128 | 128 | $sUrl = $this->aUrl['user']; |
| 129 | - if(isset($this->aUrl['pass'])) |
|
| 129 | + if (isset($this->aUrl['pass'])) |
|
| 130 | 130 | { |
| 131 | 131 | $sUrl .= ':' . $this->aUrl['pass']; |
| 132 | 132 | } |
@@ -138,7 +138,7 @@ discard block |
||
| 138 | 138 | */ |
| 139 | 139 | private function getPort(): string |
| 140 | 140 | { |
| 141 | - if(isset($this->aUrl['port']) && |
|
| 141 | + if (isset($this->aUrl['port']) && |
|
| 142 | 142 | (($this->aUrl['scheme'] === 'http' && $this->aUrl['port'] != 80) || |
| 143 | 143 | ($this->aUrl['scheme'] === 'https' && $this->aUrl['port'] != 443))) |
| 144 | 144 | { |
@@ -154,7 +154,7 @@ discard block |
||
| 154 | 154 | */ |
| 155 | 155 | private function setQuery(array $server) |
| 156 | 156 | { |
| 157 | - if(empty($this->aUrl['query'])) |
|
| 157 | + if (empty($this->aUrl['query'])) |
|
| 158 | 158 | { |
| 159 | 159 | $this->aUrl['query'] = empty($server['QUERY_STRING']) ? '' : $server['QUERY_STRING']; |
| 160 | 160 | } |
@@ -165,14 +165,14 @@ discard block |
||
| 165 | 165 | */ |
| 166 | 166 | private function getQuery(): string |
| 167 | 167 | { |
| 168 | - if(empty($this->aUrl['query'])) |
|
| 168 | + if (empty($this->aUrl['query'])) |
|
| 169 | 169 | { |
| 170 | 170 | return ''; |
| 171 | 171 | } |
| 172 | 172 | $aQueries = explode("&", $this->aUrl['query']); |
| 173 | - foreach($aQueries as $sKey => $sQuery) |
|
| 173 | + foreach ($aQueries as $sKey => $sQuery) |
|
| 174 | 174 | { |
| 175 | - if(substr($sQuery, 0, 11) === 'jxnGenerate') |
|
| 175 | + if (substr($sQuery, 0, 11) === 'jxnGenerate') |
|
| 176 | 176 | { |
| 177 | 177 | unset($aQueries[$sKey]); |
| 178 | 178 | } |
@@ -192,7 +192,7 @@ discard block |
||
| 192 | 192 | { |
| 193 | 193 | $this->aUrl = []; |
| 194 | 194 | // Try to get the request URL |
| 195 | - if(isset($server['REQUEST_URI'])) |
|
| 195 | + if (isset($server['REQUEST_URI'])) |
|
| 196 | 196 | { |
| 197 | 197 | $sUri = str_replace(['"', "'", '<', '>'], ['%22', '%27', '%3C', '%3E'], $server['REQUEST_URI']); |
| 198 | 198 | $this->aUrl = parse_url($sUri); |
@@ -45,7 +45,7 @@ discard block |
||
| 45 | 45 | */ |
| 46 | 46 | public function __construct(string $sDefaultLocale) |
| 47 | 47 | { |
| 48 | - if(($sDefaultLocale)) |
|
| 48 | + if (($sDefaultLocale)) |
|
| 49 | 49 | { |
| 50 | 50 | $this->sDefaultLocale = $sDefaultLocale; |
| 51 | 51 | } |
@@ -62,11 +62,11 @@ discard block |
||
| 62 | 62 | */ |
| 63 | 63 | private function _loadTranslations(string $sLanguage, string $sPrefix, array $aTranslations) |
| 64 | 64 | { |
| 65 | - foreach($aTranslations as $sName => $xTranslation) |
|
| 65 | + foreach ($aTranslations as $sName => $xTranslation) |
|
| 66 | 66 | { |
| 67 | 67 | $sName = trim($sName); |
| 68 | 68 | $sName = ($sPrefix) ? $sPrefix . '.' . $sName : $sName; |
| 69 | - if(is_array($xTranslation)) |
|
| 69 | + if (is_array($xTranslation)) |
|
| 70 | 70 | { |
| 71 | 71 | // Recursively read the translations in the array |
| 72 | 72 | $this->_loadTranslations($sLanguage, $sName, $xTranslation); |
@@ -89,17 +89,17 @@ discard block |
||
| 89 | 89 | */ |
| 90 | 90 | public function loadTranslations(string $sFilePath, string $sLanguage) |
| 91 | 91 | { |
| 92 | - if(!file_exists($sFilePath)) |
|
| 92 | + if (!file_exists($sFilePath)) |
|
| 93 | 93 | { |
| 94 | 94 | return; |
| 95 | 95 | } |
| 96 | 96 | $aTranslations = require($sFilePath); |
| 97 | - if(!is_array($aTranslations)) |
|
| 97 | + if (!is_array($aTranslations)) |
|
| 98 | 98 | { |
| 99 | 99 | return; |
| 100 | 100 | } |
| 101 | 101 | // Load the translations |
| 102 | - if(!isset($this->aTranslations[$sLanguage])) |
|
| 102 | + if (!isset($this->aTranslations[$sLanguage])) |
|
| 103 | 103 | { |
| 104 | 104 | $this->aTranslations[$sLanguage] = []; |
| 105 | 105 | } |
@@ -118,16 +118,16 @@ discard block |
||
| 118 | 118 | public function trans(string $sText, array $aPlaceHolders = [], string $sLanguage = ''): string |
| 119 | 119 | { |
| 120 | 120 | $sText = trim($sText); |
| 121 | - if(!$sLanguage) |
|
| 121 | + if (!$sLanguage) |
|
| 122 | 122 | { |
| 123 | 123 | $sLanguage = $this->sDefaultLocale; |
| 124 | 124 | } |
| 125 | - if(!isset($this->aTranslations[$sLanguage][$sLanguage])) |
|
| 125 | + if (!isset($this->aTranslations[$sLanguage][$sLanguage])) |
|
| 126 | 126 | { |
| 127 | 127 | return $sText; |
| 128 | 128 | } |
| 129 | 129 | $sMessage = $this->aTranslations[$sLanguage][$sText]; |
| 130 | - if(($aPlaceHolders)) |
|
| 130 | + if (($aPlaceHolders)) |
|
| 131 | 131 | { |
| 132 | 132 | $aNames = array_map(function($sName) { |
| 133 | 133 | return ':' . $sName; |
@@ -70,8 +70,7 @@ |
||
| 70 | 70 | { |
| 71 | 71 | // Recursively read the translations in the array |
| 72 | 72 | $this->_loadTranslations($sLanguage, $sName, $xTranslation); |
| 73 | - } |
|
| 74 | - else |
|
| 73 | + } else |
|
| 75 | 74 | { |
| 76 | 75 | // Save this translation |
| 77 | 76 | $this->aTranslations[$sLanguage][$sName] = $xTranslation; |
@@ -37,13 +37,13 @@ |
||
| 37 | 37 | public static function read(string $sConfigFile): array |
| 38 | 38 | { |
| 39 | 39 | $sConfigFile = realpath($sConfigFile); |
| 40 | - if(!is_readable($sConfigFile)) |
|
| 40 | + if (!is_readable($sConfigFile)) |
|
| 41 | 41 | { |
| 42 | 42 | throw new FileAccess($sConfigFile); |
| 43 | 43 | } |
| 44 | 44 | $sFileContent = file_get_contents($sConfigFile); |
| 45 | 45 | $aConfigOptions = json_decode($sFileContent, true); |
| 46 | - if(!is_array($aConfigOptions)) |
|
| 46 | + if (!is_array($aConfigOptions)) |
|
| 47 | 47 | { |
| 48 | 48 | throw new FileContent($sConfigFile); |
| 49 | 49 | } |
@@ -39,16 +39,16 @@ |
||
| 39 | 39 | public static function read(string $sConfigFile): array |
| 40 | 40 | { |
| 41 | 41 | $sConfigFile = realpath($sConfigFile); |
| 42 | - if(!extension_loaded('yaml')) |
|
| 42 | + if (!extension_loaded('yaml')) |
|
| 43 | 43 | { |
| 44 | 44 | throw new YamlExtension(); |
| 45 | 45 | } |
| 46 | - if(!is_readable($sConfigFile)) |
|
| 46 | + if (!is_readable($sConfigFile)) |
|
| 47 | 47 | { |
| 48 | 48 | throw new FileAccess($sConfigFile); |
| 49 | 49 | } |
| 50 | 50 | $aConfigOptions = yaml_parse_file($sConfigFile); |
| 51 | - if(!is_array($aConfigOptions)) |
|
| 51 | + if (!is_array($aConfigOptions)) |
|
| 52 | 52 | { |
| 53 | 53 | throw new FileContent($sConfigFile); |
| 54 | 54 | } |
@@ -35,12 +35,12 @@ |
||
| 35 | 35 | public static function read(string $sConfigFile): array |
| 36 | 36 | { |
| 37 | 37 | $sConfigFile = realpath($sConfigFile); |
| 38 | - if(!is_readable($sConfigFile)) |
|
| 38 | + if (!is_readable($sConfigFile)) |
|
| 39 | 39 | { |
| 40 | 40 | throw new FileAccess($sConfigFile); |
| 41 | 41 | } |
| 42 | 42 | $aConfigOptions = include($sConfigFile); |
| 43 | - if(!is_array($aConfigOptions)) |
|
| 43 | + if (!is_array($aConfigOptions)) |
|
| 44 | 44 | { |
| 45 | 45 | throw new FileContent($sConfigFile); |
| 46 | 46 | } |
@@ -45,7 +45,7 @@ discard block |
||
| 45 | 45 | */ |
| 46 | 46 | public function __construct(array $aOptions = [], string $sKeys = '') |
| 47 | 47 | { |
| 48 | - if(count($aOptions) > 0) |
|
| 48 | + if (count($aOptions) > 0) |
|
| 49 | 49 | { |
| 50 | 50 | $this->setOptions($aOptions, $sKeys); |
| 51 | 51 | } |
@@ -78,13 +78,13 @@ discard block |
||
| 78 | 78 | { |
| 79 | 79 | $sPrefix = trim($sPrefix); |
| 80 | 80 | // Check the max depth |
| 81 | - if($nDepth < 0 || $nDepth > 9) |
|
| 81 | + if ($nDepth < 0 || $nDepth > 9) |
|
| 82 | 82 | { |
| 83 | 83 | throw new DataDepth($sPrefix, $nDepth); |
| 84 | 84 | } |
| 85 | - foreach($aOptions as $sName => $xOption) |
|
| 85 | + foreach ($aOptions as $sName => $xOption) |
|
| 86 | 86 | { |
| 87 | - if(is_int($sName)) |
|
| 87 | + if (is_int($sName)) |
|
| 88 | 88 | { |
| 89 | 89 | continue; |
| 90 | 90 | } |
@@ -94,7 +94,7 @@ discard block |
||
| 94 | 94 | // Save the value of this option |
| 95 | 95 | $this->aOptions[$sFullName] = $xOption; |
| 96 | 96 | // Save the values of its sub-options |
| 97 | - if(is_array($xOption)) |
|
| 97 | + if (is_array($xOption)) |
|
| 98 | 98 | { |
| 99 | 99 | // Recursively read the options in the array |
| 100 | 100 | $this->_setOptions($xOption, $sFullName, $nDepth + 1); |
@@ -115,11 +115,11 @@ discard block |
||
| 115 | 115 | { |
| 116 | 116 | // Find the config array in the input data |
| 117 | 117 | $aKeys = explode('.', $sKeys); |
| 118 | - foreach($aKeys as $sKey) |
|
| 118 | + foreach ($aKeys as $sKey) |
|
| 119 | 119 | { |
| 120 | - if(($sKey)) |
|
| 120 | + if (($sKey)) |
|
| 121 | 121 | { |
| 122 | - if(!isset($aOptions[$sKey]) || !is_array($aOptions[$sKey])) |
|
| 122 | + if (!isset($aOptions[$sKey]) || !is_array($aOptions[$sKey])) |
|
| 123 | 123 | { |
| 124 | 124 | return $this; |
| 125 | 125 | } |
@@ -168,14 +168,13 @@ discard block |
||
| 168 | 168 | $sPrefix = rtrim(trim($sPrefix), '.') . '.'; |
| 169 | 169 | $sPrefixLen = strlen($sPrefix); |
| 170 | 170 | $aOptions = []; |
| 171 | - foreach($this->aOptions as $sName => $xValue) |
|
| 171 | + foreach ($this->aOptions as $sName => $xValue) |
|
| 172 | 172 | { |
| 173 | - if(substr($sName, 0, $sPrefixLen) == $sPrefix) |
|
| 173 | + if (substr($sName, 0, $sPrefixLen) == $sPrefix) |
|
| 174 | 174 | { |
| 175 | 175 | $nNextDotPos = strpos($sName, '.', $sPrefixLen); |
| 176 | 176 | $sOptionName = $nNextDotPos === false ? |
| 177 | - substr($sName, $sPrefixLen) : |
|
| 178 | - substr($sName, $sPrefixLen, $nNextDotPos - $sPrefixLen); |
|
| 177 | + substr($sName, $sPrefixLen) : substr($sName, $sPrefixLen, $nNextDotPos - $sPrefixLen); |
|
| 179 | 178 | $aOptions[$sOptionName] = $sPrefix . $sOptionName; |
| 180 | 179 | } |
| 181 | 180 | } |
@@ -45,13 +45,13 @@ |
||
| 45 | 45 | */ |
| 46 | 46 | public function read(string $sConfigFile): array |
| 47 | 47 | { |
| 48 | - if(!($sConfigFile = trim($sConfigFile))) |
|
| 48 | + if (!($sConfigFile = trim($sConfigFile))) |
|
| 49 | 49 | { |
| 50 | 50 | return []; |
| 51 | 51 | } |
| 52 | 52 | |
| 53 | 53 | $sExt = pathinfo($sConfigFile, PATHINFO_EXTENSION); |
| 54 | - switch($sExt) |
|
| 54 | + switch ($sExt) |
|
| 55 | 55 | { |
| 56 | 56 | case 'php': |
| 57 | 57 | $aConfigOptions = File\Php::read($sConfigFile); |