@@ -2,7 +2,8 @@ |
||
| 2 | 2 | |
| 3 | 3 | namespace Modules\Entitizer\Utils { |
| 4 | 4 | |
| 5 | - use Modules\Entitizer, DB; |
|
| 5 | + use Modules\Entitizer; |
|
| 6 | + use DB; |
|
| 6 | 7 | |
| 7 | 8 | abstract class Entity extends Entitizer { |
| 8 | 9 | |
@@ -12,13 +12,13 @@ discard block |
||
| 12 | 12 | |
| 13 | 13 | return ("SELECT SQL_CALC_FOUND_ROWS " . $this->getSelection() . " ") . |
| 14 | 14 | |
| 15 | - ("FROM " . static::$table . " ent ") . |
|
| 15 | + ("FROM " . static::$table . " ent ") . |
|
| 16 | 16 | |
| 17 | 17 | (('' !== ($condition = $this->getCondition($config))) ? ("WHERE " . $condition . " ") : "") . |
| 18 | 18 | |
| 19 | 19 | ("ORDER BY " . $this->getOrderBy($order_by) . " ") . |
| 20 | 20 | |
| 21 | - (($index > 0) ? ("LIMIT " . ((($index - 1) * $display) . ", " . $display)) : ""); |
|
| 21 | + (($index > 0) ? ("LIMIT " . ((($index - 1) * $display) . ", " . $display)) : ""); |
|
| 22 | 22 | } |
| 23 | 23 | |
| 24 | 24 | # Get nesting select query |
@@ -27,9 +27,9 @@ discard block |
||
| 27 | 27 | |
| 28 | 28 | return ("SELECT SQL_CALC_FOUND_ROWS " . $this->getSelection() . ", COUNT(chd.descendant) as children ") . |
| 29 | 29 | |
| 30 | - ("FROM " . static::$table . " ent ") . |
|
| 30 | + ("FROM " . static::$table . " ent ") . |
|
| 31 | 31 | |
| 32 | - ("LEFT JOIN " . static::$table_relations . " chd ON chd.ancestor = ent.id AND chd.depth = 1 ") . |
|
| 32 | + ("LEFT JOIN " . static::$table_relations . " chd ON chd.ancestor = ent.id AND chd.depth = 1 ") . |
|
| 33 | 33 | |
| 34 | 34 | ("LEFT JOIN " . static::$table_relations . " rel ON rel.descendant = ent.id AND rel.depth = 1 ") . |
| 35 | 35 | |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | |
| 40 | 40 | ("GROUP BY ent.id ORDER BY " . $this->getOrderBy($order_by) . " ") . |
| 41 | 41 | |
| 42 | - (($index > 0) ? ("LIMIT " . ((($index - 1) * $display) . ", " . $display)) : ""); |
|
| 42 | + (($index > 0) ? ("LIMIT " . ((($index - 1) * $display) . ", " . $display)) : ""); |
|
| 43 | 43 | } |
| 44 | 44 | |
| 45 | 45 | # Get default count query |
@@ -48,7 +48,7 @@ discard block |
||
| 48 | 48 | |
| 49 | 49 | return ("SELECT COUNT(ent.id) as count FROM " . static::$table . " ent ") . |
| 50 | 50 | |
| 51 | - (('' !== ($condition = $this->getCondition($config))) ? ("WHERE " . $condition) : ""); |
|
| 51 | + (('' !== ($condition = $this->getCondition($config))) ? ("WHERE " . $condition) : ""); |
|
| 52 | 52 | } |
| 53 | 53 | |
| 54 | 54 | # Get nesting count query |
@@ -57,11 +57,11 @@ discard block |
||
| 57 | 57 | |
| 58 | 58 | return ("SELECT COUNT(ent.id) as count FROM " . static::$table . " ent ") . |
| 59 | 59 | |
| 60 | - ("LEFT JOIN " . static::$table_relations . " rel ON rel.descendant = ent.id AND rel.depth = 1 ") . |
|
| 60 | + ("LEFT JOIN " . static::$table_relations . " rel ON rel.descendant = ent.id AND rel.depth = 1 ") . |
|
| 61 | 61 | |
| 62 | - ("WHERE COALESCE(rel.ancestor, 0) = " . $parent_id . " ") . |
|
| 62 | + ("WHERE COALESCE(rel.ancestor, 0) = " . $parent_id . " ") . |
|
| 63 | 63 | |
| 64 | - (('' !== ($condition = $this->getCondition($config))) ? ("AND " . $condition) : ""); |
|
| 64 | + (('' !== ($condition = $this->getCondition($config))) ? ("AND " . $condition) : ""); |
|
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | # Select entries from DB |
@@ -10,58 +10,58 @@ discard block |
||
| 10 | 10 | |
| 11 | 11 | private function getDefaultSelectQuery(array $config, array $order_by, int $index, int $display) { |
| 12 | 12 | |
| 13 | - return ("SELECT SQL_CALC_FOUND_ROWS " . $this->getSelection() . " ") . |
|
| 13 | + return ("SELECT SQL_CALC_FOUND_ROWS ".$this->getSelection()." "). |
|
| 14 | 14 | |
| 15 | - ("FROM " . static::$table . " ent ") . |
|
| 15 | + ("FROM ".static::$table." ent "). |
|
| 16 | 16 | |
| 17 | - (('' !== ($condition = $this->getCondition($config))) ? ("WHERE " . $condition . " ") : "") . |
|
| 17 | + (('' !== ($condition = $this->getCondition($config))) ? ("WHERE ".$condition." ") : ""). |
|
| 18 | 18 | |
| 19 | - ("ORDER BY " . $this->getOrderBy($order_by) . " ") . |
|
| 19 | + ("ORDER BY ".$this->getOrderBy($order_by)." "). |
|
| 20 | 20 | |
| 21 | - (($index > 0) ? ("LIMIT " . ((($index - 1) * $display) . ", " . $display)) : ""); |
|
| 21 | + (($index > 0) ? ("LIMIT ".((($index - 1) * $display).", ".$display)) : ""); |
|
| 22 | 22 | } |
| 23 | 23 | |
| 24 | 24 | # Get nesting select query |
| 25 | 25 | |
| 26 | 26 | private function getNestingSelectQuery(int $parent_id, array $config, array $order_by, int $index, int $display) { |
| 27 | 27 | |
| 28 | - return ("SELECT SQL_CALC_FOUND_ROWS " . $this->getSelection() . ", COUNT(chd.descendant) as children ") . |
|
| 28 | + return ("SELECT SQL_CALC_FOUND_ROWS ".$this->getSelection().", COUNT(chd.descendant) as children "). |
|
| 29 | 29 | |
| 30 | - ("FROM " . static::$table . " ent ") . |
|
| 30 | + ("FROM ".static::$table." ent "). |
|
| 31 | 31 | |
| 32 | - ("LEFT JOIN " . static::$table_relations . " chd ON chd.ancestor = ent.id AND chd.depth = 1 ") . |
|
| 32 | + ("LEFT JOIN ".static::$table_relations." chd ON chd.ancestor = ent.id AND chd.depth = 1 "). |
|
| 33 | 33 | |
| 34 | - ("LEFT JOIN " . static::$table_relations . " rel ON rel.descendant = ent.id AND rel.depth = 1 ") . |
|
| 34 | + ("LEFT JOIN ".static::$table_relations." rel ON rel.descendant = ent.id AND rel.depth = 1 "). |
|
| 35 | 35 | |
| 36 | - ("WHERE COALESCE(rel.ancestor, 0) = " . $parent_id . " ") . |
|
| 36 | + ("WHERE COALESCE(rel.ancestor, 0) = ".$parent_id." "). |
|
| 37 | 37 | |
| 38 | - (('' !== ($condition = $this->getCondition($config))) ? ("AND " . $condition . " ") : "") . |
|
| 38 | + (('' !== ($condition = $this->getCondition($config))) ? ("AND ".$condition." ") : ""). |
|
| 39 | 39 | |
| 40 | - ("GROUP BY ent.id ORDER BY " . $this->getOrderBy($order_by) . " ") . |
|
| 40 | + ("GROUP BY ent.id ORDER BY ".$this->getOrderBy($order_by)." "). |
|
| 41 | 41 | |
| 42 | - (($index > 0) ? ("LIMIT " . ((($index - 1) * $display) . ", " . $display)) : ""); |
|
| 42 | + (($index > 0) ? ("LIMIT ".((($index - 1) * $display).", ".$display)) : ""); |
|
| 43 | 43 | } |
| 44 | 44 | |
| 45 | 45 | # Get default count query |
| 46 | 46 | |
| 47 | 47 | private function getDefaultCountQuery(array $config) { |
| 48 | 48 | |
| 49 | - return ("SELECT COUNT(ent.id) as count FROM " . static::$table . " ent ") . |
|
| 49 | + return ("SELECT COUNT(ent.id) as count FROM ".static::$table." ent "). |
|
| 50 | 50 | |
| 51 | - (('' !== ($condition = $this->getCondition($config))) ? ("WHERE " . $condition) : ""); |
|
| 51 | + (('' !== ($condition = $this->getCondition($config))) ? ("WHERE ".$condition) : ""); |
|
| 52 | 52 | } |
| 53 | 53 | |
| 54 | 54 | # Get nesting count query |
| 55 | 55 | |
| 56 | 56 | private function getNestingCountQuery(int $parent_id, array $config) { |
| 57 | 57 | |
| 58 | - return ("SELECT COUNT(ent.id) as count FROM " . static::$table . " ent ") . |
|
| 58 | + return ("SELECT COUNT(ent.id) as count FROM ".static::$table." ent "). |
|
| 59 | 59 | |
| 60 | - ("LEFT JOIN " . static::$table_relations . " rel ON rel.descendant = ent.id AND rel.depth = 1 ") . |
|
| 60 | + ("LEFT JOIN ".static::$table_relations." rel ON rel.descendant = ent.id AND rel.depth = 1 "). |
|
| 61 | 61 | |
| 62 | - ("WHERE COALESCE(rel.ancestor, 0) = " . $parent_id . " ") . |
|
| 62 | + ("WHERE COALESCE(rel.ancestor, 0) = ".$parent_id." "). |
|
| 63 | 63 | |
| 64 | - (('' !== ($condition = $this->getCondition($config))) ? ("AND " . $condition) : ""); |
|
| 64 | + (('' !== ($condition = $this->getCondition($config))) ? ("AND ".$condition) : ""); |
|
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | # Select entries from DB |
@@ -74,9 +74,7 @@ discard block |
||
| 74 | 74 | |
| 75 | 75 | # Select entities |
| 76 | 76 | |
| 77 | - $query = ((null === $parent_id) ? $this->getDefaultSelectQuery($config, $order_by, $index, $display) : |
|
| 78 | - |
|
| 79 | - $this->getNestingSelectQuery($parent_id, $config, $order_by, $index, $display)); |
|
| 77 | + $query = ((null === $parent_id) ? $this->getDefaultSelectQuery($config, $order_by, $index, $display) : $this->getNestingSelectQuery($parent_id, $config, $order_by, $index, $display)); |
|
| 80 | 78 | |
| 81 | 79 | if (!(DB::send($query) && DB::last()->status)) return false; |
| 82 | 80 | |
@@ -113,9 +111,7 @@ discard block |
||
| 113 | 111 | |
| 114 | 112 | # Count entities |
| 115 | 113 | |
| 116 | - $query = ((null === $parent_id) ? $this->getDefaultCountQuery($config) : |
|
| 117 | - |
|
| 118 | - $this->getNestingCountQuery($parent_id, $config)); |
|
| 114 | + $query = ((null === $parent_id) ? $this->getDefaultCountQuery($config) : $this->getNestingCountQuery($parent_id, $config)); |
|
| 119 | 115 | |
| 120 | 116 | if (!(DB::send($query) && DB::last()->status)) return false; |
| 121 | 117 | |
@@ -68,9 +68,13 @@ discard block |
||
| 68 | 68 | |
| 69 | 69 | private function select(int $parent_id = null, array $config = [], array $order_by = [], int $index = 0, int $display = 0) { |
| 70 | 70 | |
| 71 | - if (!((null === $parent_id) || ($parent_id >= 0))) return false; |
|
| 71 | + if (!((null === $parent_id) || ($parent_id >= 0))) { |
|
| 72 | + return false; |
|
| 73 | + } |
|
| 72 | 74 | |
| 73 | - if (!(($index >= 0) && ($display >= 0))) return false; |
|
| 75 | + if (!(($index >= 0) && ($display >= 0))) { |
|
| 76 | + return false; |
|
| 77 | + } |
|
| 74 | 78 | |
| 75 | 79 | # Select entities |
| 76 | 80 | |
@@ -78,7 +82,9 @@ discard block |
||
| 78 | 82 | |
| 79 | 83 | $this->getNestingSelectQuery($parent_id, $config, $order_by, $index, $display)); |
| 80 | 84 | |
| 81 | - if (!(DB::send($query) && DB::last()->status)) return false; |
|
| 85 | + if (!(DB::send($query) && DB::last()->status)) { |
|
| 86 | + return false; |
|
| 87 | + } |
|
| 82 | 88 | |
| 83 | 89 | # Process results |
| 84 | 90 | |
@@ -90,7 +96,9 @@ discard block |
||
| 90 | 96 | |
| 91 | 97 | $items['list'][$entity->id] = ['entity' => $entity]; |
| 92 | 98 | |
| 93 | - if (null !== $parent_id) $items['list'][$entity->id]['children'] = intval($data['children']); |
|
| 99 | + if (null !== $parent_id) { |
|
| 100 | + $items['list'][$entity->id]['children'] = intval($data['children']); |
|
| 101 | + } |
|
| 94 | 102 | } |
| 95 | 103 | |
| 96 | 104 | # Count total |
@@ -109,7 +117,9 @@ discard block |
||
| 109 | 117 | |
| 110 | 118 | private function count(int $parent_id = null, array $config = []) { |
| 111 | 119 | |
| 112 | - if (!((null === $parent_id) || ($parent_id >= 0))) return false; |
|
| 120 | + if (!((null === $parent_id) || ($parent_id >= 0))) { |
|
| 121 | + return false; |
|
| 122 | + } |
|
| 113 | 123 | |
| 114 | 124 | # Count entities |
| 115 | 125 | |
@@ -117,7 +127,9 @@ discard block |
||
| 117 | 127 | |
| 118 | 128 | $this->getNestingCountQuery($parent_id, $config)); |
| 119 | 129 | |
| 120 | - if (!(DB::send($query) && DB::last()->status)) return false; |
|
| 130 | + if (!(DB::send($query) && DB::last()->status)) { |
|
| 131 | + return false; |
|
| 132 | + } |
|
| 121 | 133 | |
| 122 | 134 | # ------------------------ |
| 123 | 135 | |
@@ -142,7 +154,9 @@ discard block |
||
| 142 | 154 | |
| 143 | 155 | public function children(int $parent_id = 0, array $config = [], array $order_by = [], int $index = 0, int $display = 0) { |
| 144 | 156 | |
| 145 | - if (!static::$nesting) return false; |
|
| 157 | + if (!static::$nesting) { |
|
| 158 | + return false; |
|
| 159 | + } |
|
| 146 | 160 | |
| 147 | 161 | return $this->select(...func_get_args()); |
| 148 | 162 | } |
@@ -151,7 +165,9 @@ discard block |
||
| 151 | 165 | |
| 152 | 166 | public function childrenCount(int $parent_id = 0, array $config = []) { |
| 153 | 167 | |
| 154 | - if (!static::$nesting) return false; |
|
| 168 | + if (!static::$nesting) { |
|
| 169 | + return false; |
|
| 170 | + } |
|
| 155 | 171 | |
| 156 | 172 | return $this->count(...func_get_args()); |
| 157 | 173 | } |
@@ -2,7 +2,8 @@ |
||
| 2 | 2 | |
| 3 | 3 | namespace Modules\Entitizer\Utils { |
| 4 | 4 | |
| 5 | - use Modules\Entitizer, Config; |
|
| 5 | + use Modules\Entitizer; |
|
| 6 | + use Config; |
|
| 6 | 7 | |
| 7 | 8 | abstract class View { |
| 8 | 9 | |
@@ -32,7 +32,7 @@ discard block |
||
| 32 | 32 | |
| 33 | 33 | $selection = []; |
| 34 | 34 | |
| 35 | - foreach ($this->definition->paramsSecure() as $field) $selection[] = ('ent.' . $field); |
|
| 35 | + foreach ($this->definition->paramsSecure() as $field) $selection[] = ('ent.'.$field); |
|
| 36 | 36 | |
| 37 | 37 | # ------------------------ |
| 38 | 38 | |
@@ -45,7 +45,7 @@ discard block |
||
| 45 | 45 | |
| 46 | 46 | $order_by = []; |
| 47 | 47 | |
| 48 | - foreach ($this->castOrderBy($data) as $field => $direction) $order_by[] = ('ent.' . $field . ' ' . $direction); |
|
| 48 | + foreach ($this->castOrderBy($data) as $field => $direction) $order_by[] = ('ent.'.$field.' '.$direction); |
|
| 49 | 49 | |
| 50 | 50 | # ------------------------ |
| 51 | 51 | |
@@ -16,7 +16,9 @@ discard block |
||
| 16 | 16 | |
| 17 | 17 | foreach ($data as $field => $direction) { |
| 18 | 18 | |
| 19 | - if (false === ($param = $this->definition->param($field))) continue; |
|
| 19 | + if (false === ($param = $this->definition->param($field))) { |
|
| 20 | + continue; |
|
| 21 | + } |
|
| 20 | 22 | |
| 21 | 23 | $order_by[$param->name] = ((strtoupper($direction) !== 'DESC') ? 'ASC' : 'DESC'); |
| 22 | 24 | } |
@@ -32,7 +34,9 @@ discard block |
||
| 32 | 34 | |
| 33 | 35 | $selection = []; |
| 34 | 36 | |
| 35 | - foreach ($this->definition->paramsSecure() as $field) $selection[] = ('ent.' . $field); |
|
| 37 | + foreach ($this->definition->paramsSecure() as $field) { |
|
| 38 | + $selection[] = ('ent.' . $field); |
|
| 39 | + } |
|
| 36 | 40 | |
| 37 | 41 | # ------------------------ |
| 38 | 42 | |
@@ -45,7 +49,9 @@ discard block |
||
| 45 | 49 | |
| 46 | 50 | $order_by = []; |
| 47 | 51 | |
| 48 | - foreach ($this->castOrderBy($data) as $field => $direction) $order_by[] = ('ent.' . $field . ' ' . $direction); |
|
| 52 | + foreach ($this->castOrderBy($data) as $field => $direction) { |
|
| 53 | + $order_by[] = ('ent.' . $field . ' ' . $direction); |
|
| 54 | + } |
|
| 49 | 55 | |
| 50 | 56 | # ------------------------ |
| 51 | 57 | |
@@ -2,8 +2,15 @@ |
||
| 2 | 2 | |
| 3 | 3 | namespace Modules\Filemanager\Handler { |
| 4 | 4 | |
| 5 | - use Modules\Filemanager, Utils\Messages, Utils\Pagination, Utils\Uploader, Utils\View; |
|
| 6 | - use Ajax, Arr, Explorer, Language, Number, Request, Template, Url; |
|
| 5 | + use Modules\Filemanager; |
|
| 6 | + use Utils\Pagination; |
|
| 7 | + use Utils\Uploader; |
|
| 8 | + use Utils\View; |
|
| 9 | + use Arr; |
|
| 10 | + use Number; |
|
| 11 | + use Request; |
|
| 12 | + use Template; |
|
| 13 | + use Url; |
|
| 7 | 14 | |
| 8 | 15 | class Listview { |
| 9 | 16 | |
@@ -15,7 +15,7 @@ discard block |
||
| 15 | 15 | |
| 16 | 16 | $dirs = []; $files = []; |
| 17 | 17 | |
| 18 | - $prefix = (('' !== $this->parent->path()) ? ($this->parent->path() . '/') : ''); |
|
| 18 | + $prefix = (('' !== $this->parent->path()) ? ($this->parent->path().'/') : ''); |
|
| 19 | 19 | |
| 20 | 20 | # Read parent directory contents |
| 21 | 21 | |
@@ -25,7 +25,7 @@ discard block |
||
| 25 | 25 | |
| 26 | 26 | if (in_array($name, ['.', '..', '.empty'], true)) continue; |
| 27 | 27 | |
| 28 | - $path = ($prefix . $name); $path_full = ($this->parent->pathFull() . $name); |
|
| 28 | + $path = ($prefix.$name); $path_full = ($this->parent->pathFull().$name); |
|
| 29 | 29 | |
| 30 | 30 | $data = ['name' => $name, 'path' => $path, 'path_full' => $path_full]; |
| 31 | 31 | |
@@ -112,9 +112,9 @@ discard block |
||
| 112 | 112 | |
| 113 | 113 | private function getPaginationBlock() { |
| 114 | 114 | |
| 115 | - $query = (('' !== $this->parent->path()) ? ('?parent=' . $this->parent->path()) : ''); |
|
| 115 | + $query = (('' !== $this->parent->path()) ? ('?parent='.$this->parent->path()) : ''); |
|
| 116 | 116 | |
| 117 | - $url = new Url(INSTALL_PATH . '/admin/content/filemanager' . $query); |
|
| 117 | + $url = new Url(INSTALL_PATH.'/admin/content/filemanager'.$query); |
|
| 118 | 118 | |
| 119 | 119 | # ------------------------ |
| 120 | 120 | |
@@ -137,9 +137,9 @@ discard block |
||
| 137 | 137 | |
| 138 | 138 | # Set link |
| 139 | 139 | |
| 140 | - $query = (('' !== $this->parent->path()) ? ('?parent=' . $this->parent->path()) : ''); |
|
| 140 | + $query = (('' !== $this->parent->path()) ? ('?parent='.$this->parent->path()) : ''); |
|
| 141 | 141 | |
| 142 | - $contents->link = (INSTALL_PATH . '/admin/content/filemanager' . $query); |
|
| 142 | + $contents->link = (INSTALL_PATH.'/admin/content/filemanager'.$query); |
|
| 143 | 143 | |
| 144 | 144 | # Implement form |
| 145 | 145 | |
@@ -180,9 +180,9 @@ discard block |
||
| 180 | 180 | |
| 181 | 181 | if ($upload || $this->form->handle(new Filemanager\Controller\Create($this->parent))) { |
| 182 | 182 | |
| 183 | - $query = (('' !== $this->parent->path()) ? ('?parent=' . $this->parent->path()) : ''); |
|
| 183 | + $query = (('' !== $this->parent->path()) ? ('?parent='.$this->parent->path()) : ''); |
|
| 184 | 184 | |
| 185 | - Request::redirect(INSTALL_PATH . '/admin/content/filemanager' . $query); |
|
| 185 | + Request::redirect(INSTALL_PATH.'/admin/content/filemanager'.$query); |
|
| 186 | 186 | } |
| 187 | 187 | |
| 188 | 188 | # Get index |
@@ -23,15 +23,19 @@ discard block |
||
| 23 | 23 | |
| 24 | 24 | while (false !== ($name = readdir($handler))) { |
| 25 | 25 | |
| 26 | - if (in_array($name, ['.', '..', '.empty'], true)) continue; |
|
| 26 | + if (in_array($name, ['.', '..', '.empty'], true)) { |
|
| 27 | + continue; |
|
| 28 | + } |
|
| 27 | 29 | |
| 28 | 30 | $path = ($prefix . $name); $path_full = ($this->parent->pathFull() . $name); |
| 29 | 31 | |
| 30 | 32 | $data = ['name' => $name, 'path' => $path, 'path_full' => $path_full]; |
| 31 | 33 | |
| 32 | - if (@is_dir($path_full)) $dirs[] = array_merge($data, ['type' => FILEMANAGER_TYPE_DIR]); |
|
| 33 | - |
|
| 34 | - else if (@is_file($path_full)) $files[] = array_merge($data, ['type' => FILEMANAGER_TYPE_FILE]); |
|
| 34 | + if (@is_dir($path_full)) { |
|
| 35 | + $dirs[] = array_merge($data, ['type' => FILEMANAGER_TYPE_DIR]); |
|
| 36 | + } else if (@is_file($path_full)) { |
|
| 37 | + $files[] = array_merge($data, ['type' => FILEMANAGER_TYPE_FILE]); |
|
| 38 | + } |
|
| 35 | 39 | } |
| 36 | 40 | |
| 37 | 41 | closedir($handler); |
@@ -98,9 +102,11 @@ discard block |
||
| 98 | 102 | |
| 99 | 103 | foreach ($this->items['list'] as $item) { |
| 100 | 104 | |
| 101 | - if ($item['type'] === FILEMANAGER_TYPE_DIR) $items->add($this->getDirItemBlock($item)); |
|
| 102 | - |
|
| 103 | - else if ($item['type'] === FILEMANAGER_TYPE_FILE) $items->add($this->getFileItemBlock($item)); |
|
| 105 | + if ($item['type'] === FILEMANAGER_TYPE_DIR) { |
|
| 106 | + $items->add($this->getDirItemBlock($item)); |
|
| 107 | + } else if ($item['type'] === FILEMANAGER_TYPE_FILE) { |
|
| 108 | + $items->add($this->getFileItemBlock($item)); |
|
| 109 | + } |
|
| 104 | 110 | } |
| 105 | 111 | |
| 106 | 112 | # ------------------------ |
@@ -149,7 +155,9 @@ discard block |
||
| 149 | 155 | |
| 150 | 156 | $items = $this->getItemsBlock(); |
| 151 | 157 | |
| 152 | - if ($items->count() > 0) $contents->items = $items; |
|
| 158 | + if ($items->count() > 0) { |
|
| 159 | + $contents->items = $items; |
|
| 160 | + } |
|
| 153 | 161 | |
| 154 | 162 | # Set pagination |
| 155 | 163 | |
@@ -10,7 +10,9 @@ |
||
| 10 | 10 | |
| 11 | 11 | protected static function init(string $file_name) { |
| 12 | 12 | |
| 13 | - if (is_array($range = Explorer::php($file_name))) static::$range = $range; |
|
| 13 | + if (is_array($range = Explorer::php($file_name))) { |
|
| 14 | + static::$range = $range; |
|
| 15 | + } |
|
| 14 | 16 | } |
| 15 | 17 | |
| 16 | 18 | # Check if item exists |
@@ -10,7 +10,12 @@ discard block |
||
| 10 | 10 | |
| 11 | 11 | $value = false; |
| 12 | 12 | |
| 13 | - foreach ($path as $item) if (isset($array[$item])) $value = ($array = $array[$item]); else return false; |
|
| 13 | + foreach ($path as $item) { |
|
| 14 | + if (isset($array[$item])) $value = ($array = $array[$item]); |
|
| 15 | + } |
|
| 16 | + else { |
|
| 17 | + return false; |
|
| 18 | + } |
|
| 14 | 19 | |
| 15 | 20 | # ------------------------ |
| 16 | 21 | |
@@ -23,10 +28,12 @@ discard block |
||
| 23 | 28 | |
| 24 | 29 | $result = []; |
| 25 | 30 | |
| 26 | - foreach ($keys as $key) if (is_scalar($key)) { |
|
| 31 | + foreach ($keys as $key) { |
|
| 32 | + if (is_scalar($key)) { |
|
| 27 | 33 | |
| 28 | 34 | $result[$key] = ((isset($array[$key]) && is_scalar($array[$key])) ? $array[$key] : false); |
| 29 | 35 | } |
| 36 | + } |
|
| 30 | 37 | |
| 31 | 38 | # ------------------------ |
| 32 | 39 | |
@@ -39,7 +46,9 @@ discard block |
||
| 39 | 46 | |
| 40 | 47 | $result = []; |
| 41 | 48 | |
| 42 | - foreach ($array as $key => $value) $result[] = [$key_name => $key, $value_name => $value]; |
|
| 49 | + foreach ($array as $key => $value) { |
|
| 50 | + $result[] = [$key_name => $key, $value_name => $value]; |
|
| 51 | + } |
|
| 43 | 52 | |
| 44 | 53 | # ------------------------ |
| 45 | 54 | |
@@ -57,9 +66,15 @@ discard block |
||
| 57 | 66 | |
| 58 | 67 | $result = []; $column = array_map($select_key, $array); |
| 59 | 68 | |
| 60 | - if (!$descending) asort($column); else arsort($column); |
|
| 69 | + if (!$descending) { |
|
| 70 | + asort($column); |
|
| 71 | + } else { |
|
| 72 | + arsort($column); |
|
| 73 | + } |
|
| 61 | 74 | |
| 62 | - foreach (array_keys($column) as $key) $result[$key] = $array[$key]; |
|
| 75 | + foreach (array_keys($column) as $key) { |
|
| 76 | + $result[$key] = $array[$key]; |
|
| 77 | + } |
|
| 63 | 78 | |
| 64 | 79 | # ------------------------ |
| 65 | 80 | |
@@ -10,7 +10,9 @@ discard block |
||
| 10 | 10 | |
| 11 | 11 | public function add(string $name, $default, callable $handler) { |
| 12 | 12 | |
| 13 | - if ('' === $name) return; |
|
| 13 | + if ('' === $name) { |
|
| 14 | + return; |
|
| 15 | + } |
|
| 14 | 16 | |
| 15 | 17 | $this->config[$name] = $handler; $this->values[$name] = null; |
| 16 | 18 | |
@@ -23,11 +25,11 @@ discard block |
||
| 23 | 25 | |
| 24 | 26 | foreach ($data as $name => $value) { |
| 25 | 27 | |
| 26 | - if (!isset($this->config[$name])) continue; |
|
| 27 | - |
|
| 28 | - try { $this->values[$name] = $this->config[$name]($value); } |
|
| 28 | + if (!isset($this->config[$name])) { |
|
| 29 | + continue; |
|
| 30 | + } |
|
| 29 | 31 | |
| 30 | - catch (\TypeError $e) {} |
|
| 32 | + try { $this->values[$name] = $this->config[$name]($value); } catch (\TypeError $e) {} |
|
| 31 | 33 | } |
| 32 | 34 | } |
| 33 | 35 | |
@@ -39,11 +41,11 @@ discard block |
||
| 39 | 41 | |
| 40 | 42 | foreach ($this->config as $name => $handler) { |
| 41 | 43 | |
| 42 | - if (!($isset = isset($data[$name])) && !$process_all) continue; |
|
| 44 | + if (!($isset = isset($data[$name])) && !$process_all) { |
|
| 45 | + continue; |
|
| 46 | + } |
|
| 43 | 47 | |
| 44 | - try { $cast[$name] = ($isset ? $handler($data[$name]) : $this->values[$name]); } |
|
| 45 | - |
|
| 46 | - catch (\TypeError $e) { $cast[$name] = $this->values[$name]; } |
|
| 48 | + try { $cast[$name] = ($isset ? $handler($data[$name]) : $this->values[$name]); } catch (\TypeError $e) { $cast[$name] = $this->values[$name]; } |
|
| 47 | 49 | } |
| 48 | 50 | |
| 49 | 51 | # ------------------------ |
@@ -55,7 +57,9 @@ discard block |
||
| 55 | 57 | |
| 56 | 58 | public function get(string $name = null) { |
| 57 | 59 | |
| 58 | - if (null === $name) return $this->values; |
|
| 60 | + if (null === $name) { |
|
| 61 | + return $this->values; |
|
| 62 | + } |
|
| 59 | 63 | |
| 60 | 64 | return ($this->values[$name] ?? null); |
| 61 | 65 | } |
@@ -10,7 +10,9 @@ |
||
| 10 | 10 | |
| 11 | 11 | public function set(string $name, $value) { |
| 12 | 12 | |
| 13 | - if (is_scalar($value)) $this->data[$name] = $value; |
|
| 13 | + if (is_scalar($value)) { |
|
| 14 | + $this->data[$name] = $value; |
|
| 15 | + } |
|
| 14 | 16 | |
| 15 | 17 | return $this; |
| 16 | 18 | } |
@@ -2,15 +2,15 @@ |
||
| 2 | 2 | |
| 3 | 3 | # Database tables |
| 4 | 4 | |
| 5 | -define('TABLE_PAGES', 'pages'); |
|
| 6 | -define('TABLE_PAGES_RELATIONS', 'pages_relations'); |
|
| 5 | +define('TABLE_PAGES', 'pages'); |
|
| 6 | +define('TABLE_PAGES_RELATIONS', 'pages_relations'); |
|
| 7 | 7 | |
| 8 | -define('TABLE_MENU', 'menu'); |
|
| 9 | -define('TABLE_MENU_RELATIONS', 'menu_relations'); |
|
| 8 | +define('TABLE_MENU', 'menu'); |
|
| 9 | +define('TABLE_MENU_RELATIONS', 'menu_relations'); |
|
| 10 | 10 | |
| 11 | -define('TABLE_VARIABLES', 'variables'); |
|
| 12 | -define('TABLE_WIDGETS', 'widgets'); |
|
| 11 | +define('TABLE_VARIABLES', 'variables'); |
|
| 12 | +define('TABLE_WIDGETS', 'widgets'); |
|
| 13 | 13 | |
| 14 | -define('TABLE_USERS', 'users'); |
|
| 15 | -define('TABLE_USERS_SECRETS', 'users_secrets'); |
|
| 16 | -define('TABLE_USERS_SESSIONS', 'users_sessions'); |
|
| 14 | +define('TABLE_USERS', 'users'); |
|
| 15 | +define('TABLE_USERS_SECRETS', 'users_secrets'); |
|
| 16 | +define('TABLE_USERS_SESSIONS', 'users_sessions'); |
|
@@ -2,68 +2,68 @@ |
||
| 2 | 2 | |
| 3 | 3 | # Cadmium |
| 4 | 4 | |
| 5 | -define('CADMIUM_NAME', 'Cadmium CMS'); |
|
| 6 | -define('CADMIUM_HOME', 'http://cadmium-cms.com'); |
|
| 5 | +define('CADMIUM_NAME', 'Cadmium CMS'); |
|
| 6 | +define('CADMIUM_HOME', 'http://cadmium-cms.com'); |
|
| 7 | 7 | |
| 8 | -define('CADMIUM_VERSION', '0.3.0'); |
|
| 9 | -define('CADMIUM_COPY', '2016'); |
|
| 8 | +define('CADMIUM_VERSION', '0.3.0'); |
|
| 9 | +define('CADMIUM_COPY', '2016'); |
|
| 10 | 10 | |
| 11 | 11 | # External |
| 12 | 12 | |
| 13 | -define('JQUERY_VERSION', '2.2.0'); |
|
| 14 | -define('SEMANTIC_UI_VERSION', '2.1.8'); |
|
| 15 | -define('CKEDITOR_VERSION', '4.5.6'); |
|
| 13 | +define('JQUERY_VERSION', '2.2.0'); |
|
| 14 | +define('SEMANTIC_UI_VERSION', '2.1.8'); |
|
| 15 | +define('CKEDITOR_VERSION', '4.5.6'); |
|
| 16 | 16 | |
| 17 | 17 | # Sections |
| 18 | 18 | |
| 19 | -define('SECTION_ADMIN', 'Admin'); |
|
| 20 | -define('SECTION_SITE', 'Site'); |
|
| 19 | +define('SECTION_ADMIN', 'Admin'); |
|
| 20 | +define('SECTION_SITE', 'Site'); |
|
| 21 | 21 | |
| 22 | 22 | # Filemanager types |
| 23 | 23 | |
| 24 | -define('FILEMANAGER_TYPE_DIR', 'dir'); |
|
| 25 | -define('FILEMANAGER_TYPE_FILE', 'file'); |
|
| 24 | +define('FILEMANAGER_TYPE_DIR', 'dir'); |
|
| 25 | +define('FILEMANAGER_TYPE_FILE', 'file'); |
|
| 26 | 26 | |
| 27 | 27 | # Access |
| 28 | 28 | |
| 29 | -define('ACCESS_PUBLIC', 0); |
|
| 30 | -define('ACCESS_REGISTERED', 1); |
|
| 31 | -define('ACCESS_ADMINISTRATOR', 2); |
|
| 29 | +define('ACCESS_PUBLIC', 0); |
|
| 30 | +define('ACCESS_REGISTERED', 1); |
|
| 31 | +define('ACCESS_ADMINISTRATOR', 2); |
|
| 32 | 32 | |
| 33 | 33 | # Frequency |
| 34 | 34 | |
| 35 | -define('FREQUENCY_ALWAYS', 'always'); |
|
| 36 | -define('FREQUENCY_HOURLY', 'hourly'); |
|
| 37 | -define('FREQUENCY_DAILY', 'daily'); |
|
| 38 | -define('FREQUENCY_WEEKLY', 'weekly'); |
|
| 39 | -define('FREQUENCY_MONTHLY', 'monthly'); |
|
| 40 | -define('FREQUENCY_YEARLY', 'yearly'); |
|
| 41 | -define('FREQUENCY_NEVER', 'never'); |
|
| 35 | +define('FREQUENCY_ALWAYS', 'always'); |
|
| 36 | +define('FREQUENCY_HOURLY', 'hourly'); |
|
| 37 | +define('FREQUENCY_DAILY', 'daily'); |
|
| 38 | +define('FREQUENCY_WEEKLY', 'weekly'); |
|
| 39 | +define('FREQUENCY_MONTHLY', 'monthly'); |
|
| 40 | +define('FREQUENCY_YEARLY', 'yearly'); |
|
| 41 | +define('FREQUENCY_NEVER', 'never'); |
|
| 42 | 42 | |
| 43 | 43 | # Rank |
| 44 | 44 | |
| 45 | -define('RANK_GUEST', 0); |
|
| 46 | -define('RANK_USER', 1); |
|
| 47 | -define('RANK_ADMINISTRATOR', 2); |
|
| 45 | +define('RANK_GUEST', 0); |
|
| 46 | +define('RANK_USER', 1); |
|
| 47 | +define('RANK_ADMINISTRATOR', 2); |
|
| 48 | 48 | |
| 49 | 49 | # Sex |
| 50 | 50 | |
| 51 | -define('SEX_NOT_SELECTED', 0); |
|
| 52 | -define('SEX_MALE', 1); |
|
| 53 | -define('SEX_FEMALE', 2); |
|
| 51 | +define('SEX_NOT_SELECTED', 0); |
|
| 52 | +define('SEX_MALE', 1); |
|
| 53 | +define('SEX_FEMALE', 2); |
|
| 54 | 54 | |
| 55 | 55 | # Status |
| 56 | 56 | |
| 57 | -define('STATUS_ONLINE', 0); |
|
| 58 | -define('STATUS_MAINTENANCE', 1); |
|
| 59 | -define('STATUS_UPDATE', 2); |
|
| 57 | +define('STATUS_ONLINE', 0); |
|
| 58 | +define('STATUS_MAINTENANCE', 1); |
|
| 59 | +define('STATUS_UPDATE', 2); |
|
| 60 | 60 | |
| 61 | 61 | # Target |
| 62 | 62 | |
| 63 | -define('TARGET_SELF', 0); |
|
| 64 | -define('TARGET_BLANK', 1); |
|
| 63 | +define('TARGET_SELF', 0); |
|
| 64 | +define('TARGET_BLANK', 1); |
|
| 65 | 65 | |
| 66 | 66 | # Visibility |
| 67 | 67 | |
| 68 | -define('VISIBILITY_DRAFT', 0); |
|
| 69 | -define('VISIBILITY_PUBLISHED', 1); |
|
| 68 | +define('VISIBILITY_DRAFT', 0); |
|
| 69 | +define('VISIBILITY_PUBLISHED', 1); |
|