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

Merge branch 'next' into 'master'

feat!: quiqqer v2

See merge request !25
Übergeordnete 8c378527 e0e0bf33
No related branches found
Tags 3.1.0
2 Merge Requests!34Update 'next-4.x' with latest changes from 'main',!25feat!: quiqqer v2
Pipeline #7411 bestanden mit Phase
in 1 Minute und 2 Sekunden
werden angezeigt mit 110 Ergänzungen und 86 Löschungen
tools/
phpstan.neon
.phpunit.result.cache
phpunit.xml
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<phive xmlns="https://phar.io/phive">
<phar name="phpstan" version="^1.10.67" installed="1.10.67" location="./tools/phpstan" copy="false"/>
</phive>
......@@ -12,13 +12,16 @@
*
* @return array
*/
use QUI\Menu\Independent\Factory;
QUI::$Ajax->registerFunction(
'package_quiqqer_menu_ajax_backend_independent_create',
function ($title, $workingTitle) {
$title = json_decode($title, true);
$workingTitle = json_decode($workingTitle, true);
$Menu = \QUI\Menu\Independent\Factory::createMenu();
$Menu = Factory::createMenu();
$Menu->setTitle($title);
$Menu->setWorkingTitle($workingTitle);
$Menu->save();
......
......@@ -4,6 +4,8 @@
* This file contains package_quiqqer_menu_ajax_backend_independent_get
*/
use QUI\Menu\Independent\Items\AbstractMenuItem;
QUI::$Ajax->registerFunction(
'package_quiqqer_menu_ajax_backend_independent_get',
function ($id) {
......@@ -21,7 +23,7 @@ function parseChildren(&$data)
continue;
}
/* @var $Item \QUI\Menu\Independent\Items\AbstractMenuItem */
/* @var $Item AbstractMenuItem */
$Item = new $entry['type']($entry);
$icon = QUI\Menu\Independent\Items\Site::itemIcon(); // default
......
......@@ -7,6 +7,9 @@
/**
* Return the item name
*/
use QUI\Menu\Independent\Items\AbstractMenuItem;
QUI::$Ajax->registerFunction(
'package_quiqqer_menu_ajax_backend_independent_getItemName',
function ($item) {
......@@ -16,7 +19,7 @@ function ($item) {
return '';
}
/* @var $Item \QUI\Menu\Independent\Items\AbstractMenuItem */
/* @var $Item AbstractMenuItem */
$Item = new $item['type']($item);
return $Item->getName();
},
......
......@@ -7,6 +7,9 @@
/**
* Return the item name
*/
use QUI\Menu\Independent\Items\AbstractMenuItem;
QUI::$Ajax->registerFunction(
'package_quiqqer_menu_ajax_backend_independent_getItemTitle',
function ($item) {
......@@ -16,7 +19,7 @@ function ($item) {
return '';
}
/* @var $Item \QUI\Menu\Independent\Items\AbstractMenuItem */
/* @var $Item AbstractMenuItem */
$Item = new $item['type']($item);
return $Item->getTitle();
},
......
{
"name": "quiqqer\/menu",
"name": "quiqqer/menu",
"type": "quiqqer-module",
"description": "The Plugin menu provides various menu controls.",
"license": [
......@@ -10,21 +10,21 @@
{
"name": "Henning Leutz",
"email": "leutz@pcsg.de",
"homepage": "http:\/\/www.pcsg.de",
"homepage": "https://www.pcsg.de",
"role": "Developer"
}
],
"support": {
"email": "support@pcsg.de",
"url": "http:\/\/www.pcsg.de"
"url": "https://www.pcsg.de"
},
"require": {
"php": ">=5.3",
"quiqqer\/quiqqer": "*@dev"
"php": "^8.1",
"quiqqer/core": "^2"
},
"autoload": {
"psr-4": {
"QUI\\Menu\\": "src\/QUI\/Menu"
"QUI\\Menu\\": "src/QUI/Menu"
}
}
}
\ No newline at end of file
includes:
- phpstan-baseline.neon
parameters:
level: 1
paths:
- src
- ajax
bootstrapFiles:
- tests/phpstan-bootstrap.php
\ No newline at end of file
......@@ -15,12 +15,12 @@ abstract class AbstractMenu extends QUI\Control
/**
* @var string
*/
protected $append = '';
protected string $append = '';
/**
* @var string
*/
protected $prepend = '';
protected string $prepend = '';
/**
* append html to the menu
......@@ -28,7 +28,7 @@ abstract class AbstractMenu extends QUI\Control
*
* @param string $html
*/
public function appendHTML($html)
public function appendHTML(string $html): void
{
$this->append = $html;
}
......@@ -39,7 +39,7 @@ public function appendHTML($html)
*
* @param string $html
*/
public function prependHTML($html)
public function prependHTML(string $html): void
{
$this->prepend = $html;
}
......
......@@ -21,7 +21,7 @@ class FloatedNav extends QUI\Control
*
* @param array $attributes
*/
public function __construct($attributes = [])
public function __construct(array $attributes = [])
{
// default options
$this->setAttributes([
......@@ -60,7 +60,7 @@ public function __construct($attributes = [])
*
* @see \QUI\Control::create()
*/
public function getBody()
public function getBody(): string
{
$Engine = QUI::getTemplateManager()->getEngine();
$LangSwitch = null;
......@@ -73,11 +73,8 @@ public function getBody()
return '';
}
if (!$IndependentMenu) {
return '';
}
$showToggleButton = true;
switch ($this->getAttribute('showToggleButton')) {
case 'always':
$this->setJavaScriptControlOption('showtogglebutton', 'always');
......@@ -94,26 +91,15 @@ public function getBody()
break;
}
switch ($this->getAttribute('size')) {
case 'small':
case 'medium':
case 'large':
$size = 'quiqqer-floatedNavControl__size-' . $this->getAttribute('size');
break;
default:
$size = 'quiqqer-floatedNavControl__size-medium';
}
switch ($this->getAttribute('design')) {
case 'flat':
$design = 'quiqqer-floatedNavControl__design-' . $this->getAttribute('design');
break;
$size = match ($this->getAttribute('size')) {
'small', 'medium', 'large' => 'quiqqer-floatedNavControl__size-' . $this->getAttribute('size'),
default => 'quiqqer-floatedNavControl__size-medium',
};
case 'iconBar':
default:
$design = 'quiqqer-floatedNavControl__design-iconsBar';
}
$design = match ($this->getAttribute('design')) {
'flat' => 'quiqqer-floatedNavControl__design-' . $this->getAttribute('design'),
default => 'quiqqer-floatedNavControl__design-iconsBar',
};
switch ($this->getAttribute('posX')) {
case 'left':
......@@ -130,14 +116,10 @@ public function getBody()
}
if ($this->getAttribute('showLangSwitch')) {
try {
$LangSwitch = new QUI\Bricks\Controls\LanguageSwitches\Flags([
'showFlags' => 0,
'class' => 'quiqqer-floatedNav-entry'
]);
} catch (QUI\Exception $Exception) {
QUI\System\Log::writeException($Exception);
}
$LangSwitch = new QUI\Bricks\Controls\LanguageSwitches\Flags([
'showFlags' => 0,
'class' => 'quiqqer-floatedNav-entry'
]);
}
$animation = '';
......@@ -187,7 +169,7 @@ public function getBody()
*
* @return false|mixed|string
*/
public function getAnimationEasingName()
public function getAnimationEasingName(): mixed
{
switch ($this->getAttribute('animationEasing')) {
case 'easeInQuad':
......
......@@ -21,7 +21,7 @@ class Tabs extends QUI\Control
*
* @param array $attributes
*/
public function __construct($attributes = [])
public function __construct(array $attributes = [])
{
// default options
$this->setAttributes([
......@@ -63,7 +63,7 @@ public function __construct($attributes = [])
*
* @see \QUI\Control::create()
*/
public function getBody()
public function getBody(): string
{
$Engine = QUI::getTemplateManager()->getEngine();
$entries = $this->getAttribute('entries');
......@@ -78,7 +78,7 @@ public function getBody()
continue;
}
array_push($enabledEntries, $entry);
$enabledEntries[] = $entry;
}
$active = 1;
......
......@@ -7,10 +7,18 @@
namespace QUI\Menu;
use QUI;
use QUI\Exception;
use QUI\Interfaces\Projects\Site;
use function array_filter;
use function dirname;
use function is_object;
use function md5;
use function serialize;
/**
* Class DropDownMenu
* Creates an Drop Down Menu
* Creates a Drop-Down Menu
*
* @package QUI\Menu
* @author www.pcsg.de (Henning Leutz)
......@@ -20,7 +28,7 @@ class DropDownMenu extends QUI\Control
/**
* @param array $attributes
*/
public function __construct($attributes = [])
public function __construct(array $attributes = [])
{
$this->setAttribute('class', 'qui-menu-dropdown');
$this->setAttribute('qui-class', 'package/quiqqer/menu/bin/DropDownMenu');
......@@ -28,7 +36,7 @@ public function __construct($attributes = [])
parent::__construct($attributes);
$this->addCSSFile(\dirname(__FILE__) . '/DropDownMenu.css');
$this->addCSSFile(dirname(__FILE__) . '/DropDownMenu.css');
}
/**
......@@ -37,23 +45,23 @@ public function __construct($attributes = [])
* @return string
* @throws QUI\Exception
*/
public function getBody()
public function getBody(): string
{
$cache = EventHandler::menuCacheName() . '/dropDownMenu/';
$attributes = $this->getAttributes();
$attributes = \array_filter($attributes, function ($entry) {
return \is_object($entry) === false;
$attributes = array_filter($attributes, function ($entry) {
return is_object($entry) === false;
});
$cache .= \md5(
$cache .= md5(
$this->getSite()->getCachePath() .
\serialize($attributes)
serialize($attributes)
);
try {
return QUI\Cache\Manager::get($cache);
} catch (QUI\Exception $Exception) {
} catch (QUI\Exception) {
}
$Engine = QUI::getTemplateManager()->getEngine();
......@@ -62,10 +70,10 @@ public function getBody()
'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');
$result = $Engine->fetch(dirname(__FILE__) . '/DropDownMenu.html');
QUI\Cache\Manager::set($cache, $result);
......@@ -75,9 +83,10 @@ public function getBody()
/**
* Return the current site
*
* @return mixed|QUI\Projects\Site
* @return Site
* @throws Exception
*/
protected function getSite()
protected function getSite(): QUI\Interfaces\Projects\Site
{
if ($this->getAttribute('Site')) {
return $this->getAttribute('Site');
......
......@@ -6,6 +6,7 @@
namespace QUI\Menu;
use Exception;
use QUI;
/**
......@@ -20,7 +21,7 @@ class Elastic extends QUI\Control
/**
* @param array $attributes
*/
public function __construct($attributes = [])
public function __construct(array $attributes = [])
{
parent::__construct($attributes);
}
......@@ -28,8 +29,9 @@ public function __construct($attributes = [])
/**
* @return string
* @throws QUI\Exception
* @throws Exception
*/
public function getBody()
public function getBody(): string
{
$Engine = QUI::getTemplateManager()->getEngine();
......@@ -48,8 +50,9 @@ public function getBody()
* Return the current site
*
* @return mixed|QUI\Projects\Site
* @throws QUI\Exception
*/
protected function getSite()
protected function getSite(): mixed
{
if ($this->getAttribute('Site')) {
return $this->getAttribute('Site');
......
......@@ -25,7 +25,7 @@ public static function menuCacheName(): string
/**
* @param Site $Site
*/
public static function onSiteSave(Site $Site)
public static function onSiteSave(Site $Site): void
{
QUI\Cache\Manager::clear(self::menuCacheName());
}
......@@ -35,7 +35,7 @@ public static function onSiteSave(Site $Site)
*
* @return void
*/
public static function onProjectConfigSave()
public static function onProjectConfigSave(): void
{
QUI\Cache\Manager::clear(self::menuCacheName());
}
......@@ -47,7 +47,7 @@ public static function onProjectConfigSave()
* @param Smarty $Smarty
* @throws SmartyException
*/
public static function onSmartyInit(Smarty $Smarty)
public static function onSmartyInit(Smarty $Smarty): void
{
if (
!isset($Smarty->registered_plugins['function'])
......@@ -62,7 +62,7 @@ public static function onSmartyInit(Smarty $Smarty)
*
* @return void
*/
public static function onAdminLoadFooter()
public static function onAdminLoadFooter(): void
{
$jsFile = URL_OPT_DIR . 'quiqqer/menu/bin/onAdminLoadFooter.js';
echo '<script src="' . $jsFile . '" async></script>';
......@@ -72,7 +72,7 @@ public static function onAdminLoadFooter()
* @param $menuId
* @return void
*/
public static function onQuiqqerMenuIndependentClear($menuId)
public static function onQuiqqerMenuIndependentClear($menuId): void
{
QUI\Cache\Manager::clear(self::menuCacheName());
}
......
......@@ -2,6 +2,7 @@
namespace QUI\Menu\Independent;
use Exception;
use QUI;
/**
......@@ -29,7 +30,7 @@ public static function createMenu(): Menu
try {
QUI::getEvents()->fireEvent('quiqqerMenuIndependentCreate', [$Menu]);
} catch (\Exception $Exception) {
} catch (Exception $Exception) {
QUI\System\Log::writeException($Exception);
}
......@@ -42,7 +43,7 @@ public static function createMenu(): Menu
* @throws QUI\Database\Exception
* @throws QUI\Permissions\Exception
*/
public static function deleteMenu(int $menuId)
public static function deleteMenu(int $menuId): void
{
QUI\Permissions\Permission::checkPermission('quiqqer.menu.delete');
......@@ -52,7 +53,7 @@ public static function deleteMenu(int $menuId)
try {
QUI::getEvents()->fireEvent('quiqqerMenuIndependentDelete', [$menuId]);
} catch (\Exception $Exception) {
} catch (Exception $Exception) {
QUI\System\Log::writeException($Exception);
}
}
......
......@@ -36,7 +36,7 @@ public static function getMenu(int $menuId): Menu
* @param QUI\Projects\Project|null $Project
* @return string
*/
public static function getMenuCacheName($menuId = false, QUI\Projects\Project $Project = null): string
public static function getMenuCacheName(bool|int $menuId = false, QUI\Projects\Project $Project = null): string
{
if ($Project) {
$project = $Project->getName();
......
......@@ -112,7 +112,7 @@ public function getName(Locale $Locale = null): string
/**
* alias for name
* - can be use for the `a title=""` attribute
* - can be used for the `a title=""` attribute
*
* @param Locale|null $Locale
* @return string
......@@ -209,7 +209,7 @@ public function getMenuType(): string
/**
* @return mixed
*/
public function getCustomData()
public function getCustomData(): mixed
{
if (isset($this->attributes['data'])) {
return $this->attributes['data'];
......@@ -352,7 +352,7 @@ public function getChildren(bool $onlyActive = true): array
*
* @param AbstractMenuItem $Item
*/
public function appendChild(AbstractMenuItem $Item)
public function appendChild(AbstractMenuItem $Item): void
{
$this->children[] = $Item;
}
......
......@@ -35,7 +35,7 @@ public function getUrl(): string
if ($Site) {
try {
$url .= $Site->getUrlRewritten();
} catch (QUI\Exception $Exception) {
} catch (QUI\Exception) {
}
}
......@@ -66,7 +66,7 @@ public function getSite(): ?QUI\Projects\Site
try {
$siteUrl = $data['site'];
$Site = QUI\Projects\Site\Utils::getSiteByLink($siteUrl);
} catch (QUI\Exception $Exception) {
} catch (QUI\Exception) {
return null;
}
......@@ -79,7 +79,7 @@ public function getSite(): ?QUI\Projects\Site
$langId = $Site->getId($current);
$LangProject = QUI::getProject($Project->getName(), $current);
return $LangProject->get($langId);
} catch (QUI\Exception $exception) {
} catch (QUI\Exception) {
return null;
}
}
......
......@@ -58,7 +58,7 @@ public function getSite(): ?QUI\Projects\Site
try {
$siteUrl = $data['site'];
$Site = QUI\Projects\Site\Utils::getSiteByLink($siteUrl);
} catch (QUI\Exception $Exception) {
} catch (QUI\Exception) {
return null;
}
......@@ -72,7 +72,7 @@ public function getSite(): ?QUI\Projects\Site
$LangProject = QUI::getProject($Project->getName(), $current);
return $LangProject->get($langId);
} catch (QUI\Exception $exception) {
} catch (QUI\Exception) {
return null;
}
}
......@@ -136,7 +136,7 @@ public function getTitle(QUI\Locale $Locale = null): string
$Site = QUI\Projects\Site\Utils::getSiteByLink($siteUrl);
return $Site->getAttribute('title');
} catch (QUI\Exception $Exception) {
} catch (QUI\Exception) {
}
return '';
......@@ -152,7 +152,7 @@ public function getUrl(): string
if ($Site) {
try {
return $Site->getUrlRewritten();
} catch (QUI\Exception $Exception) {
} catch (QUI\Exception) {
return '';
}
}
......
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