Skip to content
Snippets Groups Projects
Commit 379e1b43 authored by Kevin Ditscheid's avatar Kevin Ditscheid
Browse files

[BUGFIX] Fix sg_news Backend Module JavaScript

parent 93556a0b
No related branches found
No related tags found
2 merge requests!13Feature remove sg news ajax plugin,!8Feature upgrade to9 lts
......@@ -32,6 +32,8 @@ use TYPO3\CMS\Backend\Clipboard\Clipboard;
use TYPO3\CMS\Backend\Utility\BackendUtility;
use TYPO3\CMS\Core\Imaging\Icon;
use TYPO3\CMS\Core\Imaging\IconFactory;
use TYPO3\CMS\Core\Localization\LanguageService;
use TYPO3\CMS\Core\Page\PageRenderer;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Utility\LocalizationUtility;
use TYPO3\CMS\Recordlist\RecordList\DatabaseRecordList;
......@@ -72,6 +74,12 @@ class ControlViewHelper extends AbstractViewHelper {
$backendUser = $GLOBALS['BE_USER'];
$pageInfo = BackendUtility::readPageAccess($row['pid'], $backendUser->getPagePermsClause(1));
$databaseRecordList->calcPerms = $GLOBALS['BE_USER']->calcPerms($pageInfo);
$pageRenderer = GeneralUtility::makeInstance(PageRenderer::class);
$pageRenderer->loadRequireJsModule('TYPO3/CMS/Backend/AjaxDataHandler');
$pageRenderer->addInlineLanguageLabelFile('EXT:backend/Resources/Private/Language/locallang_alt_doc.xlf');
$languageService = GeneralUtility::makeInstance(LanguageService::class);
$languageService->includeLLFile('EXT:backend/Resources/Private/Language/locallang_alt_doc.xlf');
$databaseRecordList->currentTable = $sortingData;
if ($table === 'pages') {
$databaseRecordList->searchLevels = 1;
......@@ -87,16 +95,9 @@ class ControlViewHelper extends AbstractViewHelper {
}
if ($table === 'pages' && LicensingService::checkKey()) {
$rootline = BackendUtility::BEgetRootLine($row['uid'], '', TRUE);
ksort($rootline);
$path = '/root';
foreach ($rootline as $page) {
$path .= '/p' . dechex($page['uid']);
}
$iconFactory = GeneralUtility::makeInstance(IconFactory::class);
$buttonLabel = LocalizationUtility::translate('backend.button.editPageContent', 'SgNews');
$onclick = 'return sgNewsGoToPageModule(' . $row['uid'] . ', \'' . $path . '\');';
$onclick = 'return TYPO3.SgNewsModule.sgNewsGoToPageModule(' . $row['uid'] . ');';
$icon = $iconFactory->getIcon('actions-document-open-white', Icon::SIZE_SMALL)->render();
$wrap = ' <div class="btn-group" role="group">%s</div>';
$link = '<a href="#" onclick="' . $onclick . '" class="btn btn-primary" title="' . $buttonLabel . '">%s</a>';
......
......@@ -3,12 +3,9 @@
<f:be.container
includeRequireJsModules="{
0: 'TYPO3/CMS/Backend/AjaxDataHandler',
1: 'TYPO3/CMS/Backend/ContextMenu',
2: 'TYPO3/CMS/Backend/Tooltip',
3: 'TYPO3/CMS/Recordlist/Tooltip',
4: 'TYPO3/CMS/SgNews/Backend'}"
includeJsFiles="{0: '{f:uri.resource(path: \'Scripts/Backend.js\')}'}">
0: 'TYPO3/CMS/Backend/ContextMenu',
1: 'TYPO3/CMS/Backend/Tooltip',
2: 'TYPO3/CMS/SgNews/Backend'}">
<div class="module" data-module-id="" data-module-name="">
<div class="module-docheader t3js-module-docheader">
<div class="module-docheader-bar module-docheader-bar-navigation t3js-module-docheader-bar t3js-module-docheader-bar-navigation">
......
......@@ -22,7 +22,11 @@
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
define(['jquery'], function($) {
define([
'jquery',
'TYPO3/CMS/Backend/ModuleMenu',
'TYPO3/CMS/Backend/Viewport'
], function($, ModuleMenu, Viewport) {
'use strict';
var SgNewsModule = {
init: function() {
......@@ -35,83 +39,15 @@ define(['jquery'], function($) {
this.form.submit();
});
},
// functions for backend docheader functionality
jumpExt: function(URL, anchor) {
var anc = anchor ? anchor : "";
window.location.href = URL + (T3_THIS_LOCATION ? "&returnUrl=" + T3_THIS_LOCATION : "") + anc;
return false;
},
jumpSelf: function(URL) {
window.location.href = URL + (T3_RETURN_URL ? "&returnUrl=" + T3_RETURN_URL : "");
return false;
},
jumpToUrl: function(URL) {
window.location.href = URL;
return false;
},
setHighlight: function(id) {
top.fsMod.recentIds["web"] = id;
top.fsMod.navFrameHighlightedID["web"] = "pages" + id + "_" + top.fsMod.currentBank; // For highlighting
if (top.content && top.content.nav_frame && top.content.nav_frame.refresh_nav) {
top.content.nav_frame.refresh_nav();
}
},
/**
* Switches to the spefied page in the BE
*
* @param {number} uid
* @param {string} path
*/
sgNewsGoToPage: function(uid, path, selectOnly) {
parent.fsMod.recentIds['web'] = uid;
if (typeof selectOnly === 'undefined') {
selectOnly = false;
}
selectOnly = Boolean(selectOnly);
if (top.nav) {
if (selectOnly) {
top.nav.invokePageId(uid, SgNewsModule.gotToPageCallbackNoFollow);
} else {
top.nav.invokePageId(uid, SgNewsModule.gotToPageCallback);
}
} else {
var tree = top.Ext.getCmp('typo3-pagetree');
if (tree) {
tree.activeTree.selectPath(path);
sgNewsGoToPageModule: function(uid) {
ModuleMenu.App.showModule('web_layout', 'id=' + uid);
var pageTreeNodes = Viewport.NavigationContainer.PageTree.instance.nodes;
for (var nodeIndex in pageTreeNodes) {
if (pageTreeNodes[nodeIndex].identifier === uid) {
Viewport.NavigationContainer.PageTree.selectNode(pageTreeNodes[nodeIndex]);
break;
}
if (selectOnly) {
return;
}
var separator = '?';
if (top.currentSubScript.indexOf('?') !== -1) {
separator = '&';
}
top.TYPO3.Backend.ContentContainer.setUrl(
top.currentSubScript + separator + 'id=' + uid
);
}
},
/**
* Callback for page selection in the pagetree without follow
*/
gotToPageCallbackNoFollow: function(path) {
var callback = top.Ext.createDelegate(top.nav.mainTree.selectPath, top.nav.mainTree);
callback.apply(this, arguments);
},
/**
* Callback for page selection in the pagetree
*/
gotToPageCallback: function(path) {
var callback = top.Ext.createDelegate(top.nav.mainTree.selectPath, top.nav.mainTree);
callback.apply(this, arguments);
var node = top.nav.getSelected();
if (node) {
top.TYPO3.Components.PageTree.Actions.singleClick(node, top.TYPO3.Components.PageTree.Tree);
}
},
sgNewsGoToPageModule: function(uid, path) {
SgNewsModule.sgNewsGoToPage(uid, path, true);
parent.TYPO3.ModuleMenu.App.showModule('web_layout');
return false;
}
};
......@@ -121,3 +57,28 @@ define(['jquery'], function($) {
SgNewsModule.init();
return SgNewsModule;
});
// functions for backend docheader functionality
function jumpExt(URL, anchor) {
var anc = anchor ? anchor : "";
window.location.href = URL + (T3_THIS_LOCATION ? "&returnUrl=" + T3_THIS_LOCATION : "") + anc;
return false;
}
function jumpSelf(URL) {
window.location.href = URL + (T3_RETURN_URL ? "&returnUrl=" + T3_RETURN_URL : "");
return false;
}
function jumpToUrl(URL) {
window.location.href = URL;
return false;
}
function setHighlight(id) {
top.fsMod.recentIds["web"] = id;
top.fsMod.navFrameHighlightedID["web"] = "pages" + id + "_" + top.fsMod.currentBank; // For highlighting
if (top.content && top.content.nav_frame && top.content.nav_frame.refresh_nav) {
top.content.nav_frame.refresh_nav();
}
}
......@@ -41,6 +41,7 @@ if (TYPO3_MODE === 'BE') {
'access' => 'user,group',
'icon' => 'EXT:sg_news/Resources/Public/Icons/module-sgnews.svg',
'labels' => 'LLL:EXT:sg_news/Resources/Private/Language/locallang.xlf',
'navigationComponentId' => 'TYPO3/CMS/Backend/PageTree/PageTreeElement'
]
);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment