@@ -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 | } |
@@ -26,9 +26,9 @@ discard block |
||
26 | 26 | */ |
27 | 27 | private function getHostFromServer(array &$aURL, string $sKey) |
28 | 28 | { |
29 | - if(empty($aURL['host']) && !empty($_SERVER[$sKey])) |
|
29 | + if (empty($aURL['host']) && !empty($_SERVER[$sKey])) |
|
30 | 30 | { |
31 | - if(strpos($_SERVER[$sKey], ':') > 0) |
|
31 | + if (strpos($_SERVER[$sKey], ':') > 0) |
|
32 | 32 | { |
33 | 33 | list($aURL['host'], $aURL['port']) = explode(':', $_SERVER[$sKey]); |
34 | 34 | } |
@@ -49,20 +49,20 @@ discard block |
||
49 | 49 | { |
50 | 50 | $aURL = []; |
51 | 51 | // Try to get the request URL |
52 | - if(!empty($_SERVER['REQUEST_URI'])) |
|
52 | + if (!empty($_SERVER['REQUEST_URI'])) |
|
53 | 53 | { |
54 | 54 | $_SERVER['REQUEST_URI'] = str_replace(['"', "'", '<', '>'], ['%22', '%27', '%3C', '%3E'], $_SERVER['REQUEST_URI']); |
55 | 55 | $aURL = parse_url($_SERVER['REQUEST_URI']); |
56 | - if(!is_array($aURL)) |
|
56 | + if (!is_array($aURL)) |
|
57 | 57 | { |
58 | 58 | $aURL = []; |
59 | 59 | } |
60 | 60 | } |
61 | 61 | |
62 | 62 | // Fill in the empty values |
63 | - if(empty($aURL['scheme'])) |
|
63 | + if (empty($aURL['scheme'])) |
|
64 | 64 | { |
65 | - if(!empty($_SERVER['HTTP_SCHEME'])) |
|
65 | + if (!empty($_SERVER['HTTP_SCHEME'])) |
|
66 | 66 | { |
67 | 67 | $aURL['scheme'] = $_SERVER['HTTP_SCHEME']; |
68 | 68 | } |
@@ -75,24 +75,24 @@ discard block |
||
75 | 75 | $this->getHostFromServer($aURL, 'HTTP_X_FORWARDED_HOST'); |
76 | 76 | $this->getHostFromServer($aURL, 'HTTP_HOST'); |
77 | 77 | $this->getHostFromServer($aURL, 'SERVER_NAME'); |
78 | - if(empty($aURL['host'])) |
|
78 | + if (empty($aURL['host'])) |
|
79 | 79 | { |
80 | 80 | throw new \Jaxon\Exception\URI(); |
81 | 81 | } |
82 | 82 | |
83 | - if(empty($aURL['port']) && !empty($_SERVER['SERVER_PORT'])) |
|
83 | + if (empty($aURL['port']) && !empty($_SERVER['SERVER_PORT'])) |
|
84 | 84 | { |
85 | 85 | $aURL['port'] = $_SERVER['SERVER_PORT']; |
86 | 86 | } |
87 | 87 | |
88 | - if(!empty($aURL['path']) && strlen(basename($aURL['path'])) == 0) |
|
88 | + if (!empty($aURL['path']) && strlen(basename($aURL['path'])) == 0) |
|
89 | 89 | { |
90 | 90 | unset($aURL['path']); |
91 | 91 | } |
92 | 92 | |
93 | - if(empty($aURL['path'])) |
|
93 | + if (empty($aURL['path'])) |
|
94 | 94 | { |
95 | - if(!empty($_SERVER['PATH_INFO'])) |
|
95 | + if (!empty($_SERVER['PATH_INFO'])) |
|
96 | 96 | { |
97 | 97 | $sPath = parse_url($_SERVER['PATH_INFO']); |
98 | 98 | } |
@@ -100,29 +100,29 @@ discard block |
||
100 | 100 | { |
101 | 101 | $sPath = parse_url($_SERVER['PHP_SELF']); |
102 | 102 | } |
103 | - if(isset($sPath['path'])) |
|
103 | + if (isset($sPath['path'])) |
|
104 | 104 | { |
105 | 105 | $aURL['path'] = str_replace(['"', "'", '<', '>'], ['%22', '%27', '%3C', '%3E'], $sPath['path']); |
106 | 106 | } |
107 | 107 | unset($sPath); |
108 | 108 | } |
109 | 109 | |
110 | - if(empty($aURL['query'])) |
|
110 | + if (empty($aURL['query'])) |
|
111 | 111 | { |
112 | 112 | $aURL['query'] = empty($_SERVER['QUERY_STRING']) ? '' : $_SERVER['QUERY_STRING']; |
113 | 113 | } |
114 | 114 | |
115 | - if(!empty($aURL['query'])) |
|
115 | + if (!empty($aURL['query'])) |
|
116 | 116 | { |
117 | 117 | $aURL['query'] = '?' . $aURL['query']; |
118 | 118 | } |
119 | 119 | |
120 | 120 | // Build the URL: Start with scheme, user and pass |
121 | 121 | $sURL = $aURL['scheme'] . '://'; |
122 | - if(!empty($aURL['user'])) |
|
122 | + if (!empty($aURL['user'])) |
|
123 | 123 | { |
124 | 124 | $sURL .= $aURL['user']; |
125 | - if(!empty($aURL['pass'])) |
|
125 | + if (!empty($aURL['pass'])) |
|
126 | 126 | { |
127 | 127 | $sURL .= ':' . $aURL['pass']; |
128 | 128 | } |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | $sURL .= $aURL['host']; |
134 | 134 | |
135 | 135 | // Add the port if needed |
136 | - if(!empty($aURL['port']) && |
|
136 | + if (!empty($aURL['port']) && |
|
137 | 137 | (($aURL['scheme'] == 'http' && $aURL['port'] != 80) || |
138 | 138 | ($aURL['scheme'] == 'https' && $aURL['port'] != 443))) |
139 | 139 | { |
@@ -148,13 +148,13 @@ discard block |
||
148 | 148 | |
149 | 149 | $aURL = explode("?", $sURL); |
150 | 150 | |
151 | - if(1 < count($aURL)) |
|
151 | + if (1 < count($aURL)) |
|
152 | 152 | { |
153 | 153 | $aQueries = explode("&", $aURL[1]); |
154 | 154 | |
155 | - foreach($aQueries as $sKey => $sQuery) |
|
155 | + foreach ($aQueries as $sKey => $sQuery) |
|
156 | 156 | { |
157 | - if("jxnGenerate" == substr($sQuery, 0, 11)) |
|
157 | + if ("jxnGenerate" == substr($sQuery, 0, 11)) |
|
158 | 158 | { |
159 | 159 | unset($aQueries[$sKey]); |
160 | 160 | } |
@@ -31,8 +31,7 @@ discard block |
||
31 | 31 | if(strpos($_SERVER[$sKey], ':') > 0) |
32 | 32 | { |
33 | 33 | list($aURL['host'], $aURL['port']) = explode(':', $_SERVER[$sKey]); |
34 | - } |
|
35 | - else |
|
34 | + } else |
|
36 | 35 | { |
37 | 36 | $aURL['host'] = $_SERVER[$sKey]; |
38 | 37 | } |
@@ -65,8 +64,7 @@ discard block |
||
65 | 64 | if(!empty($_SERVER['HTTP_SCHEME'])) |
66 | 65 | { |
67 | 66 | $aURL['scheme'] = $_SERVER['HTTP_SCHEME']; |
68 | - } |
|
69 | - else |
|
67 | + } else |
|
70 | 68 | { |
71 | 69 | $aURL['scheme'] = ((!empty($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) != 'off') ? 'https' : 'http'); |
72 | 70 | } |
@@ -95,8 +93,7 @@ discard block |
||
95 | 93 | if(!empty($_SERVER['PATH_INFO'])) |
96 | 94 | { |
97 | 95 | $sPath = parse_url($_SERVER['PATH_INFO']); |
98 | - } |
|
99 | - else |
|
96 | + } else |
|
100 | 97 | { |
101 | 98 | $sPath = parse_url($_SERVER['PHP_SELF']); |
102 | 99 | } |
@@ -68,11 +68,11 @@ discard block |
||
68 | 68 | */ |
69 | 69 | private function _loadTranslations(string $sLanguage, string $sPrefix, array $aTranslations) |
70 | 70 | { |
71 | - foreach($aTranslations as $sName => $xTranslation) |
|
71 | + foreach ($aTranslations as $sName => $xTranslation) |
|
72 | 72 | { |
73 | 73 | $sName = trim($sName); |
74 | 74 | $sName = ($sPrefix) ? $sPrefix . '.' . $sName : $sName; |
75 | - if(!is_array($xTranslation)) |
|
75 | + if (!is_array($xTranslation)) |
|
76 | 76 | { |
77 | 77 | // Save this translation |
78 | 78 | $this->aTranslations[$sLanguage][$sName] = $xTranslation; |
@@ -95,17 +95,17 @@ discard block |
||
95 | 95 | */ |
96 | 96 | public function loadTranslations(string $sFilePath, string $sLanguage) |
97 | 97 | { |
98 | - if(!file_exists($sFilePath)) |
|
98 | + if (!file_exists($sFilePath)) |
|
99 | 99 | { |
100 | 100 | return; |
101 | 101 | } |
102 | 102 | $aTranslations = require($sFilePath); |
103 | - if(!is_array($aTranslations)) |
|
103 | + if (!is_array($aTranslations)) |
|
104 | 104 | { |
105 | 105 | return; |
106 | 106 | } |
107 | 107 | // Load the translations |
108 | - if(!array_key_exists($sLanguage, $this->aTranslations)) |
|
108 | + if (!array_key_exists($sLanguage, $this->aTranslations)) |
|
109 | 109 | { |
110 | 110 | $this->aTranslations[$sLanguage] = []; |
111 | 111 | } |
@@ -124,20 +124,20 @@ discard block |
||
124 | 124 | public function trans(string $sText, array $aPlaceHolders = [], string $sLanguage = '') |
125 | 125 | { |
126 | 126 | $sText = trim($sText); |
127 | - if(!$sLanguage) |
|
127 | + if (!$sLanguage) |
|
128 | 128 | { |
129 | 129 | $sLanguage = $this->xConfig->getOption('language'); |
130 | 130 | } |
131 | - if(!$sLanguage) |
|
131 | + if (!$sLanguage) |
|
132 | 132 | { |
133 | 133 | $sLanguage = $this->sDefaultLocale; |
134 | 134 | } |
135 | - if(!array_key_exists($sLanguage, $this->aTranslations) || !array_key_exists($sText, $this->aTranslations[$sLanguage])) |
|
135 | + if (!array_key_exists($sLanguage, $this->aTranslations) || !array_key_exists($sText, $this->aTranslations[$sLanguage])) |
|
136 | 136 | { |
137 | 137 | return $sText; |
138 | 138 | } |
139 | 139 | $message = $this->aTranslations[$sLanguage][$sText]; |
140 | - foreach($aPlaceHolders as $name => $value) |
|
140 | + foreach ($aPlaceHolders as $name => $value) |
|
141 | 141 | { |
142 | 142 | $message = str_replace(':' . $name, $value, $message); |
143 | 143 | } |
@@ -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); |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | */ |
33 | 33 | public function __construct(array $aOptions = [], string $sKeys = '') |
34 | 34 | { |
35 | - if(count($aOptions) > 0) |
|
35 | + if (count($aOptions) > 0) |
|
36 | 36 | { |
37 | 37 | $this->setOptions($aOptions, $sKeys); |
38 | 38 | } |
@@ -66,13 +66,13 @@ discard block |
||
66 | 66 | $sPrefix = trim((string)$sPrefix); |
67 | 67 | $nDepth = intval($nDepth); |
68 | 68 | // Check the max depth |
69 | - if($nDepth < 0 || $nDepth > 9) |
|
69 | + if ($nDepth < 0 || $nDepth > 9) |
|
70 | 70 | { |
71 | 71 | throw new Exception\Data(jaxon_trans('errors.data.depth', ['key' => $sPrefix, 'depth' => $nDepth])); |
72 | 72 | } |
73 | - foreach($aOptions as $sName => $xOption) |
|
73 | + foreach ($aOptions as $sName => $xOption) |
|
74 | 74 | { |
75 | - if(is_int($sName)) |
|
75 | + if (is_int($sName)) |
|
76 | 76 | { |
77 | 77 | continue; |
78 | 78 | } |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | // Save the value of this option |
83 | 83 | $this->aOptions[$sFullName] = $xOption; |
84 | 84 | // Save the values of its sub-options |
85 | - if(is_array($xOption)) |
|
85 | + if (is_array($xOption)) |
|
86 | 86 | { |
87 | 87 | // Recursively read the options in the array |
88 | 88 | $this->_setOptions($xOption, $sFullName, $nDepth + 1); |
@@ -103,11 +103,11 @@ discard block |
||
103 | 103 | { |
104 | 104 | // Find the config array in the input data |
105 | 105 | $aKeys = explode('.', (string)$sKeys); |
106 | - foreach($aKeys as $sKey) |
|
106 | + foreach ($aKeys as $sKey) |
|
107 | 107 | { |
108 | - if(($sKey)) |
|
108 | + if (($sKey)) |
|
109 | 109 | { |
110 | - if(!array_key_exists($sKey, $aOptions) || !is_array($aOptions[$sKey])) |
|
110 | + if (!array_key_exists($sKey, $aOptions) || !is_array($aOptions[$sKey])) |
|
111 | 111 | { |
112 | 112 | return $this; |
113 | 113 | } |
@@ -156,14 +156,13 @@ discard block |
||
156 | 156 | $sPrefix = rtrim(trim($sPrefix), '.') . '.'; |
157 | 157 | $sPrefixLen = strlen($sPrefix); |
158 | 158 | $aOptions = []; |
159 | - foreach($this->aOptions as $sName => $xValue) |
|
159 | + foreach ($this->aOptions as $sName => $xValue) |
|
160 | 160 | { |
161 | - if(substr($sName, 0, $sPrefixLen) == $sPrefix) |
|
161 | + if (substr($sName, 0, $sPrefixLen) == $sPrefix) |
|
162 | 162 | { |
163 | 163 | $iNextDotPos = strpos($sName, '.', $sPrefixLen); |
164 | 164 | $sOptionName = $iNextDotPos === false ? |
165 | - substr($sName, $sPrefixLen) : |
|
166 | - substr($sName, $sPrefixLen, $iNextDotPos - $sPrefixLen); |
|
165 | + substr($sName, $sPrefixLen) : substr($sName, $sPrefixLen, $iNextDotPos - $sPrefixLen); |
|
167 | 166 | $aOptions[$sOptionName] = $sPrefix . $sOptionName; |
168 | 167 | } |
169 | 168 | } |
@@ -27,13 +27,13 @@ |
||
27 | 27 | public static function read(string $sConfigFile) |
28 | 28 | { |
29 | 29 | $sConfigFile = realpath($sConfigFile); |
30 | - if(!is_readable($sConfigFile)) |
|
30 | + if (!is_readable($sConfigFile)) |
|
31 | 31 | { |
32 | 32 | throw new Exception\File(jaxon_trans('errors.file.access', ['path' => $sConfigFile])); |
33 | 33 | } |
34 | 34 | $sFileContent = file_get_contents($sConfigFile); |
35 | 35 | $aConfigOptions = json_decode($sFileContent, true); |
36 | - if(!is_array($aConfigOptions)) |
|
36 | + if (!is_array($aConfigOptions)) |
|
37 | 37 | { |
38 | 38 | throw new Exception\File(jaxon_trans('errors.file.content', ['path' => $sConfigFile])); |
39 | 39 | } |
@@ -28,16 +28,16 @@ |
||
28 | 28 | public static function read(string $sConfigFile) |
29 | 29 | { |
30 | 30 | $sConfigFile = realpath($sConfigFile); |
31 | - if(!extension_loaded('yaml')) |
|
31 | + if (!extension_loaded('yaml')) |
|
32 | 32 | { |
33 | 33 | throw new Exception\Yaml(jaxon_trans('config.errors.yaml.install')); |
34 | 34 | } |
35 | - if(!is_readable($sConfigFile)) |
|
35 | + if (!is_readable($sConfigFile)) |
|
36 | 36 | { |
37 | 37 | throw new Exception\File(jaxon_trans('config.errors.file.access', ['path' => $sConfigFile])); |
38 | 38 | } |
39 | 39 | $aConfigOptions = yaml_parse_file($sConfigFile); |
40 | - if(!is_array($aConfigOptions)) |
|
40 | + if (!is_array($aConfigOptions)) |
|
41 | 41 | { |
42 | 42 | throw new Exception\File(jaxon_trans('config.errors.file.content', ['path' => $sConfigFile])); |
43 | 43 | } |
@@ -27,12 +27,12 @@ |
||
27 | 27 | public static function read(string $sConfigFile) |
28 | 28 | { |
29 | 29 | $sConfigFile = realpath($sConfigFile); |
30 | - if(!is_readable($sConfigFile)) |
|
30 | + if (!is_readable($sConfigFile)) |
|
31 | 31 | { |
32 | 32 | throw new Exception\File(jaxon_trans('errors.file.access', ['path' => $sConfigFile])); |
33 | 33 | } |
34 | 34 | $aConfigOptions = include($sConfigFile); |
35 | - if(!is_array($aConfigOptions)) |
|
35 | + if (!is_array($aConfigOptions)) |
|
36 | 36 | { |
37 | 37 | throw new Exception\File(jaxon_trans('errors.file.content', ['path' => $sConfigFile])); |
38 | 38 | } |
@@ -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); |