Initial commit

This commit is contained in:
2018-04-02 08:07:38 +02:00
commit 7330c1ed3e
2054 changed files with 405203 additions and 0 deletions

View File

@@ -0,0 +1,54 @@
<?php
namespace FluidTYPO3\Vhs\ViewHelpers\Extension;
/*
* This file is part of the FluidTYPO3/Vhs project under GPLv2 or later.
*
* For the full copyright and license information, please read the
* LICENSE.md file that was distributed with this source code.
*/
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper;
/**
* Base class: Extension ViewHelpers
*
* @author Claus Due <claus@namelesscoder.net>
* @package Vhs
* @subpackage ViewHelpers\Extension
*/
abstract class AbstractExtensionViewHelper extends AbstractViewHelper {
/**
* @return void
*/
public function initializeArguments() {
$this->registerArgument('extensionName', 'string', 'Name, in UpperCamelCase, of the extension to be checked', FALSE, NULL, TRUE);
}
/**
* @return string
*/
protected function getExtensionKey() {
$extensionName = $this->getExtensionName();
return GeneralUtility::camelCaseToLowerCaseUnderscored($extensionName);
}
/**
* @throws \RuntimeException
* @return mixed
*/
protected function getExtensionName() {
if (TRUE === isset($this->arguments['extensionName']) && FALSE === empty($this->arguments['extensionName'])) {
return $this->arguments['extensionName'];
}
$request = $this->controllerContext->getRequest();
$extensionName = $request->getControllerExtensionName();
if (TRUE === empty($extensionName)) {
throw new \RuntimeException('Unable to read extension name from ControllerContext and value not manually specified', 1364167519);
}
return $extensionName;
}
}

View File

@@ -0,0 +1,35 @@
<?php
namespace FluidTYPO3\Vhs\ViewHelpers\Extension;
/*
* This file is part of the FluidTYPO3/Vhs project under GPLv2 or later.
*
* For the full copyright and license information, please read the
* LICENSE.md file that was distributed with this source code.
*/
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
/**
* ### Extension: Icon ViewHelper
*
* Outputs the icon of the extension key. Supports both
* extension key and extension name arguments.
*
* @author Claus Due <claus@namelesscoder.net>
* @package Vhs
* @subpackage ViewHelpers\Extension
*/
class IconViewHelper extends AbstractExtensionViewHelper {
/**
* Render method
*
* @return string
*/
public function render() {
$extensionKey = $this->getExtensionKey();
return ExtensionManagementUtility::extPath($extensionKey, 'ext_icon.gif');
}
}

View File

@@ -0,0 +1,58 @@
<?php
namespace FluidTYPO3\Vhs\ViewHelpers\Extension;
/*
* This file is part of the FluidTYPO3/Vhs project under GPLv2 or later.
*
* For the full copyright and license information, please read the
* LICENSE.md file that was distributed with this source code.
*/
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Fluid\Core\ViewHelper\AbstractConditionViewHelper;
use FluidTYPO3\Vhs\Traits\ConditionViewHelperTrait;
/**
* ### Extension: Loaded (Condition) ViewHelper
*
* Condition to check if an extension is loaded.
*
* ### Example:
*
* {v:extension.loaded(extensionName: 'news', then: 'yes', else: 'no')}
*
* <v:extension.loaded extensionName="news">
* ...
* </v:extension.loaded>
*
* @author Claus Due <claus@namelesscoder.net>
* @package Vhs
* @subpackage ViewHelpers\Extension
*/
class LoadedViewHelper extends AbstractConditionViewHelper {
use ConditionViewHelperTrait;
/**
* Initialize arguments
*/
public function initializeArguments() {
parent::initializeArguments();
$this->registerArgument('extensionName', 'string', 'Name of extension that must be loaded in order to evaluate as TRUE, UpperCamelCase', TRUE);
}
/**
* This method decides if the condition is TRUE or FALSE. It can be overriden in extending viewhelpers to adjust functionality.
*
* @param array $arguments ViewHelper arguments to evaluate the condition for this ViewHelper, allows for flexiblity in overriding this method.
* @return bool
*/
static protected function evaluateCondition($arguments = NULL) {
$extensionName = $arguments['extensionName'];
$extensionKey = GeneralUtility::camelCaseToLowerCaseUnderscored($extensionName);
$isLoaded = ExtensionManagementUtility::isLoaded($extensionKey);
return TRUE === $isLoaded;
}
}

View File

@@ -0,0 +1,43 @@
<?php
namespace FluidTYPO3\Vhs\ViewHelpers\Extension\Path;
/*
* This file is part of the FluidTYPO3/Vhs project under GPLv2 or later.
*
* For the full copyright and license information, please read the
* LICENSE.md file that was distributed with this source code.
*/
use FluidTYPO3\Vhs\ViewHelpers\Extension\AbstractExtensionViewHelper;
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
/**
* ### Path: Absolute Extension Folder Path
*
* Returns the absolute path to an extension folder.
*
* @author Claus Due <claus@namelesscoder.net>
* @package Vhs
* @subpackage ViewHelpers\Extension\Path
*/
class AbsoluteViewHelper extends AbstractExtensionViewHelper {
/**
* @return void
*/
public function initializeArguments() {
parent::initializeArguments();
$this->registerArgument('path', 'string', 'Optional path to append, second argument when calling \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath');
}
/**
* Render method
*
* @return string
*/
public function render() {
$extensionKey = $this->getExtensionKey();
return ExtensionManagementUtility::extPath($extensionKey, TRUE === isset($this->arguments['path']) ? $this->arguments['path'] : NULL);
}
}

View File

@@ -0,0 +1,35 @@
<?php
namespace FluidTYPO3\Vhs\ViewHelpers\Extension\Path;
/*
* This file is part of the FluidTYPO3/Vhs project under GPLv2 or later.
*
* For the full copyright and license information, please read the
* LICENSE.md file that was distributed with this source code.
*/
use FluidTYPO3\Vhs\ViewHelpers\Extension\AbstractExtensionViewHelper;
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
/**
* ### Path: Relative Extension Folder Path
*
* Returns the relative path to an Extension folder.
*
* @author Claus Due <claus@namelesscoder.net>
* @package Vhs
* @subpackage ViewHelpers\Extension\Path
*/
class RelativeViewHelper extends AbstractExtensionViewHelper {
/**
* Render method
*
* @return string
*/
public function render() {
$extensionKey = $this->getExtensionKey();
return ExtensionManagementUtility::extRelPath($extensionKey);
}
}

View File

@@ -0,0 +1,44 @@
<?php
namespace FluidTYPO3\Vhs\ViewHelpers\Extension\Path;
/*
* This file is part of the FluidTYPO3/Vhs project under GPLv2 or later.
*
* For the full copyright and license information, please read the
* LICENSE.md file that was distributed with this source code.
*/
use FluidTYPO3\Vhs\ViewHelpers\Extension\AbstractExtensionViewHelper;
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
/**
* ### Path: Relative Extension Resource Path
*
* Site Relative path to Extension Resources/Public folder.
*
* @author Claus Due <claus@namelesscoder.net>
* @package Vhs
* @subpackage ViewHelpers\Extension\Path
*/
class ResourcesViewHelper extends AbstractExtensionViewHelper {
/**
* @return void
*/
public function initializeArguments() {
parent::initializeArguments();
$this->registerArgument('path', 'string', 'Optional path to append after output of \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extRelPath');
}
/**
* Render method
*
* @return string
*/
public function render() {
$extensionKey = $this->getExtensionKey();
$path = TRUE === empty($this->arguments['path']) ? '' : $this->arguments['path'];
return ExtensionManagementUtility::extRelPath($extensionKey) . 'Resources/Public/' . $path;
}
}

View File

@@ -0,0 +1,35 @@
<?php
namespace FluidTYPO3\Vhs\ViewHelpers\Extension\Path;
/*
* This file is part of the FluidTYPO3/Vhs project under GPLv2 or later.
*
* For the full copyright and license information, please read the
* LICENSE.md file that was distributed with this source code.
*/
use FluidTYPO3\Vhs\ViewHelpers\Extension\AbstractExtensionViewHelper;
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
/**
* ### Path: Relative Extension Folder Path
*
* Returns the site relative path to an extension folder.
*
* @author Claus Due <claus@namelesscoder.net>
* @package Vhs
* @subpackage ViewHelpers\Extension\Path
*/
class SiteRelativeViewHelper extends AbstractExtensionViewHelper {
/**
* Render method
*
* @return string
*/
public function render() {
$extensionKey = $this->getExtensionKey();
return ExtensionManagementUtility::siteRelPath($extensionKey);
}
}