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,48 @@
<?php
namespace TYPO3\CMS\Compatibility6\Hooks\ExtTablesPostProcessing;
/*
* This file is part of the TYPO3 CMS project.
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
* of the License, or any later version.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* The TYPO3 project - inspiring people to share!
*/
use TYPO3\CMS\Core\Database\TableConfigurationPostProcessingHookInterface;
use TYPO3\Cms\Core\Utility\GeneralUtility;
/**
* Migrate TCA that was added by extensions in ext_tables.php
*
* This is deprecated, all extensions should register / manipulate TCA in Configuration/TCA nowadays.
*/
class TcaMigration implements TableConfigurationPostProcessingHookInterface
{
/**
* Run migration dynamically a second time on *every* request.
* This can not be cached and is slow.
*
* @return void
*/
public function processData()
{
/** @var \TYPO3\CMS\Core\Migrations\TcaMigration $tcaMigration */
$tcaMigration = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Migrations\TcaMigration::class);
$GLOBALS['TCA'] = $tcaMigration->migrate($GLOBALS['TCA']);
$messages = $tcaMigration->getMessages();
if (!empty($messages)) {
$context = 'ext:compatibility6 did an automatic migration of TCA during bootstrap. This costs performance on every'
. ' call. It also means some old extensions register TCA in ext_tables.php and not in Configuration/TCA.'
. ' Please adapt TCA accordingly until this message is not thrown anymore and unload extension compatibility6'
. ' as soon as possible';
array_unshift($messages, $context);
GeneralUtility::deprecationLog(implode(LF, $messages));
}
}
}

View File

@@ -0,0 +1,41 @@
<?php
namespace TYPO3\CMS\Compatibility6\Hooks\PageLayoutView;
/*
* This file is part of the TYPO3 CMS project.
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
* of the License, or any later version.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* The TYPO3 project - inspiring people to share!
*/
/**
* Contains a preview rendering for the page module of
* CType="mailform"
*/
class MailformPreviewRenderer implements \TYPO3\CMS\Backend\View\PageLayoutViewDrawItemHookInterface
{
/**
* Preprocesses the preview rendering of a content element of type "mailform"
*
* @param \TYPO3\CMS\Backend\View\PageLayoutView $parentObject Calling parent object
* @param bool $drawItem Whether to draw the item using the default functionality
* @param string $headerContent Header content
* @param string $itemContent Item content
* @param array $row Record row of tt_content
*
* @return void
*/
public function preProcess(\TYPO3\CMS\Backend\View\PageLayoutView &$parentObject, &$drawItem, &$headerContent, &$itemContent, array &$row)
{
if ($row['CType'] === 'mailform') {
$itemContent = $parentObject->linkEditContent($parentObject->renderText($row['bodytext']), $row) . '<br />';
$drawItem = false;
}
}
}

View File

@@ -0,0 +1,71 @@
<?php
namespace TYPO3\CMS\Compatibility6\Hooks\PageLayoutView;
/*
* This file is part of the TYPO3 CMS project.
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
* of the License, or any later version.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* The TYPO3 project - inspiring people to share!
*/
use TYPO3\CMS\Backend\View\PageLayoutViewDrawItemHookInterface;
use TYPO3\CMS\Lang\LanguageService;
use TYPO3\CMS\Backend\View\PageLayoutView;
use TYPO3\CMS\Backend\Utility\BackendUtility;
/**
* Contains a preview rendering for the page module of CType="script"
*/
class ScriptPreviewRenderer implements PageLayoutViewDrawItemHookInterface
{
/**
* Preprocesses the preview rendering of a content element of type "script"
*
* @param \TYPO3\CMS\Backend\View\PageLayoutView $parentObject Calling parent object
* @param bool $drawItem Whether to draw the item using the default functionality
* @param string $headerContent Header content
* @param string $itemContent Item content
* @param array $row Record row of tt_content
*
* @return void
*/
public function preProcess(
PageLayoutView &$parentObject,
&$drawItem,
&$headerContent,
&$itemContent,
array &$row
) {
if ($row['CType'] === 'script') {
$itemContent .= $this->getLanguageService()->sL(
BackendUtility::getItemLabel('tt_content', 'select_key'),
true
) . ' ' . $row['select_key'] . '<br />';
$itemContent .= '<br />' . $parentObject->linkEditContent(
$parentObject->renderText($row['bodytext']),
$row
) . '<br />';
$itemContent .= '<br />' . $parentObject->linkEditContent(
$parentObject->renderText($row['imagecaption']),
$row
) . '<br />';
$drawItem = false;
}
}
/**
* Returns the language service
* @return LanguageService
*/
protected function getLanguageService()
{
return $GLOBALS['LANG'];
}
}

View File

@@ -0,0 +1,155 @@
<?php
namespace TYPO3\CMS\Compatibility6\Hooks\TypoScriptFrontendController;
/*
* This file is part of the TYPO3 CMS project.
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
* of the License, or any later version.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* The TYPO3 project - inspiring people to share!
*/
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Html\HtmlParser;
/**
* Class that hooks into TypoScriptFrontendController to do XHTML cleaning and prefixLocalAnchors functionality
*/
class ContentPostProcHook
{
/**
* @var \TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController
*/
protected $pObj;
/**
* XHTML-clean the code, if flag config.xhtml_cleaning is set
* to "all", same goes for config.prefixLocalAnchors
*
* @param array $parameters
* @param \TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController $parentObject
*/
public function contentPostProcAll(&$parameters, $parentObject)
{
$this->pObj = $parentObject;
// Fix local anchors in links, if flag set
if ($this->doLocalAnchorFix() === 'all') {
$GLOBALS['TT']->push('Local anchor fix, all', '');
$this->prefixLocalAnchorsWithScript();
$GLOBALS['TT']->pull();
}
// XHTML-clean the code, if flag set
if ($this->doXHTML_cleaning() === 'all') {
$GLOBALS['TT']->push('XHTML clean, all', '');
$XHTML_clean = GeneralUtility::makeInstance(HtmlParser::class);
$this->pObj->content = $XHTML_clean->XHTML_clean($this->pObj->content);
$GLOBALS['TT']->pull();
}
}
/**
* XHTML-clean the code, if flag config.xhtml_cleaning is set
* to "cached", same goes for config.prefixLocalAnchors
*
* @param array $parameters
* @param \TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController $parentObject
*/
public function contentPostProcCached(&$parameters, $parentObject)
{
$this->pObj = $parentObject;
// Fix local anchors in links, if flag set
if ($this->doLocalAnchorFix() === 'cached') {
$GLOBALS['TT']->push('Local anchor fix, cached', '');
$this->prefixLocalAnchorsWithScript();
$GLOBALS['TT']->pull();
}
// XHTML-clean the code, if flag set
if ($this->doXHTML_cleaning() === 'cached') {
$GLOBALS['TT']->push('XHTML clean, cached', '');
$XHTML_clean = GeneralUtility::makeInstance(HtmlParser::class);
$this->pObj->content = $XHTML_clean->XHTML_clean($this->pObj->content);
$GLOBALS['TT']->pull();
}
}
/**
* XHTML-clean the code, if flag config.xhtml_cleaning is set
* to "output", same goes for config.prefixLocalAnchors
*
* @param array $parameters
* @param \TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController $parentObject
*/
public function contentPostProcOutput(&$parameters, $parentObject)
{
$this->pObj = $parentObject;
// Fix local anchors in links, if flag set
if ($this->doLocalAnchorFix() === 'output') {
$GLOBALS['TT']->push('Local anchor fix, output', '');
$this->prefixLocalAnchorsWithScript();
$GLOBALS['TT']->pull();
}
// XHTML-clean the code, if flag set
if ($this->doXHTML_cleaning() === 'output') {
$GLOBALS['TT']->push('XHTML clean, output', '');
$XHTML_clean = GeneralUtility::makeInstance(HtmlParser::class);
$this->pObj->content = $XHTML_clean->XHTML_clean($this->pObj->content);
$GLOBALS['TT']->pull();
}
}
/**
* Returns the mode of XHTML cleaning
*
* @return string Keyword: "all", "cached", "none" or "output"
*/
protected function doXHTML_cleaning()
{
if ($this->pObj->config['config']['xmlprologue'] === 'none') {
return 'none';
}
return $this->pObj->config['config']['xhtml_cleaning'];
}
/**
* Returns the mode of Local Anchor prefixing
*
* @return string Keyword: "all", "cached" or "output"
*/
public function doLocalAnchorFix()
{
return isset($this->pObj->config['config']['prefixLocalAnchors']) ? $this->pObj->config['config']['prefixLocalAnchors'] : null;
}
/**
* Substitutes all occurrences of <a href="#"... in $this->content with <a href="[path-to-url]#"...
*
* @return void Works directly on $this->content
*/
protected function prefixLocalAnchorsWithScript()
{
if (!$this->pObj->beUserLogin) {
if (!is_object($this->pObj->cObj)) {
$this->pObj->newCObj();
}
$scriptPath = $this->pObj->cObj->getUrlToCurrentLocation();
} else {
// To break less existing sites, we allow the REQUEST_URI to be used for the prefix
$scriptPath = GeneralUtility::getIndpEnv('REQUEST_URI');
// Disable the cache so that these URI will not be the ones to be cached
$this->pObj->no_cache = true;
}
$originalContent = $this->pObj->content;
$this->pObj->content = preg_replace('/(<(?:a|area).*?href=")(#[^"]*")/i', '${1}' . htmlspecialchars($scriptPath) . '${2}', $originalContent);
// There was an error in the call to preg_replace, so keep the original content (behavior prior to PHP 5.2)
if (preg_last_error() > 0) {
GeneralUtility::sysLog('preg_replace returned error-code: ' . preg_last_error() . ' in function prefixLocalAnchorsWithScript. Replacement not done!', 'cms', GeneralUtility::SYSLOG_SEVERITY_FATAL);
$this->pObj->content = $originalContent;
}
}
}