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,81 @@
<?php
namespace FluidTYPO3\Vhs\ViewHelpers\Condition\Page;
/*
* 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\Service\PageSelectService;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Fluid\Core\ViewHelper\AbstractConditionViewHelper;
use FluidTYPO3\Vhs\Traits\ConditionViewHelperTrait;
/**
* ### Condition: Page has subpages
*
* A condition ViewHelper which renders the `then` child if
* current page or page with provided UID has subpages. By default
* disabled subpages are considered non existent which can be overridden
* by setting $includeHidden to TRUE. To include pages that are hidden
* in menus set $showHiddenInMenu to TRUE.
*
* @author Björn Fromme <fromme@dreipunktnull.com>, dreipunktnull
* @package Vhs
* @subpackage ViewHelpers\Condition\Page
*/
class HasSubpagesViewHelper extends AbstractConditionViewHelper {
use ConditionViewHelperTrait;
/**
* @var PageSelectService
*/
static protected $pageSelect;
/**
* @param PageSelectService $pageSelect
* @return void
*/
static public function setPageSelectService(PageSelectService $pageSelect) {
self::$pageSelect = $pageSelect;
}
/**
* Initialize arguments
*/
public function initializeArguments() {
parent::initializeArguments();
$this->registerArgument('pageUid', 'integer', 'value to check', FALSE, NULL);
$this->registerArgument('includeHidden', 'boolean', 'include hidden pages', FALSE, FALSE);
$this->registerArgument('showHiddenInMenu', 'boolean', 'include pages hidden in menu', FALSE, FALSE);
}
/**
* 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) {
$pageUid = $arguments['pageUid'];
$includeHidden = $arguments['includeHidden'];
$showHiddenInMenu = $arguments['showHiddenInMenu'];
if (NULL === $pageUid || TRUE === empty($pageUid) || 0 === intval($pageUid)) {
$pageUid = $GLOBALS['TSFE']->id;
}
if (self::$pageSelect === NULL) {
$objectManager = GeneralUtility::makeInstance('TYPO3\CMS\Extbase\Object\ObjectManager');
self::$pageSelect = $objectManager->get('FluidTYPO3\Vhs\Service\PageSelectService');
}
$menu = self::$pageSelect->getMenu($pageUid, array(), '', $showHiddenInMenu);
$pageHasSubPages = (0 < count($menu));
return TRUE === $pageHasSubPages;
}
}

View File

@@ -0,0 +1,62 @@
<?php
namespace FluidTYPO3\Vhs\ViewHelpers\Condition\Page;
/*
* 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 TYPO3\CMS\Frontend\Page\PageRepository;
use FluidTYPO3\Vhs\Traits\ConditionViewHelperTrait;
/**
* ### Condition: Page is child page
*
* Condition ViewHelper which renders the `then` child if current
* page or page with provided UID is a child of some other page in
* the page tree. If $respectSiteRoot is set to TRUE root pages are
* never considered child pages even if they are.
*
* @author Björn Fromme <fromme@dreipunktnull.com>, dreipunktnull
* @package Vhs
* @subpackage ViewHelpers\Condition\Page
*/
class IsChildPageViewHelper extends AbstractConditionViewHelper {
use ConditionViewHelperTrait;
/**
* Initialize arguments
*/
public function initializeArguments() {
parent::initializeArguments();
$this->registerArgument('pageUid', 'integer', 'value to check', FALSE, NULL);
$this->registerArgument('respectSiteRoot', 'boolean', 'value to check', FALSE, FALSE);
}
/**
* 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) {
$pageUid = $arguments['pageUid'];
$respectSiteRoot = $arguments['respectSiteRoot'];
if (NULL === $pageUid || TRUE === empty($pageUid) || 0 === intval($pageUid)) {
$pageUid = $GLOBALS['TSFE']->id;
}
$pageSelect = new PageRepository();
$page = $pageSelect->getPage($pageUid);
if (TRUE === (boolean) $respectSiteRoot && TRUE === isset($page['is_siteroot']) && TRUE === (boolean) $page['is_siteroot']) {
return FALSE;
}
return TRUE === isset($page['pid']) && 0 < $page['pid'];
}
}

View File

@@ -0,0 +1,68 @@
<?php
namespace FluidTYPO3\Vhs\ViewHelpers\Condition\Page;
/*
* 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: Is current language
*
* A condition ViewHelper which renders the `then` child if
* current language matches the provided language uid or language
* title. When using language titles like 'de' it is required to
* provide a default title to distinguish between the standard
* and a non existing language.
*
* @author Björn Fromme <fromme@dreipunktnull.com>, dreipunktnull
* @package Vhs
* @subpackage ViewHelpers\Condition\Page
*/
class IsLanguageViewHelper extends AbstractConditionViewHelper {
use ConditionViewHelperTrait;
/**
* Initialize arguments
*/
public function initializeArguments() {
parent::initializeArguments();
$this->registerArgument('language', 'string', 'language to check', TRUE);
$this->registerArgument('defaultTitle', 'string', 'title of the default language', FALSE, 'en');
}
/**
* 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) {
$language = $arguments['language'];
$defaultTitle = $arguments['defaultTitle'];
$currentLanguageUid = $GLOBALS['TSFE']->sys_language_uid;
if (TRUE === is_numeric($language)) {
$languageUid = intval($language);
} else {
$row = $GLOBALS['TYPO3_DB']->exec_SELECTgetSingleRow('uid', 'sys_language', "title='" . $language . "'");
if (FALSE !== $row) {
$languageUid = intval($row['uid']);
} else {
if ((string) $language === $defaultTitle) {
$languageUid = $currentLanguageUid;
} else {
$languageUid = -1;
}
}
}
return $languageUid === $currentLanguageUid;
}
}