Compare commits

..

No commits in common. "master" and "1.1.0" have entirely different histories.

11 changed files with 146 additions and 343 deletions

View 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();
}

View 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;
}
}

View 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');
});
}
}

View file

@ -0,0 +1,38 @@
<?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();
}
}
?>

View file

@ -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;
}

View file

@ -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);
}
}

View file

@ -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');
}
);
}
}

View file

@ -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();
}
}

View file

@ -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();
}
}

View file

@ -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.

View file

@ -1,83 +1,21 @@
{ {
"name": "digicomp/menu", "name":"digicomp/menu",
"description": "Helps with the creation of simple fluid based menus", "type":"typo3-flow-package",
"type": "neos-package", "description":"Menu",
"keywords": [ "require":{
"Neos", "typo3/flow":"~2.0|~3.0"
"Flow", },
"menu" "require-dev":{
], "phpunit/phpunit": "3.7.*"
"homepage": "https://git.digital-competence.de/Packages/DigiComp.Menu", },
"license": "MIT", "autoload":{
"authors": [ "psr-0":{
{ "DigiComp\\Menu":"Classes"
"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": { "extra": {
"branch-alias": { "branch-alias": {
"dev-develop": "3.0.x-dev", "dev-master": "1.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"
]
} }
} }