-
Notifications
You must be signed in to change notification settings - Fork 16
/
controller.php
52 lines (39 loc) · 1.42 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
<?php defined('C5_EXECUTE') or die(_("Access Denied."));
class DesignerContentPackage extends Package {
protected $pkgHandle = 'designer_content';
protected $appVersionRequired = '5.5.2';
protected $pkgVersion = '3.2';
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);
}
}
}