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