* Minor change to spamProtectEmailAddresses ASCII
[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');
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 Temporary DB mount notice:
306 if ($this->active_tempMountPoint) {
307 $this->content.= '
308 <div class="bgColor4 c-notice">
309 <img'.t3lib_iconWorks::skinImg('','gfx/icon_note.gif','width="18" height="16"').' align="top" alt="" />'.
310 '<a href="'.htmlspecialchars(t3lib_div::linkThisScript(array('setTempDBmount' => 0))).'">'.
311 $LANG->sl('LLL:EXT:lang/locallang_core.php:labels.temporaryDBmount',1).
312 '</a><br/>
313 '.$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>
314 </div>
315 ';
316 }
317
318 // Outputting page tree:
319 $this->content.= $tree;
320
321 // Outputting refresh-link
322 $refreshUrl = t3lib_div::getIndpEnv('REQUEST_URI');
323 $this->content.= '
324 <p class="c-refresh">
325 <a href="'.htmlspecialchars($refreshUrl).'">'.
326 '<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="" />'.
327 '</a><a href="'.htmlspecialchars($refreshUrl).'">'.
328 $LANG->sL('LLL:EXT:lang/locallang_core.php:labels.refresh',1).'</a>
329 </p>
330 <br />';
331
332 // CSH icon:
333 $this->content.= t3lib_BEfunc::cshItem('xMOD_csh_corebe', 'pagetree', $GLOBALS['BACK_PATH']);
334
335 // Adding highlight - JavaScript
336 if ($this->doHighlight) $this->content .=$this->doc->wrapScriptTags('
337 hilight_row("",top.fsMod.navFrameHighlightedID["web"]);
338 ');
339 }
340
341 /**
342 * Outputting the accumulated content to screen
343 *
344 * @return void
345 */
346 function printContent() {
347 $this->content.= $this->doc->endPage();
348 echo $this->content;
349 }
350
351
352
353
354
355
356
357
358
359
360
361
362 /**********************************
363 *
364 * Temporary DB mounts
365 *
366 **********************************/
367
368 /**
369 * Getting temporary DB mount
370 *
371 * @return void
372 */
373 function initializeTemporaryDBmount(){
374 global $BE_USER;
375
376 // Set/Cancel Temporary DB Mount:
377 if (strlen($this->setTempDBmount)) {
378 $set = t3lib_div::intInRange($this->setTempDBmount,0);
379 if ($set>0 && $BE_USER->isInWebMount($set)) { // Setting...:
380 $this->settingTemporaryMountPoint($set);
381 } else { // Clear:
382 $this->settingTemporaryMountPoint(0);
383 }
384 }
385
386 // Getting temporary mount point ID:
387 $temporaryMountPoint = intval($BE_USER->getSessionData('pageTree_temporaryMountPoint'));
388
389 // If mount point ID existed and is within users real mount points, then set it temporarily:
390 if ($temporaryMountPoint > 0 && $BE_USER->isInWebMount($temporaryMountPoint)) {
391 $this->pagetree->MOUNTS = array($temporaryMountPoint);
392 $this->active_tempMountPoint = t3lib_BEfunc::readPageAccess($temporaryMountPoint, $BE_USER->getPagePermsClause(1));
393 }
394 }
395
396 /**
397 * Setting temporary page id as DB mount
398 *
399 * @param integer The page id to set as DB mount
400 * @return void
401 */
402 function settingTemporaryMountPoint($pageId) {
403 global $BE_USER;
404
405 // Setting temporary mount point ID:
406 $BE_USER->setAndSaveSessionData('pageTree_temporaryMountPoint',intval($pageId));
407 }
408 }
409
410 // Include extension?
411 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/alt_db_navframe.php']) {
412 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/alt_db_navframe.php']);
413 }
414
415
416
417
418
419
420
421
422
423
424
425
426 // Make instance:
427 $SOBE = t3lib_div::makeInstance('SC_alt_db_navframe');
428 $SOBE->init();
429 $SOBE->main();
430 $SOBE->printContent();
431
432 ?>