Fixing SVN directory structure
[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 *
41 * 78: class localPageTree extends t3lib_browseTree
42 * 88: function localPageTree()
43 * 99: function wrapIcon($icon,&$row)
44 * 142: function wrapStop($str,$row)
45 * 158: function wrapTitle($title,$row,$bank=0)
46 *
47 *
48 * 192: class SC_alt_db_navframe
49 * 210: function init()
50 * 313: function main()
51 * 387: function printContent()
52 *
53 * SECTION: Temporary DB mounts
54 * 415: function initializeTemporaryDBmount()
55 * 449: function settingTemporaryMountPoint($pageId)
56 *
57 * TOTAL FUNCTIONS: 9
58 * (This index is automatically created/updated by the extension "extdeveval")
59 *
60 */
61
62
63 $BACK_PATH='';
64 require('init.php');
65 require('template.php');
66 require_once(PATH_t3lib.'class.t3lib_browsetree.php');
67
68
69
70 /**
71 * Extension class for the t3lib_browsetree class, specially made for browsing pages in the Web module
72 *
73 * @author Kasper Skaarhoj <kasperYYYY@typo3.com>
74 * @package TYPO3
75 * @subpackage core
76 * @see class t3lib_browseTree
77 */
78 class localPageTree extends t3lib_browseTree {
79
80 var $ext_showPageId;
81 var $ext_IconMode;
82
83 /**
84 * Calls init functions
85 *
86 * @return void
87 */
88 function localPageTree() {
89 $this->init();
90 }
91
92 /**
93 * Wrapping icon in browse tree
94 *
95 * @param string Icon IMG code
96 * @param array Data row for element.
97 * @return string Page icon
98 */
99 function wrapIcon($icon,&$row) {
100 // If the record is locked, present a warning sign.
101 if ($lockInfo=t3lib_BEfunc::isRecordLocked('pages',$row['uid'])) {
102 $aOnClick = 'alert('.$GLOBALS['LANG']->JScharCode($lockInfo['msg']).');return false;';
103 $lockIcon='<a href="#" onclick="'.htmlspecialchars($aOnClick).'">'.
104 '<img'.t3lib_iconWorks::skinImg('','gfx/recordlock_warning3.gif','width="17" height="12"').' title="'.htmlspecialchars($lockInfo['msg']).'" alt="" />'.
105 '</a>';
106 } else $lockIcon = '';
107
108 // Add title attribute to input icon tag
109 $thePageIcon = $this->addTagAttributes($icon, $this->titleAttrib.'="'.$this->getTitleAttrib($row).'"');
110
111 // Wrap icon in click-menu link.
112 if (!$this->ext_IconMode) {
113 $thePageIcon = $GLOBALS['TBE_TEMPLATE']->wrapClickMenuOnIcon($thePageIcon,'pages',$row['uid'],0,'&bank='.$this->bank);
114 } elseif (!strcmp($this->ext_IconMode,'titlelink')) {
115 $aOnClick = 'return jumpTo(\''.$this->getJumpToParam($row).'\',this,\''.$this->treeName.'\');';
116 $thePageIcon='<a href="#" onclick="'.htmlspecialchars($aOnClick).'">'.$thePageIcon.'</a>';
117 }
118
119 // Wrap icon in a drag/drop span.
120 $spanOnDrag = htmlspecialchars('return dragElement("'.$row['uid'].'")');
121 $spanOnDrop = htmlspecialchars('return dropElement("'.$row['uid'].'")');
122 $dragDropIcon = '<span id="dragIconID_'.$row['uid'].'" ondragstart="'.$spanOnDrag.'" onmousedown="'.$spanOnDrag.'" onmouseup="'.$spanOnDrop.'">'.$thePageIcon.'</span>';
123
124 // Add Page ID:
125 if ($this->ext_showPageId) {
126 $pageIdStr = '['.$row['uid'].']&nbsp;';
127 } else {
128 $pageIdStr = '';
129 }
130
131 return $dragDropIcon.$lockIcon.$pageIdStr;
132 }
133
134 /**
135 * Adds a red "+" to the input string, $str, if the field "php_tree_stop" in the $row (pages) is set
136 *
137 * @param string Input string, like a page title for the tree
138 * @param array record row with "php_tree_stop" field
139 * @return string Modified string
140 * @access private
141 */
142 function wrapStop($str,$row) {
143 if ($row['php_tree_stop']) {
144 $str.='<a href="'.htmlspecialchars(t3lib_div::linkThisScript(array('setTempDBmount' => $row['uid']))).'" class="typo3-red">+</a> ';
145 }
146 return $str;
147 }
148
149 /**
150 * Wrapping $title in a-tags.
151 *
152 * @param string Title string
153 * @param string Item record
154 * @param integer Bank pointer (which mount point number)
155 * @return string
156 * @access private
157 */
158 function wrapTitle($title,$row,$bank=0) {
159 $aOnClick = 'return jumpTo(\''.$this->getJumpToParam($row).'\',this,\''.$this->domIdPrefix.$this->getId($row).'\','.$bank.');';
160 $CSM = '';
161 if ($GLOBALS['TYPO3_CONF_VARS']['BE']['useOnContextMenuHandler']) {
162 $CSM = ' oncontextmenu="'.htmlspecialchars($GLOBALS['TBE_TEMPLATE']->wrapClickMenuOnIcon('','pages',$row['uid'],0,'&bank='.$this->bank,'',TRUE)).'"';
163 }
164 $thePageTitle='<a href="#" onclick="'.htmlspecialchars($aOnClick).'"'.$CSM.'>'.$title.'</a>';
165
166 // Wrap title in a drag/drop span.
167 $spanOnDrag = htmlspecialchars('return dragElement("'.$row['uid'].'")');
168 $spanOnDrop = htmlspecialchars('return dropElement("'.$row['uid'].'")');
169 $dragDropTitle = '<span id="dragTitleID_'.$row['uid'].'" ondragstart="'.$spanOnDrag.'" onmousedown="'.$spanOnDrag.'" onmouseup="'.$spanOnDrop.'">'.$thePageTitle.'</span>';
170 return $dragDropTitle;
171 }
172 }
173
174
175
176
177
178
179
180
181
182
183
184
185 /**
186 * Main script class for the page tree navigation frame
187 *
188 * @author Kasper Skaarhoj <kasperYYYY@typo3.com>
189 * @package TYPO3
190 * @subpackage core
191 */
192 class SC_alt_db_navframe {
193
194 // Internal:
195 var $content;
196 var $pagetree;
197 var $doc;
198 var $active_tempMountPoint = 0; // Temporary mount point (record), if any
199
200 // Internal, static: GPvar:
201 var $currentSubScript;
202 var $cMR;
203 var $setTempDBmount; // If not '' (blank) then it will clear (0) or set (>0) Temporary DB mount.
204
205 /**
206 * Initialiation of the class
207 *
208 * @return void
209 */
210 function init() {
211 global $BE_USER,$BACK_PATH;
212
213 // Setting GPvars:
214 $this->currentSubScript = t3lib_div::_GP('currentSubScript');
215 $this->cMR = t3lib_div::_GP('cMR');
216 $this->setTempDBmount = t3lib_div::_GP('setTempDBmount');
217
218 // Create page tree object:
219 $this->pagetree = t3lib_div::makeInstance('localPageTree');
220 $this->pagetree->ext_IconMode = $BE_USER->getTSConfigVal('options.pageTree.disableIconLinkToContextmenu');
221 $this->pagetree->ext_showPageId = $BE_USER->getTSConfigVal('options.pageTree.showPageIdWithTitle');
222 $this->pagetree->thisScript = 'alt_db_navframe.php';
223 $this->pagetree->addField('alias');
224 $this->pagetree->addField('shortcut');
225 $this->pagetree->addField('shortcut_mode');
226 $this->pagetree->addField('mount_pid');
227 $this->pagetree->addField('mount_pid_ol');
228 $this->pagetree->addField('nav_hide');
229 $this->pagetree->addField('url');
230
231 # $this->settingTemporaryMountPoint(11);
232 // Temporary DB mounts:
233 $this->initializeTemporaryDBmount();
234
235 // Setting highlight mode:
236 $this->doHighlight = !$BE_USER->getTSConfigVal('options.pageTree.disableTitleHighlight') && $BE_USER->workspace===0;
237
238 // Create template object:
239 $this->doc = t3lib_div::makeInstance('template');
240 $this->doc->docType='xhtml_trans';
241
242 // Setting backPath
243 $this->doc->backPath = $BACK_PATH;
244
245 // Setting JavaScript for menu.
246 $this->doc->JScode=$this->doc->wrapScriptTags(
247 ($this->currentSubScript?'top.currentSubScript=unescape("'.rawurlencode($this->currentSubScript).'");':'').'
248
249 // Function, loading the list frame from navigation tree:
250 function jumpTo(id,linkObj,highLightID,bank) { //
251 var theUrl = top.TS.PATH_typo3+top.currentSubScript+"?id="+id;
252 top.fsMod.currentBank = bank;
253
254 if (top.condensedMode) {
255 top.content.location.href=theUrl;
256 } else {
257 parent.list_frame.location.href=theUrl;
258 }
259
260 '.($this->doHighlight?'hilight_row("web",highLightID+"_"+bank);':'').'
261
262 '.(!$GLOBALS['CLIENT']['FORMSTYLE'] ? '' : 'if (linkObj) {linkObj.blur();}').'
263 return false;
264 }
265
266 // Call this function, refresh_nav(), from another script in the backend if you want to refresh the navigation frame (eg. after having changed a page title or moved pages etc.)
267 // See t3lib_BEfunc::getSetUpdateSignal()
268 function refresh_nav() { //
269 window.setTimeout("_refresh_nav();",0);
270 }
271 function _refresh_nav() { //
272 window.location.href="'.$this->pagetree->thisScript.'?unique='.time().'";
273 }
274
275 // Highlighting rows in the page tree:
276 function hilight_row(frameSetModule,highLightID) { //
277
278 // Remove old:
279 theObj = document.getElementById(top.fsMod.navFrameHighlightedID[frameSetModule]);
280 if (theObj) {
281 theObj.className = "";
282 }
283
284 // Set new:
285 top.fsMod.navFrameHighlightedID[frameSetModule] = highLightID;
286 theObj = document.getElementById(highLightID);
287 if (theObj) {
288 theObj.className = "navFrameHL";
289 }
290 }
291
292 '.($this->cMR?"jumpTo(top.fsMod.recentIds['web'],'');":'').';
293 ');
294
295 // Click menu code is added:
296 $CMparts=$this->doc->getContextMenuCode();
297 $this->doc->bodyTagAdditions = $CMparts[1];
298 $this->doc->JScode.= $CMparts[0];
299 $this->doc->postCode.= $CMparts[2];
300
301 // Drag and Drop code is added:
302 $DDparts=$this->doc->getDragDropCode('pages');
303 // ignore the $DDparts[1] for now
304 $this->doc->JScode.= $DDparts[0];
305 $this->doc->postCode.= $DDparts[2];
306 }
307
308 /**
309 * Main function, rendering the browsable page tree
310 *
311 * @return void
312 */
313 function main() {
314 global $LANG,$CLIENT;
315
316 // Produce browse-tree:
317 $tree = $this->pagetree->getBrowsableTree();
318
319 // Start page:
320 $this->content = '';
321 $this->content.= $this->doc->startPage('Page tree');
322
323 // Outputting workspace info
324 if ($GLOBALS['BE_USER']->workspace!==0 || $GLOBALS['BE_USER']->getTSConfigVal('options.pageTree.onlineWorkspaceInfo')) {
325 switch($GLOBALS['BE_USER']->workspace) {
326 case 0:
327 $wsTitle = '&nbsp;'.$this->doc->icons(2).'['.$LANG->sL('LLL:EXT:lang/locallang_misc.xml:shortcut_onlineWS',1).']';
328 break;
329 case -1:
330 $wsTitle = '['.$LANG->sL('LLL:EXT:lang/locallang_misc.xml:shortcut_offlineWS',1).']';
331 break;
332 default:
333 $wsTitle = '['.$GLOBALS['BE_USER']->workspace.'] '.htmlspecialchars($GLOBALS['BE_USER']->workspaceRec['title']);
334 break;
335 }
336
337 $this->content.= '
338 <div class="bgColor4 workspace-info">'.
339 '<a href="'.htmlspecialchars('mod/user/ws/index.php').'" target="content">'.
340 '<img'.t3lib_iconWorks::skinImg('','gfx/i/sys_workspace.png','width="18" height="16"').' align="top" alt="" />'.
341 '</a>'.$wsTitle.'
342 </div>
343 ';
344 }
345
346 // Outputting Temporary DB mount notice:
347 if ($this->active_tempMountPoint) {
348 $this->content.= '
349 <div class="bgColor4 c-notice">
350 <img'.t3lib_iconWorks::skinImg('','gfx/icon_note.gif','width="18" height="16"').' align="top" alt="" />'.
351 '<a href="'.htmlspecialchars(t3lib_div::linkThisScript(array('setTempDBmount' => 0))).'">'.
352 $LANG->sl('LLL:EXT:lang/locallang_core.php:labels.temporaryDBmount',1).
353 '</a><br/>
354 '.$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>
355 </div>
356 ';
357 }
358
359 // Outputting page tree:
360 $this->content.= $tree;
361
362 // Outputting refresh-link
363 $refreshUrl = t3lib_div::getIndpEnv('REQUEST_URI');
364 $this->content.= '
365 <p class="c-refresh">
366 <a href="'.htmlspecialchars($refreshUrl).'">'.
367 '<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="" />'.
368 '</a><a href="'.htmlspecialchars($refreshUrl).'">'.
369 $LANG->sL('LLL:EXT:lang/locallang_core.php:labels.refresh',1).'</a>
370 </p>
371 <br />';
372
373 // CSH icon:
374 $this->content.= t3lib_BEfunc::cshItem('xMOD_csh_corebe', 'pagetree', $GLOBALS['BACK_PATH']);
375
376 // Adding highlight - JavaScript
377 if ($this->doHighlight) $this->content .=$this->doc->wrapScriptTags('
378 hilight_row("",top.fsMod.navFrameHighlightedID["web"]);
379 ');
380 }
381
382 /**
383 * Outputting the accumulated content to screen
384 *
385 * @return void
386 */
387 function printContent() {
388 $this->content.= $this->doc->endPage();
389 $this->content = $this->doc->insertStylesAndJS($this->content);
390 echo $this->content;
391 }
392
393
394
395
396
397
398
399
400
401
402
403
404 /**********************************
405 *
406 * Temporary DB mounts
407 *
408 **********************************/
409
410 /**
411 * Getting temporary DB mount
412 *
413 * @return void
414 */
415 function initializeTemporaryDBmount(){
416 global $BE_USER;
417
418 // Set/Cancel Temporary DB Mount:
419 if (strlen($this->setTempDBmount)) {
420 $set = t3lib_div::intInRange($this->setTempDBmount,0);
421 if ($set>0 && $BE_USER->isInWebMount($set)) { // Setting...:
422 $this->settingTemporaryMountPoint($set);
423 } else { // Clear:
424 $this->settingTemporaryMountPoint(0);
425 }
426 }
427
428 // Getting temporary mount point ID:
429 $temporaryMountPoint = intval($BE_USER->getSessionData('pageTree_temporaryMountPoint'));
430
431 // If mount point ID existed and is within users real mount points, then set it temporarily:
432 if ($temporaryMountPoint > 0 && $BE_USER->isInWebMount($temporaryMountPoint)) {
433 if ($this->active_tempMountPoint = t3lib_BEfunc::readPageAccess($temporaryMountPoint, $BE_USER->getPagePermsClause(1))) {
434 $this->pagetree->MOUNTS = array($temporaryMountPoint);
435 }
436 else {
437 // Clear temporary mount point as we have no access to it any longer
438 $this->settingTemporaryMountPoint(0);
439 }
440 }
441 }
442
443 /**
444 * Setting temporary page id as DB mount
445 *
446 * @param integer The page id to set as DB mount
447 * @return void
448 */
449 function settingTemporaryMountPoint($pageId) {
450 global $BE_USER;
451
452 // Setting temporary mount point ID:
453 $BE_USER->setAndSaveSessionData('pageTree_temporaryMountPoint',intval($pageId));
454 }
455 }
456
457 // Include extension?
458 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/alt_db_navframe.php']) {
459 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/alt_db_navframe.php']);
460 }
461
462
463
464
465
466
467
468
469
470
471
472
473 // Make instance:
474 $SOBE = t3lib_div::makeInstance('SC_alt_db_navframe');
475 $SOBE->init();
476 $SOBE->main();
477 $SOBE->printContent();
478
479 ?>