Commit 84dca007 authored by Kevin Ditscheid's avatar Kevin Ditscheid

[BUGFIX] Fix the sg_routes Backend module

parent d20c2f56
......@@ -29,13 +29,21 @@ namespace SGalinski\SgRoutes\Controller;
use SGalinski\SgRoutes\Domain\Model\Category;
use SGalinski\SgRoutes\Domain\Model\PageNotFoundHandling;
use SGalinski\SgRoutes\Domain\Model\Route;
use SGalinski\SgRoutes\Domain\Repository\CategoryRepository;
use SGalinski\SgRoutes\Domain\Repository\LogRepository;
use SGalinski\SgRoutes\Domain\Repository\PageNotFoundHandlingRepository;
use SGalinski\SgRoutes\Domain\Repository\RouteRepository;
use SGalinski\SgRoutes\Service\LicensingService;
use SGalinski\SgRoutes\Service\RoutingService;
use TYPO3\CMS\Backend\Clipboard\Clipboard;
use TYPO3\CMS\Backend\Routing\UriBuilder;
use TYPO3\CMS\Backend\Template\Components\ButtonBar;
use TYPO3\CMS\Backend\Template\Components\DocHeaderComponent;
use TYPO3\CMS\Backend\Utility\BackendUtility;
use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Core\Database\Query\Restriction\BackendWorkspaceRestriction;
use TYPO3\CMS\Core\Database\Query\Restriction\DeletedRestriction;
use TYPO3\CMS\Core\Imaging\Icon;
use TYPO3\CMS\Core\Imaging\IconFactory;
use TYPO3\CMS\Core\Messaging\FlashMessage;
......@@ -84,29 +92,64 @@ class RouteController extends ActionController {
private $docHeaderComponent;
/**
* @var \SGalinski\SgRoutes\Domain\Repository\RouteRepository
* @inject
* @var RouteRepository
*/
private $routeRepository;
/**
* @var \SGalinski\SgRoutes\Domain\Repository\CategoryRepository
* @inject
* Inject the RouteRepository
*
* @param RouteRepository $routeRepository
*/
public function injectRouteRepository(RouteRepository $routeRepository) {
$this->routeRepository = $routeRepository;
}
/**
* @var CategoryRepository
*/
private $categoryRepository;
/**
* @var \SGalinski\SgRoutes\Domain\Repository\LogRepository
* @inject
* Inject the CategoryRepository
*
* @param CategoryRepository $categoryRepository
*/
public function injectCategoryRepository(CategoryRepository $categoryRepository) {
$this->categoryRepository = $categoryRepository;
}
/**
* @var LogRepository
*
*/
private $logRepository;
/**
* @var \SGalinski\SgRoutes\Domain\Repository\PageNotFoundHandlingRepository
* @inject
* Inject the LogRepository
*
* @param LogRepository $logRepository
*/
public function injectLogRepository(LogRepository $logRepository) {
$this->logRepository = $logRepository;
}
/**
* @var PageNotFoundHandlingRepository
*
*/
private $pageNotFoundHandlingRepository;
/**
* Inject the PageNotFoundHandlingRepository
*
* @param PageNotFoundHandlingRepository $pageNotFoundHandlingRepository
*/
public function injectPageNotFoundHandlingRepository(PageNotFoundHandlingRepository $pageNotFoundHandlingRepository
) {
$this->pageNotFoundHandlingRepository = $pageNotFoundHandlingRepository;
}
/**
* Initialize action for all actions
*
......@@ -150,20 +193,30 @@ class RouteController extends ActionController {
$this->view->assign('typo3Version', VersionNumberUtility::convertVersionNumberToInteger(TYPO3_version));
if (!$this->rootPageUid) {
$rootOptionRows = (array) BackendUtility::getRecordsByField('pages', 'is_siteroot', 1, '', '', 'sorting');
$connectionPool = GeneralUtility::makeInstance(ConnectionPool::class);
$queryBuilder = $connectionPool->getQueryBuilderForTable('pages');
$queryBuilder->getRestrictions()
->removeAll()
->add(GeneralUtility::makeInstance(BackendWorkspaceRestriction::class))
->add(GeneralUtility::makeInstance(DeletedRestriction::class));
$rootOptionRows = $queryBuilder->select('*')
->from('pages')
->where(
$queryBuilder->expr()->eq('is_siteroot', $queryBuilder->createNamedParameter(1, \PDO::PARAM_INT))
)->orderBy('sorting')->execute()->fetchAll();
$rootOptions = [];
foreach ($rootOptionRows as $row) {
$pageInfo = BackendUtility::readPageAccess($row['uid'], $GLOBALS['BE_USER']->getPagePermsClause(1));
if ($pageInfo) {
$rootline = BackendUtility::BEgetRootLine($pageInfo['uid'], '', TRUE);
ksort($rootline);
\ksort($rootline);
$path = '/root';
foreach ($rootline as $page) {
$path .= '/p' . dechex($page['uid']);
$path .= '/p' . \dechex($page['uid']);
}
$pageInfo['path'] = $path;
$pageInfo['_thePathFull'] = substr($pageInfo['_thePathFull'], 1);
$pageInfo['_thePathFull'] = substr($pageInfo['_thePathFull'], 0, -1);
$pageInfo['_thePathFull'] = \substr($pageInfo['_thePathFull'], 1);
$pageInfo['_thePathFull'] = \substr($pageInfo['_thePathFull'], 0, -1);
$rootOptions[] = $pageInfo;
}
}
......@@ -254,7 +307,11 @@ class RouteController extends ActionController {
// Refresh
$refreshButton = $buttonBar->makeLinkButton()
->setHref(GeneralUtility::getIndpEnv('REQUEST_URI'))
->setTitle(LocalizationUtility::translate('LLL:EXT:lang/locallang_core.xlf:labels.reload', ''))
->setTitle(
LocalizationUtility::translate(
'LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.reload'
)
)
->setIcon($iconFactory->getIcon('actions-refresh', Icon::SIZE_SMALL));
$buttonBar->addButton($refreshButton, ButtonBar::BUTTON_POSITION_RIGHT);
......@@ -342,6 +399,7 @@ class RouteController extends ActionController {
* @throws \TYPO3\CMS\Extbase\Persistence\Exception\InvalidQueryException
* @throws \UnexpectedValueException
* @throws \InvalidArgumentException
* @throws \TYPO3\CMS\Backend\Routing\Exception\RouteNotFoundException
*/
public function pageNotFoundHandlingAction() {
if ($this->rootPageUid) {
......@@ -350,16 +408,32 @@ class RouteController extends ActionController {
/** @var PageNotFoundHandling $handling */
$handling = $this->pageNotFoundHandlingRepository->findOneByPid($this->rootPageUid);
$tableName = 'tx_sgroutes_domain_model_pagenotfoundhandling';
$returnUrl = BackendUtility::getModuleUrl('web_SgRoutesRoute', ['id' => $pageUid]);
$uriBuilder = GeneralUtility::makeInstance(UriBuilder::class);
$returnUrl = $uriBuilder->buildUriFromRoute('web_SgRoutesRoute', ['id' => $pageUid]);
if ($handling) {
$editUri = BackendUtility::getModuleUrl('record_edit') .
'&edit[' . $tableName . '][' . $handling->getUid() . ']=edit';
$editUri = $uriBuilder->buildUriFromRoute(
'record_edit', [
'edit' => [
$tableName => [
$handling->getUid() => 'edit'
]
],
'returnUrl' => (string) $returnUrl
]
);
} else {
$editUri = BackendUtility::getModuleUrl('record_edit') .
'&edit[' . $tableName . '][' . $this->rootPageUid . ']=new';
$editUri = $uriBuilder->buildUriFromRoute(
'record_edit', [
'edit' => [
$tableName => [
$this->rootPageUid => 'new'
]
],
'returnUrl' => (string) $returnUrl
]
);
}
$editUri .= '&returnUrl=' . rawurlencode($returnUrl);
header('Location: ' . $editUri, TRUE);
\header('Location: ' . $editUri, TRUE);
exit();
}
}
......@@ -394,7 +468,7 @@ class RouteController extends ActionController {
foreach ($propertyColumns as $propertyName => $columnName) {
$label = isset($GLOBALS['TCA']['tx_sgroutes_domain_model_route']['columns'][$columnName]) ?
$GLOBALS['TCA']['tx_sgroutes_domain_model_route']['columns'][$columnName]['label'] : '';
if (strpos($label, 'LLL:') === 0) {
if (\strpos($label, 'LLL:') === 0) {
$label = $GLOBALS['LANG']->sL($label);
}
$export[0][] = $label ?: $propertyName;
......@@ -405,8 +479,8 @@ class RouteController extends ActionController {
foreach ($routes as $route) {
foreach ($propertyColumns as $propertyName => $columnName) {
$value = $route->_getProperty($propertyName);
if (in_array($propertyName, $dateFields, TRUE)) {
$export[$line][] = $value ? date('d.m.Y', $value) : '';
if (\in_array($propertyName, $dateFields, TRUE)) {
$export[$line][] = $value ? \date('d.m.Y', $value) : '';
} elseif ($propertyName === 'categories') {
$categoryString = '';
if ($value) {
......@@ -433,13 +507,13 @@ class RouteController extends ActionController {
foreach ($line as $field) {
$fields[] = '"' . $field . '"';
}
$exportString .= implode(',', $fields) . ';' . LF;
$exportString .= \implode(',', $fields) . ';' . LF;
}
}
header('Content-Type: application/force-download');
header('Content-Transfer-Encoding: Binary');
header('Content-Disposition: attachment; filename="export.csv"');
header('Content-Length: ' . strlen($exportString));
\header('Content-Type: application/force-download');
\header('Content-Transfer-Encoding: Binary');
\header('Content-Disposition: attachment; filename="export.csv"');
\header('Content-Length: ' . \strlen($exportString));
echo $exportString;
exit(0);
}
......@@ -450,7 +524,7 @@ class RouteController extends ActionController {
* @throws \InvalidArgumentException
*/
public function initClipboard() {
if (is_array($this->clipboardCommandArray)) {
if (\is_array($this->clipboardCommandArray)) {
$clipObj = GeneralUtility::makeInstance(Clipboard::class);
$clipObj->initializeClipboard();
if ($this->clipboardCommandArray['paste']) {
......
......@@ -69,14 +69,14 @@ class RouteRepository extends Repository {
$constraints = [];
if (isset($filters['categories']) && is_array($filters['categories']) && count($filters['categories'])) {
if (isset($filters['categories']) && \is_array($filters['categories']) && \count($filters['categories'])) {
$categoryConstraints = [];
foreach ($filters['categories'] as $category) {
if ((int) $category) {
$categoryConstraints[] = $query->contains('categories', $category);
}
}
if (count($categoryConstraints)) {
if (\count($categoryConstraints)) {
$constraints[] = $query->logicalOr($categoryConstraints);
}
}
......@@ -91,9 +91,9 @@ class RouteRepository extends Repository {
$constraints[] = $query->logicalOr($searchConstraints);
}
if (count($constraints) > 1) {
if (\count($constraints) > 1) {
$query->matching($query->logicalAnd($constraints));
} elseif (count($constraints)) {
} elseif (\count($constraints)) {
$query->matching($constraints[0]);
}
......
......@@ -28,6 +28,7 @@ namespace SGalinski\SgRoutes\Service;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use SGalinski\SgRoutes\Utility\ExtensionUtility;
use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
use TYPO3\CMS\Core\Utility\GeneralUtility;
......@@ -54,9 +55,9 @@ class LicensingService {
public static function checkKey(): bool {
if (static::$isLicenseKeyValid === NULL) {
static::$isLicenseKeyValid = FALSE;
$configuration = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf'][self::EXTENSION_KEY], [FALSE]);
if (isset($configuration['key']) && $key = trim($configuration['key'])) {
static::$isLicenseKeyValid = (bool) preg_match('/^([A-Z\d]{6}-?){4}$/', $key);
$configuration = ExtensionUtility::getExtensionConfiguration();
if (isset($configuration['key']) && $key = \trim($configuration['key'])) {
static::$isLicenseKeyValid = (bool) \preg_match('/^([A-Z\d]{6}-?){4}$/', $key);
}
}
......@@ -71,19 +72,19 @@ class LicensingService {
*/
public static function ping($returnUrl = FALSE): string {
try {
$configuration = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf'][self::EXTENSION_KEY], [FALSE]);
$configuration = ExtensionUtility::getExtensionConfiguration();
$key = '';
if (isset($configuration['key'])) {
$key = trim($configuration['key']);
$key = \trim($configuration['key']);
}
$params = [
'extension' => self::EXTENSION_KEY,
'host' => GeneralUtility::getIndpEnv('HTTP_HOST'),
'key' => $key
];
$params = http_build_query($params);
$params = \http_build_query($params);
$pingUrl = self::URL;
$pingUrl .= $params !== '' ? (strpos($pingUrl, '?') === FALSE ? '?' : '&') . $params : '';
$pingUrl .= $params !== '' ? (\strpos($pingUrl, '?') === FALSE ? '?' : '&') . $params : '';
if ($returnUrl) {
return $pingUrl;
}
......
......@@ -82,21 +82,21 @@ class RoutingService {
/** @noinspection PhpUnusedParameterInspection */
array $parameters = [], $controller
): int {
$start = microtime(TRUE);
$start = \microtime(TRUE);
$requestUri = GeneralUtility::getIndpEnv('REQUEST_URI');
list($requestPath, $requestParameters) = GeneralUtility::trimExplode('?', $requestUri, TRUE);
$requestParameterPageId = NULL;
$filteredRequestParameters = [];
foreach (GeneralUtility::trimExplode('&', $requestParameters, TRUE) as $splitedParameter) {
if (strpos($splitedParameter, self::PAGE_ID_URL_ID) === 0) {
if (\strpos($splitedParameter, self::PAGE_ID_URL_ID) === 0) {
$requestParameterPageId = $splitedParameter;
continue;
}
$filteredRequestParameters[] = $splitedParameter;
}
$requestParameters = implode('&', $filteredRequestParameters);
$requestParameters = \implode('&', $filteredRequestParameters);
if ($requestParameterPageId !== NULL) {
$requestUri = $requestPath . '?' . $requestParameterPageId;
......@@ -104,8 +104,8 @@ class RoutingService {
$requestUri = $requestPath;
}
if (substr($requestUri, -1) === '/') {
$requestUri = substr($requestUri, 0, -1);
if (\substr($requestUri, -1) === '/') {
$requestUri = \substr($requestUri, 0, -1);
}
$rootUid = $this->getRootUid($controller);
......@@ -137,23 +137,27 @@ class RoutingService {
$appendParameters = '?' . $requestParameters;
}
if (substr($redirect['source_url'], -1) === '/') {
$trimmedSourceUrl = substr($redirect['source_url'], 0, -1);
if (\substr($redirect['source_url'], -1) === '/') {
$trimmedSourceUrl = \substr($redirect['source_url'], 0, -1);
} else {
$trimmedSourceUrl = $redirect['source_url'];
}
if ($redirect['use_regular_expression'] && LicensingService::checkKey()) {
$pattern = '/' . str_replace('/', '\\/', $redirect['source_url']) . '/is';
$pattern = '/' . \str_replace('/', '\\/', $redirect['source_url']) . '/is';
if ($requestParameters && !$redirect['redirect_url_parameters']) {
$requestUri .= '?' . $requestParameters;
}
if (preg_match($pattern, \rawurldecode($requestUri))) {
$redirectUri = preg_replace($pattern, $redirect['destination_url'], \rawurldecode($requestUri)) .
if (\preg_match($pattern, \rawurldecode($requestUri))) {
$redirectUri = \preg_replace(
$pattern, $redirect['destination_url'], \rawurldecode($requestUri)
) .
$appendParameters;
$this->logRedirect($redirect, \rawurldecode($requestUri), $redirectUri, $start, microtime(TRUE));
header('Location: ' . $redirectUri, TRUE, $redirect['redirect_code']);
$this->logRedirect(
$redirect, \rawurldecode($requestUri), $redirectUri, $start, \microtime(TRUE)
);
\header('Location: ' . $redirectUri, TRUE, $redirect['redirect_code']);
exit();
}
} elseif (
......@@ -167,8 +171,8 @@ class RoutingService {
)
) {
$destinationUrl = $redirect['destination_url'];
if (strpos($destinationUrl, self::URL_WIZARD_ID) === 0) {
$destinationUrl = (int) substr($destinationUrl, 14);
if (\strpos($destinationUrl, self::URL_WIZARD_ID) === 0) {
$destinationUrl = (int) \substr($destinationUrl, 14);
}
if (\is_numeric($destinationUrl)) {
......@@ -184,8 +188,10 @@ class RoutingService {
$redirectUri = $destinationUrl . $appendParameters;
}
$this->logRedirect($redirect, \rawurldecode($requestUri), $redirectUri, $start, microtime(TRUE));
header('Location: ' . $redirectUri, TRUE, $redirect['redirect_code']);
$this->logRedirect(
$redirect, \rawurldecode($requestUri), $redirectUri, $start, \microtime(TRUE)
);
\header('Location: ' . $redirectUri, TRUE, $redirect['redirect_code']);
exit();
}
}
......@@ -295,19 +301,19 @@ class RoutingService {
try {
$key = 'pageAccessFailureReasons';
$pageAccessFailureReasons = [];
if (array_key_exists($key, $parameters) && \is_array($parameters[$key])) {
if (\array_key_exists($key, $parameters) && \is_array($parameters[$key])) {
$pageAccessFailureReasons = $parameters[$key];
}
$loginUrl = $this->getLoginPageUrl();
$isPageAccessFailureFrontendGroup = array_key_exists('fe_group', $pageAccessFailureReasons);
$isPageAccessFailureFrontendGroup = \array_key_exists('fe_group', $pageAccessFailureReasons);
$isSgAccountLoaded = ExtensionManagementUtility::isLoaded('sg_account');
$isKeyNumeric = isset($pageAccessFailureReasons['fe_group']) ?
is_numeric(key($pageAccessFailureReasons['fe_group'])) : FALSE;
\is_numeric(key($pageAccessFailureReasons['fe_group'])) : FALSE;
if ($isPageAccessFailureFrontendGroup && $isSgAccountLoaded && $loginUrl !== '' && $isKeyNumeric) {
@ob_end_clean();
header('HTTP/1.1 302 PagenotfoundHandler Redirect');
header('Location: ' . GeneralUtility::locationHeaderUrl($loginUrl));
@\ob_end_clean();
\header('HTTP/1.1 302 PagenotfoundHandler Redirect');
\header('Location: ' . GeneralUtility::locationHeaderUrl($loginUrl));
exit;
}
$_params = ['pObj' => $controller];
......@@ -324,13 +330,13 @@ class RoutingService {
if ($handling && $handling['function'] !== '') {
$configurationFound = TRUE;
$function = $handling['function'];
$isFunctionStartsWithT3Prefix = (strpos($function, self::URL_WIZARD_ID) === 0);
$isFunctionStartsWithT3Prefix = (\strpos($function, self::URL_WIZARD_ID) === 0);
$evaluationFunctionThatItsNotStartedWithNumbers = ((string) (int) $function);
if ((($evaluationFunctionThatItsNotStartedWithNumbers === $function) && (int) $function) ||
$isFunctionStartsWithT3Prefix
) {
if ($isFunctionStartsWithT3Prefix) {
$function = (int) substr($function, 14);
$function = (int) \substr($function, 14);
}
$function = 'index.php?id=' . $function;
$languageId = $this->getLanguageId($controller);
......@@ -370,7 +376,7 @@ class RoutingService {
} catch (\Exception $exception) {
// this can happen if e.g. the wanted error page can't be fetched.
header($GLOBALS['TYPO3_CONF_VARS']['FE']['pageNotFound_handling_statheader']);
\header($GLOBALS['TYPO3_CONF_VARS']['FE']['pageNotFound_handling_statheader']);
$htaccessMessage = '';
if(
......@@ -443,14 +449,15 @@ class RoutingService {
* @param array $routes
* @return string
* @throws \InvalidArgumentException
* @throws ServiceUnavailableException
*/
public static function getHtaccessEntries(array $routes = []): string {
$htaccessEntries = '';
if ($routes) {
foreach ($routes as $route) {
$route['description'] = trim($route['description']);
$route['description'] = \trim($route['description']);
if ($route['description']) {
$htaccessEntries .= preg_replace('/(^)/m', '#$1', $route['description']) . LF;
$htaccessEntries .= \preg_replace('/(^)/m', '#$1', $route['description']) . LF;
}
$directive = 'Redirect';
if ($route['use_regular_expression']) {
......@@ -626,8 +633,8 @@ class RoutingService {
* @throws \UnexpectedValueException
*/
private function getLoginPageUrl(): string {
$sgAccountConfiguration = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['sg_account'], [FALSE]);
$loginRedirectUrl = trim($sgAccountConfiguration['loginRedirectUrl']);
$sgAccountConfiguration = \unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['sg_account'], [FALSE]);
$loginRedirectUrl = \trim($sgAccountConfiguration['loginRedirectUrl']);
if ($loginRedirectUrl === '') {
return '';
}
......@@ -636,7 +643,7 @@ class RoutingService {
return $loginRedirectUrl;
}
$parsedUrl = parse_url($loginRedirectUrl);
$parsedUrl = \parse_url($loginRedirectUrl);
$path = $parsedUrl['path'] ?? '';
$query = isset($parsedUrl['query']) ? '?' . $parsedUrl['query'] : '';
$fragment = isset($parsedUrl['fragment']) ? '#' . $parsedUrl['fragment'] : '';
......
<?php
namespace SGalinski\SgRoutes\Utility;
/**
*
* Copyright notice
*
* (c) sgalinski Internet Services (https://www.sgalinski.de)
*
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
* free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
*
* This script is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* This copyright notice MUST APPEAR in all copies of the script!
*/
use TYPO3\CMS\Core\Utility\VersionNumberUtility;
/**
* Class ExtensionUtility
*
* @package SGalinski\SgRoutes\Utility
* @author Kevin Ditscheid <kevin.ditscheid@sgalinski.de>
*/
class ExtensionUtility {
/**
* Get the extension configuration
*
* @return array
*/
public static function getExtensionConfiguration(): array {
if (version_compare(VersionNumberUtility::getCurrentTypo3Version(), '9.0.0', '<')) {
return \unserialize(
$GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['sg_routes'], ['allowed_classes' => FALSE]
);
} else {
return $GLOBALS['TYPO3_CONF_VARS']['EXTENSIONS']['sg_routes'];
}
}
}
......@@ -61,7 +61,7 @@ class ControlViewHelper extends AbstractViewHelper {
$row = $this->arguments['row'];
$sortingData = $this->arguments['sortingData'];
$clipboard = $this->arguments['clipboard'];
if (!is_array($row)) {
if (!\is_array($row)) {
$row = BackendUtility::getRecord($table, $row->getUid());
}
/** @var DatabaseRecordList $databaseRecordList */
......
......@@ -26,7 +26,8 @@ namespace SGalinski\SgRoutes\ViewHelpers\Backend;
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
use TYPO3\CMS\Backend\Utility\BackendUtility;
use TYPO3\CMS\Backend\Routing\UriBuilder;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
/**
......@@ -34,6 +35,9 @@ use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
**/
class EditLinkViewHelper extends AbstractViewHelper {
/**
* Register the ViewHelpers arguments
*/
public function initializeArguments() {
parent::initializeArguments();
$this->registerArgument('table', 'string', 'The table of the edit link', TRUE);
......@@ -45,10 +49,18 @@ class EditLinkViewHelper extends AbstractViewHelper {
* Renders the onclick script for editing a record
*
* @return string
* @throws \TYPO3\CMS\Backend\Routing\Exception\RouteNotFoundException
*/
public function render() {
return BackendUtility::getModuleUrl(
'record_edit'
) . '&edit[' . $this->arguments['table'] . '][' . $this->arguments['uid'] . ']=' . ($this->arguments['new'] ? 'new' : 'edit');
$uriBuilder = GeneralUtility::makeInstance(UriBuilder::class);
return $uriBuilder->buildUriFromRoute(
'record_edit', [
'edit' => [
$this->arguments['table'] => [
$this->arguments['uid'] => $this->arguments['new'] ? 'new' : 'edit'
]
]
]
);
}
}
......@@ -68,8 +68,8 @@ class IconViewHelper extends AbstractViewHelper {
. '</span>';
if ($clickMenu) {
return BackendUtility::wrapClickMenuOnIcon($iconImg, $table, $row['uid']);
} else {
return $iconImg;
}
return $iconImg;
}
}
......@@ -58,7 +58,8 @@ class InlineLanguageLabelsViewHelper extends AbstractViewHelper {
public function render() {
$labels = $this->arguments['labels'];
$htmlEscape = $this->arguments['htmlEscape'];
$extensionName = $this->controllerContext->getRequest()->getControllerExtensionName();
$controllerContext = $this->renderingContext->getControllerContext();
$extensionName = $controllerContext->getRequest()->getControllerExtensionName();
$labels = GeneralUtility::trimExplode(',', $labels, TRUE);
$languageArray = [];
foreach ($labels as $key) {
......
......@@ -55,15 +55,15 @@ class SetViewHelper extends AbstractViewHelper {
if (NULL === $value) {
$value = $this->renderChildren();
}
if (FALSE === strpos($name, '.')) {
if (FALSE === \strpos($name, '.')) {
if (TRUE === $this->templateVariableContainer->exists($name)) {
$this->templateVariableContainer->remove($name);
}
$this->templateVariableContainer->add($name, $value);
} elseif (1 === substr_count($name, '.')) {
$parts = explode('.', $name);
$objectName = array_shift($parts);
$path = implode('.', $parts);
} elseif (1 === \substr_count($name, '.')) {
$parts = \explode('.', $name);
$objectName = \array_shift($parts);
$path = \implode('.', $parts);
if (FALSE === $this->templateVariableContainer->exists($objectName)) {
return NULL;
}
......
<?php
/**
*
* Copyright notice
*
* (c) sgalinski Internet Services (https://www.sgalinski.de)
*
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
* free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
*
* This script is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* This copyright notice MUST APPEAR in all copies of the script!
*/
call_user_func(
function ($extKey, $table) {
// Adds the static TypoScript template.
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addStaticFile(
$extKey, 'Configuration/TypoScript/Frontend', 'SgRoutes - Configuration'
);
}, 'sg_routes', 'sys_template'
);
......@@ -31,7 +31,7 @@ return [
],
'columns' => [
't3ver_label' => [
'label' => 'LLL:EXT:lang/locallang_general.xml:LGL.versionLabel',
'label' => 'LLL:EXT:core/Resources/Private/Language/locallang_general.xlf:LGL.versionLabel',
'config' => [
'type' => 'input',
'size' => 30,
......
......@@ -46,7 +46,7 @@ return [
],
'columns' => [
't3ver_label' => [
'label' => 'LLL:EXT:lang/locallang_general.xml:LGL.versionLabel',
'label' => 'LLL:EXT:core/Resources/Private/Language/locallang_general.xlf:LGL.versionLabel',
'config' => [
'type' => 'input',
'size' => 30,
......
</
{namespace core = TYPO3\CMS\Core\ViewHelpers}
{namespace sg=SGalinski\SgRoutes\ViewHelpers}
<f:be.container enableClickMenu="FALSE" loadExtJs="FALSE"
<f:be.container
includeRequireJsModules="{
0: 'TYPO3/CMS/Backend/AjaxDataHandler',
1: '{f:if(condition: \'{typo3Version} < 8000000 \', then: \'TYPO3/CMS/Backend/ClickMenu\', else: \'TYPO3/CMS/Backend/ContextMenu\')}',
......@@ -26,7 +26,7 @@