Fixed bug: #5092: Typo in Who is online
[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('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 var $doc;
74 var $active_tempMountPoint = 0; // Temporary mount point (record), if any
75 var $backPath;
76
77 // Internal, static: GPvar:
78 var $ajax; // Is set, if an AJAX call should be handled.
79 var $currentSubScript;
80 var $cMR;
81 var $setTempDBmount; // If not '' (blank) then it will clear (0) or set (>0) Temporary DB mount.
82
83 /**
84 * Initialiation of the class
85 *
86 * @return void
87 */
88 function init() {
89 global $BE_USER,$BACK_PATH;
90
91 // Setting backPath
92 $this->backPath = $BACK_PATH;
93 $this->doc->backPath = $BACK_PATH;
94
95 // Setting GPvars:
96 $this->ajax = t3lib_div::_GP('ajax');
97 $this->cMR = t3lib_div::_GP('cMR');
98 $this->currentSubScript = t3lib_div::_GP('currentSubScript');
99 $this->setTempDBmount = t3lib_div::_GP('setTempDBmount');
100
101 // Create page tree object:
102 $this->pagetree = t3lib_div::makeInstance('webPageTree');
103 $this->pagetree->ext_IconMode = $BE_USER->getTSConfigVal('options.pageTree.disableIconLinkToContextmenu');
104 $this->pagetree->ext_showPageId = $BE_USER->getTSConfigVal('options.pageTree.showPageIdWithTitle');
105 $this->pagetree->thisScript = 'alt_db_navframe.php';
106 $this->pagetree->addField('alias');
107 $this->pagetree->addField('shortcut');
108 $this->pagetree->addField('shortcut_mode');
109 $this->pagetree->addField('mount_pid');
110 $this->pagetree->addField('mount_pid_ol');
111 $this->pagetree->addField('nav_hide');
112 $this->pagetree->addField('url');
113
114 // Temporary DB mounts:
115 $this->initializeTemporaryDBmount();
116
117 // Use template rendering only if this is a non-AJAX call:
118 if (!$this->ajax) {
119 // Setting highlight mode:
120 $this->doHighlight = !$BE_USER->getTSConfigVal('options.pageTree.disableTitleHighlight');
121
122 // If highlighting is active, define the CSS class for the active item depending on the workspace
123 if ($this->doHighlight) {
124 if ($BE_USER->workspace === 0) $hlClass = 'active';
125 else $hlClass = 'active active-ws wsver'.$BE_USER->workspace;
126 }
127
128 // Create template object:
129 $this->doc = t3lib_div::makeInstance('template');
130 $this->doc->docType = 'xhtml_trans';
131
132 // Adding javascript code for AJAX (prototype), drag&drop and the pagetree
133 $this->doc->JScode = '
134 <script type="text/javascript" src="'.$this->backPath.'contrib/prototype/prototype.js"></script>
135 <script type="text/javascript" src="'.$this->backPath.'tree.js"></script>'."\n";
136
137 $this->doc->JScode .= $this->doc->wrapScriptTags(
138 ($this->currentSubScript?'top.currentSubScript=unescape("'.rawurlencode($this->currentSubScript).'");':'').'
139 // setting prefs for pagetree and drag & drop
140 Tree.thisScript = "'.$this->pagetree->thisScript.'";
141 '.($this->doHighlight ? 'Tree.highlightClass = "'.$hlClass.'";' : '').'
142
143 DragDrop.changeURL = "'.$this->backPath.'alt_clickmenu.php";
144 DragDrop.backPath = "'.t3lib_div::shortMD5(''.'|'.$GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey']).'";
145 DragDrop.table = "pages";
146
147 // Function, loading the list frame from navigation tree:
148 function jumpTo(id, linkObj, highlightID, bank) { //
149 var theUrl = top.TS.PATH_typo3 + top.currentSubScript + "?id=" + id;
150 top.fsMod.currentBank = bank;
151
152 if (top.condensedMode) top.content.location.href = theUrl;
153 else parent.list_frame.location.href=theUrl;
154
155 '.($this->doHighlight ? 'Tree.highlightActiveItem("web", highlightID + "_" + bank);' : '').'
156 '.(!$GLOBALS['CLIENT']['FORMSTYLE'] ? '' : 'if (linkObj) linkObj.blur(); ').'
157 return false;
158 }
159 '.($this->cMR?"jumpTo(top.fsMod.recentIds['web'],'');":'').'
160 ');
161
162 // Click menu code is added:
163 $CMparts=$this->doc->getContextMenuCode();
164 $this->doc->bodyTagAdditions = $CMparts[1];
165 $this->doc->JScode.= $CMparts[0];
166 $this->doc->postCode.= $CMparts[2];
167 }
168 }
169
170
171 /**
172 * Main function, rendering the browsable page tree
173 *
174 * @return void
175 */
176 function main() {
177 global $LANG,$CLIENT;
178
179 // Produce browse-tree:
180 $tree = $this->pagetree->getBrowsableTree();
181
182 // Output only the tree if this is an AJAX call:
183 if ($this->ajax) {
184 $this->content = $LANG->csConvObj->utf8_encode($tree, $LANG->charSet);
185 return;
186 }
187
188 // Start page:
189 $this->content = $this->doc->startPage('TYPO3 Page Tree');
190
191 // Outputting workspace info
192 if ($GLOBALS['BE_USER']->workspace!==0 || $GLOBALS['BE_USER']->getTSConfigVal('options.pageTree.onlineWorkspaceInfo')) {
193 switch($GLOBALS['BE_USER']->workspace) {
194 case 0:
195 $wsTitle = '&nbsp;'.$this->doc->icons(2).'['.$LANG->sL('LLL:EXT:lang/locallang_misc.xml:shortcut_onlineWS',1).']';
196 break;
197 case -1:
198 $wsTitle = '['.$LANG->sL('LLL:EXT:lang/locallang_misc.xml:shortcut_offlineWS',1).']';
199 break;
200 default:
201 $wsTitle = '['.$GLOBALS['BE_USER']->workspace.'] '.htmlspecialchars($GLOBALS['BE_USER']->workspaceRec['title']);
202 break;
203 }
204
205 $this->content.= '
206 <div class="bgColor4 workspace-info">'.
207 '<a href="'.htmlspecialchars('mod/user/ws/index.php').'" target="content">'.
208 '<img'.t3lib_iconWorks::skinImg('','gfx/i/sys_workspace.png','width="18" height="16"').' align="top" alt="" />'.
209 '</a>'.$wsTitle.'
210 </div>
211 ';
212 }
213
214 // Outputting Temporary DB mount notice:
215 if ($this->active_tempMountPoint) {
216 $this->content.= '
217 <div class="bgColor4 c-notice">
218 <img'.t3lib_iconWorks::skinImg('','gfx/icon_note.gif','width="18" height="16"').' align="top" alt="" />'.
219 '<a href="'.htmlspecialchars(t3lib_div::linkThisScript(array('setTempDBmount' => 0))).'">'.
220 $LANG->sl('LLL:EXT:lang/locallang_core.php:labels.temporaryDBmount',1).
221 '</a><br/>
222 '.$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>
223 </div>
224 ';
225 }
226
227 // Outputting page tree:
228 $this->content.= $tree;
229
230 // Outputting refresh-link
231 $this->content.= '
232 <p class="c-refresh">
233 <a href="'.htmlspecialchars(t3lib_div::getIndpEnv('REQUEST_URI')).'">'.
234 '<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="" />'.
235 $LANG->sL('LLL:EXT:lang/locallang_core.php:labels.refresh',1).'</a>
236 </p>
237 <br />';
238
239 // CSH icon:
240 $this->content.= t3lib_BEfunc::cshItem('xMOD_csh_corebe', 'pagetree', $GLOBALS['BACK_PATH']);
241
242 // Adding javascript for drag & drop activation and highlighting
243 $this->content .=$this->doc->wrapScriptTags('
244 '.($this->doHighlight ? 'Tree.highlightActiveItem("",top.fsMod.navFrameHighlightedID["web"]);' : '').'
245 '.(!$this->doc->isCMlayers() ? 'Tree.activateDragDrop = false;' : 'Tree.registerDragDropHandlers();')
246 );
247 }
248
249 /**
250 * Outputting the accumulated content to screen
251 *
252 * @return void
253 */
254 function printContent() {
255 // If we handle an AJAX call, send headers:
256 if ($this->ajax) {
257 header('X-JSON: ('.($this->pagetree->ajaxStatus?'true':'false').')');
258 header('Content-type: text/html; charset=utf-8');
259 // If it's the regular call to fully output the tree:
260 } else {
261 $this->content.= $this->doc->endPage();
262 $this->content = $this->doc->insertStylesAndJS($this->content);
263 }
264 echo $this->content;
265 }
266
267
268
269
270
271 /**********************************
272 *
273 * Temporary DB mounts
274 *
275 **********************************/
276
277 /**
278 * Getting temporary DB mount
279 *
280 * @return void
281 */
282 function initializeTemporaryDBmount(){
283 global $BE_USER;
284
285 // Set/Cancel Temporary DB Mount:
286 if (strlen($this->setTempDBmount)) {
287 $set = t3lib_div::intInRange($this->setTempDBmount,0);
288 if ($set>0 && $BE_USER->isInWebMount($set)) { // Setting...:
289 $this->settingTemporaryMountPoint($set);
290 } else { // Clear:
291 $this->settingTemporaryMountPoint(0);
292 }
293 }
294
295 // Getting temporary mount point ID:
296 $temporaryMountPoint = intval($BE_USER->getSessionData('pageTree_temporaryMountPoint'));
297
298 // If mount point ID existed and is within users real mount points, then set it temporarily:
299 if ($temporaryMountPoint > 0 && $BE_USER->isInWebMount($temporaryMountPoint)) {
300 if ($this->active_tempMountPoint = t3lib_BEfunc::readPageAccess($temporaryMountPoint, $BE_USER->getPagePermsClause(1))) {
301 $this->pagetree->MOUNTS = array($temporaryMountPoint);
302 }
303 else {
304 // Clear temporary mount point as we have no access to it any longer
305 $this->settingTemporaryMountPoint(0);
306 }
307 }
308 }
309
310
311 /**
312 * Setting temporary page id as DB mount
313 *
314 * @param integer The page id to set as DB mount
315 * @return void
316 */
317 function settingTemporaryMountPoint($pageId) {
318 global $BE_USER;
319
320 // Setting temporary mount point ID:
321 $BE_USER->setAndSaveSessionData('pageTree_temporaryMountPoint',intval($pageId));
322 }
323 }
324
325
326 // Include extension?
327 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/alt_db_navframe.php']) {
328 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/alt_db_navframe.php']);
329 }
330
331
332
333
334
335 // Make instance:
336 $SOBE = t3lib_div::makeInstance('SC_alt_db_navframe');
337 $SOBE->init();
338 $SOBE->main();
339 $SOBE->printContent();
340
341 ?>