Committed DBAL-related changes, see RFC mail from Dec 24th.
[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 * 137: function wrapStop($str,$row)
45 * 153: function wrapTitle($title,$row,$bank=0)
46 *
47 *
48 * 181: class SC_alt_db_navframe
49 * 199: function init()
50 * 295: function main()
51 * 346: function printContent()
52 *
53 * SECTION: Temporary DB mounts
54 * 373: function initializeTemporaryDBmount()
55 * 402: 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 // Add Page ID:
120 if ($this->ext_showPageId) {
121 $pageIdStr = '['.$row['uid'].']&nbsp;';
122 } else {
123 $pageIdStr = '';
124 }
125
126 return $thePageIcon.$lockIcon.$pageIdStr;
127 }
128
129 /**
130 * Adds a red "+" to the input string, $str, if the field "php_tree_stop" in the $row (pages) is set
131 *
132 * @param string Input string, like a page title for the tree
133 * @param array record row with "php_tree_stop" field
134 * @return string Modified string
135 * @access private
136 */
137 function wrapStop($str,$row) {
138 if ($row['php_tree_stop']) {
139 $str.='<a href="'.htmlspecialchars(t3lib_div::linkThisScript(array('setTempDBmount' => $row['uid']))).'" class="typo3-red">+</a> ';
140 }
141 return $str;
142 }
143
144 /**
145 * Wrapping $title in a-tags.
146 *
147 * @param string Title string
148 * @param string Item record
149 * @param integer Bank pointer (which mount point number)
150 * @return string
151 * @access private
152 */
153 function wrapTitle($title,$row,$bank=0) {
154 $aOnClick = 'return jumpTo(\''.$this->getJumpToParam($row).'\',this,\''.$this->domIdPrefix.$this->getId($row).'_'.$bank.'\');';
155 $CSM = '';
156 if ($GLOBALS['TYPO3_CONF_VARS']['BE']['useOnContextMenuHandler']) {
157 $CSM = ' oncontextmenu="'.htmlspecialchars($GLOBALS['TBE_TEMPLATE']->wrapClickMenuOnIcon('','pages',$row['uid'],0,'&bank='.$this->bank,'',TRUE)).'"';
158 }
159 return '<a href="#" onclick="'.htmlspecialchars($aOnClick).'"'.$CSM.'>'.$title.'</a>';
160 }
161 }
162
163
164
165
166
167
168
169
170
171
172
173
174 /**
175 * Main script class for the page tree navigation frame
176 *
177 * @author Kasper Skaarhoj <kasperYYYY@typo3.com>
178 * @package TYPO3
179 * @subpackage core
180 */
181 class SC_alt_db_navframe {
182
183 // Internal:
184 var $content;
185 var $pagetree;
186 var $doc;
187 var $active_tempMountPoint = 0; // Temporary mount point (record), if any
188
189 // Internal, static: GPvar:
190 var $currentSubScript;
191 var $cMR;
192 var $setTempDBmount; // If not '' (blank) then it will clear (0) or set (>0) Temporary DB mount.
193
194 /**
195 * Initialiation of the class
196 *
197 * @return void
198 */
199 function init() {
200 global $BE_USER,$BACK_PATH;
201
202 // Setting GPvars:
203 $this->currentSubScript = t3lib_div::_GP('currentSubScript');
204 $this->cMR = t3lib_div::_GP('cMR');
205 $this->setTempDBmount = t3lib_div::_GP('setTempDBmount');
206
207 // Create page tree object:
208 $this->pagetree = t3lib_div::makeInstance('localPageTree');
209 $this->pagetree->ext_IconMode = $BE_USER->getTSConfigVal('options.pageTree.disableIconLinkToContextmenu');
210 $this->pagetree->ext_showPageId = $BE_USER->getTSConfigVal('options.pageTree.showPageIdWithTitle');
211 $this->pagetree->thisScript = 'alt_db_navframe.php';
212 $this->pagetree->addField('alias');
213 $this->pagetree->addField('shortcut');
214 $this->pagetree->addField('shortcut_mode');
215 $this->pagetree->addField('mount_pid');
216 $this->pagetree->addField('mount_pid_ol');
217 $this->pagetree->addField('nav_hide');
218 $this->pagetree->addField('url');
219
220 # $this->settingTemporaryMountPoint(11);
221 // Temporary DB mounts:
222 $this->initializeTemporaryDBmount();
223
224 // Setting highlight mode:
225 $this->doHighlight = !$BE_USER->getTSConfigVal('options.pageTree.disableTitleHighlight') && $BE_USER->workspace===0;
226
227 // Create template object:
228 $this->doc = t3lib_div::makeInstance('template');
229 $this->doc->docType='xhtml_trans';
230
231 // Setting backPath
232 $this->doc->backPath = $BACK_PATH;
233
234 // Setting JavaScript for menu.
235 $this->doc->JScode=$this->doc->wrapScriptTags(
236 ($this->currentSubScript?'top.currentSubScript=unescape("'.rawurlencode($this->currentSubScript).'");':'').'
237
238 // Function, loading the list frame from navigation tree:
239 function jumpTo(id,linkObj,highLightID) { //
240 var theUrl = top.TS.PATH_typo3+top.currentSubScript+"?id="+id;
241
242 if (top.condensedMode) {
243 top.content.document.location=theUrl;
244 } else {
245 parent.list_frame.document.location=theUrl;
246 }
247
248 '.($this->doHighlight?'hilight_row("web",highLightID);':'').'
249
250 '.(!$GLOBALS['CLIENT']['FORMSTYLE'] ? '' : 'if (linkObj) {linkObj.blur();}').'
251 return false;
252 }
253
254 // 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.)
255 // See t3lib_BEfunc::getSetUpdateSignal()
256 function refresh_nav() { //
257 window.setTimeout("_refresh_nav();",0);
258 }
259 function _refresh_nav() { //
260 document.location="'.$this->pagetree->thisScript.'?unique='.time().'";
261 }
262
263 // Highlighting rows in the page tree:
264 function hilight_row(frameSetModule,highLightID) { //
265
266 // Remove old:
267 theObj = document.getElementById(top.fsMod.navFrameHighlightedID[frameSetModule]);
268 if (theObj) {
269 theObj.style.backgroundColor="";
270 }
271
272 // Set new:
273 top.fsMod.navFrameHighlightedID[frameSetModule] = highLightID;
274 theObj = document.getElementById(highLightID);
275 if (theObj) {
276 theObj.style.backgroundColor="'.t3lib_div::modifyHTMLColorAll($this->doc->bgColor,-20).'";
277 }
278 }
279
280 '.($this->cMR?"jumpTo(top.fsMod.recentIds['web'],'');":'').';
281 ');
282
283 // Click menu code is added:
284 $CMparts=$this->doc->getContextMenuCode();
285 $this->doc->bodyTagAdditions = $CMparts[1];
286 $this->doc->JScode.= $CMparts[0];
287 $this->doc->postCode.= $CMparts[2];
288 }
289
290 /**
291 * Main function, rendering the browsable page tree
292 *
293 * @return void
294 */
295 function main() {
296 global $LANG,$CLIENT;
297
298 // Produce browse-tree:
299 $tree = $this->pagetree->getBrowsableTree();
300
301 // Start page:
302 $this->content = '';
303 $this->content.= $this->doc->startPage('Page tree');
304
305 // Outputting workspace info
306 if ($GLOBALS['BE_USER']->workspace!==0 || $GLOBALS['BE_USER']->getTSConfigVal('options.pageTree.onlineWorkspaceInfo')) {
307 switch($GLOBALS['BE_USER']->workspace) {
308 case 0:
309 $wsTitle = '&nbsp;'.$this->doc->icons(2).'['.$LANG->sL('LLL:EXT:lang/locallang_misc.xml:shortcut_onlineWS',1).']';
310 break;
311 case -1:
312 $wsTitle = '['.$LANG->sL('LLL:EXT:lang/locallang_misc.xml:shortcut_offlineWS',1).']';
313 break;
314 default:
315 $wsTitle = '['.$GLOBALS['BE_USER']->workspace.'] '.htmlspecialchars($GLOBALS['BE_USER']->workspaceRec['title']);
316 break;
317 }
318
319 $this->content.= '
320 <div class="bgColor4 workspace-info">'.
321 '<a href="'.htmlspecialchars('mod/user/ws/index.php').'" target="content">'.
322 '<img'.t3lib_iconWorks::skinImg('','gfx/i/sys_workspace.png','width="18" height="16"').' align="top" alt="" />'.
323 '</a>'.$wsTitle.'
324 </div>
325 ';
326 }
327
328 // Outputting Temporary DB mount notice:
329 if ($this->active_tempMountPoint) {
330 $this->content.= '
331 <div class="bgColor4 c-notice">
332 <img'.t3lib_iconWorks::skinImg('','gfx/icon_note.gif','width="18" height="16"').' align="top" alt="" />'.
333 '<a href="'.htmlspecialchars(t3lib_div::linkThisScript(array('setTempDBmount' => 0))).'">'.
334 $LANG->sl('LLL:EXT:lang/locallang_core.php:labels.temporaryDBmount',1).
335 '</a><br/>
336 '.$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>
337 </div>
338 ';
339 }
340
341 // Outputting page tree:
342 $this->content.= $tree;
343
344 // Outputting refresh-link
345 $refreshUrl = t3lib_div::getIndpEnv('REQUEST_URI');
346 $this->content.= '
347 <p class="c-refresh">
348 <a href="'.htmlspecialchars($refreshUrl).'">'.
349 '<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="" />'.
350 '</a><a href="'.htmlspecialchars($refreshUrl).'">'.
351 $LANG->sL('LLL:EXT:lang/locallang_core.php:labels.refresh',1).'</a>
352 </p>
353 <br />';
354
355 // CSH icon:
356 $this->content.= t3lib_BEfunc::cshItem('xMOD_csh_corebe', 'pagetree', $GLOBALS['BACK_PATH']);
357
358 // Adding highlight - JavaScript
359 if ($this->doHighlight) $this->content .=$this->doc->wrapScriptTags('
360 hilight_row("",top.fsMod.navFrameHighlightedID["web"]);
361 ');
362 }
363
364 /**
365 * Outputting the accumulated content to screen
366 *
367 * @return void
368 */
369 function printContent() {
370 $this->content.= $this->doc->endPage();
371 echo $this->content;
372 }
373
374
375
376
377
378
379
380
381
382
383
384
385 /**********************************
386 *
387 * Temporary DB mounts
388 *
389 **********************************/
390
391 /**
392 * Getting temporary DB mount
393 *
394 * @return void
395 */
396 function initializeTemporaryDBmount(){
397 global $BE_USER;
398
399 // Set/Cancel Temporary DB Mount:
400 if (strlen($this->setTempDBmount)) {
401 $set = t3lib_div::intInRange($this->setTempDBmount,0);
402 if ($set>0 && $BE_USER->isInWebMount($set)) { // Setting...:
403 $this->settingTemporaryMountPoint($set);
404 } else { // Clear:
405 $this->settingTemporaryMountPoint(0);
406 }
407 }
408
409 // Getting temporary mount point ID:
410 $temporaryMountPoint = intval($BE_USER->getSessionData('pageTree_temporaryMountPoint'));
411
412 // If mount point ID existed and is within users real mount points, then set it temporarily:
413 if ($temporaryMountPoint > 0 && $BE_USER->isInWebMount($temporaryMountPoint)) {
414 $this->pagetree->MOUNTS = array($temporaryMountPoint);
415 $this->active_tempMountPoint = t3lib_BEfunc::readPageAccess($temporaryMountPoint, $BE_USER->getPagePermsClause(1));
416 }
417 }
418
419 /**
420 * Setting temporary page id as DB mount
421 *
422 * @param integer The page id to set as DB mount
423 * @return void
424 */
425 function settingTemporaryMountPoint($pageId) {
426 global $BE_USER;
427
428 // Setting temporary mount point ID:
429 $BE_USER->setAndSaveSessionData('pageTree_temporaryMountPoint',intval($pageId));
430 }
431 }
432
433 // Include extension?
434 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/alt_db_navframe.php']) {
435 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/alt_db_navframe.php']);
436 }
437
438
439
440
441
442
443
444
445
446
447
448
449 // Make instance:
450 $SOBE = t3lib_div::makeInstance('SC_alt_db_navframe');
451 $SOBE->init();
452 $SOBE->main();
453 $SOBE->printContent();
454
455 ?>