-
Notifications
You must be signed in to change notification settings - Fork 0
/
controller.php
79 lines (66 loc) · 2.33 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
71
72
73
74
75
76
77
78
79
<?php
namespace Concrete\Package\KalmoyaElementalCloner;
defined('C5_EXECUTE') or die('Access denied.');
use Concrete\Core\Page\Page;
use Concrete\Core\Package\Package;
use Concrete\Core\Support\Facade\Route;
use Concrete\Core\Block\BlockType\BlockType;
use Concrete\Core\Page\Single as SinglePage;
class Controller extends Package
{
protected $pkgHandle = 'kalmoya_elemental_cloner';
protected $appVersionRequired = '8.0.0';
protected $pkgVersion = '1.0';
protected $pkgAutoloaderRegistries = [
'vendor/kalmoya' => '\ElClKalmoya',
'src/ElementalCloner' => '\KalmoyaElementalCloner',
];
public function getPackageName()
{
return t('Elemental Cloner');
}
public function getPackageDescription()
{
return t("Easily clone Elemental as a new theme anytime you like %s Developed by Nour Akalay @ %sKALMOYA - bespoke Concrete5 development%s", '<br /><span style="font-size:11px;">', '<a target="_blank" href="https://www.kalmoya.com">', '</a></span>');
}
public function on_start()
{
define(ELEMENTAL_CLONER_PACKAGE_HANDLE, $this->pkgHandle);
Route::register(
'/elementalcloner/uploadThumb',
'\KalmoyaElementalCloner\ThumbnailUploader::uploadThumb'
);
}
public function install()
{
$pkg = parent::install();
$this->installPages($pkg);
}
public function upgrade()
{
$pkg = Package::getByHandle($this->pkgHandle);
parent::upgrade();
$this->installPages($pkg);
}
protected function installPages($pkg)
{
$singlePages = [
[
'path' => '/dashboard/pages/elemental_cloner',
'cName' => t('Elemental Cloner'),
],
];
foreach ($singlePages as $singlePage) {
$singlePageObject = Page::getByPath($singlePage['path']);
// Check if it exists, if not, add it
if ($singlePageObject->isError() || (!is_object($singlePageObject))) {
$sp = SinglePage::add($singlePage['path'], $pkg);
unset($singlePage['path']);
if (!empty($singlePage)) {
// And make sure we update the page with the remaining values
$sp->update($singlePage);
}
}
}
}
}