Skip to content

Commit

Permalink
Merge branch 'staging'
Browse files Browse the repository at this point in the history
  • Loading branch information
NamelessCoder committed Jan 9, 2019
2 parents 54143df + d678a3b commit 6ccd453
Show file tree
Hide file tree
Showing 27 changed files with 244 additions and 100 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
Latest release: 5.1.0 (2018/10/02)
Latest release: 5.1.1 (2019/01/09)

All previous release change logs:

* [5.1.1 (2019/01/09)](Documentation/Changelog/5.1.1.md) [Full list of changes](https://github.com/FluidTYPO3/vhs/compare/5.1.0...5.1.1)
* [5.1.0 (2018/10/02)](Documentation/Changelog/5.1.0.md) [Full list of changes](https://github.com/FluidTYPO3/vhs/compare/5.0.1...5.1.0)
* [5.0.1 (2018/06/21)](Documentation/Changelog/5.0.1.md) [Full list of changes](https://github.com/FluidTYPO3/vhs/compare/5.0.0...5.0.1)
* [5.0.0 (2018/06/19)](Documentation/Changelog/5.0.0.md) [Full list of changes](https://github.com/FluidTYPO3/vhs/compare/4.4.0...5.0.0)
Expand Down
2 changes: 1 addition & 1 deletion Classes/Traits/TagViewHelperTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ protected function renderTag(
$this->tag->addAttributes($attributes);
$this->tag->forceClosingTag($forceClosingTag);
if (null !== $content) {
$this->tag->setContent($content);
$this->tag->setContent($trimmedContent);
}
// process some attributes differently - if empty, remove the property:
foreach ($nonEmptyAttributes as $propertyName) {
Expand Down
2 changes: 1 addition & 1 deletion Classes/Traits/TemplateVariableViewHelperTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ protected static function renderChildrenWithVariableOrReturnInputStatic(
$variables = [$as => $variable];
$content = static::renderChildrenWithVariablesStatic(
$variables,
$renderingContext->getTemplateVariableContainer(),
$renderingContext->getVariableProvider(),
$renderChildrenClosure
);
}
Expand Down
5 changes: 4 additions & 1 deletion Classes/Utility/CoreUtility.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ class CoreUtility
*/
public static function getLanguageFlagIconPath()
{
return ExtensionManagementUtility::extPath('core') . 'Resources/Public/Icons/Flags/SVG/';
if (version_compare(self::getCurrentCoreVersion(), 9.0, '<')) {
return ExtensionManagementUtility::extPath('core') . 'Resources/Public/Icons/Flags/PNG/';
}
return ExtensionManagementUtility::extPath('core') . 'Resources/Public/Icons/Flags/';
}

/**
Expand Down
5 changes: 1 addition & 4 deletions Classes/Utility/ViewHelperUtility.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@ class ViewHelperUtility
*/
public static function getVariableProviderFromRenderingContext(RenderingContextInterface $renderingContext)
{
if (method_exists($renderingContext, 'getVariableProvider')) {
return $renderingContext->getVariableProvider();
}
return $renderingContext->getTemplateVariableContainer();
return $renderingContext->getVariableProvider();
}
}
2 changes: 1 addition & 1 deletion Classes/ViewHelpers/Condition/Context/IsCliViewHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,6 @@ class IsCliViewHelper extends AbstractConditionViewHelper
*/
protected static function evaluateCondition($arguments = null)
{
return defined('TYPO3_climode');
return (bool) (TYPO3_REQUESTTYPE & TYPO3_REQUESTTYPE_CLI);
}
}
18 changes: 17 additions & 1 deletion Classes/ViewHelpers/Condition/Page/IsLanguageViewHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
* LICENSE.md file that was distributed with this source code.
*/

use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Core\Database\Query\QueryBuilder;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Fluid\Core\ViewHelper\AbstractConditionViewHelper;

/**
Expand Down Expand Up @@ -44,7 +47,20 @@ protected static function evaluateCondition($arguments = null)
if (true === is_numeric($language)) {
$languageUid = intval($language);
} else {
$row = $GLOBALS['TYPO3_DB']->exec_SELECTgetSingleRow('uid', 'sys_language', "title='" . $language . "'");
/** @var QueryBuilder $queryBuilder */
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('sys_language');

$queryBuilder->createNamedParameter($language, \PDO::PARAM_STR, ':title');

$row = $queryBuilder
->select('uid')
->from('sys_language')
->where(
$queryBuilder->expr()->eq('title', ':title')
)
->execute()
->fetch();

if (false !== $row) {
$languageUid = intval($row['uid']);
} else {
Expand Down
2 changes: 1 addition & 1 deletion Classes/ViewHelpers/Condition/Variable/IssetViewHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public function render()
protected static function evaluateCondition($arguments = null)
{
$renderingContext = static::$staticRenderingContext;
$variableProvider = method_exists($renderingContext, 'getVariableProvider') ? $renderingContext->getVariableProvider() : $renderingContext->getTemplateVariableContainer();
$variableProvider = $renderingContext->getVariableProvider();
return $variableProvider->exists($arguments['name']);
}

Expand Down
30 changes: 12 additions & 18 deletions Classes/ViewHelpers/Content/AbstractContentViewHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -251,19 +251,16 @@ protected static function renderRecord(array $row)
*/
protected function executeSelectQuery($fields, $condition, $order, $limit)
{
if (class_exists(ConnectionPool::class)) {
$queryBuilder = (new ConnectionPool())->getConnectionForTable('tt_content')->createQueryBuilder();
$queryBuilder->select($fields)->from('tt_content')->where($condition);
if ($order) {
$orderings = explode(' ', $order);
$queryBuilder->orderBy($orderings[0], $orderings[1]);
}
if ($limit) {
$queryBuilder->setMaxResults((integer) $limit);
}
return $queryBuilder->execute()->fetchAll();
$queryBuilder = (new ConnectionPool())->getConnectionForTable('tt_content')->createQueryBuilder();
$queryBuilder->select($fields)->from('tt_content')->where($condition);
if ($order) {
$orderings = explode(' ', $order);
$queryBuilder->orderBy($orderings[0], $orderings[1]);
}
return $GLOBALS['TYPO3_DB']->exec_SELECTgetRows($fields, 'tt_content', $condition, '', $order, $limit);
if ($limit) {
$queryBuilder->setMaxResults((integer) $limit);
}
return $queryBuilder->execute()->fetchAll();
}

/**
Expand All @@ -273,11 +270,8 @@ protected function executeSelectQuery($fields, $condition, $order, $limit)
*/
protected function generateSelectQuery($fields, $condition)
{
if (class_exists(ConnectionPool::class)) {
$queryBuilder = (new ConnectionPool())->getConnectionForTable('tt_content')->createQueryBuilder();
$queryBuilder->select($fields)->from('tt_content')->where($condition);
return $queryBuilder->getSQL();
}
return $GLOBALS['TYPO3_DB']->SELECTquery($fields, 'tt_content', $condition);
$queryBuilder = (new ConnectionPool())->getConnectionForTable('tt_content')->createQueryBuilder();
$queryBuilder->select($fields)->from('tt_content')->where($condition);
return $queryBuilder->getSQL();
}
}
21 changes: 16 additions & 5 deletions Classes/ViewHelpers/Content/InfoViewHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
*/

use FluidTYPO3\Vhs\Traits\TemplateVariableViewHelperTrait;
use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Core\Database\Query\QueryBuilder;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface;
use TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper;

Expand Down Expand Up @@ -80,11 +83,19 @@ public function render()
} else {
$selectFields = '*';
}
$record = $GLOBALS['TYPO3_DB']->exec_SELECTgetSingleRow(
$selectFields,
'tt_content',
sprintf('uid=%d', $contentUid)
);

/** @var QueryBuilder $queryBuilder */
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('tt_content');
$queryBuilder->createNamedParameter($contentUid, \PDO::PARAM_INT, ':uid');

$record = $queryBuilder
->select($selectFields)
->from('tt_content')
->where(
$queryBuilder->expr()->eq('uid', ':uid')
)
->execute()
->fetch();

// Add the page overlay
$languageUid = (integer) $GLOBALS['TSFE']->sys_language_uid;
Expand Down
5 changes: 5 additions & 0 deletions Classes/ViewHelpers/Format/TidyViewHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ class TidyViewHelper extends AbstractViewHelper
{
use CompileWithContentArgumentAndRenderStatic;

/**
* @var boolean
*/
protected $escapeOutput = false;

/**
* @return void
*/
Expand Down
6 changes: 3 additions & 3 deletions Classes/ViewHelpers/Math/DivisionViewHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ protected static function calculateAction($a, $b, array $arguments)
{
$aIsIterable = static::assertIsArrayOrIterator($a);
$bIsIterable = static::assertIsArrayOrIterator($b);
if (false === $aIsIterable && $b === null && (boolean) $arguments['fail']) {
ErrorUtility::throwViewHelperException('Required argument "b" was not supplied', 1237823699);
}
if (true === $aIsIterable && null === $b) {
$a = static::arrayFromArrayOrTraversableOrCSVStatic($a);
$sum = array_sum($a);
Expand All @@ -49,9 +52,6 @@ protected static function calculateAction($a, $b, array $arguments)
}
return $a;
}
if ($b === null && (boolean) $arguments['fail']) {
ErrorUtility::throwViewHelperException('Required argument "b" was not supplied', 1237823699);
}
return (0 <> $b ? $a / $b : $a);
}
}
6 changes: 3 additions & 3 deletions Classes/ViewHelpers/Math/MaximumViewHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,13 @@ public function initializeArguments()
protected static function calculateAction($a, $b, array $arguments)
{
$aIsIterable = static::assertIsArrayOrIterator($a);
if (false === $aIsIterable && $b === null && (boolean) $arguments['fail']) {
ErrorUtility::throwViewHelperException('Required argument "b" was not supplied', 1237823699);
}
if (true === $aIsIterable && null === $b) {
$a = static::arrayFromArrayOrTraversableOrCSVStatic($a);
return max($a);
}
if ($b === null && (boolean) $arguments['fail']) {
ErrorUtility::throwViewHelperException('Required argument "b" was not supplied', 1237823699);
}
return max($a, $b);
}
}
6 changes: 3 additions & 3 deletions Classes/ViewHelpers/Math/MinimumViewHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,13 @@ public function initializeArguments()
protected static function calculateAction($a, $b, array $arguments)
{
$aIsIterable = static::assertIsArrayOrIterator($a);
if (false === $aIsIterable && $b === null && (boolean) $arguments['fail']) {
ErrorUtility::throwViewHelperException('Required argument "b" was not supplied', 1237823699);
}
if (true === $aIsIterable && null === $b) {
$a = static::arrayFromArrayOrTraversableOrCSVStatic($a);
return min($a);
}
if ($b === null && (boolean) $arguments['fail']) {
ErrorUtility::throwViewHelperException('Required argument "b" was not supplied', 1237823699);
}
return min($a, $b);
}
}
6 changes: 3 additions & 3 deletions Classes/ViewHelpers/Math/ProductViewHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,13 @@ class ProductViewHelper extends AbstractMultipleMathViewHelper
protected static function calculateAction($a, $b, array $arguments)
{
$aIsIterable = static::assertIsArrayOrIterator($a);
if (false === $aIsIterable && $b === null && (boolean) $arguments['fail']) {
ErrorUtility::throwViewHelperException('Required argument "b" was not supplied', 1237823699);
}
if (true === $aIsIterable && null === $b) {
$a = static::arrayFromArrayOrTraversableOrCSVStatic($a);
return array_product($a);
}
if ($b === null && (boolean) $arguments['fail']) {
ErrorUtility::throwViewHelperException('Required argument "b" was not supplied', 1237823699);
}
return $a * $b;
}
}
6 changes: 3 additions & 3 deletions Classes/ViewHelpers/Math/SubtractViewHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,13 @@ public function initializeArguments()
protected static function calculateAction($a, $b, array $arguments)
{
$aIsIterable = static::assertIsArrayOrIterator($a);
if (false === $aIsIterable && $b === null && (boolean) $arguments['fail']) {
ErrorUtility::throwViewHelperException('Required argument "b" was not supplied', 1237823699);
}
if (true === $aIsIterable && null === $b) {
$a = static::arrayFromArrayOrTraversableOrCSVStatic($a);
return -array_sum($a);
}
if ($b === null && (boolean) $arguments['fail']) {
ErrorUtility::throwViewHelperException('Required argument "b" was not supplied', 1237823699);
}
return $a - $b;
}
}
4 changes: 2 additions & 2 deletions Classes/ViewHelpers/Math/SumViewHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@ public function initializeArguments()
*/
protected static function calculateAction($a, $b, array $arguments)
{
if ($b === null && (boolean) $arguments['fail']) {
$aIsIterable = static::assertIsArrayOrIterator($a);
if (false === $aIsIterable && $b === null && (boolean) $arguments['fail']) {
ErrorUtility::throwViewHelperException('Required argument "b" was not supplied', 1237823699);
}
$aIsIterable = static::assertIsArrayOrIterator($a);
if (true === $aIsIterable) {
if (null === $b) {
$a = static::arrayFromArrayOrTraversableOrCSVStatic($a);
Expand Down
2 changes: 1 addition & 1 deletion Classes/ViewHelpers/Media/AudioViewHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ public function render()
$tagAttributes['muted'] = 'muted';
}
if (true === in_array($this->arguments['preload'], $this->validPreloadModes)) {
$tagAttributes['preload'] = 'preload';
$tagAttributes['preload'] = $this->arguments['preload'];
}
if (null !== $this->arguments['poster']) {
$tagAttributes['poster'] = $this->arguments['poster'];
Expand Down
36 changes: 32 additions & 4 deletions Classes/ViewHelpers/Page/LanguageMenuViewHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

use FluidTYPO3\Vhs\Traits\ArrayConsumingViewHelperTrait;
use FluidTYPO3\Vhs\Utility\CoreUtility;
use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Fluid\Core\ViewHelper\AbstractTagBasedViewHelper;
use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;
Expand Down Expand Up @@ -313,10 +314,7 @@ protected function parseLanguageMenu()
}
}

// Select all pages_language_overlay records on the current page. Each represents a possibility for a language.
$table = 'pages_language_overlay';
$sysLang = $GLOBALS['TSFE']->cObj->getRecords($table, ['selectFields' => 'sys_language_uid', 'pidInList' => $this->getPageUid(), 'languageField' => 0]);
$languageUids = array_column($sysLang, 'sys_language_uid');
$languageUids = $this->getSystemLanguageUids();

foreach ($languageMenu as $key => $value) {
$current = $GLOBALS['TSFE']->sys_language_uid === (integer) $key ? 1 : 0;
Expand Down Expand Up @@ -377,4 +375,34 @@ protected function getPageUid()

return (integer) $pageUid;
}

/**
* Fetches system languages depending on the TYPO3 version.
*
* @return int[]
* @see https://docs.typo3.org/typo3cms/extensions/core/Changelog/9.0/Important-82445-MigratePagesLanguageOverlayIntoPages.html
*/
protected function getSystemLanguageUids()
{
if (version_compare(TYPO3_branch, '9.0', '<')) {
$table = 'pages_language_overlay';
$parentField = 'pid';
} else {
$table = 'pages';
$parentField = 'l10n_parent';
}

$connectionPool = GeneralUtility::makeInstance(ConnectionPool::class);
$connection = $connectionPool->getConnectionForTable($table);
$queryBuilder = $connection->createQueryBuilder();
$result = $queryBuilder->select('sys_language_uid')
->from($table)
->where(
$queryBuilder->expr()->eq($parentField, $this->getPageUid())
)
->execute()
;

return array_column($result->fetchAll(), 'sys_language_uid');
}
}
1 change: 1 addition & 0 deletions Classes/ViewHelpers/Render/AbstractRenderViewHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ protected static function getPreparedClonedView(RenderingContextInterface $rende
$controllerContext = clone $renderingContext->getControllerContext();
$view->setControllerContext($controllerContext);
$view->setFormat($controllerContext->getRequest()->getFormat());
$view->getRenderingContext()->setViewHelperVariableContainer($renderingContext->getViewHelperVariableContainer());
}
$view->assignMultiple(ViewHelperUtility::getVariableProviderFromRenderingContext($renderingContext)->getAll());
return $view;
Expand Down
2 changes: 1 addition & 1 deletion Classes/ViewHelpers/Render/UncacheViewHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public static function renderStatic(
\Closure $renderChildrenClosure,
RenderingContextInterface $renderingContext
) {
$templateVariableContainer = $renderingContext->getTemplateVariableContainer();
$templateVariableContainer = $renderingContext->getVariableProvider();
$partialArguments = $arguments['arguments'];
if (false === is_array($partialArguments)) {
$partialArguments = [];
Expand Down
Loading

0 comments on commit 6ccd453

Please sign in to comment.