@@ -25,16 +25,16 @@ discard block |
||
25 | 25 | { |
26 | 26 | $aURL = []; |
27 | 27 | // Try to get the request URL |
28 | - if(!empty($_SERVER['REQUEST_URI'])) |
|
28 | + if (!empty($_SERVER['REQUEST_URI'])) |
|
29 | 29 | { |
30 | - $_SERVER['REQUEST_URI'] = str_replace(array('"',"'",'<','>'), array('%22','%27','%3C','%3E'), $_SERVER['REQUEST_URI']); |
|
30 | + $_SERVER['REQUEST_URI'] = str_replace(array('"', "'", '<', '>'), array('%22', '%27', '%3C', '%3E'), $_SERVER['REQUEST_URI']); |
|
31 | 31 | $aURL = parse_url($_SERVER['REQUEST_URI']); |
32 | 32 | } |
33 | 33 | |
34 | 34 | // Fill in the empty values |
35 | - if(empty($aURL['scheme'])) |
|
35 | + if (empty($aURL['scheme'])) |
|
36 | 36 | { |
37 | - if(!empty($_SERVER['HTTP_SCHEME'])) |
|
37 | + if (!empty($_SERVER['HTTP_SCHEME'])) |
|
38 | 38 | { |
39 | 39 | $aURL['scheme'] = $_SERVER['HTTP_SCHEME']; |
40 | 40 | } |
@@ -44,11 +44,11 @@ discard block |
||
44 | 44 | } |
45 | 45 | } |
46 | 46 | |
47 | - if(empty($aURL['host'])) |
|
47 | + if (empty($aURL['host'])) |
|
48 | 48 | { |
49 | - if(!empty($_SERVER['HTTP_X_FORWARDED_HOST'])) |
|
49 | + if (!empty($_SERVER['HTTP_X_FORWARDED_HOST'])) |
|
50 | 50 | { |
51 | - if(strpos($_SERVER['HTTP_X_FORWARDED_HOST'], ':') > 0) |
|
51 | + if (strpos($_SERVER['HTTP_X_FORWARDED_HOST'], ':') > 0) |
|
52 | 52 | { |
53 | 53 | list($aURL['host'], $aURL['port']) = explode(':', $_SERVER['HTTP_X_FORWARDED_HOST']); |
54 | 54 | } |
@@ -57,9 +57,9 @@ discard block |
||
57 | 57 | $aURL['host'] = $_SERVER['HTTP_X_FORWARDED_HOST']; |
58 | 58 | } |
59 | 59 | } |
60 | - elseif(!empty($_SERVER['HTTP_HOST'])) |
|
60 | + elseif (!empty($_SERVER['HTTP_HOST'])) |
|
61 | 61 | { |
62 | - if(strpos($_SERVER['HTTP_HOST'], ':') > 0) |
|
62 | + if (strpos($_SERVER['HTTP_HOST'], ':') > 0) |
|
63 | 63 | { |
64 | 64 | list($aURL['host'], $aURL['port']) = explode(':', $_SERVER['HTTP_HOST']); |
65 | 65 | } |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | $aURL['host'] = $_SERVER['HTTP_HOST']; |
69 | 69 | } |
70 | 70 | } |
71 | - elseif(!empty($_SERVER['SERVER_NAME'])) |
|
71 | + elseif (!empty($_SERVER['SERVER_NAME'])) |
|
72 | 72 | { |
73 | 73 | $aURL['host'] = $_SERVER['SERVER_NAME']; |
74 | 74 | } |
@@ -78,20 +78,20 @@ discard block |
||
78 | 78 | } |
79 | 79 | } |
80 | 80 | |
81 | - if(empty($aURL['port']) && !empty($_SERVER['SERVER_PORT'])) |
|
81 | + if (empty($aURL['port']) && !empty($_SERVER['SERVER_PORT'])) |
|
82 | 82 | { |
83 | 83 | $aURL['port'] = $_SERVER['SERVER_PORT']; |
84 | 84 | } |
85 | 85 | |
86 | - if(!empty($aURL['path']) && strlen(basename($aURL['path'])) == 0) |
|
86 | + if (!empty($aURL['path']) && strlen(basename($aURL['path'])) == 0) |
|
87 | 87 | { |
88 | 88 | unset($aURL['path']); |
89 | 89 | } |
90 | 90 | |
91 | - if(empty($aURL['path'])) |
|
91 | + if (empty($aURL['path'])) |
|
92 | 92 | { |
93 | 93 | $sPath = []; |
94 | - if(!empty($_SERVER['PATH_INFO'])) |
|
94 | + if (!empty($_SERVER['PATH_INFO'])) |
|
95 | 95 | { |
96 | 96 | $sPath = parse_url($_SERVER['PATH_INFO']); |
97 | 97 | } |
@@ -99,61 +99,61 @@ discard block |
||
99 | 99 | { |
100 | 100 | $sPath = parse_url($_SERVER['PHP_SELF']); |
101 | 101 | } |
102 | - if(isset($sPath['path'])) |
|
102 | + if (isset($sPath['path'])) |
|
103 | 103 | { |
104 | - $aURL['path'] = str_replace(array('"',"'",'<','>'), array('%22','%27','%3C','%3E'), $sPath['path']); |
|
104 | + $aURL['path'] = str_replace(array('"', "'", '<', '>'), array('%22', '%27', '%3C', '%3E'), $sPath['path']); |
|
105 | 105 | } |
106 | 106 | unset($sPath); |
107 | 107 | } |
108 | 108 | |
109 | - if(empty($aURL['query']) && !empty($_SERVER['QUERY_STRING'])) |
|
109 | + if (empty($aURL['query']) && !empty($_SERVER['QUERY_STRING'])) |
|
110 | 110 | { |
111 | 111 | $aURL['query'] = $_SERVER['QUERY_STRING']; |
112 | 112 | } |
113 | 113 | |
114 | - if(!empty($aURL['query'])) |
|
114 | + if (!empty($aURL['query'])) |
|
115 | 115 | { |
116 | - $aURL['query'] = '?'.$aURL['query']; |
|
116 | + $aURL['query'] = '?' . $aURL['query']; |
|
117 | 117 | } |
118 | 118 | |
119 | 119 | // Build the URL: Start with scheme, user and pass |
120 | - $sURL = $aURL['scheme'].'://'; |
|
121 | - if(!empty($aURL['user'])) |
|
120 | + $sURL = $aURL['scheme'] . '://'; |
|
121 | + if (!empty($aURL['user'])) |
|
122 | 122 | { |
123 | - $sURL.= $aURL['user']; |
|
124 | - if(!empty($aURL['pass'])) |
|
123 | + $sURL .= $aURL['user']; |
|
124 | + if (!empty($aURL['pass'])) |
|
125 | 125 | { |
126 | - $sURL.= ':'.$aURL['pass']; |
|
126 | + $sURL .= ':' . $aURL['pass']; |
|
127 | 127 | } |
128 | - $sURL.= '@'; |
|
128 | + $sURL .= '@'; |
|
129 | 129 | } |
130 | 130 | |
131 | 131 | // Add the host |
132 | - $sURL.= $aURL['host']; |
|
132 | + $sURL .= $aURL['host']; |
|
133 | 133 | |
134 | 134 | // Add the port if needed |
135 | - if(!empty($aURL['port']) |
|
135 | + if (!empty($aURL['port']) |
|
136 | 136 | && (($aURL['scheme'] == 'http' && $aURL['port'] != 80) |
137 | 137 | || ($aURL['scheme'] == 'https' && $aURL['port'] != 443))) |
138 | 138 | { |
139 | - $sURL.= ':'.$aURL['port']; |
|
139 | + $sURL .= ':' . $aURL['port']; |
|
140 | 140 | } |
141 | 141 | |
142 | 142 | // Add the path and the query string |
143 | - $sURL.= $aURL['path'].@$aURL['query']; |
|
143 | + $sURL .= $aURL['path'] . @$aURL['query']; |
|
144 | 144 | |
145 | 145 | // Clean up |
146 | 146 | unset($aURL); |
147 | 147 | |
148 | 148 | $aURL = explode("?", $sURL); |
149 | 149 | |
150 | - if(1 < count($aURL)) |
|
150 | + if (1 < count($aURL)) |
|
151 | 151 | { |
152 | 152 | $aQueries = explode("&", $aURL[1]); |
153 | 153 | |
154 | - foreach($aQueries as $sKey => $sQuery) |
|
154 | + foreach ($aQueries as $sKey => $sQuery) |
|
155 | 155 | { |
156 | - if("jxnGenerate" == substr($sQuery, 0, 11)) |
|
156 | + if ("jxnGenerate" == substr($sQuery, 0, 11)) |
|
157 | 157 | unset($aQueries[$sKey]); |
158 | 158 | } |
159 | 159 |
@@ -27,7 +27,7 @@ |
||
27 | 27 | public function render($sPath, array $aVars = []) |
28 | 28 | { |
29 | 29 | // Make the template vars available as attributes |
30 | - foreach($aVars as $sName => $xValue) |
|
30 | + foreach ($aVars as $sName => $xValue) |
|
31 | 31 | { |
32 | 32 | $sName = (string)$sName; |
33 | 33 | $this->$sName = $xValue; |
@@ -55,11 +55,11 @@ discard block |
||
55 | 55 | */ |
56 | 56 | private function _loadTranslations($sLanguage, $sPrefix, array $aTranslations) |
57 | 57 | { |
58 | - foreach($aTranslations as $sName => $xTranslation) |
|
58 | + foreach ($aTranslations as $sName => $xTranslation) |
|
59 | 59 | { |
60 | 60 | $sName = trim($sName); |
61 | 61 | $sName = ($sPrefix) ? $sPrefix . '.' . $sName : $sName; |
62 | - if(!is_array($xTranslation)) |
|
62 | + if (!is_array($xTranslation)) |
|
63 | 63 | { |
64 | 64 | // Save this translation |
65 | 65 | $this->aTranslations[$sLanguage][$sName] = $xTranslation; |
@@ -82,17 +82,17 @@ discard block |
||
82 | 82 | */ |
83 | 83 | public function loadTranslations($sFilePath, $sLanguage) |
84 | 84 | { |
85 | - if(!file_exists($sFilePath)) |
|
85 | + if (!file_exists($sFilePath)) |
|
86 | 86 | { |
87 | 87 | return; |
88 | 88 | } |
89 | 89 | $aTranslations = require($sFilePath); |
90 | - if(!is_array($aTranslations)) |
|
90 | + if (!is_array($aTranslations)) |
|
91 | 91 | { |
92 | 92 | return; |
93 | 93 | } |
94 | 94 | // Load the translations |
95 | - if(!array_key_exists($sLanguage, $this->aTranslations)) |
|
95 | + if (!array_key_exists($sLanguage, $this->aTranslations)) |
|
96 | 96 | { |
97 | 97 | $this->aTranslations[$sLanguage] = []; |
98 | 98 | } |
@@ -111,20 +111,20 @@ discard block |
||
111 | 111 | public function trans($sText, array $aPlaceHolders = [], $sLanguage = null) |
112 | 112 | { |
113 | 113 | $sText = trim((string)$sText); |
114 | - if(!$sLanguage) |
|
114 | + if (!$sLanguage) |
|
115 | 115 | { |
116 | 116 | $sLanguage = $this->xConfig->getOption('language'); |
117 | 117 | } |
118 | - if(!$sLanguage) |
|
118 | + if (!$sLanguage) |
|
119 | 119 | { |
120 | 120 | $sLanguage = $this->sDefaultLocale; |
121 | 121 | } |
122 | - if(!array_key_exists($sLanguage, $this->aTranslations) || !array_key_exists($sText, $this->aTranslations[$sLanguage])) |
|
122 | + if (!array_key_exists($sLanguage, $this->aTranslations) || !array_key_exists($sText, $this->aTranslations[$sLanguage])) |
|
123 | 123 | { |
124 | 124 | return $sText; |
125 | 125 | } |
126 | 126 | $message = $this->aTranslations[$sLanguage][$sText]; |
127 | - foreach($aPlaceHolders as $name => $value) |
|
127 | + foreach ($aPlaceHolders as $name => $value) |
|
128 | 128 | { |
129 | 129 | $message = str_replace(':' . $name, $value, $message); |
130 | 130 | } |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | |
66 | 66 | protected function updateNumPages() |
67 | 67 | { |
68 | - $this->numPages = ($this->itemsPerPage == 0 ? 0 : (int) ceil($this->totalItems/$this->itemsPerPage)); |
|
68 | + $this->numPages = ($this->itemsPerPage == 0 ? 0 : (int)ceil($this->totalItems / $this->itemsPerPage)); |
|
69 | 69 | } |
70 | 70 | |
71 | 71 | /** |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | */ |
75 | 75 | public function setMaxPagesToShow($maxPagesToShow) |
76 | 76 | { |
77 | - if($maxPagesToShow < 3) |
|
77 | + if ($maxPagesToShow < 3) |
|
78 | 78 | { |
79 | 79 | throw new \InvalidArgumentException('maxPagesToShow cannot be less than 3.'); |
80 | 80 | } |
@@ -154,7 +154,7 @@ discard block |
||
154 | 154 | { |
155 | 155 | $this->request = $request; |
156 | 156 | // Append the page number to the parameter list, if not yet given. |
157 | - if(($this->request) && !$this->request->hasPageNumber()) |
|
157 | + if (($this->request) && !$this->request->hasPageNumber()) |
|
158 | 158 | { |
159 | 159 | $this->request->addParameter(Jaxon::PAGE_NUMBER, 0); |
160 | 160 | } |
@@ -193,7 +193,7 @@ discard block |
||
193 | 193 | |
194 | 194 | public function getNextPage() |
195 | 195 | { |
196 | - if($this->currentPage < $this->numPages) |
|
196 | + if ($this->currentPage < $this->numPages) |
|
197 | 197 | { |
198 | 198 | return $this->currentPage + 1; |
199 | 199 | } |
@@ -203,7 +203,7 @@ discard block |
||
203 | 203 | |
204 | 204 | public function getPrevPage() |
205 | 205 | { |
206 | - if($this->currentPage > 1) |
|
206 | + if ($this->currentPage > 1) |
|
207 | 207 | { |
208 | 208 | return $this->currentPage - 1; |
209 | 209 | } |
@@ -213,7 +213,7 @@ discard block |
||
213 | 213 | |
214 | 214 | public function getNextCall() |
215 | 215 | { |
216 | - if(!$this->getNextPage()) |
|
216 | + if (!$this->getNextPage()) |
|
217 | 217 | { |
218 | 218 | return null; |
219 | 219 | } |
@@ -226,7 +226,7 @@ discard block |
||
226 | 226 | */ |
227 | 227 | public function getPrevCall() |
228 | 228 | { |
229 | - if(!$this->getPrevPage()) |
|
229 | + if (!$this->getPrevPage()) |
|
230 | 230 | { |
231 | 231 | return null; |
232 | 232 | } |
@@ -254,14 +254,14 @@ discard block |
||
254 | 254 | { |
255 | 255 | $pages = []; |
256 | 256 | |
257 | - if($this->numPages <= 1) |
|
257 | + if ($this->numPages <= 1) |
|
258 | 258 | { |
259 | 259 | return []; |
260 | 260 | } |
261 | 261 | |
262 | - if($this->numPages <= $this->maxPagesToShow) |
|
262 | + if ($this->numPages <= $this->maxPagesToShow) |
|
263 | 263 | { |
264 | - for($i = 1; $i <= $this->numPages; $i++) |
|
264 | + for ($i = 1; $i <= $this->numPages; $i++) |
|
265 | 265 | { |
266 | 266 | $pages[] = $this->createPage($i, $i == $this->currentPage); |
267 | 267 | } |
@@ -269,9 +269,9 @@ discard block |
||
269 | 269 | else |
270 | 270 | { |
271 | 271 | // Determine the sliding range, centered around the current page. |
272 | - $numAdjacents = (int) floor(($this->maxPagesToShow - 3) / 2); |
|
272 | + $numAdjacents = (int)floor(($this->maxPagesToShow - 3) / 2); |
|
273 | 273 | |
274 | - if($this->currentPage + $numAdjacents > $this->numPages) |
|
274 | + if ($this->currentPage + $numAdjacents > $this->numPages) |
|
275 | 275 | { |
276 | 276 | $slidingStart = $this->numPages - $this->maxPagesToShow + 2; |
277 | 277 | } |
@@ -279,28 +279,28 @@ discard block |
||
279 | 279 | { |
280 | 280 | $slidingStart = $this->currentPage - $numAdjacents; |
281 | 281 | } |
282 | - if($slidingStart < 2) |
|
282 | + if ($slidingStart < 2) |
|
283 | 283 | { |
284 | 284 | $slidingStart = 2; |
285 | 285 | } |
286 | 286 | |
287 | 287 | $slidingEnd = $slidingStart + $this->maxPagesToShow - 3; |
288 | - if($slidingEnd >= $this->numPages) |
|
288 | + if ($slidingEnd >= $this->numPages) |
|
289 | 289 | { |
290 | 290 | $slidingEnd = $this->numPages - 1; |
291 | 291 | } |
292 | 292 | |
293 | 293 | // Build the list of pages. |
294 | 294 | $pages[] = $this->createPage(1, $this->currentPage == 1); |
295 | - if($slidingStart > 2) |
|
295 | + if ($slidingStart > 2) |
|
296 | 296 | { |
297 | 297 | $pages[] = $this->createPageEllipsis(); |
298 | 298 | } |
299 | - for($i = $slidingStart; $i <= $slidingEnd; $i++) |
|
299 | + for ($i = $slidingStart; $i <= $slidingEnd; $i++) |
|
300 | 300 | { |
301 | 301 | $pages[] = $this->createPage($i, $i == $this->currentPage); |
302 | 302 | } |
303 | - if($slidingEnd < $this->numPages - 1) |
|
303 | + if ($slidingEnd < $this->numPages - 1) |
|
304 | 304 | { |
305 | 305 | $pages[] = $this->createPageEllipsis(); |
306 | 306 | } |
@@ -346,7 +346,7 @@ discard block |
||
346 | 346 | */ |
347 | 347 | public function toHtml() |
348 | 348 | { |
349 | - if($this->getNumPages() <= 1) |
|
349 | + if ($this->getNumPages() <= 1) |
|
350 | 350 | { |
351 | 351 | return ''; |
352 | 352 | } |
@@ -369,7 +369,7 @@ discard block |
||
369 | 369 | { |
370 | 370 | $first = ($this->currentPage - 1) * $this->itemsPerPage + 1; |
371 | 371 | |
372 | - if($first > $this->totalItems) |
|
372 | + if ($first > $this->totalItems) |
|
373 | 373 | { |
374 | 374 | return null; |
375 | 375 | } |
@@ -380,13 +380,13 @@ discard block |
||
380 | 380 | public function getCurrentPageLastItem() |
381 | 381 | { |
382 | 382 | $first = $this->getCurrentPageFirstItem(); |
383 | - if($first === null) |
|
383 | + if ($first === null) |
|
384 | 384 | { |
385 | 385 | return null; |
386 | 386 | } |
387 | 387 | |
388 | 388 | $last = $first + $this->itemsPerPage - 1; |
389 | - if($last > $this->totalItems) |
|
389 | + if ($last > $this->totalItems) |
|
390 | 390 | { |
391 | 391 | return $this->totalItems; |
392 | 392 | } |
@@ -50,14 +50,14 @@ discard block |
||
50 | 50 | $sPrefix = trim((string)$sPrefix); |
51 | 51 | $nDepth = intval($nDepth); |
52 | 52 | // Check the max depth |
53 | - if($nDepth < 0 || $nDepth > 9) |
|
53 | + if ($nDepth < 0 || $nDepth > 9) |
|
54 | 54 | { |
55 | 55 | throw new \Jaxon\Exception\Config\Data(jaxon_trans('config.errors.data.depth', |
56 | 56 | array('key' => $sPrefix, 'depth' => $nDepth))); |
57 | 57 | } |
58 | - foreach($aOptions as $sName => $xOption) |
|
58 | + foreach ($aOptions as $sName => $xOption) |
|
59 | 59 | { |
60 | - if(is_int($sName)) |
|
60 | + if (is_int($sName)) |
|
61 | 61 | { |
62 | 62 | continue; |
63 | 63 | } |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | // Save the value of this option |
68 | 68 | $this->aOptions[$sFullName] = $xOption; |
69 | 69 | // Save the values of its sub-options |
70 | - if(is_array($xOption)) |
|
70 | + if (is_array($xOption)) |
|
71 | 71 | { |
72 | 72 | // Recursively read the options in the array |
73 | 73 | $this->_setOptions($xOption, $sFullName, $nDepth + 1); |
@@ -89,9 +89,9 @@ discard block |
||
89 | 89 | $aKeys = explode('.', (string)$sKeys); |
90 | 90 | foreach ($aKeys as $sKey) |
91 | 91 | { |
92 | - if(($sKey)) |
|
92 | + if (($sKey)) |
|
93 | 93 | { |
94 | - if(!array_key_exists($sKey, $aOptions) || !is_array($aOptions[$sKey])) |
|
94 | + if (!array_key_exists($sKey, $aOptions) || !is_array($aOptions[$sKey])) |
|
95 | 95 | { |
96 | 96 | return; |
97 | 97 | } |
@@ -139,13 +139,12 @@ discard block |
||
139 | 139 | $sPrefix = rtrim($sPrefix, '.') . '.'; |
140 | 140 | $sPrefixLen = strlen($sPrefix); |
141 | 141 | $aOptions = []; |
142 | - foreach($this->aOptions as $sName => $xValue) |
|
142 | + foreach ($this->aOptions as $sName => $xValue) |
|
143 | 143 | { |
144 | - if(substr($sName, 0, $sPrefixLen) == $sPrefix) |
|
144 | + if (substr($sName, 0, $sPrefixLen) == $sPrefix) |
|
145 | 145 | { |
146 | 146 | $iNextDotPos = strpos($sName, '.', $sPrefixLen); |
147 | - $sOptionName = $iNextDotPos === false ? substr($sName, $sPrefixLen) : |
|
148 | - substr($sName, $sPrefixLen, $iNextDotPos - $sPrefixLen); |
|
147 | + $sOptionName = $iNextDotPos === false ? substr($sName, $sPrefixLen) : substr($sName, $sPrefixLen, $iNextDotPos - $sPrefixLen); |
|
149 | 148 | $aOptions[$sOptionName] = $sPrefix . $sOptionName; |
150 | 149 | } |
151 | 150 | } |