Compare commits
45 commits
Author | SHA1 | Date | |
---|---|---|---|
c03377c974 | |||
![]() |
f4d3da82a6 | ||
![]() |
e8ea04f323 | ||
f54dded1e0 | |||
b77e4f391b | |||
![]() |
5cbd1340cd | ||
![]() |
3a08a677bd | ||
![]() |
bb648cee60 | ||
![]() |
277835311c | ||
f32f995f43 | |||
13206fec9a | |||
5baf0c080c | |||
07233f7750 | |||
68e35595f3 | |||
6b3f24b0ee | |||
27bfb049f3 | |||
6339e96084 | |||
e436e722c1 | |||
893e6b313a | |||
ac808d34d6 | |||
![]() |
892d2613c4 | ||
![]() |
2d7249922a | ||
![]() |
6beae6f7b3 | ||
9e4380c524 | |||
8c71d9ac07 | |||
8a4dcc589b | |||
7f5432e855 | |||
91e8899a37 | |||
f6e8617fdf | |||
caeb6e4b0c | |||
39e0a9e96a | |||
ec7d8be5d4 | |||
02d8a07173 | |||
614a0fe2cc | |||
e2ec22acf2 | |||
48e535fd36 | |||
7af6a08fef | |||
83115a5fef | |||
a423c660bb | |||
2b82c48b74 | |||
e11c20606f | |||
a63fa594d2 | |||
0f3b19ba49 | |||
f7af3e1024 | |||
9ea0c863dd |
11 changed files with 343 additions and 146 deletions
|
@ -1,15 +0,0 @@
|
|||
<?php
|
||||
namespace DigiComp\Menu\MenuService;
|
||||
/* *
|
||||
* This script belongs to the FLOW3 package "DigiComp.Controls". *
|
||||
* *
|
||||
* */
|
||||
|
||||
/**
|
||||
* Interface for Menu-Configuration
|
||||
*/
|
||||
interface ServiceInterface {
|
||||
|
||||
public function getItems();
|
||||
|
||||
}
|
|
@ -1,53 +0,0 @@
|
|||
<?php
|
||||
namespace DigiComp\Menu\MenuService;
|
||||
/* *
|
||||
* This script belongs to the FLOW3 package "DigiComp.Controls". *
|
||||
* *
|
||||
* */
|
||||
|
||||
use TYPO3\Flow\Annotations as Flow;
|
||||
use TYPO3\Flow\Configuration\ConfigurationManager;
|
||||
|
||||
/**
|
||||
* Class Menu
|
||||
* @package DigiComp\Menu\Menu
|
||||
*
|
||||
* @Flow\Scope("singleton")
|
||||
*/
|
||||
class SettingsService implements ServiceInterface {
|
||||
/**
|
||||
* @var \TYPO3\Flow\Configuration\ConfigurationManager
|
||||
*/
|
||||
protected $configurationManager;
|
||||
public function injectConfigurationManager(ConfigurationManager $configurationManager) {
|
||||
$this->configurationManager = $configurationManager;
|
||||
$this->menu = $this->configurationManager->getConfiguration('Menu');
|
||||
}
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $menu;
|
||||
|
||||
protected $items = array();
|
||||
|
||||
/**
|
||||
* @param string $forMenu
|
||||
* @return array
|
||||
*/
|
||||
public function getItems($forMenu = NULL) {
|
||||
if ($forMenu){
|
||||
$items = &$this->menu[$forMenu];
|
||||
}else {
|
||||
$items = &$this->menu;
|
||||
}
|
||||
if ($items) {
|
||||
uasort($items, function ($a, $b) {
|
||||
return $a['sorting'] > $b['sorting'];
|
||||
});
|
||||
}
|
||||
return $items;
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -1,25 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* @author skoetzing
|
||||
* @date 07.07.14
|
||||
*/
|
||||
|
||||
namespace DigiComp\Menu;
|
||||
use TYPO3\Flow\Core\Bootstrap;
|
||||
use TYPO3\Flow\Package\Package as BasePackage;
|
||||
use TYPO3\Flow\Annotations as Flow;
|
||||
use TYPO3\Flow\Configuration\ConfigurationManager;
|
||||
|
||||
class Package extends BasePackage{
|
||||
|
||||
public function boot(Bootstrap $bootstrap){
|
||||
parent::boot($bootstrap);
|
||||
|
||||
$dispatcher = $bootstrap->getSignalSlotDispatcher();
|
||||
$dispatcher->connect('TYPO3\Flow\Configuration\ConfigurationManager', 'configurationManagerReady',
|
||||
function(ConfigurationManager $configurationManager){
|
||||
$configurationManager->registerConfigurationType('Menu');
|
||||
});
|
||||
}
|
||||
|
||||
}
|
|
@ -1,38 +0,0 @@
|
|||
<?php
|
||||
namespace DigiComp\Menu\ViewHelpers;
|
||||
/* *
|
||||
* This script belongs to the FLOW3 package "DigiComp.Controls". *
|
||||
* *
|
||||
* */
|
||||
use TYPO3\Flow\Annotations as Flow;
|
||||
/**
|
||||
* Renders the sum of given collection and property name
|
||||
*/
|
||||
class MenuViewHelper extends \TYPO3\Fluid\Core\ViewHelper\AbstractViewHelper {
|
||||
|
||||
|
||||
/**
|
||||
* NOTE: This property has been introduced via code migration to ensure backwards-compatibility.
|
||||
* @see AbstractViewHelper::isOutputEscapingEnabled()
|
||||
* @var boolean
|
||||
*/
|
||||
protected $escapeOutput = FALSE;
|
||||
|
||||
/**
|
||||
* @var \DigiComp\Menu\MenuService\ServiceInterface
|
||||
* @Flow\Inject
|
||||
*/
|
||||
protected $menuService;
|
||||
|
||||
/**
|
||||
* @param string $as
|
||||
* @param string $forPath
|
||||
* @return mixed
|
||||
*/
|
||||
public function render($as = 'menuItems', $forPath = NULL) {
|
||||
$this->templateVariableContainer->add($as, $this->menuService->getItems($forPath));
|
||||
return $this->renderChildren();
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
26
Classes/MenuService/ServiceInterface.php
Normal file
26
Classes/MenuService/ServiceInterface.php
Normal file
|
@ -0,0 +1,26 @@
|
|||
<?php
|
||||
|
||||
namespace DigiComp\Menu\MenuService;
|
||||
|
||||
/*
|
||||
* This file is part of the DigiComp.Menu package.
|
||||
*
|
||||
* (c) digital competence
|
||||
*
|
||||
* This package is Open Source Software. For the full copyright and license
|
||||
* information, please view the LICENSE file which was distributed with this
|
||||
* source code.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Interface for Menu-Configuration
|
||||
*/
|
||||
interface ServiceInterface
|
||||
{
|
||||
/**
|
||||
* @param string|null $forPath
|
||||
*
|
||||
* @return \Iterator
|
||||
*/
|
||||
public function getItems(string $forPath = null): \Iterator;
|
||||
}
|
50
Classes/MenuService/SettingsService.php
Normal file
50
Classes/MenuService/SettingsService.php
Normal file
|
@ -0,0 +1,50 @@
|
|||
<?php
|
||||
|
||||
namespace DigiComp\Menu\MenuService;
|
||||
|
||||
/*
|
||||
* This file is part of the DigiComp.Menu package.
|
||||
*
|
||||
* (c) digital competence
|
||||
*
|
||||
* This package is Open Source Software. For the full copyright and license
|
||||
* information, please view the LICENSE file which was distributed with this
|
||||
* source code.
|
||||
*/
|
||||
|
||||
use Neos\Flow\Annotations as Flow;
|
||||
|
||||
/**
|
||||
* @Flow\Scope("singleton")
|
||||
*/
|
||||
class SettingsService implements ServiceInterface
|
||||
{
|
||||
/**
|
||||
* @Flow\InjectConfiguration(type="Menu")
|
||||
* @var array
|
||||
*/
|
||||
protected array $menuConfiguration;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected array $items = [];
|
||||
|
||||
public function getItems(string $forPath = null): \Iterator
|
||||
{
|
||||
if ($forPath) {
|
||||
$items = &$this->menuConfiguration[$forPath];
|
||||
} else {
|
||||
$items = &$this->menuConfiguration;
|
||||
}
|
||||
if ($items) {
|
||||
\uasort(
|
||||
$items,
|
||||
static function ($a, $b) {
|
||||
return $a['sorting'] > $b['sorting'];
|
||||
}
|
||||
);
|
||||
}
|
||||
return new \ArrayIterator($items);
|
||||
}
|
||||
}
|
37
Classes/Package.php
Normal file
37
Classes/Package.php
Normal file
|
@ -0,0 +1,37 @@
|
|||
<?php
|
||||
|
||||
namespace DigiComp\Menu;
|
||||
|
||||
/*
|
||||
* This file is part of the DigiComp.Menu package.
|
||||
*
|
||||
* (c) digital competence
|
||||
*
|
||||
* This package is Open Source Software. For the full copyright and license
|
||||
* information, please view the LICENSE file which was distributed with this
|
||||
* source code.
|
||||
*/
|
||||
|
||||
use Neos\Flow\Configuration\ConfigurationManager;
|
||||
use Neos\Flow\Core\Bootstrap;
|
||||
use Neos\Flow\Package\Package as BasePackage;
|
||||
|
||||
/**
|
||||
* Package base class of the DigiComp.Menu package.
|
||||
*/
|
||||
class Package extends BasePackage
|
||||
{
|
||||
public function boot(Bootstrap $bootstrap)
|
||||
{
|
||||
parent::boot($bootstrap);
|
||||
|
||||
$dispatcher = $bootstrap->getSignalSlotDispatcher();
|
||||
$dispatcher->connect(
|
||||
ConfigurationManager::class,
|
||||
'configurationManagerReady',
|
||||
function (ConfigurationManager $configurationManager) {
|
||||
$configurationManager->registerConfigurationType('Menu');
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
54
Classes/ViewHelpers/ItemsViewHelper.php
Normal file
54
Classes/ViewHelpers/ItemsViewHelper.php
Normal file
|
@ -0,0 +1,54 @@
|
|||
<?php
|
||||
|
||||
namespace DigiComp\Menu\ViewHelpers;
|
||||
|
||||
/*
|
||||
* This file is part of the DigiComp.Menu package.
|
||||
*
|
||||
* (c) digital competence
|
||||
*
|
||||
* This package is Open Source Software. For the full copyright and license
|
||||
* information, please view the LICENSE file which was distributed with this
|
||||
* source code.
|
||||
*/
|
||||
|
||||
use DigiComp\Menu\MenuService\ServiceInterface;
|
||||
use Neos\Flow\Annotations as Flow;
|
||||
use Neos\FluidAdaptor\Core\ViewHelper\AbstractViewHelper;
|
||||
use Neos\FluidAdaptor\Core\ViewHelper\Exception;
|
||||
|
||||
/**
|
||||
* Just adds the return of MenuService
|
||||
* TODO: Write example
|
||||
*/
|
||||
class ItemsViewHelper extends AbstractViewHelper
|
||||
{
|
||||
protected $escapeOutput = false;
|
||||
|
||||
/**
|
||||
* @Flow\Inject
|
||||
* @var ServiceInterface
|
||||
*/
|
||||
protected $menuService;
|
||||
|
||||
/**
|
||||
* @throws Exception
|
||||
*/
|
||||
public function initializeArguments(): void
|
||||
{
|
||||
$this->registerArgument('for', 'string', 'path in Menu.yaml', false);
|
||||
$this->registerArgument('as', 'string', 'Name in Frontend', false);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
$this->templateVariableContainer->add(
|
||||
$this->arguments['as'],
|
||||
$this->menuService->getItems($this->arguments['for'])
|
||||
);
|
||||
return $this->renderChildren();
|
||||
}
|
||||
}
|
80
Classes/ViewHelpers/ProgressViewHelper.php
Normal file
80
Classes/ViewHelpers/ProgressViewHelper.php
Normal file
|
@ -0,0 +1,80 @@
|
|||
<?php
|
||||
|
||||
namespace DigiComp\Menu\ViewHelpers;
|
||||
|
||||
/*
|
||||
* This file is part of the DigiComp.Menu package.
|
||||
*
|
||||
* (c) digital competence
|
||||
*
|
||||
* This package is Open Source Software. For the full copyright and license
|
||||
* information, please view the LICENSE file which was distributed with this
|
||||
* source code.
|
||||
*/
|
||||
|
||||
use Neos\FluidAdaptor\Core\ViewHelper\AbstractViewHelper;
|
||||
use Neos\FluidAdaptor\Core\ViewHelper\Exception;
|
||||
|
||||
/**
|
||||
* Helps to get useful template variables for process menus
|
||||
*/
|
||||
class ProgressViewHelper extends AbstractViewHelper
|
||||
{
|
||||
protected $escapeOutput = false;
|
||||
|
||||
/**
|
||||
* @throws Exception
|
||||
*/
|
||||
public function initializeArguments(): void
|
||||
{
|
||||
$this->registerArgument('for', 'string', 'path in Menu.yaml', false);
|
||||
$this->registerArgument('as', 'string', 'Name in Frontend', false);
|
||||
$this->registerArgument('links', 'array', 'links to show', true);
|
||||
$this->registerArgument('activeStep', 'int', 'current active link index', false, 1);
|
||||
$this->registerArgument('returnable', 'bool', 'can you go back to the last index', false, true);
|
||||
$this->registerArgument('stepsAs', 'string', 'variable name of a single step', false, 'steps');
|
||||
$this->registerArgument('backLinkAs', 'string', 'variable name of a backlink', false, 'backLink');
|
||||
$this->registerArgument('linksAs', 'string', 'variable name of the links array', false, 'links');
|
||||
$this->registerArgument(
|
||||
'activeStepLinkAs',
|
||||
'string',
|
||||
'variable name of the active step link',
|
||||
false,
|
||||
'activeStepLink'
|
||||
);
|
||||
$this->registerArgument('offset', 'int', 'offset to start with', false, 1);
|
||||
$this->registerArgument('linkCount', 'int', 'force this number of steps', false);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
$links = $activeStep = $returnable = $stepsAs = $backLinkAs = $activeStepAs = $linksAs =
|
||||
$activeStepLinkAs = $offset = $linkCount = null;
|
||||
\extract($this->arguments, \EXTR_OVERWRITE);
|
||||
//handling famous off by one
|
||||
$activeStep -= $offset;
|
||||
//make sure our array index is numeric
|
||||
if (\is_iterable($links)) {
|
||||
$links = \iterator_to_array($links);
|
||||
}
|
||||
$links = \array_values($links);
|
||||
if (!$linkCount) {
|
||||
$linkCount = \count($links);
|
||||
}
|
||||
foreach ($links as $i => &$link) {
|
||||
$link['completed'] = $activeStep > $i;
|
||||
$link['returnable'] = $returnable && $i < $activeStep;
|
||||
}
|
||||
$this->templateVariableContainer->add($linksAs, $links);
|
||||
$this->templateVariableContainer->add($stepsAs, $linkCount);
|
||||
$this->templateVariableContainer->add($activeStepAs, $activeStep + $offset);
|
||||
$this->templateVariableContainer->add($activeStepLinkAs, $links[$activeStep]);
|
||||
if (isset($links[$activeStep - 1])) {
|
||||
$this->templateVariableContainer->add($backLinkAs, $links[$activeStep - 1]);
|
||||
}
|
||||
return $this->renderChildren();
|
||||
}
|
||||
}
|
19
License.txt
Normal file
19
License.txt
Normal file
|
@ -0,0 +1,19 @@
|
|||
Copyright (c) 2021 Ferdinand Kuhl <f.kuhl@digital-competence.de>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
|
@ -1,21 +1,83 @@
|
|||
{
|
||||
"name":"digicomp/menu",
|
||||
"type":"typo3-flow-package",
|
||||
"description":"Menu",
|
||||
"require":{
|
||||
"typo3/flow":"~2.0|~3.0"
|
||||
},
|
||||
"require-dev":{
|
||||
"phpunit/phpunit": "3.7.*"
|
||||
},
|
||||
"autoload":{
|
||||
"psr-0":{
|
||||
"DigiComp\\Menu":"Classes"
|
||||
"name": "digicomp/menu",
|
||||
"description": "Helps with the creation of simple fluid based menus",
|
||||
"type": "neos-package",
|
||||
"keywords": [
|
||||
"Neos",
|
||||
"Flow",
|
||||
"menu"
|
||||
],
|
||||
"homepage": "https://git.digital-competence.de/Packages/DigiComp.Menu",
|
||||
"license": "MIT",
|
||||
"authors": [
|
||||
{
|
||||
"name": "Ferdinand Kuhl",
|
||||
"email": "f.kuhl@digital-competence.de",
|
||||
"homepage": "https://www.digital-competence.de",
|
||||
"role": "Developer"
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"php": ">=7.4.0",
|
||||
"neos/flow": "^6.3.21"
|
||||
},
|
||||
"require-dev": {
|
||||
"mikey179/vfsstream": "^1.6.1",
|
||||
"neos/buildessentials": "^7.0.0",
|
||||
"phpunit/phpunit": "~8.5",
|
||||
"vimeo/psalm": "~4.22.0"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"DigiComp\\Menu\\": "Classes/"
|
||||
}
|
||||
},
|
||||
"config": {
|
||||
"sort-packages": true,
|
||||
"platform-check": true
|
||||
},
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.0.x-dev"
|
||||
}
|
||||
"dev-develop": "3.0.x-dev",
|
||||
"dev-version/2.x-dev": "2.0.x-dev"
|
||||
},
|
||||
"neos": {
|
||||
"package-key": "DigiComp.Menu"
|
||||
},
|
||||
"applied-flow-migrations": [
|
||||
"TYPO3.Fluid-20150214130800",
|
||||
"TYPO3.Fluid-20141121091700",
|
||||
"TYPO3.Flow-20141113121400",
|
||||
"TYPO3.Fluid-20141113120800",
|
||||
"TYPO3.Flow-201405111147",
|
||||
"TYPO3.Flow-201310031523",
|
||||
"TYPO3.Flow-201212051340",
|
||||
"TYPO3.Flow-201211151101",
|
||||
"TYPO3.Flow-201209251426",
|
||||
"TYPO3.FLOW3-201209201112",
|
||||
"TYPO3.FLOW3-201206271128",
|
||||
"TYPO3.FLOW3-201205292145",
|
||||
"TYPO3.Fluid-201205031303",
|
||||
"TYPO3.FLOW3-201201261636",
|
||||
"DigiComp.Excel-201308011951",
|
||||
"Inwebs.Basket-201409170938",
|
||||
"TYPO3.Flow-20151113161300",
|
||||
"TYPO3.Flow-20161115140400",
|
||||
"TYPO3.Flow-20161115140430",
|
||||
"Neos.Flow-20161124204700",
|
||||
"Neos.Flow-20161124204701",
|
||||
"Neos.Flow-20161124224015",
|
||||
"Neos.Eel-20161124230101",
|
||||
"Neos.Imagine-20161124231742",
|
||||
"Neos.Media-20161124233100",
|
||||
"Neos.Flow-20161125124112",
|
||||
"Neos.SwiftMailer-20161130105617",
|
||||
"TYPO3.FluidAdaptor-20161130112935",
|
||||
"Neos.Media-20161219094126",
|
||||
"Neos.Flow-20170125103800",
|
||||
"Neos.Flow-20170127183102",
|
||||
"DigiComp.SettingValidator-20170603120900",
|
||||
"Neos.Flow-20180415105700"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue