@@ -36,17 +36,17 @@ |
||
| 36 | 36 | |
| 37 | 37 | $query = ("SELECT SQL_CALC_FOUND_ROWS ent.id, " . implode(', ', $selection)) . |
| 38 | 38 | |
| 39 | - (static::$nesting ? ", COUNT(chd.id) as children " : " ") . |
|
| 39 | + (static::$nesting ? ", COUNT(chd.id) as children " : " ") . |
|
| 40 | 40 | |
| 41 | - ("FROM " . static::$table . " ent ") . |
|
| 41 | + ("FROM " . static::$table . " ent ") . |
|
| 42 | 42 | |
| 43 | - (static::$nesting ? ("LEFT JOIN " . static::$table . " chd ON chd.parent_id = ent.id ") : "") . |
|
| 43 | + (static::$nesting ? ("LEFT JOIN " . static::$table . " chd ON chd.parent_id = ent.id ") : "") . |
|
| 44 | 44 | |
| 45 | - ("WHERE ent.id != " . $disable_id . " ") . |
|
| 45 | + ("WHERE ent.id != " . $disable_id . " ") . |
|
| 46 | 46 | |
| 47 | - (static::$nesting ? ("AND ent.parent_id = " . $parent_id . " GROUP BY ent.id ") : "") . |
|
| 47 | + (static::$nesting ? ("AND ent.parent_id = " . $parent_id . " GROUP BY ent.id ") : "") . |
|
| 48 | 48 | |
| 49 | - ("ORDER BY " . implode(', ', $order_by) . ", ent.id ASC" . ($limit ? (" LIMIT " . $limit) : "")); |
|
| 49 | + ("ORDER BY " . implode(', ', $order_by) . ", ent.id ASC" . ($limit ? (" LIMIT " . $limit) : "")); |
|
| 50 | 50 | |
| 51 | 51 | # ------------------------ |
| 52 | 52 | |
@@ -66,13 +66,17 @@ |
||
| 66 | 66 | |
| 67 | 67 | $items = ['list' => [], 'total' => 0]; |
| 68 | 68 | |
| 69 | - if (!(($index >= 0) && ($display >= 0) && ($parent_id >= 0) && ($disable_id >= 0))) return $items; |
|
| 69 | + if (!(($index >= 0) && ($display >= 0) && ($parent_id >= 0) && ($disable_id >= 0))) { |
|
| 70 | + return $items; |
|
| 71 | + } |
|
| 70 | 72 | |
| 71 | 73 | # Select entities |
| 72 | 74 | |
| 73 | 75 | $query = $this->getQuery($index, $display, $parent_id, $disable_id); |
| 74 | 76 | |
| 75 | - if (!(DB::send($query) && DB::last()->status)) return $items; |
|
| 77 | + if (!(DB::send($query) && DB::last()->status)) { |
|
| 78 | + return $items; |
|
| 79 | + } |
|
| 76 | 80 | |
| 77 | 81 | # Process results |
| 78 | 82 | |
@@ -18,35 +18,35 @@ |
||
| 18 | 18 | |
| 19 | 19 | foreach (array_keys($this->definition->params()) as $field) { |
| 20 | 20 | |
| 21 | - $selection[] = ('ent.' . $field); |
|
| 21 | + $selection[] = ('ent.'.$field); |
|
| 22 | 22 | } |
| 23 | 23 | |
| 24 | 24 | # Process order |
| 25 | 25 | |
| 26 | 26 | foreach ($this->definition->orderers() as $field => $descending) { |
| 27 | 27 | |
| 28 | - $order_by[] = ('ent.' . $field . ' ' . ($descending ? 'DESC' : 'ASC')); |
|
| 28 | + $order_by[] = ('ent.'.$field.' '.($descending ? 'DESC' : 'ASC')); |
|
| 29 | 29 | } |
| 30 | 30 | |
| 31 | 31 | # Process limit |
| 32 | 32 | |
| 33 | - $limit = (($index > 0) ? ((($index - 1) * $display) . ", " . $display) : ""); |
|
| 33 | + $limit = (($index > 0) ? ((($index - 1) * $display).", ".$display) : ""); |
|
| 34 | 34 | |
| 35 | 35 | # Process query |
| 36 | 36 | |
| 37 | - $query = ("SELECT SQL_CALC_FOUND_ROWS ent.id, " . implode(', ', $selection)) . |
|
| 37 | + $query = ("SELECT SQL_CALC_FOUND_ROWS ent.id, ".implode(', ', $selection)). |
|
| 38 | 38 | |
| 39 | - (static::$nesting ? ", COUNT(chd.id) as children " : " ") . |
|
| 39 | + (static::$nesting ? ", COUNT(chd.id) as children " : " "). |
|
| 40 | 40 | |
| 41 | - ("FROM " . static::$table . " ent ") . |
|
| 41 | + ("FROM ".static::$table." ent "). |
|
| 42 | 42 | |
| 43 | - (static::$nesting ? ("LEFT JOIN " . static::$table . " chd ON chd.parent_id = ent.id ") : "") . |
|
| 43 | + (static::$nesting ? ("LEFT JOIN ".static::$table." chd ON chd.parent_id = ent.id ") : ""). |
|
| 44 | 44 | |
| 45 | - ("WHERE ent.id != " . $disable_id . " ") . |
|
| 45 | + ("WHERE ent.id != ".$disable_id." "). |
|
| 46 | 46 | |
| 47 | - (static::$nesting ? ("AND ent.parent_id = " . $parent_id . " GROUP BY ent.id ") : "") . |
|
| 47 | + (static::$nesting ? ("AND ent.parent_id = ".$parent_id." GROUP BY ent.id ") : ""). |
|
| 48 | 48 | |
| 49 | - ("ORDER BY " . implode(', ', $order_by) . ", ent.id ASC" . ($limit ? (" LIMIT " . $limit) : "")); |
|
| 49 | + ("ORDER BY ".implode(', ', $order_by).", ent.id ASC".($limit ? (" LIMIT ".$limit) : "")); |
|
| 50 | 50 | |
| 51 | 51 | # ------------------------ |
| 52 | 52 | |
@@ -24,7 +24,9 @@ discard block |
||
| 24 | 24 | |
| 25 | 25 | # Set edit button |
| 26 | 26 | |
| 27 | - if (0 === $this->parent->id) $parent->block('edit')->disable(); else { |
|
| 27 | + if (0 === $this->parent->id) { |
|
| 28 | + $parent->block('edit')->disable(); |
|
| 29 | + } else { |
|
| 28 | 30 | |
| 29 | 31 | $parent->block('edit')->class = (!$this->create ? 'active item' : 'item'); |
| 30 | 32 | |
@@ -36,7 +38,9 @@ discard block |
||
| 36 | 38 | |
| 37 | 39 | private function processSelector(Template\Asset\Block $selector) { |
| 38 | 40 | |
| 39 | - if ($this->create) return $selector->disable(); |
|
| 41 | + if ($this->create) { |
|
| 42 | + return $selector->disable(); |
|
| 43 | + } |
|
| 40 | 44 | |
| 41 | 45 | $parent = Entitizer::get(static::$type, $this->entity->parent_id); |
| 42 | 46 | |
@@ -55,25 +59,33 @@ discard block |
||
| 55 | 59 | |
| 56 | 60 | # Set path / title |
| 57 | 61 | |
| 58 | - if (static::$nesting) $contents->path = $this->parent->path; |
|
| 59 | - |
|
| 60 | - else $contents->title = ($this->create ? Language::get(static::$naming_new) : $this->entity->__get(static::$naming)); |
|
| 62 | + if (static::$nesting) { |
|
| 63 | + $contents->path = $this->parent->path; |
|
| 64 | + } else { |
|
| 65 | + $contents->title = ($this->create ? Language::get(static::$naming_new) : $this->entity->__get(static::$naming)); |
|
| 66 | + } |
|
| 61 | 67 | |
| 62 | 68 | # Set link |
| 63 | 69 | |
| 64 | 70 | $link = (INSTALL_PATH . static::$link . '/'); |
| 65 | 71 | |
| 66 | - if (static::$nesting) $contents->link = ($link . ($this->create ? 'create' : 'edit') . '?id=' . $this->parent->id); |
|
| 67 | - |
|
| 68 | - else $contents->link = ($link . ($this->create ? 'create' : ('edit?id=' . $this->entity->id))); |
|
| 72 | + if (static::$nesting) { |
|
| 73 | + $contents->link = ($link . ($this->create ? 'create' : 'edit') . '?id=' . $this->parent->id); |
|
| 74 | + } else { |
|
| 75 | + $contents->link = ($link . ($this->create ? 'create' : ('edit?id=' . $this->entity->id))); |
|
| 76 | + } |
|
| 69 | 77 | |
| 70 | 78 | # Process parent block |
| 71 | 79 | |
| 72 | - if (static::$nesting) $this->processParent($contents->block('parent')); |
|
| 80 | + if (static::$nesting) { |
|
| 81 | + $this->processParent($contents->block('parent')); |
|
| 82 | + } |
|
| 73 | 83 | |
| 74 | 84 | # Process selector block |
| 75 | 85 | |
| 76 | - if (static::$nesting) $this->processSelector($contents->block('selector')); |
|
| 86 | + if (static::$nesting) { |
|
| 87 | + $this->processSelector($contents->block('selector')); |
|
| 88 | + } |
|
| 77 | 89 | |
| 78 | 90 | # Implement form |
| 79 | 91 | |
@@ -102,7 +114,9 @@ discard block |
||
| 102 | 114 | |
| 103 | 115 | if (Request::post('action') === 'remove') { |
| 104 | 116 | |
| 105 | - if (!$this->entity->remove()) return $ajax->error(Language::get(static::$message_error_remove)); |
|
| 117 | + if (!$this->entity->remove()) { |
|
| 118 | + return $ajax->error(Language::get(static::$message_error_remove)); |
|
| 119 | + } |
|
| 106 | 120 | } |
| 107 | 121 | |
| 108 | 122 | # ------------------------ |
@@ -114,23 +128,31 @@ discard block |
||
| 114 | 128 | |
| 115 | 129 | public function handle(bool $create = false) { |
| 116 | 130 | |
| 117 | - if (!($this->create = $create) && Request::isAjax()) return $this->handleAjax(); |
|
| 131 | + if (!($this->create = $create) && Request::isAjax()) { |
|
| 132 | + return $this->handleAjax(); |
|
| 133 | + } |
|
| 118 | 134 | |
| 119 | 135 | # Create entity |
| 120 | 136 | |
| 121 | - if (static::$nesting) $this->parent = Entitizer::get(static::$type, Number::format(Request::get('id'))); |
|
| 137 | + if (static::$nesting) { |
|
| 138 | + $this->parent = Entitizer::get(static::$type, Number::format(Request::get('id'))); |
|
| 139 | + } |
|
| 122 | 140 | |
| 123 | 141 | $this->entity = Entitizer::get(static::$type, (!$this->create ? Number::format(Request::get('id')) : 0)); |
| 124 | 142 | |
| 125 | 143 | # Redirect if entity not found |
| 126 | 144 | |
| 127 | - if (!$this->create && (0 === $this->entity->id)) return Request::redirect(INSTALL_PATH . static::$link); |
|
| 145 | + if (!$this->create && (0 === $this->entity->id)) { |
|
| 146 | + return Request::redirect(INSTALL_PATH . static::$link); |
|
| 147 | + } |
|
| 128 | 148 | |
| 129 | 149 | # Create form |
| 130 | 150 | |
| 131 | 151 | $this->form = new static::$form_class($this->entity); |
| 132 | 152 | |
| 133 | - if (static::$nesting && $this->create) $this->form->get('parent_id')->set($this->parent->id); |
|
| 153 | + if (static::$nesting && $this->create) { |
|
| 154 | + $this->form->get('parent_id')->set($this->parent->id); |
|
| 155 | + } |
|
| 134 | 156 | |
| 135 | 157 | # Handle form |
| 136 | 158 | |
@@ -2,7 +2,14 @@ |
||
| 2 | 2 | |
| 3 | 3 | namespace Modules\Entitizer\Utils { |
| 4 | 4 | |
| 5 | - use Modules\Entitizer, Utils\Messages, Utils\View, Ajax, Language, Number, Request, Template; |
|
| 5 | + use Modules\Entitizer; |
|
| 6 | + use Utils\Messages; |
|
| 7 | + use Utils\View; |
|
| 8 | + use Ajax; |
|
| 9 | + use Language; |
|
| 10 | + use Number; |
|
| 11 | + use Request; |
|
| 12 | + use Template; |
|
| 6 | 13 | |
| 7 | 14 | abstract class Handler { |
| 8 | 15 | |
@@ -61,11 +61,11 @@ discard block |
||
| 61 | 61 | |
| 62 | 62 | # Set link |
| 63 | 63 | |
| 64 | - $link = (INSTALL_PATH . static::$link . '/'); |
|
| 64 | + $link = (INSTALL_PATH.static::$link.'/'); |
|
| 65 | 65 | |
| 66 | - if (static::$nesting) $contents->link = ($link . ($this->create ? 'create' : 'edit') . '?id=' . $this->parent->id); |
|
| 66 | + if (static::$nesting) $contents->link = ($link.($this->create ? 'create' : 'edit').'?id='.$this->parent->id); |
|
| 67 | 67 | |
| 68 | - else $contents->link = ($link . ($this->create ? 'create' : ('edit?id=' . $this->entity->id))); |
|
| 68 | + else $contents->link = ($link.($this->create ? 'create' : ('edit?id='.$this->entity->id))); |
|
| 69 | 69 | |
| 70 | 70 | # Process parent block |
| 71 | 71 | |
@@ -124,7 +124,7 @@ discard block |
||
| 124 | 124 | |
| 125 | 125 | # Redirect if entity not found |
| 126 | 126 | |
| 127 | - if (!$this->create && (0 === $this->entity->id)) return Request::redirect(INSTALL_PATH . static::$link); |
|
| 127 | + if (!$this->create && (0 === $this->entity->id)) return Request::redirect(INSTALL_PATH.static::$link); |
|
| 128 | 128 | |
| 129 | 129 | # Create form |
| 130 | 130 | |
@@ -136,7 +136,7 @@ discard block |
||
| 136 | 136 | |
| 137 | 137 | if ($this->form->handle(new static::$controller($this->entity))) { |
| 138 | 138 | |
| 139 | - Request::redirect(INSTALL_PATH . static::$link . '/edit?id=' . $this->entity->id . '&submitted'); |
|
| 139 | + Request::redirect(INSTALL_PATH.static::$link.'/edit?id='.$this->entity->id.'&submitted'); |
|
| 140 | 140 | } |
| 141 | 141 | |
| 142 | 142 | # Display success message |
@@ -12,25 +12,35 @@ |
||
| 12 | 12 | |
| 13 | 13 | public function create(array $data) { |
| 14 | 14 | |
| 15 | - if (0 !== $this->id) return false; |
|
| 15 | + if (0 !== $this->id) { |
|
| 16 | + return false; |
|
| 17 | + } |
|
| 16 | 18 | |
| 17 | 19 | $set = $this->getDataset($data, true); |
| 18 | 20 | |
| 19 | - if (isset($set['id']) && !($set['id'] > 0)) return false; |
|
| 21 | + if (isset($set['id']) && !($set['id'] > 0)) { |
|
| 22 | + return false; |
|
| 23 | + } |
|
| 20 | 24 | |
| 21 | 25 | # Insert entity |
| 22 | 26 | |
| 23 | 27 | DB::insert(static::$table, $set); |
| 24 | 28 | |
| 25 | - if (!(DB::last() && DB::last()->status)) return false; |
|
| 29 | + if (!(DB::last() && DB::last()->status)) { |
|
| 30 | + return false; |
|
| 31 | + } |
|
| 26 | 32 | |
| 27 | 33 | # Re-init entity |
| 28 | 34 | |
| 29 | 35 | $this->error = false; $this->id = DB::last()->id; |
| 30 | 36 | |
| 31 | - foreach ($set as $name => $value) if ($name !== 'id') $this->data[$name] = $value; |
|
| 37 | + foreach ($set as $name => $value) { |
|
| 38 | + if ($name !== 'id') $this->data[$name] = $value; |
|
| 39 | + } |
|
| 32 | 40 | |
| 33 | - if (static::$nesting) $this->data['path'] = $this->getPath(); |
|
| 41 | + if (static::$nesting) { |
|
| 42 | + $this->data['path'] = $this->getPath(); |
|
| 43 | + } |
|
| 34 | 44 | |
| 35 | 45 | # Implement entity |
| 36 | 46 | |
@@ -12,7 +12,9 @@ discard block |
||
| 12 | 12 | |
| 13 | 13 | public function edit(array $data) { |
| 14 | 14 | |
| 15 | - if (0 === $this->id) return false; |
|
| 15 | + if (0 === $this->id) { |
|
| 16 | + return false; |
|
| 17 | + } |
|
| 16 | 18 | |
| 17 | 19 | $set = $this->getDataset($data); |
| 18 | 20 | |
@@ -20,13 +22,19 @@ discard block |
||
| 20 | 22 | |
| 21 | 23 | DB::update(static::$table, $set, ['id' => $this->id]); |
| 22 | 24 | |
| 23 | - if (!(DB::last() && DB::last()->status)) return false; |
|
| 25 | + if (!(DB::last() && DB::last()->status)) { |
|
| 26 | + return false; |
|
| 27 | + } |
|
| 24 | 28 | |
| 25 | 29 | # Re-init entity |
| 26 | 30 | |
| 27 | - foreach ($set as $name => $value) $this->data[$name] = $value; |
|
| 31 | + foreach ($set as $name => $value) { |
|
| 32 | + $this->data[$name] = $value; |
|
| 33 | + } |
|
| 28 | 34 | |
| 29 | - if (static::$nesting) $this->data['path'] = $this->getPath(); |
|
| 35 | + if (static::$nesting) { |
|
| 36 | + $this->data['path'] = $this->getPath(); |
|
| 37 | + } |
|
| 30 | 38 | |
| 31 | 39 | # Implement entity |
| 32 | 40 | |
@@ -22,9 +22,11 @@ discard block |
||
| 22 | 22 | |
| 23 | 23 | # Set edit button |
| 24 | 24 | |
| 25 | - if (0 === $this->parent->id) $parent->block('edit')->disable(); |
|
| 26 | - |
|
| 27 | - else $parent->block('edit')->id = $this->parent->id; |
|
| 25 | + if (0 === $this->parent->id) { |
|
| 26 | + $parent->block('edit')->disable(); |
|
| 27 | + } else { |
|
| 28 | + $parent->block('edit')->id = $this->parent->id; |
|
| 29 | + } |
|
| 28 | 30 | } |
| 29 | 31 | |
| 30 | 32 | # Get items block |
@@ -82,21 +84,29 @@ discard block |
||
| 82 | 84 | |
| 83 | 85 | # Set path |
| 84 | 86 | |
| 85 | - if (static::$nesting) $contents->path = $this->parent->path; |
|
| 87 | + if (static::$nesting) { |
|
| 88 | + $contents->path = $this->parent->path; |
|
| 89 | + } |
|
| 86 | 90 | |
| 87 | 91 | # Process parent block |
| 88 | 92 | |
| 89 | - if (static::$nesting && !$ajax) $this->processParent($contents->block('parent')); |
|
| 93 | + if (static::$nesting && !$ajax) { |
|
| 94 | + $this->processParent($contents->block('parent')); |
|
| 95 | + } |
|
| 90 | 96 | |
| 91 | 97 | # Set items |
| 92 | 98 | |
| 93 | 99 | $items = $this->getItemsBlock($ajax); |
| 94 | 100 | |
| 95 | - if ($items->count() > 0) $contents->items = $items; |
|
| 101 | + if ($items->count() > 0) { |
|
| 102 | + $contents->items = $items; |
|
| 103 | + } |
|
| 96 | 104 | |
| 97 | 105 | # Set pagination |
| 98 | 106 | |
| 99 | - if (!$ajax) $contents->pagination = $this->getPaginationBlock(); |
|
| 107 | + if (!$ajax) { |
|
| 108 | + $contents->pagination = $this->getPaginationBlock(); |
|
| 109 | + } |
|
| 100 | 110 | |
| 101 | 111 | # Add additional data for specific entity |
| 102 | 112 | |
@@ -115,7 +125,9 @@ discard block |
||
| 115 | 125 | |
| 116 | 126 | # Create parent entity |
| 117 | 127 | |
| 118 | - if (static::$nesting) $this->parent = Entitizer::get(static::$type, Number::format(Request::get('parent_id'))); |
|
| 128 | + if (static::$nesting) { |
|
| 129 | + $this->parent = Entitizer::get(static::$type, Number::format(Request::get('parent_id'))); |
|
| 130 | + } |
|
| 119 | 131 | |
| 120 | 132 | # Get children items |
| 121 | 133 | |
@@ -132,13 +144,17 @@ discard block |
||
| 132 | 144 | |
| 133 | 145 | public function handle() { |
| 134 | 146 | |
| 135 | - if (Request::isAjax()) return $this->handleAjax(); |
|
| 147 | + if (Request::isAjax()) { |
|
| 148 | + return $this->handleAjax(); |
|
| 149 | + } |
|
| 136 | 150 | |
| 137 | 151 | $this->index = Number::format(Request::get('index'), 1, 999999); |
| 138 | 152 | |
| 139 | 153 | # Create parent entity |
| 140 | 154 | |
| 141 | - if (static::$nesting) $this->parent = Entitizer::get(static::$type, Number::format(Request::get('parent_id'))); |
|
| 155 | + if (static::$nesting) { |
|
| 156 | + $this->parent = Entitizer::get(static::$type, Number::format(Request::get('parent_id'))); |
|
| 157 | + } |
|
| 142 | 158 | |
| 143 | 159 | # Get children items |
| 144 | 160 | |
@@ -2,7 +2,14 @@ |
||
| 2 | 2 | |
| 3 | 3 | namespace Modules\Entitizer\Utils { |
| 4 | 4 | |
| 5 | - use Modules\Entitizer, Utils\Pagination, Utils\View, Ajax, Number, Request, Template, Url; |
|
| 5 | + use Modules\Entitizer; |
|
| 6 | + use Utils\Pagination; |
|
| 7 | + use Utils\View; |
|
| 8 | + use Ajax; |
|
| 9 | + use Number; |
|
| 10 | + use Request; |
|
| 11 | + use Template; |
|
| 12 | + use Url; |
|
| 6 | 13 | |
| 7 | 14 | abstract class Listview { |
| 8 | 15 | |
@@ -65,9 +65,9 @@ |
||
| 65 | 65 | |
| 66 | 66 | private function getPaginationBlock() { |
| 67 | 67 | |
| 68 | - $query = (static::$nesting ? ('?parent_id=' . $this->parent->id) : ''); |
|
| 68 | + $query = (static::$nesting ? ('?parent_id='.$this->parent->id) : ''); |
|
| 69 | 69 | |
| 70 | - $url = new Url(INSTALL_PATH . static::$link . $query); |
|
| 70 | + $url = new Url(INSTALL_PATH.static::$link.$query); |
|
| 71 | 71 | |
| 72 | 72 | # ------------------------ |
| 73 | 73 | |
@@ -23,11 +23,15 @@ discard block |
||
| 23 | 23 | |
| 24 | 24 | $name = Settings::get(self::$param[$this->section]); $primary = self::$default[$this->section]; |
| 25 | 25 | |
| 26 | - if (self::valid($name) && isset($items[$name])) $active = $name; |
|
| 27 | - |
|
| 28 | - else if (self::valid($primary) && isset($items[$primary])) $active = $primary; |
|
| 26 | + if (self::valid($name) && isset($items[$name])) { |
|
| 27 | + $active = $name; |
|
| 28 | + } else if (self::valid($primary) && isset($items[$primary])) { |
|
| 29 | + $active = $primary; |
|
| 30 | + } |
|
| 29 | 31 | |
| 30 | - foreach (array_keys($items) as $name) $items[$name]['active'] = ($name === $active); |
|
| 32 | + foreach (array_keys($items) as $name) { |
|
| 33 | + $items[$name]['active'] = ($name === $active); |
|
| 34 | + } |
|
| 31 | 35 | |
| 32 | 36 | # ------------------------ |
| 33 | 37 | |
@@ -73,12 +77,16 @@ discard block |
||
| 73 | 77 | |
| 74 | 78 | $items->add($item = View::get(self::$view_item)); |
| 75 | 79 | |
| 76 | - foreach (self::$data as $name) $item->$name = $extension[$name]; |
|
| 80 | + foreach (self::$data as $name) { |
|
| 81 | + $item->$name = $extension[$name]; |
|
| 82 | + } |
|
| 77 | 83 | |
| 78 | 84 | $item->class = ($extension['active'] ? 'positive' : 'grey'); |
| 79 | 85 | } |
| 80 | 86 | |
| 81 | - if ($items->count()) $contents->block('items', $items); |
|
| 87 | + if ($items->count()) { |
|
| 88 | + $contents->block('items', $items); |
|
| 89 | + } |
|
| 82 | 90 | |
| 83 | 91 | # ------------------------ |
| 84 | 92 | |
@@ -93,15 +101,21 @@ discard block |
||
| 93 | 101 | |
| 94 | 102 | # Check for demo mode |
| 95 | 103 | |
| 96 | - if (Informer::isDemoMode()) return $ajax->error(Language::get('DEMO_MODE_RESTRICTION')); |
|
| 104 | + if (Informer::isDemoMode()) { |
|
| 105 | + return $ajax->error(Language::get('DEMO_MODE_RESTRICTION')); |
|
| 106 | + } |
|
| 97 | 107 | |
| 98 | 108 | # Save configuration |
| 99 | 109 | |
| 100 | 110 | $param = self::$param[$this->section]; $name = Request::post('name'); |
| 101 | 111 | |
| 102 | - if (false === Settings::set($param, $name)) return $ajax->error(Language::get(self::$error_name)); |
|
| 112 | + if (false === Settings::set($param, $name)) { |
|
| 113 | + return $ajax->error(Language::get(self::$error_name)); |
|
| 114 | + } |
|
| 103 | 115 | |
| 104 | - if (false === Settings::save()) return $ajax->error(Language::get(self::$error_save)); |
|
| 116 | + if (false === Settings::save()) { |
|
| 117 | + return $ajax->error(Language::get(self::$error_save)); |
|
| 118 | + } |
|
| 105 | 119 | |
| 106 | 120 | # ------------------------ |
| 107 | 121 | |
@@ -116,7 +130,9 @@ discard block |
||
| 116 | 130 | |
| 117 | 131 | $this->items = $this->getHandlerItems(); |
| 118 | 132 | |
| 119 | - if (Request::isAjax()) return $this->handleAjax(); |
|
| 133 | + if (Request::isAjax()) { |
|
| 134 | + return $this->handleAjax(); |
|
| 135 | + } |
|
| 120 | 136 | |
| 121 | 137 | # ------------------------ |
| 122 | 138 | |
@@ -32,10 +32,12 @@ discard block |
||
| 32 | 32 | |
| 33 | 33 | $languages = [Extend\Languages::pathPrimary(), Extend\Languages::path()]; |
| 34 | 34 | |
| 35 | - foreach (array_unique($languages) as $path) foreach (static::PHRASES as $name) { |
|
| 35 | + foreach (array_unique($languages) as $path) { |
|
| 36 | + foreach (static::PHRASES as $name) { |
|
| 36 | 37 | |
| 37 | 38 | Language::load($path . 'Phrases/' . $name . '.php'); |
| 38 | 39 | } |
| 40 | + } |
|
| 39 | 41 | |
| 40 | 42 | # Set template globals |
| 41 | 43 | |
@@ -57,7 +59,9 @@ discard block |
||
| 57 | 59 | |
| 58 | 60 | # Set timezone |
| 59 | 61 | |
| 60 | - if (Auth::check() && ('' !== ($timezone = Auth::user()->timezone))) date_default_timezone_set($timezone); |
|
| 62 | + if (Auth::check() && ('' !== ($timezone = Auth::user()->timezone))) { |
|
| 63 | + date_default_timezone_set($timezone); |
|
| 64 | + } |
|
| 61 | 65 | |
| 62 | 66 | # ------------------------ |
| 63 | 67 | |
@@ -34,7 +34,7 @@ |
||
| 34 | 34 | |
| 35 | 35 | foreach (array_unique($languages) as $path) foreach (static::PHRASES as $name) { |
| 36 | 36 | |
| 37 | - Language::load($path . 'Phrases/' . $name . '.php'); |
|
| 37 | + Language::load($path.'Phrases/'.$name.'.php'); |
|
| 38 | 38 | } |
| 39 | 39 | |
| 40 | 40 | # Set template globals |
@@ -147,20 +147,29 @@ discard block |
||
| 147 | 147 | |
| 148 | 148 | if ($this instanceof Component\Install) { |
| 149 | 149 | |
| 150 | - if (Template::isBlock($result = $this->handle())) return $this->displayForm($result, STATUS_CODE_200); |
|
| 150 | + if (Template::isBlock($result = $this->handle())) { |
|
| 151 | + return $this->displayForm($result, STATUS_CODE_200); |
|
| 152 | + } |
|
| 151 | 153 | } |
| 152 | 154 | |
| 153 | 155 | # Handle auth component request |
| 154 | 156 | |
| 155 | 157 | else if ($this instanceof Component\Auth) { |
| 156 | 158 | |
| 157 | - if (Auth::check()) Request::redirect(INSTALL_PATH . '/admin'); |
|
| 158 | - |
|
| 159 | - if ($this instanceof Component\Auth\Initial) { if (!Auth::initial()) Request::redirect(INSTALL_PATH . '/admin/login'); } |
|
| 159 | + if (Auth::check()) { |
|
| 160 | + Request::redirect(INSTALL_PATH . '/admin'); |
|
| 161 | + } |
|
| 160 | 162 | |
| 161 | - else if (Auth::initial()) Request::redirect(INSTALL_PATH . '/admin/register'); |
|
| 163 | + if ($this instanceof Component\Auth\Initial) { if (!Auth::initial()) { |
|
| 164 | + Request::redirect(INSTALL_PATH . '/admin/login'); |
|
| 165 | + } |
|
| 166 | + } else if (Auth::initial()) { |
|
| 167 | + Request::redirect(INSTALL_PATH . '/admin/register'); |
|
| 168 | + } |
|
| 162 | 169 | |
| 163 | - if (Template::isBlock($result = $this->handle())) return $this->displayForm($result, STATUS_CODE_401); |
|
| 170 | + if (Template::isBlock($result = $this->handle())) { |
|
| 171 | + return $this->displayForm($result, STATUS_CODE_401); |
|
| 172 | + } |
|
| 164 | 173 | } |
| 165 | 174 | |
| 166 | 175 | # Handle panel component request |
@@ -172,9 +181,13 @@ discard block |
||
| 172 | 181 | Request::redirect(INSTALL_PATH . '/admin/login'); |
| 173 | 182 | } |
| 174 | 183 | |
| 175 | - if (Template::isBlock($result = $this->handle())) return $this->displayPage($result); |
|
| 184 | + if (Template::isBlock($result = $this->handle())) { |
|
| 185 | + return $this->displayPage($result); |
|
| 186 | + } |
|
| 176 | 187 | |
| 177 | - if (Ajax::isResponse($result)) return Ajax::output($result); |
|
| 188 | + if (Ajax::isResponse($result)) { |
|
| 189 | + return Ajax::output($result); |
|
| 190 | + } |
|
| 178 | 191 | } |
| 179 | 192 | } |
| 180 | 193 | |
@@ -31,7 +31,7 @@ discard block |
||
| 31 | 31 | |
| 32 | 32 | # Set title |
| 33 | 33 | |
| 34 | - $form->title = ((('' !== $this->title) ? ($this->title . ' | ') : '') . CADMIUM_NAME); |
|
| 34 | + $form->title = ((('' !== $this->title) ? ($this->title.' | ') : '').CADMIUM_NAME); |
|
| 35 | 35 | |
| 36 | 36 | # Create layout |
| 37 | 37 | |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | |
| 73 | 73 | # Set title |
| 74 | 74 | |
| 75 | - $page->title = ((('' !== $this->title) ? ($this->title . ' | ') : '') . CADMIUM_NAME); |
|
| 75 | + $page->title = ((('' !== $this->title) ? ($this->title.' | ') : '').CADMIUM_NAME); |
|
| 76 | 76 | |
| 77 | 77 | # Create layout |
| 78 | 78 | |
@@ -153,11 +153,11 @@ discard block |
||
| 153 | 153 | |
| 154 | 154 | else if ($this instanceof Component\Auth) { |
| 155 | 155 | |
| 156 | - if (Auth::check()) Request::redirect(INSTALL_PATH . '/admin'); |
|
| 156 | + if (Auth::check()) Request::redirect(INSTALL_PATH.'/admin'); |
|
| 157 | 157 | |
| 158 | - if ($this instanceof Component\Auth\Initial) { if (!Auth::initial()) Request::redirect(INSTALL_PATH . '/admin/login'); } |
|
| 158 | + if ($this instanceof Component\Auth\Initial) { if (!Auth::initial()) Request::redirect(INSTALL_PATH.'/admin/login'); } |
|
| 159 | 159 | |
| 160 | - else if (Auth::initial()) Request::redirect(INSTALL_PATH . '/admin/register'); |
|
| 160 | + else if (Auth::initial()) Request::redirect(INSTALL_PATH.'/admin/register'); |
|
| 161 | 161 | |
| 162 | 162 | if (Template::isBlock($result = $this->handle())) return $this->displayForm($result, STATUS_CODE_401); |
| 163 | 163 | } |
@@ -168,7 +168,7 @@ discard block |
||
| 168 | 168 | |
| 169 | 169 | if (!Auth::check() || ((false !== Request::get('logout')) && Auth::logout())) { |
| 170 | 170 | |
| 171 | - Request::redirect(INSTALL_PATH . '/admin/login'); |
|
| 171 | + Request::redirect(INSTALL_PATH.'/admin/login'); |
|
| 172 | 172 | } |
| 173 | 173 | |
| 174 | 174 | if (Template::isBlock($result = $this->handle())) return $this->displayPage($result); |
@@ -40,7 +40,9 @@ discard block |
||
| 40 | 40 | |
| 41 | 41 | if (Settings::get('users_registration')) { |
| 42 | 42 | |
| 43 | - if (!Auth::check()) $layout->block('auth')->enable(); else { |
|
| 43 | + if (!Auth::check()) { |
|
| 44 | + $layout->block('auth')->enable(); |
|
| 45 | + } else { |
|
| 44 | 46 | |
| 45 | 47 | $layout->block('user')->enable(); |
| 46 | 48 | |
@@ -48,7 +50,9 @@ discard block |
||
| 48 | 50 | |
| 49 | 51 | $layout->block('user')->name = Auth::user()->name; |
| 50 | 52 | |
| 51 | - if (Auth::user()->rank === RANK_ADMINISTRATOR) $layout->block('user')->block('admin')->enable(); |
|
| 53 | + if (Auth::user()->rank === RANK_ADMINISTRATOR) { |
|
| 54 | + $layout->block('user')->block('admin')->enable(); |
|
| 55 | + } |
|
| 52 | 56 | } |
| 53 | 57 | } |
| 54 | 58 | |
@@ -109,9 +113,11 @@ discard block |
||
| 109 | 113 | |
| 110 | 114 | # Set canonical |
| 111 | 115 | |
| 112 | - if ('' === $this->canonical) $page->block('canonical')->disable(); |
|
| 113 | - |
|
| 114 | - else $page->block('canonical')->link = $this->canonical; |
|
| 116 | + if ('' === $this->canonical) { |
|
| 117 | + $page->block('canonical')->disable(); |
|
| 118 | + } else { |
|
| 119 | + $page->block('canonical')->link = $this->canonical; |
|
| 120 | + } |
|
| 115 | 121 | |
| 116 | 122 | # Set layout |
| 117 | 123 | |
@@ -128,19 +134,27 @@ discard block |
||
| 128 | 134 | |
| 129 | 135 | # Check site status |
| 130 | 136 | |
| 131 | - if (Settings::get('site_status') === STATUS_MAINTENANCE) return Status::maintenance(); |
|
| 137 | + if (Settings::get('site_status') === STATUS_MAINTENANCE) { |
|
| 138 | + return Status::maintenance(); |
|
| 139 | + } |
|
| 132 | 140 | |
| 133 | - if (Settings::get('site_status') === STATUS_UPDATE) return Status::update(); |
|
| 141 | + if (Settings::get('site_status') === STATUS_UPDATE) { |
|
| 142 | + return Status::update(); |
|
| 143 | + } |
|
| 134 | 144 | |
| 135 | 145 | # Check access rights |
| 136 | 146 | |
| 137 | 147 | if ($this instanceof Component\Profile) { |
| 138 | 148 | |
| 139 | - if (!Settings::get('users_registration')) return Status::error404(); |
|
| 149 | + if (!Settings::get('users_registration')) { |
|
| 150 | + return Status::error404(); |
|
| 151 | + } |
|
| 140 | 152 | |
| 141 | 153 | if (($this instanceof Component\Profile\Auth)) { |
| 142 | 154 | |
| 143 | - if (Auth::check()) Request::redirect(INSTALL_PATH . '/profile'); |
|
| 155 | + if (Auth::check()) { |
|
| 156 | + Request::redirect(INSTALL_PATH . '/profile'); |
|
| 157 | + } |
|
| 144 | 158 | |
| 145 | 159 | } else if (!Auth::check() || ((false !== Request::get('logout')) && Auth::logout())) { |
| 146 | 160 | |
@@ -156,9 +170,13 @@ discard block |
||
| 156 | 170 | |
| 157 | 171 | $variables = new Variables(); $widgets = new Widgets(); |
| 158 | 172 | |
| 159 | - foreach ($variables->items() as $name => $value) Template::global($name, $value); |
|
| 173 | + foreach ($variables->items() as $name => $value) { |
|
| 174 | + Template::global($name, $value); |
|
| 175 | + } |
|
| 160 | 176 | |
| 161 | - foreach ($widgets->items() as $name => $block) Template::widget($name, $block); |
|
| 177 | + foreach ($widgets->items() as $name => $block) { |
|
| 178 | + Template::widget($name, $block); |
|
| 179 | + } |
|
| 162 | 180 | |
| 163 | 181 | # Display page |
| 164 | 182 | |
@@ -25,7 +25,7 @@ discard block |
||
| 25 | 25 | |
| 26 | 26 | private function getLayout(Template\Asset\Block $contents) { |
| 27 | 27 | |
| 28 | - $layout = View::get('Layouts\\' . $this->layout); |
|
| 28 | + $layout = View::get('Layouts\\'.$this->layout); |
|
| 29 | 29 | |
| 30 | 30 | # Create layout components |
| 31 | 31 | |
@@ -100,11 +100,11 @@ discard block |
||
| 100 | 100 | |
| 101 | 101 | $page->keywords = ('' !== $this->keywords) ? $this->keywords : Settings::get('site_keywords'); |
| 102 | 102 | |
| 103 | - $page->robots = (($this->robots_index ? 'INDEX' : 'NOINDEX') . ',' . ($this->robots_follow ? 'FOLLOW' : 'NOFOLLOW')); |
|
| 103 | + $page->robots = (($this->robots_index ? 'INDEX' : 'NOINDEX').','.($this->robots_follow ? 'FOLLOW' : 'NOFOLLOW')); |
|
| 104 | 104 | |
| 105 | 105 | # Set title |
| 106 | 106 | |
| 107 | - $page->title = ((('' !== $this->title) ? ($this->title . ' | ') : '') . Settings::get('site_title')); |
|
| 107 | + $page->title = ((('' !== $this->title) ? ($this->title.' | ') : '').Settings::get('site_title')); |
|
| 108 | 108 | |
| 109 | 109 | # Set canonical |
| 110 | 110 | |
@@ -139,11 +139,11 @@ discard block |
||
| 139 | 139 | |
| 140 | 140 | if (($this instanceof Component\Profile\Auth)) { |
| 141 | 141 | |
| 142 | - if (Auth::check()) Request::redirect(INSTALL_PATH . '/profile'); |
|
| 142 | + if (Auth::check()) Request::redirect(INSTALL_PATH.'/profile'); |
|
| 143 | 143 | |
| 144 | 144 | } else if (!Auth::check() || ((false !== Request::get('logout')) && Auth::logout())) { |
| 145 | 145 | |
| 146 | - Request::redirect(INSTALL_PATH . '/profile/login'); |
|
| 146 | + Request::redirect(INSTALL_PATH.'/profile/login'); |
|
| 147 | 147 | } |
| 148 | 148 | } |
| 149 | 149 | |