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,46 @@
<?php
namespace FluidTYPO3\Vhs\ViewHelpers\Condition\Variable;
/*
* 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\Fluid\Core\ViewHelper\AbstractConditionViewHelper;
use FluidTYPO3\Vhs\Traits\ConditionViewHelperTrait;
/**
* ### Condition: Value is NULL
*
* Condition ViewHelper which renders the `then` child if provided
* value is NULL.
*
* @author Björn Fromme <fromme@dreipunktnull.com>, dreipunktnull
* @package Vhs
* @subpackage ViewHelpers\If\Var
*/
class IsNullViewHelper extends AbstractConditionViewHelper {
use ConditionViewHelperTrait;
/**
* Initialize arguments
*/
public function initializeArguments() {
parent::initializeArguments();
$this->registerArgument('value', 'string', 'value to check', 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) {
return NULL === $arguments['value'];
}
}

View File

@@ -0,0 +1,88 @@
<?php
namespace FluidTYPO3\Vhs\ViewHelpers\Condition\Variable;
/*
* 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\Fluid\Core\Rendering\RenderingContextInterface;
use TYPO3\CMS\Fluid\Core\ViewHelper\AbstractConditionViewHelper;
use FluidTYPO3\Vhs\Traits\ConditionViewHelperTrait;
/**
* ### Variable: Isset
*
* Renders the `then` child if the variable name given in
* the `name` argument exists in the template. The value
* can be zero, NULL or an empty string - but the ViewHelper
* will still return TRUE if the variable exists.
*
* Combines well with dynamic variable names:
*
* <!-- if {variableContainingVariableName} is "foo" this checks existence of {foo} -->
* <v:condition.variable.isset name="{variableContainingVariableName}">...</v:condition.variable.isset>
* <!-- if {suffix} is "Name" this checks existence of "variableName" -->
* <v:condition.variable.isset name="variable{suffix}">...</v:condition.variable.isset>
* <!-- outputs value of {foo} if {bar} is defined -->
* {foo -> v:condition.variable.isset(name: bar)}
*
* @author Claus Due <claus@namelesscoder.net>
* @package Vhs
* @subpackage ViewHelpers\Condition\Variable
*/
class IssetViewHelper extends AbstractConditionViewHelper {
use ConditionViewHelperTrait;
/**
* Initialize arguments
*/
public function initializeArguments() {
parent::initializeArguments();
$this->registerArgument('name', 'string', 'name of the variable', TRUE);
}
/**
* Render
*
* @return string
*/
public function render() {
return static::renderStatic(
$this->arguments,
$this->buildRenderChildrenClosure(),
$this->renderingContext
);
}
/**
* Default implementation for use in compiled templates
*
* @param array $arguments
* @param \Closure $renderChildrenClosure
* @param \TYPO3\CMS\Fluid\Core\Rendering\RenderingContextInterface $renderingContext
* @return mixed
*/
static public function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext) {
$hasEvaluated = TRUE;
if (TRUE === $renderingContext->getTemplateVariableContainer()->exists($arguments['name'])) {
$result = static::renderStaticThenChild($arguments, $hasEvaluated);
if ($hasEvaluated) {
return $result;
}
return $renderChildrenClosure();
} else {
$result = static::renderStaticElseChild($arguments, $hasEvaluated);
if ($hasEvaluated) {
return $result;
}
}
return '';
}
}