Revert "[FEATURE] Speed-up Backend with CardLayout"
[Packages/TYPO3.CMS.git] / typo3 / alt_db_navframe.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 1999-2011 Kasper Skårhøj (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 * Revised for TYPO3 3.6 2/2003 by Kasper Skårhøj
31 * XHTML compliant
32 *
33 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
34 */
35
36
37 $BACK_PATH = '';
38 require_once('init.php');
39 require('template.php');
40 require_once('class.webpagetree.php');
41
42
43 /**
44 * Main script class for the page tree navigation frame
45 *
46 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
47 * @package TYPO3
48 * @subpackage core
49 */
50 class SC_alt_db_navframe {
51
52 // Internal:
53 var $content;
54 var $pagetree;
55
56 /**
57 * document template object
58 *
59 * @var template
60 */
61 var $doc;
62 var $active_tempMountPoint = 0; // Temporary mount point (record), if any
63 var $backPath;
64
65 // Internal, static: GPvar:
66 var $currentSubScript;
67 var $cMR;
68 var $setTempDBmount; // If not '' (blank) then it will clear (0) or set (>0) Temporary DB mount.
69
70 var $template; // a static HTML template, usually in templates/alt_db_navframe.html
71 var $hasFilterBox; //depends on userTS-setting
72
73 /**
74 * Initialiation of the class
75 *
76 * @return void
77 */
78 function init() {
79
80 // Setting backPath
81 $this->backPath = $GLOBALS['BACK_PATH'];
82
83 // Setting GPvars:
84 $this->cMR = t3lib_div::_GP('cMR');
85 $this->currentSubScript = t3lib_div::_GP('currentSubScript');
86 $this->setTempDBmount = t3lib_div::_GP('setTempDBmount');
87
88 // look for User setting
89 $this->hasFilterBox = !$GLOBALS['BE_USER']->getTSConfigVal('options.pageTree.hideFilter');
90
91 // Create page tree object:
92 $this->pagetree = t3lib_div::makeInstance('webPageTree');
93 $this->pagetree->ext_IconMode = $GLOBALS['BE_USER']->getTSConfigVal('options.pageTree.disableIconLinkToContextmenu');
94 $this->pagetree->ext_showPageId = $GLOBALS['BE_USER']->getTSConfigVal('options.pageTree.showPageIdWithTitle');
95 $this->pagetree->ext_showNavTitle = $GLOBALS['BE_USER']->getTSConfigVal('options.pageTree.showNavTitle');
96 $this->pagetree->ext_separateNotinmenuPages = $GLOBALS['BE_USER']->getTSConfigVal('options.pageTree.separateNotinmenuPages');
97 $this->pagetree->ext_alphasortNotinmenuPages = $GLOBALS['BE_USER']->getTSConfigVal('options.pageTree.alphasortNotinmenuPages');
98 $this->pagetree->thisScript = 'alt_db_navframe.php';
99 $this->pagetree->addField('alias');
100 $this->pagetree->addField('shortcut');
101 $this->pagetree->addField('shortcut_mode');
102 $this->pagetree->addField('mount_pid');
103 $this->pagetree->addField('mount_pid_ol');
104 $this->pagetree->addField('nav_hide');
105 $this->pagetree->addField('nav_title');
106 $this->pagetree->addField('url');
107
108 // Temporary DB mounts:
109 $this->initializeTemporaryDBmount();
110 }
111
112
113 /**
114 * initialization for the visual parts of the class
115 * Use template rendering only if this is a non-AJAX call
116 *
117 * @return void
118 */
119 public function initPage() {
120
121 // Setting highlight mode:
122 $this->doHighlight = !$GLOBALS['BE_USER']->getTSConfigVal('options.pageTree.disableTitleHighlight');
123
124 // If highlighting is active, define the CSS class for the active item depending on the workspace
125 if ($this->doHighlight) {
126 $hlClass = ($GLOBALS['BE_USER']->workspace === 0 ? 'active' : 'active active-ws wsver' . $GLOBALS['BE_USER']->workspace);
127 }
128
129 // Create template object:
130 $this->doc = t3lib_div::makeInstance('template');
131 $this->doc->backPath = $GLOBALS['BACK_PATH'];
132 $this->doc->setModuleTemplate('templates/alt_db_navframe.html');
133 $this->doc->showFlashMessages = FALSE;
134
135 // get HTML-Template
136
137
138 // Adding javascript code for AJAX (prototype), drag&drop and the pagetree as well as the click menu code
139 $this->doc->getDragDropCode('pages');
140 $this->doc->getContextMenuCode();
141 $this->doc->getPageRenderer()->loadScriptaculous('effects');
142 $this->doc->getPageRenderer()->loadExtJS();
143
144 if ($this->hasFilterBox) {
145 $this->doc->getPageRenderer()->addJsFile('js/pagetreefiltermenu.js');
146 }
147
148 $this->doc->JScode .= $this->doc->wrapScriptTags(
149 ($this->currentSubScript?'top.currentSubScript=unescape("'.rawurlencode($this->currentSubScript).'");':'').'
150 // setting prefs for pagetree and drag & drop
151 '.($this->doHighlight ? 'Tree.highlightClass = "'.$hlClass.'";' : '').'
152
153 // Function, loading the list frame from navigation tree:
154 function jumpTo(id, linkObj, highlightID, bank) { //
155 var theUrl = top.TS.PATH_typo3 + top.currentSubScript ;
156 if (theUrl.indexOf("?") != -1) {
157 theUrl += "&id=" + id
158 } else {
159 theUrl += "?id=" + id
160 }
161 top.fsMod.currentBank = bank;
162 top.TYPO3.Backend.ContentContainer.setUrl(theUrl);
163
164 '.($this->doHighlight ? 'Tree.highlightActiveItem("web", highlightID + "_" + bank);' : '').'
165 '.(!$GLOBALS['CLIENT']['FORMSTYLE'] ? '' : 'if (linkObj) linkObj.blur(); ').'
166 return false;
167 }
168 '.($this->cMR?"jumpTo(top.fsMod.recentIds['web'],'');":'').
169
170 ($this->hasFilterBox ? 'var TYPO3PageTreeFilter = new PageTreeFilter();' : '') . '
171
172 ');
173
174 $this->doc->bodyTagId = 'typo3-pagetree';
175 }
176
177
178 /**
179 * Main function, rendering the browsable page tree
180 *
181 * @return void
182 */
183 function main() {
184
185 // Produce browse-tree:
186 $tree = $this->pagetree->getBrowsableTree();
187
188
189 // Outputting Temporary DB mount notice:
190 if ($this->active_tempMountPoint) {
191 $flashText = '
192 <a href="' . htmlspecialchars(t3lib_div::linkThisScript(array('setTempDBmount' => 0))) . '">' .
193 $GLOBALS['LANG']->sl('LLL:EXT:lang/locallang_core.xml:labels.temporaryDBmount', 1) .
194 '</a> <br />' .
195 $GLOBALS['LANG']->sl('LLL:EXT:lang/locallang_core.xml:labels.path', 1) . ': <span title="' .
196 htmlspecialchars($this->active_tempMountPoint['_thePathFull']) . '">' .
197 htmlspecialchars(t3lib_div::fixed_lgd_cs($this->active_tempMountPoint['_thePath'],-50)).
198 '</span>
199 ';
200
201 $flashMessage = t3lib_div::makeInstance(
202 't3lib_FlashMessage',
203 $flashText,
204 '',
205 t3lib_FlashMessage::INFO
206 );
207
208
209 $this->content.= $flashMessage->render();
210 }
211
212 // Outputting page tree:
213 $this->content .= '<div id="PageTreeDiv">'.$tree.'</div>';
214
215 // Adding javascript for drag & drop activation and highlighting
216 $this->content .= $this->doc->wrapScriptTags('
217 '.($this->doHighlight ? 'Tree.highlightActiveItem("",top.fsMod.navFrameHighlightedID["web"]);' : '').'
218 '.(!$this->doc->isCMlayers() ? 'Tree.activateDragDrop = false;' : 'Tree.registerDragDropHandlers();')
219 );
220
221 // Setting up the buttons and markers for docheader
222 $docHeaderButtons = $this->getButtons();
223 $markers = array(
224 'IMG_RESET' => t3lib_iconWorks::getSpriteIcon('actions-document-close', array(
225 'id' =>'treeFilterReset',
226 'alt'=> $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:labels.resetFilter'),
227 'title' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:labels.resetFilter')
228 )),
229 'WORKSPACEINFO' => $this->getWorkspaceInfo(),
230 'CONTENT' => $this->content
231 );
232 $subparts = array();
233
234 if (!$this->hasFilterBox) {
235 $subparts['###SECOND_ROW###'] = '';
236 }
237 // Build the <body> for the module
238 $this->content = $this->doc->startPage('TYPO3 Page Tree');
239 $this->content.= $this->doc->moduleBody($this->pageinfo, $docHeaderButtons, $markers, $subparts);
240 $this->content.= $this->doc->endPage();
241
242 $this->content = $this->doc->insertStylesAndJS($this->content);
243 }
244
245 /**
246 * Outputting the accumulated content to screen
247 *
248 * @return void
249 */
250 function printContent() {
251 echo $this->content;
252 }
253
254 /**
255 * Create the panel of buttons for submitting the form or otherwise perform operations.
256 *
257 * @return array all available buttons as an assoc. array
258 */
259 protected function getButtons() {
260 $buttons = array(
261 'csh' => '',
262 'new_page' => '',
263 'refresh' => '',
264 'filter' => '',
265 );
266
267 // New Page
268 $onclickNewPageWizard = 'top.content.list_frame.location.href=top.TS.PATH_typo3+\'db_new.php?pagesOnly=1&amp;id=\'+Tree.pageID;';
269 $buttons['new_page'] = '<a href="#" onclick="' . $onclickNewPageWizard . '" title="' . $GLOBALS['LANG']->sL('LLL:EXT:cms/layout/locallang.xml:newPage', TRUE) . '">' .
270 t3lib_iconWorks::getSpriteIcon('actions-page-new') .
271 '</a>';
272
273 // Refresh
274 $buttons['refresh'] = '<a href="' . htmlspecialchars(t3lib_div::getIndpEnv('REQUEST_URI')) . '" title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.refresh', TRUE) . '">' .
275 t3lib_iconWorks::getSpriteIcon('actions-system-refresh') .
276 '</a>';
277
278 // CSH
279 $buttons['csh'] = str_replace('typo3-csh-inline','typo3-csh-inline show-right',t3lib_BEfunc::cshItem('xMOD_csh_corebe', 'pagetree', $GLOBALS['BACK_PATH'], '', TRUE));
280
281 // Filter
282 if ($this->hasFilterBox) {
283 $buttons['filter'] = '<a href="#" id="tree-toolbar-filter-item">' . t3lib_iconWorks::getSpriteIcon('actions-system-tree-search-open', array('title'=> $GLOBALS['LANG']->sL('LLL:EXT:cms/layout/locallang.xml:labels.filter', 1))) . '</a>';
284 }
285
286 return $buttons;
287 }
288
289 /**
290 * Create the workspace information
291 *
292 * @return string HTML containing workspace info
293 */
294 protected function getWorkspaceInfo() {
295
296 if (t3lib_extMgm::isLoaded('workspaces') && ($GLOBALS['BE_USER']->workspace !== 0 || $GLOBALS['BE_USER']->getTSConfigVal('options.pageTree.onlineWorkspaceInfo'))) {
297 $wsTitle = htmlspecialchars(tx_Workspaces_Service_Workspaces::getWorkspaceTitle($GLOBALS['BE_USER']->workspace));
298
299 $workspaceInfo = '
300 <div class="bgColor4 workspace-info">' .
301 t3lib_iconWorks::getSpriteIcon(
302 'apps-toolbar-menu-workspace',
303 array(
304 'title' => $wsTitle,
305 'onclick' => 'top.goToModule(\'web_WorkspacesWorkspaces\');',
306 'style' => 'cursor:pointer;'
307 )
308 ) .
309 $wsTitle .
310 '</div>
311 ';
312 }
313
314 return $workspaceInfo;
315 }
316
317
318 /**********************************
319 *
320 * Temporary DB mounts
321 *
322 **********************************/
323
324 /**
325 * Getting temporary DB mount
326 *
327 * @return void
328 */
329 function initializeTemporaryDBmount(){
330
331 // Set/Cancel Temporary DB Mount:
332 if (strlen($this->setTempDBmount)) {
333 $set = t3lib_utility_Math::forceIntegerInRange($this->setTempDBmount,0);
334 if ($set > 0 && $GLOBALS['BE_USER']->isInWebMount($set)){
335 // Setting...:
336 $this->settingTemporaryMountPoint($set);
337 } else { // Clear:
338 $this->settingTemporaryMountPoint(0);
339 }
340 }
341
342 // Getting temporary mount point ID:
343 $temporaryMountPoint = intval($GLOBALS['BE_USER']->getSessionData('pageTree_temporaryMountPoint'));
344
345 // If mount point ID existed and is within users real mount points, then set it temporarily:
346 if ($temporaryMountPoint > 0 && $GLOBALS['BE_USER']->isInWebMount($temporaryMountPoint)) {
347 if ($this->active_tempMountPoint = t3lib_BEfunc::readPageAccess($temporaryMountPoint, $GLOBALS['BE_USER']->getPagePermsClause(1))) {
348 $this->pagetree->MOUNTS = array($temporaryMountPoint);
349 }
350 else {
351 // Clear temporary mount point as we have no access to it any longer
352 $this->settingTemporaryMountPoint(0);
353 }
354 }
355 }
356
357
358 /**
359 * Setting temporary page id as DB mount
360 *
361 * @param integer The page id to set as DB mount
362 * @return void
363 */
364 function settingTemporaryMountPoint($pageId) {
365 $GLOBALS['BE_USER']->setAndSaveSessionData('pageTree_temporaryMountPoint',intval($pageId));
366 }
367
368
369 /**********************************
370 *
371 * AJAX Calls
372 *
373 **********************************/
374
375 /**
376 * Makes the AJAX call to expand or collapse the pagetree.
377 * Called by typo3/ajax.php
378 *
379 * @param array $params: additional parameters (not used here)
380 * @param TYPO3AJAX $ajaxObj: The TYPO3AJAX object of this request
381 * @return void
382 */
383 public function ajaxExpandCollapse($params, $ajaxObj) {
384 $this->init();
385 $tree = $this->pagetree->getBrowsableTree();
386 if (!$this->pagetree->ajaxStatus) {
387 $ajaxObj->setError($tree);
388 } else {
389 $ajaxObj->addContent('tree', $tree);
390 }
391 }
392 }
393
394
395
396 if (defined('TYPO3_MODE') && isset($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['typo3/alt_db_navframe.php'])) {
397 include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['typo3/alt_db_navframe.php']);
398 }
399
400
401 // Make instance if it is not an AJAX call
402 if (!(TYPO3_REQUESTTYPE & TYPO3_REQUESTTYPE_AJAX)) {
403 $SOBE = t3lib_div::makeInstance('SC_alt_db_navframe');
404 $SOBE->init();
405 $SOBE->initPage();
406 $SOBE->main();
407 $SOBE->printContent();
408 }
409
410 ?>