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