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