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\ActionCategoryList { |
44
|
|
|
contentCategoryList as actionCategories; |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
use Content\ActionCategoryDelete { |
48
|
|
|
categoryDelete as actionCategorydelete; |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
use Content\ActionCategoryUpdate { |
|
|
|
|
52
|
|
|
categoryUpdate as actionCategoryupdate; |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
use Content\ActionGlobDelete { |
|
|
|
|
56
|
|
|
globDelete as actionGlobdelete; |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
use Content\ActionPublish { |
|
|
|
|
60
|
|
|
publish as actionPublish; |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* Show settings form with prepared model |
65
|
|
|
* @return string |
66
|
|
|
* @throws SyntaxException |
67
|
|
|
*/ |
68
|
|
|
public function actionSettings(): ?string |
69
|
|
|
{ |
70
|
|
|
// init model with config array data |
71
|
|
|
$model = new FormSettings($this->getConfigs()); |
72
|
|
|
|
73
|
|
|
// check if form is send |
74
|
|
|
if ($model->send()) { |
75
|
|
|
if ($model->validate()) { |
76
|
|
|
$this->setConfigs($model->getAllProperties()); |
|
|
|
|
77
|
|
|
App::$Session->getFlashBag()->add('success', __('Settings is successful updated')); |
78
|
|
|
$this->response->redirect('content/index'); |
79
|
|
|
} else { |
80
|
|
|
App::$Session->getFlashBag()->add('error', __('Form validation is failed')); |
81
|
|
|
} |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
// draw response |
85
|
|
|
return $this->view->render('content/settings', [ |
86
|
|
|
'model' => $model |
87
|
|
|
]); |
88
|
|
|
} |
89
|
|
|
} |
90
|
|
|
|