|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Apps\Controller\Admin; |
|
4
|
|
|
|
|
5
|
|
|
use Apps\ActiveRecord\ContentCategory; |
|
6
|
|
|
use Apps\Model\Admin\Content\FormSettings; |
|
7
|
|
|
use Extend\Core\Arch\AdminController; |
|
8
|
|
|
use Ffcms\Core\App; |
|
9
|
|
|
use Ffcms\Core\Exception\SyntaxException; |
|
10
|
|
|
|
|
11
|
|
|
/** |
|
12
|
|
|
* Class Content. Admin controller to manage & control contents |
|
13
|
|
|
* @package Apps\Controller\Admin |
|
14
|
|
|
*/ |
|
15
|
|
|
class Content extends AdminController |
|
16
|
|
|
{ |
|
17
|
|
|
const VERSION = '1.0.0'; |
|
18
|
|
|
const ITEM_PER_PAGE = 10; |
|
19
|
|
|
|
|
20
|
|
|
public $type = 'app'; |
|
21
|
|
|
|
|
22
|
|
|
// import heavy actions |
|
23
|
|
|
use Content\ActionIndex { |
|
24
|
|
|
index as actionIndex; |
|
25
|
|
|
} |
|
26
|
|
|
|
|
27
|
|
|
use Content\ActionUpdate { |
|
28
|
|
|
update as actionUpdate; |
|
29
|
|
|
} |
|
30
|
|
|
|
|
31
|
|
|
use Content\ActionDelete { |
|
32
|
|
|
delete as actionDelete; |
|
33
|
|
|
} |
|
34
|
|
|
|
|
35
|
|
|
use Content\ActionRestore { |
|
36
|
|
|
restore as actionRestore; |
|
37
|
|
|
} |
|
38
|
|
|
|
|
39
|
|
|
use Content\ActionClear { |
|
40
|
|
|
clear as actionClear; |
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
|
|
use Content\ActionCategoryDelete { |
|
44
|
|
|
categoryDelete as actionCategorydelete; |
|
45
|
|
|
} |
|
46
|
|
|
|
|
47
|
|
|
use Content\ActionCategoryUpdate { |
|
48
|
|
|
categoryUpdate as actionCategoryupdate; |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
|
|
use Content\ActionGlobDelete { |
|
52
|
|
|
globDelete as actionGlobdelete; |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
use Content\ActionPublish { |
|
56
|
|
|
publish as actionPublish; |
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
|
|
/** |
|
60
|
|
|
* Display category list |
|
61
|
|
|
* @return string |
|
62
|
|
|
* @throws SyntaxException |
|
63
|
|
|
*/ |
|
64
|
|
|
public function actionCategories(): ?string |
|
65
|
|
|
{ |
|
66
|
|
|
return $this->view->render('category_list', [ |
|
67
|
|
|
'categories' => ContentCategory::getSortedAll() |
|
68
|
|
|
]); |
|
69
|
|
|
} |
|
70
|
|
|
|
|
71
|
|
|
/** |
|
72
|
|
|
* Show settings form with prepared model |
|
73
|
|
|
* @return string |
|
74
|
|
|
* @throws SyntaxException |
|
75
|
|
|
*/ |
|
76
|
|
|
public function actionSettings(): ?string |
|
77
|
|
|
{ |
|
78
|
|
|
// init model with config array data |
|
79
|
|
|
$model = new FormSettings($this->getConfigs()); |
|
80
|
|
|
|
|
81
|
|
|
// check if form is send |
|
82
|
|
|
if ($model->send()) { |
|
83
|
|
|
if ($model->validate()) { |
|
84
|
|
|
$this->setConfigs($model->getAllProperties()); |
|
85
|
|
|
App::$Session->getFlashBag()->add('success', __('Settings is successful updated')); |
|
86
|
|
|
$this->response->redirect('content/index'); |
|
87
|
|
|
} else { |
|
88
|
|
|
App::$Session->getFlashBag()->add('error', __('Form validation is failed')); |
|
89
|
|
|
} |
|
90
|
|
|
} |
|
91
|
|
|
|
|
92
|
|
|
// draw response |
|
93
|
|
|
return $this->view->render('settings', [ |
|
94
|
|
|
'model' => $model |
|
95
|
|
|
]); |
|
96
|
|
|
} |
|
97
|
|
|
} |
|
98
|
|
|
|