Skip to content

Commit

Permalink
Merge pull request #126 from aeberhard/CSSJS-Optimierung
Browse files Browse the repository at this point in the history
Cssjs optimierung
  • Loading branch information
IngoWinter authored Jan 27, 2021
2 parents 397c6d3 + b4a59ea commit 6968a2a
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 63 deletions.
14 changes: 13 additions & 1 deletion boot.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,17 @@
<?php
rex_perm::register('consent_manager[texteditonly]');
if (rex::isBackend() && rex::getUser()) {
if (!rex::getUser()->isAdmin() && rex::getUser()->hasPerm('consent_manager[texteditonly]')) {
$page = $this->getProperty('page');
if ($page) {
foreach (['cookiegroup', 'cookie', 'domain', 'config', 'setup', 'help'] as $removepage) {
unset($page['subpages'][$removepage]);
}
$this->setProperty('page', $page);
}
}
}

rex_extension::register('PACKAGES_INCLUDED', function () {
if (rex::getUser())
{
Expand All @@ -21,7 +34,6 @@
{
rex_view::addCssFile($this->getAssetsUrl('consent_manager_backend.css'));
}

}
});

Expand Down
62 changes: 33 additions & 29 deletions fragments/consent_manager_box.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,18 @@
<div class="consent_manager-cookiegroups">
<?php
foreach ($consent_manager->cookiegroups as $cookiegroup) {
if ($cookiegroup['required']) {
echo '<div class="consent_manager-cookiegroup-checkbox">';
echo '<label for="'.$cookiegroup['uid'].'"><input type="checkbox" disabled="disabled" data-action="toggle-cookie" id="'.$cookiegroup['uid'].'" data-uid="'.$cookiegroup['uid'].'" data-cookie-uids=\''.json_encode($cookiegroup['cookie_uids']).'\' checked>';
echo '<span>'.$cookiegroup['name'].'</span></label>';
echo '</div>' . PHP_EOL;
} else {
echo '<div class="consent_manager-cookiegroup-checkbox">';
echo '<label for="'.$cookiegroup['uid'].'"><input type="checkbox" id="'.$cookiegroup['uid'].'" data-uid="'.$cookiegroup['uid'].'" data-cookie-uids=\''.json_encode($cookiegroup['cookie_uids']).'\'>';
echo '<span>'.$cookiegroup['name'].'</span></label>';
echo '</div>' . PHP_EOL;
if (count($cookiegroup['cookie_uids']) >= 1) {
if ($cookiegroup['required']) {
echo '<div class="consent_manager-cookiegroup-checkbox">';
echo '<label for="'.$cookiegroup['uid'].'"><input type="checkbox" disabled="disabled" data-action="toggle-cookie" id="'.$cookiegroup['uid'].'" data-uid="'.$cookiegroup['uid'].'" data-cookie-uids=\''.json_encode($cookiegroup['cookie_uids']).'\' checked>';
echo '<span>'.$cookiegroup['name'].'</span></label>';
echo '</div>' . PHP_EOL;
} else {
echo '<div class="consent_manager-cookiegroup-checkbox">';
echo '<label for="'.$cookiegroup['uid'].'"><input type="checkbox" id="'.$cookiegroup['uid'].'" data-uid="'.$cookiegroup['uid'].'" data-cookie-uids=\''.json_encode($cookiegroup['cookie_uids']).'\'>';
echo '<span>'.$cookiegroup['name'].'</span></label>';
echo '</div>' . PHP_EOL;
}
}
}
?>
Expand All @@ -33,28 +35,30 @@
<div class="consent_manager-detail consent_manager-hidden" id="consent_manager-detail">
<?php
foreach ($consent_manager->cookiegroups as $cookiegroup) {
echo '<div class="consent_manager-cookiegroup-title consent_manager-headline">';
echo $cookiegroup['name'].' <span>('.count($cookiegroup['cookie_uids']).')</span>';
echo '</div>';
echo '<div class="consent_manager-cookiegroup-description">';
echo $cookiegroup['description'];
echo '</div>';
echo '<div class="consent_manager-cookiegroup">';
foreach ($cookiegroup['cookie_uids'] as $cookieUid) {
$cookie = $consent_manager->cookies[$cookieUid];
if (isset($cookie['definition'])) {
foreach ($cookie['definition'] as $def) {
echo '<div class="consent_manager-cookie">';
echo '<span class="consent_manager-cookie-name"><strong>'.$def['cookie_name'].'</strong> ('.$cookie['service_name'].')</span>';
echo '<span class="consent_manager-cookie-description">'.$def['description'].'</span>';
echo '<span class="consent_manager-cookie-description">'.$consent_manager->texts['lifetime'].' '.$def['cookie_lifetime'].'</span>';
echo '<span class="consent_manager-cookie-provider">'.$consent_manager->texts['provider'].' '.$cookie['provider'].'</span>';
echo '<span class="consent_manager-cookie-link-privacy-policy"><a href="'.$cookie['provider_link_privacy'].'">'.$consent_manager->texts['link_privacy'].'</a></span>';
echo '</div>' . PHP_EOL;
if (count($cookiegroup['cookie_uids']) >= 1) {
echo '<div class="consent_manager-cookiegroup-title consent_manager-headline">';
echo $cookiegroup['name'].' <span>('.count($cookiegroup['cookie_uids']).')</span>';
echo '</div>';
echo '<div class="consent_manager-cookiegroup-description">';
echo $cookiegroup['description'];
echo '</div>';
echo '<div class="consent_manager-cookiegroup">';
foreach ($cookiegroup['cookie_uids'] as $cookieUid) {
$cookie = $consent_manager->cookies[$cookieUid];
if (isset($cookie['definition'])) {
foreach ($cookie['definition'] as $def) {
echo '<div class="consent_manager-cookie">';
echo '<span class="consent_manager-cookie-name"><strong>'.$def['cookie_name'].'</strong> ('.$cookie['service_name'].')</span>';
echo '<span class="consent_manager-cookie-description">'.$def['description'].'</span>';
echo '<span class="consent_manager-cookie-description">'.$consent_manager->texts['lifetime'].' '.$def['cookie_lifetime'].'</span>';
echo '<span class="consent_manager-cookie-provider">'.$consent_manager->texts['provider'].' '.$cookie['provider'].'</span>';
echo '<span class="consent_manager-cookie-link-privacy-policy"><a href="'.$cookie['provider_link_privacy'].'">'.$consent_manager->texts['link_privacy'].'</a></span>';
echo '</div>' . PHP_EOL;
}
}
}
echo '</div>';
}
echo '</div>';
}
?>
</div>
Expand Down
68 changes: 35 additions & 33 deletions fragments/consent_manager_cookiedb.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
FROM '.rex::getTable('consent_manager_consent_log').'
WHERE '.rex::getTable('consent_manager_consent_log').'.cachelogid = :cachelogid
ORDER BY '.rex::getTable('consent_manager_consent_log').'.id DESC
LIMIT 5'
LIMIT 5'
,['cachelogid'=>$consent_manager_cookie['cachelogid']]
);
$history = $db->getArray();
Expand All @@ -46,7 +46,7 @@
<th class="consent_manager-history-id">'.$consent_manager->texts['consent_id'].'</th>
<th class="consent_manager-history-consents">'.$consent_manager->texts['consent_consents'].'</th>
</tr>';
foreach ($history as $historyentry) {
foreach ($history as $historyentry) {
$consents = json_decode($historyentry['consents']);
//$consents_uids_output = implode(', ', $consents);
$consents_service_names = array();
Expand All @@ -69,35 +69,37 @@
$output .= '<h2>'.$consent_manager->texts['headline_mayusedcookies'].'</h2>';

foreach ($consent_manager->cookiegroups as $cookiegroup) {
$output .= '<div class="consent_manager-cookiegroup-title consent_manager-headline">';
$output .= $cookiegroup['name'].' <span>('.count($cookiegroup['cookie_uids']).')</span>';
$output .= '</div>';
$output .= '<div class="consent_manager-cookiegroup-description">';
$output .= $cookiegroup['description'];
$output .= '</div>';
$output .= '<div class="consent_manager-cookiegroup">';
$output .= '<table class="consent_manager-cookietable">';
$output .= '<tr>
<th class="consent_manager-cookie-name">'.$consent_manager->texts['cookiename'].'</th>
<th class="consent_manager-cookie-provider">'.$consent_manager->texts['provider'].'</th>
<th class="consent_manager-cookie-description">'.$consent_manager->texts['usage'].'</th>
<th class="consent_manager-cookie-lifetime">'.$consent_manager->texts['lifetime'].'</th>
<th class="consent_manager-cookie-service">'.$consent_manager->texts['service'].'</th>
</tr>';
foreach ($cookiegroup['cookie_uids'] as $cookieUid) {
$cookie = $consent_manager->cookies[$cookieUid];
foreach ($cookie['definition'] as $def) {
$output .= '<tr>';
$output .= '<td class="consent_manager-cookie-name">'.$def['cookie_name'].'</td>';
$output .= '<td class="consent_manager-cookie-provider"><a href="'.$cookie['provider_link_privacy'].'">'.$cookie['provider'].'</a></td>';
$output .= '<td class="consent_manager-cookie-description">'.$def['description'].'</td>';
$output .= '<td class="consent_manager-cookie-lifetime">'.$def['cookie_lifetime'].'</td>';
$output .= '<td class="consent_manager-cookie-service">'.$cookie['service_name'].'</td>';
$output .= '</tr>';
}
}
$output .= '</table>';
$output .= '</div>';
if (count($cookiegroup['cookie_uids']) >= 1) {
$output .= '<div class="consent_manager-cookiegroup-title consent_manager-headline">';
$output .= $cookiegroup['name'].' <span>('.count($cookiegroup['cookie_uids']).')</span>';
$output .= '</div>';
$output .= '<div class="consent_manager-cookiegroup-description">';
$output .= $cookiegroup['description'];
$output .= '</div>';
$output .= '<div class="consent_manager-cookiegroup">';
$output .= '<table class="consent_manager-cookietable">';
$output .= '<tr>
<th class="consent_manager-cookie-name">'.$consent_manager->texts['cookiename'].'</th>
<th class="consent_manager-cookie-provider">'.$consent_manager->texts['provider'].'</th>
<th class="consent_manager-cookie-description">'.$consent_manager->texts['usage'].'</th>
<th class="consent_manager-cookie-lifetime">'.$consent_manager->texts['lifetime'].'</th>
<th class="consent_manager-cookie-service">'.$consent_manager->texts['service'].'</th>
</tr>';
foreach ($cookiegroup['cookie_uids'] as $cookieUid) {
$cookie = $consent_manager->cookies[$cookieUid];
foreach ($cookie['definition'] as $def) {
$output .= '<tr>';
$output .= '<td class="consent_manager-cookie-name">'.$def['cookie_name'].'</td>';
$output .= '<td class="consent_manager-cookie-provider"><a href="'.$cookie['provider_link_privacy'].'">'.$cookie['provider'].'</a></td>';
$output .= '<td class="consent_manager-cookie-description">'.$def['description'].'</td>';
$output .= '<td class="consent_manager-cookie-lifetime">'.$def['cookie_lifetime'].'</td>';
$output .= '<td class="consent_manager-cookie-service">'.$cookie['service_name'].'</td>';
$output .= '</tr>';
}
}
$output .= '</table>';
$output .= '</div>';
}
}

// Cookies actually used
Expand All @@ -107,11 +109,11 @@

foreach ($consent_manager->cookies as $cookies) {
foreach ($cookies['definition'] as $def) {
$cookiedb[$def['cookie_name']] = array(
$cookiedb[$def['cookie_name']] = array(
"service_name"=>$cookies['service_name'],
"provider"=>$cookies['provider'],
"lifetime"=>$def['cookie_lifetime'],
"description"=>$def['description']
"description"=>$def['description']
);
}
}
Expand Down

0 comments on commit 6968a2a

Please sign in to comment.