@@ -25,9 +25,9 @@ discard block |
||
| 25 | 25 | |
| 26 | 26 | $name = $entity->getName(); $path = $entity->getPath(); |
| 27 | 27 | |
| 28 | - $query = ('?parent=' . $parent->getPath() . '&name=' . $name); |
|
| 28 | + $query = ('?parent='.$parent->getPath().'&name='.$name); |
|
| 29 | 29 | |
| 30 | - $link = (INSTALL_PATH . '/admin/content/filemanager/' . $parent->getOrigin() . '/dir' . $query); |
|
| 30 | + $link = (INSTALL_PATH.'/admin/content/filemanager/'.$parent->getOrigin().'/dir'.$query); |
|
| 31 | 31 | |
| 32 | 32 | # Set data |
| 33 | 33 | |
@@ -35,7 +35,7 @@ discard block |
||
| 35 | 35 | |
| 36 | 36 | # Set link |
| 37 | 37 | |
| 38 | - $view->link = (INSTALL_PATH . '/admin/content/filemanager/' . $parent->getOrigin() . '?parent=' . $path); |
|
| 38 | + $view->link = (INSTALL_PATH.'/admin/content/filemanager/'.$parent->getOrigin().'?parent='.$path); |
|
| 39 | 39 | |
| 40 | 40 | # Set buttons |
| 41 | 41 | |
@@ -29,9 +29,9 @@ discard block |
||
| 29 | 29 | |
| 30 | 30 | $format = Filemanager\Utils\Mime::getFormat($entity->getExtension()); |
| 31 | 31 | |
| 32 | - $query = ('?parent=' . $parent->getPath() . '&name=' . $name); |
|
| 32 | + $query = ('?parent='.$parent->getPath().'&name='.$name); |
|
| 33 | 33 | |
| 34 | - $link = (INSTALL_PATH . '/admin/content/filemanager/' . $parent->getOrigin() . '/file' . $query); |
|
| 34 | + $link = (INSTALL_PATH.'/admin/content/filemanager/'.$parent->getOrigin().'/file'.$query); |
|
| 35 | 35 | |
| 36 | 36 | # Set data |
| 37 | 37 | |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | |
| 40 | 40 | # Set link |
| 41 | 41 | |
| 42 | - $view->link = ($permissions['browse'] ? (INSTALL_PATH . '/uploads/' . $path) : $link); |
|
| 42 | + $view->link = ($permissions['browse'] ? (INSTALL_PATH.'/uploads/'.$path) : $link); |
|
| 43 | 43 | |
| 44 | 44 | $view->target = ($permissions['browse'] ? '_blank' : '_self'); |
| 45 | 45 | |
@@ -35,7 +35,9 @@ discard block |
||
| 35 | 35 | |
| 36 | 36 | public function load(int $index = 0, int $display = 0) : Loader { |
| 37 | 37 | |
| 38 | - if (!(($index >= 0) && ($display >= 0))) return $this; |
|
| 38 | + if (!(($index >= 0) && ($display >= 0))) { |
|
| 39 | + return $this; |
|
| 40 | + } |
|
| 39 | 41 | |
| 40 | 42 | $dirs = []; $files = []; |
| 41 | 43 | |
@@ -43,9 +45,15 @@ discard block |
||
| 43 | 45 | |
| 44 | 46 | foreach (Explorer::iterate($this->parent->getPathFull()) as $name) { |
| 45 | 47 | |
| 46 | - if (!($entity = new Entity($this->parent, $name))->isInited()) continue; |
|
| 48 | + if (!($entity = new Entity($this->parent, $name))->isInited()) { |
|
| 49 | + continue; |
|
| 50 | + } |
|
| 47 | 51 | |
| 48 | - if ($entity->isDir()) $dirs[] = $entity; else $files[] = $entity; |
|
| 52 | + if ($entity->isDir()) { |
|
| 53 | + $dirs[] = $entity; |
|
| 54 | + } else { |
|
| 55 | + $files[] = $entity; |
|
| 56 | + } |
|
| 49 | 57 | } |
| 50 | 58 | |
| 51 | 59 | # Sort arrays |
@@ -61,7 +69,9 @@ discard block |
||
| 61 | 69 | |
| 62 | 70 | $items = array_merge($dirs, $files); $total = count($items); |
| 63 | 71 | |
| 64 | - if (($index > 0) && ($display > 0)) $items = array_splice($items, (($index - 1) * $display), $display); |
|
| 72 | + if (($index > 0) && ($display > 0)) { |
|
| 73 | + $items = array_splice($items, (($index - 1) * $display), $display); |
|
| 74 | + } |
|
| 65 | 75 | |
| 66 | 76 | # Set properties |
| 67 | 77 | |
@@ -50,7 +50,7 @@ |
||
| 50 | 50 | |
| 51 | 51 | # Sort arrays |
| 52 | 52 | |
| 53 | - $sort = function (Entity $a, Entity $b) { |
|
| 53 | + $sort = function(Entity $a, Entity $b) { |
|
| 54 | 54 | |
| 55 | 55 | return strcmp(Str::toLower($a->getName()), Str::toLower($b->getName())); |
| 56 | 56 | }; |
@@ -118,9 +118,9 @@ discard block |
||
| 118 | 118 | |
| 119 | 119 | if (!$this->entity->isInited()) { |
| 120 | 120 | |
| 121 | - $query = (('' !== $this->parent->getPath()) ? ('?parent=' . $this->parent->getPath()) : ''); |
|
| 121 | + $query = (('' !== $this->parent->getPath()) ? ('?parent='.$this->parent->getPath()) : ''); |
|
| 122 | 122 | |
| 123 | - Request::redirect(INSTALL_PATH . '/admin/content/filemanager/' . static::$origin . '/' . $query); |
|
| 123 | + Request::redirect(INSTALL_PATH.'/admin/content/filemanager/'.static::$origin.'/'.$query); |
|
| 124 | 124 | } |
| 125 | 125 | |
| 126 | 126 | # Create rename form |
@@ -142,9 +142,9 @@ discard block |
||
| 142 | 142 | |
| 143 | 143 | foreach ($this->forms as $name => $form) if ($form->handle($this->controllers[$name], true)) { |
| 144 | 144 | |
| 145 | - Request::redirect(INSTALL_PATH . '/admin/content/filemanager/' . static::$origin . '/' . static::$type . |
|
| 145 | + Request::redirect(INSTALL_PATH.'/admin/content/filemanager/'.static::$origin.'/'.static::$type. |
|
| 146 | 146 | |
| 147 | - '?parent=' . $this->parent->getPath() . '&name=' . $this->entity->getName() . '&submitted=' . $name); |
|
| 147 | + '?parent='.$this->parent->getPath().'&name='.$this->entity->getName().'&submitted='.$name); |
|
| 148 | 148 | } |
| 149 | 149 | |
| 150 | 150 | # Display success message |
@@ -45,7 +45,9 @@ discard block |
||
| 45 | 45 | |
| 46 | 46 | # Implement forms |
| 47 | 47 | |
| 48 | - foreach ($this->forms as $form) $form->implement($contents); |
|
| 48 | + foreach ($this->forms as $form) { |
|
| 49 | + $form->implement($contents); |
|
| 50 | + } |
|
| 49 | 51 | |
| 50 | 52 | # Process info block |
| 51 | 53 | |
@@ -104,7 +106,9 @@ discard block |
||
| 104 | 106 | |
| 105 | 107 | # Handle ajax request |
| 106 | 108 | |
| 107 | - if ($ajax) return $this->handleAjax(); |
|
| 109 | + if ($ajax) { |
|
| 110 | + return $this->handleAjax(); |
|
| 111 | + } |
|
| 108 | 112 | |
| 109 | 113 | # Create parent |
| 110 | 114 | |
@@ -140,18 +144,22 @@ discard block |
||
| 140 | 144 | |
| 141 | 145 | # Handle form |
| 142 | 146 | |
| 143 | - foreach ($this->forms as $name => $form) if ($form->handle($this->controllers[$name], true)) { |
|
| 147 | + foreach ($this->forms as $name => $form) { |
|
| 148 | + if ($form->handle($this->controllers[$name], true)) { |
|
| 144 | 149 | |
| 145 | 150 | Request::redirect(INSTALL_PATH . '/admin/content/filemanager/' . static::$origin . '/' . static::$type . |
| 146 | 151 | |
| 147 | 152 | '?parent=' . $this->parent->getPath() . '&name=' . $this->entity->getName() . '&submitted=' . $name); |
| 148 | 153 | } |
| 154 | + } |
|
| 149 | 155 | |
| 150 | 156 | # Display success message |
| 151 | 157 | |
| 152 | - if (Request::get('submitted') === 'rename') Popup::set('positive', Language::get(static::$message_success_rename)); |
|
| 153 | - |
|
| 154 | - else if (Request::get('submitted') === 'edit') Popup::set('positive', Language::get(static::$message_success_edit)); |
|
| 158 | + if (Request::get('submitted') === 'rename') { |
|
| 159 | + Popup::set('positive', Language::get(static::$message_success_rename)); |
|
| 160 | + } else if (Request::get('submitted') === 'edit') { |
|
| 161 | + Popup::set('positive', Language::get(static::$message_success_edit)); |
|
| 162 | + } |
|
| 155 | 163 | |
| 156 | 164 | # ------------------------ |
| 157 | 165 | |
@@ -25,7 +25,7 @@ |
||
| 25 | 25 | |
| 26 | 26 | $scheme = array_diff(preg_split('/[\/\\\\]+/', $path, -1, PREG_SPLIT_NO_EMPTY), ['.', '..']); |
| 27 | 27 | |
| 28 | - $path_full = ($this->path_full . (('' !== ($path = implode('/', $scheme))) ? ($path . '/') : '')); |
|
| 28 | + $path_full = ($this->path_full.(('' !== ($path = implode('/', $scheme))) ? ($path.'/') : '')); |
|
| 29 | 29 | |
| 30 | 30 | if (!Explorer::isDir($path_full)) return; |
| 31 | 31 | |
@@ -27,7 +27,9 @@ |
||
| 27 | 27 | |
| 28 | 28 | $path_full = ($this->path_full . (('' !== ($path = implode('/', $scheme))) ? ($path . '/') : '')); |
| 29 | 29 | |
| 30 | - if (!Explorer::isDir($path_full)) return; |
|
| 30 | + if (!Explorer::isDir($path_full)) { |
|
| 31 | + return; |
|
| 32 | + } |
|
| 31 | 33 | |
| 32 | 34 | $this->scheme = $scheme; $this->path = $path; $this->path_full = $path_full; |
| 33 | 35 | } |
@@ -34,19 +34,33 @@ |
||
| 34 | 34 | |
| 35 | 35 | public static function getFormat(string $extension) { |
| 36 | 36 | |
| 37 | - if (self::isImage($extension)) return 'image'; |
|
| 37 | + if (self::isImage($extension)) { |
|
| 38 | + return 'image'; |
|
| 39 | + } |
|
| 38 | 40 | |
| 39 | - if (self::isAudio($extension)) return 'audio'; |
|
| 41 | + if (self::isAudio($extension)) { |
|
| 42 | + return 'audio'; |
|
| 43 | + } |
|
| 40 | 44 | |
| 41 | - if (self::isVideo($extension)) return 'video'; |
|
| 45 | + if (self::isVideo($extension)) { |
|
| 46 | + return 'video'; |
|
| 47 | + } |
|
| 42 | 48 | |
| 43 | - if (in_array($extension, ['doc', 'docx'], true)) return 'word'; |
|
| 49 | + if (in_array($extension, ['doc', 'docx'], true)) { |
|
| 50 | + return 'word'; |
|
| 51 | + } |
|
| 44 | 52 | |
| 45 | - if (in_array($extension, ['xls', 'xlsx'], true)) return 'excel'; |
|
| 53 | + if (in_array($extension, ['xls', 'xlsx'], true)) { |
|
| 54 | + return 'excel'; |
|
| 55 | + } |
|
| 46 | 56 | |
| 47 | - if (in_array($extension, ['ppt', 'pptx'], true)) return 'powerpoint'; |
|
| 57 | + if (in_array($extension, ['ppt', 'pptx'], true)) { |
|
| 58 | + return 'powerpoint'; |
|
| 59 | + } |
|
| 48 | 60 | |
| 49 | - if ($extension === 'pdf') return 'pdf'; |
|
| 61 | + if ($extension === 'pdf') { |
|
| 62 | + return 'pdf'; |
|
| 63 | + } |
|
| 50 | 64 | |
| 51 | 65 | # ------------------------ |
| 52 | 66 | |
@@ -23,7 +23,7 @@ discard block |
||
| 23 | 23 | |
| 24 | 24 | if (($name === '.') || ($name === '..')) continue; |
| 25 | 25 | |
| 26 | - if ((null === $type) || (@filetype($dir_name . $name) === $type)) yield $name; |
|
| 26 | + if ((null === $type) || (@filetype($dir_name.$name) === $type)) yield $name; |
|
| 27 | 27 | } |
| 28 | 28 | |
| 29 | 29 | closedir($handler); |
@@ -115,7 +115,7 @@ discard block |
||
| 115 | 115 | |
| 116 | 116 | foreach (array_diff($list, ['.', '..']) as $name) { |
| 117 | 117 | |
| 118 | - $name = ($dir_name . '/' . $name); |
|
| 118 | + $name = ($dir_name.'/'.$name); |
|
| 119 | 119 | |
| 120 | 120 | if (@is_dir($name)) self::removeDir($name, true); |
| 121 | 121 | |
@@ -21,9 +21,13 @@ discard block |
||
| 21 | 21 | |
| 22 | 22 | while (false !== ($name = readdir($handler))) { |
| 23 | 23 | |
| 24 | - if (($name === '.') || ($name === '..')) continue; |
|
| 24 | + if (($name === '.') || ($name === '..')) { |
|
| 25 | + continue; |
|
| 26 | + } |
|
| 25 | 27 | |
| 26 | - if ((null === $type) || (@filetype($dir_name . $name) === $type)) yield $name; |
|
| 28 | + if ((null === $type) || (@filetype($dir_name . $name) === $type)) { |
|
| 29 | + yield $name; |
|
| 30 | + } |
|
| 27 | 31 | } |
| 28 | 32 | |
| 29 | 33 | closedir($handler); |
@@ -38,7 +42,9 @@ discard block |
||
| 38 | 42 | |
| 39 | 43 | private static function getInfo(string $file_name, int $param, bool $check_exists = true) { |
| 40 | 44 | |
| 41 | - if ($check_exists && !self::isFile($file_name)) return false; |
|
| 45 | + if ($check_exists && !self::isFile($file_name)) { |
|
| 46 | + return false; |
|
| 47 | + } |
|
| 42 | 48 | |
| 43 | 49 | return pathinfo($file_name, $param); |
| 44 | 50 | } |
@@ -117,9 +123,11 @@ discard block |
||
| 117 | 123 | |
| 118 | 124 | $name = ($dir_name . '/' . $name); |
| 119 | 125 | |
| 120 | - if (@is_dir($name)) self::removeDir($name, true); |
|
| 121 | - |
|
| 122 | - else if (@is_file($name)) self::removeFile($name); |
|
| 126 | + if (@is_dir($name)) { |
|
| 127 | + self::removeDir($name, true); |
|
| 128 | + } else if (@is_file($name)) { |
|
| 129 | + self::removeFile($name); |
|
| 130 | + } |
|
| 123 | 131 | } |
| 124 | 132 | } |
| 125 | 133 | |
@@ -145,7 +153,9 @@ discard block |
||
| 145 | 153 | |
| 146 | 154 | public static function iterate(string $dir_name) : Generator { |
| 147 | 155 | |
| 148 | - foreach (self::getList($dir_name) as $name) yield $name; |
|
| 156 | + foreach (self::getList($dir_name) as $name) { |
|
| 157 | + yield $name; |
|
| 158 | + } |
|
| 149 | 159 | } |
| 150 | 160 | |
| 151 | 161 | /** |
@@ -154,7 +164,9 @@ discard block |
||
| 154 | 164 | |
| 155 | 165 | public static function iterateDirs(string $dir_name) : Generator { |
| 156 | 166 | |
| 157 | - foreach (self::getList($dir_name, 'dir') as $name) yield $name; |
|
| 167 | + foreach (self::getList($dir_name, 'dir') as $name) { |
|
| 168 | + yield $name; |
|
| 169 | + } |
|
| 158 | 170 | } |
| 159 | 171 | |
| 160 | 172 | /** |
@@ -163,7 +175,9 @@ discard block |
||
| 163 | 175 | |
| 164 | 176 | public static function iterateFiles(string $dir_name) : Generator { |
| 165 | 177 | |
| 166 | - foreach (self::getList($dir_name, 'file') as $name) yield $name; |
|
| 178 | + foreach (self::getList($dir_name, 'file') as $name) { |
|
| 179 | + yield $name; |
|
| 180 | + } |
|
| 167 | 181 | } |
| 168 | 182 | |
| 169 | 183 | /** |
@@ -334,7 +348,9 @@ discard block |
||
| 334 | 348 | |
| 335 | 349 | public static function include(string $file_name) { |
| 336 | 350 | |
| 337 | - if ((strtolower(self::getExtension($file_name)) !== 'php')) return false; |
|
| 351 | + if ((strtolower(self::getExtension($file_name)) !== 'php')) { |
|
| 352 | + return false; |
|
| 353 | + } |
|
| 338 | 354 | |
| 339 | 355 | return @include $file_name; |
| 340 | 356 | } |
@@ -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 | |