added feature: make the page tree filter pretty, credits Bennjamin Mack
[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 * 192: class SC_alt_db_navframe
41 * 210: function init()
42 * 313: function main()
43 * 387: function printContent()
44 *
45 * SECTION: Temporary DB mounts
46 * 415: function initializeTemporaryDBmount()
47 * 449: function settingTemporaryMountPoint($pageId)
48 *
49 * TOTAL FUNCTIONS: 9
50 * (This index is automatically created/updated by the extension "extdeveval")
51 *
52 */
53
54
55 $BACK_PATH = '';
56 require_once('init.php');
57 require('template.php');
58 require_once('class.webpagetree.php');
59
60
61 /**
62 * Main script class for the page tree navigation frame
63 *
64 * @author Kasper Skaarhoj <kasperYYYY@typo3.com>
65 * @package TYPO3
66 * @subpackage core
67 */
68 class SC_alt_db_navframe {
69
70 // Internal:
71 var $content;
72 var $pagetree;
73
74 /**
75 * document template object
76 *
77 * @var template
78 */
79 var $doc;
80 var $active_tempMountPoint = 0; // Temporary mount point (record), if any
81 var $backPath;
82
83 // Internal, static: GPvar:
84 var $currentSubScript;
85 var $cMR;
86 var $setTempDBmount; // If not '' (blank) then it will clear (0) or set (>0) Temporary DB mount.
87
88
89 /**
90 * Initialiation of the class
91 *
92 * @return void
93 */
94 function init() {
95 global $BE_USER,$BACK_PATH;
96
97 // Setting backPath
98 $this->backPath = $BACK_PATH;
99
100 // Setting GPvars:
101 $this->cMR = t3lib_div::_GP('cMR');
102 $this->currentSubScript = t3lib_div::_GP('currentSubScript');
103 $this->setTempDBmount = t3lib_div::_GP('setTempDBmount');
104
105 // Create page tree object:
106 $this->pagetree = t3lib_div::makeInstance('webPageTree');
107 $this->pagetree->ext_IconMode = $BE_USER->getTSConfigVal('options.pageTree.disableIconLinkToContextmenu');
108 $this->pagetree->ext_showPageId = $BE_USER->getTSConfigVal('options.pageTree.showPageIdWithTitle');
109 $this->pagetree->ext_showNavTitle = $BE_USER->getTSConfigVal('options.pageTree.showNavTitle');
110 $this->pagetree->ext_separateNotinmenuPages = $BE_USER->getTSConfigVal('options.pageTree.separateNotinmenuPages');
111 $this->pagetree->ext_alphasortNotinmenuPages = $BE_USER->getTSConfigVal('options.pageTree.alphasortNotinmenuPages');
112 $this->pagetree->thisScript = 'alt_db_navframe.php';
113 $this->pagetree->addField('alias');
114 $this->pagetree->addField('shortcut');
115 $this->pagetree->addField('shortcut_mode');
116 $this->pagetree->addField('mount_pid');
117 $this->pagetree->addField('mount_pid_ol');
118 $this->pagetree->addField('nav_hide');
119 $this->pagetree->addField('nav_title');
120 $this->pagetree->addField('url');
121
122 // Temporary DB mounts:
123 $this->initializeTemporaryDBmount();
124 }
125
126
127 /**
128 * initialization for the visual parts of the class
129 * Use template rendering only if this is a non-AJAX call
130 *
131 * @return void
132 */
133 public function initPage() {
134 global $BE_USER;
135
136 // Setting highlight mode:
137 $this->doHighlight = !$BE_USER->getTSConfigVal('options.pageTree.disableTitleHighlight');
138
139 // If highlighting is active, define the CSS class for the active item depending on the workspace
140 if ($this->doHighlight) {
141 $hlClass = ($BE_USER->workspace === 0 ? 'active' : 'active active-ws wsver'.$BE_USER->workspace);
142 }
143
144 // Create template object:
145 $this->doc = t3lib_div::makeInstance('template');
146 $this->doc->backPath = $BACK_PATH;
147 $this->doc->docType = 'xhtml_trans';
148
149
150 // Adding javascript code for AJAX (prototype), drag&drop and the pagetree as well as the click menu code
151 $this->doc->getDragDropCode('pages');
152 $this->doc->getContextMenuCode();
153
154
155 $this->doc->JScode .= $this->doc->wrapScriptTags(
156 ($this->currentSubScript?'top.currentSubScript=unescape("'.rawurlencode($this->currentSubScript).'");':'').'
157 // setting prefs for pagetree and drag & drop
158 '.($this->doHighlight ? 'Tree.highlightClass = "'.$hlClass.'";' : '').'
159
160 // Function, loading the list frame from navigation tree:
161 function jumpTo(id, linkObj, highlightID, bank) { //
162 var theUrl = top.TS.PATH_typo3 + top.currentSubScript + "?id=" + id;
163 top.fsMod.currentBank = bank;
164
165 if (top.condensedMode) top.content.location.href = theUrl;
166 else parent.list_frame.location.href=theUrl;
167
168 '.($this->doHighlight ? 'Tree.highlightActiveItem("web", highlightID + "_" + bank);' : '').'
169 '.(!$GLOBALS['CLIENT']['FORMSTYLE'] ? '' : 'if (linkObj) linkObj.blur(); ').'
170 return false;
171 }
172 '.($this->cMR?"jumpTo(top.fsMod.recentIds['web'],'');":'').'
173
174 Event.observe(window, "load", function() {
175 Event.observe(PageTreeFilter.field, "keyup", PageTreeFilter.filter.bindAsEventListener(PageTreeFilter));
176 Event.observe(PageTreeFilter.resetfield, "click", PageTreeFilter.resetSearchField.bindAsEventListener(PageTreeFilter) );
177 });
178
179 ');
180
181 $this->doc->bodyTagId = 'typo3-pagetree';
182 }
183
184
185 /**
186 * Main function, rendering the browsable page tree
187 *
188 * @return void
189 */
190 function main() {
191 global $LANG,$CLIENT;
192
193 // Produce browse-tree:
194 $tree = $this->pagetree->getBrowsableTree();
195
196 // Start page:
197 $this->content = $this->doc->startPage('TYPO3 Page Tree');
198
199 // Outputting workspace info
200 if ($GLOBALS['BE_USER']->workspace!==0 || $GLOBALS['BE_USER']->getTSConfigVal('options.pageTree.onlineWorkspaceInfo')) {
201 switch($GLOBALS['BE_USER']->workspace) {
202 case 0:
203 $wsTitle = '&nbsp;'.$this->doc->icons(2).'['.$LANG->sL('LLL:EXT:lang/locallang_misc.xml:shortcut_onlineWS',1).']';
204 break;
205 case -1:
206 $wsTitle = '['.$LANG->sL('LLL:EXT:lang/locallang_misc.xml:shortcut_offlineWS',1).']';
207 break;
208 default:
209 $wsTitle = '['.$GLOBALS['BE_USER']->workspace.'] '.htmlspecialchars($GLOBALS['BE_USER']->workspaceRec['title']);
210 break;
211 }
212
213 $this->content.= '
214 <div class="bgColor4 workspace-info">'.
215 '<a href="'.htmlspecialchars('mod/user/ws/index.php').'" target="content">'.
216 '<img'.t3lib_iconWorks::skinImg('','gfx/i/sys_workspace.png','width="18" height="16"').' align="top" alt="" />'.
217 '</a>'.$wsTitle.'
218 </div>
219 ';
220 }
221
222 // adding tree options
223 $this->content .= '
224 <div id="treeOptions">';
225 if (!$GLOBALS['BE_USER']->getTSConfigVal('options.pageTree.hideFilter')) {
226 $this->content .= '
227 <div id="treeFilterBox">
228 <input type="text" value="" name="treeFilter" id="treeFilter" />
229 <img'.t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'], 'gfx/search_reset.png', ' width="11" height="11"').' id="treeFilterReset" alt="Reset Filter" />
230 </div>';
231
232 }
233
234 $this->content .= '
235 <div id="treeOptionButtons">
236 <a href="'.htmlspecialchars(t3lib_div::getIndpEnv('REQUEST_URI')).'"><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="" /></a>'.
237 // CSH icon:
238 t3lib_BEfunc::cshItem('xMOD_csh_corebe', 'pagetree', $GLOBALS['BACK_PATH']).'
239 </div>
240 </div>';
241
242
243 // Outputting Temporary DB mount notice:
244 if ($this->active_tempMountPoint) {
245 $this->content.= '
246 <div class="bgColor4 c-notice">
247 <img'.t3lib_iconWorks::skinImg('','gfx/icon_note.gif','width="18" height="16"').' align="top" alt="" />'.
248 '<a href="'.htmlspecialchars(t3lib_div::linkThisScript(array('setTempDBmount' => 0))).'">'.
249 $LANG->sl('LLL:EXT:lang/locallang_core.php:labels.temporaryDBmount',1).
250 '</a><br/>
251 '.$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>
252 </div>
253 ';
254 }
255
256
257 // Outputting page tree:
258 $this->content .= $tree;
259
260 // Adding javascript for drag & drop activation and highlighting
261 $this->content .= $this->doc->wrapScriptTags('
262 '.($this->doHighlight ? 'Tree.highlightActiveItem("",top.fsMod.navFrameHighlightedID["web"]);' : '').'
263 '.(!$this->doc->isCMlayers() ? 'Tree.activateDragDrop = false;' : 'Tree.registerDragDropHandlers();')
264 );
265 }
266
267 /**
268 * Outputting the accumulated content to screen
269 *
270 * @return void
271 */
272 function printContent() {
273 $this->content.= $this->doc->endPage();
274 $this->content = $this->doc->insertStylesAndJS($this->content);
275 echo $this->content;
276 }
277
278
279
280
281
282 /**********************************
283 *
284 * Temporary DB mounts
285 *
286 **********************************/
287
288 /**
289 * Getting temporary DB mount
290 *
291 * @return void
292 */
293 function initializeTemporaryDBmount(){
294 global $BE_USER;
295
296 // Set/Cancel Temporary DB Mount:
297 if (strlen($this->setTempDBmount)) {
298 $set = t3lib_div::intInRange($this->setTempDBmount,0);
299 if ($set>0 && $BE_USER->isInWebMount($set)) { // Setting...:
300 $this->settingTemporaryMountPoint($set);
301 } else { // Clear:
302 $this->settingTemporaryMountPoint(0);
303 }
304 }
305
306 // Getting temporary mount point ID:
307 $temporaryMountPoint = intval($BE_USER->getSessionData('pageTree_temporaryMountPoint'));
308
309 // If mount point ID existed and is within users real mount points, then set it temporarily:
310 if ($temporaryMountPoint > 0 && $BE_USER->isInWebMount($temporaryMountPoint)) {
311 if ($this->active_tempMountPoint = t3lib_BEfunc::readPageAccess($temporaryMountPoint, $BE_USER->getPagePermsClause(1))) {
312 $this->pagetree->MOUNTS = array($temporaryMountPoint);
313 }
314 else {
315 // Clear temporary mount point as we have no access to it any longer
316 $this->settingTemporaryMountPoint(0);
317 }
318 }
319 }
320
321
322 /**
323 * Setting temporary page id as DB mount
324 *
325 * @param integer The page id to set as DB mount
326 * @return void
327 */
328 function settingTemporaryMountPoint($pageId) {
329 $GLOBALS['BE_USER']->setAndSaveSessionData('pageTree_temporaryMountPoint',intval($pageId));
330 }
331
332
333 /**********************************
334 *
335 * AJAX Calls
336 *
337 **********************************/
338
339 /**
340 * Makes the AJAX call to expand or collapse the pagetree.
341 * Called by typo3/ajax.php
342 *
343 * @param array $params: additional parameters (not used here)
344 * @param TYPO3AJAX &$ajaxObj: reference of the TYPO3AJAX object of this request
345 * @return void
346 */
347 public function ajaxExpandCollapse($params, &$ajaxObj) {
348 global $LANG;
349
350 $this->init();
351 $tree = $this->pagetree->getBrowsableTree();
352 if (!$this->pagetree->ajaxStatus) {
353 $ajaxObj->setError($tree);
354 } else {
355 $ajaxObj->addContent('tree', $tree);
356 }
357 }
358 }
359
360
361 // Include extension?
362 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/alt_db_navframe.php']) {
363 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/alt_db_navframe.php']);
364 }
365
366
367 // Make instance if it is not an AJAX call
368 if (!(TYPO3_REQUESTTYPE & TYPO3_REQUESTTYPE_AJAX)) {
369 $SOBE = t3lib_div::makeInstance('SC_alt_db_navframe');
370 $SOBE->init();
371 $SOBE->initPage();
372 $SOBE->main();
373 $SOBE->printContent();
374 }
375
376 ?>