Skip to content
Code-Schnipsel Gruppen Projekte
Commit 24714519 erstellt von Henning Leutz's avatar Henning Leutz :martial_arts_uniform:
Dateien durchsuchen

Merge branch 'next' into 'master'

Next

See merge request !17
Übergeordnete 4db0f661 00ad67cf
No related branches found
No related tags found
3 Merge Requests!19Dev,!18Feat menu manager improvement,!17Next
Pipeline #5372 bestanden mit Phase
in 37 Sekunden
werden angezeigt mit 277 Ergänzungen und 259 Löschungen
......@@ -21,15 +21,15 @@ class Anchor extends AbstractMenuItem
*/
public function getUrl(): string
{
$Site = $this->getSite();
$data = $this->getCustomData();
$Site = $this->getSite();
$data = $this->getCustomData();
$current = QUI::getLocale()->getCurrent();
if (!isset($data['url'])) {
return '';
}
$url = '';
$url = '';
$anchor = [];
if ($Site) {
......@@ -65,7 +65,7 @@ public function getSite(): ?QUI\Projects\Site
try {
$siteUrl = $data['site'];
$Site = QUI\Projects\Site\Utils::getSiteByLink($siteUrl);
$Site = QUI\Projects\Site\Utils::getSiteByLink($siteUrl);
} catch (QUI\Exception $Exception) {
return null;
}
......@@ -75,8 +75,8 @@ public function getSite(): ?QUI\Projects\Site
// if current language is another language as the site
if ($current !== $Site->getAttribute('lang')) {
try {
$Project = $Site->getProject();
$langId = $Site->getId($current);
$Project = $Site->getProject();
$langId = $Site->getId($current);
$LangProject = QUI::getProject($Project->getName(), $current);
return $LangProject->get($langId);
} catch (QUI\Exception $exception) {
......
......@@ -47,7 +47,7 @@ public function getSite(): ?QUI\Projects\Site
try {
$siteUrl = $data['site'];
$Site = QUI\Projects\Site\Utils::getSiteByLink($siteUrl);
$Site = QUI\Projects\Site\Utils::getSiteByLink($siteUrl);
} catch (QUI\Exception $Exception) {
return null;
}
......@@ -57,8 +57,8 @@ public function getSite(): ?QUI\Projects\Site
// if current language is another language as the site
if ($current !== $Site->getAttribute('lang')) {
try {
$Project = $Site->getProject();
$langId = $Site->getId($current);
$Project = $Site->getProject();
$langId = $Site->getId($current);
$LangProject = QUI::getProject($Project->getName(), $current);
return $LangProject->get($langId);
......@@ -123,7 +123,7 @@ public function getTitle(QUI\Locale $Locale = null): string
}
$siteUrl = $data['site'];
$Site = QUI\Projects\Site\Utils::getSiteByLink($siteUrl);
$Site = QUI\Projects\Site\Utils::getSiteByLink($siteUrl);
return $Site->getAttribute('title');
} catch (QUI\Exception $Exception) {
......
......@@ -20,12 +20,12 @@
*/
class Menu
{
protected int $id;
protected ?array $title = null;
protected ?array $workingTitle = null;
protected array $data = [];
protected array $children = [];
protected int $currentChildId = 0;
protected int $id;
protected ?array $title = null;
protected ?array $workingTitle = null;
protected array $data = [];
protected array $children = [];
protected int $currentChildId = 0;
/**
* @param int|array $menuId - menu id or menu data
......@@ -40,7 +40,8 @@ public function __construct($menuId)
} else {
$data = $menuId;
if (!isset($data['id'])
if (
!isset($data['id'])
|| !isset($data['title'])
|| !isset($data['workingTitle'])
) {
......@@ -155,10 +156,10 @@ public function getChildren(bool $onlyActive = true): array
public function toArray(): array
{
return [
'id' => $this->getId(),
'title' => $this->getTitle(),
'id' => $this->getId(),
'title' => $this->getTitle(),
'workingTitle' => $this->getWorkingTitle(),
'data' => $this->data
'data' => $this->data
];
}
......@@ -226,10 +227,10 @@ public function getWorkingTitle(QUI\Locale $Locale = null): string
public function getData(): array
{
return [
'id' => $this->id,
'title' => $this->title,
'id' => $this->id,
'title' => $this->title,
'workingTitle' => $this->workingTitle,
'data' => $this->data
'data' => $this->data
];
}
......@@ -248,9 +249,9 @@ public function save(?QUI\Interfaces\Users\User $PermissionUser = null)
QUI\Permissions\Permission::checkPermission('quiqqer.menu.edit', $PermissionUser);
QUI::getDataBase()->update(Handler::table(), [
'title' => json_encode($this->title),
'title' => json_encode($this->title),
'workingTitle' => json_encode($this->workingTitle),
'data' => json_encode($this->data)
'data' => json_encode($this->data)
], [
'id' => $this->getId()
]);
......@@ -385,9 +386,11 @@ protected function checkMenuDataItem(array $item): ?array
$result['icon'] = $item['icon'];
}
if (isset($item['type'])
if (
isset($item['type'])
&& class_exists($item['type'])
&& new $item['type']() instanceof AbstractMenuItem) {
&& new $item['type']() instanceof AbstractMenuItem
) {
$result['type'] = $item['type'];
}
......
......@@ -29,7 +29,7 @@ public static function menu($params, $smarty): string
return '';
}
$menuId = $params['id'];
$menuId = $params['id'];
$cacheName = Handler::getMenuCacheName($menuId, $Project);
try {
......@@ -38,7 +38,7 @@ public static function menu($params, $smarty): string
}
try {
$Menu = QUI\Menu\Independent\Handler::getMenu($params['id']);
$Menu = QUI\Menu\Independent\Handler::getMenu($params['id']);
$Control = new $params['control']($Menu);
} catch (QUI\Exception $Exception) {
QUI\System\Log::addError($Exception->getMessage());
......
......@@ -3,6 +3,7 @@
/**
* This file contains QUI\Menu\Mega\Icons
*/
namespace QUI\Menu\Mega;
use QUI;
......@@ -24,7 +25,7 @@ class Icons extends AbstractChild
*
* @param array $params
*/
public function __construct(array $params = array())
public function __construct(array $params = [])
{
parent::__construct($params);
......@@ -42,11 +43,11 @@ public function getBody()
{
$Engine = QUI::getTemplateManager()->getEngine();
$Engine->assign(array(
'this' => $this,
$Engine->assign([
'this' => $this,
'children' => $this->getChildren(),
'Site' => $this->getSite()
));
'Site' => $this->getSite()
]);
return $Engine->fetch(dirname(__FILE__) . '/Icons.html');
}
......
......@@ -3,6 +3,7 @@
/**
* This file contains QUI\Menu\Mega\IconsDescription
*/
namespace QUI\Menu\Mega;
use QUI;
......@@ -25,7 +26,7 @@ class IconsDescription extends AbstractChild
*
* @param array $params
*/
public function __construct(array $params = array())
public function __construct(array $params = [])
{
parent::__construct($params);
......@@ -43,11 +44,11 @@ public function getBody()
{
$Engine = QUI::getTemplateManager()->getEngine();
$Engine->assign(array(
'this' => $this,
$Engine->assign([
'this' => $this,
'children' => $this->getChildren(),
'Site' => $this->getSite()
));
'Site' => $this->getSite()
]);
return $Engine->fetch(dirname(__FILE__) . '/IconsDescription.html');
}
......
......@@ -3,6 +3,7 @@
/**
* This file contains QUI\Menu\Mega\Image
*/
namespace QUI\Menu\Mega;
use QUI;
......@@ -24,7 +25,7 @@ class Image extends AbstractChild
*
* @param array $params
*/
public function __construct(array $params = array())
public function __construct(array $params = [])
{
parent::__construct($params);
......@@ -42,11 +43,11 @@ public function getBody()
{
$Engine = QUI::getTemplateManager()->getEngine();
$Engine->assign(array(
'this' => $this,
$Engine->assign([
'this' => $this,
'children' => $this->getChildren(),
'Site' => $this->getSite()
));
'Site' => $this->getSite()
]);
return $Engine->fetch(dirname(__FILE__) . '/Image.html');
}
......
......@@ -35,7 +35,7 @@ public function __construct(array $params = [])
parent::__construct($params);
$this->addCSSClass('quiqqer-menu-megaMenu-children-simple');
$this->addCSSFile(dirname(__FILE__).'/Simple.css');
$this->addCSSFile(dirname(__FILE__) . '/Simple.css');
}
/**
......@@ -51,24 +51,28 @@ public function getBody()
if ($this->getAttribute('independentMenu')) {
$MenuChild = $this->getAttribute('MenuChild');
if (!$this->getAttribute('MenuChild') && !$MenuChild instanceof QUI\Menu\Independent\Items\AbstractMenuItem) {
if (
!$this->getAttribute(
'MenuChild'
) && !$MenuChild instanceof QUI\Menu\Independent\Items\AbstractMenuItem
) {
return '';
}
$Engine->assign([
'this' => $this,
'this' => $this,
'children' => $MenuChild->getChildren()
]);
$template = dirname(__FILE__).'/Simple.Independent.html';
$template = dirname(__FILE__) . '/Simple.Independent.html';
} else {
$Engine->assign([
'this' => $this,
'this' => $this,
'children' => $this->getChildren(),
'Site' => $this->getSite()
'Site' => $this->getSite()
]);
$template = dirname(__FILE__).'/Simple.html';
$template = dirname(__FILE__) . '/Simple.html';
}
return $Engine->fetch($template);
......
......@@ -3,6 +3,7 @@
/**
* This file contains QUI\Menu\Mega\Standard
*/
namespace QUI\Menu\Mega;
use QUI;
......@@ -24,7 +25,7 @@ class Standard extends AbstractChild
*
* @param array $params
*/
public function __construct(array $params = array())
public function __construct(array $params = [])
{
parent::__construct($params);
......@@ -42,11 +43,11 @@ public function getBody()
{
$Engine = QUI::getTemplateManager()->getEngine();
$Engine->assign(array(
'this' => $this,
$Engine->assign([
'this' => $this,
'children' => $this->getChildren(),
'Site' => $this->getSite()
));
'Site' => $this->getSite()
]);
return $Engine->fetch(dirname(__FILE__) . '/Standard.html');
}
......
......@@ -31,20 +31,20 @@ class MegaMenu extends AbstractMenu
public function __construct($attributes = [])
{
$this->setAttributes([
'showStart' => false,
'Start' => false,
'startText' => '', // optional: displayed text
'data-qui' => 'package/quiqqer/menu/bin/MegaMenu',
'display' => 'Standard',
'enableMobile' => true,
'menuId' => false,
'showStart' => false,
'Start' => false,
'startText' => '', // optional: displayed text
'data-qui' => 'package/quiqqer/menu/bin/MegaMenu',
'display' => 'Standard',
'enableMobile' => true,
'menuId' => false,
'showFirstLevelIcons' => false, // current it works only for independent menu
'showMenuDelay' => false,
'collapseSubmenu' => false,
'showLevel' => 1,
'showHomeLink' => false,
'showShortDesc' => false,
'breakPoint' => 767
'showMenuDelay' => false,
'collapseSubmenu' => false,
'showLevel' => 1,
'showHomeLink' => false,
'showShortDesc' => false,
'breakPoint' => 767
]);
if ($this->getProject()->getConfig('menu.settings.type')) {
......@@ -54,7 +54,7 @@ public function __construct($attributes = [])
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;
......@@ -89,7 +89,7 @@ public function __construct($attributes = [])
*/
public function getBody()
{
$cache = EventHandler::menuCacheName().'/megaMenu/';
$cache = EventHandler::menuCacheName() . '/megaMenu/';
$attributes = $this->getAttributes();
$attributes = \array_filter($attributes, function ($entry) {
......@@ -97,7 +97,7 @@ public function getBody()
});
$cache .= \md5(
$this->getSite()->getCachePath().
$this->getSite()->getCachePath() .
\serialize($attributes)
);
......@@ -109,9 +109,11 @@ public function getBody()
$showMenuDelay = intval($this->getProject()->getConfig('menu.settings.showMenuDelay'));
}
if ($this->getAttribute('showMenuDelay') !== '' &&
if (
$this->getAttribute('showMenuDelay') !== '' &&
$this->getAttribute('showMenuDelay') !== false &&
intval($this->getAttribute('showMenuDelay')) >= 0) {
intval($this->getAttribute('showMenuDelay')) >= 0
) {
$showMenuDelay = intval($this->getAttribute('showMenuDelay'));
}
......@@ -168,41 +170,41 @@ public function getBody()
$children = $IndependentMenu->getChildren();
$Engine->assign([
'this' => $this,
'Mobile' => $this->Mobile,
'children' => $children,
'prepend' => $this->prepend,
'append' => $this->append,
'this' => $this,
'Mobile' => $this->Mobile,
'children' => $children,
'prepend' => $this->prepend,
'append' => $this->append,
'childControl' => $childControl,
'showMenu' => true,
'breakPoint' => $breakPoint
'showMenu' => true,
'breakPoint' => $breakPoint
]);
$result = [];
$result['html'] = $Engine->fetch(dirname(__FILE__).'/MegaMenu.Independent.html');
$result = [];
$result['html'] = $Engine->fetch(dirname(__FILE__) . '/MegaMenu.Independent.html');
} else {
$Engine->assign([
'this' => $this,
'Site' => $this->getSite(),
'Project' => $this->getProject(),
'Mobile' => $this->Mobile,
'Start' => $this->getStart(),
'children' => $this->getStart()->getNavigation(),
'Rewrite' => QUI::getRewrite(),
'jsControl' => 'package/quiqqer/menu/bin/MegaMenu',
'prepend' => $this->prepend,
'append' => $this->append,
'this' => $this,
'Site' => $this->getSite(),
'Project' => $this->getProject(),
'Mobile' => $this->Mobile,
'Start' => $this->getStart(),
'children' => $this->getStart()->getNavigation(),
'Rewrite' => QUI::getRewrite(),
'jsControl' => 'package/quiqqer/menu/bin/MegaMenu',
'prepend' => $this->prepend,
'append' => $this->append,
'childControl' => $childControl,
'showMenu' => true,
'breakPoint' => $breakPoint
'showMenu' => true,
'breakPoint' => $breakPoint
]);
if ($this->getProject()->getConfig('menu.settings.type') == 'noMenu') {
$Engine->assign('showMenu', false);
}
$result = [];
$result['html'] = $Engine->fetch(dirname(__FILE__).'/MegaMenu.html');
$result = [];
$result['html'] = $Engine->fetch(dirname(__FILE__) . '/MegaMenu.html');
}
$result['subMenus'] = \array_unique($this->subMenus);
......
......@@ -33,20 +33,20 @@ class NavTabs extends QUI\Control
public function __construct($attributes = [])
{
$this->setAttributes([
'nodeName' => 'div',
'class' => 'quiqqer-menu-navTabs',
'data-qui' => 'package/quiqqer/menu/bin/Controls/NavTabs',
'nodeName' => 'div',
'class' => 'quiqqer-menu-navTabs',
'data-qui' => 'package/quiqqer/menu/bin/Controls/NavTabs',
'activeEntry' => 1, // number
'parentSite' => false, // for child sites, example: index.php?project=test&lang=de&id=1
'showShort' => false, // only if parentSite set
'max' => 10,
'entries' => [],
'template' => 'default'
'parentSite' => false, // for child sites, example: index.php?project=test&lang=de&id=1
'showShort' => false, // only if parentSite set
'max' => 10,
'entries' => [],
'template' => 'default'
]);
parent::__construct($attributes);
$this->addCSSFile(dirname(__FILE__).'/NavTabs.css');
$this->addCSSFile(dirname(__FILE__) . '/NavTabs.css');
}
/**
......@@ -69,12 +69,12 @@ public function getBody()
}
$Engine->assign([
'this' => $this,
'this' => $this,
'entries' => $this->entries,
'active' => $active
'active' => $active
]);
return $Engine->fetch(dirname(__FILE__).'/NavTabs.html');
return $Engine->fetch(dirname(__FILE__) . '/NavTabs.html');
}
/**
......@@ -111,13 +111,15 @@ private function getChildrenFromParent()
$short = '';
if ($this->getAttribute('showShort') && $Site->getAttribute('short')) {
$short = '<div class="quiqqer-menu-navTabs-content-item-shortDesc text-muted">'.$Site->getAttribute('short').'</div>';
$short = '<div class="quiqqer-menu-navTabs-content-item-shortDesc text-muted">' .
$Site->getAttribute('short') .
'</div>';
}
$entryContent = $short.$Site->getAttribute('content');
$entryContent = $short . $Site->getAttribute('content');
$entry = [
'title' => $Site->getAttribute('title'),
'title' => $Site->getAttribute('title'),
'content' => $entryContent,
];
......@@ -154,7 +156,7 @@ public function setData(array $data)
}
$entry = [
'title' => $dataSet[0],
'title' => $dataSet[0],
'content' => $dataSet[1],
];
......
......@@ -25,20 +25,20 @@ public function __construct($attributes = [])
{
// default options
$this->setAttributes([
'class' => 'quiqqer-menu-navTabsVertical',
'qui-class' => 'package/quiqqer/menu/bin/Controls/NavTabs',
'navTitle' => false,
'navContent' => false,
'imagePos' => 'top',
'imageMaxWidth' => false,
'class' => 'quiqqer-menu-navTabsVertical',
'qui-class' => 'package/quiqqer/menu/bin/Controls/NavTabs',
'navTitle' => false,
'navContent' => false,
'imagePos' => 'top',
'imageMaxWidth' => false,
'imageMaxHeight' => false,
'entries' => [],
'template' => 'default'
'entries' => [],
'template' => 'default'
]);
parent::__construct($attributes);
$this->addCSSFile(dirname(__FILE__).'/NavTabsVertical.css');
$this->addCSSFile(dirname(__FILE__) . '/NavTabsVertical.css');
}
/**
......@@ -48,7 +48,7 @@ public function __construct($attributes = [])
*/
public function getBody()
{
$Engine = QUI::getTemplateManager()->getEngine();
$Engine = QUI::getTemplateManager()->getEngine();
$entries = $this->getAttribute('entries');
$enabledEntries = [];
......@@ -65,13 +65,13 @@ public function getBody()
}
$Engine->assign([
'this' => $this,
'entries' => $enabledEntries,
'navTitle' => $this->getAttribute('navTitle'),
'this' => $this,
'entries' => $enabledEntries,
'navTitle' => $this->getAttribute('navTitle'),
'navContent' => $this->getAttribute('navContent'),
'imagePos' => $this->getAttribute('imagePos')
'imagePos' => $this->getAttribute('imagePos')
]);
return $Engine->fetch(dirname(__FILE__).'/NavTabsVertical.html');
return $Engine->fetch(dirname(__FILE__) . '/NavTabsVertical.html');
}
}
......@@ -24,10 +24,10 @@ public function __construct($attributes = [])
{
// default options
$this->setAttributes([
'title' => 'One Page Navigation',
'title' => 'One Page Navigation',
'contentList' => false,
'entries' => [],
'qui-class' => 'package/quiqqer/menu/bin/Controls/OnePageNav'
'entries' => [],
'qui-class' => 'package/quiqqer/menu/bin/Controls/OnePageNav'
]);
parent::__construct($attributes);
......@@ -44,7 +44,7 @@ public function __construct($attributes = [])
*/
public function getBody()
{
$Engine = QUI::getTemplateManager()->getEngine();
$Engine = QUI::getTemplateManager()->getEngine();
$entries = $this->getAttribute('entries');
if (is_string($entries)) {
......@@ -52,7 +52,7 @@ public function getBody()
}
$Engine->assign([
'this' => $this,
'this' => $this,
'entries' => $entries
]);
......
......@@ -2,17 +2,20 @@
namespace QUI\Menu\Rest;
use Exception;
use Psr\Http\Message\MessageInterface;
use Psr\Http\Message\ResponseInterface as ResponseInterface;
use Psr\Http\Message\ServerRequestInterface as RequestInterface;
use QUI;
use QUI\CoreRest\Handler;
use QUI\Menu\Independent\Factory as MenuFactory;
use QUI\Menu\Independent\Handler as MenuHandler;
use QUI\REST\ProviderInterface;
use Psr\Http\Message\ServerRequestInterface as RequestInterface;
use Psr\Http\Message\ResponseInterface as ResponseInterface;
use Psr\Http\Message\MessageInterface;
use QUI\REST\Server;
use QUI\CoreRest\Handler;
use Slim\Routing\RouteCollectorProxy;
use QUI\Utils\Security\Orthos;
use QUI\Menu\Independent\Handler as MenuHandler;
use QUI\Menu\Independent\Factory as MenuFactory;
use Slim\Routing\RouteCollectorProxy;
use function is_array;
/**
* Class Provider
......@@ -50,18 +53,18 @@ public function register(Server $Server)
public function create(RequestInterface $Request, ResponseInterface $Response): MessageInterface
{
$params = $Request->getParsedBody();
$menu = [];
$menu = [];
$requiredFields = [
'title',
'title'
];
foreach ($requiredFields as $field) {
if (empty($params[$field])) {
return Handler::getGenericErrorResponse('Field "'.$field.'" is missing.');
return Handler::getGenericErrorResponse('Field "' . $field . '" is missing.');
}
if (\is_array($params[$field])) {
if (is_array($params[$field])) {
$value = Orthos::clearArray($params[$field]);
} else {
$value = Orthos::clear($params[$field]);
......@@ -88,7 +91,7 @@ public function create(RequestInterface $Request, ResponseInterface $Response):
break;
default:
if (\is_array($params[$field])) {
if (is_array($params[$field])) {
$value = Orthos::clearArray($params[$field]);
} else {
$value = Orthos::clear($params[$field]);
......@@ -109,20 +112,20 @@ public function create(RequestInterface $Request, ResponseInterface $Response):
try {
$Menu = MenuHandler::getMenu($menuId);
} catch (\Exception $Exception) {
} catch (Exception $Exception) {
QUI\System\Log::writeDebugException($Exception);
$Menu = false;
}
if ($Menu) {
throw new QUI\Exception(
'Menu with specific id #'.$menuId.' cannot be created, since a menu with this id already'
.' exists.'
'Menu with specific id #' . $menuId . ' cannot be created, since a menu with this id already'
. ' exists.'
);
}
}
$Menu = MenuFactory::createMenu();
$Menu = MenuFactory::createMenu();
$newMenuId = $Menu->getId();
if ($menuId) {
......@@ -137,7 +140,7 @@ public function create(RequestInterface $Request, ResponseInterface $Response):
);
$newMenuId = $menuId;
$Menu = MenuHandler::getMenu($newMenuId);
$Menu = MenuHandler::getMenu($newMenuId);
}
$Menu->setTitle($menu['title']);
......@@ -151,7 +154,7 @@ public function create(RequestInterface $Request, ResponseInterface $Response):
}
$Menu->save(QUI::getUsers()->getSystemUser());
} catch (\Exception $Exception) {
} catch (Exception $Exception) {
return Handler::getGenericExceptionResponse($Exception);
}
......@@ -173,7 +176,7 @@ public function create(RequestInterface $Request, ResponseInterface $Response):
public function get(RequestInterface $Request, ResponseInterface $Response): MessageInterface
{
$params = $Request->getParsedBody();
$menu = [];
$menu = [];
$requiredFields = [
'id'
......@@ -181,7 +184,7 @@ public function get(RequestInterface $Request, ResponseInterface $Response): Mes
foreach ($requiredFields as $field) {
if (empty($params[$field])) {
return Handler::getGenericErrorResponse('Field "'.$field.'" is missing.');
return Handler::getGenericErrorResponse('Field "' . $field . '" is missing.');
}
$menu[$field] = Orthos::clear($params[$field]);
......@@ -189,7 +192,7 @@ public function get(RequestInterface $Request, ResponseInterface $Response): Mes
try {
$Menu = MenuHandler::getMenu($menu['id']);
} catch (\Exception $Exception) {
} catch (Exception $Exception) {
return Handler::getGenericExceptionResponse($Exception);
}
......@@ -209,7 +212,7 @@ public function get(RequestInterface $Request, ResponseInterface $Response): Mes
public function update(RequestInterface $Request, ResponseInterface $Response): MessageInterface
{
$params = $Request->getParsedBody();
$menu = [];
$menu = [];
$requiredFields = [
'id'
......@@ -217,7 +220,7 @@ public function update(RequestInterface $Request, ResponseInterface $Response):
foreach ($requiredFields as $field) {
if (empty($params[$field])) {
return Handler::getGenericErrorResponse('Field "'.$field.'" is missing.');
return Handler::getGenericErrorResponse('Field "' . $field . '" is missing.');
}
$menu[$field] = Orthos::clear($params[$field]);
......@@ -241,7 +244,7 @@ public function update(RequestInterface $Request, ResponseInterface $Response):
break;
default:
if (\is_array($params[$field])) {
if (is_array($params[$field])) {
$value = Orthos::clearArray($params[$field]);
} else {
$value = Orthos::clear($params[$field]);
......@@ -267,14 +270,14 @@ public function update(RequestInterface $Request, ResponseInterface $Response):
}
$Menu->save(QUI::getUsers()->getSystemUser());
} catch (\Exception $Exception) {
} catch (Exception $Exception) {
QUI\System\Log::writeException($Exception);
return Handler::getGenericExceptionResponse($Exception);
}
return Handler::getGenericSuccessResponse(
'Menu #'.$menu['id'].' successfully updated.',
'Menu #' . $menu['id'] . ' successfully updated.',
$Menu->toArray()
);
}
......@@ -289,7 +292,7 @@ public function update(RequestInterface $Request, ResponseInterface $Response):
public function delete(RequestInterface $Request, ResponseInterface $Response): MessageInterface
{
$params = $Request->getParsedBody();
$menu = [];
$menu = [];
$requiredFields = [
'id'
......@@ -297,7 +300,7 @@ public function delete(RequestInterface $Request, ResponseInterface $Response):
foreach ($requiredFields as $field) {
if (empty($params[$field])) {
return Handler::getGenericErrorResponse('Field "'.$field.'" is missing.');
return Handler::getGenericErrorResponse('Field "' . $field . '" is missing.');
}
$menu[$field] = Orthos::clear($params[$field]);
......@@ -305,12 +308,12 @@ public function delete(RequestInterface $Request, ResponseInterface $Response):
try {
MenuFactory::deleteMenu((int)$menu['id']);
} catch (\Exception $Exception) {
} catch (Exception $Exception) {
return Handler::getGenericExceptionResponse($Exception);
}
return Handler::getGenericSuccessResponse(
'Menu #'.$menu['id'].' successfully deleted.'
'Menu #' . $menu['id'] . ' successfully deleted.'
);
}
......
......@@ -25,18 +25,18 @@ public function __construct($attributes = [])
{
// defaults values
$this->setAttributes([
'startId' => 1, // id or site link
'menuId' => false,
'parentLink' => false,
'levels' => 0,
'startId' => 1, // id or site link
'menuId' => false,
'parentLink' => false,
'levels' => 0,
'onlyFirstLevelIcons' => false,
'listType' => 'fontAwesome',
'homeIcon' => 'fa-home',
'listIcon' => 'fa-angle-right',
'levelIcon' => 'fa-angle-double-right',
'qui-class' => 'package/quiqqer/menu/bin/SidebarDropDownMenu',
'display' => 'simple',
'showAllChildren' => false
'listType' => 'fontAwesome',
'homeIcon' => 'fa-home',
'listIcon' => 'fa-angle-right',
'levelIcon' => 'fa-angle-double-right',
'qui-class' => 'package/quiqqer/menu/bin/SidebarDropDownMenu',
'display' => 'simple',
'showAllChildren' => false
]);
parent::__construct($attributes);
......@@ -52,8 +52,8 @@ public function __construct($attributes = [])
*/
public function getBody()
{
$Engine = QUI::getTemplateManager()->getEngine();
$Project = $this->getProject();
$Engine = QUI::getTemplateManager()->getEngine();
$Project = $this->getProject();
$activeId = false;
// start
......@@ -101,61 +101,61 @@ public function getBody()
switch ($this->getAttribute('display')) {
default:
case 'simple':
$css = dirname(__FILE__).'/SidebarDropDownMenu.Independent.Simple.css';
$template = dirname(__FILE__).'/SidebarDropDownMenu.Independent.Simple.html';
$css = dirname(__FILE__) . '/SidebarDropDownMenu.Independent.Simple.css';
$template = dirname(__FILE__) . '/SidebarDropDownMenu.Independent.Simple.html';
break;
case 'advanced':
$css = dirname(__FILE__).'/SidebarDropDownMenu.Independent.Advanced.css';
$template = dirname(__FILE__).'/SidebarDropDownMenu.Independent.Advanced.html';
$css = dirname(__FILE__) . '/SidebarDropDownMenu.Independent.Advanced.css';
$template = dirname(__FILE__) . '/SidebarDropDownMenu.Independent.Advanced.html';
break;
}
$Engine->assign([
'this' => $this,
'this' => $this,
'children' => $children,
'Project' => $this->getProject(),
'Site' => $Site,
'FirstPage' => $FirstPage,
'listType' => $this->getAttribute('listType'),
'parentLink' => $this->getAttribute('parentLink'),
'activeId' => $activeId,
'navTemplate' => $template,
'levels' => $levels,
'Rewrite' => QUI::getRewrite(),
'parentIcon' => $this->getAttribute('parentIcon'),
'listIcon' => $this->getAttribute('listIcon'),
'levelIcon' => $this->getAttribute('levelIcon'),
'Project' => $this->getProject(),
'Site' => $Site,
'FirstPage' => $FirstPage,
'listType' => $this->getAttribute('listType'),
'parentLink' => $this->getAttribute('parentLink'),
'activeId' => $activeId,
'navTemplate' => $template,
'levels' => $levels,
'Rewrite' => QUI::getRewrite(),
'parentIcon' => $this->getAttribute('parentIcon'),
'listIcon' => $this->getAttribute('listIcon'),
'levelIcon' => $this->getAttribute('levelIcon'),
'onlyFirstLevelIcons' => $this->getAttribute('onlyFirstLevelIcons')
]);
} else {
switch ($this->getAttribute('display')) {
default:
case 'simple':
$css = dirname(__FILE__).'/SidebarDropDownMenu.Simple.css';
$template = dirname(__FILE__).'/SidebarDropDownMenu.Simple.html';
$css = dirname(__FILE__) . '/SidebarDropDownMenu.Simple.css';
$template = dirname(__FILE__) . '/SidebarDropDownMenu.Simple.html';
break;
case 'advanced':
$css = dirname(__FILE__).'/SidebarDropDownMenu.Advanced.css';
$template = dirname(__FILE__).'/SidebarDropDownMenu.Advanced.html';
$css = dirname(__FILE__) . '/SidebarDropDownMenu.Advanced.css';
$template = dirname(__FILE__) . '/SidebarDropDownMenu.Advanced.html';
break;
}
$Engine->assign([
'this' => $this,
'Project' => $this->getProject(),
'Site' => $Site,
'FirstPage' => $FirstPage,
'listType' => $this->getAttribute('listType'),
'parentLink' => $this->getAttribute('parentLink'),
'activeId' => $activeId,
'navTemplate' => $template,
'levels' => $levels,
'Rewrite' => QUI::getRewrite(),
'parentIcon' => $this->getAttribute('parentIcon'),
'listIcon' => $this->getAttribute('listIcon'),
'levelIcon' => $this->getAttribute('levelIcon'),
'this' => $this,
'Project' => $this->getProject(),
'Site' => $Site,
'FirstPage' => $FirstPage,
'listType' => $this->getAttribute('listType'),
'parentLink' => $this->getAttribute('parentLink'),
'activeId' => $activeId,
'navTemplate' => $template,
'levels' => $levels,
'Rewrite' => QUI::getRewrite(),
'parentIcon' => $this->getAttribute('parentIcon'),
'listIcon' => $this->getAttribute('listIcon'),
'levelIcon' => $this->getAttribute('levelIcon'),
'onlyFirstLevelIcons' => $this->getAttribute('onlyFirstLevelIcons')
]);
}
......@@ -164,7 +164,7 @@ public function getBody()
$this->addCSSFile($css);
$html = $Engine->fetch($template);
$html = '<nav>'.$html.'</nav>';
$html = '<nav>' . $html . '</nav>';
return $html;
}
......
......@@ -23,11 +23,11 @@ class SlideOut extends QUI\Control
public function __construct($attributes = [])
{
$this->setAttributes([
'showHomeLink' => true,
'menuId' => false, // if set independent menu template will be used
'showFirstLevelIcons' => false, // current it works only for independent menu
'showHomeLink' => true,
'menuId' => false, // if set independent menu template will be used
'showFirstLevelIcons' => false, // current it works only for independent menu
'collapseMobileSubmenu' => false,
'showLevel' => 1
'showLevel' => 1
]);
parent::__construct($attributes);
......@@ -42,31 +42,31 @@ public function getBody()
$Engine = QUI::getTemplateManager()->getEngine();
$collapseMobileSubmenu = $this->getAttribute('collapseMobileSubmenu');
$showLevel = $this->getAttribute('showLevel');
$showLevel = $this->getAttribute('showLevel');
$params = [
'this' => $this,
'Project' => $this->getProject(),
'jsControl' => 'package/quiqqer/menu/bin/SlideOut',
'this' => $this,
'Project' => $this->getProject(),
'jsControl' => 'package/quiqqer/menu/bin/SlideOut',
'showHomeLink' => $this->getAttribute('showHomeLink')
];
if ($this->getAttribute('menuId')) {
$IndependentMenu = Independent\Handler::getMenu($this->getAttribute('menuId'));
$template = dirname(__FILE__).'/Menu.Independent.html';
$params['FileMenu'] = dirname(__FILE__).'/Menu.Children.Independent.html';
$params['IndependentMenu'] = $IndependentMenu;
$params['Site'] = $this->getSite();
$template = dirname(__FILE__) . '/Menu.Independent.html';
$params['FileMenu'] = dirname(__FILE__) . '/Menu.Children.Independent.html';
$params['IndependentMenu'] = $IndependentMenu;
$params['Site'] = $this->getSite();
$params['collapseMobileSubmenu'] = $collapseMobileSubmenu;
$params['showLevel'] = $showLevel;
$params['showFirstLevelIcons'] = $this->getAttribute('showFirstLevelIcons');
$params['showLevel'] = $showLevel;
$params['showFirstLevelIcons'] = $this->getAttribute('showFirstLevelIcons');
} else {
$template = dirname(__FILE__).'/Menu.html';
$template = dirname(__FILE__) . '/Menu.html';
$params['collapseMobileSubmenu'] = $collapseMobileSubmenu;
$params['showLevel'] = $showLevel;
$params['FileMenu'] = dirname(__FILE__).'/Menu.Children.html';
$params['Site'] = $this->getSite();
$params['showLevel'] = $showLevel;
$params['FileMenu'] = dirname(__FILE__) . '/Menu.Children.html';
$params['Site'] = $this->getSite();
}
$Engine->assign($params);
......
......@@ -22,16 +22,16 @@ class SlideOutAdvanced extends QUI\Control
public function __construct($attributes = [])
{
$this->setAttributes([
'menuId' => false, // if set independent menu template will be used
'menuId' => false, // if set independent menu template will be used
'showFirstLevelIcons' => false, // current it works only for independent menu
'showHomeLink' => true,
'showShortDesc' => true,
'showHomeLink' => true,
'showShortDesc' => true,
]);
parent::__construct($attributes);
$this->addCSSFile(
\dirname(__FILE__).'/SlideOutAdvanced.css'
\dirname(__FILE__) . '/SlideOutAdvanced.css'
);
}
......@@ -44,25 +44,25 @@ public function getBody()
$Engine = QUI::getTemplateManager()->getEngine();
$params = [
'this' => $this,
'Project' => $this->getProject(),
'jsControl' => 'package/quiqqer/menu/bin/SlideoutAdvanced',
'this' => $this,
'Project' => $this->getProject(),
'jsControl' => 'package/quiqqer/menu/bin/SlideoutAdvanced',
'showShortDesc' => $this->getAttribute('showShortDesc'),
'showHomeLink' => $this->getAttribute('showHomeLink')
'showHomeLink' => $this->getAttribute('showHomeLink')
];
if ($this->getAttribute('menuId')) {
$IndependentMenu = Independent\Handler::getMenu($this->getAttribute('menuId'));
$template = dirname(__FILE__).'/SlideOutAdvanced.Independent.html';
$params['FileMenu'] = dirname(__FILE__).'/SlideOutAdvanced.Children.Independent.html';
$params['IndependentMenu'] = $IndependentMenu;
$params['Site'] = $this->getSite();
$template = dirname(__FILE__) . '/SlideOutAdvanced.Independent.html';
$params['FileMenu'] = dirname(__FILE__) . '/SlideOutAdvanced.Children.Independent.html';
$params['IndependentMenu'] = $IndependentMenu;
$params['Site'] = $this->getSite();
$params['showFirstLevelIcons'] = $this->getAttribute('showFirstLevelIcons');
} else {
$template = dirname(__FILE__).'/SlideOutAdvanced.html';
$params['FileMenu'] = dirname(__FILE__).'/SlideOutAdvanced.Children.html';
$params['Site'] = $this->getSite();
$template = dirname(__FILE__) . '/SlideOutAdvanced.html';
$params['FileMenu'] = dirname(__FILE__) . '/SlideOutAdvanced.Children.html';
$params['Site'] = $this->getSite();
}
$Engine->assign($params);
......
......@@ -33,12 +33,12 @@ public function __construct($attributes = [])
{
// defaults values
$this->setAttributes([
'class' => 'quiqqer-urlList',
'headerText' => '', // title above the url list
'startId' => false, // id or site link
'menuId' => false, // id of an (independent) menu
'display' => 'default',
'icon' => '', // only fontawesome icons are supported
'class' => 'quiqqer-urlList',
'headerText' => '', // title above the url list
'startId' => false, // id or site link
'menuId' => false, // id of an (independent) menu
'display' => 'default',
'icon' => '', // only fontawesome icons are supported
'resetLinkColor' => false // if true, the link inherit color from parent
]);
......@@ -57,17 +57,17 @@ public function getBody()
if ($this->getAttribute('menuId')) {
// independent menu
$children = $this->getChildrenForIndependentMenu();
$template = dirname(__FILE__).'/UrlList.Independent.Default.html';
$template = dirname(__FILE__) . '/UrlList.Independent.Default.html';
} elseif ($this->getAttribute('startId')) {
// qui site
$children = $this->getChildrenForQUISite();
$template = dirname(__FILE__).'/UrlList.Default.html';
$template = dirname(__FILE__) . '/UrlList.Default.html';
} else {
return '';
}
$Engine = QUI::getTemplateManager()->getEngine();
$icon = '';
$Engine = QUI::getTemplateManager()->getEngine();
$icon = '';
$restLinkColorCss = '';
if ($this->getAttribute('icon') && strpos($this->getAttribute('icon'), 'fa ') === 0) {
......@@ -86,14 +86,14 @@ public function getBody()
}
$Engine->assign([
'this' => $this,
'headerText' => $this->getAttribute('headerText'),
'children' => $children,
'icon' => $icon,
'this' => $this,
'headerText' => $this->getAttribute('headerText'),
'children' => $children,
'icon' => $icon,
'restLinkColorCss' => $restLinkColorCss
]);
$this->addCSSFile(dirname(__FILE__).'/UrlList.Default.css');
$this->addCSSFile(dirname(__FILE__) . '/UrlList.Default.css');
return $Engine->fetch($template);
}
......
0% oder .
You are about to add 0 people to the discussion. Proceed with caution.
Bearbeitung dieser Nachricht zuerst beenden!
Bitte registrieren oder zum Kommentieren