Skip to content
Snippets Groups Projects
Commit b3908e99 authored by Mathias Schreiber's avatar Mathias Schreiber Committed by Frans Saris
Browse files

[TASK] Use ModuleTemplate API for EXT:viewpage

Releases: master
Resolves: #70365
Change-Id: I95315d1b713d28df0ec5f6fdde61eb2abc10a182
Reviewed-on: http://review.typo3.org/43812


Reviewed-by: default avatarWouter Wolters <typo3@wouterwolters.nl>
Tested-by: default avatarWouter Wolters <typo3@wouterwolters.nl>
Reviewed-by: default avatarFrans Saris <franssaris@gmail.com>
Tested-by: default avatarFrans Saris <franssaris@gmail.com>
parent 962915a0
Branches
Tags
No related merge requests found
......@@ -14,14 +14,73 @@ namespace TYPO3\CMS\Viewpage\Controller;
* The TYPO3 project - inspiring people to share!
*/
use TYPO3\CMS\Backend\Template\Components\ButtonBar;
use TYPO3\CMS\Backend\Utility\BackendUtility;
use TYPO3\CMS\Backend\View\BackendTemplateView;
use TYPO3\CMS\Core\Imaging\Icon;
use TYPO3\CMS\Core\Page\PageRenderer;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Mvc\Controller\ActionController;
use TYPO3\CMS\Extbase\Mvc\View\ViewInterface;
/**
* Controller for viewing the frontend
*/
class ViewModuleController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionController {
class ViewModuleController extends ActionController {
/**
* @var string
*/
protected $defaultViewObjectName = BackendTemplateView::class;
/**
* @var BackendTemplateView
*/
protected $view;
/**
* Set up the doc header properly here
*
* @param ViewInterface $view
*/
protected function initializeView(ViewInterface $view) {
/** @var BackendTemplateView $view */
parent::initializeView($view);
$this->registerButtons();
}
/**
* Registers the docheader buttons
*/
protected function registerButtons() {
$iconFactory = $this->view->getModuleTemplate()->getIconFactory();
$buttonBar = $this->view->getModuleTemplate()->getDocHeaderComponent()->getButtonBar();
$showButton = $buttonBar->makeLinkButton()
->setHref($this->getTargetUrl())
->setOnClick('window.open(this.href, \'newTYPO3frontendWindow\').focus();return false;')
->setTitle($this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:labels.showPage', TRUE))
->setIcon($iconFactory->getIcon('actions-document-view', Icon::SIZE_SMALL));
$buttonBar->addButton($showButton);
$refreshButton = $buttonBar->makeLinkButton()
->setHref('javascript:document.getElementById(\'tx_viewpage_iframe\').contentWindow.location.reload(true);')
->setTitle($this->getLanguageService()->sL('LLL:EXT:viewpage/Resources/Private/Language/locallang.xlf:refreshPage'))
->setIcon($iconFactory->getIcon('actions-refresh', Icon::SIZE_SMALL));
$buttonBar->addButton($refreshButton, ButtonBar::BUTTON_POSITION_RIGHT, 1);
$currentRequest = $this->request;
$moduleName = $currentRequest->getPluginName();
$getVars = $this->request->getArguments();
$extensionName = $currentRequest->getControllerExtensionName();
if (count($getVars) === 0) {
$modulePrefix = strtolower('tx_' . $extensionName . '_' . $moduleName);
$getVars = array('id', 'M', $modulePrefix);
}
$getList = implode(',', $getVars);
$shortcutButton = $buttonBar->makeFullyRenderedButton()
->setHtmlSource($this->view->getModuleTemplate()->makeShortcutIcon($getList, '', $moduleName));
$buttonBar->addButton($shortcutButton, ButtonBar::BUTTON_POSITION_RIGHT, 2);
}
/**
* Gets called before each action
......@@ -52,6 +111,11 @@ class ViewModuleController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionContr
*/
protected function getTargetUrl() {
$pageIdToShow = (int)GeneralUtility::_GP('id');
$permissionClause = $this->getBackendUser()->getPagePermsClause(1);
$pageRecord = BackendUtility::readPageAccess($pageIdToShow, $permissionClause);
$this->view->getModuleTemplate()->getDocHeaderComponent()->setMetaInformation($pageRecord);
$adminCommand = $this->getAdminCommand($pageIdToShow);
$domainName = $this->getDomainName($pageIdToShow);
$languageParameter = $this->getLanguageParameter();
......
{namespace core=TYPO3\CMS\Core\ViewHelpers}
<f:be.container
<f:be.pageRenderer
includeCssFiles="{
0:'{f:uri.resource(path:\'Css/ui-lightness/jquery-ui-1.10.3.custom.min.css\')}',
1:'{f:uri.resource(path:\'Css/main.css\')}'
}"
includeRequireJsModules="{
0:'TYPO3/CMS/Viewpage/Main'
}">
<div class="typo3-fullDoc">
<div id="typo3-docheader">
<div class="typo3-docheader-functions">
<form>
<label for="width">
<f:translate key="width" />
</label>
<f:form.select options="{widths}" id="width" name="width" />
<f:if condition="{languages -> f:count()} > 1">
<label for="language">
<f:translate key="language" />
</label>
<f:form.select options="{languages}" id="language" name="language" />
</f:if>
</form>
</div>
<div class="typo3-docheader-buttons">
<div class="left">
<a href="{url}" onclick="window.open(this.href, 'newTYPO3frontendWindow').focus();return false;" title="{f:translate(key: 'LLL:EXT:lang/locallang_core.xlf:labels.showPage')}">
<core:icon identifier="actions-document-view" />
</a>
</div>
<div class="right">
<a href="javascript:document.getElementById('tx_viewpage_iframe').contentWindow.location.reload(true);" title="{f:translate(key: 'refreshPage')}">
<core:icon identifier="actions-refresh" />
</a>
<f:be.buttons.shortcut/>
</div>
</div>
</div>
<div id="typo3-docbody">
<div id="typo3-inner-docbody" class="tx_viewpage">
<f:render section="Content" />
</div>
</div>
</div>
</f:be.container>
}" />
<div class="tx_viewpage">
<form>
<label for="width">
<f:translate key="width" />
</label>
<f:form.select options="{widths}" id="width" name="width" />
<f:if condition="{languages -> f:count()} > 1">
<label for="language">
<f:translate key="language" />
</label>
<f:form.select options="{languages}" id="language" name="language" />
</f:if>
</form>
<f:render section="Content" />
</div>
\ No newline at end of file
......@@ -37,9 +37,13 @@ define(['jquery', 'jquery-ui/resizable'], function($) {
var value = me.$widthSelector.val();
if (value) {
value = value.split('|');
var height = value[1] || '100%';
if (height === '100%') {
height = ViewPage.calculateContainerMaxHeight();
}
me.$resizableContainer.animate({
width: value[0],
height: value[1] || '100%'
height: height
});
Storage.Persistent.set(me.storagePrefix + 'widthSelectorValue', value[0] + '|' + (value[1] || '100%'));
}
......@@ -118,6 +122,15 @@ define(['jquery', 'jquery-ui/resizable'], function($) {
});
};
ViewPage.calculateContainerMaxHeight = function() {
ViewPage.$resizableContainer.hide();
var padding = $('.t3js-module-body').outerHeight() - $('.t3js-module-body').height(),
controlsHeight = ViewPage.$widthSelector.parents('form:first').height(),
documentHeight = $(document).height();
ViewPage.$resizableContainer.show();
return documentHeight - (controlsHeight + padding);
};
ViewPage.addCustomWidthOption = function(value) {
ViewPage.$widthSelector.prepend('<option id="customOption" value="' + value + '">' + ViewPage.getOptionLabel(value) + '</option>');
};
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment