2 namespace TYPO3\CMS\Backend\Controller
;
4 /***************************************************************
7 * (c) 1999-2013 Kasper Skårhøj (kasperYYYY@typo3.com)
10 * This script is part of the TYPO3 project. The TYPO3 project is
11 * free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
16 * The GNU General Public License can be found at
17 * http://www.gnu.org/copyleft/gpl.html.
18 * A copy is found in the textfile GPL.txt and important notices to the license
19 * from the author is found in LICENSE.txt distributed with these scripts.
22 * This script is distributed in the hope that it will be useful,
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 * GNU General Public License for more details.
27 * This copyright notice MUST APPEAR in all copies of the script!
28 ***************************************************************/
30 use TYPO3\CMS\Backend\Utility\BackendUtility
;
31 use TYPO3\CMS\Backend\Utility\IconUtility
;
32 use TYPO3\CMS\Core\Utility\GeneralUtility
;
35 * Main script class for the page tree navigation frame
37 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
39 class PageTreeNavigationController
{
43 * @todo Define visibility
48 * @todo Define visibility
53 * document template object
55 * @var \TYPO3\CMS\Backend\Template\DocumentTemplate
56 * @todo Define visibility
60 // Temporary mount point (record), if any
62 * @todo Define visibility
64 public $active_tempMountPoint = 0;
67 * @todo Define visibility
71 // Internal, static: GPvar:
73 * @todo Define visibility
75 public $currentSubScript;
78 * @todo Define visibility
82 // If not '' (blank) then it will clear (0) or set (>0) Temporary DB mount.
84 * @todo Define visibility
86 public $setTempDBmount;
89 * @todo Define visibility
93 // Depends on userTS-setting
95 * @todo Define visibility
100 * Initialiation of the class
103 * @todo Define visibility
105 public function init() {
107 $this->backPath
= $GLOBALS['BACK_PATH'];
109 $this->cMR
= GeneralUtility
::_GP('cMR');
110 $this->currentSubScript
= GeneralUtility
::_GP('currentSubScript');
111 $this->setTempDBmount
= GeneralUtility
::_GP('setTempDBmount');
112 // look for User setting
113 $this->hasFilterBox
= !$GLOBALS['BE_USER']->getTSConfigVal('options.pageTree.hideFilter');
114 // Create page tree object:
115 $this->pagetree
= GeneralUtility
::makeInstance('TYPO3\\CMS\\Backend\\View\\PageTreeView');
116 $this->pagetree
->ext_IconMode
= $GLOBALS['BE_USER']->getTSConfigVal('options.pageTree.disableIconLinkToContextmenu');
117 $this->pagetree
->ext_showPageId
= $GLOBALS['BE_USER']->getTSConfigVal('options.pageTree.showPageIdWithTitle');
118 $this->pagetree
->ext_showNavTitle
= $GLOBALS['BE_USER']->getTSConfigVal('options.pageTree.showNavTitle');
119 $this->pagetree
->ext_separateNotinmenuPages
= $GLOBALS['BE_USER']->getTSConfigVal('options.pageTree.separateNotinmenuPages');
120 $this->pagetree
->ext_alphasortNotinmenuPages
= $GLOBALS['BE_USER']->getTSConfigVal('options.pageTree.alphasortNotinmenuPages');
121 $this->pagetree
->thisScript
= 'alt_db_navframe.php';
122 $this->pagetree
->addField('alias');
123 $this->pagetree
->addField('shortcut');
124 $this->pagetree
->addField('shortcut_mode');
125 $this->pagetree
->addField('mount_pid');
126 $this->pagetree
->addField('mount_pid_ol');
127 $this->pagetree
->addField('nav_hide');
128 $this->pagetree
->addField('nav_title');
129 $this->pagetree
->addField('url');
130 // Temporary DB mounts:
131 $this->initializeTemporaryDBmount();
135 * Initialization for the visual parts of the class
136 * Use template rendering only if this is a non-AJAX call
140 public function initPage() {
141 // Setting highlight mode:
142 $this->doHighlight
= !$GLOBALS['BE_USER']->getTSConfigVal('options.pageTree.disableTitleHighlight');
143 // If highlighting is active, define the CSS class for the active item depending on the workspace
144 if ($this->doHighlight
) {
145 $hlClass = $GLOBALS['BE_USER']->workspace
=== 0 ?
'active' : 'active active-ws wsver' . $GLOBALS['BE_USER']->workspace
;
147 // Create template object:
148 $this->doc
= GeneralUtility
::makeInstance('TYPO3\\CMS\\Backend\\Template\\DocumentTemplate');
149 $this->doc
->backPath
= $GLOBALS['BACK_PATH'];
150 $this->doc
->setModuleTemplate('EXT:backend/Resources/Private/Templates/alt_db_navframe.html');
151 $this->doc
->showFlashMessages
= FALSE;
153 // Adding javascript code for AJAX (prototype), drag&drop and the pagetree as well as the click menu code
154 $this->doc
->getDragDropCode('pages');
155 $this->doc
->getContextMenuCode();
156 $this->doc
->getPageRenderer()->loadScriptaculous('effects');
157 $this->doc
->getPageRenderer()->loadExtJS();
158 if ($this->hasFilterBox
) {
159 $this->doc
->getPageRenderer()->addJsFile('sysext/backend/Resources/Public/JavaScript/pagetreefiltermenu.js');
161 $this->doc
->JScode
.= $this->doc
->wrapScriptTags(($this->currentSubScript ?
'top.currentSubScript=unescape("' . rawurlencode($this->currentSubScript
) . '");' : '') . '
162 // setting prefs for pagetree and drag & drop
163 ' . ($this->doHighlight ?
'Tree.highlightClass = "' . $hlClass . '";' : '') . '
165 // Function, loading the list frame from navigation tree:
166 function jumpTo(id, linkObj, highlightID, bank) { //
167 var theUrl = top.TS.PATH_typo3 + top.currentSubScript ;
168 if (theUrl.indexOf("?") != -1) {
169 theUrl += "&id=" + id
171 theUrl += "?id=" + id
173 top.fsMod.currentBank = bank;
174 top.TYPO3.Backend.ContentContainer.setUrl(theUrl);
176 ' . ($this->doHighlight ?
'Tree.highlightActiveItem("web", highlightID + "_" + bank);' : '') . '
177 ' . (!$GLOBALS['CLIENT']['FORMSTYLE'] ?
'' : 'if (linkObj) linkObj.blur(); ') . '
180 ' . ($this->cMR ?
'jumpTo(top.fsMod.recentIds[\'web\'],\'\');' : '') . ($this->hasFilterBox ?
'var TYPO3PageTreeFilter = new PageTreeFilter();' : '') . '
183 $this->doc
->bodyTagId
= 'typo3-pagetree';
187 * Main function, rendering the browsable page tree
190 * @todo Define visibility
192 public function main() {
193 // Produce browse-tree:
194 $tree = $this->pagetree
->getBrowsableTree();
195 // Outputting Temporary DB mount notice:
196 if ($this->active_tempMountPoint
) {
198 <a href="' . htmlspecialchars(GeneralUtility
::linkThisScript(array('setTempDBmount' => 0))) . '">' . $GLOBALS['LANG']->sl('LLL:EXT:lang/locallang_core.xlf:labels.temporaryDBmount', 1) . '</a> <br />' . $GLOBALS['LANG']->sl('LLL:EXT:lang/locallang_core.xlf:labels.path', 1) . ': <span title="' . htmlspecialchars($this->active_tempMountPoint
['_thePathFull']) . '">' . htmlspecialchars(GeneralUtility
::fixed_lgd_cs($this->active_tempMountPoint
['_thePath'], -50)) . '</span>
200 $flashMessage = GeneralUtility
::makeInstance('TYPO3\\CMS\\Core\\Messaging\\FlashMessage', $flashText, '', \TYPO3\CMS\Core\Messaging\FlashMessage
::INFO
);
201 $this->content
.= $flashMessage->render();
203 // Outputting page tree:
204 $this->content
.= '<div id="PageTreeDiv">' . $tree . '</div>';
205 // Adding javascript for drag & drop activation and highlighting
206 $this->content
.= $this->doc
->wrapScriptTags('
207 ' . ($this->doHighlight ?
'Tree.highlightActiveItem("",top.fsMod.navFrameHighlightedID["web"]);' : '') . '
208 Tree.registerDragDropHandlers();');
209 // Setting up the buttons and markers for docheader
210 $docHeaderButtons = $this->getButtons();
212 'IMG_RESET' => IconUtility
::getSpriteIcon('actions-document-close', array(
213 'id' => 'treeFilterReset',
214 'alt' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:labels.resetFilter'),
215 'title' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:labels.resetFilter')
217 'WORKSPACEINFO' => $this->getWorkspaceInfo(),
218 'CONTENT' => $this->content
221 if (!$this->hasFilterBox
) {
222 $subparts['###SECOND_ROW###'] = '';
224 // Build the <body> for the module
225 $this->content
= $this->doc
->startPage('TYPO3 Page Tree');
226 $this->content
.= $this->doc
->moduleBody($this->pageinfo
, $docHeaderButtons, $markers, $subparts);
227 $this->content
.= $this->doc
->endPage();
228 $this->content
= $this->doc
->insertStylesAndJS($this->content
);
232 * Outputting the accumulated content to screen
235 * @todo Define visibility
237 public function printContent() {
242 * Create the panel of buttons for submitting the form or otherwise perform operations.
244 * @return array All available buttons as an assoc. array
246 protected function getButtons() {
254 $onclickNewPageWizard = 'top.content.list_frame.location.href=top.TS.PATH_typo3+\'db_new.php?pagesOnly=1&id=\'+Tree.pageID;';
255 $buttons['new_page'] = '<a href="#" onclick="' . $onclickNewPageWizard . '" title="' . $GLOBALS['LANG']->sL('LLL:EXT:cms/layout/locallang.xml:newPage', TRUE) . '">' . IconUtility
::getSpriteIcon('actions-page-new') . '</a>';
257 $buttons['refresh'] = '<a href="' . htmlspecialchars(GeneralUtility
::getIndpEnv('REQUEST_URI')) . '" title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:labels.refresh', TRUE) . '">' . IconUtility
::getSpriteIcon('actions-system-refresh') . '</a>';
259 $buttons['csh'] = str_replace('typo3-csh-inline', 'typo3-csh-inline show-right', BackendUtility
::cshItem('xMOD_csh_corebe', 'pagetree', $GLOBALS['BACK_PATH'], '', TRUE));
261 if ($this->hasFilterBox
) {
262 $buttons['filter'] = '<a href="#" id="tree-toolbar-filter-item">' . IconUtility
::getSpriteIcon('actions-system-tree-search-open', array('title' => $GLOBALS['LANG']->sL('LLL:EXT:cms/layout/locallang.xml:labels.filter', 1))) . '</a>';
268 * Create the workspace information
270 * @return string HTML containing workspace info
272 protected function getWorkspaceInfo() {
273 if (\TYPO3\CMS\Core\Utility\ExtensionManagementUtility
::isLoaded('workspaces') && ($GLOBALS['BE_USER']->workspace
!== 0 ||
$GLOBALS['BE_USER']->getTSConfigVal('options.pageTree.onlineWorkspaceInfo'))) {
274 $wsTitle = htmlspecialchars(\TYPO3\CMS\Workspaces\Service\WorkspaceService
::getWorkspaceTitle($GLOBALS['BE_USER']->workspace
));
276 <div class="bgColor4 workspace-info">' . IconUtility
::getSpriteIcon('apps-toolbar-menu-workspace', array(
278 'onclick' => 'top.goToModule(\'web_WorkspacesWorkspaces\');',
279 'style' => 'cursor:pointer;'
280 )) . $wsTitle . '</div>
283 return $workspaceInfo;
286 /**********************************
288 * Temporary DB mounts
290 **********************************/
292 * Getting temporary DB mount
295 * @todo Define visibility
297 public function initializeTemporaryDBmount() {
298 // Set/Cancel Temporary DB Mount:
299 if (strlen($this->setTempDBmount
)) {
300 $set = \TYPO3\CMS\Core\Utility\MathUtility
::forceIntegerInRange($this->setTempDBmount
, 0);
301 if ($set > 0 && $GLOBALS['BE_USER']->isInWebMount($set)) {
303 $this->settingTemporaryMountPoint($set);
306 $this->settingTemporaryMountPoint(0);
309 // Getting temporary mount point ID:
310 $temporaryMountPoint = intval($GLOBALS['BE_USER']->getSessionData('pageTree_temporaryMountPoint'));
311 // If mount point ID existed and is within users real mount points, then set it temporarily:
312 if ($temporaryMountPoint > 0 && $GLOBALS['BE_USER']->isInWebMount($temporaryMountPoint)) {
313 if ($this->active_tempMountPoint
= BackendUtility
::readPageAccess($temporaryMountPoint, $GLOBALS['BE_USER']->getPagePermsClause(1))) {
314 $this->pagetree
->MOUNTS
= array($temporaryMountPoint);
316 // Clear temporary mount point as we have no access to it any longer
317 $this->settingTemporaryMountPoint(0);
323 * Setting temporary page id as DB mount
325 * @param integer $pageId The page id to set as DB mount
327 * @todo Define visibility
329 public function settingTemporaryMountPoint($pageId) {
330 $GLOBALS['BE_USER']->setAndSaveSessionData('pageTree_temporaryMountPoint', intval($pageId));
333 /**********************************
337 **********************************/
339 * Makes the AJAX call to expand or collapse the pagetree.
340 * Called by typo3/ajax.php
342 * @param array $params Additional parameters (not used here)
343 * @param \TYPO3\CMS\Core\Http\AjaxRequestHandler $ajaxObj The AjaxRequestHandler object of this request
346 public function ajaxExpandCollapse($params, $ajaxObj) {
348 $tree = $this->pagetree
->getBrowsableTree();
349 if (!$this->pagetree
->ajaxStatus
) {
350 $ajaxObj->setError($tree);
352 $ajaxObj->addContent('tree', $tree);