Compare commits
No commits in common. "master" and "1.0.0" have entirely different histories.
11 changed files with 138 additions and 343 deletions
15
Classes/DigiComp/Menu/MenuService/ServiceInterface.php
Normal file
15
Classes/DigiComp/Menu/MenuService/ServiceInterface.php
Normal file
|
@ -0,0 +1,15 @@
|
|||
<?php
|
||||
namespace DigiComp\Menu\MenuService;
|
||||
/* *
|
||||
* This script belongs to the FLOW3 package "DigiComp.Controls". *
|
||||
* *
|
||||
* */
|
||||
|
||||
/**
|
||||
* Interface for Menu-Configuration
|
||||
*/
|
||||
interface ServiceInterface {
|
||||
|
||||
public function getItems();
|
||||
|
||||
}
|
53
Classes/DigiComp/Menu/MenuService/SettingsService.php
Normal file
53
Classes/DigiComp/Menu/MenuService/SettingsService.php
Normal file
|
@ -0,0 +1,53 @@
|
|||
<?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;
|
||||
}
|
||||
|
||||
|
||||
}
|
25
Classes/DigiComp/Menu/Package.php
Normal file
25
Classes/DigiComp/Menu/Package.php
Normal file
|
@ -0,0 +1,25 @@
|
|||
<?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');
|
||||
});
|
||||
}
|
||||
|
||||
}
|
30
Classes/DigiComp/Menu/ViewHelpers/MenuViewHelper.php
Normal file
30
Classes/DigiComp/Menu/ViewHelpers/MenuViewHelper.php
Normal file
|
@ -0,0 +1,30 @@
|
|||
<?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 {
|
||||
|
||||
/**
|
||||
* @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();
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
|
@ -1,26 +0,0 @@
|
|||
<?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;
|
||||
}
|
|
@ -1,50 +0,0 @@
|
|||
<?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);
|
||||
}
|
||||
}
|
|
@ -1,37 +0,0 @@
|
|||
<?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');
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
|
@ -1,54 +0,0 @@
|
|||
<?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();
|
||||
}
|
||||
}
|
|
@ -1,80 +0,0 @@
|
|||
<?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
19
License.txt
|
@ -1,19 +0,0 @@
|
|||
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,83 +1,21 @@
|
|||
{
|
||||
"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"
|
||||
"name":"digicomp/menu",
|
||||
"type":"typo3-flow-package",
|
||||
"description":"Menu",
|
||||
"require":{
|
||||
"typo3/flow":"~2.0"
|
||||
},
|
||||
"require-dev":{
|
||||
"phpunit/phpunit": "3.7.*"
|
||||
},
|
||||
"autoload":{
|
||||
"psr-0":{
|
||||
"DigiComp\\Menu":"Classes"
|
||||
}
|
||||
],
|
||||
"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-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"
|
||||
]
|
||||
"dev-master": "1.0.x-dev"
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue