@@ -133,7 +133,7 @@ discard block |
||
| 133 | 133 | { |
| 134 | 134 | $xDefault = $this->xConfig->getOption('upload.default.' . $sProperty); |
| 135 | 135 | $aAllowed = $this->xConfig->getOption('upload.files.' . $sName . '.' . $sProperty, $xDefault); |
| 136 | - if(is_array($aAllowed) && !in_array($sValue, $aAllowed)) |
|
| 136 | + if (is_array($aAllowed) && !in_array($sValue, $aAllowed)) |
|
| 137 | 137 | { |
| 138 | 138 | $this->sErrorMessage = $this->xTranslator->trans('errors.upload.' . $sField, [$sField => $sValue]); |
| 139 | 139 | return false; |
@@ -154,7 +154,7 @@ discard block |
||
| 154 | 154 | { |
| 155 | 155 | $xDefault = $this->xConfig->getOption('upload.default.' . $sProperty, 0); |
| 156 | 156 | $iSize = $this->xConfig->getOption('upload.files.' . $sName . '.' . $sProperty, $xDefault); |
| 157 | - if($iSize > 0 && ( |
|
| 157 | + if ($iSize > 0 && ( |
|
| 158 | 158 | ($sProperty == 'max-size' && $iFileSize > $iSize) || |
| 159 | 159 | ($sProperty == 'min-size' && $iFileSize < $iSize))) |
| 160 | 160 | { |
@@ -176,25 +176,25 @@ discard block |
||
| 176 | 176 | { |
| 177 | 177 | $this->sErrorMessage = ''; |
| 178 | 178 | // Verify the file extension |
| 179 | - if(!$this->validateFileProperty($sName, $aUploadedFile['type'], 'types', 'type')) |
|
| 179 | + if (!$this->validateFileProperty($sName, $aUploadedFile['type'], 'types', 'type')) |
|
| 180 | 180 | { |
| 181 | 181 | return false; |
| 182 | 182 | } |
| 183 | 183 | |
| 184 | 184 | // Verify the file extension |
| 185 | - if(!$this->validateFileProperty($sName, $aUploadedFile['extension'], 'extensions', 'extension')) |
|
| 185 | + if (!$this->validateFileProperty($sName, $aUploadedFile['extension'], 'extensions', 'extension')) |
|
| 186 | 186 | { |
| 187 | 187 | return false; |
| 188 | 188 | } |
| 189 | 189 | |
| 190 | 190 | // Verify the max size |
| 191 | - if(!$this->validateFileSize($sName, $aUploadedFile['size'], 'max-size')) |
|
| 191 | + if (!$this->validateFileSize($sName, $aUploadedFile['size'], 'max-size')) |
|
| 192 | 192 | { |
| 193 | 193 | return false; |
| 194 | 194 | } |
| 195 | 195 | |
| 196 | 196 | // Verify the min size |
| 197 | - if(!$this->validateFileSize($sName, $aUploadedFile['size'], 'min-size')) |
|
| 197 | + if (!$this->validateFileSize($sName, $aUploadedFile['size'], 'min-size')) |
|
| 198 | 198 | { |
| 199 | 199 | return false; |
| 200 | 200 | } |
@@ -64,7 +64,7 @@ discard block |
||
| 64 | 64 | { |
| 65 | 65 | // Make the template vars available, throught a Context object. |
| 66 | 66 | $xContext = new Context($this); |
| 67 | - foreach($aVars as $sName => $xValue) |
|
| 67 | + foreach ($aVars as $sName => $xValue) |
|
| 68 | 68 | { |
| 69 | 69 | $sName = (string)$sName; |
| 70 | 70 | $xContext->$sName = $xValue; |
@@ -94,18 +94,18 @@ discard block |
||
| 94 | 94 | // Get the namespace name |
| 95 | 95 | $sNamespace = ''; |
| 96 | 96 | $iSeparatorPosition = strrpos($sTemplate, '::'); |
| 97 | - if($iSeparatorPosition !== false) |
|
| 97 | + if ($iSeparatorPosition !== false) |
|
| 98 | 98 | { |
| 99 | 99 | $sNamespace = substr($sTemplate, 0, $iSeparatorPosition); |
| 100 | 100 | $sTemplate = substr($sTemplate, $iSeparatorPosition + 2); |
| 101 | 101 | } |
| 102 | 102 | // The default namespace is 'jaxon' |
| 103 | - if(!($sNamespace = trim($sNamespace))) |
|
| 103 | + if (!($sNamespace = trim($sNamespace))) |
|
| 104 | 104 | { |
| 105 | 105 | $sNamespace = 'jaxon'; |
| 106 | 106 | } |
| 107 | 107 | // Check if the namespace is defined |
| 108 | - if(!key_exists($sNamespace, $this->aNamespaces)) |
|
| 108 | + if (!key_exists($sNamespace, $this->aNamespaces)) |
|
| 109 | 109 | { |
| 110 | 110 | return ''; |
| 111 | 111 | } |
@@ -76,8 +76,7 @@ |
||
| 76 | 76 | { |
| 77 | 77 | // Save this translation |
| 78 | 78 | $this->aTranslations[$sLanguage][$sName] = $xTranslation; |
| 79 | - } |
|
| 80 | - else |
|
| 79 | + } else |
|
| 81 | 80 | { |
| 82 | 81 | // Recursively read the translations in the array |
| 83 | 82 | $this->_loadTranslations($sLanguage, $sName, $xTranslation); |
@@ -61,11 +61,11 @@ discard block |
||
| 61 | 61 | */ |
| 62 | 62 | private function _loadTranslations(string $sLanguage, string $sPrefix, array $aTranslations) |
| 63 | 63 | { |
| 64 | - foreach($aTranslations as $sName => $xTranslation) |
|
| 64 | + foreach ($aTranslations as $sName => $xTranslation) |
|
| 65 | 65 | { |
| 66 | 66 | $sName = trim($sName); |
| 67 | 67 | $sName = ($sPrefix) ? $sPrefix . '.' . $sName : $sName; |
| 68 | - if(!is_array($xTranslation)) |
|
| 68 | + if (!is_array($xTranslation)) |
|
| 69 | 69 | { |
| 70 | 70 | // Save this translation |
| 71 | 71 | $this->aTranslations[$sLanguage][$sName] = $xTranslation; |
@@ -88,17 +88,17 @@ discard block |
||
| 88 | 88 | */ |
| 89 | 89 | public function loadTranslations(string $sFilePath, string $sLanguage) |
| 90 | 90 | { |
| 91 | - if(!file_exists($sFilePath)) |
|
| 91 | + if (!file_exists($sFilePath)) |
|
| 92 | 92 | { |
| 93 | 93 | return; |
| 94 | 94 | } |
| 95 | 95 | $aTranslations = require($sFilePath); |
| 96 | - if(!is_array($aTranslations)) |
|
| 96 | + if (!is_array($aTranslations)) |
|
| 97 | 97 | { |
| 98 | 98 | return; |
| 99 | 99 | } |
| 100 | 100 | // Load the translations |
| 101 | - if(!array_key_exists($sLanguage, $this->aTranslations)) |
|
| 101 | + if (!array_key_exists($sLanguage, $this->aTranslations)) |
|
| 102 | 102 | { |
| 103 | 103 | $this->aTranslations[$sLanguage] = []; |
| 104 | 104 | } |
@@ -117,20 +117,20 @@ discard block |
||
| 117 | 117 | public function trans(string $sText, array $aPlaceHolders = [], string $sLanguage = '') |
| 118 | 118 | { |
| 119 | 119 | $sText = trim($sText); |
| 120 | - if(!$sLanguage) |
|
| 120 | + if (!$sLanguage) |
|
| 121 | 121 | { |
| 122 | 122 | $sLanguage = $this->xConfig->getOption('language', 'en'); |
| 123 | 123 | } |
| 124 | - if(!$sLanguage) |
|
| 124 | + if (!$sLanguage) |
|
| 125 | 125 | { |
| 126 | 126 | $sLanguage = $this->sDefaultLocale; |
| 127 | 127 | } |
| 128 | - if(!array_key_exists($sLanguage, $this->aTranslations) || !array_key_exists($sText, $this->aTranslations[$sLanguage])) |
|
| 128 | + if (!array_key_exists($sLanguage, $this->aTranslations) || !array_key_exists($sText, $this->aTranslations[$sLanguage])) |
|
| 129 | 129 | { |
| 130 | 130 | return $sText; |
| 131 | 131 | } |
| 132 | 132 | $message = $this->aTranslations[$sLanguage][$sText]; |
| 133 | - foreach($aPlaceHolders as $name => $value) |
|
| 133 | + foreach ($aPlaceHolders as $name => $value) |
|
| 134 | 134 | { |
| 135 | 135 | $message = str_replace(':' . $name, $value, $message); |
| 136 | 136 | } |
@@ -40,13 +40,13 @@ |
||
| 40 | 40 | */ |
| 41 | 41 | public function read(string $sConfigFile) |
| 42 | 42 | { |
| 43 | - if(!($sConfigFile = trim($sConfigFile))) |
|
| 43 | + if (!($sConfigFile = trim($sConfigFile))) |
|
| 44 | 44 | { |
| 45 | 45 | return []; |
| 46 | 46 | } |
| 47 | 47 | |
| 48 | 48 | $sExt = pathinfo($sConfigFile, PATHINFO_EXTENSION); |
| 49 | - switch($sExt) |
|
| 49 | + switch ($sExt) |
|
| 50 | 50 | { |
| 51 | 51 | case 'php': |
| 52 | 52 | $aConfigOptions = Php::read($sConfigFile); |
@@ -34,13 +34,13 @@ |
||
| 34 | 34 | public static function read(string $sConfigFile) |
| 35 | 35 | { |
| 36 | 36 | $sConfigFile = realpath($sConfigFile); |
| 37 | - if(!is_readable($sConfigFile)) |
|
| 37 | + if (!is_readable($sConfigFile)) |
|
| 38 | 38 | { |
| 39 | 39 | throw new Exception\FileAccess($sConfigFile); |
| 40 | 40 | } |
| 41 | 41 | $sFileContent = file_get_contents($sConfigFile); |
| 42 | 42 | $aConfigOptions = json_decode($sFileContent, true); |
| 43 | - if(!is_array($aConfigOptions)) |
|
| 43 | + if (!is_array($aConfigOptions)) |
|
| 44 | 44 | { |
| 45 | 45 | throw new Exception\FileContent($sConfigFile); |
| 46 | 46 | } |
@@ -32,12 +32,12 @@ |
||
| 32 | 32 | public static function read(string $sConfigFile) |
| 33 | 33 | { |
| 34 | 34 | $sConfigFile = realpath($sConfigFile); |
| 35 | - if(!is_readable($sConfigFile)) |
|
| 35 | + if (!is_readable($sConfigFile)) |
|
| 36 | 36 | { |
| 37 | 37 | throw new Exception\FileAccess($sConfigFile); |
| 38 | 38 | } |
| 39 | 39 | $aConfigOptions = include($sConfigFile); |
| 40 | - if(!is_array($aConfigOptions)) |
|
| 40 | + if (!is_array($aConfigOptions)) |
|
| 41 | 41 | { |
| 42 | 42 | throw new Exception\FileContent($sConfigFile); |
| 43 | 43 | } |
@@ -35,16 +35,16 @@ |
||
| 35 | 35 | public static function read(string $sConfigFile) |
| 36 | 36 | { |
| 37 | 37 | $sConfigFile = realpath($sConfigFile); |
| 38 | - if(!extension_loaded('yaml')) |
|
| 38 | + if (!extension_loaded('yaml')) |
|
| 39 | 39 | { |
| 40 | 40 | throw new Exception\YamlExtension(); |
| 41 | 41 | } |
| 42 | - if(!is_readable($sConfigFile)) |
|
| 42 | + if (!is_readable($sConfigFile)) |
|
| 43 | 43 | { |
| 44 | 44 | throw new Exception\FileAccess($sConfigFile); |
| 45 | 45 | } |
| 46 | 46 | $aConfigOptions = yaml_parse_file($sConfigFile); |
| 47 | - if(!is_array($aConfigOptions)) |
|
| 47 | + if (!is_array($aConfigOptions)) |
|
| 48 | 48 | { |
| 49 | 49 | throw new Exception\FileContent($sConfigFile); |
| 50 | 50 | } |
@@ -46,7 +46,7 @@ discard block |
||
| 46 | 46 | */ |
| 47 | 47 | public function __construct(array $aOptions = [], string $sKeys = '') |
| 48 | 48 | { |
| 49 | - if(count($aOptions) > 0) |
|
| 49 | + if (count($aOptions) > 0) |
|
| 50 | 50 | { |
| 51 | 51 | $this->setOptions($aOptions, $sKeys); |
| 52 | 52 | } |
@@ -80,13 +80,13 @@ discard block |
||
| 80 | 80 | $sPrefix = trim($sPrefix); |
| 81 | 81 | $nDepth = intval($nDepth); |
| 82 | 82 | // Check the max depth |
| 83 | - if($nDepth < 0 || $nDepth > 9) |
|
| 83 | + if ($nDepth < 0 || $nDepth > 9) |
|
| 84 | 84 | { |
| 85 | 85 | throw new Exception\DataDepth($sPrefix, $nDepth); |
| 86 | 86 | } |
| 87 | - foreach($aOptions as $sName => $xOption) |
|
| 87 | + foreach ($aOptions as $sName => $xOption) |
|
| 88 | 88 | { |
| 89 | - if(is_int($sName)) |
|
| 89 | + if (is_int($sName)) |
|
| 90 | 90 | { |
| 91 | 91 | continue; |
| 92 | 92 | } |
@@ -96,7 +96,7 @@ discard block |
||
| 96 | 96 | // Save the value of this option |
| 97 | 97 | $this->aOptions[$sFullName] = $xOption; |
| 98 | 98 | // Save the values of its sub-options |
| 99 | - if(is_array($xOption)) |
|
| 99 | + if (is_array($xOption)) |
|
| 100 | 100 | { |
| 101 | 101 | // Recursively read the options in the array |
| 102 | 102 | $this->_setOptions($xOption, $sFullName, $nDepth + 1); |
@@ -117,11 +117,11 @@ discard block |
||
| 117 | 117 | { |
| 118 | 118 | // Find the config array in the input data |
| 119 | 119 | $aKeys = explode('.', (string)$sKeys); |
| 120 | - foreach($aKeys as $sKey) |
|
| 120 | + foreach ($aKeys as $sKey) |
|
| 121 | 121 | { |
| 122 | - if(($sKey)) |
|
| 122 | + if (($sKey)) |
|
| 123 | 123 | { |
| 124 | - if(!array_key_exists($sKey, $aOptions) || !is_array($aOptions[$sKey])) |
|
| 124 | + if (!array_key_exists($sKey, $aOptions) || !is_array($aOptions[$sKey])) |
|
| 125 | 125 | { |
| 126 | 126 | return $this; |
| 127 | 127 | } |
@@ -170,14 +170,13 @@ discard block |
||
| 170 | 170 | $sPrefix = rtrim(trim($sPrefix), '.') . '.'; |
| 171 | 171 | $sPrefixLen = strlen($sPrefix); |
| 172 | 172 | $aOptions = []; |
| 173 | - foreach($this->aOptions as $sName => $xValue) |
|
| 173 | + foreach ($this->aOptions as $sName => $xValue) |
|
| 174 | 174 | { |
| 175 | - if(substr($sName, 0, $sPrefixLen) == $sPrefix) |
|
| 175 | + if (substr($sName, 0, $sPrefixLen) == $sPrefix) |
|
| 176 | 176 | { |
| 177 | 177 | $iNextDotPos = strpos($sName, '.', $sPrefixLen); |
| 178 | 178 | $sOptionName = $iNextDotPos === false ? |
| 179 | - substr($sName, $sPrefixLen) : |
|
| 180 | - substr($sName, $sPrefixLen, $iNextDotPos - $sPrefixLen); |
|
| 179 | + substr($sName, $sPrefixLen) : substr($sName, $sPrefixLen, $iNextDotPos - $sPrefixLen); |
|
| 181 | 180 | $aOptions[$sOptionName] = $sPrefix . $sOptionName; |
| 182 | 181 | } |
| 183 | 182 | } |
@@ -32,11 +32,11 @@ discard block |
||
| 32 | 32 | */ |
| 33 | 33 | private function setScheme(array &$aUrl) |
| 34 | 34 | { |
| 35 | - if(!empty($aUrl['scheme'])) |
|
| 35 | + if (!empty($aUrl['scheme'])) |
|
| 36 | 36 | { |
| 37 | 37 | return; |
| 38 | 38 | } |
| 39 | - if(!empty($_SERVER['HTTP_SCHEME'])) |
|
| 39 | + if (!empty($_SERVER['HTTP_SCHEME'])) |
|
| 40 | 40 | { |
| 41 | 41 | $aUrl['scheme'] = $_SERVER['HTTP_SCHEME']; |
| 42 | 42 | return; |
@@ -54,11 +54,11 @@ discard block |
||
| 54 | 54 | */ |
| 55 | 55 | private function setHostFromServer(array &$aUrl, string $sKey) |
| 56 | 56 | { |
| 57 | - if(!empty($aUrl['host']) && !empty($_SERVER[$sKey])) |
|
| 57 | + if (!empty($aUrl['host']) && !empty($_SERVER[$sKey])) |
|
| 58 | 58 | { |
| 59 | 59 | return; |
| 60 | 60 | } |
| 61 | - if(strpos($_SERVER[$sKey], ':') === false) |
|
| 61 | + if (strpos($_SERVER[$sKey], ':') === false) |
|
| 62 | 62 | { |
| 63 | 63 | $aUrl['host'] = $_SERVER[$sKey]; |
| 64 | 64 | return; |
@@ -77,11 +77,11 @@ discard block |
||
| 77 | 77 | $this->setHostFromServer($aUrl, 'HTTP_X_FORWARDED_HOST'); |
| 78 | 78 | $this->setHostFromServer($aUrl, 'HTTP_HOST'); |
| 79 | 79 | $this->setHostFromServer($aUrl, 'SERVER_NAME'); |
| 80 | - if(empty($aUrl['host'])) |
|
| 80 | + if (empty($aUrl['host'])) |
|
| 81 | 81 | { |
| 82 | 82 | throw new Error(); |
| 83 | 83 | } |
| 84 | - if(empty($aUrl['port']) && !empty($_SERVER['SERVER_PORT'])) |
|
| 84 | + if (empty($aUrl['port']) && !empty($_SERVER['SERVER_PORT'])) |
|
| 85 | 85 | { |
| 86 | 86 | $aUrl['port'] = $_SERVER['SERVER_PORT']; |
| 87 | 87 | } |
@@ -94,16 +94,16 @@ discard block |
||
| 94 | 94 | */ |
| 95 | 95 | private function setPath(array &$aUrl) |
| 96 | 96 | { |
| 97 | - if(!empty($aUrl['path']) && strlen(basename($aUrl['path'])) === 0) |
|
| 97 | + if (!empty($aUrl['path']) && strlen(basename($aUrl['path'])) === 0) |
|
| 98 | 98 | { |
| 99 | 99 | unset($aUrl['path']); |
| 100 | 100 | } |
| 101 | - if(!empty($aUrl['path'])) |
|
| 101 | + if (!empty($aUrl['path'])) |
|
| 102 | 102 | { |
| 103 | 103 | return; |
| 104 | 104 | } |
| 105 | 105 | $sPath = parse_url(!empty($_SERVER['PATH_INFO']) ? $_SERVER['PATH_INFO'] : $_SERVER['PHP_SELF']); |
| 106 | - if(isset($sPath['path'])) |
|
| 106 | + if (isset($sPath['path'])) |
|
| 107 | 107 | { |
| 108 | 108 | $aUrl['path'] = str_replace(['"', "'", '<', '>'], ['%22', '%27', '%3C', '%3E'], $sPath['path']); |
| 109 | 109 | } |
@@ -116,12 +116,12 @@ discard block |
||
| 116 | 116 | */ |
| 117 | 117 | private function getUser(array $aUrl) |
| 118 | 118 | { |
| 119 | - if(empty($aUrl['user'])) |
|
| 119 | + if (empty($aUrl['user'])) |
|
| 120 | 120 | { |
| 121 | 121 | return ''; |
| 122 | 122 | } |
| 123 | 123 | $sUrl = $aUrl['user']; |
| 124 | - if(!empty($aUrl['pass'])) |
|
| 124 | + if (!empty($aUrl['pass'])) |
|
| 125 | 125 | { |
| 126 | 126 | $sUrl .= ':' . $aUrl['pass']; |
| 127 | 127 | } |
@@ -135,7 +135,7 @@ discard block |
||
| 135 | 135 | */ |
| 136 | 136 | private function getPort(array $aUrl) |
| 137 | 137 | { |
| 138 | - if(!empty($aUrl['port']) && |
|
| 138 | + if (!empty($aUrl['port']) && |
|
| 139 | 139 | (($aUrl['scheme'] === 'http' && $aUrl['port'] != 80) || |
| 140 | 140 | ($aUrl['scheme'] === 'https' && $aUrl['port'] != 443))) |
| 141 | 141 | { |
@@ -151,7 +151,7 @@ discard block |
||
| 151 | 151 | */ |
| 152 | 152 | private function setQuery(array &$aUrl) |
| 153 | 153 | { |
| 154 | - if(empty($aUrl['query'])) |
|
| 154 | + if (empty($aUrl['query'])) |
|
| 155 | 155 | { |
| 156 | 156 | $aUrl['query'] = empty($_SERVER['QUERY_STRING']) ? '' : $_SERVER['QUERY_STRING']; |
| 157 | 157 | } |
@@ -164,14 +164,14 @@ discard block |
||
| 164 | 164 | */ |
| 165 | 165 | private function getQuery(array $aUrl) |
| 166 | 166 | { |
| 167 | - if(empty($aUrl['query'])) |
|
| 167 | + if (empty($aUrl['query'])) |
|
| 168 | 168 | { |
| 169 | 169 | return ''; |
| 170 | 170 | } |
| 171 | 171 | $aQueries = explode("&", $aUrl['query']); |
| 172 | - foreach($aQueries as $sKey => $sQuery) |
|
| 172 | + foreach ($aQueries as $sKey => $sQuery) |
|
| 173 | 173 | { |
| 174 | - if(substr($sQuery, 0, 11) === 'jxnGenerate') |
|
| 174 | + if (substr($sQuery, 0, 11) === 'jxnGenerate') |
|
| 175 | 175 | { |
| 176 | 176 | unset($aQueries[$sKey]); |
| 177 | 177 | } |
@@ -189,7 +189,7 @@ discard block |
||
| 189 | 189 | { |
| 190 | 190 | $aUrl = []; |
| 191 | 191 | // Try to get the request URL |
| 192 | - if(!empty($_SERVER['REQUEST_URI'])) |
|
| 192 | + if (!empty($_SERVER['REQUEST_URI'])) |
|
| 193 | 193 | { |
| 194 | 194 | $_SERVER['REQUEST_URI'] = str_replace(['"', "'", '<', '>'], ['%22', '%27', '%3C', '%3E'], $_SERVER['REQUEST_URI']); |
| 195 | 195 | $aUrl = parse_url($_SERVER['REQUEST_URI']); |