Skip to content

Commit

Permalink
Add cookie consent
Browse files Browse the repository at this point in the history
  • Loading branch information
kveldscholten committed Feb 9, 2016
1 parent 99aa855 commit e48316a
Show file tree
Hide file tree
Showing 11 changed files with 278 additions and 14 deletions.
31 changes: 30 additions & 1 deletion application/libraries/Ilch/Layout/Frontend.php
Expand Up @@ -67,6 +67,22 @@ public function getDescription()
return '';
}

/**
* Get key from config.
*
* @return string
*/
public function getConfigKey($key)
{
$config = \Ilch\Registry::get('config');

if (!empty($config) && $key !== '') {
return $config->get($key);
}

return '';
}

/**
* Gets the box with the given key.
*
Expand Down Expand Up @@ -118,9 +134,22 @@ public function getHeader()
<script type="text/javascript" src="'.$this->getStaticUrl('js/jquery.mjs.nestedSortable.js').'"></script>
<script type="text/javascript" src="'.$this->getStaticUrl('../application/modules/admin/static/js/functions.js').'"></script>';

if ($this->getConfigKey('cookie_consent') != 0) {
$html .= '<script type="text/javascript">
window.cookieconsent_options = {
message: "'.$this->escape($this->getConfigKey('cookie_consent_message')).'",
dismiss: "OK",
learnMore: "Weitere Informationen",
link: "'.$this->getUrl(array('module' => 'cookieconsent', 'controller' => 'index', 'action' => 'index')).'",
theme: "'.$this->escape($this->getConfigKey('cookie_consent_style')).'-'.$this->escape($this->getConfigKey('cookie_consent_pos')).'"
};
</script>
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/cookieconsent2/1.0.9/cookieconsent.min.js"></script>';
}

return $html;
}

/**
* Loads a layout file.
*
Expand Down
2 changes: 1 addition & 1 deletion application/modules/admin/static/css/admin.css
Expand Up @@ -541,7 +541,7 @@ legend {
position: static !important;
}
#ilch_dropdown .full {
width: 100%;
width: 110%;
left: auto !important;
right: auto !important;
}
Expand Down
62 changes: 62 additions & 0 deletions application/modules/cookieconsent/config/config.php
@@ -0,0 +1,62 @@
<?php
/**
* @copyright Ilch 2.0
* @package ilch
*/

namespace Modules\Cookieconsent\Config;

class Config extends \Ilch\Config\Install
{
public $config = array
(
'key' => 'cookieconsent',
'icon_small' => 'cookieconsent.png',
'system_module' => true,
'languages' => array
(
'de_DE' => array
(
'name' => 'Cookie-Richtlinien',
'description' => 'Hier können die Cookie-Richtlinien verwaltet werden.',
),
'en_EN' => array
(
'name' => 'Cookie Consent',
'description' => 'Here you can manage the cookie consent.',
),
)
);

public function install()
{
$databaseConfig = new \Ilch\Config\Database($this->db());
$databaseConfig->set('cookie_consent', '0');
$databaseConfig->set('cookie_consent_style', 'light');
$databaseConfig->set('cookie_consent_pos', 'top');
$databaseConfig->set('cookie_consent_message', 'Diese Website nutzt Cookies, um bestmögliche Funktionalität bieten zu können.');
$databaseConfig->set('cookie_consent_text', '<h3>Einsatz von Cookies</h3>
<p>Wie viele Internetseiten nutzt auch diese Seite Cookies. An dieser Stelle wird erklärt was Cookies sind und wie sie genutzt werden.</p>
<p>&nbsp;</p>
<h4>Was sind Cookies</h4>
<p>Cookies sind kleine Dateien, die beim Aufruf von Internetseiten durch den Internet Browser auf Ihrem lokalen Rechner gespeichert werden. In den Dateien speichern Internetseiten verschiedene Informationen, um die Nutzung von besuchten Internetseiten für Sie komfortabler zu gestalten. Oftmals wird in Cookies z.B. Ihr Login gespeichert, um Sie bei einem späteren Besuch der Internetseite automatisch anzumelden, ohne dass Sie Ihre Zugangsdaten noch einmal manuell eingeben müssen.</p>
<p>&nbsp;</p>
<h4>Wie wir Cookies nutzen</h4>
<p>Wir setzen Cookies für folgende Zwecke ein:</p>
<ul>
<li>Anmeldung: Bei der Anmeldung werden Ihre Zugangsdaten in verschlüsselter Form als Cookies gespeichert, um Sie bei einem späteren Seitenaufruf automatisiert anzumelden. Im Anmeldefenster können Sie mit der Option „Dauerhaft angemeldet bleiben“ festlegen, ob diese Cookies angelegt werden sollen.</li>
<li>Sitzung: Beim ersten Aufruf unserer Seite wird eine neue Sitzung gestartet, diese wird durch ein eindeutiges Cookies Ihrem Computer zugeordnet. Sitzungen erlauben es, Sie zwischen zwei Seitenaufrufen wieder zu erkennen und Ihnen alle Funktionalitäten bereitstellen zu können. Es handelt sich um ein temporäres Cookies, dass beim Beenden des Internet Browsers automatisch gelöscht wird.</li>
<li>Drittanbieter-Dienste: Die Einblendung von Werbeanzeigen oder das Teilen von Inhalten auf sozialen Netzwerken oder vergleichbaren Internetseiten kann die Erzeugung eines Cookies zur Folge haben. Diese Cookies werden nicht direkt von unserer Seite erzeugt, sondern durch den Drittanbieter selbst.</li>
</ul>
<p>&nbsp;</p>
<h4>Wie Sie Cookies deaktivieren und entfernen</h4>
<p>Cookies können in den Einstellungen Ihres Internet Browsers verwaltet und entfernt werden. Darüber hinaus lässt sich in den Einstellungen das Speichern von Cookies zudem vollständig deaktivieren. Bitte entnehmen Sie der folgenden Auflistung die passende Anleitung für den Umgang mit Cookies zu dem von Ihnen genutzten Internet Browser.</p>
<ul>
<li><a href="https://support.google.com/chrome/answer/95647?hl=de" target="_blank">Google Chrome</a></li>
<li><a href="https://support.mozilla.org/de/kb/cookies-informationen-websites-auf-ihrem-computer" target="_blank">Mozilla Firefox</a></li>
<li><a href="http://help.opera.com/Windows/12.00/de/cookies.html" target="_blank">Opera</a></li>
<li><a href="https://support.apple.com/kb/ph17191?locale=de_DE" target="_blank">Safari</a></li>
<li><a href="http://windows.microsoft.com/de-DE/internet-explorer/delete-manage-cookies" target="_blank">Windows Internet Explorer</a></li>
</ul>');
}
}
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 20 additions & 0 deletions application/modules/cookieconsent/controllers/Index.php
@@ -0,0 +1,20 @@
<?php
/**
* @copyright Ilch 2.0
* @package ilch
*/

namespace Modules\Cookieconsent\Controllers;

class Index extends \Ilch\Controller\Frontend
{
public function indexAction()
{
$this->getLayout()->getHmenu()->add($this->getTranslator()->trans('menuCookieConsent'), array('action' => 'index'));

$this->getView()->set('cookieConsent', $this->getConfig()->get('cookie_consent'));
$this->getView()->set('cookieConsentText', $this->getConfig()->get('cookie_consent_text'));
}
}


51 changes: 51 additions & 0 deletions application/modules/cookieconsent/controllers/admin/Index.php
@@ -0,0 +1,51 @@
<?php
/**
* @copyright Ilch 2.0
* @package ilch
*/

namespace Modules\Cookieconsent\Controllers\Admin;

class Index extends \Ilch\Controller\Admin
{
public function init()
{
$this->getLayout()->addMenu
(
'menuCookieConsent',
array
(
array
(
'name' => 'settings',
'active' => true,
'icon' => 'fa fa-cogs',
'url' => $this->getLayout()->getUrl(array('controller' => 'index', 'action' => 'index'))
)
)
);
}

public function indexAction()
{
$this->getLayout()->getAdminHmenu()
->add($this->getTranslator()->trans('menuCookieConsent'), array('action' => 'index'))
->add($this->getTranslator()->trans('settings'), array('action' => 'index'));

if ($this->getRequest()->isPost()) {
$this->getConfig()->set('cookie_consent', $this->getRequest()->getPost('cookieConsent'));
$this->getConfig()->set('cookie_consent_style', $this->getRequest()->getPost('cookieConsentStyle'));
$this->getConfig()->set('cookie_consent_pos', $this->getRequest()->getPost('cookieConsentPos'));
$this->getConfig()->set('cookie_consent_message', $this->getRequest()->getPost('cookieConsentMessage'));
$this->getConfig()->set('cookie_consent_text', $this->getRequest()->getPost('cookieConsentText'));
$this->addMessage('saveSuccess');
}

$this->getView()->set('cookieConsent', $this->getConfig()->get('cookie_consent'));
$this->getView()->set('cookieConsentStyle', $this->getConfig()->get('cookie_consent_style'));
$this->getView()->set('cookieConsentPos', $this->getConfig()->get('cookie_consent_pos'));
$this->getView()->set('cookieConsentMessage', $this->getConfig()->get('cookie_consent_message'));
$this->getView()->set('cookieConsentText', $this->getConfig()->get('cookie_consent_text'));

}
}
20 changes: 20 additions & 0 deletions application/modules/cookieconsent/translations/de.php
@@ -0,0 +1,20 @@
<?php
/**
* @copyright Ilch 2.0
* @package ilch
*/

return array
(
'menuCookieConsent' => 'Cookie-Richtlinien',
'cookieConsentShow' => 'Anzeigen',
'cookieConsentStyle' => 'Style',
'cookieConsentStyleDark' => 'Dunkel',
'cookieConsentStyleLight' => 'Hell',
'cookieConsentPos' => 'Position',
'cookieConsentPosTop' => 'am Seitenanfang',
'cookieConsentPosFloating' => 'unten Rechts',
'cookieConsentPosBottom' => 'am Seitenende',
'cookieConsentMessage' => 'Benachrichtigungstext',
'cookieConsentText' => 'Richtlinien-Text',
);
14 changes: 14 additions & 0 deletions application/modules/cookieconsent/translations/en.php
@@ -0,0 +1,14 @@
<?php
/**
* @copyright Ilch 2.0
* @package ilch
*/

return array
(
'menuCookieConsent' => 'Cookie Consent',
'cookieConsentShow' => 'Show',
'cookieConsentPos' => 'Position',
'cookieConsentMessage' => 'Notification text',
'cookieConsentText' => 'Consent Text',
);
65 changes: 65 additions & 0 deletions application/modules/cookieconsent/views/admin/index/index.php
@@ -0,0 +1,65 @@
<legend><?=$this->getTrans('settings') ?></legend>
<form class="form-horizontal" method="POST" action="">
<?=$this->getTokenField() ?>
<div class="form-group">
<label for="cookieConsent" class="col-lg-2 control-label">
<?=$this->getTrans('cookieConsentShow') ?>:
</label>
<div class="col-lg-2">
<div class="flipswitch">
<input type="radio" class="flipswitch-input" name="cookieConsent" value="1" id="cookie-consent-yes" <?php if ($this->get('cookieConsent') == '1') { echo 'checked="checked"'; } ?> />
<label for="cookie-consent-yes" class="flipswitch-label flipswitch-label-on"><?=$this->getTrans('yes') ?></label>
<input type="radio" class="flipswitch-input" name="cookieConsent" value="0" id="cookie-consent-no" <?php if ($this->get('cookieConsent') == '0') { echo 'checked="checked"'; } ?> />
<label for="cookie-consent-no" class="flipswitch-label flipswitch-label-off"><?=$this->getTrans('no') ?></label>
<span class="flipswitch-selection"></span>
</div>
</div>
</div>
<div class="form-group">
<label for="cookieConsentStyle" class="col-lg-2 control-label">
<?=$this->getTrans('cookieConsentStyle') ?>:
</label>
<div class="col-lg-2">
<select class="form-control" name="cookieConsentStyle">
<option <?php if ($this->get('cookieConsentStyle') == 'dark') { echo 'selected="selected"'; } ?> value="dark"><?=$this->getTrans('cookieConsentStyleDark') ?></option>
<option <?php if ($this->get('cookieConsentStyle') == 'light') { echo 'selected="selected"'; } ?> value="light"><?=$this->getTrans('cookieConsentStyleLight') ?></option>
</select>
</div>
</div>
<div class="form-group">
<label for="cookieConsentPos" class="col-lg-2 control-label">
<?=$this->getTrans('cookieConsentPos') ?>:
</label>
<div class="col-lg-2">
<select class="form-control" name="cookieConsentPos">
<option <?php if ($this->get('cookieConsentPos') == 'top') { echo 'selected="selected"'; } ?> value="top"><?=$this->getTrans('cookieConsentPosTop') ?></option>
<option <?php if ($this->get('cookieConsentPos') == 'floating') { echo 'selected="selected"'; } ?> value="floating"><?=$this->getTrans('cookieConsentPosFloating') ?></option>
<option <?php if ($this->get('cookieConsentPos') == 'bottom') { echo 'selected="selected"'; } ?> value="bottom"><?=$this->getTrans('cookieConsentPosBottom') ?></option>
</select>
</div>
</div>
<div class="form-group">
<label for="cookieConsentMessage" class="col-lg-2 control-label">
<?=$this->getTrans('cookieConsentMessage') ?>:
</label>
<div class="col-lg-6">
<input class="form-control"
name="cookieConsentMessage"
type="text"
value="<?=$this->escape($this->get('cookieConsentMessage')) ?>" />
</div>
</div>
<div class="form-group">
<label for="cookieConsentText" class="col-lg-2 control-label">
<?=$this->getTrans('cookieConsentText') ?>:
</label>
<div class="col-lg-10">
<textarea class="form-control ckeditor"
name="cookieConsentText"
id="ck_1"
toolbar="ilch_html"
rows="5"><?=$this->escape($this->get('cookieConsentText')) ?></textarea>
</div>
</div>
<?=$this->getSaveBar() ?>
</form>
2 changes: 2 additions & 0 deletions application/modules/cookieconsent/views/index/index.php
@@ -0,0 +1,2 @@
<legend><?=$this->getTrans('menuCookieConsent') ?></legend>
<?=$this->get('cookieConsentText') ?>
25 changes: 13 additions & 12 deletions application/modules/install/controllers/Index.php
Expand Up @@ -230,9 +230,9 @@ public function configAction()

$modulesToInstall = $_SESSION['install']['modulesToInstall'][$_SESSION['install']['usage']];
if (!empty($modulesToInstall)) {
$modulesToInstall = array_merge(array('admin', 'article', 'user', 'page', 'media', 'comment', 'imprint', 'contact', 'privacy', 'statistic'), $modulesToInstall);
$modulesToInstall = array_merge(array('admin', 'article', 'user', 'page', 'media', 'comment', 'imprint', 'contact', 'privacy', 'statistic', 'cookieconsent'), $modulesToInstall);
} else {
$modulesToInstall = array('admin', 'article', 'user', 'page', 'media', 'comment', 'imprint', 'contact', 'privacy', 'statistic');
$modulesToInstall = array('admin', 'article', 'user', 'page', 'media', 'comment', 'imprint', 'contact', 'privacy', 'statistic', 'cookieconsent');
}

$moduleMapper = new \Modules\Admin\Mappers\Module();
Expand Down Expand Up @@ -293,7 +293,7 @@ public function configAction()
* Will not linked in menu
*/
foreach ($modulesToInstall as $module) {
if (in_array($module, array('comment', 'shoutbox', 'admin', 'media', 'page', 'newsletter', 'statistic'))) {
if (in_array($module, array('comment', 'shoutbox', 'admin', 'media', 'page', 'newsletter', 'statistic', 'cookieconsent'))) {
continue;
}

Expand Down Expand Up @@ -345,15 +345,16 @@ public function ajaxconfigAction()
/*
* System-Modules
*/
$modules['user']['types'] = array();
$modules['article']['types'] = array();
$modules['page']['types'] = array();
$modules['media']['types'] = array();
$modules['comment']['types'] = array();
$modules['contact']['types'] = array();
$modules['imprint']['types'] = array();
$modules['privacy']['types'] = array();
$modules['statistic']['types'] = array();
$modules['user']['types'] = array();
$modules['article']['types'] = array();
$modules['page']['types'] = array();
$modules['media']['types'] = array();
$modules['comment']['types'] = array();
$modules['contact']['types'] = array();
$modules['imprint']['types'] = array();
$modules['privacy']['types'] = array();
$modules['cookieconsent']['types'] = array();
$modules['statistic']['types'] = array();

/*
* Optional-Modules.
Expand Down

0 comments on commit e48316a

Please sign in to comment.