Skip to content

Commit

Permalink
Contao 5 compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
fritzmg committed Mar 17, 2024
1 parent f271c9e commit 6cc8509
Show file tree
Hide file tree
Showing 128 changed files with 275 additions and 195 deletions.
10 changes: 6 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,13 @@
},
"require": {
"php": "^7.4 || ^8.0",
"contao/core-bundle": "^4.9 || ^5.0",
"contao/core-bundle": "^4.13 || ^5.0",
"doctrine/dbal": "^2.11 || ^3.0",
"symfony/dependency-injection": "^4.4 || ^5.4 || ^6.0",
"symfony/filesystem": "^4.4 || ^5.4 || ^6.0",
"symfony/finder": "^4.4 || ^5.4 || ^6.0",
"symfony/http-kernel": "^4.4 || ^5.4 || ^6.0"
"symfony/http-kernel": "^4.4 || ^5.4 || ^6.0",
"symfony/polyfill-php80": "^1.29"
},
"require-dev": {
"contao/manager-plugin": "^2.0"
Expand All @@ -50,13 +51,14 @@
"config": {
"allow-plugins": {
"contao-components/installer": true,
"contao/manager-plugin": true
"contao/manager-plugin": true,
"php-http/discovery": false
}
},
"extra": {
"contao-manager-plugin": "DirkKlemmt\\ContaoMmenuBundle\\ContaoManager\\Plugin"
},
"scripts": {
"ecs": "@php tools/ecs/vendor/bin/ecs check src/ --config tools/ecs/config/default.php --fix --ansi"
"ecs": "@php tools/ecs/vendor/bin/ecs --config tools/ecs/config/default.php --fix --ansi"
}
}
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,28 @@
* This file is part of the ContaoMmenuBundle.
*
* (c) Dirk Klemmt
* (c) inspiredminds
* (c) INSPIRED MINDS
*
* @license MIT
*/

use Contao\ArrayUtil;
use DirkKlemmt\ContaoMmenuBundle\FrontendModule\MmenuCustomModule;
use DirkKlemmt\ContaoMmenuBundle\FrontendModule\MmenuHtmlModule;
use DirkKlemmt\ContaoMmenuBundle\FrontendModule\MmenuModule;
use DirkKlemmt\ContaoMmenuBundle\Model\MmenuConfigModel;

array_insert(
ArrayUtil::arrayInsert(
$GLOBALS['BE_MOD']['system'],
0,
[
'mmenu_config' => [
'tables' => ['tl_dk_mmenu_config'],
],
]
],
);

array_insert($GLOBALS['FE_MOD'], 3, [
ArrayUtil::arrayInsert($GLOBALS['FE_MOD'], 3, [
'navigationMenu' => [
'mmenu' => MmenuModule::class,
'mmenuCustom' => MmenuCustomModule::class,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* This file is part of the ContaoMmenuBundle.
*
* (c) Dirk Klemmt
* (c) inspiredminds
* (c) INSPIRED MINDS
*
* @license MIT
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* This file is part of the ContaoMmenuBundle.
*
* (c) Dirk Klemmt
* (c) inspiredminds
* (c) INSPIRED MINDS
*
* @license MIT
*/
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@
<source>High contrast theme</source>
<target>Theme mit hohem Kontrast</target>
</trans-unit>
<trans-unit id="tl_dk_mmenu_config.themeHighContrast.1">
<source>Enable the high contrast theme.</source>
<target>Theme mit hohem Kontrast aktivieren.</target>
</trans-unit>
<trans-unit id="tl_dk_mmenu_config.countersAdd.0">
<source>Show submenu counter</source>
<target>Zähler für Untermenüs</target>
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@
<trans-unit id="tl_dk_mmenu_config.themeHighContrast.0">
<source>High contrast theme</source>
</trans-unit>
<trans-unit id="tl_dk_mmenu_config.themeHighContrast.1">
<source>Enable the high contrast theme.</source>
</trans-unit>
<trans-unit id="tl_dk_mmenu_config.countersAdd.0">
<source>Show submenu counter</source>
</trans-unit>
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ $GLOBALS['TL_CSS']['contao_dk_mmenu'] = 'bundles/contaommenu/mmenu/mmenu.css|sta
$GLOBALS['TL_JAVASCRIPT']['contao_dk_mmenu'] = 'bundles/contaommenu/mmenu/mmenu.js|static';

?>
<script>
<script<?= method_exists($this, 'attr') ? $this->attr()->setIfExists('nonce', $this->nonce('script-src')) : '' ?>>
document.addEventListener(
"DOMContentLoaded", function () {
const menu = document.querySelector('#<?= $this->elementId ?>');
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<?php if ($item['isActive']): ?>
<li class="<?= $item['class'] ?>"><span class="<?= $item['class'] ?>"<?php if (!empty($item['subitems'])): ?> aria-haspopup="true"<?php endif; ?>><?= $item['link'] ?></span><?= $item['subitems'] ?? '' ?></li>
<?php else: ?>
<li<?php if ($item['class']): ?> class="<?= $item['class'] ?>"<?php endif; ?>><a href="<?= $item['href'] ?: './' ?>" title="<?= $item['pageTitle'] ?: $item['title'] ?>"<?php if ($item['class']): ?> class="<?= $item['class'] ?>"<?php endif; ?><?php if ('' !== $item['accesskey']): ?> accesskey="<?= $item['accesskey'] ?>"<?php endif; ?><?php if ($item['tabindex']): ?> tabindex="<?= $item['tabindex'] ?>"<?php endif; ?><?= $item['target'] ?><?= $item['rel'] ?? '' ?><?php if (!empty($item['subitems'])): ?> aria-haspopup="true"<?php endif; ?>><?= $item['link'] ?></a><?= $item['subitems'] ?? '' ?></li>
<li<?php if ($item['class']): ?> class="<?= $item['class'] ?>"<?php endif; ?>><a href="<?= $item['href'] ?: './' ?>" title="<?= $item['pageTitle'] ?: $item['title'] ?>"<?php if ($item['class']): ?> class="<?= $item['class'] ?>"<?php endif; ?><?php if ('' !== ($item['accesskey'] ?? '')): ?> accesskey="<?= $item['accesskey'] ?>"<?php endif; ?><?php if ('' !== ($item['tabindex'] ?? '')): ?> tabindex="<?= $item['tabindex'] ?>"<?php endif; ?><?= $item['target'] ?><?= $item['rel'] ?? '' ?><?php if ($item['subitems'] ?? null): ?> aria-haspopup="true"<?php endif; ?>><?= $item['link'] ?></a><?= $item['subitems'] ?? '' ?></li>
<?php endif; ?>
<?php endforeach; ?>
</ul>
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -11,34 +11,34 @@ export default function () {
const _menu = `#${this.node.menu.id}`;
// Close menu
if (options.close) {
var states = [];
let states = [];
const setStates = () => {
states = [_menu];
DOM.children(this.node.pnls, '.mm-panel--opened, .mm-panel--parent').forEach((panel) => {
states.push('#' + panel.id);
});
};
this.bind('open:after', () => {
history.pushState(null, document.title, _menu);
history.pushState(null, '', location.pathname + location.search + _menu);
});
this.bind('open:after', setStates);
this.bind('openPanel:after', setStates);
this.bind('close:after', () => {
states = [];
history.back();
history.pushState(null, document.title, location.pathname + location.search);
history.pushState(null, '', location.pathname + location.search);
});
window.addEventListener('popstate', (evnt) => {
window.addEventListener('popstate', () => {
if (this.node.menu.matches('.mm-menu--opened')) {
if (states.length) {
states = states.slice(0, -1);
var hash = states[states.length - 1];
const hash = states[states.length - 1];
if (hash == _menu) {
this.close();
}
else {
this.openPanel(this.node.menu.querySelector(hash));
history.pushState(null, document.title, _menu);
history.pushState(null, '', location.pathname + location.search + _menu);
}
}
}
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@ import nl from './nl';
import pt_br from './pt_br';
import ru from './ru';
import sk from './sk';
import uk from './uk';
export default function () {
add(de, 'de');
add(fa, 'fa');
add(nl, 'nl');
add(pt_br, 'pt_br');
add(ru, 'ru');
add(sk, 'sk');
add(uk, 'uk');
}
7 changes: 7 additions & 0 deletions public/mmenu/addons/searchfield/translations/uk.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export default {
'cancel': 'скасувати',
'Cancel searching': 'Скасувати пошук',
'Clear searchfield': 'Очистити поле пошуку',
'No results found.': 'Нічого не знайдено.',
'Search': 'Пошук',
};
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -25,22 +25,21 @@ export default function () {
}
// Add methods to the API.
this._api.push('open', 'close', 'setPage', 'position');
// Clone menu and prepend it to the <body>.
this.bind('initMenu:before', () => {
// Clone if needed.
if (configs.clone) {
// Clone the original menu and store it.
this.node.menu = this.node.menu.cloneNode(true);
// Prefix all ID's in the cloned menu.
if (this.node.menu.id) {
this.node.menu.id = cloneId(this.node.menu.id);
}
DOM.find(this.node.menu, '[id]').forEach((elem) => {
elem.id = cloneId(elem.id);
});
// Clone menu if needed.
if (configs.clone) {
// Clone the original menu and store it.
this.node.menu = this.node.menu.cloneNode(true);
// Prefix all ID's in the cloned menu.
if (this.node.menu.id) {
this.node.menu.id = cloneId(this.node.menu.id);
}
DOM.find(this.node.menu, '[id]').forEach((elem) => {
elem.id = cloneId(elem.id);
});
}
// Prepend the menu to the <body>.
this.bind('initMenu:before', () => {
this.node.wrpr = document.querySelector(configs.menu.insertSelector);
// Prepend to the <body>
this.node.wrpr[configs.menu.insertMethod](this.node.menu);
});
// Setup the UI blocker.
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@ import nl from './nl';
import pt_br from './pt_br';
import ru from './ru';
import sk from './sk';
import uk from './uk';
export default function () {
add(de, 'de');
add(fa, 'fa');
add(nl, 'nl');
add(pt_br, 'pt_br');
add(ru, 'ru');
add(sk, 'sk');
add(uk, 'uk');
}
4 changes: 4 additions & 0 deletions public/mmenu/core/offcanvas/translations/uk.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export default {
'Close menu': 'Закрити меню',
'Open menu': 'Відкрити меню',
};
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@ import nl from './nl';
import pt_br from './pt_br';
import ru from './ru';
import sk from './sk';
import uk from './uk';
export default function () {
add(de, 'de');
add(fa, 'fa');
add(nl, 'nl');
add(pt_br, 'pt_br');
add(ru, 'ru');
add(sk, 'sk');
add(uk, 'uk');
}
6 changes: 6 additions & 0 deletions public/mmenu/core/oncanvas/translations/uk.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export default {
'Close submenu': 'Закрити підменю',
'Menu': 'Меню',
'Open submenu': 'Відкрити підменю',
'Toggle submenu': 'Перемкнути підменю'
};
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 2 additions & 0 deletions public/mmenu/mmenu.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/ContaoManager/Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* This file is part of the ContaoMmenuBundle.
*
* (c) Dirk Klemmt
* (c) inspiredminds
* (c) INSPIRED MINDS
*
* @license MIT
*/
Expand Down
6 changes: 5 additions & 1 deletion src/ContaoMmenuBundle.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* This file is part of the ContaoMmenuBundle.
*
* (c) Dirk Klemmt
* (c) inspiredminds
* (c) INSPIRED MINDS
*
* @license MIT
*/
Expand All @@ -17,4 +17,8 @@

class ContaoMmenuBundle extends Bundle
{
public function getPath(): string
{
return \dirname(__DIR__);
}
}
2 changes: 1 addition & 1 deletion src/DependencyInjection/ContaoMmenuExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* This file is part of the ContaoMmenuBundle.
*
* (c) Dirk Klemmt
* (c) inspiredminds
* (c) INSPIRED MINDS
*
* @license MIT
*/
Expand Down
2 changes: 1 addition & 1 deletion src/EventListener/DataContainer/JsTemplateOptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* This file is part of the ContaoMmenuBundle.
*
* (c) Dirk Klemmt
* (c) inspiredminds
* (c) INSPIRED MINDS
*
* @license MIT
*/
Expand Down
2 changes: 1 addition & 1 deletion src/EventListener/DataContainer/MmenuConfigOptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* This file is part of the ContaoMmenuBundle.
*
* (c) Dirk Klemmt
* (c) inspiredminds
* (c) INSPIRED MINDS
*
* @license MIT
*/
Expand Down
4 changes: 2 additions & 2 deletions src/EventListener/DataContainer/NavigationTemplateDefault.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* This file is part of the ContaoMmenuBundle.
*
* (c) Dirk Klemmt
* (c) inspiredminds
* (c) INSPIRED MINDS
*
* @license MIT
*/
Expand All @@ -21,7 +21,7 @@
*/
class NavigationTemplateDefault
{
public function __invoke(?string $value, DataContainer $dc): ?string
public function __invoke(?string $value, DataContainer $dc): string|null
{
switch ($dc->activeRecord->type) {
case 'mmenu':
Expand Down
8 changes: 5 additions & 3 deletions src/FrontendModule/MmenuCustomModule.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* This file is part of the ContaoMmenuBundle.
*
* (c) Dirk Klemmt
* (c) inspiredminds
* (c) INSPIRED MINDS
*
* @license MIT
*/
Expand All @@ -19,6 +19,8 @@

class MmenuCustomModule extends ModuleCustomnav
{
use MmenuFrontendModuleTrait;

/**
* Template.
*
Expand All @@ -36,14 +38,14 @@ class MmenuCustomModule extends ModuleCustomnav
*/
public function generate(): string
{
if (TL_MODE === 'BE') {
if ($this->isBackend()) {
// --- create BE template for mmenu module
$template = new BackendTemplate('be_wildcard');
$template->wildcard = '### '.mb_strtoupper($GLOBALS['TL_LANG']['FMD']['mmenu'][0]).' ###';
$template->title = $this->headline;
$template->id = $this->id;
$template->link = $this->name;
$template->href = 'contao/main.php?do=themes&amp;table=tl_module&amp;act=edit&amp;id='.$this->id;
$template->href = $this->getBackendUrl();

return $template->parse();
}
Expand Down
Loading

0 comments on commit 6cc8509

Please sign in to comment.