a8c226a9ac40672d9d842db1d3e361a804333092
[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);
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
125
126
127
128
129
130
131
132
133
134
135 /**
136 * Main script class for the page tree navigation frame
137 *
138 * @author Kasper Skaarhoj <kasper@typo3.com>
139 * @package TYPO3
140 * @subpackage core
141 */
142 class SC_alt_db_navframe {
143
144 // Internal:
145 var $content;
146 var $pagetree;
147 var $doc;
148 var $active_tempMountPoint = 0; // Temporary mount point (record), if any
149
150 // Internal, static: GPvar:
151 var $currentSubScript;
152 var $cMR;
153 var $setTempDBmount; // If not '' (blank) then it will clear (0) or set (>0) Temporary DB mount.
154
155 /**
156 * Initialiation of the class
157 *
158 * @return void
159 */
160 function init() {
161 global $BE_USER,$BACK_PATH;
162
163 // Setting GPvars:
164 $this->currentSubScript = t3lib_div::_GP('currentSubScript');
165 $this->cMR = t3lib_div::_GP('cMR');
166 $this->setTempDBmount = t3lib_div::_GP('setTempDBmount');
167
168 // Create page tree object:
169 $this->pagetree = t3lib_div::makeInstance('localPageTree');
170 $this->pagetree->ext_IconMode = $BE_USER->getTSConfigVal('options.pageTree.disableIconLinkToContextmenu');
171 $this->pagetree->ext_showPageId = $BE_USER->getTSConfigVal('options.pageTree.showPageIdWithTitle');
172 $this->pagetree->thisScript = 'alt_db_navframe.php';
173 $this->pagetree->addField('alias');
174 $this->pagetree->addField('shortcut');
175 $this->pagetree->addField('shortcut_mode');
176 $this->pagetree->addField('mount_pid');
177 $this->pagetree->addField('mount_pid_ol');
178 $this->pagetree->addField('nav_hide');
179 $this->pagetree->addField('url');
180
181 # $this->settingTemporaryMountPoint(11);
182 // Temporary DB mounts:
183 $this->initializeTemporaryDBmount();
184
185 // Setting highlight mode:
186 $this->doHighlight = !$BE_USER->getTSConfigVal('options.pageTree.disableTitleHighlight');
187
188 // Create template object:
189 $this->doc = t3lib_div::makeInstance('template');
190 $this->doc->docType='xhtml_trans';
191
192 // Setting backPath
193 $this->doc->backPath = $BACK_PATH;
194
195 // Setting JavaScript for menu.
196 $this->doc->JScode=$this->doc->wrapScriptTags(
197 ($this->currentSubScript?'top.currentSubScript=unescape("'.rawurlencode($this->currentSubScript).'");':'').'
198
199 // Function, loading the list frame from navigation tree:
200 function jumpTo(id,linkObj,highLightID) { //
201 var theUrl = top.TS.PATH_typo3+top.currentSubScript+"?id="+id;
202
203 if (top.condensedMode) {
204 top.content.document.location=theUrl;
205 } else {
206 parent.list_frame.document.location=theUrl;
207 }
208
209 '.($this->doHighlight?'hilight_row("web",highLightID);':'').'
210
211 '.(!$GLOBALS['CLIENT']['FORMSTYLE'] ? '' : 'if (linkObj) {linkObj.blur();}').'
212 return false;
213 }
214
215 // 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.)
216 // See t3lib_BEfunc::getSetUpdateSignal()
217 function refresh_nav() { //
218 window.setTimeout("_refresh_nav();",0);
219 }
220 function _refresh_nav() { //
221 document.location="'.$this->pagetree->thisScript.'?unique='.time().'";
222 }
223
224 // Highlighting rows in the page tree:
225 function hilight_row(frameSetModule,highLightID) { //
226
227 // Remove old:
228 theObj = document.getElementById(top.fsMod.navFrameHighlightedID[frameSetModule]);
229 if (theObj) {
230 theObj.style.backgroundColor="";
231 }
232
233 // Set new:
234 top.fsMod.navFrameHighlightedID[frameSetModule] = highLightID;
235 theObj = document.getElementById(highLightID);
236 if (theObj) {
237 theObj.style.backgroundColor="'.t3lib_div::modifyHTMLColorAll($this->doc->bgColor,-20).'";
238 }
239 }
240
241 '.($this->cMR?"jumpTo(top.fsMod.recentIds['web'],'');":'').';
242 ');
243
244 // Click menu code is added:
245 $CMparts=$this->doc->getContextMenuCode();
246 $this->doc->bodyTagAdditions = $CMparts[1];
247 $this->doc->JScode.= $CMparts[0];
248 $this->doc->postCode.= $CMparts[2];
249 }
250
251 /**
252 * Main function, rendering the browsable page tree
253 *
254 * @return void
255 */
256 function main() {
257 global $LANG,$CLIENT;
258
259 // Produce browse-tree:
260 $tree = $this->pagetree->getBrowsableTree();
261
262 // Start page:
263 $this->content = '';
264 $this->content.= $this->doc->startPage('Page tree');
265
266 // Outputting Temporary DB mount notice:
267 if ($this->active_tempMountPoint) {
268 $this->content.= '
269 <div class="bgColor4 c-notice">
270 <img'.t3lib_iconWorks::skinImg('','gfx/icon_note.gif','width="18" height="16"').' align="top" alt="" />'.
271 '<a href="'.htmlspecialchars(t3lib_div::linkThisScript(array('setTempDBmount' => 0))).'">'.
272 $LANG->sl('LLL:EXT:lang/locallang_core.php:labels.temporaryDBmount',1).
273 '</a><br/>
274 '.$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>
275 </div>
276 ';
277 }
278
279 // Outputting page tree:
280 $this->content.= $tree;
281
282 // Outputting refresh-link
283 $refreshUrl = t3lib_div::getIndpEnv('REQUEST_URI');
284 $this->content.= '
285 <p class="c-refresh">
286 <a href="'.htmlspecialchars($refreshUrl).'">'.
287 '<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="" />'.
288 '</a><a href="'.htmlspecialchars($refreshUrl).'">'.
289 $LANG->sL('LLL:EXT:lang/locallang_core.php:labels.refresh',1).'</a>
290 </p>
291 <br />';
292
293 // CSH icon:
294 $this->content.= t3lib_BEfunc::cshItem('xMOD_csh_corebe', 'pagetree', $GLOBALS['BACK_PATH']);
295
296 // Adding highlight - JavaScript
297 if ($this->doHighlight) $this->content .=$this->doc->wrapScriptTags('
298 hilight_row("",top.fsMod.navFrameHighlightedID["web"]);
299 ');
300 }
301
302 /**
303 * Outputting the accumulated content to screen
304 *
305 * @return void
306 */
307 function printContent() {
308 $this->content.= $this->doc->endPage();
309 echo $this->content;
310 }
311
312
313
314
315
316
317
318
319
320
321
322
323 /**********************************
324 *
325 * Temporary DB mounts
326 *
327 **********************************/
328
329 /**
330 * Getting temporary DB mount
331 */
332 function initializeTemporaryDBmount(){
333 global $BE_USER;
334
335 // Set/Cancel Temporary DB Mount:
336 if (strlen($this->setTempDBmount)) {
337 $set = t3lib_div::intInRange($this->setTempDBmount,0);
338 if ($set>0 && $BE_USER->isInWebMount($set)) { // Setting...:
339 $this->settingTemporaryMountPoint($set);
340 } else { // Clear:
341 $this->settingTemporaryMountPoint(0);
342 }
343 }
344
345 // Getting temporary mount point ID:
346 $temporaryMountPoint = intval($BE_USER->getSessionData('pageTree_temporaryMountPoint'));
347
348 // If mount point ID existed and is within users real mount points, then set it temporarily:
349 if ($temporaryMountPoint > 0 && $BE_USER->isInWebMount($temporaryMountPoint)) {
350 $this->pagetree->MOUNTS = array($temporaryMountPoint);
351 $this->active_tempMountPoint = t3lib_BEfunc::readPageAccess($temporaryMountPoint, $BE_USER->getPagePermsClause(1));
352 }
353 }
354
355 /**
356 * Setting temporary page id as DB mount
357 */
358 function settingTemporaryMountPoint($pageId) {
359 global $BE_USER;
360
361 // Setting temporary mount point ID:
362 $BE_USER->setAndSaveSessionData('pageTree_temporaryMountPoint',intval($pageId));
363 }
364 }
365
366 // Include extension?
367 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/alt_db_navframe.php']) {
368 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/alt_db_navframe.php']);
369 }
370
371
372
373
374
375
376
377
378
379
380
381
382 // Make instance:
383 $SOBE = t3lib_div::makeInstance('SC_alt_db_navframe');
384 $SOBE->init();
385 $SOBE->main();
386 $SOBE->printContent();
387
388 ?>