@@ -7,7 +7,7 @@ discard block |
||
| 7 | 7 | $text = $isCaps ? 'HELLO WORLD!' : 'Hello World!'; |
| 8 | 8 | $xResponse = jaxon()->newResponse(); |
| 9 | 9 | $xResponse->assign('div2', 'innerHTML', $text); |
| 10 | - if(($bNotify)) |
|
| 10 | + if (($bNotify)) |
|
| 11 | 11 | $xResponse->dialog->success("div2 text is now $text"); |
| 12 | 12 | } |
| 13 | 13 | |
@@ -15,7 +15,7 @@ discard block |
||
| 15 | 15 | { |
| 16 | 16 | $xResponse = jaxon()->newResponse(); |
| 17 | 17 | $xResponse->assign('div2', 'style.color', $sColor); |
| 18 | - if(($bNotify)) |
|
| 18 | + if (($bNotify)) |
|
| 19 | 19 | $xResponse->dialog->success("div2 color is now $sColor"); |
| 20 | 20 | } |
| 21 | 21 | |
@@ -7,16 +7,18 @@ |
||
| 7 | 7 | $text = $isCaps ? 'HELLO WORLD!' : 'Hello World!'; |
| 8 | 8 | $xResponse = jaxon()->newResponse(); |
| 9 | 9 | $xResponse->assign('div2', 'innerHTML', $text); |
| 10 | - if(($bNotify)) |
|
| 11 | - $xResponse->dialog->success("div2 text is now $text"); |
|
| 10 | + if(($bNotify)) { |
|
| 11 | + $xResponse->dialog->success("div2 text is now $text"); |
|
| 12 | + } |
|
| 12 | 13 | } |
| 13 | 14 | |
| 14 | 15 | public function setColor(string $sColor, bool $bNotify = true) |
| 15 | 16 | { |
| 16 | 17 | $xResponse = jaxon()->newResponse(); |
| 17 | 18 | $xResponse->assign('div2', 'style.color', $sColor); |
| 18 | - if(($bNotify)) |
|
| 19 | - $xResponse->dialog->success("div2 color is now $sColor"); |
|
| 19 | + if(($bNotify)) { |
|
| 20 | + $xResponse->dialog->success("div2 color is now $sColor"); |
|
| 21 | + } |
|
| 20 | 22 | } |
| 21 | 23 | |
| 22 | 24 | public function showDialog() |
@@ -4,7 +4,7 @@ |
||
| 4 | 4 | |
| 5 | 5 | $menus = menu_entries(); |
| 6 | 6 | $example = menu_current(); |
| 7 | -if(isset($menus[$example])) |
|
| 7 | +if (isset($menus[$example])) |
|
| 8 | 8 | { |
| 9 | 9 | renderExample($example); |
| 10 | 10 | exit(); |
@@ -4,7 +4,7 @@ |
||
| 4 | 4 | |
| 5 | 5 | $menus = menu_entries(); |
| 6 | 6 | $example = menu_current(); |
| 7 | -if(isset($menus[$example])) |
|
| 7 | +if (isset($menus[$example])) |
|
| 8 | 8 | { |
| 9 | 9 | require dirname(__DIR__) . "/examples/$example/code.php"; |
| 10 | 10 | |
@@ -43,16 +43,16 @@ discard block |
||
| 43 | 43 | */ |
| 44 | 44 | private function setScheme(array $aServerParams): void |
| 45 | 45 | { |
| 46 | - if(isset($this->aUrl['scheme'])) |
|
| 46 | + if (isset($this->aUrl['scheme'])) |
|
| 47 | 47 | { |
| 48 | 48 | return; |
| 49 | 49 | } |
| 50 | - if(isset($aServerParams['HTTP_SCHEME'])) |
|
| 50 | + if (isset($aServerParams['HTTP_SCHEME'])) |
|
| 51 | 51 | { |
| 52 | 52 | $this->aUrl['scheme'] = $aServerParams['HTTP_SCHEME']; |
| 53 | 53 | return; |
| 54 | 54 | } |
| 55 | - if((isset($aServerParams['HTTPS']) && strtolower($aServerParams['HTTPS']) === 'on') || |
|
| 55 | + if ((isset($aServerParams['HTTPS']) && strtolower($aServerParams['HTTPS']) === 'on') || |
|
| 56 | 56 | (isset($aServerParams['HTTP_X_FORWARDED_SSL']) && $aServerParams['HTTP_X_FORWARDED_SSL'] === 'on') || |
| 57 | 57 | (isset($aServerParams['HTTP_X_FORWARDED_PROTO']) && $aServerParams['HTTP_X_FORWARDED_PROTO'] === 'https')) |
| 58 | 58 | { |
@@ -72,11 +72,11 @@ discard block |
||
| 72 | 72 | */ |
| 73 | 73 | private function setHostFromServer(array $aServerParams, string $sKey): void |
| 74 | 74 | { |
| 75 | - if(isset($this->aUrl['host']) || empty($aServerParams[$sKey])) |
|
| 75 | + if (isset($this->aUrl['host']) || empty($aServerParams[$sKey])) |
|
| 76 | 76 | { |
| 77 | 77 | return; |
| 78 | 78 | } |
| 79 | - if(strpos($aServerParams[$sKey], ':') === false) |
|
| 79 | + if (strpos($aServerParams[$sKey], ':') === false) |
|
| 80 | 80 | { |
| 81 | 81 | $this->aUrl['host'] = $aServerParams[$sKey]; |
| 82 | 82 | return; |
@@ -95,11 +95,11 @@ discard block |
||
| 95 | 95 | $this->setHostFromServer($aServerParams, 'HTTP_X_FORWARDED_HOST'); |
| 96 | 96 | $this->setHostFromServer($aServerParams, 'HTTP_HOST'); |
| 97 | 97 | $this->setHostFromServer($aServerParams, 'SERVER_NAME'); |
| 98 | - if(empty($this->aUrl['host'])) |
|
| 98 | + if (empty($this->aUrl['host'])) |
|
| 99 | 99 | { |
| 100 | 100 | throw new UriException(); |
| 101 | 101 | } |
| 102 | - if(empty($this->aUrl['port']) && isset($aServerParams['SERVER_PORT'])) |
|
| 102 | + if (empty($this->aUrl['port']) && isset($aServerParams['SERVER_PORT'])) |
|
| 103 | 103 | { |
| 104 | 104 | $this->aUrl['port'] = $aServerParams['SERVER_PORT']; |
| 105 | 105 | } |
@@ -112,16 +112,16 @@ discard block |
||
| 112 | 112 | */ |
| 113 | 113 | private function setPath(array $aServerParams): void |
| 114 | 114 | { |
| 115 | - if(isset($this->aUrl['path']) && strlen(basename($this->aUrl['path'])) === 0) |
|
| 115 | + if (isset($this->aUrl['path']) && strlen(basename($this->aUrl['path'])) === 0) |
|
| 116 | 116 | { |
| 117 | 117 | unset($this->aUrl['path']); |
| 118 | 118 | } |
| 119 | - if(isset($this->aUrl['path'])) |
|
| 119 | + if (isset($this->aUrl['path'])) |
|
| 120 | 120 | { |
| 121 | 121 | return; |
| 122 | 122 | } |
| 123 | 123 | $aPath = parse_url($aServerParams['PATH_INFO'] ?? ($aServerParams['PHP_SELF'] ?? '')); |
| 124 | - if(isset($aPath['path'])) |
|
| 124 | + if (isset($aPath['path'])) |
|
| 125 | 125 | { |
| 126 | 126 | $this->aUrl['path'] = $aPath['path']; |
| 127 | 127 | } |
@@ -140,12 +140,12 @@ discard block |
||
| 140 | 140 | */ |
| 141 | 141 | private function getUser(): string |
| 142 | 142 | { |
| 143 | - if(empty($this->aUrl['user'])) |
|
| 143 | + if (empty($this->aUrl['user'])) |
|
| 144 | 144 | { |
| 145 | 145 | return ''; |
| 146 | 146 | } |
| 147 | 147 | $sUrl = $this->aUrl['user']; |
| 148 | - if(isset($this->aUrl['pass'])) |
|
| 148 | + if (isset($this->aUrl['pass'])) |
|
| 149 | 149 | { |
| 150 | 150 | $sUrl .= ':' . $this->aUrl['pass']; |
| 151 | 151 | } |
@@ -157,7 +157,7 @@ discard block |
||
| 157 | 157 | */ |
| 158 | 158 | private function getPort(): string |
| 159 | 159 | { |
| 160 | - if(isset($this->aUrl['port']) && |
|
| 160 | + if (isset($this->aUrl['port']) && |
|
| 161 | 161 | (($this->aUrl['scheme'] === 'http' && $this->aUrl['port'] != 80) || |
| 162 | 162 | ($this->aUrl['scheme'] === 'https' && $this->aUrl['port'] != 443))) |
| 163 | 163 | { |
@@ -173,7 +173,7 @@ discard block |
||
| 173 | 173 | */ |
| 174 | 174 | private function setQuery(array $aServerParams): void |
| 175 | 175 | { |
| 176 | - if(empty($this->aUrl['query'])) |
|
| 176 | + if (empty($this->aUrl['query'])) |
|
| 177 | 177 | { |
| 178 | 178 | $this->aUrl['query'] = $aServerParams['QUERY_STRING'] ?? ''; |
| 179 | 179 | } |
@@ -184,19 +184,19 @@ discard block |
||
| 184 | 184 | */ |
| 185 | 185 | private function getQuery(): string |
| 186 | 186 | { |
| 187 | - if(empty($this->aUrl['query'])) |
|
| 187 | + if (empty($this->aUrl['query'])) |
|
| 188 | 188 | { |
| 189 | 189 | return ''; |
| 190 | 190 | } |
| 191 | 191 | $aQueries = explode('&', $this->aUrl['query']); |
| 192 | - foreach($aQueries as $sKey => $sQuery) |
|
| 192 | + foreach ($aQueries as $sKey => $sQuery) |
|
| 193 | 193 | { |
| 194 | - if(substr($sQuery, 0, 11) === 'jxnGenerate') |
|
| 194 | + if (substr($sQuery, 0, 11) === 'jxnGenerate') |
|
| 195 | 195 | { |
| 196 | 196 | unset($aQueries[$sKey]); |
| 197 | 197 | } |
| 198 | 198 | } |
| 199 | - if(empty($aQueries)) |
|
| 199 | + if (empty($aQueries)) |
|
| 200 | 200 | { |
| 201 | 201 | return ''; |
| 202 | 202 | } |
@@ -215,7 +215,7 @@ discard block |
||
| 215 | 215 | { |
| 216 | 216 | $this->aUrl = []; |
| 217 | 217 | // Try to get the request URL |
| 218 | - if(isset($aServerParams['REQUEST_URI'])) |
|
| 218 | + if (isset($aServerParams['REQUEST_URI'])) |
|
| 219 | 219 | { |
| 220 | 220 | $this->aUrl = parse_url($aServerParams['REQUEST_URI']); |
| 221 | 221 | } |
@@ -255,17 +255,17 @@ discard block |
||
| 255 | 255 | { |
| 256 | 256 | $aQueryParts = []; |
| 257 | 257 | parse_str($sQueryPart, $aQueryParts); |
| 258 | - if(empty($aQueryParts)) |
|
| 258 | + if (empty($aQueryParts)) |
|
| 259 | 259 | { |
| 260 | 260 | // Couldn't break up the query, but there's one there. |
| 261 | 261 | // Possibly "http://url/page.html?query1234" type of query? |
| 262 | 262 | // Try to get data from the server environment var. |
| 263 | 263 | parse_str($aServerParams['QUERY_STRING'] ?? '', $aQueryParts); |
| 264 | 264 | } |
| 265 | - if(($aQueryParts)) |
|
| 265 | + if (($aQueryParts)) |
|
| 266 | 266 | { |
| 267 | 267 | $aNewQueryParts = []; |
| 268 | - foreach($aQueryParts as $sKey => $sValue) |
|
| 268 | + foreach ($aQueryParts as $sKey => $sValue) |
|
| 269 | 269 | { |
| 270 | 270 | $aNewQueryParts[] = $this->makeQueryPart($sQueryPart, $sKey, $sValue); |
| 271 | 271 | } |
@@ -288,13 +288,13 @@ discard block |
||
| 288 | 288 | // Can't just use parse_url() cos we could be dealing with a relative URL which parse_url() can't deal with. |
| 289 | 289 | $sURL = trim($sURL); |
| 290 | 290 | $nQueryStart = strpos($sURL, '?', strrpos($sURL, '/')); |
| 291 | - if($nQueryStart === false) |
|
| 291 | + if ($nQueryStart === false) |
|
| 292 | 292 | { |
| 293 | 293 | return $sURL; |
| 294 | 294 | } |
| 295 | 295 | $nQueryStart++; |
| 296 | 296 | $nQueryEnd = strpos($sURL, '#', $nQueryStart); |
| 297 | - if($nQueryEnd === false) |
|
| 297 | + if ($nQueryEnd === false) |
|
| 298 | 298 | { |
| 299 | 299 | $nQueryEnd = strlen($sURL); |
| 300 | 300 | } |
@@ -138,13 +138,13 @@ discard block |
||
| 138 | 138 | // Get the namespace name |
| 139 | 139 | $namespace = $this->__default_namespace__; |
| 140 | 140 | $separatorPosition = strrpos($template, '::'); |
| 141 | - if($separatorPosition !== false) |
|
| 141 | + if ($separatorPosition !== false) |
|
| 142 | 142 | { |
| 143 | 143 | $namespace = substr($template, 0, $separatorPosition); |
| 144 | 144 | $template = substr($template, $separatorPosition + 2); |
| 145 | 145 | } |
| 146 | 146 | // Check if the namespace is defined |
| 147 | - if(!isset($this->__namespaces__[$namespace])) |
|
| 147 | + if (!isset($this->__namespaces__[$namespace])) |
|
| 148 | 148 | { |
| 149 | 149 | return $template; |
| 150 | 150 | } |
@@ -165,13 +165,13 @@ discard block |
||
| 165 | 165 | { |
| 166 | 166 | // Get the template path |
| 167 | 167 | $templatePath = $this->__path(); |
| 168 | - if(!@is_readable($templatePath)) |
|
| 168 | + if (!@is_readable($templatePath)) |
|
| 169 | 169 | { |
| 170 | 170 | return ''; |
| 171 | 171 | } |
| 172 | 172 | |
| 173 | 173 | // Save the template properties. |
| 174 | - foreach($vars as $name => $value) |
|
| 174 | + foreach ($vars as $name => $value) |
|
| 175 | 175 | { |
| 176 | 176 | $this->__set((string)$name, $value); |
| 177 | 177 | } |
@@ -182,8 +182,7 @@ discard block |
||
| 182 | 182 | include $templatePath; |
| 183 | 183 | $content = ob_get_clean(); |
| 184 | 184 | |
| 185 | - return $this->__extends__ === null ? $content : |
|
| 186 | - // Render the extended template with the same properties. |
|
| 185 | + return $this->__extends__ === null ? $content : // Render the extended template with the same properties. |
|
| 187 | 186 | $this->__extends__->__render($this->__properties__); |
| 188 | 187 | }; |
| 189 | 188 | |
@@ -56,7 +56,7 @@ discard block |
||
| 56 | 56 | */ |
| 57 | 57 | public function setLocale(string $sLocale): void |
| 58 | 58 | { |
| 59 | - if(($sLocale = trim($sLocale))) |
|
| 59 | + if (($sLocale = trim($sLocale))) |
|
| 60 | 60 | { |
| 61 | 61 | $this->sDefaultLocale = $sLocale; |
| 62 | 62 | } |
@@ -73,11 +73,11 @@ discard block |
||
| 73 | 73 | */ |
| 74 | 74 | private function _loadTranslations(string $sLanguage, string $sPrefix, array $aTranslations): void |
| 75 | 75 | { |
| 76 | - foreach($aTranslations as $sKey => $xTranslation) |
|
| 76 | + foreach ($aTranslations as $sKey => $xTranslation) |
|
| 77 | 77 | { |
| 78 | 78 | $sKey = trim($sKey); |
| 79 | 79 | $sKey = ($sPrefix) ? $sPrefix . '.' . $sKey : $sKey; |
| 80 | - if(is_array($xTranslation)) |
|
| 80 | + if (is_array($xTranslation)) |
|
| 81 | 81 | { |
| 82 | 82 | // Recursively read the translations in the array |
| 83 | 83 | $this->_loadTranslations($sLanguage, $sKey, $xTranslation); |
@@ -100,18 +100,18 @@ discard block |
||
| 100 | 100 | */ |
| 101 | 101 | public function loadTranslations(string $sFilePath, string $sLanguage): bool |
| 102 | 102 | { |
| 103 | - if(!file_exists($sFilePath)) |
|
| 103 | + if (!file_exists($sFilePath)) |
|
| 104 | 104 | { |
| 105 | 105 | return false; |
| 106 | 106 | } |
| 107 | 107 | $aTranslations = require($sFilePath); |
| 108 | - if(!is_array($aTranslations)) |
|
| 108 | + if (!is_array($aTranslations)) |
|
| 109 | 109 | { |
| 110 | 110 | return false; |
| 111 | 111 | } |
| 112 | 112 | |
| 113 | 113 | // Load the translations |
| 114 | - if(!isset($this->aTranslations[$sLanguage])) |
|
| 114 | + if (!isset($this->aTranslations[$sLanguage])) |
|
| 115 | 115 | { |
| 116 | 116 | $this->aTranslations[$sLanguage] = []; |
| 117 | 117 | } |
@@ -133,16 +133,16 @@ discard block |
||
| 133 | 133 | public function trans(string $sText, array $aPlaceHolders = [], string $sLanguage = ''): string |
| 134 | 134 | { |
| 135 | 135 | $sText = trim($sText); |
| 136 | - if(empty($sLanguage)) |
|
| 136 | + if (empty($sLanguage)) |
|
| 137 | 137 | { |
| 138 | 138 | $sLanguage = $this->sDefaultLocale; |
| 139 | 139 | } |
| 140 | - if(!isset($this->aTranslations[$sLanguage][$sText])) |
|
| 140 | + if (!isset($this->aTranslations[$sLanguage][$sText])) |
|
| 141 | 141 | { |
| 142 | 142 | return $sText; |
| 143 | 143 | } |
| 144 | 144 | $sMessage = $this->aTranslations[$sLanguage][$sText]; |
| 145 | - if(!empty($aPlaceHolders)) |
|
| 145 | + if (!empty($aPlaceHolders)) |
|
| 146 | 146 | { |
| 147 | 147 | $aVars = array_map(function($sVar) { |
| 148 | 148 | return ':' . $sVar; |
@@ -162,16 +162,16 @@ discard block |
||
| 162 | 162 | */ |
| 163 | 163 | public function translations(string $sKey, string $sLanguage = ''): array |
| 164 | 164 | { |
| 165 | - if(empty($sLanguage)) |
|
| 165 | + if (empty($sLanguage)) |
|
| 166 | 166 | { |
| 167 | 167 | $sLanguage = $this->sDefaultLocale; |
| 168 | 168 | } |
| 169 | 169 | $aKeys = explode('.', $sKey); |
| 170 | 170 | |
| 171 | 171 | $aTranslations = $this->aRawTranslations[$sLanguage]; |
| 172 | - foreach($aKeys as $sKey) |
|
| 172 | + foreach ($aKeys as $sKey) |
|
| 173 | 173 | { |
| 174 | - if($sKey !== '') |
|
| 174 | + if ($sKey !== '') |
|
| 175 | 175 | { |
| 176 | 176 | $aTranslations = $aTranslations[$sKey] ?? []; |
| 177 | 177 | } |
@@ -81,8 +81,7 @@ |
||
| 81 | 81 | { |
| 82 | 82 | // Recursively read the translations in the array |
| 83 | 83 | $this->_loadTranslations($sLanguage, $sKey, $xTranslation); |
| 84 | - } |
|
| 85 | - else |
|
| 84 | + } else |
|
| 86 | 85 | { |
| 87 | 86 | // Save this translation |
| 88 | 87 | $this->aTranslations[$sLanguage][$sKey] = $xTranslation; |
@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | { |
| 38 | 38 | return file_get_contents($sPath); |
| 39 | 39 | } |
| 40 | - catch(Exception $e) |
|
| 40 | + catch (Exception $e) |
|
| 41 | 41 | { |
| 42 | 42 | return false; |
| 43 | 43 | } |
@@ -56,7 +56,7 @@ discard block |
||
| 56 | 56 | { |
| 57 | 57 | return Minifier::minify($sCode); |
| 58 | 58 | } |
| 59 | - catch(Exception $e) |
|
| 59 | + catch (Exception $e) |
|
| 60 | 60 | { |
| 61 | 61 | return false; |
| 62 | 62 | } |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | */ |
| 73 | 73 | public function minify(string $sJsFile, string $sMinFile): bool |
| 74 | 74 | { |
| 75 | - if(($sJsCode = $this->readFile($sJsFile)) === false || |
|
| 75 | + if (($sJsCode = $this->readFile($sJsFile)) === false || |
|
| 76 | 76 | ($sMinCode = $this->minifyCode($sJsCode)) === false) |
| 77 | 77 | { |
| 78 | 78 | return false; |
@@ -36,8 +36,7 @@ discard block |
||
| 36 | 36 | try |
| 37 | 37 | { |
| 38 | 38 | return file_get_contents($sPath); |
| 39 | - } |
|
| 40 | - catch(Exception $e) |
|
| 39 | + } catch(Exception $e) |
|
| 41 | 40 | { |
| 42 | 41 | return false; |
| 43 | 42 | } |
@@ -55,8 +54,7 @@ discard block |
||
| 55 | 54 | try |
| 56 | 55 | { |
| 57 | 56 | return Minifier::minify($sCode); |
| 58 | - } |
|
| 59 | - catch(Exception $e) |
|
| 57 | + } catch(Exception $e) |
|
| 60 | 58 | { |
| 61 | 59 | return false; |
| 62 | 60 | } |
@@ -35,7 +35,7 @@ |
||
| 35 | 35 | |
| 36 | 36 | protected function setUp(): void |
| 37 | 37 | { |
| 38 | - $this->sConfigDir = __DIR__ . '/../config'; |
|
| 38 | + $this->sConfigDir = __DIR__ . '/../config'; |
|
| 39 | 39 | $this->xConfigSetter = new ConfigSetter(); |
| 40 | 40 | $this->xConfigReader = new ConfigReader($this->xConfigSetter); |
| 41 | 41 | $this->xConfig = $this->xConfigSetter->newConfig(['core' => ['language' => 'en']]); |
@@ -90,11 +90,11 @@ |
||
| 90 | 90 | $sKey = trim($sKey, ' .'); |
| 91 | 91 | $aKeys = Value::explodeName($sKey); |
| 92 | 92 | $aValues = $this->aValues; |
| 93 | - foreach($aKeys as $_sKey) |
|
| 93 | + foreach ($aKeys as $_sKey) |
|
| 94 | 94 | { |
| 95 | 95 | $aValues = $aValues[$_sKey] ?? []; |
| 96 | 96 | } |
| 97 | - if(!Value::containsOptions($aValues)) |
|
| 97 | + if (!Value::containsOptions($aValues)) |
|
| 98 | 98 | { |
| 99 | 99 | return []; |
| 100 | 100 | } |