2 /***************************************************************
5 * (c) 1999-2010 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
31 * Revised for TYPO3 3.6 2/2003 by Kasper Skårhøj
34 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
37 * [CLASS/FUNCTION INDEX of SCRIPT]
40 * 192: class SC_alt_db_navframe
41 * 210: function init()
42 * 313: function main()
43 * 387: function printContent()
45 * SECTION: Temporary DB mounts
46 * 415: function initializeTemporaryDBmount()
47 * 449: function settingTemporaryMountPoint($pageId)
50 * (This index is automatically created/updated by the extension "extdeveval")
56 require_once('init.php');
57 require('template.php');
58 require_once('class.webpagetree.php');
62 * Main script class for the page tree navigation frame
64 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
68 class SC_alt_db_navframe
{
75 * document template object
80 var $active_tempMountPoint = 0; // Temporary mount point (record), if any
83 // Internal, static: GPvar:
84 var $currentSubScript;
86 var $setTempDBmount; // If not '' (blank) then it will clear (0) or set (>0) Temporary DB mount.
88 var $template; // a static HTML template, usually in templates/alt_db_navframe.html
89 var $hasFilterBox; //depends on userTS-setting
92 * Initialiation of the class
97 global $BE_USER,$BACK_PATH;
100 $this->backPath
= $BACK_PATH;
103 $this->cMR
= t3lib_div
::_GP('cMR');
104 $this->currentSubScript
= t3lib_div
::_GP('currentSubScript');
105 $this->setTempDBmount
= t3lib_div
::_GP('setTempDBmount');
107 // look for User setting
108 $this->hasFilterBox
= !$BE_USER->getTSConfigVal('options.pageTree.hideFilter');
110 // Create page tree object:
111 $this->pagetree
= t3lib_div
::makeInstance('webPageTree');
112 $this->pagetree
->ext_IconMode
= $BE_USER->getTSConfigVal('options.pageTree.disableIconLinkToContextmenu');
113 $this->pagetree
->ext_showPageId
= $BE_USER->getTSConfigVal('options.pageTree.showPageIdWithTitle');
114 $this->pagetree
->ext_showNavTitle
= $BE_USER->getTSConfigVal('options.pageTree.showNavTitle');
115 $this->pagetree
->ext_separateNotinmenuPages
= $BE_USER->getTSConfigVal('options.pageTree.separateNotinmenuPages');
116 $this->pagetree
->ext_alphasortNotinmenuPages
= $BE_USER->getTSConfigVal('options.pageTree.alphasortNotinmenuPages');
117 $this->pagetree
->thisScript
= 'alt_db_navframe.php';
118 $this->pagetree
->addField('alias');
119 $this->pagetree
->addField('shortcut');
120 $this->pagetree
->addField('shortcut_mode');
121 $this->pagetree
->addField('mount_pid');
122 $this->pagetree
->addField('mount_pid_ol');
123 $this->pagetree
->addField('nav_hide');
124 $this->pagetree
->addField('nav_title');
125 $this->pagetree
->addField('url');
127 // Temporary DB mounts:
128 $this->initializeTemporaryDBmount();
133 * initialization for the visual parts of the class
134 * Use template rendering only if this is a non-AJAX call
138 public function initPage() {
141 // Setting highlight mode:
142 $this->doHighlight
= !$BE_USER->getTSConfigVal('options.pageTree.disableTitleHighlight');
144 // If highlighting is active, define the CSS class for the active item depending on the workspace
145 if ($this->doHighlight
) {
146 $hlClass = ($BE_USER->workspace
=== 0 ?
'active' : 'active active-ws wsver'.$BE_USER->workspace
);
149 // Create template object:
150 $this->doc
= t3lib_div
::makeInstance('template');
151 $this->doc
->backPath
= $BACK_PATH;
152 $this->doc
->setModuleTemplate('templates/alt_db_navframe.html');
153 $this->doc
->showFlashMessages
= FALSE;
158 // Adding javascript code for AJAX (prototype), drag&drop and the pagetree as well as the click menu code
159 $this->doc
->getDragDropCode('pages');
160 $this->doc
->getContextMenuCode();
161 $this->doc
->getPageRenderer()->loadScriptaculous('effects');
162 $this->doc
->getPageRenderer()->loadExtJS();
164 if ($this->hasFilterBox
) {
165 $this->doc
->getPageRenderer()->addJsFile('js/pagetreefiltermenu.js');
168 $this->doc
->JScode
.= $this->doc
->wrapScriptTags(
169 ($this->currentSubScript?
'top.currentSubScript=unescape("'.rawurlencode($this->currentSubScript
).'");':'').'
170 // setting prefs for pagetree and drag & drop
171 '.($this->doHighlight ?
'Tree.highlightClass = "'.$hlClass.'";' : '').'
173 // Function, loading the list frame from navigation tree:
174 function jumpTo(id, linkObj, highlightID, bank) { //
175 var theUrl = top.TS.PATH_typo3 + top.currentSubScript ;
176 if (theUrl.indexOf("?") != -1) {
177 theUrl += "&id=" + id
179 theUrl += "?id=" + id
181 top.fsMod.currentBank = bank;
182 top.TYPO3.Backend.ContentContainer.setUrl(theUrl);
184 '.($this->doHighlight ?
'Tree.highlightActiveItem("web", highlightID + "_" + bank);' : '').'
185 '.(!$GLOBALS['CLIENT']['FORMSTYLE'] ?
'' : 'if (linkObj) linkObj.blur(); ').'
188 '.($this->cMR?
"jumpTo(top.fsMod.recentIds['web'],'');":'').
190 ($this->hasFilterBox ?
'var TYPO3PageTreeFilter = new PageTreeFilter();' : '') . '
194 $this->doc
->bodyTagId
= 'typo3-pagetree';
199 * Main function, rendering the browsable page tree
204 global $LANG,$CLIENT;
206 // Produce browse-tree:
207 $tree = $this->pagetree
->getBrowsableTree();
210 // Outputting Temporary DB mount notice:
211 if ($this->active_tempMountPoint
) {
213 <a href="' . htmlspecialchars(t3lib_div
::linkThisScript(array('setTempDBmount' => 0))) . '">' .
214 $LANG->sl('LLL:EXT:lang/locallang_core.xml:labels.temporaryDBmount',1) .
216 $LANG->sl('LLL:EXT:lang/locallang_core.xml:labels.path',1) . ': <span title="' .
217 htmlspecialchars($this->active_tempMountPoint
['_thePathFull']) . '">' .
218 htmlspecialchars(t3lib_div
::fixed_lgd_cs($this->active_tempMountPoint
['_thePath'],-50)).
222 $flashMessage = t3lib_div
::makeInstance(
223 't3lib_FlashMessage',
226 t3lib_FlashMessage
::INFO
230 $this->content
.= $flashMessage->render();
233 // Outputting page tree:
234 $this->content
.= '<div id="PageTreeDiv">'.$tree.'</div>';
236 // Adding javascript for drag & drop activation and highlighting
237 $this->content
.= $this->doc
->wrapScriptTags('
238 '.($this->doHighlight ?
'Tree.highlightActiveItem("",top.fsMod.navFrameHighlightedID["web"]);' : '').'
239 '.(!$this->doc
->isCMlayers() ?
'Tree.activateDragDrop = false;' : 'Tree.registerDragDropHandlers();')
242 // Setting up the buttons and markers for docheader
243 $docHeaderButtons = $this->getButtons();
245 'IMG_RESET' => t3lib_iconWorks
::getSpriteIcon('actions-document-close', array(
246 'id' =>'treeFilterReset',
247 'alt'=> $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:labels.resetFilter'),
248 'title' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:labels.resetFilter')
250 'WORKSPACEINFO' => $this->getWorkspaceInfo(),
251 'CONTENT' => $this->content
255 if (!$this->hasFilterBox
) {
256 $subparts['###SECOND_ROW###'] = '';
258 // Build the <body> for the module
259 $this->content
= $this->doc
->startPage('TYPO3 Page Tree');
260 $this->content
.= $this->doc
->moduleBody($this->pageinfo
, $docHeaderButtons, $markers, $subparts);
261 $this->content
.= $this->doc
->endPage();
263 $this->content
= $this->doc
->insertStylesAndJS($this->content
);
267 * Outputting the accumulated content to screen
271 function printContent() {
276 * Create the panel of buttons for submitting the form or otherwise perform operations.
278 * @return array all available buttons as an assoc. array
280 protected function getButtons() {
291 $onclickNewPageWizard = 'top.content.list_frame.location.href=top.TS.PATH_typo3+\'db_new.php?pagesOnly=1&id=\'+Tree.pageID;';
292 $buttons['new_page'] = '<a href="#" onclick="' . $onclickNewPageWizard . '" title="' . $LANG->sL('LLL:EXT:cms/layout/locallang.xml:newPage', TRUE) . '">' .
293 t3lib_iconWorks
::getSpriteIcon('actions-page-new') .
297 $buttons['refresh'] = '<a href="' . htmlspecialchars(t3lib_div
::getIndpEnv('REQUEST_URI')) . '" title="' . $LANG->sL('LLL:EXT:lang/locallang_core.php:labels.refresh', TRUE) . '">' .
298 t3lib_iconWorks
::getSpriteIcon('actions-system-refresh') .
302 $buttons['csh'] = str_replace('typo3-csh-inline','typo3-csh-inline show-right',t3lib_BEfunc
::cshItem('xMOD_csh_corebe', 'pagetree', $GLOBALS['BACK_PATH'], '', TRUE));
305 if ($this->hasFilterBox
) {
306 $buttons['filter'] = '<a href="#" id="tree-toolbar-filter-item">' . t3lib_iconWorks
::getSpriteIcon('actions-system-tree-search-open', array('title'=> $LANG->sL('LLL:EXT:cms/layout/locallang.xml:labels.filter', 1))) . '</a>';
313 * Create the workspace information
315 * @return string HTML containing workspace info
317 protected function getWorkspaceInfo() {
320 if ($GLOBALS['BE_USER']->workspace
!==0 ||
$GLOBALS['BE_USER']->getTSConfigVal('options.pageTree.onlineWorkspaceInfo')) {
321 switch($GLOBALS['BE_USER']->workspace
) {
323 $wsTitle = ' '.$this->doc
->icons(2).'['.$LANG->sL('LLL:EXT:lang/locallang_misc.xml:bookmark_onlineWS',1).']';
326 $wsTitle = '['.$LANG->sL('LLL:EXT:lang/locallang_misc.xml:bookmark_offlineWS',1).']';
329 $wsTitle = '['.$GLOBALS['BE_USER']->workspace
.'] '.htmlspecialchars($GLOBALS['BE_USER']->workspaceRec
['title']);
334 <div class="bgColor4 workspace-info">
335 <a href="'.htmlspecialchars('mod/user/ws/index.php').'" target="content">'.
336 t3lib_iconWorks
::getSpriteIcon('apps-toolbar-menu-workspace') .
342 return $workspaceInfo;
346 /**********************************
348 * Temporary DB mounts
350 **********************************/
353 * Getting temporary DB mount
357 function initializeTemporaryDBmount(){
360 // Set/Cancel Temporary DB Mount:
361 if (strlen($this->setTempDBmount
)) {
362 $set = t3lib_div
::intInRange($this->setTempDBmount
,0);
363 if ($set>0 && $BE_USER->isInWebMount($set)) { // Setting...:
364 $this->settingTemporaryMountPoint($set);
366 $this->settingTemporaryMountPoint(0);
370 // Getting temporary mount point ID:
371 $temporaryMountPoint = intval($BE_USER->getSessionData('pageTree_temporaryMountPoint'));
373 // If mount point ID existed and is within users real mount points, then set it temporarily:
374 if ($temporaryMountPoint > 0 && $BE_USER->isInWebMount($temporaryMountPoint)) {
375 if ($this->active_tempMountPoint
= t3lib_BEfunc
::readPageAccess($temporaryMountPoint, $BE_USER->getPagePermsClause(1))) {
376 $this->pagetree
->MOUNTS
= array($temporaryMountPoint);
379 // Clear temporary mount point as we have no access to it any longer
380 $this->settingTemporaryMountPoint(0);
387 * Setting temporary page id as DB mount
389 * @param integer The page id to set as DB mount
392 function settingTemporaryMountPoint($pageId) {
393 $GLOBALS['BE_USER']->setAndSaveSessionData('pageTree_temporaryMountPoint',intval($pageId));
397 /**********************************
401 **********************************/
404 * Makes the AJAX call to expand or collapse the pagetree.
405 * Called by typo3/ajax.php
407 * @param array $params: additional parameters (not used here)
408 * @param TYPO3AJAX $ajaxObj: The TYPO3AJAX object of this request
411 public function ajaxExpandCollapse($params, $ajaxObj) {
415 $tree = $this->pagetree
->getBrowsableTree();
416 if (!$this->pagetree
->ajaxStatus
) {
417 $ajaxObj->setError($tree);
419 $ajaxObj->addContent('tree', $tree);
426 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE
]['XCLASS']['typo3/alt_db_navframe.php']) {
427 include_once($TYPO3_CONF_VARS[TYPO3_MODE
]['XCLASS']['typo3/alt_db_navframe.php']);
431 // Make instance if it is not an AJAX call
432 if (!(TYPO3_REQUESTTYPE
& TYPO3_REQUESTTYPE_AJAX
)) {
433 $SOBE = t3lib_div
::makeInstance('SC_alt_db_navframe');
437 $SOBE->printContent();