forked from jordanlev/c5_designer_content
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcontroller.php
70 lines (54 loc) · 1.87 KB
/
controller.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
<?php
namespace Concrete\Package\DesignerContent;
use Loader;
use Page;
use SinglePage;
use CollectionAttributeKey;
use BlockType;
use Route;
use View;
use Plugin;
use \Core;
use \Concrete\Package\DesignerContent\Libraries\BlockGenerator as DesignerContentBlockGenerator;
defined('C5_EXECUTE') or die(_("Access Denied."));
class Controller extends \Concrete\Core\Package\Package {
protected $pkgHandle = 'designer_content';
protected $appVersionRequired = '5.7';
protected $pkgVersion = '4.0';
public function on_start() {
Route::register('/validate_handle', '\Concrete\Package\DesignerContent\Controller\SinglePage\Dashboard\Blocks\ValidateHandle::validate');
}
public function getPackageName() {
return t("Designer Content");
}
public function getPackageDescription() {
return t('Create custom content blocks via the dashboard.');
}
public function install() {
$pkg = parent::install();
$this->_upgrade($pkg);
}
public function upgrade() {
$pkg = Package::getByHandle('designer_content');
$this->_upgrade($pkg);
parent::upgrade();
}
private function _upgrade(&$pkg) {
Loader::model('single_page');
$oldDashboardPage = Page::getByPath('/dashboard/pages/designer_content');
if ($oldDashboardPage && is_object($oldDashboardPage) && $oldDashboardPage->getCollectionID()) {
$oldDashboardPage->delete();
}
$newDashboardPage = Page::getByPath('/dashboard/blocks/designer_content');
if (!$newDashboardPage || !is_object($newDashboardPage) || !$newDashboardPage->getCollectionID()) {
$newDashboardPage = SinglePage::add('/dashboard/blocks/designer_content', $pkg);
}
$this->_setupDashboardIcon($newDashboardPage, 'icon-gift');
}
private function _setupDashboardIcon($page, $icon) {
$cak = CollectionAttributeKey::getByHandle('icon_dashboard');
if (is_object($cak)) {
$page->setAttribute('icon_dashboard', $icon);
}
}
}