Newer
Older
<?php
/**
* This file contains QUI\Menu\MegaMenu
*/
namespace QUI\Menu;
use QUI;
/**
* Class MegaMenu
*
* @package QUI\Menu
*/
/**
* @var SlideOut
*/
protected $Mobile;
/**
* @param array $attributes
*/
public function __construct($attributes = array())
{
$this->setAttributes(array(
'showStart' => false,
'Start' => false,
'data-qui' => 'package/quiqqer/menu/bin/MegaMenu',
'display' => 'Standard'
));
parent::__construct($attributes);
$this->addCSSClass('quiqqer-menu-megaMenu');
$this->addCSSFile(dirname(__FILE__) . '/MegaMenu.css');
$this->Mobile = new QUI\Menu\SlideOut();
// defaults
$this->Mobile->setAttribute('Project', $this->getProject());
$this->Mobile->setAttribute('Site', $this->getSite());
$this->Mobile->setAttribute('data-menu-right', 10);
$this->Mobile->setAttribute('data-menu-top', 15);
$this->Mobile->setAttribute('data-show-button-on-desktop', 0);
$this->Mobile->setAttribute('data-qui-options-menu-width', 400);
$this->Mobile->setAttribute('data-qui-options-menu-button', 0);
$this->Mobile->setAttribute('data-qui-options-touch', 0);
$this->Mobile->setAttribute('data-qui-options-buttonids', 'mobileMenu');
}
/**
* @return string
* @throws QUI\Exception
*/
public function getBody()
{
$Engine = QUI::getTemplateManager()->getEngine();
$childControl = $this->getMenuControl($this->getAttribute('display'));

Henning Leutz
committed
$this->Mobile->setAttribute('Project', $this->getProject());
$this->Mobile->setAttribute('Site', $this->getSite());
$this->Mobile->setAttribute('data-menu-right', 10);
$this->Mobile->setAttribute('data-menu-top', 15);
$this->Mobile->setAttribute('data-show-button-on-desktop', 0);
$this->Mobile->setAttribute('data-qui-options-menu-width', 400);
$this->Mobile->setAttribute('data-qui-options-menu-button', 0);
$this->Mobile->setAttribute('data-qui-options-touch', 0);
$this->Mobile->setAttribute('data-qui-options-buttonids', 'mobileMenu');

Henning Leutz
committed
'this' => $this,
'Site' => $this->getSite(),
'Project' => $this->getProject(),

Henning Leutz
committed
'Start' => $this->getStart(),
'children' => $this->getStart()->getNavigation(),
'Rewrite' => QUI::getRewrite(),
'jsControl' => 'package/quiqqer/menu/bin/MegaMenu',
'prepend' => $this->prepend,
'append' => $this->append,
'childControl' => $childControl
));
return $Engine->fetch(dirname(__FILE__) . '/MegaMenu.html');
}
/**
* @return QUI\Projects\Site
*/
public function getStart()
{
if ($this->getAttribute('Start')) {
return $this->getAttribute('Start');
}
return $this->getProject()->firstChild();
}
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
/**
* Return the menu control class name for a menu control shortcut
*
* @param $control
* @return mixed
*/
public function getMenuControl($control)
{
switch ($control) {
case 'Image':
case QUI\Menu\Mega\Image::class:
return QUI\Menu\Mega\Image::class;
case 'Icons':
case QUI\Menu\Mega\Icons::class:
return QUI\Menu\Mega\Icons::class;
case 'IconsDescription':
case QUI\Menu\Mega\IconsDescription::class:
return QUI\Menu\Mega\IconsDescription::class;
case 'Standard':
case QUI\Menu\Mega\Standard::class:
return QUI\Menu\Mega\Standard::class;
}
if ($this->getAttribute('display')) {
switch ($this->getAttribute('display')) {
case 'Image':
case QUI\Menu\Mega\Image::class:
return QUI\Menu\Mega\Image::class;
case 'Icons':
case QUI\Menu\Mega\Icons::class:
return QUI\Menu\Mega\Icons::class;
case 'IconsDescription':
case QUI\Menu\Mega\IconsDescription::class:
return QUI\Menu\Mega\IconsDescription::class;
case 'Standard':
case QUI\Menu\Mega\Standard::class:
return QUI\Menu\Mega\Standard::class;
}
}
return QUI\Menu\Mega\Standard::class;
}
/**
* Return the current site
*
* @return mixed|QUI\Projects\Site
*/
protected function getSite()
{
if ($this->getAttribute('Site')) {
return $this->getAttribute('Site');
}
return QUI::getRewrite()->getSite();
}
}