Skip to content
Code-Schnipsel Gruppen Projekte
Commit 7946f307 erstellt von Michael Danielczok's avatar Michael Danielczok
Dateien durchsuchen

Merge branch 'dev'

Übergeordnete 4cf90225 6fddf6a2
Keine zugehörigen Branchen gefunden
Keine zugehörigen Tags gefunden
2 Merge Requests!19Dev,!18Feat menu manager improvement
<?xml version="1.0" encoding="UTF-8"?>
<events>
<event on="onSiteSave" fire="\QUI\Menu\EventHandler::onSiteSave"/>
</events>
......@@ -20,7 +20,7 @@ class DropDownMenu extends QUI\Control
/**
* @param array $attributes
*/
public function __construct($attributes = array())
public function __construct($attributes = [])
{
$this->setAttribute('class', 'qui-menu-dropdown');
$this->setAttribute('qui-class', 'package/quiqqer/menu/bin/DropDownMenu');
......@@ -28,7 +28,7 @@ public function __construct($attributes = array())
parent::__construct($attributes);
$this->addCSSFile(dirname(__FILE__) . '/DropDownMenu.css');
$this->addCSSFile(\dirname(__FILE__).'/DropDownMenu.css');
}
/**
......@@ -39,16 +39,32 @@ public function __construct($attributes = array())
*/
public function getBody()
{
$cache = EventHandler::menuCacheName().'/dropDownMenu/';
$cache .= \md5(
$this->getSite()->getCachePath().
\serialize($this->getAttributes())
);
try {
return QUI\Cache\Manager::get($cache);
} catch (QUI\Exception $Exception) {
}
$Engine = QUI::getTemplateManager()->getEngine();
$Engine->assign(array(
$Engine->assign([
'this' => $this,
'Site' => $this->getSite(),
'Project' => $this->getProject(),
'FileMenu' => dirname(__FILE__) . '/DropDownMenu.Children.html'
));
'FileMenu' => \dirname(__FILE__).'/DropDownMenu.Children.html'
]);
$result = $Engine->fetch(\dirname(__FILE__).'/DropDownMenu.html');
QUI\Cache\Manager::set($cache, $result);
return $Engine->fetch(dirname(__FILE__) . '/DropDownMenu.html');
return $result;
}
/**
......
<?php
namespace QUI\Menu;
use QUI;
use QUI\Interfaces\Projects\Site;
/**
* Class EventHandler
*
* @package QUI\Menu
*/
class EventHandler
{
/**
* @return string
*/
public static function menuCacheName()
{
return 'quiqqer/package/menu';
}
/**
* @param Site $Site
*/
public static function onSiteSave(Site $Site)
{
QUI\Cache\Manager::clear(self::menuCacheName());
}
}
......@@ -3,6 +3,7 @@
/**
* This file contains QUI\Menu\MegaMenu
*/
namespace QUI\Menu;
use QUI;
......@@ -22,7 +23,7 @@ class MegaMenu extends AbstractMenu
/**
* @param array $attributes
*/
public function __construct($attributes = array())
public function __construct($attributes = [])
{
$this->setAttributes([
'showStart' => false,
......@@ -35,7 +36,7 @@ public function __construct($attributes = array())
parent::__construct($attributes);
$this->addCSSClass('quiqqer-menu-megaMenu');
$this->addCSSFile(dirname(__FILE__) . '/MegaMenu.css');
$this->addCSSFile(dirname(__FILE__).'/MegaMenu.css');
if (!$this->getAttribute('enableMobile')) {
return;
......@@ -62,9 +63,22 @@ public function __construct($attributes = array())
*/
public function getBody()
{
$Engine = QUI::getTemplateManager()->getEngine();
$cache = EventHandler::menuCacheName().'/megaMenu/';
$cache .= \md5(
$this->getSite()->getCachePath().
\serialize($this->getAttributes())
);
$childControl = $this->getMenuControl($this->getAttribute('display'));
try {
return QUI\Cache\Manager::get($cache);
} catch (QUI\Exception $Exception) {
}
$Engine = QUI::getTemplateManager()->getEngine();
if ($this->Mobile) {
$this->Mobile->setAttribute('Project', $this->getProject());
$this->Mobile->setAttribute('Site', $this->getSite());
......@@ -80,7 +94,7 @@ public function getBody()
$this->setAttribute('data-qui-options-enablemobile', $this->getAttribute('enableMobile'));
$Engine->assign(array(
$Engine->assign([
'this' => $this,
'Site' => $this->getSite(),
'Project' => $this->getProject(),
......@@ -93,13 +107,17 @@ public function getBody()
'append' => $this->append,
'childControl' => $childControl,
'showMenu' => true
));
]);
if ($this->getProject()->getConfig('menu.settings.type') == 'noMenu') {
$Engine->assign('showMenu', false);
}
return $Engine->fetch(dirname(__FILE__) . '/MegaMenu.html');
$result = $Engine->fetch(dirname(__FILE__).'/MegaMenu.html');
QUI\Cache\Manager::set($cache, $result);
return $result;
}
/**
......
0% Lade oder .
You are about to add 0 people to the discussion. Proceed with caution.
Bearbeitung dieser Nachricht zuerst beenden!
Bitte registrieren oder zum Kommentieren