| @@ 125-148 (lines=24) @@ | ||
| 122 | * @throws \Ffcms\Core\Exception\SyntaxException |
|
| 123 | * @throws \Ffcms\Core\Exception\NativeException |
|
| 124 | */ |
|
| 125 | public function actionDelete($id) |
|
| 126 | { |
|
| 127 | if (!Obj::isLikeInt($id) || $id < 1) { |
|
| 128 | throw new NotFoundException(); |
|
| 129 | } |
|
| 130 | ||
| 131 | // get content record and check availability |
|
| 132 | $record = ContentEntity::find($id); |
|
| 133 | if ($record === null || $record === false) { |
|
| 134 | throw new NotFoundException(); |
|
| 135 | } |
|
| 136 | ||
| 137 | // init delete model |
|
| 138 | $model = new FormContentDelete($record); |
|
| 139 | if ($model->send() && $model->validate()) { |
|
| 140 | $model->make(); |
|
| 141 | App::$Session->getFlashBag()->add('success', __('Content is successful moved to trash')); |
|
| 142 | $this->response->redirect('content/index'); |
|
| 143 | } |
|
| 144 | ||
| 145 | return $this->view->render('content_delete', [ |
|
| 146 | 'model' => $model |
|
| 147 | ]); |
|
| 148 | } |
|
| 149 | ||
| 150 | /** |
|
| 151 | * Restore deleted content |
|
| @@ 158-183 (lines=26) @@ | ||
| 155 | * @throws SyntaxException |
|
| 156 | * @throws \Ffcms\Core\Exception\NativeException |
|
| 157 | */ |
|
| 158 | public function actionRestore($id) |
|
| 159 | { |
|
| 160 | if (!Obj::isLikeInt($id) || $id < 1) { |
|
| 161 | throw new NotFoundException(); |
|
| 162 | } |
|
| 163 | ||
| 164 | // get removed object |
|
| 165 | $record = ContentEntity::onlyTrashed()->find($id); |
|
| 166 | if ($record === null || $record === false) { |
|
| 167 | throw new NotFoundException(); |
|
| 168 | } |
|
| 169 | ||
| 170 | // init model |
|
| 171 | $model = new FormContentRestore($record); |
|
| 172 | // check if action is send |
|
| 173 | if ($model->send() && $model->validate()) { |
|
| 174 | $model->make(); |
|
| 175 | App::$Session->getFlashBag()->add('success', __('Content are successful recovered')); |
|
| 176 | $this->response->redirect('content/index'); |
|
| 177 | } |
|
| 178 | ||
| 179 | // draw response |
|
| 180 | return $this->view->render('content_restore', [ |
|
| 181 | 'model' => $model |
|
| 182 | ]); |
|
| 183 | } |
|
| 184 | ||
| 185 | /** |
|
| 186 | * Clear all trashed items |
|
| @@ 232-259 (lines=28) @@ | ||
| 229 | * @throws \Ffcms\Core\Exception\SyntaxException |
|
| 230 | * @throws \Ffcms\Core\Exception\NativeException |
|
| 231 | */ |
|
| 232 | public function actionCategorydelete($id) |
|
| 233 | { |
|
| 234 | // check id |
|
| 235 | if (!Obj::isLikeInt($id) || $id < 2) { |
|
| 236 | throw new ForbiddenException(); |
|
| 237 | } |
|
| 238 | ||
| 239 | // get object relation |
|
| 240 | $record = ContentCategory::find($id); |
|
| 241 | if ($record === null || $record === false) { |
|
| 242 | throw new ForbiddenException(); |
|
| 243 | } |
|
| 244 | ||
| 245 | // init model with object relation |
|
| 246 | $model = new FormCategoryDelete($record); |
|
| 247 | ||
| 248 | // check if delete is submited |
|
| 249 | if ($model->send() && $model->validate()) { |
|
| 250 | $model->make(); |
|
| 251 | App::$Session->getFlashBag()->add('success', __('Category is successful removed')); |
|
| 252 | $this->response->redirect('content/categories'); |
|
| 253 | } |
|
| 254 | ||
| 255 | // draw view |
|
| 256 | return $this->view->render('category_delete', [ |
|
| 257 | 'model' => $model |
|
| 258 | ]); |
|
| 259 | } |
|
| 260 | ||
| 261 | /** |
|
| 262 | * Show category edit and create |
|