Skip to content

Commit

Permalink
Merge pull request #31 from a-kehr/controller
Browse files Browse the repository at this point in the history
Umsetzung als Symfony Bundle
  • Loading branch information
denniserdmann authored Jan 7, 2025
2 parents 33175d8 + 41e8977 commit 5dae9f5
Show file tree
Hide file tree
Showing 32 changed files with 500 additions and 430 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/.idea/
/vendor/
/composer.lock
/composer.phar
28 changes: 28 additions & 0 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

$date = date('Y');

$header = <<<EOF
Contao Onepage Navigation for Contao Open Source CMS.
@copyright Copyright (c) $date, Erdmann & Freunde
@author Erdmann & Freunde <https://erdmann-freunde.de>
@license MIT
@link https://github.com/erdmannfreunde/contao-onepage-navigation
EOF;

$finder = (new \PhpCsFixer\Finder())
->in(__DIR__ . '/src');

return (new \PhpCsFixer\Config())
->setRules(
[
'@Symfony' => true,
'header_comment' => [
'header' => $header
],
]
)
->setFinder($finder)
->setUsingCache(false)
->setLineEnding("\r\n");
60 changes: 0 additions & 60 deletions .php_cs.dist

This file was deleted.

21 changes: 18 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,13 @@
},
{
"name":"Erdmann & Freunde // Sebastian Buck",
"homepage":"http://erdmann-freunde.de",
"homepage":"https://erdmann-freunde.de",
"role":"Developer"
},
{
"name": "Kehr Solutions",
"homepage": "https://www.kehr-solutions.de",
"role": "Developer"
}
],
"support":{
Expand All @@ -22,10 +27,13 @@
"source":"https://github.com/ErdmannFreunde/contao-onepage-navigation"
},
"require":{
"contao/core-bundle": "~4.9 || ~5.0"
"php": "^8.2",
"contao/core-bundle": "^5.3"
},
"require-dev": {
"contao/manager-plugin": "^2.0"
"contao/manager-plugin": "^2.0",
"friendsofphp/php-cs-fixer": "^3.64",
"phpstan/phpstan": "^1.12"
},
"replace":{
"sascha-brandhoff/onepage-navigation":"self.version"
Expand All @@ -37,5 +45,12 @@
},
"extra": {
"contao-manager-plugin": "EuF\\OnepageNavigation\\ContaoManager\\ContaoManagerPlugin"
},
"config": {
"allow-plugins": {
"contao-components/installer": true,
"php-http/discovery": true,
"contao/manager-plugin": true
}
}
}
9 changes: 9 additions & 0 deletions config/services.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
services:
_defaults:
autoconfigure: true
autowire: true

EuF\OnepageNavigation\EventListener\InsertTagsListener: ~
EuF\OnepageNavigation\EventListener\GetArticleListener: ~
EuF\OnepageNavigation\Controller\FrontendModule\OnepageNavigationController: ~
EuF\OnepageNavigation\EventListener\DataContainer\GenerateAliasSaveCallback: ~
74 changes: 74 additions & 0 deletions contao/dca/tl_article.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
<?php

declare(strict_types=1);

/*
* Contao Onepage Navigation for Contao Open Source CMS.
*
* @copyright Copyright (c) 2024, Erdmann & Freunde
* @author Erdmann & Freunde <https://erdmann-freunde.de>
* @license MIT
* @link https://github.com/erdmannfreunde/contao-onepage-navigation
*/

use Contao\CoreBundle\DataContainer\PaletteManipulator;

/*
* Palettes
*/
PaletteManipulator::create()
->addLegend('onepage_legend', 'layout_legend', PaletteManipulator::POSITION_BEFORE)
->addField('addNavigation', 'onepage_legend', PaletteManipulator::POSITION_APPEND)
->applyToPalette('default', 'tl_article');

$GLOBALS['TL_DCA']['tl_article']['palettes']['__selector__'][] = 'addNavigation';
$GLOBALS['TL_DCA']['tl_article']['subpalettes']['addNavigation'] = 'navigation_title,navigation_jumpTo';

/*
* Fields
*/
$GLOBALS['TL_DCA']['tl_article']['fields']['addNavigation'] = [
'exclude' => true,
'inputType' => 'checkbox',
'eval' => [
'submitOnChange' => true,
'doNotCopy' => true,
],
'sql' => [
'type' => 'string',
'length' => 1,
'fixed' => true,
'default' => '',
],
];

$GLOBALS['TL_DCA']['tl_article']['fields']['navigation_title'] = [
'exclude' => true,
'inputType' => 'text',
'search' => true,
'eval' => [
'mandatory' => false,
'decodeEntities' => true,
'maxlength' => 255,
'tl_class' => 'w50',
],
'sql' => [
'type' => 'string',
'default' => '',
],
];

$GLOBALS['TL_DCA']['tl_article']['fields']['navigation_jumpTo'] = [
'exclude' => true,
'inputType' => 'text',
'search' => true,
'eval' => [
'maxlength' => 255,
'tl_class' => 'w50',
'rgxp' => 'alias',
],
'sql' => [
'type' => 'string',
'default' => '',
],
];
19 changes: 19 additions & 0 deletions contao/dca/tl_module.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

declare(strict_types=1);

/*
* Contao Onepage Navigation for Contao Open Source CMS.
*
* @copyright Copyright (c) 2024, Erdmann & Freunde
* @author Erdmann & Freunde <https://erdmann-freunde.de>
* @license MIT
* @link https://github.com/erdmannfreunde/contao-onepage-navigation
*/

use EuF\OnepageNavigation\Controller\FrontendModule\OnepageNavigationController;

/*
* Palettes
*/
$GLOBALS['TL_DCA']['tl_module']['palettes'][OnepageNavigationController::TYPE] = '{title_legend},name,headline,type;{reference_legend:hide},defineRoot;{template_legend:hide},customTpl;{protected_legend:hide},protected;{expert_legend:hide},guests,cssID;';
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
/*
* Contao Onepage Navigation for Contao Open Source CMS.
*
* @copyright Copyright (c) 2021, Erdmann & Freunde
* @copyright Copyright (c) 2024, Erdmann & Freunde
* @author Erdmann & Freunde <https://erdmann-freunde.de>
* @license MIT
* @link http://github.com/erdmannfreunde/contao-onepage-navigation
* @link https://github.com/erdmannfreunde/contao-onepage-navigation
*/

/*
Expand Down
24 changes: 24 additions & 0 deletions contao/languages/de/tl_article.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php

declare(strict_types=1);

/*
* Contao Onepage Navigation for Contao Open Source CMS.
*
* @copyright Copyright (c) 2024, Erdmann & Freunde
* @author Erdmann & Freunde <https://erdmann-freunde.de>
* @license MIT
* @link https://github.com/erdmannfreunde/contao-onepage-navigation
*/

/*
* Legends
*/
$GLOBALS['TL_LANG']['tl_article']['onepage_legend'] = 'Onepage-Navigation';

/*
* Fields
*/
$GLOBALS['TL_LANG']['tl_article']['addNavigation'] = ['Als Navigationspunkt hinzufügen', 'Wenn Sie diesen Artikel zur Navigation hinzufügen möchten, aktivieren Sie bitte die Checkbox.'];
$GLOBALS['TL_LANG']['tl_article']['navigation_title'] = ['Navigationtitel', 'Bitte geben Sie den Titel für die Navigation ein, wenn dieser abweichend vom allgemeinen Titel ist.'];
$GLOBALS['TL_LANG']['tl_article']['navigation_jumpTo'] = ['Sprungmarke', 'Hier können Sie eine optionale Bezeichnung der Sprungmarke eingeben. Diese wird nur gesetzt, wenn Sie keine ID festgelegt haben.'];
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
/*
* Contao Onepage Navigation for Contao Open Source CMS.
*
* @copyright Copyright (c) 2021, Erdmann & Freunde
* @copyright Copyright (c) 2024, Erdmann & Freunde
* @author Erdmann & Freunde <https://erdmann-freunde.de>
* @license MIT
* @link http://github.com/erdmannfreunde/contao-onepage-navigation
* @link https://github.com/erdmannfreunde/contao-onepage-navigation
*/

/*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
/*
* Contao Onepage Navigation for Contao Open Source CMS.
*
* @copyright Copyright (c) 2021, Erdmann & Freunde
* @copyright Copyright (c) 2024, Erdmann & Freunde
* @author Erdmann & Freunde <https://erdmann-freunde.de>
* @license MIT
* @link http://github.com/erdmannfreunde/contao-onepage-navigation
* @link https://github.com/erdmannfreunde/contao-onepage-navigation
*/

/*
Expand All @@ -19,6 +19,6 @@
/*
* Fields
*/
$GLOBALS['TL_LANG']['tl_article']['addNavigation'] = ['Add as navigation item', 'If you want to add this article to the navigation check this box.'];
$GLOBALS['TL_LANG']['tl_article']['navigation_title'] = ['Alternative title', 'You can define an optional title to be displayed in the navigation for this item.'];
$GLOBALS['TL_LANG']['tl_article']['addNavigation'] = ['Add as navigation item', 'If you want to add this article to the navigation check this box.'];
$GLOBALS['TL_LANG']['tl_article']['navigation_title'] = ['Alternative title', 'You can define an optional title to be displayed in the navigation for this item.'];
$GLOBALS['TL_LANG']['tl_article']['navigation_jumpTo'] = ['Anchor', 'Define an optional jump to anchor. It will only be used if you did not define a custom ID.'];
Empty file added contao/templates/.twig-root
Empty file.
15 changes: 15 additions & 0 deletions contao/templates/frontend_module/onepage_navigation.html.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{% extends '@Contao/frontend_module/_base.html.twig' %}

{% set searchable = false %}

{% block content %}
{% if hasItems %}
<ul class="level_1">
{% for item in navigation %}
<li{% if item.css is defined %} class="{{ item.css }}"{% endif %} data-onepage-link="{{ item.navigation_jumpTo }}">
<a href="{{ item.onepage_jump }}" data-onepage-link="{{ item.navigation_jumpTo }}" title="{{ item.title }}">{{ item.title }}</a>
</li>
{% endfor %}
</ul>
{% endif %}
{% endblock %}
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

<script>
(function() {
let list = document.querySelector('.mod_onepage_navigation');
let list = document.querySelector('.module-onepage-navigation');

new Onepage(list, {
'offset': '30', // make navigation active when 30% is visible
Expand Down
19 changes: 19 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
parameters:
level: 6

featureToggles:
alwaysTrueAlwaysReported: false
detectDeadTypeInMultiCatch: false
disableCheckMissingIterableValueType: false

universalObjectCratesClasses:
- Contao\Model
- Contao\ArticleModel
- Contao\DataContainer
- Contao\Model\Collection

ignoreErrors:
- identifier: missingType.iterableValue

treatPhpDocTypesAsCertain: false
rememberPossiblyImpureFunctionValues: false
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 5dae9f5

Please sign in to comment.