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