@@ -26,7 +26,7 @@ |
||
26 | 26 | */ |
27 | 27 | protected function hash($path) |
28 | 28 | { |
29 | - if (isset($this->publishOptions['path'])){ |
|
29 | + if (isset($this->publishOptions['path'])) { |
|
30 | 30 | // if a path is specified then use this instead of a hash |
31 | 31 | return $this->publishOptions['path']; |
32 | 32 | } |
@@ -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 | ] |
@@ -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); |
@@ -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 |
@@ -50,7 +50,7 @@ |
||
50 | 50 | private function createCSVFile() |
51 | 51 | { |
52 | 52 | // create a temp directory |
53 | - $tmpDir = \Yii::$app->runtimePath . '/csvtmp'; |
|
53 | + $tmpDir = \Yii::$app->runtimePath.'/csvtmp'; |
|
54 | 54 | if (!is_dir($tmpDir) && (!@mkdir($tmpDir) && !is_dir($tmpDir))) { |
55 | 55 | throw new \yii\web\NotFoundHttpException('temp directory does not exist'); |
56 | 56 | } |
@@ -29,8 +29,9 @@ |
||
29 | 29 | unset($rows); |
30 | 30 | } while ($hasRows === true); |
31 | 31 | $handle = fopen($csvFile, 'r'); |
32 | - if ($handle) |
|
33 | - neon()->response->sendStreamAsFile($handle, $grid->title.'.csv')->send(); |
|
32 | + if ($handle) { |
|
33 | + neon()->response->sendStreamAsFile($handle, $grid->title.'.csv')->send(); |
|
34 | + } |
|
34 | 35 | @unlink($csvFile); |
35 | 36 | } |
36 | 37 |
@@ -33,13 +33,13 @@ discard block |
||
33 | 33 | * @param integer $size size of the string required |
34 | 34 | * @return string |
35 | 35 | */ |
36 | - protected static function randomString($size=20) |
|
36 | + protected static function randomString($size = 20) |
|
37 | 37 | { |
38 | 38 | $source = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; |
39 | 39 | $sourceLen = strlen($source); |
40 | 40 | $string = ''; |
41 | - for ($i=0; $i<$size; $i++) |
|
42 | - $string .= substr($source, rand(0, $sourceLen-1), 1); |
|
41 | + for ($i = 0; $i < $size; $i++) |
|
42 | + $string .= substr($source, rand(0, $sourceLen - 1), 1); |
|
43 | 43 | return $string; |
44 | 44 | } |
45 | 45 | |
@@ -84,9 +84,9 @@ discard block |
||
84 | 84 | * @param int $time the time if not now |
85 | 85 | * @return datetime in form yyyy-mm-dd hh-mm-ss |
86 | 86 | */ |
87 | - protected function datetime($time=null, $format='Y-m-d H:i:s') |
|
87 | + protected function datetime($time = null, $format = 'Y-m-d H:i:s') |
|
88 | 88 | { |
89 | - return date($format, ($time===null ? time() : $time)); |
|
89 | + return date($format, ($time === null ? time() : $time)); |
|
90 | 90 | } |
91 | 91 | |
92 | 92 | /** |
@@ -38,8 +38,9 @@ |
||
38 | 38 | $source = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; |
39 | 39 | $sourceLen = strlen($source); |
40 | 40 | $string = ''; |
41 | - for ($i=0; $i<$size; $i++) |
|
42 | - $string .= substr($source, rand(0, $sourceLen-1), 1); |
|
41 | + for ($i=0; $i<$size; $i++) { |
|
42 | + $string .= substr($source, rand(0, $sourceLen-1), 1); |
|
43 | + } |
|
43 | 44 | return $string; |
44 | 45 | } |
45 | 46 |