2 /***************************************************************
5 * (c) 1999-2005 Kasper Skaarhoj (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 Skaarhoj
34 * @author Kasper Skaarhoj <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")
57 require('template.php');
58 require_once('class.webpagetree.php');
62 * Main script class for the page tree navigation frame
64 * @author Kasper Skaarhoj <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 $ajax; // Is set, if an AJAX call should be handled.
85 var $currentSubScript;
87 var $setTempDBmount; // If not '' (blank) then it will clear (0) or set (>0) Temporary DB mount.
90 * Initialiation of the class
95 global $BE_USER,$BACK_PATH;
98 $this->backPath
= $BACK_PATH;
101 $this->ajax
= t3lib_div
::_GP('ajax');
102 $this->cMR
= t3lib_div
::_GP('cMR');
103 $this->currentSubScript
= t3lib_div
::_GP('currentSubScript');
104 $this->setTempDBmount
= t3lib_div
::_GP('setTempDBmount');
106 // Create page tree object:
107 $this->pagetree
= t3lib_div
::makeInstance('webPageTree');
108 $this->pagetree
->ext_IconMode
= $BE_USER->getTSConfigVal('options.pageTree.disableIconLinkToContextmenu');
109 $this->pagetree
->ext_showPageId
= $BE_USER->getTSConfigVal('options.pageTree.showPageIdWithTitle');
110 $this->pagetree
->thisScript
= 'alt_db_navframe.php';
111 $this->pagetree
->addField('alias');
112 $this->pagetree
->addField('shortcut');
113 $this->pagetree
->addField('shortcut_mode');
114 $this->pagetree
->addField('mount_pid');
115 $this->pagetree
->addField('mount_pid_ol');
116 $this->pagetree
->addField('nav_hide');
117 $this->pagetree
->addField('url');
119 // Temporary DB mounts:
120 $this->initializeTemporaryDBmount();
122 // Use template rendering only if this is a non-AJAX call:
124 // Setting highlight mode:
125 $this->doHighlight
= !$BE_USER->getTSConfigVal('options.pageTree.disableTitleHighlight');
127 // If highlighting is active, define the CSS class for the active item depending on the workspace
128 if ($this->doHighlight
) {
129 if ($BE_USER->workspace
=== 0) $hlClass = 'active';
130 else $hlClass = 'active active-ws wsver'.$BE_USER->workspace
;
133 // Create template object:
134 $this->doc
= t3lib_div
::makeInstance('template');
135 $this->doc
->backPath
= $BACK_PATH;
136 $this->doc
->docType
= 'xhtml_trans';
138 // Adding javascript code for AJAX (prototype), drag&drop and the pagetree
139 $this->doc
->JScode
= '
140 <script type="text/javascript" src="'.$this->backPath
.'contrib/prototype/prototype.js"></script>
141 <script type="text/javascript" src="'.$this->backPath
.'tree.js"></script>'."\n";
143 $this->doc
->JScode
.= $this->doc
->wrapScriptTags(
144 ($this->currentSubScript?
'top.currentSubScript=unescape("'.rawurlencode($this->currentSubScript
).'");':'').'
145 // setting prefs for pagetree and drag & drop
146 Tree.thisScript = "'.$this->pagetree
->thisScript
.'";
147 '.($this->doHighlight ?
'Tree.highlightClass = "'.$hlClass.'";' : '').'
149 DragDrop.changeURL = "'.$this->backPath
.'alt_clickmenu.php";
150 DragDrop.backPath = "'.t3lib_div
::shortMD5(''.'|'.$GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey']).'";
151 DragDrop.table = "pages";
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 + "?id=" + id;
156 top.fsMod.currentBank = bank;
158 if (top.condensedMode) top.content.location.href = theUrl;
159 else parent.list_frame.location.href=theUrl;
161 '.($this->doHighlight ?
'Tree.highlightActiveItem("web", highlightID + "_" + bank);' : '').'
162 '.(!$GLOBALS['CLIENT']['FORMSTYLE'] ?
'' : 'if (linkObj) linkObj.blur(); ').'
165 '.($this->cMR?
"jumpTo(top.fsMod.recentIds['web'],'');":'').'
168 // Click menu code is added:
169 $CMparts=$this->doc
->getContextMenuCode();
170 $this->doc
->bodyTagAdditions
= $CMparts[1];
171 $this->doc
->JScode
.= $CMparts[0];
172 $this->doc
->postCode
.= $CMparts[2];
178 * Main function, rendering the browsable page tree
183 global $LANG,$CLIENT;
185 // Produce browse-tree:
186 $tree = $this->pagetree
->getBrowsableTree();
188 // Output only the tree if this is an AJAX call:
190 $this->content
= $LANG->csConvObj
->utf8_encode($tree, $LANG->charSet
);
195 $this->content
= $this->doc
->startPage('TYPO3 Page Tree');
197 // Outputting workspace info
198 if ($GLOBALS['BE_USER']->workspace
!==0 ||
$GLOBALS['BE_USER']->getTSConfigVal('options.pageTree.onlineWorkspaceInfo')) {
199 switch($GLOBALS['BE_USER']->workspace
) {
201 $wsTitle = ' '.$this->doc
->icons(2).'['.$LANG->sL('LLL:EXT:lang/locallang_misc.xml:shortcut_onlineWS',1).']';
204 $wsTitle = '['.$LANG->sL('LLL:EXT:lang/locallang_misc.xml:shortcut_offlineWS',1).']';
207 $wsTitle = '['.$GLOBALS['BE_USER']->workspace
.'] '.htmlspecialchars($GLOBALS['BE_USER']->workspaceRec
['title']);
212 <div class="bgColor4 workspace-info">'.
213 '<a href="'.htmlspecialchars('mod/user/ws/index.php').'" target="content">'.
214 '<img'.t3lib_iconWorks
::skinImg('','gfx/i/sys_workspace.png','width="18" height="16"').' align="top" alt="" />'.
220 // Outputting Temporary DB mount notice:
221 if ($this->active_tempMountPoint
) {
223 <div class="bgColor4 c-notice">
224 <img'.t3lib_iconWorks
::skinImg('','gfx/icon_note.gif','width="18" height="16"').' align="top" alt="" />'.
225 '<a href="'.htmlspecialchars(t3lib_div
::linkThisScript(array('setTempDBmount' => 0))).'">'.
226 $LANG->sl('LLL:EXT:lang/locallang_core.php:labels.temporaryDBmount',1).
228 '.$LANG->sl('LLL:EXT:lang/locallang_core.php:labels.path',1).': <span title="'.htmlspecialchars($this->active_tempMountPoint
['_thePathFull']).'">'.htmlspecialchars(t3lib_div
::fixed_lgd_cs($this->active_tempMountPoint
['_thePath'],-50)).'</span>
233 // Outputting page tree:
234 $this->content
.= $tree;
236 // Outputting refresh-link
238 <p class="c-refresh">
239 <a href="'.htmlspecialchars(t3lib_div
::getIndpEnv('REQUEST_URI')).'">'.
240 '<img'.t3lib_iconWorks
::skinImg('','gfx/refresh_n.gif','width="14" height="14"').' title="'.$LANG->sL('LLL:EXT:lang/locallang_core.php:labels.refresh',1).'" alt="" />'.
241 $LANG->sL('LLL:EXT:lang/locallang_core.php:labels.refresh',1).'</a>
246 $this->content
.= t3lib_BEfunc
::cshItem('xMOD_csh_corebe', 'pagetree', $GLOBALS['BACK_PATH']);
248 // Adding javascript for drag & drop activation and highlighting
249 $this->content
.=$this->doc
->wrapScriptTags('
250 '.($this->doHighlight ?
'Tree.highlightActiveItem("",top.fsMod.navFrameHighlightedID["web"]);' : '').'
251 '.(!$this->doc
->isCMlayers() ?
'Tree.activateDragDrop = false;' : 'Tree.registerDragDropHandlers();')
256 * Outputting the accumulated content to screen
260 function printContent() {
261 // If we handle an AJAX call, send headers:
263 header('X-JSON: ('.($this->pagetree
->ajaxStatus?
'true':'false').')');
264 header('Content-type: text/html; charset=utf-8');
265 // If it's the regular call to fully output the tree:
267 $this->content
.= $this->doc
->endPage();
268 $this->content
= $this->doc
->insertStylesAndJS($this->content
);
277 /**********************************
279 * Temporary DB mounts
281 **********************************/
284 * Getting temporary DB mount
288 function initializeTemporaryDBmount(){
291 // Set/Cancel Temporary DB Mount:
292 if (strlen($this->setTempDBmount
)) {
293 $set = t3lib_div
::intInRange($this->setTempDBmount
,0);
294 if ($set>0 && $BE_USER->isInWebMount($set)) { // Setting...:
295 $this->settingTemporaryMountPoint($set);
297 $this->settingTemporaryMountPoint(0);
301 // Getting temporary mount point ID:
302 $temporaryMountPoint = intval($BE_USER->getSessionData('pageTree_temporaryMountPoint'));
304 // If mount point ID existed and is within users real mount points, then set it temporarily:
305 if ($temporaryMountPoint > 0 && $BE_USER->isInWebMount($temporaryMountPoint)) {
306 if ($this->active_tempMountPoint
= t3lib_BEfunc
::readPageAccess($temporaryMountPoint, $BE_USER->getPagePermsClause(1))) {
307 $this->pagetree
->MOUNTS
= array($temporaryMountPoint);
310 // Clear temporary mount point as we have no access to it any longer
311 $this->settingTemporaryMountPoint(0);
318 * Setting temporary page id as DB mount
320 * @param integer The page id to set as DB mount
323 function settingTemporaryMountPoint($pageId) {
326 // Setting temporary mount point ID:
327 $BE_USER->setAndSaveSessionData('pageTree_temporaryMountPoint',intval($pageId));
332 // Include extension?
333 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE
]['XCLASS']['typo3/alt_db_navframe.php']) {
334 include_once($TYPO3_CONF_VARS[TYPO3_MODE
]['XCLASS']['typo3/alt_db_navframe.php']);
342 $SOBE = t3lib_div
::makeInstance('SC_alt_db_navframe');
345 $SOBE->printContent();