@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | /** |
63 | 63 | * Update the entity dataset with a selected data. Also updates every entity object having an identical id |
64 | 64 | * |
65 | - * @return true : always true ;) |
|
65 | + * @return boolean : always true ;) |
|
66 | 66 | */ |
67 | 67 | |
68 | 68 | protected function setData(array $data) : bool { |
@@ -137,6 +137,7 @@ discard block |
||
137 | 137 | * Check whether another entity with a given unique param value exists. |
138 | 138 | * This method is useful to find out is it possible to change the entity's unique param value to the given one |
139 | 139 | * |
140 | + * @param string $value |
|
140 | 141 | * @return int|false : the number of entities found (0 or 1) or false on error |
141 | 142 | */ |
142 | 143 |
@@ -183,7 +183,7 @@ discard block |
||
183 | 183 | /** |
184 | 184 | * Get the entity creation time |
185 | 185 | * |
186 | - * @return int|false : the time or false on failure |
|
186 | + * @return null|integer : the time or false on failure |
|
187 | 187 | */ |
188 | 188 | |
189 | 189 | public function getCreated() { |
@@ -209,7 +209,7 @@ discard block |
||
209 | 209 | /** |
210 | 210 | * Get the entity modification time |
211 | 211 | * |
212 | - * @return int|false : the time or false on failure |
|
212 | + * @return null|integer : the time or false on failure |
|
213 | 213 | */ |
214 | 214 | |
215 | 215 | public function getModified() { |
@@ -235,7 +235,7 @@ discard block |
||
235 | 235 | /** |
236 | 236 | * Get the entity size |
237 | 237 | * |
238 | - * @return int|false : the size or false on failure |
|
238 | + * @return integer : the size or false on failure |
|
239 | 239 | */ |
240 | 240 | |
241 | 241 | public function getSize() { |
@@ -27,9 +27,9 @@ |
||
27 | 27 | |
28 | 28 | if ($this->parent->isIgnoreHidden() && preg_match('/^\./', $name)) return false; |
29 | 29 | |
30 | - $path = (($this->parent->getPath() ? ($this->parent->getPath() . '/') : '') . $name); |
|
30 | + $path = (($this->parent->getPath() ? ($this->parent->getPath().'/') : '').$name); |
|
31 | 31 | |
32 | - $path_full = ($this->parent->getPathFull() . $name); |
|
32 | + $path_full = ($this->parent->getPathFull().$name); |
|
33 | 33 | |
34 | 34 | # ------------------------ |
35 | 35 |
@@ -23,9 +23,13 @@ discard block |
||
23 | 23 | |
24 | 24 | private function getPrototype(string $name) { |
25 | 25 | |
26 | - if (('' === $name) || preg_match('/[\/\\\\]/', $name)) return false; |
|
26 | + if (('' === $name) || preg_match('/[\/\\\\]/', $name)) { |
|
27 | + return false; |
|
28 | + } |
|
27 | 29 | |
28 | - if ($this->parent->isIgnoreHidden() && preg_match('/^\./', $name)) return false; |
|
30 | + if ($this->parent->isIgnoreHidden() && preg_match('/^\./', $name)) { |
|
31 | + return false; |
|
32 | + } |
|
29 | 33 | |
30 | 34 | $path = (($this->parent->getPath() ? ($this->parent->getPath() . '/') : '') . $name); |
31 | 35 | |
@@ -53,17 +57,23 @@ discard block |
||
53 | 57 | |
54 | 58 | public function init(string $name) : bool { |
55 | 59 | |
56 | - if (false === ($prototype = $this->getPrototype($name))) return false; |
|
60 | + if (false === ($prototype = $this->getPrototype($name))) { |
|
61 | + return false; |
|
62 | + } |
|
57 | 63 | |
58 | 64 | # Check type |
59 | 65 | |
60 | 66 | $type = Explorer::getType($prototype['path_full']); |
61 | 67 | |
62 | - if (!in_array($type, ['dir', 'file'], true)) return false; |
|
68 | + if (!in_array($type, ['dir', 'file'], true)) { |
|
69 | + return false; |
|
70 | + } |
|
63 | 71 | |
64 | 72 | # Set data |
65 | 73 | |
66 | - foreach ($prototype as $var => $value) $this->$var = $value; |
|
74 | + foreach ($prototype as $var => $value) { |
|
75 | + $this->$var = $value; |
|
76 | + } |
|
67 | 77 | |
68 | 78 | $this->type = $type; |
69 | 79 | |
@@ -81,9 +91,13 @@ discard block |
||
81 | 91 | |
82 | 92 | public function check(string $name) : bool { |
83 | 93 | |
84 | - if (false === ($prototype = $this->getPrototype($name))) return false; |
|
94 | + if (false === ($prototype = $this->getPrototype($name))) { |
|
95 | + return false; |
|
96 | + } |
|
85 | 97 | |
86 | - if (($name !== $this->name) && Explorer::exists($prototype['path_full'])) return false; |
|
98 | + if (($name !== $this->name) && Explorer::exists($prototype['path_full'])) { |
|
99 | + return false; |
|
100 | + } |
|
87 | 101 | |
88 | 102 | # ------------------------ |
89 | 103 | |
@@ -98,19 +112,27 @@ discard block |
||
98 | 112 | |
99 | 113 | public function create(string $name, string $type) : bool { |
100 | 114 | |
101 | - if (('' !== $this->name) || (false === ($prototype = $this->getPrototype($name)))) return false; |
|
115 | + if (('' !== $this->name) || (false === ($prototype = $this->getPrototype($name)))) { |
|
116 | + return false; |
|
117 | + } |
|
102 | 118 | |
103 | - if (!in_array($type, ['dir', 'file'], true)) return false; |
|
119 | + if (!in_array($type, ['dir', 'file'], true)) { |
|
120 | + return false; |
|
121 | + } |
|
104 | 122 | |
105 | 123 | # Create entity |
106 | 124 | |
107 | 125 | $create = (($type === 'dir') ? 'createDir' : 'createFile'); |
108 | 126 | |
109 | - if (!Explorer::$create($prototype['path_full'])) return false; |
|
127 | + if (!Explorer::$create($prototype['path_full'])) { |
|
128 | + return false; |
|
129 | + } |
|
110 | 130 | |
111 | 131 | # Set data |
112 | 132 | |
113 | - foreach ($prototype as $var => $value) $this->$var = $value; |
|
133 | + foreach ($prototype as $var => $value) { |
|
134 | + $this->$var = $value; |
|
135 | + } |
|
114 | 136 | |
115 | 137 | $this->type = $type; |
116 | 138 | |
@@ -127,15 +149,21 @@ discard block |
||
127 | 149 | |
128 | 150 | public function rename(string $name) : bool { |
129 | 151 | |
130 | - if (('' === $this->name) || (false === ($prototype = $this->getPrototype($name)))) return false; |
|
152 | + if (('' === $this->name) || (false === ($prototype = $this->getPrototype($name)))) { |
|
153 | + return false; |
|
154 | + } |
|
131 | 155 | |
132 | 156 | # Rename entity |
133 | 157 | |
134 | - if (!Explorer::rename($this->path_full, $prototype['path_full'])) return false; |
|
158 | + if (!Explorer::rename($this->path_full, $prototype['path_full'])) { |
|
159 | + return false; |
|
160 | + } |
|
135 | 161 | |
136 | 162 | # Set data |
137 | 163 | |
138 | - foreach ($prototype as $var => $value) $this->$var = $value; |
|
164 | + foreach ($prototype as $var => $value) { |
|
165 | + $this->$var = $value; |
|
166 | + } |
|
139 | 167 | |
140 | 168 | # ------------------------ |
141 | 169 | |
@@ -150,13 +178,17 @@ discard block |
||
150 | 178 | |
151 | 179 | public function remove() : bool { |
152 | 180 | |
153 | - if ('' === $this->name) return false; |
|
181 | + if ('' === $this->name) { |
|
182 | + return false; |
|
183 | + } |
|
154 | 184 | |
155 | 185 | # Remove entity |
156 | 186 | |
157 | 187 | $remove = (($this->type === 'dir') ? 'removeDir' : 'removeFile'); |
158 | 188 | |
159 | - if (!Explorer::$remove($this->path_full, true)) return false; |
|
189 | + if (!Explorer::$remove($this->path_full, true)) { |
|
190 | + return false; |
|
191 | + } |
|
160 | 192 | |
161 | 193 | # Reset data |
162 | 194 | |
@@ -175,7 +207,9 @@ discard block |
||
175 | 207 | |
176 | 208 | public function getExtension() { |
177 | 209 | |
178 | - if ('' === $this->name) return false; |
|
210 | + if ('' === $this->name) { |
|
211 | + return false; |
|
212 | + } |
|
179 | 213 | |
180 | 214 | return strtolower(Explorer::getExtension($this->name, false)); |
181 | 215 | } |
@@ -188,7 +222,9 @@ discard block |
||
188 | 222 | |
189 | 223 | public function getCreated() { |
190 | 224 | |
191 | - if ('' === $this->name) return false; |
|
225 | + if ('' === $this->name) { |
|
226 | + return false; |
|
227 | + } |
|
192 | 228 | |
193 | 229 | return Explorer::getCreated($this->path_full); |
194 | 230 | } |
@@ -201,7 +237,9 @@ discard block |
||
201 | 237 | |
202 | 238 | public function getAccessed() { |
203 | 239 | |
204 | - if ('' === $this->name) return false; |
|
240 | + if ('' === $this->name) { |
|
241 | + return false; |
|
242 | + } |
|
205 | 243 | |
206 | 244 | return Explorer::getAccessed($this->path_full); |
207 | 245 | } |
@@ -214,7 +252,9 @@ discard block |
||
214 | 252 | |
215 | 253 | public function getModified() { |
216 | 254 | |
217 | - if ('' === $this->name) return false; |
|
255 | + if ('' === $this->name) { |
|
256 | + return false; |
|
257 | + } |
|
218 | 258 | |
219 | 259 | return Explorer::getModified($this->path_full); |
220 | 260 | } |
@@ -227,7 +267,9 @@ discard block |
||
227 | 267 | |
228 | 268 | public function getPermissions() { |
229 | 269 | |
230 | - if ('' === $this->name) return false; |
|
270 | + if ('' === $this->name) { |
|
271 | + return false; |
|
272 | + } |
|
231 | 273 | |
232 | 274 | return Explorer::getPermissions($this->path_full); |
233 | 275 | } |
@@ -240,7 +282,9 @@ discard block |
||
240 | 282 | |
241 | 283 | public function getSize() { |
242 | 284 | |
243 | - if ('' === $this->name) return false; |
|
285 | + if ('' === $this->name) { |
|
286 | + return false; |
|
287 | + } |
|
244 | 288 | |
245 | 289 | return Explorer::getSize($this->path_full); |
246 | 290 | } |
@@ -253,7 +297,9 @@ discard block |
||
253 | 297 | |
254 | 298 | public function getContents() { |
255 | 299 | |
256 | - if ('' === $this->name) return false; |
|
300 | + if ('' === $this->name) { |
|
301 | + return false; |
|
302 | + } |
|
257 | 303 | |
258 | 304 | return Explorer::getContents($this->path_full); |
259 | 305 | } |
@@ -266,7 +312,9 @@ discard block |
||
266 | 312 | |
267 | 313 | public function putContents(string $contents) { |
268 | 314 | |
269 | - if ('' === $this->name) return false; |
|
315 | + if ('' === $this->name) { |
|
316 | + return false; |
|
317 | + } |
|
270 | 318 | |
271 | 319 | return Explorer::putContents($this->path_full, $contents); |
272 | 320 | } |
@@ -9,64 +9,64 @@ |
||
9 | 9 | |
10 | 10 | # Cadmium |
11 | 11 | |
12 | -define('CADMIUM_NAME', 'Cadmium CMS'); |
|
13 | -define('CADMIUM_HOME', 'http://cadmium-cms.com'); |
|
12 | +define('CADMIUM_NAME', 'Cadmium CMS'); |
|
13 | +define('CADMIUM_HOME', 'http://cadmium-cms.com'); |
|
14 | 14 | |
15 | -define('CADMIUM_VERSION', '0.4.6'); |
|
16 | -define('CADMIUM_COPY', '2017'); |
|
15 | +define('CADMIUM_VERSION', '0.4.6'); |
|
16 | +define('CADMIUM_COPY', '2017'); |
|
17 | 17 | |
18 | 18 | # Third-party |
19 | 19 | |
20 | -define('JQUERY_VERSION', '3.2.1'); |
|
21 | -define('SEMANTIC_UI_VERSION', '2.2.10'); |
|
22 | -define('CKEDITOR_VERSION', '4.6.2'); |
|
23 | -define('ACE_VERSION', '1.2.6'); |
|
20 | +define('JQUERY_VERSION', '3.2.1'); |
|
21 | +define('SEMANTIC_UI_VERSION', '2.2.10'); |
|
22 | +define('CKEDITOR_VERSION', '4.6.2'); |
|
23 | +define('ACE_VERSION', '1.2.6'); |
|
24 | 24 | |
25 | 25 | # Sections |
26 | 26 | |
27 | -define('SECTION_SITE', 'site'); |
|
28 | -define('SECTION_ADMIN', 'admin'); |
|
27 | +define('SECTION_SITE', 'site'); |
|
28 | +define('SECTION_ADMIN', 'admin'); |
|
29 | 29 | |
30 | 30 | # Access |
31 | 31 | |
32 | -define('ACCESS_PUBLIC', 0); |
|
33 | -define('ACCESS_REGISTERED', 1); |
|
34 | -define('ACCESS_ADMINISTRATOR', 2); |
|
32 | +define('ACCESS_PUBLIC', 0); |
|
33 | +define('ACCESS_REGISTERED', 1); |
|
34 | +define('ACCESS_ADMINISTRATOR', 2); |
|
35 | 35 | |
36 | 36 | # Frequency |
37 | 37 | |
38 | -define('FREQUENCY_ALWAYS', 'always'); |
|
39 | -define('FREQUENCY_HOURLY', 'hourly'); |
|
40 | -define('FREQUENCY_DAILY', 'daily'); |
|
41 | -define('FREQUENCY_WEEKLY', 'weekly'); |
|
42 | -define('FREQUENCY_MONTHLY', 'monthly'); |
|
43 | -define('FREQUENCY_YEARLY', 'yearly'); |
|
44 | -define('FREQUENCY_NEVER', 'never'); |
|
38 | +define('FREQUENCY_ALWAYS', 'always'); |
|
39 | +define('FREQUENCY_HOURLY', 'hourly'); |
|
40 | +define('FREQUENCY_DAILY', 'daily'); |
|
41 | +define('FREQUENCY_WEEKLY', 'weekly'); |
|
42 | +define('FREQUENCY_MONTHLY', 'monthly'); |
|
43 | +define('FREQUENCY_YEARLY', 'yearly'); |
|
44 | +define('FREQUENCY_NEVER', 'never'); |
|
45 | 45 | |
46 | 46 | # Rank |
47 | 47 | |
48 | -define('RANK_GUEST', 0); |
|
49 | -define('RANK_USER', 1); |
|
50 | -define('RANK_ADMINISTRATOR', 2); |
|
48 | +define('RANK_GUEST', 0); |
|
49 | +define('RANK_USER', 1); |
|
50 | +define('RANK_ADMINISTRATOR', 2); |
|
51 | 51 | |
52 | 52 | # Sex |
53 | 53 | |
54 | -define('SEX_NOT_SELECTED', 0); |
|
55 | -define('SEX_MALE', 1); |
|
56 | -define('SEX_FEMALE', 2); |
|
54 | +define('SEX_NOT_SELECTED', 0); |
|
55 | +define('SEX_MALE', 1); |
|
56 | +define('SEX_FEMALE', 2); |
|
57 | 57 | |
58 | 58 | # Status |
59 | 59 | |
60 | -define('STATUS_ONLINE', 0); |
|
61 | -define('STATUS_MAINTENANCE', 1); |
|
62 | -define('STATUS_UPDATE', 2); |
|
60 | +define('STATUS_ONLINE', 0); |
|
61 | +define('STATUS_MAINTENANCE', 1); |
|
62 | +define('STATUS_UPDATE', 2); |
|
63 | 63 | |
64 | 64 | # Target |
65 | 65 | |
66 | -define('TARGET_SELF', 0); |
|
67 | -define('TARGET_BLANK', 1); |
|
66 | +define('TARGET_SELF', 0); |
|
67 | +define('TARGET_BLANK', 1); |
|
68 | 68 | |
69 | 69 | # Visibility |
70 | 70 | |
71 | -define('VISIBILITY_DRAFT', 0); |
|
72 | -define('VISIBILITY_PUBLISHED', 1); |
|
71 | +define('VISIBILITY_DRAFT', 0); |
|
72 | +define('VISIBILITY_PUBLISHED', 1); |
@@ -32,10 +32,12 @@ discard block |
||
32 | 32 | |
33 | 33 | $phrases = array_merge(static::PHRASES, array_keys(Extend\Addons::items() ?? [])); |
34 | 34 | |
35 | - foreach (array_unique($languages) as $path) foreach ($phrases as $name) { |
|
35 | + foreach (array_unique($languages) as $path) { |
|
36 | + foreach ($phrases as $name) { |
|
36 | 37 | |
37 | 38 | Language::load($path . 'Phrases/' . $name . '.php'); |
38 | 39 | } |
40 | + } |
|
39 | 41 | } |
40 | 42 | |
41 | 43 | /** |
@@ -86,7 +88,9 @@ discard block |
||
86 | 88 | |
87 | 89 | # Set timezone |
88 | 90 | |
89 | - if (Auth::isLogged() && ('' !== ($timezone = Auth::get('timezone')))) date_default_timezone_set($timezone); |
|
91 | + if (Auth::isLogged() && ('' !== ($timezone = Auth::get('timezone')))) { |
|
92 | + date_default_timezone_set($timezone); |
|
93 | + } |
|
90 | 94 | |
91 | 95 | # Init utils |
92 | 96 |
@@ -21,7 +21,9 @@ |
||
21 | 21 | |
22 | 22 | protected function handle(bool $ajax = false) { |
23 | 23 | |
24 | - if (!$ajax) return false; |
|
24 | + if (!$ajax) { |
|
25 | + return false; |
|
26 | + } |
|
25 | 27 | |
26 | 28 | # Create response |
27 | 29 |
@@ -44,19 +44,27 @@ |
||
44 | 44 | |
45 | 45 | # Validate name |
46 | 46 | |
47 | - if (false === ($name = Validate::fileName($name))) return ['name', 'FILEMANAGER_ERROR_NAME_INVALID']; |
|
47 | + if (false === ($name = Validate::fileName($name))) { |
|
48 | + return ['name', 'FILEMANAGER_ERROR_NAME_INVALID']; |
|
49 | + } |
|
48 | 50 | |
49 | - if ($this->parent->isIgnoreHidden() && preg_match('/^\./', $name)) return ['name', 'FILEMANAGER_ERROR_HIDDEN']; |
|
51 | + if ($this->parent->isIgnoreHidden() && preg_match('/^\./', $name)) { |
|
52 | + return ['name', 'FILEMANAGER_ERROR_HIDDEN']; |
|
53 | + } |
|
50 | 54 | |
51 | 55 | # Check if name is used |
52 | 56 | |
53 | - if (!$this->entity->check($name)) return ['name', 'FILEMANAGER_ERROR_EXISTS']; |
|
57 | + if (!$this->entity->check($name)) { |
|
58 | + return ['name', 'FILEMANAGER_ERROR_EXISTS']; |
|
59 | + } |
|
54 | 60 | |
55 | 61 | # Rename entity |
56 | 62 | |
57 | - if (!$this->entity->rename($name)) return (($this->entity->getType() === 'dir') ? |
|
63 | + if (!$this->entity->rename($name)) { |
|
64 | + return (($this->entity->getType() === 'dir') ? |
|
58 | 65 | |
59 | 66 | 'FILEMANAGER_ERROR_DIR_RENAME' : 'FILEMANAGER_ERROR_FILE_RENAME'); |
67 | + } |
|
60 | 68 | |
61 | 69 | # ------------------------ |
62 | 70 |
@@ -44,7 +44,9 @@ |
||
44 | 44 | |
45 | 45 | # Rename item |
46 | 46 | |
47 | - if (false === $this->entity->putContents($contents)) return 'FILEMANAGER_ERROR_FILE_EDIT'; |
|
47 | + if (false === $this->entity->putContents($contents)) { |
|
48 | + return 'FILEMANAGER_ERROR_FILE_EDIT'; |
|
49 | + } |
|
48 | 50 | |
49 | 51 | # ------------------------ |
50 | 52 |
@@ -44,9 +44,13 @@ discard block |
||
44 | 44 | |
45 | 45 | # Validate name |
46 | 46 | |
47 | - if (false === ($name = Validate::fileName($name))) return ['name', 'FILEMANAGER_ERROR_NAME_INVALID']; |
|
47 | + if (false === ($name = Validate::fileName($name))) { |
|
48 | + return ['name', 'FILEMANAGER_ERROR_NAME_INVALID']; |
|
49 | + } |
|
48 | 50 | |
49 | - if ($this->parent->isIgnoreHidden() && preg_match('/^\./', $name)) return ['name', 'FILEMANAGER_ERROR_HIDDEN']; |
|
51 | + if ($this->parent->isIgnoreHidden() && preg_match('/^\./', $name)) { |
|
52 | + return ['name', 'FILEMANAGER_ERROR_HIDDEN']; |
|
53 | + } |
|
50 | 54 | |
51 | 55 | # Get entity |
52 | 56 | |
@@ -54,11 +58,15 @@ discard block |
||
54 | 58 | |
55 | 59 | # Check if name is used |
56 | 60 | |
57 | - if (!$entity->check($name)) return ['name', 'FILEMANAGER_ERROR_EXISTS']; |
|
61 | + if (!$entity->check($name)) { |
|
62 | + return ['name', 'FILEMANAGER_ERROR_EXISTS']; |
|
63 | + } |
|
58 | 64 | |
59 | 65 | # Create entity |
60 | 66 | |
61 | - if (!$entity->create($name, 'dir')) return 'FILEMANAGER_ERROR_DIR_CREATE'; |
|
67 | + if (!$entity->create($name, 'dir')) { |
|
68 | + return 'FILEMANAGER_ERROR_DIR_CREATE'; |
|
69 | + } |
|
62 | 70 | |
63 | 71 | # ------------------------ |
64 | 72 |
@@ -15,6 +15,6 @@ |
||
15 | 15 | |
16 | 16 | use Filemanager\Common\Addons; |
17 | 17 | |
18 | - protected $path_full = (DIR_SYSTEM_CLASSES . 'Addons/'); |
|
18 | + protected $path_full = (DIR_SYSTEM_CLASSES.'Addons/'); |
|
19 | 19 | } |
20 | 20 | } |