Added feature #7150: Add pageUnavailable_handling for system problems and maintenance
[Packages/TYPO3.CMS.git] / typo3 / alt_db_navframe.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 1999-2005 Kasper Skaarhoj (kasperYYYY@typo3.com)
6 * All rights reserved
7 *
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.
13 *
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.
18 *
19 *
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.
24 *
25 * This copyright notice MUST APPEAR in all copies of the script!
26 ***************************************************************/
27 /**
28 * Page navigation tree for the Web module
29 *
30 * $Id$
31 * Revised for TYPO3 3.6 2/2003 by Kasper Skaarhoj
32 * XHTML compliant
33 *
34 * @author Kasper Skaarhoj <kasperYYYY@typo3.com>
35 */
36 /**
37 * [CLASS/FUNCTION INDEX of SCRIPT]
38 *
39 *
40 * 192: class SC_alt_db_navframe
41 * 210: function init()
42 * 313: function main()
43 * 387: function printContent()
44 *
45 * SECTION: Temporary DB mounts
46 * 415: function initializeTemporaryDBmount()
47 * 449: function settingTemporaryMountPoint($pageId)
48 *
49 * TOTAL FUNCTIONS: 9
50 * (This index is automatically created/updated by the extension "extdeveval")
51 *
52 */
53
54
55 $BACK_PATH = '';
56 require_once('init.php');
57 require('template.php');
58 require_once('class.webpagetree.php');
59
60
61 /**
62 * Main script class for the page tree navigation frame
63 *
64 * @author Kasper Skaarhoj <kasperYYYY@typo3.com>
65 * @package TYPO3
66 * @subpackage core
67 */
68 class SC_alt_db_navframe {
69
70 // Internal:
71 var $content;
72 var $pagetree;
73
74 /**
75 * document template object
76 *
77 * @var template
78 */
79 var $doc;
80 var $active_tempMountPoint = 0; // Temporary mount point (record), if any
81 var $backPath;
82
83 // Internal, static: GPvar:
84 var $currentSubScript;
85 var $cMR;
86 var $setTempDBmount; // If not '' (blank) then it will clear (0) or set (>0) Temporary DB mount.
87
88 var $template; // a static HTML template, usually in templates/alt_db_navframe.html
89 var $hasFilterBox; //depends on userTS-setting
90
91 /**
92 * Initialiation of the class
93 *
94 * @return void
95 */
96 function init() {
97 global $BE_USER,$BACK_PATH;
98
99 // Setting backPath
100 $this->backPath = $BACK_PATH;
101
102 // Setting GPvars:
103 $this->cMR = t3lib_div::_GP('cMR');
104 $this->currentSubScript = t3lib_div::_GP('currentSubScript');
105 $this->setTempDBmount = t3lib_div::_GP('setTempDBmount');
106
107 // look for User setting
108 $this->hasFilterBox = !$BE_USER->getTSConfigVal('options.pageTree.hideFilter');
109
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');
126
127 // Temporary DB mounts:
128 $this->initializeTemporaryDBmount();
129 }
130
131
132 /**
133 * initialization for the visual parts of the class
134 * Use template rendering only if this is a non-AJAX call
135 *
136 * @return void
137 */
138 public function initPage() {
139 global $BE_USER;
140
141 // Setting highlight mode:
142 $this->doHighlight = !$BE_USER->getTSConfigVal('options.pageTree.disableTitleHighlight');
143
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);
147 }
148
149 // Create template object:
150 $this->doc = t3lib_div::makeInstance('template');
151 $this->doc->backPath = $BACK_PATH;
152 $this->doc->docType = 'xhtml_trans';
153
154 // get HTML-Template
155 $this->template = $this->doc->getHtmlTemplate('templates/alt_db_navframe.html');
156
157
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->loadJavascriptLib('contrib/scriptaculous/scriptaculous.js?load=effects');
162
163 $this->doc->JScode .= $this->doc->wrapScriptTags(
164 ($this->currentSubScript?'top.currentSubScript=unescape("'.rawurlencode($this->currentSubScript).'");':'').'
165 // setting prefs for pagetree and drag & drop
166 '.($this->doHighlight ? 'Tree.highlightClass = "'.$hlClass.'";' : '').'
167
168 // Function, loading the list frame from navigation tree:
169 function jumpTo(id, linkObj, highlightID, bank) { //
170 var theUrl = top.TS.PATH_typo3 + top.currentSubScript + "?id=" + id;
171 top.fsMod.currentBank = bank;
172
173 if (top.condensedMode) top.content.location.href = theUrl;
174 else parent.list_frame.location.href=theUrl;
175
176 '.($this->doHighlight ? 'Tree.highlightActiveItem("web", highlightID + "_" + bank);' : '').'
177 '.(!$GLOBALS['CLIENT']['FORMSTYLE'] ? '' : 'if (linkObj) linkObj.blur(); ').'
178 return false;
179 }
180 '.($this->cMR?"jumpTo(top.fsMod.recentIds['web'],'');":'').
181
182 ($this->hasFilterBox ? 'var TYPO3PageTreeFilter = new PageTreeFilter();' : '') . '
183
184 ');
185
186 $this->doc->bodyTagId = 'typo3-pagetree';
187 }
188
189
190 /**
191 * Main function, rendering the browsable page tree
192 *
193 * @return void
194 */
195 function main() {
196 global $LANG,$CLIENT;
197
198 // Produce browse-tree:
199 $tree = $this->pagetree->getBrowsableTree();
200
201 // Start page:
202 $this->content = $this->doc->startPage('TYPO3 Page Tree');
203
204 // Outputting workspace info
205 if ($GLOBALS['BE_USER']->workspace!==0 || $GLOBALS['BE_USER']->getTSConfigVal('options.pageTree.onlineWorkspaceInfo')) {
206 switch($GLOBALS['BE_USER']->workspace) {
207 case 0:
208 $wsTitle = '&nbsp;'.$this->doc->icons(2).'['.$LANG->sL('LLL:EXT:lang/locallang_misc.xml:shortcut_onlineWS',1).']';
209 break;
210 case -1:
211 $wsTitle = '['.$LANG->sL('LLL:EXT:lang/locallang_misc.xml:shortcut_offlineWS',1).']';
212 break;
213 default:
214 $wsTitle = '['.$GLOBALS['BE_USER']->workspace.'] '.htmlspecialchars($GLOBALS['BE_USER']->workspaceRec['title']);
215 break;
216 }
217
218 $showWorkspaceInfo = true;
219 }
220
221 //prepare onclick links
222 $onclickNewPageWizard = 'top.content.list_frame.location.href=top.TS.PATH_typo3+\'db_new.php?id=1&pagesOnly=1\';"';
223
224 $docheader = t3lib_parsehtml::getSubpart($this->template, '###DOCHEADER###');
225
226 $markers['BUTTONSLEFT'] =
227 // Filter switch
228 ($this->hasFilterBox ? '
229 <a href="#" id="toggleTreeFilter">
230 <img'.t3lib_iconWorks::skinImg('',$GLOBALS['BE_USER']->uc['moduleData']['pageTree']['filterBox'] ? 'gfx/arrowright.gif' : 'gfx/arrowdown.gif','width="16" height="16"').' title="show filter" alt="" />
231 <span>'.$LANG->sL('LLL:EXT:lang/locallang_misc.xml:pageTree_filter',1).'</span>
232 </a>' : '')
233 ;
234
235 $markers['BUTTONSRIGHT'] =
236 // New Page
237 '<a href="#" onclick="'.$onclickNewPageWizard.'"><img'.t3lib_iconWorks::skinImg('','gfx/new_page.gif','width="13" height="12"').' title="'.$LANG->sL('LLL:EXT:cms/layout/locallang.xml:newPage',1).'" alt="" /></a>'.
238
239 // Refresh-Icon
240 '<a href="'.htmlspecialchars(t3lib_div::getIndpEnv('REQUEST_URI')).'"><img'.t3lib_iconWorks::skinImg('','gfx/refresh_n.gif','width="14" height="14"').' title="'.$LANG->sL('LLL:EXT:lang/locallang_core.xml:labels.refresh',1).'" alt="" /></a>'.
241
242 // CSH-Icon
243 t3lib_BEfunc::cshItem('xMOD_csh_corebe', 'pagetree', $GLOBALS['BACK_PATH'])
244
245 ;
246
247 $markers['STYLE'] = $GLOBALS['BE_USER']->uc['moduleData']['pageTree']['filterBox'] ? ' style="display:none;"' : '';
248 $markers['IMG_RESET'] = '<img'.t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'], 'gfx/search_reset.png', ' width="11" height="11"').' id="treeFilterReset" alt="Reset Filter" />';
249
250 $this->content .= t3lib_parsehtml::substituteMarkerArray($docheader, $markers, '###|###');
251
252
253 if($showWorkspaceInfo) {
254 $this->content.= '
255 <div class="bgColor4 workspace-info">'.
256 '<a href="'.htmlspecialchars('mod/user/ws/index.php').'" target="content">'.
257 '<img'.t3lib_iconWorks::skinImg('','gfx/i/sys_workspace.png','width="18" height="16"').' align="top" alt="" />'.
258 '</a>'.$wsTitle.'
259 </div>
260 ';
261 }
262
263
264 // Outputting Temporary DB mount notice:
265 if ($this->active_tempMountPoint) {
266 $this->content.= '
267 <div class="bgColor4 c-notice">
268 <img'.t3lib_iconWorks::skinImg('','gfx/icon_note.gif','width="18" height="16"').' align="top" alt="" />'.
269 '<a href="'.htmlspecialchars(t3lib_div::linkThisScript(array('setTempDBmount' => 0))).'">'.
270 $LANG->sl('LLL:EXT:lang/locallang_core.xml:labels.temporaryDBmount',1).
271 '</a><br/>
272 '.$LANG->sl('LLL:EXT:lang/locallang_core.xml:labels.path',1).': <span title="'.htmlspecialchars($this->active_tempMountPoint['_thePathFull']).'">'.htmlspecialchars(t3lib_div::fixed_lgd_cs($this->active_tempMountPoint['_thePath'],-50)).'</span>
273 </div>
274 ';
275 }
276
277
278 // Outputting page tree:
279 $this->content .= '<div id="PageTreeDiv">'.$tree.'</div>';
280
281 // Adding javascript for drag & drop activation and highlighting
282 $this->content .= $this->doc->wrapScriptTags('
283 '.($this->doHighlight ? 'Tree.highlightActiveItem("",top.fsMod.navFrameHighlightedID["web"]);' : '').'
284 '.(!$this->doc->isCMlayers() ? 'Tree.activateDragDrop = false;' : 'Tree.registerDragDropHandlers();')
285 );
286 }
287
288 /**
289 * Outputting the accumulated content to screen
290 *
291 * @return void
292 */
293 function printContent() {
294 $this->content.= $this->doc->endPage();
295 $this->content = $this->doc->insertStylesAndJS($this->content);
296 echo $this->content;
297 }
298
299
300
301
302
303 /**********************************
304 *
305 * Temporary DB mounts
306 *
307 **********************************/
308
309 /**
310 * Getting temporary DB mount
311 *
312 * @return void
313 */
314 function initializeTemporaryDBmount(){
315 global $BE_USER;
316
317 // Set/Cancel Temporary DB Mount:
318 if (strlen($this->setTempDBmount)) {
319 $set = t3lib_div::intInRange($this->setTempDBmount,0);
320 if ($set>0 && $BE_USER->isInWebMount($set)) { // Setting...:
321 $this->settingTemporaryMountPoint($set);
322 } else { // Clear:
323 $this->settingTemporaryMountPoint(0);
324 }
325 }
326
327 // Getting temporary mount point ID:
328 $temporaryMountPoint = intval($BE_USER->getSessionData('pageTree_temporaryMountPoint'));
329
330 // If mount point ID existed and is within users real mount points, then set it temporarily:
331 if ($temporaryMountPoint > 0 && $BE_USER->isInWebMount($temporaryMountPoint)) {
332 if ($this->active_tempMountPoint = t3lib_BEfunc::readPageAccess($temporaryMountPoint, $BE_USER->getPagePermsClause(1))) {
333 $this->pagetree->MOUNTS = array($temporaryMountPoint);
334 }
335 else {
336 // Clear temporary mount point as we have no access to it any longer
337 $this->settingTemporaryMountPoint(0);
338 }
339 }
340 }
341
342
343 /**
344 * Setting temporary page id as DB mount
345 *
346 * @param integer The page id to set as DB mount
347 * @return void
348 */
349 function settingTemporaryMountPoint($pageId) {
350 $GLOBALS['BE_USER']->setAndSaveSessionData('pageTree_temporaryMountPoint',intval($pageId));
351 }
352
353
354 /**********************************
355 *
356 * AJAX Calls
357 *
358 **********************************/
359
360 /**
361 * Makes the AJAX call to expand or collapse the pagetree.
362 * Called by typo3/ajax.php
363 *
364 * @param array $params: additional parameters (not used here)
365 * @param TYPO3AJAX &$ajaxObj: reference of the TYPO3AJAX object of this request
366 * @return void
367 */
368 public function ajaxExpandCollapse($params, &$ajaxObj) {
369 global $LANG;
370
371 $this->init();
372 $tree = $this->pagetree->getBrowsableTree();
373 if (!$this->pagetree->ajaxStatus) {
374 $ajaxObj->setError($tree);
375 } else {
376 $ajaxObj->addContent('tree', $tree);
377 }
378 }
379
380 /**
381 * Makes the AJAX call to expand or collapse the filterbox.
382 * Called by typo3/ajax.php
383 *
384 * @param array $params: additional parameters (not used here)
385 * @param TYPO3AJAX &$ajaxObj: reference of the TYPO3AJAX object of this request
386 * @return void
387 */
388 public function ajaxSaveFilterboxStatus(array $params, &$ajaxObj) {
389 $state = t3lib_div::_POST('state') === 'true' ? 1 : 0;
390
391 $GLOBALS['BE_USER']->uc['moduleData']['pageTree']['filterBox'] = $state;
392 $GLOBALS['BE_USER']->writeUC();
393 }
394
395 }
396
397
398 // Include extension?
399 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/alt_db_navframe.php']) {
400 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/alt_db_navframe.php']);
401 }
402
403
404 // Make instance if it is not an AJAX call
405 if (!(TYPO3_REQUESTTYPE & TYPO3_REQUESTTYPE_AJAX)) {
406 $SOBE = t3lib_div::makeInstance('SC_alt_db_navframe');
407 $SOBE->init();
408 $SOBE->initPage();
409 $SOBE->main();
410 $SOBE->printContent();
411 }
412
413 ?>