-
Notifications
You must be signed in to change notification settings - Fork 453
/
design.php
92 lines (78 loc) · 2.98 KB
/
design.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
<?php
namespace Concrete\Controller\Dialog\Area;
use Concrete\Core\Area\CustomStyle;
use Concrete\Core\Page\EditResponse;
use Concrete\Core\StyleCustomizer\Inline\StyleSet;
use Concrete\Controller\Backend\UserInterface\Page as BackendPageController;
class Design extends BackendPageController
{
protected $viewPath = '/dialogs/area/design';
public function on_start()
{
parent::on_start();
$this->area = \Area::getOrCreate($this->page, $_REQUEST['arHandle']);
$this->permissions = new \Permissions($this->area);
$this->set('a', $this->area);
}
protected function canAccess()
{
return $this->permissions->canEditAreaDesign();
}
public function reset()
{
$a = $this->area;
$nvc = $this->page->getVersionToModify();
$nvc->resetAreaCustomStyle($a);
$pr = new EditResponse();
$pr->setPage($this->page);
$pr->setAdditionalDataAttribute('aID', $this->area->getAreaID());
$pr->setAdditionalDataAttribute('arHandle', $this->area->getAreaHandle());
$pr->setMessage(t('Custom design reset.'));
$pr->outputJSON();
}
public function submit()
{
if ($this->validateAction() && $this->canAccess()) {
$a = $this->area;
$oldStyle = $this->page->getAreaCustomStyle($a);
if (is_object($oldStyle)) {
$oldStyleSet = $oldStyle->getStyleSet();
}
$nvc = $this->page->getVersionToModify();
$set = StyleSet::populateFromRequest($this->request);
if (is_object($set)) {
$set->save();
$nvc->setCustomStyleSet($a, $set);
} elseif ($oldStyleSet) {
$nvc->resetAreaCustomStyle($this->area);
}
$pr = new EditResponse();
$pr->setPage($this->page);
$pr->setAdditionalDataAttribute('aID', $this->area->getAreaID());
$pr->setAdditionalDataAttribute('arHandle', $this->area->getAreaHandle());
if (is_object($oldStyleSet)) {
$pr->setAdditionalDataAttribute('oldIssID', $oldStyleSet->getID());
}
if (is_object($set)) {
$pr->setAdditionalDataAttribute('issID', $set->getID());
$style = new CustomStyle($set, $this->area, $this->page->getCollectionThemeObject());
$css = $style->getCSS();
if ($css !== '') {
$pr->setAdditionalDataAttribute('css', $style->getStyleWrapper($style->getCSS()));
}
$pr->setAdditionalDataAttribute('containerClass', $style->getContainerClass());
}
$pr->setMessage(t('Design updated.'));
$pr->outputJSON();
}
}
public function action()
{
$url = call_user_func_array('parent::action', func_get_args());
$url .= '&arHandle=' . h($this->area->getAreaHandle());
return $url;
}
public function view()
{
}
}