-
Notifications
You must be signed in to change notification settings - Fork 0
/
controller.php
executable file
·77 lines (62 loc) · 2.49 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
<?php
namespace Concrete\Package\Cookieconsent;
use Concrete\Core\Page\Single as SinglePage;
use Concrete\Core\Support\Facade\Config;
use Package;
use Loader;
use View;
use Route;
defined('C5_EXECUTE') or die(_("Access Denied."));
class Controller extends Package
{
protected $pkgHandle = 'cookieconsent';
protected $appVersionRequired = '8.0.0';
protected $pkgVersion = '1.0';
protected $pkgAutoloaderRegistries = [
'src/Cookieconsent' => '\Concrete\Package\Cookieconsent\Src\Cookieconsent',
];
public function getPackageDescription()
{
return t("Cookieconsent");
}
public function getPackageName()
{
return t("Cookieconsent");
}
public function install()
{
$pkg = parent::install();
SinglePage::add('/dashboard/cookieconsent', $pkg);
}
// Set Defaults
public function setDefaults(){
Config::save('cookieconsent.defaults', 1);
Config::save('cookieconsent.popup-color', '#000000');
Config::save('cookieconsent.button-color', '#ffaa00');
Config::save('cookieconsent.layout', 'block');
Config::save('cookieconsent.position', 'top');
Config::save('cookieconsent.button-text', t('Got it!'));
Config::save('cookieconsent.link-text', t('Learn more'));
Config::save('cookieconsent.pageID', '');
Config::save('cookieconsent.href', '');
Config::save('cookieconsent.text', t('This website uses cookies to ensure you get the best experience on our website.'));
}
public function on_start()
{
Route::register('/cookieconsent/getData', '\Concrete\Package\Cookieconsent\Src\Cookieconsent\Helper::getData');
if (Config::get('cookieconsent.defaults') != 1) {
$this->setDefaults();
}
// Load magic only if cookie not exist
if(!isset($_COOKIE['cookieconsent_status'])){
View::getInstance()->addHeaderItem(Loader::helper('html')->css('/packages/cookieconsent/build/cookieconsent.min.css'));
View::getInstance()->addFooterItem(Loader::helper('html')->javascript('/packages/cookieconsent/build/cookieconsent.min.js'));
View::getInstance()->addFooterItem(Loader::helper('html')->javascript('/packages/cookieconsent/loadCooekieconsent.js'));
}
}
public function uninstall()
{
Config::save('cookieconsent.defaults', null);
parent::uninstall();
}
}