Commit 5fd24499 authored by Nicole Cordes's avatar Nicole Cordes Committed by Benni Mack
Browse files

[TASK] Streamline usage of PageRenderer

The PageRenderer is a Singleton and only one instance exists during
runtime. This patch cleans up the usage and prevents sharing the
PageRenderer object over public getters. This helps to improve the api
and get rid of unnecessary functions.

Releases: master
Resolves: #68074
Change-Id: I66abd565df96ff0b8fb31d24a04721ca8ecb3f3a
Reviewed-on: http://review.typo3.org/41131


Reviewed-by: Georg Ringer's avatarGeorg Ringer <georg.ringer@gmail.com>
Tested-by: Georg Ringer's avatarGeorg Ringer <georg.ringer@gmail.com>
Reviewed-by: Benni Mack's avatarBenjamin Mack <benni@typo3.org>
Tested-by: Benni Mack's avatarBenjamin Mack <benni@typo3.org>
parent b1b99012
......@@ -14,11 +14,12 @@ namespace TYPO3\CMS\Backend\Backend\ToolbarItems;
* The TYPO3 project - inspiring people to share!
*/
use TYPO3\CMS\Backend\Toolbar\ToolbarItemInterface;
use TYPO3\CMS\Backend\Toolbar\ClearCacheActionsHookInterface;
use TYPO3\CMS\Backend\Utility\BackendUtility;
use TYPO3\CMS\Backend\Utility\IconUtility;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Backend\Toolbar\ToolbarItemInterface;
use TYPO3\CMS\Backend\Toolbar\ClearCacheActionsHookInterface;
use TYPO3\CMS\Core\Page\PageRenderer;
/**
* Render cache clearing toolbar item
......@@ -189,12 +190,10 @@ class ClearCacheToolbarItem implements ToolbarItemInterface {
/**
* Returns current PageRenderer
*
* @return \TYPO3\CMS\Core\Page\PageRenderer
* @return PageRenderer
*/
protected function getPageRenderer() {
/** @var \TYPO3\CMS\Backend\Template\DocumentTemplate $documentTemplate */
$documentTemplate = $GLOBALS['TBE_TEMPLATE'];
return $documentTemplate->getPageRenderer();
return GeneralUtility::makeInstance(PageRenderer::class);
}
/**
......
......@@ -16,6 +16,7 @@ namespace TYPO3\CMS\Backend\Backend\ToolbarItems;
use TYPO3\CMS\Backend\Toolbar\ToolbarItemInterface;
use TYPO3\CMS\Backend\Module\ModuleLoader;
use TYPO3\CMS\Core\Page\PageRenderer;
use TYPO3\CMS\Core\Utility\GeneralUtility;
/**
......@@ -105,12 +106,10 @@ class LiveSearchToolbarItem implements ToolbarItemInterface {
/**
* Returns current PageRenderer
*
* @return \TYPO3\CMS\Core\Page\PageRenderer
* @return PageRenderer
*/
protected function getPageRenderer() {
/** @var \TYPO3\CMS\Backend\Template\DocumentTemplate $documentTemplate */
$documentTemplate = $GLOBALS['TBE_TEMPLATE'];
return $documentTemplate->getPageRenderer();
return GeneralUtility::makeInstance(PageRenderer::class);
}
}
......@@ -14,13 +14,14 @@ namespace TYPO3\CMS\Backend\Backend\ToolbarItems;
* The TYPO3 project - inspiring people to share!
*/
use TYPO3\CMS\Backend\Module\ModuleLoader;
use TYPO3\CMS\Backend\Toolbar\ToolbarItemInterface;
use TYPO3\CMS\Backend\Utility\BackendUtility;
use TYPO3\CMS\Backend\Utility\IconUtility;
use TYPO3\CMS\Core\Http\AjaxRequestHandler;
use TYPO3\CMS\Core\Page\PageRenderer;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Utility\MathUtility;
use TYPO3\CMS\Backend\Toolbar\ToolbarItemInterface;
use TYPO3\CMS\Backend\Module\ModuleLoader;
use TYPO3\CMS\Core\Http\AjaxRequestHandler;
use TYPO3\CMS\Core\Utility\PathUtility;
/**
......@@ -759,12 +760,10 @@ class ShortcutToolbarItem implements ToolbarItemInterface {
/**
* Returns current PageRenderer
*
* @return \TYPO3\CMS\Core\Page\PageRenderer
* @return PageRenderer
*/
protected function getPageRenderer() {
/** @var \TYPO3\CMS\Backend\Template\DocumentTemplate $documentTemplate */
$documentTemplate = $GLOBALS['TBE_TEMPLATE'];
return $documentTemplate->getPageRenderer();
return GeneralUtility::makeInstance(PageRenderer::class);
}
/**
......
......@@ -19,6 +19,7 @@ use TYPO3\CMS\Backend\Toolbar\Enumeration\InformationStatus;
use TYPO3\CMS\Backend\Utility\BackendUtility;
use TYPO3\CMS\Backend\Utility\IconUtility;
use TYPO3\CMS\Core\Http\AjaxRequestHandler;
use \TYPO3\CMS\Core\Page\PageRenderer;
use TYPO3\CMS\Core\Utility\CommandUtility;
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
use TYPO3\CMS\Core\Utility\GeneralUtility;
......@@ -89,8 +90,7 @@ class SystemInformationToolbarItem implements ToolbarItemInterface {
$this->standaloneView = GeneralUtility::makeInstance(StandaloneView::class);
$this->standaloneView->setTemplatePathAndFilename($extPath . 'Resources/Private/Templates/ToolbarMenu/' . static::TOOLBAR_MENU_TEMPLATE);
$pageRenderer = $this->getPageRenderer();
$pageRenderer->loadRequireJsModule('TYPO3/CMS/Backend/Toolbar/SystemInformationMenu');
$this->getPageRenderer()->loadRequireJsModule('TYPO3/CMS/Backend/Toolbar/SystemInformationMenu');
}
/**
......@@ -350,12 +350,10 @@ class SystemInformationToolbarItem implements ToolbarItemInterface {
/**
* Returns current PageRenderer
*
* @return \TYPO3\CMS\Core\Page\PageRenderer
* @return PageRenderer
*/
protected function getPageRenderer() {
/** @var \TYPO3\CMS\Backend\Template\DocumentTemplate $documentTemplate */
$documentTemplate = $GLOBALS['TBE_TEMPLATE'];
return $documentTemplate->getPageRenderer();
return GeneralUtility::makeInstance(PageRenderer::class);
}
/**
......
......@@ -14,12 +14,13 @@ namespace TYPO3\CMS\Backend\Controller;
* The TYPO3 project - inspiring people to share!
*/
use TYPO3\CMS\Backend\Utility\BackendUtility;
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Backend\Domain\Repository\Module\BackendModuleRepository;
use TYPO3\CMS\Backend\Module\ModuleLoader;
use TYPO3\CMS\Backend\Toolbar\ToolbarItemInterface;
use TYPO3\CMS\Backend\Utility\BackendUtility;
use TYPO3\CMS\Core\Page\PageRenderer;
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Utility\MathUtility;
use TYPO3\CMS\Fluid\View\StandaloneView;
use TYPO3\CMS\Rsaauth\RsaEncryptionEncoder;
......@@ -87,14 +88,16 @@ class BackendController {
protected $moduleLoader;
/**
* @var \TYPO3\CMS\Core\Page\PageRenderer
* @var PageRenderer
*/
protected $pageRenderer;
/**
* @return \TYPO3\CMS\Core\Page\PageRenderer
* @return PageRenderer
* @deprecated since TYPO3 CMS 7, will be removed in TYPO3 CMS 8
*/
public function getPageRenderer() {
GeneralUtility::logDeprecatedFunction();
return $this->pageRenderer;
}
......@@ -109,7 +112,7 @@ class BackendController {
// Initializes the backend modules structure for use later.
$this->moduleLoader = GeneralUtility::makeInstance(ModuleLoader::class);
$this->moduleLoader->load($GLOBALS['TBE_MODULES']);
$this->pageRenderer = $this->getDocumentTemplate()->getPageRenderer();
$this->pageRenderer = GeneralUtility::makeInstance(PageRenderer::class);
$this->pageRenderer->loadExtJS();
// included for the module menu JavaScript, please note that this is subject to change
$this->pageRenderer->loadJquery();
......
......@@ -14,12 +14,13 @@ namespace TYPO3\CMS\Backend\Controller;
* The TYPO3 project - inspiring people to share!
*/
use TYPO3\CMS\Backend\Template\DocumentTemplate;
use TYPO3\CMS\Backend\Utility\BackendUtility;
use TYPO3\CMS\Backend\Utility\IconUtility;
use TYPO3\CMS\Core\Page\PageRenderer;
use TYPO3\CMS\Core\TypoScript\Parser\TypoScriptParser;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
use TYPO3\CMS\Core\TypoScript\Parser\TypoScriptParser;
use TYPO3\CMS\Backend\Template\DocumentTemplate;
use TYPO3\CMS\Backend\Utility\BackendUtility;
/**
......@@ -81,7 +82,7 @@ class BackendLayoutWizardController {
// Initialize document object:
$this->doc = GeneralUtility::makeInstance(DocumentTemplate::class);
$this->doc->backPath = $GLOBALS['BACK_PATH'];
$pageRenderer = $this->doc->getPageRenderer();
$pageRenderer = GeneralUtility::makeInstance(PageRenderer::class);
$pageRenderer->loadExtJS();
$pageRenderer->addJsFile(ExtensionManagementUtility::extRelPath('backend') . 'Resources/Public/JavaScript/grideditor.js');
$pageRenderer->addInlineSetting('ContextHelp', 'moduleUrl', BackendUtility::getModuleUrl('help_cshmanual'));
......
......@@ -14,22 +14,23 @@ namespace TYPO3\CMS\Backend\Controller;
* The TYPO3 project - inspiring people to share!
*/
use TYPO3\CMS\Backend\Form\DataPreprocessor;
use TYPO3\CMS\Backend\Form\FormEngine;
use TYPO3\CMS\Backend\Form\Utility\FormEngineUtility;
use TYPO3\CMS\Backend\Utility\BackendUtility;
use TYPO3\CMS\Backend\Utility\IconUtility;
use TYPO3\CMS\Core\DataHandling\DataHandler;
use TYPO3\CMS\Core\Html\HtmlParser;
use TYPO3\CMS\Core\Messaging\FlashMessage;
use TYPO3\CMS\Core\Messaging\FlashMessageService;
use TYPO3\CMS\Core\Page\PageRenderer;
use TYPO3\CMS\Core\Type\Bitmask\JsConfirmation;
use TYPO3\CMS\Core\Type\Bitmask\Permission;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Utility\HttpUtility;
use TYPO3\CMS\Core\Utility\MathUtility;
use TYPO3\CMS\Frontend\Page\PageRepository;
use TYPO3\CMS\Backend\Form\Utility\FormEngineUtility;
use TYPO3\CMS\Extbase\SignalSlot\Dispatcher;
use TYPO3\CMS\Core\DataHandling\DataHandler;
use TYPO3\CMS\Backend\Form\DataPreprocessor;
use TYPO3\CMS\Core\Messaging\FlashMessage;
use TYPO3\CMS\Core\Messaging\FlashMessageService;
use TYPO3\CMS\Frontend\Page\PageRepository;
/**
* Script Class: Drawing the editing form for editing records in TYPO3.
......@@ -679,11 +680,12 @@ class EditDocumentController {
$this->MCONF['name'] = 'xMOD_alt_doc.php';
// Create an instance of the document template object
$this->doc = $GLOBALS['TBE_TEMPLATE'];
$this->doc->getPageRenderer()->addInlineLanguageLabelFile('EXT:lang/locallang_alt_doc.xlf');
$pageRenderer = GeneralUtility::makeInstance(PageRenderer::class);
$pageRenderer->addInlineLanguageLabelFile('EXT:lang/locallang_alt_doc.xlf');
$pageRenderer->loadPrototype();
$this->doc->backPath = $GLOBALS['BACK_PATH'];
$this->doc->setModuleTemplate('EXT:backend/Resources/Private/Templates/alt_doc.html');
$this->doc->form = '<form action="' . htmlspecialchars($this->R_URI) . '" method="post" enctype="' . $GLOBALS['TYPO3_CONF_VARS']['SYS']['form_enctype'] . '" name="editform" onsubmit="document.editform._scrollPosition.value=(document.documentElement.scrollTop || document.body.scrollTop); return TBE_EDITOR.checkSubmit(1);">';
$this->doc->getPageRenderer()->loadPrototype();
// override the default jumpToUrl
$this->doc->JScodeArray['jumpToUrl'] = '
function jumpToUrl(URL,formEl) {
......
......@@ -20,6 +20,7 @@ use TYPO3\CMS\Backend\Utility\BackendUtility;
use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
use TYPO3\CMS\Core\FormProtection\BackendFormProtection;
use TYPO3\CMS\Core\FormProtection\FormProtectionFactory;
use TYPO3\CMS\Core\Page\PageRenderer;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Utility\HttpUtility;
use TYPO3\CMS\Core\Utility\PathUtility;
......@@ -144,8 +145,8 @@ class LoginController implements \TYPO3\CMS\Core\Http\ControllerInterface {
* @return string The content to output
*/
public function main() {
/** @var $pageRenderer \TYPO3\CMS\Core\Page\PageRenderer */
$pageRenderer = $this->getDocumentTemplate()->getPageRenderer();
/** @var $pageRenderer PageRenderer */
$pageRenderer = GeneralUtility::makeInstance(PageRenderer::class);
$pageRenderer->loadRequireJsModule('TYPO3/CMS/Backend/Login');
// support placeholders for IE9 and lower
......
......@@ -16,6 +16,7 @@ namespace TYPO3\CMS\Backend\Controller;
use TYPO3\CMS\Backend\Utility\BackendUtility;
use TYPO3\CMS\Core\Page\PageRenderer;
use TYPO3\CMS\Core\Utility\GeneralUtility;
/**
* Script Class, putting the frameset together.
......@@ -40,7 +41,7 @@ class LoginFramesetController {
$this->getDocumentTemplate()->startPage($title);
// Create the frameset for the window
$this->content = $this->getDocumentTemplate()->getPageRenderer()->render(PageRenderer::PART_HEADER) . '
$this->content = $this->getPageRenderer()->render(PageRenderer::PART_HEADER) . '
<frameset rows="*,1">
<frame name="login" src="index.php?loginRefresh=1" marginwidth="0" marginheight="0" scrolling="no" noresize="noresize" />
<frame name="dummy" src="' . htmlspecialchars(BackendUtility::getModuleUrl('dummy')) . '" marginwidth="0" marginheight="0" scrolling="auto" noresize="noresize" />
......@@ -66,4 +67,11 @@ class LoginFramesetController {
return $GLOBALS['TBE_TEMPLATE'];
}
/**
* @return PageRenderer
*/
protected function getPageRenderer() {
return GeneralUtility::makeInstance(PageRenderer::class);
}
}
......@@ -14,15 +14,16 @@ namespace TYPO3\CMS\Backend\Controller;
* The TYPO3 project - inspiring people to share!
*/
use TYPO3\CMS\Backend\Template\DocumentTemplate;
use TYPO3\CMS\Backend\Utility\BackendUtility;
use TYPO3\CMS\Backend\Utility\IconUtility;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Backend\View\PageTreeView;
use TYPO3\CMS\Backend\Template\DocumentTemplate;
use TYPO3\CMS\Core\Messaging\FlashMessage;
use TYPO3\CMS\Core\Page\PageRenderer;
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
use TYPO3\CMS\Workspaces\Service\WorkspaceService;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Utility\MathUtility;
use TYPO3\CMS\Workspaces\Service\WorkspaceService;
/**
* Main script class for the page tree navigation frame
......@@ -156,8 +157,8 @@ class PageTreeNavigationController {
// Adding javascript code for drag&drop and the pagetree as well as the click menu code
$this->doc->getDragDropCode('pages', $dragDropCode);
$this->doc->getContextMenuCode();
/** @var $pageRenderer \TYPO3\CMS\Core\Page\PageRenderer */
$pageRenderer = $this->doc->getPageRenderer();
/** @var $pageRenderer PageRenderer */
$pageRenderer = GeneralUtility::makeInstance(PageRenderer::class);
$pageRenderer->loadExtJS();
$this->doc->JScode .= $this->doc->wrapScriptTags(($this->currentSubScript ? 'top.currentSubScript=unescape("' . rawurlencode($this->currentSubScript) . '");' : '') . '
// Function, loading the list frame from navigation tree:
......
......@@ -16,6 +16,7 @@ namespace TYPO3\CMS\Backend\Controller\Wizard;
use TYPO3\CMS\Backend\Template\DocumentTemplate;
use TYPO3\CMS\Backend\Utility\BackendUtility;
use TYPO3\CMS\Core\Page\PageRenderer;
use TYPO3\CMS\Core\Utility\GeneralUtility;
/**
......@@ -293,7 +294,7 @@ class ColorpickerController extends AbstractWizardController {
'fieldChangeFuncHash' => $this->P['fieldChangeFuncHash'],
)
);
$this->content = $this->getDocumentTemplate()->getPageRenderer()->render(\TYPO3\CMS\Core\Page\PageRenderer::PART_HEADER) . '
$this->content = $this->getPageRenderer()->render(PageRenderer::PART_HEADER) . '
<frameset rows="*,1" framespacing="0" frameborder="0" border="0">
<frame name="content" src="' . htmlspecialchars($url) . '" marginwidth="0" marginheight="0" frameborder="0" scrolling="auto" noresize="noresize" />
<frame name="menu" src="' . htmlspecialchars(BackendUtility::getModuleUrl('dummy')) . '" marginwidth="0" marginheight="0" frameborder="0" scrolling="no" noresize="noresize" />
......@@ -434,4 +435,11 @@ class ColorpickerController extends AbstractWizardController {
return $this->fieldChangeFunc && $this->fieldChangeFuncHash && $this->fieldChangeFuncHash === GeneralUtility::hmac($this->fieldChangeFunc);
}
/**
* @return PageRenderer
*/
protected function getPageRenderer() {
return GeneralUtility::makeInstance(PageRenderer::class);
}
}
......@@ -14,15 +14,15 @@ namespace TYPO3\CMS\Backend\Form\Element;
* The TYPO3 project - inspiring people to share!
*/
use TYPO3\CMS\Backend\Form\FormEngine;
use TYPO3\CMS\Backend\Form\NodeFactory;
use TYPO3\CMS\Backend\Utility\BackendUtility;
use TYPO3\CMS\Core\Page\PageRenderer;
use TYPO3\CMS\Core\Resource\Exception\FileDoesNotExistException;
use TYPO3\CMS\Core\Resource\File;
use TYPO3\CMS\Core\Resource\ResourceFactory;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Utility\MathUtility;
use TYPO3\CMS\Extbase\Utility\ArrayUtility;
use TYPO3\CMS\Backend\Form\NodeFactory;
/**
* Generation of image manipulation TCEform element
......@@ -133,8 +133,8 @@ class ImageManipulationElement extends AbstractFormElement {
$content .= $this->getImageManipulationInfoTable($parameterArray['itemFormElValue']);
/** @var $pageRenderer \TYPO3\CMS\Core\Page\PageRenderer */
$pageRenderer = $GLOBALS['SOBE']->doc->getPageRenderer();
/** @var $pageRenderer PageRenderer */
$pageRenderer = GeneralUtility::makeInstance(PageRenderer::class);
$pageRenderer->loadRequireJsModule(
'TYPO3/CMS/Backend/ImageManipulation',
'function(ImageManipulation){ImageManipulation.initializeTrigger()}' // Initialize after load
......
......@@ -14,18 +14,18 @@ namespace TYPO3\CMS\Backend\Form\Element;
* The TYPO3 project - inspiring people to share!
*/
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Backend\Utility\BackendUtility;
use TYPO3\CMS\Core\Utility\MathUtility;
use TYPO3\CMS\Backend\Form\Utility\FormEngineUtility;
use TYPO3\CMS\Lang\LanguageService;
use TYPO3\CMS\Backend\Utility\BackendUtility;
use TYPO3\CMS\Backend\Utility\IconUtility;
use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
use TYPO3\CMS\Core\Page\PageRenderer;
use TYPO3\CMS\Core\Tree\TableConfiguration\ExtJsArrayTreeRenderer;
use TYPO3\CMS\Core\Tree\TableConfiguration\TableConfigurationTree;
use TYPO3\CMS\Core\Tree\TableConfiguration\TreeDataProviderFactory;
use TYPO3\CMS\Core\Type\Bitmask\JsConfirmation;
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
use TYPO3\CMS\Backend\Utility\IconUtility;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Lang\LanguageService;
/**
* Render data as a tree.
......@@ -167,8 +167,8 @@ class SelectTreeElement extends AbstractFormElement {
$onChange .= 'if (TBE_EDITOR.checkSubmit(-1)){ TBE_EDITOR.submitForm() };';
}
}
/** @var $pageRenderer \TYPO3\CMS\Core\Page\PageRenderer */
$pageRenderer = $GLOBALS['SOBE']->doc->getPageRenderer();
/** @var $pageRenderer PageRenderer */
$pageRenderer = GeneralUtility::makeInstance(PageRenderer::class);
$pageRenderer->loadExtJs();
$pageRenderer->addJsFile('sysext/backend/Resources/Public/JavaScript/tree.js');
$pageRenderer->addInlineLanguageLabelFile(ExtensionManagementUtility::extPath('lang') . 'locallang_csh_corebe.xlf', 'tcatree');
......
......@@ -22,15 +22,12 @@ use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
use TYPO3\CMS\Core\FormProtection\FormProtectionFactory;
use TYPO3\CMS\Core\Html\HtmlParser;
use TYPO3\CMS\Core\Http\AjaxRequestHandler;
use TYPO3\CMS\Core\Page\PageRenderer;
use TYPO3\CMS\Core\Utility\ArrayUtility;
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Utility\MathUtility;
use TYPO3\CMS\Lang\LanguageService;
use TYPO3\CMS\Backend\Form\Container\FullRecordContainer;
use TYPO3\CMS\Backend\Form\Container\SoloFieldContainer;
use TYPO3\CMS\Backend\Form\Container\InlineRecordContainer;
use TYPO3\CMS\Backend\Form\Container\ListOfFieldsContainer;
use TYPO3\CMS\Core\Utility\ArrayUtility;
/**
* This is form engine - Class for creating the backend editing forms.
......@@ -213,6 +210,11 @@ class FormEngine {
*/
protected $requireJsModules = array();
/**
* @var PageRenderer
*/
protected $pageRenderer = NULL;
/**
* Constructor function, setting internal variables, loading the styles used.
*
......@@ -1055,8 +1057,8 @@ class FormEngine {
* @todo: aaaargs ...
*/
protected function getJavaScriptOfPageRenderer() {
/** @var $pageRenderer \TYPO3\CMS\Core\Page\PageRenderer */
$pageRenderer = clone $GLOBALS['SOBE']->doc->getPageRenderer();
/** @var $pageRenderer PageRenderer */
$pageRenderer = clone $this->getPageRenderer();
$pageRenderer->setCharSet($this->getLanguageService()->charSet);
$pageRenderer->setTemplateFile('EXT:backend/Resources/Private/Templates/helper_javascript_css.html');
return $pageRenderer->render();
......@@ -1220,7 +1222,6 @@ class FormEngine {
if ($this->loadMD5_JS) {
$this->loadJavascriptLib('sysext/backend/Resources/Public/JavaScript/md5.js');
}
$pageRenderer = $this->getPageRenderer();
// load the main module for FormEngine with all important JS functions
$this->requireJsModules['TYPO3/CMS/Backend/FormEngine'] = 'function(FormEngine) {
FormEngine.setBrowserUrl(' . GeneralUtility::quoteJSvalue(BackendUtility::getModuleUrl('browser')) . ');
......@@ -1235,26 +1236,26 @@ class FormEngine {
$callbacks = array($callbacks);
}
foreach ($callbacks as $callback) {
$pageRenderer->loadRequireJsModule($moduleName, $callback);
$this->getPageRenderer()->loadRequireJsModule($moduleName, $callback);
}
}
$pageRenderer->loadPrototype();
$pageRenderer->loadJquery();
$pageRenderer->loadExtJS();
$this->getPageRenderer()->loadPrototype();
$this->getPageRenderer()->loadJquery();
$this->getPageRenderer()->loadExtJS();
// rtehtmlarea needs extjs quick tips (?)
$pageRenderer->enableExtJSQuickTips();
$this->getPageRenderer()->enableExtJSQuickTips();
$beUserAuth = $this->getBackendUserAuthentication();
// Make textareas resizable and flexible ("autogrow" in height)
$textareaSettings = array(
'autosize' => (bool)$beUserAuth->uc['resizeTextareas_Flexible']
);
$pageRenderer->addInlineSettingArray('Textarea', $textareaSettings);
$this->getPageRenderer()->addInlineSettingArray('Textarea', $textareaSettings);
$this->loadJavascriptLib('sysext/backend/Resources/Public/JavaScript/jsfunc.tbe_editor.js');
$pageRenderer->loadRequireJsModule('TYPO3/CMS/Backend/ValueSlider');
$this->getPageRenderer()->loadRequireJsModule('TYPO3/CMS/Backend/ValueSlider');
// Needed for FormEngine manipulation (date picker)
$dateFormat = ($GLOBALS['TYPO3_CONF_VARS']['SYS']['USdateFormat'] ? array('MM-DD-YYYY', 'HH:mm MM-DD-YYYY') : array('DD-MM-YYYY', 'HH:mm DD-MM-YYYY'));
$pageRenderer->addInlineSetting('DateTimePicker', 'DateFormat', $dateFormat);
$this->getPageRenderer()->addInlineSetting('DateTimePicker', 'DateFormat', $dateFormat);
// support placeholders for IE9 and lower
$clientInfo = GeneralUtility::clientInfo();
......@@ -1263,13 +1264,13 @@ class FormEngine {
}
// @todo: remove scriptaclous once suggest & flex form foo is moved to RequireJS, see #55575
$pageRenderer->loadScriptaculous();
$this->getPageRenderer()->loadScriptaculous();
$this->loadJavascriptLib('sysext/backend/Resources/Public/JavaScript/jsfunc.tceforms_suggest.js');
$pageRenderer->loadRequireJsModule('TYPO3/CMS/Filelist/FileListLocalisation');
$pageRenderer->loadRequireJsModule('TYPO3/CMS/Backend/DragUploader');
$this->getPageRenderer()->loadRequireJsModule('TYPO3/CMS/Filelist/FileListLocalisation');
$this->getPageRenderer()->loadRequireJsModule('TYPO3/CMS/Backend/DragUploader');
$pageRenderer->addInlineLanguagelabelFile(
$this->getPageRenderer()->addInlineLanguagelabelFile(
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('lang') . 'locallang_core.xlf',
'file_upload'
);
......@@ -1327,15 +1328,12 @@ class FormEngine {
* @return string
*/
public function printNeededJSFunctions() {
/** @var $pageRenderer \TYPO3\CMS\Core\Page\PageRenderer */
$pageRenderer = $this->getControllerDocumentTemplate()->getPageRenderer();
// set variables to be accessible for JS
$pageRenderer->addInlineSetting('FormEngine', 'formName', 'editform');
$pageRenderer->addInlineSetting('FormEngine', 'backPath', '');
$this->getPageRenderer()->addInlineSetting('FormEngine', 'formName', 'editform');
$this->getPageRenderer()->addInlineSetting('FormEngine', 'backPath', '');
// Integrate JS functions for the element browser if such fields or IRRE fields were processed
$pageRenderer->addInlineSetting('FormEngine', 'legacyFieldChangedCb', 'function() { ' . $this->TBE_EDITOR_fieldChanged_func . ' };');
$this->getPageRenderer()->addInlineSetting('FormEngine', 'legacyFieldChangedCb', 'function() { ' . $this->TBE_EDITOR_fieldChanged_func . ' };');
return $this->JSbottom('editform');
}
......@@ -1467,7 +1465,11 @@ class FormEngine {
* @return \TYPO3\CMS\Core\Page\PageRenderer
*/
protected function getPageRenderer() {
return $this->getControllerDocumentTemplate()->getPageRenderer();
if ($this->pageRenderer === NULL) {
$this->pageRenderer = GeneralUtility::makeInstance(PageRenderer::class);
}
return $this->pageRenderer;
}
}
......@@ -18,6 +18,7 @@ use TYPO3\CMS\Backend\Template\DocumentTemplate;
use TYPO3\CMS\Backend\Utility\BackendUtility;
use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
use TYPO3\CMS\Core\Database\DatabaseConnection;
use TYPO3\CMS\Core\Page\PageRenderer;
use TYPO3\CMS\Core\Utility\ArrayUtility;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Lang\LanguageService;
......@@ -156,6 +157,11 @@ abstract class AbstractFunctionModule {
*/
public $function_key = '';
/**
* @var PageRenderer
*/
protected $pageRenderer = NULL;
/**
* Initialize the object
*
......@@ -287,4 +293,15 @@ abstract class AbstractFunctionModule {
return $GLOBALS['TYPO3_DB'];
}
/**
* @return PageRenderer
*/
protected function getPageRenderer() {
if ($this->pageRenderer === NULL) {
$this->pageRenderer = GeneralUtility::makeInstance(PageRenderer::class);
}
return $this->pageRenderer;
}
}
......@@ -18,6 +18,7 @@ use TYPO3\CMS\Backend\Utility\BackendUtility;
use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
use TYPO3\CMS\Core\Database\DatabaseConnection;
use TYPO3\CMS\Core\Messaging\FlashMessage;
use TYPO3\CMS\Core\Page\PageRenderer;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Lang\LanguageService;