@@ -18,7 +18,7 @@ |
||
18 | 18 | // of text/html instead of application/json then we are probably browsing the API |
19 | 19 | // and therefore want a prettier version of the response. |
20 | 20 | $acceptableContentTypes = array_keys(neon()->request->getAcceptableContentTypes()); |
21 | - $contentTypeIsHtml = (isset($acceptableContentTypes[0]) && $acceptableContentTypes[0] === 'text/html'); |
|
21 | + $contentTypeIsHtml = (isset($acceptableContentTypes[0]) && $acceptableContentTypes[0] === 'text/html'); |
|
22 | 22 | $prettyGetVarExists = (neon()->request->get('_pretty', false) !== false); |
23 | 23 | if ($contentTypeIsHtml || $prettyGetVarExists) { |
24 | 24 | $this->prettyPrint = true; |
@@ -48,14 +48,14 @@ discard block |
||
48 | 48 | public function getForm() |
49 | 49 | { |
50 | 50 | $f = new \neon\core\form\Form('style'); |
51 | - foreach($this->getDefinition() as $field) { |
|
51 | + foreach ($this->getDefinition() as $field) { |
|
52 | 52 | $f->add($field); |
53 | 53 | } |
54 | 54 | $f->load($this->getStyles()); |
55 | 55 | return $f; |
56 | 56 | } |
57 | 57 | |
58 | - public function loadStyles($key='default') |
|
58 | + public function loadStyles($key = 'default') |
|
59 | 59 | { |
60 | 60 | return setting('cms', 'styles'); |
61 | 61 | } |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | * @param array $options |
68 | 68 | * @return string - the current value for the style if the style variable with he name $name already exists |
69 | 69 | */ |
70 | - public function add($name, $default, $type, $options=[]) |
|
70 | + public function add($name, $default, $type, $options = []) |
|
71 | 71 | { |
72 | 72 | // check if a style property already exists |
73 | 73 | $styleValue = $this->getStyleValue($name, $default); |
@@ -79,13 +79,13 @@ discard block |
||
79 | 79 | return $styleValue; |
80 | 80 | } |
81 | 81 | |
82 | - public function getStyleValue($name, $default='') |
|
82 | + public function getStyleValue($name, $default = '') |
|
83 | 83 | { |
84 | 84 | $styles = $this->getStyles(); |
85 | 85 | return Arr::get($styles, $name, $default); |
86 | 86 | } |
87 | 87 | |
88 | - public function set($name, $value, $field=null, $key='default') |
|
88 | + public function set($name, $value, $field = null, $key = 'default') |
|
89 | 89 | { |
90 | 90 | $styles = $this->getStyles(); |
91 | 91 | Arr::setValue($styles, $name, $value); |
@@ -72,8 +72,9 @@ |
||
72 | 72 | // check if a style property already exists |
73 | 73 | $styleValue = $this->getStyleValue($name, $default); |
74 | 74 | $options['name'] = $name; |
75 | - if (!isset($options['class'])) |
|
76 | - $options['class'] = $type; |
|
75 | + if (!isset($options['class'])) { |
|
76 | + $options['class'] = $type; |
|
77 | + } |
|
77 | 78 | $options['label'] = Arr::get($options, 'label', Str::humanize($name)); |
78 | 79 | $this->set($name, $styleValue, $options); |
79 | 80 | return $styleValue; |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | public function findView($view, $context) |
125 | 125 | { |
126 | 126 | $exists = file_exists($this->findViewFile($view, $context)); |
127 | - return $exists ? $this->findViewFile($view, $context) : false ; |
|
127 | + return $exists ? $this->findViewFile($view, $context) : false; |
|
128 | 128 | } |
129 | 129 | |
130 | 130 | /** |
@@ -191,7 +191,7 @@ discard block |
||
191 | 191 | profile_begin('renderHeadHtml'); |
192 | 192 | if ($this->cssConcatenate) |
193 | 193 | $this->cssFiles = $this->resolveFiles($this->cssFiles, 'css'); |
194 | - $out = parent::renderHeadHtml() . "\n" . $this->getHtmlFragment(self::POS_HEAD); |
|
194 | + $out = parent::renderHeadHtml()."\n".$this->getHtmlFragment(self::POS_HEAD); |
|
195 | 195 | profile_end('renderHeadHtml'); |
196 | 196 | return $out; |
197 | 197 | } |
@@ -201,7 +201,7 @@ discard block |
||
201 | 201 | */ |
202 | 202 | public function renderBodyBeginHtml() |
203 | 203 | { |
204 | - return parent::renderBodyBeginHtml() . "\n" . $this->getHtmlFragment(self::POS_BEGIN); |
|
204 | + return parent::renderBodyBeginHtml()."\n".$this->getHtmlFragment(self::POS_BEGIN); |
|
205 | 205 | } |
206 | 206 | |
207 | 207 | /** |
@@ -214,7 +214,7 @@ discard block |
||
214 | 214 | if (isset($this->jsFiles[self::POS_END])) |
215 | 215 | $this->jsFiles[self::POS_END] = $this->resolveFiles($this->jsFiles[self::POS_END], 'js'); |
216 | 216 | } |
217 | - $out = parent::renderBodyEndHtml($ajaxMode) . "\n" . $this->getHtmlFragment(self::POS_END); |
|
217 | + $out = parent::renderBodyEndHtml($ajaxMode)."\n".$this->getHtmlFragment(self::POS_END); |
|
218 | 218 | profile_end('renderBodyEndHtml'); |
219 | 219 | return $out; |
220 | 220 | } |
@@ -254,13 +254,13 @@ discard block |
||
254 | 254 | * @throws \yii\base\Exception - if the file/directory containing the new concatenated file could not be created |
255 | 255 | * @return array - new array of css files to replace $this->cssFiles |
256 | 256 | */ |
257 | - public function resolveFiles($files, $type='css') |
|
257 | + public function resolveFiles($files, $type = 'css') |
|
258 | 258 | { |
259 | 259 | // should cache results here |
260 | 260 | $concatFiles = $this->findFilesToConcatenate($files); |
261 | 261 | $url = ($type === 'css') ? $this->cssConcatenateFiles($concatFiles) : $this->jsConcatenateFiles($concatFiles); |
262 | 262 | // replace css/js files to be output with the one concatenated file |
263 | - foreach($concatFiles as $fileKey) unset($files[$fileKey]); |
|
263 | + foreach ($concatFiles as $fileKey) unset($files[$fileKey]); |
|
264 | 264 | $files[$url] = ($type === 'css') ? Html::cssFile($url) : Html::jsFile($url); |
265 | 265 | return $files; |
266 | 266 | } |
@@ -277,7 +277,7 @@ discard block |
||
277 | 277 | * @throws \yii\base\Exception - if the file/directory containing the new concatenated file could not be created |
278 | 278 | * @return string - url to dynamic css file url |
279 | 279 | */ |
280 | - public function cssConcatenateFiles($concatenateFiles, &$key='') |
|
280 | + public function cssConcatenateFiles($concatenateFiles, &$key = '') |
|
281 | 281 | { |
282 | 282 | $key = md5(serialize([$concatenateFiles, $this->cssMinify])); |
283 | 283 | |
@@ -291,7 +291,7 @@ discard block |
||
291 | 291 | // for cache busting. Lets remove get params ? (namely the cache busting ?v=) |
292 | 292 | $file = substr($fileKey, 0, strpos($fileKey, '?')); |
293 | 293 | // Get the disk file path - replace web root path with the disk root path |
294 | - $fileName = $rootPath . Str::replaceFirst($webPath, '', $file); |
|
294 | + $fileName = $rootPath.Str::replaceFirst($webPath, '', $file); |
|
295 | 295 | // make sure local css url's are made absolute |
296 | 296 | $css = Css::replaceRelativeUrls(file_get_contents($fileName), $fileKey); |
297 | 297 | $cssConcat .= $css; |
@@ -327,14 +327,14 @@ discard block |
||
327 | 327 | // remove get params ? (namely the cache busting ?v=) |
328 | 328 | $file = substr($fileKey, 0, strpos($fileKey, '?')); |
329 | 329 | // replace overlap web root path |
330 | - $fileName = $rootPath . (empty($webPath) ? $file : Str::replaceFirst($webPath, '', $file)); |
|
330 | + $fileName = $rootPath.(empty($webPath) ? $file : Str::replaceFirst($webPath, '', $file)); |
|
331 | 331 | // make sure we can find the file here |
332 | 332 | // we must concatenate each file on a new line to prevent |
333 | 333 | // line comments commenting out the first line of the next file |
334 | 334 | if (substr($fileName, -6) === 'min.js') { |
335 | - $jsConcat .= "\n" . file_get_contents($fileName); |
|
335 | + $jsConcat .= "\n".file_get_contents($fileName); |
|
336 | 336 | } else { |
337 | - $jsConcat .= "\n" . file_get_contents($fileName); |
|
337 | + $jsConcat .= "\n".file_get_contents($fileName); |
|
338 | 338 | // if allow auto php minify: its a bit too slow |
339 | 339 | //$jsConcat .= \JShrink\Minifier::minify(file_get_contents($fileName), array('flaggedComments' => false)); |
340 | 340 | } |
@@ -382,10 +382,10 @@ discard block |
||
382 | 382 | */ |
383 | 383 | private function _assetManagerGenerate($path, $callback) |
384 | 384 | { |
385 | - $file = neon()->getAlias(neon()->assetManager->basePath . $path); |
|
386 | - if (! file_exists($file)) |
|
385 | + $file = neon()->getAlias(neon()->assetManager->basePath.$path); |
|
386 | + if (!file_exists($file)) |
|
387 | 387 | File::createFile($file, $callback()); |
388 | - return neon()->assetManager->baseUrl . $path; |
|
388 | + return neon()->assetManager->baseUrl.$path; |
|
389 | 389 | } |
390 | 390 | |
391 | 391 | /** |
@@ -397,7 +397,7 @@ discard block |
||
397 | 397 | * @param $styleKey |
398 | 398 | * @return string |
399 | 399 | */ |
400 | - public function getCssByKey($key, $styleKey='') |
|
400 | + public function getCssByKey($key, $styleKey = '') |
|
401 | 401 | { |
402 | 402 | $css = ''; |
403 | 403 | // load css file |
@@ -420,7 +420,7 @@ discard block |
||
420 | 420 | */ |
421 | 421 | public function getCssFileByKey($key) |
422 | 422 | { |
423 | - return '@webroot/assets/css/' . $key . '.css'; |
|
423 | + return '@webroot/assets/css/'.$key.'.css'; |
|
424 | 424 | } |
425 | 425 | |
426 | 426 | /** |
@@ -429,7 +429,7 @@ discard block |
||
429 | 429 | * @param string $styleKey - a key to identify the style to load |
430 | 430 | * @return array |
431 | 431 | */ |
432 | - public function getStyleData($styleKey='') |
|
432 | + public function getStyleData($styleKey = '') |
|
433 | 433 | { |
434 | 434 | return neon()->view->styleManager->getStyles(); |
435 | 435 | } |
@@ -189,8 +189,9 @@ discard block |
||
189 | 189 | public function renderHeadHtml() |
190 | 190 | { |
191 | 191 | profile_begin('renderHeadHtml'); |
192 | - if ($this->cssConcatenate) |
|
193 | - $this->cssFiles = $this->resolveFiles($this->cssFiles, 'css'); |
|
192 | + if ($this->cssConcatenate) { |
|
193 | + $this->cssFiles = $this->resolveFiles($this->cssFiles, 'css'); |
|
194 | + } |
|
194 | 195 | $out = parent::renderHeadHtml() . "\n" . $this->getHtmlFragment(self::POS_HEAD); |
195 | 196 | profile_end('renderHeadHtml'); |
196 | 197 | return $out; |
@@ -211,8 +212,9 @@ discard block |
||
211 | 212 | { |
212 | 213 | profile_begin('renderBodyEndHtml'); |
213 | 214 | if ($this->jsConcatenate) { |
214 | - if (isset($this->jsFiles[self::POS_END])) |
|
215 | - $this->jsFiles[self::POS_END] = $this->resolveFiles($this->jsFiles[self::POS_END], 'js'); |
|
215 | + if (isset($this->jsFiles[self::POS_END])) { |
|
216 | + $this->jsFiles[self::POS_END] = $this->resolveFiles($this->jsFiles[self::POS_END], 'js'); |
|
217 | + } |
|
216 | 218 | } |
217 | 219 | $out = parent::renderBodyEndHtml($ajaxMode) . "\n" . $this->getHtmlFragment(self::POS_END); |
218 | 220 | profile_end('renderBodyEndHtml'); |
@@ -260,7 +262,9 @@ discard block |
||
260 | 262 | $concatFiles = $this->findFilesToConcatenate($files); |
261 | 263 | $url = ($type === 'css') ? $this->cssConcatenateFiles($concatFiles) : $this->jsConcatenateFiles($concatFiles); |
262 | 264 | // replace css/js files to be output with the one concatenated file |
263 | - foreach($concatFiles as $fileKey) unset($files[$fileKey]); |
|
265 | + foreach($concatFiles as $fileKey) { |
|
266 | + unset($files[$fileKey]); |
|
267 | + } |
|
264 | 268 | $files[$url] = ($type === 'css') ? Html::cssFile($url) : Html::jsFile($url); |
265 | 269 | return $files; |
266 | 270 | } |
@@ -359,11 +363,13 @@ discard block |
||
359 | 363 | $concatenateFiles = []; |
360 | 364 | foreach ($files as $fileKey => $tag) { |
361 | 365 | // Do not concatenate externally loaded files (for e.g. from cdns) |
362 | - if (Url::isAbsolute($fileKey)) |
|
363 | - continue; |
|
366 | + if (Url::isAbsolute($fileKey)) { |
|
367 | + continue; |
|
368 | + } |
|
364 | 369 | // remove excluded files - files we do not want to concatenate |
365 | - if (Str::contains($tag, 'concatenate="false"')) |
|
366 | - continue; |
|
370 | + if (Str::contains($tag, 'concatenate="false"')) { |
|
371 | + continue; |
|
372 | + } |
|
367 | 373 | $concatenateFiles[] = $fileKey; |
368 | 374 | } |
369 | 375 | profile_end('_findFilesToConcatenate'); |
@@ -383,8 +389,9 @@ discard block |
||
383 | 389 | private function _assetManagerGenerate($path, $callback) |
384 | 390 | { |
385 | 391 | $file = neon()->getAlias(neon()->assetManager->basePath . $path); |
386 | - if (! file_exists($file)) |
|
387 | - File::createFile($file, $callback()); |
|
392 | + if (! file_exists($file)) { |
|
393 | + File::createFile($file, $callback()); |
|
394 | + } |
|
388 | 395 | return neon()->assetManager->baseUrl . $path; |
389 | 396 | } |
390 | 397 | |
@@ -407,8 +414,9 @@ discard block |
||
407 | 414 | $this->renderFile($file, $this->getStyleData($styleKey)) |
408 | 415 | : file_get_contents(neon()->getAlias($file)); |
409 | 416 | // minify css file |
410 | - if (neon()->view->cssMinify) |
|
411 | - $css = Css::minify($css); |
|
417 | + if (neon()->view->cssMinify) { |
|
418 | + $css = Css::minify($css); |
|
419 | + } |
|
412 | 420 | return $css; |
413 | 421 | } |
414 | 422 |
@@ -56,11 +56,11 @@ |
||
56 | 56 | // allow authenticated users |
57 | 57 | [ |
58 | 58 | 'allow' => true, |
59 | - 'roles' => [ 'neon-administrator' ] |
|
59 | + 'roles' => ['neon-administrator'] |
|
60 | 60 | ], |
61 | 61 | [ |
62 | 62 | 'allow' => true, |
63 | - 'matchCallback' => function ($rule, $action) { |
|
63 | + 'matchCallback' => function($rule, $action) { |
|
64 | 64 | return neon()->user->isSuper(); |
65 | 65 | } |
66 | 66 | ] |
@@ -114,12 +114,12 @@ discard block |
||
114 | 114 | // routes are either set by extending from AdminController or defined here |
115 | 115 | 'neon-administrator' => [ |
116 | 116 | 'label' => 'Neon Administrator', |
117 | - 'routes' => [ '^/admin/.*' ], |
|
117 | + 'routes' => ['^/admin/.*'], |
|
118 | 118 | 'homeUrl' => '/admin' // default url if not going elsewhere |
119 | 119 | ], |
120 | 120 | 'neon-developer' => [ |
121 | 121 | 'label' => 'Neon Developer', |
122 | - 'routes' => [ '^/admin/.*' ], |
|
122 | + 'routes' => ['^/admin/.*'], |
|
123 | 123 | 'homeUrl' => '/admin' // default url if not going elsewhere |
124 | 124 | ], |
125 | 125 | ] |
@@ -299,7 +299,7 @@ discard block |
||
299 | 299 | 'maxFileSize' => 1024 * 2, |
300 | 300 | 'maxLogFiles' => 20, |
301 | 301 | 'logVars' => ['_GET', '_POST', '_FILES', '_SESSION', '_SERVER'], |
302 | - 'maskVars' => ['_SERVER.HTTP_AUTHORIZATION','_SERVER.PHP_AUTH_USER','_SERVER.PHP_AUTH_PW','_SERVER.DB_PASSWORD','_SERVER.NEON_SECRET','_SERVER.NEON_ENCRYPTION_KEY'] |
|
302 | + 'maskVars' => ['_SERVER.HTTP_AUTHORIZATION', '_SERVER.PHP_AUTH_USER', '_SERVER.PHP_AUTH_PW', '_SERVER.DB_PASSWORD', '_SERVER.NEON_SECRET', '_SERVER.NEON_ENCRYPTION_KEY'] |
|
303 | 303 | ], |
304 | 304 | 'warning' => [ |
305 | 305 | 'class' => 'yii\log\FileTarget', |
@@ -308,7 +308,7 @@ discard block |
||
308 | 308 | 'maxFileSize' => 1024 * 2, |
309 | 309 | 'maxLogFiles' => 20, |
310 | 310 | 'logVars' => ['_GET', '_POST', '_FILES', '_SESSION', '_SERVER'], |
311 | - 'maskVars' => ['_SERVER.HTTP_AUTHORIZATION','_SERVER.PHP_AUTH_USER','_SERVER.PHP_AUTH_PW','_SERVER.DB_PASSWORD','_SERVER.NEON_SECRET','_SERVER.NEON_ENCRYPTION_KEY'] |
|
311 | + 'maskVars' => ['_SERVER.HTTP_AUTHORIZATION', '_SERVER.PHP_AUTH_USER', '_SERVER.PHP_AUTH_PW', '_SERVER.DB_PASSWORD', '_SERVER.NEON_SECRET', '_SERVER.NEON_ENCRYPTION_KEY'] |
|
312 | 312 | ], |
313 | 313 | 'trace' => [ |
314 | 314 | // to enable trace logging set ['components']['log']['targets']['trace']['enabled'] to true in the app config |
@@ -23,7 +23,7 @@ |
||
23 | 23 | ], |
24 | 24 | // the user module could define this on boot. |
25 | 25 | // but this is useful if you need to make any project specific adjustments |
26 | - 'session' => [ // for use session in console application |
|
26 | + 'session' => [// for use session in console application |
|
27 | 27 | 'class' => 'yii\web\DbSession' |
28 | 28 | ], |
29 | 29 | ], |
@@ -19,7 +19,7 @@ |
||
19 | 19 | * @return array |
20 | 20 | * @throws \Exception |
21 | 21 | */ |
22 | - public function actionGetMapObjects($objectToken, $formField, $query=null, $start=0, $length=100) |
|
22 | + public function actionGetMapObjects($objectToken, $formField, $query = null, $start = 0, $length = 100) |
|
23 | 23 | { |
24 | 24 | /** @var \neon\core\form\Form $form */ |
25 | 25 | $form = Hash::getObjectFromToken($objectToken); |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | |
33 | 33 | // If we have requested json we should return the error as json |
34 | 34 | $acceptsJson = array_key_exists('application/json', neon()->request->getAcceptableContentTypes()); |
35 | - if (neon()->request->getIsAjax() || $acceptsJson ) { |
|
35 | + if (neon()->request->getIsAjax() || $acceptsJson) { |
|
36 | 36 | return $data; |
37 | 37 | } |
38 | 38 | |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | return $this->render($errorPage, $data); |
50 | 50 | } |
51 | 51 | // Look up specific framework view file e.g `core/view/error_404.php` |
52 | - $viewForError = 'error_' . $data['status']; |
|
52 | + $viewForError = 'error_'.$data['status']; |
|
53 | 53 | if ($this->findView($viewForError)) { |
54 | 54 | return $this->render($viewForError, $data); |
55 | 55 | } |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | */ |
65 | 65 | public function getCustomErrorPage($errorCode) |
66 | 66 | { |
67 | - $themeFile = neon('cms')->getThemeAlias() . "/error_$errorCode.tpl"; |
|
67 | + $themeFile = neon('cms')->getThemeAlias()."/error_$errorCode.tpl"; |
|
68 | 68 | if (!$this->findView($themeFile)) { |
69 | 69 | return false; |
70 | 70 | } |
@@ -31,7 +31,7 @@ |
||
31 | 31 | // NOTE: may be useful to add this to the request / view as a helper function if the headers work |
32 | 32 | // `neon()->response->sendCachePermanentHeaders()`; |
33 | 33 | header("Content-type: text/css; charset: UTF-8"); |
34 | - header("Expires: " . gmdate("D, d M Y H:i:s", time() + $cacheSeconds) . " GMT"); |
|
34 | + header("Expires: ".gmdate("D, d M Y H:i:s", time() + $cacheSeconds)." GMT"); |
|
35 | 35 | header("Pragma: cache"); |
36 | 36 | header("Cache-Control: public, max-age=$cacheSeconds"); |
37 | 37 | // return css content with correct headers |