@@ -133,7 +133,7 @@ |
||
133 | 133 | /** |
134 | 134 | * Get the active item data or a specific param value |
135 | 135 | * |
136 | - * @return array|mixed|false : the data array, the param value, or false if the active item was not loaded |
|
136 | + * @return string : the data array, the param value, or false if the active item was not loaded |
|
137 | 137 | */ |
138 | 138 | |
139 | 139 | public function get(string $param = null) { |
@@ -34,11 +34,15 @@ discard block |
||
34 | 34 | |
35 | 35 | protected function loadFirst() { |
36 | 36 | |
37 | - if ($this->loaded) return ($this->items[key($this->items)] ?? null); |
|
37 | + if ($this->loaded) { |
|
38 | + return ($this->items[key($this->items)] ?? null); |
|
39 | + } |
|
38 | 40 | |
39 | 41 | foreach (Explorer::iterateDirs($this->dir_name) as $name) { |
40 | 42 | |
41 | - if (null !== ($data = $this->loadItem($name))) return $data; |
|
43 | + if (null !== ($data = $this->loadItem($name))) { |
|
44 | + return $data; |
|
45 | + } |
|
42 | 46 | } |
43 | 47 | |
44 | 48 | # ------------------------ |
@@ -97,9 +101,13 @@ discard block |
||
97 | 101 | |
98 | 102 | public function activate(string $name, bool $save = false) : bool { |
99 | 103 | |
100 | - if (null === ($data = $this->loadItem($name))) return false; |
|
104 | + if (null === ($data = $this->loadItem($name))) { |
|
105 | + return false; |
|
106 | + } |
|
101 | 107 | |
102 | - if ($save && ((!Settings::set(static::$param[$this->section], $name)) || !Settings::save())) return false; |
|
108 | + if ($save && ((!Settings::set(static::$param[$this->section], $name)) || !Settings::save())) { |
|
109 | + return false; |
|
110 | + } |
|
103 | 111 | |
104 | 112 | $this->active = $data; |
105 | 113 | |
@@ -125,7 +133,9 @@ discard block |
||
125 | 133 | |
126 | 134 | public function getPrimary(string $param = null) { |
127 | 135 | |
128 | - if (null !== $param) return ($this->primary[$param] ?? false); |
|
136 | + if (null !== $param) { |
|
137 | + return ($this->primary[$param] ?? false); |
|
138 | + } |
|
129 | 139 | |
130 | 140 | return ($this->primary ?? false); |
131 | 141 | } |
@@ -138,7 +148,9 @@ discard block |
||
138 | 148 | |
139 | 149 | public function get(string $param = null) { |
140 | 150 | |
141 | - if (null !== $param) return ($this->active[$param] ?? false); |
|
151 | + if (null !== $param) { |
|
152 | + return ($this->active[$param] ?? false); |
|
153 | + } |
|
142 | 154 | |
143 | 155 | return ($this->active ?? false); |
144 | 156 | } |
@@ -92,7 +92,7 @@ |
||
92 | 92 | |
93 | 93 | if (false === ($handler = self::parseString($route['handler'], REGEX_MAP_ITEM_HANDLER))) return; |
94 | 94 | |
95 | - self::$routes['/' . implode('/', $path)] = ('Addons\\' . $name . '\\' . implode('\\', $handler)); |
|
95 | + self::$routes['/'.implode('/', $path)] = ('Addons\\'.$name.'\\'.implode('\\', $handler)); |
|
96 | 96 | } |
97 | 97 | |
98 | 98 | /** |
@@ -75,7 +75,9 @@ discard block |
||
75 | 75 | |
76 | 76 | $parts = preg_split('/\//', $string, 0, PREG_SPLIT_NO_EMPTY); |
77 | 77 | |
78 | - foreach ($parts as $name) if (!preg_match($regex, $name)) return false; |
|
78 | + foreach ($parts as $name) { |
|
79 | + if (!preg_match($regex, $name)) return false; |
|
80 | + } |
|
79 | 81 | |
80 | 82 | # ------------------------ |
81 | 83 | |
@@ -88,9 +90,13 @@ discard block |
||
88 | 90 | |
89 | 91 | private static function parseRoute(string $name, array $route) { |
90 | 92 | |
91 | - if (false === ($path = self::parseString($route['path'], REGEX_MAP_ITEM_PATH))) return; |
|
93 | + if (false === ($path = self::parseString($route['path'], REGEX_MAP_ITEM_PATH))) { |
|
94 | + return; |
|
95 | + } |
|
92 | 96 | |
93 | - if (false === ($handler = self::parseString($route['handler'], REGEX_MAP_ITEM_HANDLER))) return; |
|
97 | + if (false === ($handler = self::parseString($route['handler'], REGEX_MAP_ITEM_HANDLER))) { |
|
98 | + return; |
|
99 | + } |
|
94 | 100 | |
95 | 101 | self::$routes['/' . implode('/', $path)] = ('Addons\\' . $name . '\\' . implode('\\', $handler)); |
96 | 102 | } |
@@ -103,7 +109,9 @@ discard block |
||
103 | 109 | |
104 | 110 | foreach (Extend\Addons::getItems() as $item) { |
105 | 111 | |
106 | - foreach ($item['routes'] as $route) self::parseRoute($item['name'], $route); |
|
112 | + foreach ($item['routes'] as $route) { |
|
113 | + self::parseRoute($item['name'], $route); |
|
114 | + } |
|
107 | 115 | } |
108 | 116 | } |
109 | 117 |
@@ -29,7 +29,9 @@ discard block |
||
29 | 29 | |
30 | 30 | $item->children = ($children = Template::createBlock()); |
31 | 31 | |
32 | - foreach ($this->menu[$id]['children'] as $child) $children->addItem($this->parseItem($child)); |
|
32 | + foreach ($this->menu[$id]['children'] as $child) { |
|
33 | + $children->addItem($this->parseItem($child)); |
|
34 | + } |
|
33 | 35 | |
34 | 36 | } else { |
35 | 37 | |
@@ -55,7 +57,9 @@ discard block |
||
55 | 57 | |
56 | 58 | $menu = Entitizer::getTreeview(TABLE_MENU)->getSubtree(0, ['active' => true]); |
57 | 59 | |
58 | - if (false !== $menu) $this->menu = $menu; |
|
60 | + if (false !== $menu) { |
|
61 | + $this->menu = $menu; |
|
62 | + } |
|
59 | 63 | } |
60 | 64 | |
61 | 65 | /** |
@@ -66,7 +70,9 @@ discard block |
||
66 | 70 | |
67 | 71 | $menu = Template::createBlock(); |
68 | 72 | |
69 | - foreach ($this->menu[0]['children'] as $id) $menu->addItem($this->parseItem($id)); |
|
73 | + foreach ($this->menu[0]['children'] as $id) { |
|
74 | + $menu->addItem($this->parseItem($id)); |
|
75 | + } |
|
70 | 76 | |
71 | 77 | # ------------------------ |
72 | 78 |
@@ -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 |