-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
228 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"name": "YourVendorName/CookieNotice", | ||
"type": "pimcore-plugin", | ||
"require": { | ||
"pimcore/installer-plugin": ">=1" | ||
}, | ||
"autoload": { | ||
"psr-4": { | ||
"CookieNotice\\": "lib" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
|
||
|
||
class CookieNotice_IndexController extends \Pimcore\Controller\Action\Admin | ||
{ | ||
public function indexAction() | ||
{ | ||
|
||
} | ||
|
||
public function jsAction() | ||
{ | ||
$this->disableViewAutoRender(); | ||
$this->getResponse()->setHeader("Content-Type", "application/javascript"); | ||
$config = $this->getConfig(); | ||
echo "var COOKIE_NOTICE_TEXT = '" . str_replace("'", "\'", $config->text) . "';\n"; | ||
echo "var COOKIE_NOTICE_BUTTON = '" . str_replace("'", "\'", $config->buttonLabel) . "';\n"; | ||
} | ||
|
||
public function cssAction() | ||
{ | ||
$this->disableViewAutoRender(); | ||
$this->getResponse()->setHeader("Content-Type", "text/css"); | ||
$config = $this->getConfig(); | ||
echo $config->css; | ||
} | ||
|
||
private function getConfig() { | ||
$fileContent = file_get_contents(PIMCORE_WEBSITE_PATH . '/var/config/cookienotice.json'); | ||
return json_decode(str_replace("\n", "", $fileContent)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"css": ".cookieNotice {} | ||
.cookieNotice__text {} | ||
.cookieNotice__button {}", | ||
"text": "", | ||
"buttonLabel": "" | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
<?php | ||
|
||
namespace CookieNotice; | ||
|
||
use Pimcore\API\Plugin as PluginLib; | ||
|
||
class Plugin extends PluginLib\AbstractPlugin implements PluginLib\PluginInterface | ||
{ | ||
const SAMPLE_CONFIG_XML = "/CookieNotice/cookienotice.json"; | ||
const CONFIG_XML = '/var/config/cookienotice.json'; | ||
|
||
public function init() | ||
{ | ||
parent::init(); | ||
|
||
// register your events here | ||
|
||
// using anonymous function | ||
\Pimcore::getEventManager()->attach("frontend.controller.postInit", function ($event) { | ||
// do something | ||
$event->getTarget()->view->headLink()->appendStylesheet('/plugins/CookieNotice/static/css/cookieNotice.css'); | ||
$event->getTarget()->view->headLink()->appendStylesheet('/plugin/CookieNotice/index/css'); | ||
$event->getTarget()->view->headScript()->appendFile('/plugin/CookieNotice/index/js'); | ||
$event->getTarget()->view->headScript()->appendFile('/plugins/CookieNotice/static/js/cookieNotice.js'); | ||
|
||
}); | ||
} | ||
|
||
public function handleDocument($event) {} | ||
|
||
public static function install() | ||
{ | ||
if (!file_exists(self::getConfigName())) { | ||
$defaultContent = file_get_contents(PIMCORE_PLUGINS_PATH . self::SAMPLE_CONFIG_XML); | ||
file_put_contents(self::getConfigName(), $defaultContent); | ||
//copy(PIMCORE_PLUGINS_PATH . self::SAMPLE_CONFIG_XML, self::getConfigName()) | ||
/*$defaultConfig = self::getDefaultConfigXML(); | ||
$configWriter = new \Zend_Config_Writer_Xml(); | ||
$configWriter->setConfig($defaultConfig); | ||
$configWriter->write(self::getConfigName());*/ | ||
} | ||
} | ||
|
||
public static function uninstall() { | ||
if (file_exists(self::getConfigName())) { | ||
unlink(self::getConfigName()); | ||
} | ||
} | ||
|
||
public static function isInstalled() | ||
{ | ||
return file_exists(self::getConfigName()); | ||
} | ||
|
||
private static function getConfigName() | ||
{ | ||
return PIMCORE_WEBSITE_PATH . self::CONFIG_XML; | ||
} | ||
|
||
private static function getDefaultConfigXML() | ||
{ | ||
return new \Zend_Config_Xml(PIMCORE_PLUGINS_PATH . self::SAMPLE_CONFIG_XML); | ||
} | ||
|
||
private static function getConfigXML() | ||
{ | ||
return new \Zend_Config_Xml(self::getConfigName()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?xml version="1.0"?> | ||
<zend-config xmlns:zf="http://framework.zend.com/xml/zend-config-xml/1.0/"> | ||
<plugin> | ||
|
||
<!-- the plugin name [A-Za-z_] --> | ||
<pluginName>CookieNotice</pluginName> | ||
|
||
<!-- a short description --> | ||
<pluginDescription>Displays a notification bar regarding the EU cookie law</pluginDescription> | ||
|
||
<!-- meta data --> | ||
<pluginVersion>1.0</pluginVersion> | ||
<pluginRevision>1</pluginRevision> | ||
<pluginBuildTimestamp>0</pluginBuildTimestamp> | ||
|
||
<!-- put in the URL for the plugin configuration eg. /plugin/CookieNotice/admin/index --> | ||
<pluginIframeSrc></pluginIframeSrc> | ||
|
||
<!-- className of the plugin which extends Pimcore_API_Plugin_Abstract--> | ||
<pluginClassName>\CookieNotice\Plugin</pluginClassName> | ||
|
||
<!-- include paths relative to plugin-directory --> | ||
<pluginIncludePaths> | ||
<path>/CookieNotice/lib</path> | ||
</pluginIncludePaths> | ||
|
||
<!-- namespaces to register with autoloader--> | ||
<pluginNamespaces> | ||
<namespace>CookieNotice</namespace> | ||
</pluginNamespaces> | ||
|
||
<pluginXmlEditorFile>/website/var/config/cookienotice.json</pluginXmlEditorFile> | ||
</plugin> | ||
</zend-config> |
Binary file not shown.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
.cookieNotice { | ||
position: fixed; | ||
bottom: 0px; | ||
left: 0px; | ||
width: 100%; | ||
background: #FFFFFF; | ||
padding: 10px; | ||
display: flex; | ||
|
||
.cookieNotice__text { | ||
color: #333; | ||
margin: auto 0px; | ||
flex-grow: 1; | ||
} | ||
|
||
.cookieNotice__button { | ||
margin: 0px 0px auto 15px; | ||
border: 2px solid #333; | ||
padding: 10px; | ||
color: #333; | ||
background-color: #FFF; | ||
cursor: pointer; | ||
flex-grow: 0; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
window.onload = function () { | ||
var cookieName = 'cookiesAllowed'; | ||
|
||
var splitted = document.cookie.split(';'); | ||
var cookieFound = false; | ||
for(var i = 0; i < splitted.length; i++) { | ||
if(splitted[i].trim() == cookieName + '=1') { | ||
cookieFound = true; | ||
break; | ||
} | ||
} | ||
|
||
if(!cookieFound) { | ||
var cookieNotice = document.createElement('div'); | ||
cookieNotice.setAttribute('class', 'cookieNotice'); | ||
|
||
var cookieNoticeButton = document.createElement('div'); | ||
cookieNoticeButton.setAttribute('class', 'cookieNotice__button'); | ||
cookieNoticeButton.innerHTML = typeof(COOKIE_NOTICE_BUTTON) !== 'undefined' && COOKIE_NOTICE_BUTTON != '' ? COOKIE_NOTICE_BUTTON : 'Cookies erlauben'; | ||
|
||
cookieNoticeButton.addEventListener('click', function () { | ||
var days = 30; | ||
var date = new Date(); | ||
date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000)); | ||
document.cookie = cookieName + "=1; expires=" + date.toUTCString(); | ||
var notice = document.getElementsByClassName('cookieNotice')[0]; | ||
notice.parentNode.removeChild(notice); | ||
}); | ||
|
||
var cookieNoticeText = document.createElement('div'); | ||
cookieNoticeText.setAttribute('class', 'cookieNotice__text'); | ||
cookieNoticeText.innerHTML = typeof(COOKIE_NOTICE_TEXT) !== 'undefined' && COOKIE_NOTICE_TEXT != '' ? COOKIE_NOTICE_TEXT : 'Diese Internetseite verwendet Cookies, um die Nutzererfahrung zu verbessern und den Benutzern bestimmte Dienste und Funktionen bereitzustellen.'; | ||
|
||
cookieNotice.append(cookieNoticeText); | ||
cookieNotice.append(cookieNoticeButton); | ||
|
||
document.body.append(cookieNotice); | ||
} | ||
} | ||
|
Binary file not shown.
Binary file not shown.
Empty file.