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