@@ -23,7 +23,11 @@ discard block |
||
23 | 23 | |
24 | 24 | $text = Language::get($phrase); |
25 | 25 | |
26 | - if (!$popup) Messages::set('error', $text); else Popup::set('negative', $text); |
|
26 | + if (!$popup) { |
|
27 | + Messages::set('error', $text); |
|
28 | + } else { |
|
29 | + Popup::set('negative', $text); |
|
30 | + } |
|
27 | 31 | |
28 | 32 | # ------------------------ |
29 | 33 | |
@@ -41,17 +45,25 @@ discard block |
||
41 | 45 | |
42 | 46 | public function handle(callable $callback, bool $popup = false) : bool { |
43 | 47 | |
44 | - if (false === ($post = $this->post())) return false; |
|
48 | + if (false === ($post = $this->post())) { |
|
49 | + return false; |
|
50 | + } |
|
45 | 51 | |
46 | 52 | # Check form for errors |
47 | 53 | |
48 | - if ($this->hasErrors()) return $this->displayError('FORM_ERROR_REQUIRED', $popup); |
|
54 | + if ($this->hasErrors()) { |
|
55 | + return $this->displayError('FORM_ERROR_REQUIRED', $popup); |
|
56 | + } |
|
49 | 57 | |
50 | 58 | # Call controller method and display error |
51 | 59 | |
52 | - if (is_string($result = $callback($post))) return $this->displayError($result, $popup); |
|
60 | + if (is_string($result = $callback($post))) { |
|
61 | + return $this->displayError($result, $popup); |
|
62 | + } |
|
53 | 63 | |
54 | - if (is_array($result)) return (($this->getField($result[0])->error = true) && $this->displayError($result[1], $popup)); |
|
64 | + if (is_array($result)) { |
|
65 | + return (($this->getField($result[0])->error = true) && $this->displayError($result[1], $popup)); |
|
66 | + } |
|
55 | 67 | |
56 | 68 | # ------------------------ |
57 | 69 |
@@ -32,7 +32,7 @@ |
||
32 | 32 | |
33 | 33 | if (false === ($path = Extend\Templates::get('path'))) throw new Exception\View; |
34 | 34 | |
35 | - if (!isset(self::$cache[$file_name = ($path . $name . '.ctp')])) { |
|
35 | + if (!isset(self::$cache[$file_name = ($path.$name.'.ctp')])) { |
|
36 | 36 | |
37 | 37 | if (false === ($contents = Explorer::getContents($file_name))) throw new Exception\ViewFile($file_name); |
38 | 38 |
@@ -30,11 +30,15 @@ |
||
30 | 30 | |
31 | 31 | public static function get(string $name) : Template\Block { |
32 | 32 | |
33 | - if (false === ($path = Extend\Templates::get('path'))) throw new Exception\View; |
|
33 | + if (false === ($path = Extend\Templates::get('path'))) { |
|
34 | + throw new Exception\View; |
|
35 | + } |
|
34 | 36 | |
35 | 37 | if (!isset(self::$cache[$file_name = ($path . $name . '.ctp')])) { |
36 | 38 | |
37 | - if (false === ($contents = Explorer::getContents($file_name))) throw new Exception\ViewFile($file_name); |
|
39 | + if (false === ($contents = Explorer::getContents($file_name))) { |
|
40 | + throw new Exception\ViewFile($file_name); |
|
41 | + } |
|
38 | 42 | |
39 | 43 | self::$cache[$file_name] = Template::createBlock($contents); |
40 | 44 | } |
@@ -60,7 +60,7 @@ |
||
60 | 60 | |
61 | 61 | if (null === self::$dataset) self::init(); |
62 | 62 | |
63 | - return ((self::get('robots_index') ? 'INDEX' : 'NOINDEX') . ',' . (self::get('robots_follow') ? 'FOLLOW' : 'NOFOLLOW')); |
|
63 | + return ((self::get('robots_index') ? 'INDEX' : 'NOINDEX').','.(self::get('robots_follow') ? 'FOLLOW' : 'NOFOLLOW')); |
|
64 | 64 | } |
65 | 65 | } |
66 | 66 | } |
@@ -34,7 +34,9 @@ discard block |
||
34 | 34 | |
35 | 35 | public static function set(string $name, $value) : bool { |
36 | 36 | |
37 | - if (null === self::$dataset) self::init(); |
|
37 | + if (null === self::$dataset) { |
|
38 | + self::init(); |
|
39 | + } |
|
38 | 40 | |
39 | 41 | return (self::$dataset->set($name, $value) ?? false); |
40 | 42 | } |
@@ -47,7 +49,9 @@ discard block |
||
47 | 49 | |
48 | 50 | public static function get(string $name) { |
49 | 51 | |
50 | - if (null === self::$dataset) self::init(); |
|
52 | + if (null === self::$dataset) { |
|
53 | + self::init(); |
|
54 | + } |
|
51 | 55 | |
52 | 56 | return (self::$dataset->get($name) ?? false); |
53 | 57 | } |
@@ -58,7 +62,9 @@ discard block |
||
58 | 62 | |
59 | 63 | public static function getRobots() { |
60 | 64 | |
61 | - if (null === self::$dataset) self::init(); |
|
65 | + if (null === self::$dataset) { |
|
66 | + self::init(); |
|
67 | + } |
|
62 | 68 | |
63 | 69 | return ((self::get('robots_index') ? 'INDEX' : 'NOINDEX') . ',' . (self::get('robots_follow') ? 'FOLLOW' : 'NOFOLLOW')); |
64 | 70 | } |
@@ -34,7 +34,9 @@ discard block |
||
34 | 34 | |
35 | 35 | public static function set(string $type, string $text, string $title = null) { |
36 | 36 | |
37 | - if (!in_array($type, static::$types, true) || isset(static::$items[$type]) || ('' === $text)) return; |
|
37 | + if (!in_array($type, static::$types, true) || isset(static::$items[$type]) || ('' === $text)) { |
|
38 | + return; |
|
39 | + } |
|
38 | 40 | |
39 | 41 | static::$items[$type] = ['text' => $text, 'title' => (('' !== $title) ? $title : null)]; |
40 | 42 | } |
@@ -64,7 +66,9 @@ discard block |
||
64 | 66 | |
65 | 67 | $message->type = $type; $message->text = Template::createBlock($item['text']); |
66 | 68 | |
67 | - if (isset($item['title'])) $message->getBlock('title')->set('text', $item['title'])->enable(); |
|
69 | + if (isset($item['title'])) { |
|
70 | + $message->getBlock('title')->set('text', $item['title'])->enable(); |
|
71 | + } |
|
68 | 72 | } |
69 | 73 | |
70 | 74 | # ------------------------ |
@@ -68,11 +68,11 @@ |
||
68 | 68 | |
69 | 69 | if ($this->page->id !== 1) SEO::set('title', $this->page->title); else $this->_layout = 'Index'; |
70 | 70 | |
71 | - SEO::set('description', $this->page->description); |
|
72 | - SEO::set('keywords', $this->page->keywords); |
|
73 | - SEO::set('robots_index', $this->page->robots_index); |
|
74 | - SEO::set('robots_follow', $this->page->robots_follow); |
|
75 | - SEO::set('canonical', $this->page->canonical); |
|
71 | + SEO::set('description', $this->page->description); |
|
72 | + SEO::set('keywords', $this->page->keywords); |
|
73 | + SEO::set('robots_index', $this->page->robots_index); |
|
74 | + SEO::set('robots_follow', $this->page->robots_follow); |
|
75 | + SEO::set('canonical', $this->page->canonical); |
|
76 | 76 | |
77 | 77 | # ------------------------ |
78 | 78 |
@@ -25,9 +25,11 @@ discard block |
||
25 | 25 | |
26 | 26 | # Set breadcrumbs |
27 | 27 | |
28 | - if (count($this->path) <= 1) $contents->getBlock('breadcrumbs')->disable(); |
|
29 | - |
|
30 | - else $contents->getBlock('breadcrumbs')->path = $this->path; |
|
28 | + if (count($this->path) <= 1) { |
|
29 | + $contents->getBlock('breadcrumbs')->disable(); |
|
30 | + } else { |
|
31 | + $contents->getBlock('breadcrumbs')->path = $this->path; |
|
32 | + } |
|
31 | 33 | |
32 | 34 | # Set contents |
33 | 35 | |
@@ -54,19 +56,31 @@ discard block |
||
54 | 56 | |
55 | 57 | $slug = $this->_url->getSlug(); |
56 | 58 | |
57 | - if ('' !== $slug) $this->page->initBySlug($slug); else $this->page->init(1); |
|
59 | + if ('' !== $slug) { |
|
60 | + $this->page->initBySlug($slug); |
|
61 | + } else { |
|
62 | + $this->page->init(1); |
|
63 | + } |
|
58 | 64 | |
59 | 65 | # Display error if not found |
60 | 66 | |
61 | - if (0 === $this->page->id) return false; |
|
67 | + if (0 === $this->page->id) { |
|
68 | + return false; |
|
69 | + } |
|
62 | 70 | |
63 | 71 | # Get path |
64 | 72 | |
65 | - if (false !== ($path = $this->page->getPath())) $this->path = $path; |
|
73 | + if (false !== ($path = $this->page->getPath())) { |
|
74 | + $this->path = $path; |
|
75 | + } |
|
66 | 76 | |
67 | 77 | # Set data |
68 | 78 | |
69 | - if ($this->page->id !== 1) SEO::set('title', $this->page->title); else $this->_layout = 'Index'; |
|
79 | + if ($this->page->id !== 1) { |
|
80 | + SEO::set('title', $this->page->title); |
|
81 | + } else { |
|
82 | + $this->_layout = 'Index'; |
|
83 | + } |
|
70 | 84 | |
71 | 85 | SEO::set('description', $this->page->description); |
72 | 86 | SEO::set('keywords', $this->page->keywords); |
@@ -45,7 +45,9 @@ discard block |
||
45 | 45 | |
46 | 46 | $name = Request::post('name'); |
47 | 47 | |
48 | - if (!$this->loader->activate($name, true)) return $ajax->setError(Language::get(static::$error_activate)); |
|
48 | + if (!$this->loader->activate($name, true)) { |
|
49 | + return $ajax->setError(Language::get(static::$error_activate)); |
|
50 | + } |
|
49 | 51 | |
50 | 52 | } else if (Request::post('action') === 'list') { |
51 | 53 | |
@@ -67,7 +69,9 @@ discard block |
||
67 | 69 | |
68 | 70 | $this->loader = new static::$loader_class(Request::get('list')); |
69 | 71 | |
70 | - if ($ajax) return $this->handleAjax(); |
|
72 | + if ($ajax) { |
|
73 | + return $this->handleAjax(); |
|
74 | + } |
|
71 | 75 | |
72 | 76 | # ------------------------ |
73 | 77 |
@@ -41,9 +41,9 @@ |
||
41 | 41 | |
42 | 42 | protected function loadItem(string $name) { |
43 | 43 | |
44 | - $path = ($this->dir_name . $name . '/'); |
|
44 | + $path = ($this->dir_name.$name.'/'); |
|
45 | 45 | |
46 | - if (null === ($data = JSON::load($path . '.Config.json'))) return null; |
|
46 | + if (null === ($data = JSON::load($path.'.Config.json'))) return null; |
|
47 | 47 | |
48 | 48 | if (null === ($data = Schema::get(static::$schema_prototype)->validate($data))) return null; |
49 | 49 |
@@ -25,7 +25,9 @@ discard block |
||
25 | 25 | |
26 | 26 | foreach (Explorer::iterateDirs($this->dir_name) as $name) { |
27 | 27 | |
28 | - if (null !== ($data = $this->loadItem($name))) $items[$name] = ($pattern + $data); |
|
28 | + if (null !== ($data = $this->loadItem($name))) { |
|
29 | + $items[$name] = ($pattern + $data); |
|
30 | + } |
|
29 | 31 | } |
30 | 32 | |
31 | 33 | # ------------------------ |
@@ -43,11 +45,17 @@ discard block |
||
43 | 45 | |
44 | 46 | $path = ($this->dir_name . $name . '/'); |
45 | 47 | |
46 | - if (null === ($data = JSON::load($path . '.Config.json'))) return null; |
|
48 | + if (null === ($data = JSON::load($path . '.Config.json'))) { |
|
49 | + return null; |
|
50 | + } |
|
47 | 51 | |
48 | - if (null === ($data = Schema::get(static::$schema_prototype)->validate($data))) return null; |
|
52 | + if (null === ($data = Schema::get(static::$schema_prototype)->validate($data))) { |
|
53 | + return null; |
|
54 | + } |
|
49 | 55 | |
50 | - if (!(static::$extension_class::isValid($data['name']) && ($data['name'] === $name))) return null; |
|
56 | + if (!(static::$extension_class::isValid($data['name']) && ($data['name'] === $name))) { |
|
57 | + return null; |
|
58 | + } |
|
51 | 59 | |
52 | 60 | # ------------------------ |
53 | 61 |
@@ -23,10 +23,10 @@ |
||
23 | 23 | } |
24 | 24 | |
25 | 25 | /** |
26 | - * Validate an item name |
|
27 | - * |
|
28 | - * @return string|false : the name or false on failure |
|
29 | - */ |
|
26 | + * Validate an item name |
|
27 | + * |
|
28 | + * @return string|false : the name or false on failure |
|
29 | + */ |
|
30 | 30 | |
31 | 31 | public static function validate(string $name) { |
32 | 32 |
@@ -41,7 +41,7 @@ |
||
41 | 41 | |
42 | 42 | if (null !== static::$loader) return static::$loader->$name(...$arguments); |
43 | 43 | |
44 | - throw new \BadMethodCallException('Call to undefined method ' . get_called_class() . '::' . $name . '()'); |
|
44 | + throw new \BadMethodCallException('Call to undefined method '.get_called_class().'::'.$name.'()'); |
|
45 | 45 | } |
46 | 46 | } |
47 | 47 | } |
@@ -39,7 +39,9 @@ |
||
39 | 39 | |
40 | 40 | public static function __callStatic($name, $arguments) { |
41 | 41 | |
42 | - if (null !== static::$loader) return static::$loader->$name(...$arguments); |
|
42 | + if (null !== static::$loader) { |
|
43 | + return static::$loader->$name(...$arguments); |
|
44 | + } |
|
43 | 45 | |
44 | 46 | throw new \BadMethodCallException('Call to undefined method ' . get_called_class() . '::' . $name . '()'); |
45 | 47 | } |
@@ -23,7 +23,9 @@ discard block |
||
23 | 23 | |
24 | 24 | foreach ((Schema::get(static::$schema)->load() ?? []) as $item) { |
25 | 25 | |
26 | - if (isset($items[$item['name']])) $items[$item['name']]['installed'] = true; |
|
26 | + if (isset($items[$item['name']])) { |
|
27 | + $items[$item['name']]['installed'] = true; |
|
28 | + } |
|
27 | 29 | } |
28 | 30 | |
29 | 31 | # ------------------------ |
@@ -41,7 +43,9 @@ discard block |
||
41 | 43 | |
42 | 44 | foreach ((Schema::get(static::$schema)->load() ?? []) as $item) { |
43 | 45 | |
44 | - if (static::$extension_class::isValid($item['name'])) $items[$item['name']] = $item; |
|
46 | + if (static::$extension_class::isValid($item['name'])) { |
|
47 | + $items[$item['name']] = $item; |
|
48 | + } |
|
45 | 49 | } |
46 | 50 | |
47 | 51 | # ------------------------ |
@@ -70,18 +74,26 @@ discard block |
||
70 | 74 | |
71 | 75 | public function install(string $name, bool $value = true) : bool { |
72 | 76 | |
73 | - if (!isset($this->items[$name])) return false; |
|
77 | + if (!isset($this->items[$name])) { |
|
78 | + return false; |
|
79 | + } |
|
74 | 80 | |
75 | 81 | $items = []; |
76 | 82 | |
77 | 83 | foreach ($this->items as $item) { |
78 | 84 | |
79 | - if ($value) { if ($item['installed'] || ($item['name'] === $name)) $items[] = $item; } |
|
80 | - |
|
81 | - else { if ($item['installed'] && ($item['name'] !== $name)) $items[] = $item; } |
|
85 | + if ($value) { if ($item['installed'] || ($item['name'] === $name)) { |
|
86 | + $items[] = $item; |
|
87 | + } |
|
88 | + } else { if ($item['installed'] && ($item['name'] !== $name)) { |
|
89 | + $items[] = $item; |
|
90 | + } |
|
91 | + } |
|
82 | 92 | } |
83 | 93 | |
84 | - if (!Schema::get(static::$schema)->save($items)) return false; |
|
94 | + if (!Schema::get(static::$schema)->save($items)) { |
|
95 | + return false; |
|
96 | + } |
|
85 | 97 | |
86 | 98 | $this->items[$name]['installed'] = $value; |
87 | 99 |