Skip to content

Commit

Permalink
[TASK] Move info popups to modal windows
Browse files Browse the repository at this point in the history
Resolves: #83844
Releases: master
Change-Id: I5fef80a48d52da9800a7a9a2a23445d60168e8b5
Reviewed-on: https://review.typo3.org/55659
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Joerg Boesche <typo3@joergboesche.de>
Tested-by: Joerg Boesche <typo3@joergboesche.de>
Reviewed-by: Andreas Fernandez <a.fernandez@scripting-base.de>
Tested-by: Andreas Fernandez <a.fernandez@scripting-base.de>
  • Loading branch information
Benjamin Kott authored and andreaskienast committed Feb 12, 2018
1 parent 1ea84aa commit e44f009
Show file tree
Hide file tree
Showing 23 changed files with 127 additions and 31 deletions.
1 change: 1 addition & 0 deletions Build/types/TYPO3/index.d.ts
Expand Up @@ -6,6 +6,7 @@
*/
declare namespace TYPO3 {
export let DebugConsole: any;
export let InfoWindow: any;
export let Popover: any;
export let ShortcutMenu: any;
export let Storage: any;
Expand Down
4 changes: 2 additions & 2 deletions typo3/sysext/backend/Classes/Clipboard/Clipboard.php
Expand Up @@ -405,7 +405,7 @@ public function getContentFromTab($pad)
$this->getBackendUser()->uc['titleLen']
)), $fileObject->getName()),
'thumb' => $thumb,
'infoLink' => htmlspecialchars('top.launchView(' . GeneralUtility::quoteJSvalue($table) . ', ' . GeneralUtility::quoteJSvalue($v) . '); return false;'),
'infoLink' => htmlspecialchars('top.TYPO3.InfoWindow.showItem(' . GeneralUtility::quoteJSvalue($table) . ', ' . GeneralUtility::quoteJSvalue($v) . '); return false;'),
'removeLink' => $this->removeUrl('_FILE', GeneralUtility::shortMD5($v))
];
} else {
Expand All @@ -427,7 +427,7 @@ public function getContentFromTab($pad)
$table,
$rec
), $this->getBackendUser()->uc['titleLen'])), $rec, $table),
'infoLink' => htmlspecialchars('top.launchView(' . GeneralUtility::quoteJSvalue($table) . ', \'' . (int)$uid . '\'); return false;'),
'infoLink' => htmlspecialchars('top.TYPO3.InfoWindow.showItem(' . GeneralUtility::quoteJSvalue($table) . ', \'' . (int)$uid . '\'); return false;'),
'removeLink' => $this->removeUrl($table, $uid)
];

Expand Down
3 changes: 3 additions & 0 deletions typo3/sysext/backend/Classes/Controller/BackendController.php
Expand Up @@ -151,6 +151,9 @@ public function __construct()
// load Modals
$this->pageRenderer->loadRequireJsModule('TYPO3/CMS/Backend/Modal');

// load InfoWindow
$this->pageRenderer->loadRequireJsModule('TYPO3/CMS/Backend/InfoWindow');

// load ContextMenu
$this->pageRenderer->loadRequireJsModule('TYPO3/CMS/Backend/ContextMenu');

Expand Down
Expand Up @@ -732,6 +732,7 @@ function jumpToUrl(URL,formEl) {
// Info view:
function launchView(table,uid) {
console.warn(\'Calling launchView() has been deprecated in v9 and will be removed in v10.0\');
var thePreviewWindow = window.open(
' . GeneralUtility::quoteJSvalue((string)$uriBuilder->buildUriFromRoute('show_item') . '&table=') . ' + encodeURIComponent(table) + "&uid=" + encodeURIComponent(uid),
"ShowItem" + Math.random().toString(16).slice(2),
Expand Down
Expand Up @@ -444,7 +444,7 @@ protected function renderForeignRecordHeaderControl(array $data)
$cells['info'] = '<span class="btn btn-default disabled">' . $this->iconFactory->getIcon('empty-empty', Icon::SIZE_SMALL)->render() . '</span>';
} else {
$cells['info'] = '
<a class="btn btn-default" href="#" onclick="' . htmlspecialchars(('top.launchView(' . GeneralUtility::quoteJSvalue($table) . ', ' . GeneralUtility::quoteJSvalue($uid) . '); return false;')) . '" title="' . htmlspecialchars($languageService->sL('LLL:EXT:lang/Resources/Private/Language/locallang_mod_web_list.xlf:showInfo')) . '">
<a class="btn btn-default" href="#" onclick="' . htmlspecialchars(('top.TYPO3.InfoWindow.showItem(' . GeneralUtility::quoteJSvalue($table) . ', ' . GeneralUtility::quoteJSvalue($uid) . '); return false;')) . '" title="' . htmlspecialchars($languageService->sL('LLL:EXT:lang/Resources/Private/Language/locallang_mod_web_list.xlf:showInfo')) . '">
' . $this->iconFactory->getIcon('actions-document-info', Icon::SIZE_SMALL)->render() . '
</a>';
}
Expand Down
Expand Up @@ -517,7 +517,7 @@ protected function getTranslateTools()
* sys_refindex records you hand over
*
* @param int $references number of records from sys_refindex table
* @param string $launchViewParameter JavaScript String, which will be passed as parameters to top.launchView
* @param string $launchViewParameter JavaScript String, which will be passed as parameters to top.TYPO3.InfoWindow.showItem
* @return string
* @deprecated since TYPO3 v9, will be removed in TYPO3 v10
*/
Expand All @@ -528,7 +528,7 @@ protected function generateReferenceToolTip($references, $launchViewParameter =
} else {
$htmlCode = '<a href="#"';
if ($launchViewParameter !== '') {
$htmlCode .= ' onclick="' . htmlspecialchars(('top.launchView(' . $launchViewParameter . '); return false;')) . '"';
$htmlCode .= ' onclick="' . htmlspecialchars(('top.TYPO3.InfoWindow.showItem(' . $launchViewParameter . '); return false;')) . '"';
}
$htmlCode .= ' title="' . htmlspecialchars($this->getLanguageService()->sL('LLL:EXT:backend/Resources/Private/Language/locallang.xlf:show_references') . ' (' . $references . ')') . '">';
$htmlCode .= $references;
Expand Down
6 changes: 3 additions & 3 deletions typo3/sysext/backend/Classes/Utility/BackendUtility.php
Expand Up @@ -1346,7 +1346,7 @@ public static function thumbCode(
. '</span>';
}
if ($linkInfoPopup) {
$onClick = 'top.launchView(\'_FILE\',\'' . (int)$fileObject->getUid() . '\'); return false;';
$onClick = 'top.TYPO3.InfoWindow.showItem(\'_FILE\',\'' . (int)$fileObject->getUid() . '\'); return false;';
$thumbData .= '<a href="#" onclick="' . htmlspecialchars($onClick) . '">' . $imgTag . '</a> ';
} else {
$thumbData .= $imgTag;
Expand Down Expand Up @@ -1400,7 +1400,7 @@ public static function thumbCode(

$image = '<img src="' . htmlspecialchars($imageUrl) . '" hspace="2" border="0" title="' . htmlspecialchars($fileObject->getName()) . '"' . $tparams . ' alt="" />';
if ($linkInfoPopup) {
$onClick = 'top.launchView(\'_FILE\', ' . GeneralUtility::quoteJSvalue($fileName) . ',\'\');return false;';
$onClick = 'top.TYPO3.InfoWindow.showItem(\'_FILE\', ' . GeneralUtility::quoteJSvalue($fileName) . ',\'\');return false;';
$thumbData .= '<a href="#" onclick="' . htmlspecialchars($onClick) . '">' . $image . '</a> ';
} else {
$thumbData .= $image;
Expand All @@ -1411,7 +1411,7 @@ public static function thumbCode(
. $iconFactory->getIconForResource($fileObject, Icon::SIZE_SMALL)->render()
. '</span>';
if ($linkInfoPopup) {
$onClick = 'top.launchView(\'_FILE\', ' . GeneralUtility::quoteJSvalue($fileName) . ',\'\'); return false;';
$onClick = 'top.TYPO3.InfoWindow.showItem(\'_FILE\', ' . GeneralUtility::quoteJSvalue($fileName) . ',\'\'); return false;';
$thumbData .= '<a href="#" onclick="' . htmlspecialchars($onClick) . '">' . $fileIcon . '</a> ';
} else {
$thumbData .= $fileIcon;
Expand Down
6 changes: 3 additions & 3 deletions typo3/sysext/backend/Classes/View/PageLayoutView.php
Expand Up @@ -3750,7 +3750,7 @@ public function linkWrapItems($table, $uid, $code, $row)
case 'info':
// "Info": (All records)
$code = '<a href="#" onclick="' . htmlspecialchars(
('top.launchView(\'' . $table . '\', \'' . $row['uid'] . '\'); return false;')
('top.TYPO3.InfoWindow.showItem(\'' . $table . '\', \'' . $row['uid'] . '\'); return false;')
) . '" title="' . htmlspecialchars($lang->getLL('showInfo')) . '">' . $code . '</a>';
break;
default:
Expand Down Expand Up @@ -4440,7 +4440,7 @@ protected function getTranslateTools()
* sys_refindex records you hand over
*
* @param int $references number of records from sys_refindex table
* @param string $launchViewParameter JavaScript String, which will be passed as parameters to top.launchView
* @param string $launchViewParameter JavaScript String, which will be passed as parameters to top.TYPO3.InfoWindow.showItem
* @return string
*/
protected function generateReferenceToolTip($references, $launchViewParameter = '')
Expand All @@ -4451,7 +4451,7 @@ protected function generateReferenceToolTip($references, $launchViewParameter =
$htmlCode = '<a href="#"';
if ($launchViewParameter !== '') {
$htmlCode .= ' onclick="' . htmlspecialchars(
('top.launchView(' . $launchViewParameter . '); return false;')
('top.TYPO3.InfoWindow.showItem(' . $launchViewParameter . '); return false;')
) . '"';
}
$htmlCode .= ' title="' . htmlspecialchars(
Expand Down
42 changes: 42 additions & 0 deletions typo3/sysext/backend/Resources/Private/TypeScript/InfoWindow.ts
@@ -0,0 +1,42 @@
/*
* 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!
*/

import Modal = require('TYPO3/CMS/Backend/Modal');
import Severity = require('TYPO3/CMS/Backend/Severity');

/**
* Module: TYPO3/CMS/Backend/InfoWindow
* @exports TYPO3/CMS/Backend/InfoWindow
*/
class InfoWindow {
/**
* Shows the info modal
*
* @param {string} table
* @param {string | number} uid
*/
public static showItem(table: string, uid: string|number): void {
Modal.advanced({
type: Modal.types.iframe,
size: Modal.sizes.large,
content: TYPO3.settings.ShowItem.moduleUrl
+ '&table=' + encodeURIComponent(table)
+ '&uid=' + (typeof uid === 'number' ? uid : encodeURIComponent(uid)),
severity: Severity.notice
});
}
}

// expose as global object
TYPO3.InfoWindow = InfoWindow;
export = InfoWindow;
Expand Up @@ -41,7 +41,7 @@ define(['jquery', 'TYPO3/CMS/Backend/Modal', 'TYPO3/CMS/Backend/Severity'], func
};

ContextMenuActions.openInfoPopUp = function(table, uid) {
top.launchView(table, uid);
top.TYPO3.InfoWindow.showItem(table, uid);
};

ContextMenuActions.mountAsTreeRoot = function(table, uid) {
Expand Down
13 changes: 13 additions & 0 deletions typo3/sysext/backend/Resources/Public/JavaScript/InfoWindow.js
@@ -0,0 +1,13 @@
/*
* 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!
*/
define(["require","exports","TYPO3/CMS/Backend/Modal","TYPO3/CMS/Backend/Severity"],function(a,b,c,d){"use strict";var e=function(){function a(){}return a.showItem=function(a,b){console.log(TYPO3.settings),c.advanced({type:c.types.iframe,size:c.sizes.large,content:TYPO3.settings.ShowItem.moduleUrl+"&table="+encodeURIComponent(a)+"&uid="+("number"==typeof b?b:encodeURIComponent(b)),severity:d.notice})},a}();return TYPO3.InfoWindow=e,e});
Expand Up @@ -71,6 +71,7 @@ function str_replace(match, replace, string) { //
* Launcing information window for records/files (fileref as "table" argument)
*/
function launchView(table, uid) {
console.warn('Calling launchView() has been deprecated in v9 and will be removed in v10.0');
var thePreviewWindow = window.open(TYPO3.settings.ShowItem.moduleUrl + '&table=' + encodeURIComponent(table) + "&uid=" + encodeURIComponent(uid),
"ShowItem" + Math.random().toString(16).slice(2),
"width=650,height=600,status=0,menubar=0,resizable=0,location=0,directories=0,scrollbars=1,toolbar=0");
Expand Down
Expand Up @@ -48,7 +48,7 @@
<bu:removeUser backendUser="{backendUser}" />
</div>
<div class="btn-group" role="group">
<a class="btn btn-default" href="#" onclick="top.launchView('be_users', '{backendUser.uid}'); return false;"><core:icon identifier="actions-document-info" /></a>
<a class="btn btn-default" href="#" onclick="top.TYPO3.InfoWindow.showItem('be_users', '{backendUser.uid}'); return false;"><core:icon identifier="actions-document-info" /></a>
</div>
<div class="btn-group" role="group">
<f:if condition="{compareUserUidList.{backendUser.uid}}">
Expand Down
Expand Up @@ -40,7 +40,7 @@
</f:link.action>
</f:else>
</f:if>
<a class="btn btn-default" href="#" onclick="top.launchView('be_users', '{onlineUser.backendUser.uid}',''); return false;">
<a class="btn btn-default" href="#" onclick="top.TYPO3.InfoWindow.showItem('be_users', '{onlineUser.backendUser.uid}'); return false;">
<core:icon identifier="actions-document-info" />
</a>
</div>
Expand Down
Expand Up @@ -33,7 +33,7 @@
</f:if>
</div>
<div class="btn-group" role="group">
<a class="btn btn-default" href="#" onclick="top.launchView('be_groups', '{backendUserGroup.uid}'); return false;"><core:icon identifier="actions-document-info" /></a
<a class="btn btn-default" href="#" onclick="top.TYPO3.InfoWindow.showItem('be_groups', '{backendUserGroup.uid}'); return false;"><core:icon identifier="actions-document-info" /></a
</div>
</td>
</tr>
2 changes: 1 addition & 1 deletion typo3/sysext/core/Classes/Database/QueryView.php
Expand Up @@ -718,7 +718,7 @@ public function resultRowDisplay($row, $conf, $table)
$out .= '<a class="btn btn-default" href="' . htmlspecialchars($url) . '">'
. $this->iconFactory->getIcon('actions-open', Icon::SIZE_SMALL)->render() . '</a>';
$out .= '</div><div class="btn-group" role="group">';
$out .= '<a class="btn btn-default" href="#" onClick="top.launchView(\'' . $table . '\',' . $row['uid']
$out .= '<a class="btn btn-default" href="#" onClick="top.TYPO3.InfoWindow.showItem(\'' . $table . '\',' . $row['uid']
. ');return false;">' . $this->iconFactory->getIcon('actions-document-info', Icon::SIZE_SMALL)->render()
. '</a>';
$out .= '</div>';
Expand Down
@@ -0,0 +1,33 @@
.. include:: ../../Includes.txt

========================================================
Deprecation: #83844 - Deprecated usage of top.launchView
========================================================

See :issue:`83844`

Description
===========

The usage of :js:`top.launchView()`, that opens certain information in a popup window, has been deprecated.


Impact
======

Calling :js:`top.launchView()` will trigger a deprecation log entry in the browser's console.


Affected Installations
======================

Every 3rd party extension that uses :js:`top.launchView` is affected.


Migration
=========

Either use :js:`top.TYPO3.InfoWindow.showItem()` directly or import the RequireJS module `TYPO3/CMS/Backend/InfoWindow`
and call :js:`showItem()`.

.. index:: Backend, JavaScript, NotScanned
Expand Up @@ -517,7 +517,11 @@ public function searchAction($searchWord = '')
}
}

/** @var \TYPO3\CMS\Backend\Routing\UriBuilder $uriBuilder */
$uriBuilder = GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Routing\UriBuilder::class);

$pageRenderer = $this->view->getModuleTemplate()->getPageRenderer();
$pageRenderer->addInlineSetting('ShowItem', 'moduleUrl', (string)$uriBuilder->buildUriFromRoute('show_item'));
$pageRenderer->loadRequireJsModule('TYPO3/CMS/Filelist/FileList');

$thumbnailConfiguration = GeneralUtility::makeInstance(ThumbnailConfiguration::class);
Expand All @@ -528,8 +532,6 @@ public function searchAction($searchWord = '')

$this->view->assign('searchWord', $searchWord);
$this->view->assign('files', $fileFacades);
/** @var \TYPO3\CMS\Backend\Routing\UriBuilder $uriBuilder */
$uriBuilder = GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Routing\UriBuilder::class);
$this->view->assign('deleteUrl', (string)$uriBuilder->buildUriFromRoute('tce_file'));
$this->view->assign('settings', [
'jsConfirmationDelete' => $this->getBackendUser()->jsConfirmation(JsConfirmation::DELETE)
Expand Down
8 changes: 4 additions & 4 deletions typo3/sysext/filelist/Classes/FileList.php
Expand Up @@ -1381,9 +1381,9 @@ public function makeEdit($fileOrFolderObject)
if ($fileOrFolderObject->checkActionPermission('read')) {
$infoOnClick = '';
if ($fileOrFolderObject instanceof Folder) {
$infoOnClick = 'top.launchView( \'_FOLDER\', ' . GeneralUtility::quoteJSvalue($fullIdentifier) . ');return false;';
$infoOnClick = 'top.TYPO3.InfoWindow.showItem(\'_FOLDER\', ' . GeneralUtility::quoteJSvalue($fullIdentifier) . ');return false;';
} elseif ($fileOrFolderObject instanceof File) {
$infoOnClick = 'top.launchView( \'_FILE\', ' . GeneralUtility::quoteJSvalue($fullIdentifier) . ');return false;';
$infoOnClick = 'top.TYPO3.InfoWindow.showItem(\'_FILE\', ' . GeneralUtility::quoteJSvalue($fullIdentifier) . ');return false;';
}
$cells['info'] = '<a href="#" class="btn btn-default" onclick="' . htmlspecialchars($infoOnClick) . '" title="' . $this->getLanguageService()->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:cm.info') . '">' . $this->iconFactory->getIcon('actions-document-info', Icon::SIZE_SMALL)->render() . '</a>';
} else {
Expand Down Expand Up @@ -1535,7 +1535,7 @@ protected function getTranslateTools()
* sys_refindex records you hand over
*
* @param int $references number of records from sys_refindex table
* @param string $launchViewParameter JavaScript String, which will be passed as parameters to top.launchView
* @param string $launchViewParameter JavaScript String, which will be passed as parameters to top.TYPO3.InfoWindow.showItem
* @return string
*/
protected function generateReferenceToolTip($references, $launchViewParameter = '')
Expand All @@ -1546,7 +1546,7 @@ protected function generateReferenceToolTip($references, $launchViewParameter =
$htmlCode = '<a href="#"';
if ($launchViewParameter !== '') {
$htmlCode .= ' onclick="' . htmlspecialchars(
('top.launchView(' . $launchViewParameter . '); return false;')
('top.TYPO3.InfoWindow.showItem(' . $launchViewParameter . '); return false;')
) . '"';
}
$htmlCode .= ' title="' . htmlspecialchars(
Expand Down
Expand Up @@ -48,10 +48,10 @@ define(['jquery', 'TYPO3/CMS/Backend/Modal', 'TYPO3/CMS/Backend/Severity'], func

ContextMenuActions.openInfoPopUp = function(table, uid) {
if (table === 'sys_file_storage') {
top.launchView(table, uid);
top.TYPO3.InfoWindow.showItem(table, uid);
} else {
//files and folders
top.launchView('_FILE', uid);
top.TYPO3.InfoWindow.showItem('_FILE', uid);
}
};

Expand Down
4 changes: 2 additions & 2 deletions typo3/sysext/filelist/Resources/Public/JavaScript/FileList.js
Expand Up @@ -15,7 +15,7 @@
* Module: TYPO3/CMS/Filelist/Filelist
* @exports TYPO3/CMS/Filelist/Filelist
*/
define(['jquery'], function($) {
define(['jquery', 'TYPO3/CMS/Backend/InfoWindow'], function($, InfoWindow) {

$(function() {
$('a.filelist-file-title').click(function(event) {
Expand Down Expand Up @@ -73,7 +73,7 @@ define(['jquery'], function($) {
* @param identifier
*/
function openFileInfoPopup(identifier) {
top.launchView('_FILE', identifier);
InfoWindow.showItem('_FILE', identifier);
}

});
Expand Up @@ -1085,7 +1085,7 @@ public function linkWrapItems($table, $uid, $code, $row)
break;
case 'info':
// "Info": (All records)
$code = '<a href="#" onclick="' . htmlspecialchars(('top.launchView(\'' . $table . '\', \'' . $row['uid'] . '\'); return false;')) . '" title="' . htmlspecialchars($lang->getLL('showInfo')) . '">' . $code . '</a>';
$code = '<a href="#" onclick="' . htmlspecialchars(('top.TYPO3.InfoWindow.showItem(\'' . $table . '\', \'' . $row['uid'] . '\'); return false;')) . '" title="' . htmlspecialchars($lang->getLL('showInfo')) . '">' . $code . '</a>';
break;
default:
// Output the label now:
Expand Down

0 comments on commit e44f009

Please sign in to comment.