2 /***************************************************************
5 * (c) 1999-2011 Kasper Skårhøj (kasperYYYY@typo3.com)
8 * This script is part of the TYPO3 project. The TYPO3 project is
9 * free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * The GNU General Public License can be found at
15 * http://www.gnu.org/copyleft/gpl.html.
16 * A copy is found in the textfile GPL.txt and important notices to the license
17 * from the author is found in LICENSE.txt distributed with these scripts.
20 * This script is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
25 * This copyright notice MUST APPEAR in all copies of the script!
26 ***************************************************************/
28 * Page navigation tree for the Web module
30 * Revised for TYPO3 3.6 2/2003 by Kasper Skårhøj
33 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
38 require_once('init.php');
39 require('template.php');
40 require_once('class.webpagetree.php');
44 * Main script class for the page tree navigation frame
46 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
50 class SC_alt_db_navframe
{
57 * document template object
62 var $active_tempMountPoint = 0; // Temporary mount point (record), if any
65 // Internal, static: GPvar:
66 var $currentSubScript;
68 var $setTempDBmount; // If not '' (blank) then it will clear (0) or set (>0) Temporary DB mount.
70 var $template; // a static HTML template, usually in templates/alt_db_navframe.html
71 var $hasFilterBox; //depends on userTS-setting
74 * Initialiation of the class
81 $this->backPath
= $GLOBALS['BACK_PATH'];
84 $this->cMR
= t3lib_div
::_GP('cMR');
85 $this->currentSubScript
= t3lib_div
::_GP('currentSubScript');
86 $this->setTempDBmount
= t3lib_div
::_GP('setTempDBmount');
88 // look for User setting
89 $this->hasFilterBox
= !$GLOBALS['BE_USER']->getTSConfigVal('options.pageTree.hideFilter');
91 // Create page tree object:
92 $this->pagetree
= t3lib_div
::makeInstance('webPageTree');
93 $this->pagetree
->ext_IconMode
= $GLOBALS['BE_USER']->getTSConfigVal('options.pageTree.disableIconLinkToContextmenu');
94 $this->pagetree
->ext_showPageId
= $GLOBALS['BE_USER']->getTSConfigVal('options.pageTree.showPageIdWithTitle');
95 $this->pagetree
->ext_showNavTitle
= $GLOBALS['BE_USER']->getTSConfigVal('options.pageTree.showNavTitle');
96 $this->pagetree
->ext_separateNotinmenuPages
= $GLOBALS['BE_USER']->getTSConfigVal('options.pageTree.separateNotinmenuPages');
97 $this->pagetree
->ext_alphasortNotinmenuPages
= $GLOBALS['BE_USER']->getTSConfigVal('options.pageTree.alphasortNotinmenuPages');
98 $this->pagetree
->thisScript
= 'alt_db_navframe.php';
99 $this->pagetree
->addField('alias');
100 $this->pagetree
->addField('shortcut');
101 $this->pagetree
->addField('shortcut_mode');
102 $this->pagetree
->addField('mount_pid');
103 $this->pagetree
->addField('mount_pid_ol');
104 $this->pagetree
->addField('nav_hide');
105 $this->pagetree
->addField('nav_title');
106 $this->pagetree
->addField('url');
108 // Temporary DB mounts:
109 $this->initializeTemporaryDBmount();
114 * initialization for the visual parts of the class
115 * Use template rendering only if this is a non-AJAX call
119 public function initPage() {
121 // Setting highlight mode:
122 $this->doHighlight
= !$GLOBALS['BE_USER']->getTSConfigVal('options.pageTree.disableTitleHighlight');
124 // If highlighting is active, define the CSS class for the active item depending on the workspace
125 if ($this->doHighlight
) {
126 $hlClass = ($GLOBALS['BE_USER']->workspace
=== 0 ?
'active' : 'active active-ws wsver' . $GLOBALS['BE_USER']->workspace
);
129 // Create template object:
130 $this->doc
= t3lib_div
::makeInstance('template');
131 $this->doc
->backPath
= $GLOBALS['BACK_PATH'];
132 $this->doc
->setModuleTemplate('templates/alt_db_navframe.html');
133 $this->doc
->showFlashMessages
= FALSE;
138 // Adding javascript code for AJAX (prototype), drag&drop and the pagetree as well as the click menu code
139 $this->doc
->getDragDropCode('pages');
140 $this->doc
->getContextMenuCode();
141 $this->doc
->getPageRenderer()->loadScriptaculous('effects');
142 $this->doc
->getPageRenderer()->loadExtJS();
144 if ($this->hasFilterBox
) {
145 $this->doc
->getPageRenderer()->addJsFile('js/pagetreefiltermenu.js');
148 $this->doc
->JScode
.= $this->doc
->wrapScriptTags(
149 ($this->currentSubScript?
'top.currentSubScript=unescape("'.rawurlencode($this->currentSubScript
).'");':'').'
150 // setting prefs for pagetree and drag & drop
151 '.($this->doHighlight ?
'Tree.highlightClass = "'.$hlClass.'";' : '').'
153 // Function, loading the list frame from navigation tree:
154 function jumpTo(id, linkObj, highlightID, bank) { //
155 var theUrl = top.TS.PATH_typo3 + top.currentSubScript ;
156 if (theUrl.indexOf("?") != -1) {
157 theUrl += "&id=" + id
159 theUrl += "?id=" + id
161 top.fsMod.currentBank = bank;
162 top.TYPO3.Backend.ContentContainer.setUrl(theUrl);
164 '.($this->doHighlight ?
'Tree.highlightActiveItem("web", highlightID + "_" + bank);' : '').'
165 '.(!$GLOBALS['CLIENT']['FORMSTYLE'] ?
'' : 'if (linkObj) linkObj.blur(); ').'
168 '.($this->cMR?
"jumpTo(top.fsMod.recentIds['web'],'');":'').
170 ($this->hasFilterBox ?
'var TYPO3PageTreeFilter = new PageTreeFilter();' : '') . '
174 $this->doc
->bodyTagId
= 'typo3-pagetree';
179 * Main function, rendering the browsable page tree
185 // Produce browse-tree:
186 $tree = $this->pagetree
->getBrowsableTree();
189 // Outputting Temporary DB mount notice:
190 if ($this->active_tempMountPoint
) {
192 <a href="' . htmlspecialchars(t3lib_div
::linkThisScript(array('setTempDBmount' => 0))) . '">' .
193 $GLOBALS['LANG']->sl('LLL:EXT:lang/locallang_core.xml:labels.temporaryDBmount', 1) .
195 $GLOBALS['LANG']->sl('LLL:EXT:lang/locallang_core.xml:labels.path', 1) . ': <span title="' .
196 htmlspecialchars($this->active_tempMountPoint
['_thePathFull']) . '">' .
197 htmlspecialchars(t3lib_div
::fixed_lgd_cs($this->active_tempMountPoint
['_thePath'],-50)).
201 $flashMessage = t3lib_div
::makeInstance(
202 't3lib_FlashMessage',
205 t3lib_FlashMessage
::INFO
209 $this->content
.= $flashMessage->render();
212 // Outputting page tree:
213 $this->content
.= '<div id="PageTreeDiv">'.$tree.'</div>';
215 // Adding javascript for drag & drop activation and highlighting
216 $this->content
.= $this->doc
->wrapScriptTags('
217 '.($this->doHighlight ?
'Tree.highlightActiveItem("",top.fsMod.navFrameHighlightedID["web"]);' : '').'
218 '.(!$this->doc
->isCMlayers() ?
'Tree.activateDragDrop = false;' : 'Tree.registerDragDropHandlers();')
221 // Setting up the buttons and markers for docheader
222 $docHeaderButtons = $this->getButtons();
224 'IMG_RESET' => t3lib_iconWorks
::getSpriteIcon('actions-document-close', array(
225 'id' =>'treeFilterReset',
226 'alt'=> $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:labels.resetFilter'),
227 'title' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:labels.resetFilter')
229 'WORKSPACEINFO' => $this->getWorkspaceInfo(),
230 'CONTENT' => $this->content
234 if (!$this->hasFilterBox
) {
235 $subparts['###SECOND_ROW###'] = '';
237 // Build the <body> for the module
238 $this->content
= $this->doc
->startPage('TYPO3 Page Tree');
239 $this->content
.= $this->doc
->moduleBody($this->pageinfo
, $docHeaderButtons, $markers, $subparts);
240 $this->content
.= $this->doc
->endPage();
242 $this->content
= $this->doc
->insertStylesAndJS($this->content
);
246 * Outputting the accumulated content to screen
250 function printContent() {
255 * Create the panel of buttons for submitting the form or otherwise perform operations.
257 * @return array all available buttons as an assoc. array
259 protected function getButtons() {
268 $onclickNewPageWizard = 'top.content.list_frame.location.href=top.TS.PATH_typo3+\'db_new.php?pagesOnly=1&id=\'+Tree.pageID;';
269 $buttons['new_page'] = '<a href="#" onclick="' . $onclickNewPageWizard . '" title="' . $GLOBALS['LANG']->sL('LLL:EXT:cms/layout/locallang.xml:newPage', TRUE) . '">' .
270 t3lib_iconWorks
::getSpriteIcon('actions-page-new') .
274 $buttons['refresh'] = '<a href="' . htmlspecialchars(t3lib_div
::getIndpEnv('REQUEST_URI')) . '" title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.refresh', TRUE) . '">' .
275 t3lib_iconWorks
::getSpriteIcon('actions-system-refresh') .
279 $buttons['csh'] = str_replace('typo3-csh-inline','typo3-csh-inline show-right',t3lib_BEfunc
::cshItem('xMOD_csh_corebe', 'pagetree', $GLOBALS['BACK_PATH'], '', TRUE));
282 if ($this->hasFilterBox
) {
283 $buttons['filter'] = '<a href="#" id="tree-toolbar-filter-item">' . t3lib_iconWorks
::getSpriteIcon('actions-system-tree-search-open', array('title'=> $GLOBALS['LANG']->sL('LLL:EXT:cms/layout/locallang.xml:labels.filter', 1))) . '</a>';
290 * Create the workspace information
292 * @return string HTML containing workspace info
294 protected function getWorkspaceInfo() {
296 if (t3lib_extMgm
::isLoaded('workspaces') && ($GLOBALS['BE_USER']->workspace
!== 0 ||
$GLOBALS['BE_USER']->getTSConfigVal('options.pageTree.onlineWorkspaceInfo'))) {
297 $wsTitle = htmlspecialchars(tx_Workspaces_Service_Workspaces
::getWorkspaceTitle($GLOBALS['BE_USER']->workspace
));
300 <div class="bgColor4 workspace-info">' .
301 t3lib_iconWorks
::getSpriteIcon(
302 'apps-toolbar-menu-workspace',
305 'onclick' => 'top.goToModule(\'web_WorkspacesWorkspaces\');',
306 'style' => 'cursor:pointer;'
314 return $workspaceInfo;
318 /**********************************
320 * Temporary DB mounts
322 **********************************/
325 * Getting temporary DB mount
329 function initializeTemporaryDBmount(){
331 // Set/Cancel Temporary DB Mount:
332 if (strlen($this->setTempDBmount
)) {
333 $set = t3lib_utility_Math
::forceIntegerInRange($this->setTempDBmount
,0);
334 if ($set > 0 && $GLOBALS['BE_USER']->isInWebMount($set)){
336 $this->settingTemporaryMountPoint($set);
338 $this->settingTemporaryMountPoint(0);
342 // Getting temporary mount point ID:
343 $temporaryMountPoint = intval($GLOBALS['BE_USER']->getSessionData('pageTree_temporaryMountPoint'));
345 // If mount point ID existed and is within users real mount points, then set it temporarily:
346 if ($temporaryMountPoint > 0 && $GLOBALS['BE_USER']->isInWebMount($temporaryMountPoint)) {
347 if ($this->active_tempMountPoint
= t3lib_BEfunc
::readPageAccess($temporaryMountPoint, $GLOBALS['BE_USER']->getPagePermsClause(1))) {
348 $this->pagetree
->MOUNTS
= array($temporaryMountPoint);
351 // Clear temporary mount point as we have no access to it any longer
352 $this->settingTemporaryMountPoint(0);
359 * Setting temporary page id as DB mount
361 * @param integer The page id to set as DB mount
364 function settingTemporaryMountPoint($pageId) {
365 $GLOBALS['BE_USER']->setAndSaveSessionData('pageTree_temporaryMountPoint',intval($pageId));
369 /**********************************
373 **********************************/
376 * Makes the AJAX call to expand or collapse the pagetree.
377 * Called by typo3/ajax.php
379 * @param array $params: additional parameters (not used here)
380 * @param TYPO3AJAX $ajaxObj: The TYPO3AJAX object of this request
383 public function ajaxExpandCollapse($params, $ajaxObj) {
385 $tree = $this->pagetree
->getBrowsableTree();
386 if (!$this->pagetree
->ajaxStatus
) {
387 $ajaxObj->setError($tree);
389 $ajaxObj->addContent('tree', $tree);
394 // Make instance if it is not an AJAX call
395 if (!(TYPO3_REQUESTTYPE
& TYPO3_REQUESTTYPE_AJAX
)) {
396 $SOBE = t3lib_div
::makeInstance('SC_alt_db_navframe');
400 $SOBE->printContent();