[TASK] Remove require statements for classes
[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
188 // Outputting Temporary DB mount notice:
189 if ($this->active_tempMountPoint) {
190 $flashText = '
191 <a href="' . htmlspecialchars(t3lib_div::linkThisScript(array('setTempDBmount' => 0))) . '">' .
192 $GLOBALS['LANG']->sl('LLL:EXT:lang/locallang_core.xml:labels.temporaryDBmount', 1) .
193 '</a> <br />' .
194 $GLOBALS['LANG']->sl('LLL:EXT:lang/locallang_core.xml:labels.path', 1) . ': <span title="' .
195 htmlspecialchars($this->active_tempMountPoint['_thePathFull']) . '">' .
196 htmlspecialchars(t3lib_div::fixed_lgd_cs($this->active_tempMountPoint['_thePath'], -50)).
197 '</span>
198 ';
199
200 $flashMessage = t3lib_div::makeInstance(
201 't3lib_FlashMessage',
202 $flashText,
203 '',
204 t3lib_FlashMessage::INFO
205 );
206
207
208 $this->content.= $flashMessage->render();
209 }
210
211 // Outputting page tree:
212 $this->content .= '<div id="PageTreeDiv">'.$tree.'</div>';
213
214 // Adding javascript for drag & drop activation and highlighting
215 $this->content .= $this->doc->wrapScriptTags('
216 '.($this->doHighlight ? 'Tree.highlightActiveItem("",top.fsMod.navFrameHighlightedID["web"]);' : '').'
217 '.(!$this->doc->isCMlayers() ? 'Tree.activateDragDrop = false;' : 'Tree.registerDragDropHandlers();')
218 );
219
220 // Setting up the buttons and markers for docheader
221 $docHeaderButtons = $this->getButtons();
222 $markers = array(
223 'IMG_RESET' => t3lib_iconWorks::getSpriteIcon('actions-document-close', array(
224 'id' =>'treeFilterReset',
225 'alt'=> $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:labels.resetFilter'),
226 'title' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:labels.resetFilter')
227 )),
228 'WORKSPACEINFO' => $this->getWorkspaceInfo(),
229 'CONTENT' => $this->content
230 );
231 $subparts = array();
232
233 if (!$this->hasFilterBox) {
234 $subparts['###SECOND_ROW###'] = '';
235 }
236 // Build the <body> for the module
237 $this->content = $this->doc->startPage('TYPO3 Page Tree');
238 $this->content.= $this->doc->moduleBody($this->pageinfo, $docHeaderButtons, $markers, $subparts);
239 $this->content.= $this->doc->endPage();
240
241 $this->content = $this->doc->insertStylesAndJS($this->content);
242 }
243
244 /**
245 * Outputting the accumulated content to screen
246 *
247 * @return void
248 */
249 function printContent() {
250 echo $this->content;
251 }
252
253 /**
254 * Create the panel of buttons for submitting the form or otherwise perform operations.
255 *
256 * @return array All available buttons as an assoc. array
257 */
258 protected function getButtons() {
259 $buttons = array(
260 'csh' => '',
261 'new_page' => '',
262 'refresh' => '',
263 'filter' => '',
264 );
265
266 // New Page
267 $onclickNewPageWizard = 'top.content.list_frame.location.href=top.TS.PATH_typo3+\'db_new.php?pagesOnly=1&amp;id=\'+Tree.pageID;';
268 $buttons['new_page'] = '<a href="#" onclick="' . $onclickNewPageWizard . '" title="' . $GLOBALS['LANG']->sL('LLL:EXT:cms/layout/locallang.xml:newPage', TRUE) . '">' .
269 t3lib_iconWorks::getSpriteIcon('actions-page-new') .
270 '</a>';
271
272 // Refresh
273 $buttons['refresh'] = '<a href="' . htmlspecialchars(t3lib_div::getIndpEnv('REQUEST_URI')) . '" title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.refresh', TRUE) . '">' .
274 t3lib_iconWorks::getSpriteIcon('actions-system-refresh') .
275 '</a>';
276
277 // CSH
278 $buttons['csh'] = str_replace('typo3-csh-inline', 'typo3-csh-inline show-right', t3lib_BEfunc::cshItem('xMOD_csh_corebe', 'pagetree', $GLOBALS['BACK_PATH'], '', TRUE));
279
280 // Filter
281 if ($this->hasFilterBox) {
282 $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>';
283 }
284
285 return $buttons;
286 }
287
288 /**
289 * Create the workspace information
290 *
291 * @return string HTML containing workspace info
292 */
293 protected function getWorkspaceInfo() {
294
295 if (t3lib_extMgm::isLoaded('workspaces') && ($GLOBALS['BE_USER']->workspace !== 0 || $GLOBALS['BE_USER']->getTSConfigVal('options.pageTree.onlineWorkspaceInfo'))) {
296 $wsTitle = htmlspecialchars(tx_Workspaces_Service_Workspaces::getWorkspaceTitle($GLOBALS['BE_USER']->workspace));
297
298 $workspaceInfo = '
299 <div class="bgColor4 workspace-info">' .
300 t3lib_iconWorks::getSpriteIcon(
301 'apps-toolbar-menu-workspace',
302 array(
303 'title' => $wsTitle,
304 'onclick' => 'top.goToModule(\'web_WorkspacesWorkspaces\');',
305 'style' => 'cursor:pointer;'
306 )
307 ) .
308 $wsTitle .
309 '</div>
310 ';
311 }
312
313 return $workspaceInfo;
314 }
315
316 /**********************************
317 *
318 * Temporary DB mounts
319 *
320 **********************************/
321
322 /**
323 * Getting temporary DB mount
324 *
325 * @return void
326 */
327 function initializeTemporaryDBmount() {
328
329 // Set/Cancel Temporary DB Mount:
330 if (strlen($this->setTempDBmount)) {
331 $set = t3lib_utility_Math::forceIntegerInRange($this->setTempDBmount, 0);
332 if ($set > 0 && $GLOBALS['BE_USER']->isInWebMount($set)) {
333 // Setting...:
334 $this->settingTemporaryMountPoint($set);
335 } else {
336 // Clear:
337 $this->settingTemporaryMountPoint(0);
338 }
339 }
340
341 // Getting temporary mount point ID:
342 $temporaryMountPoint = intval($GLOBALS['BE_USER']->getSessionData('pageTree_temporaryMountPoint'));
343
344 // If mount point ID existed and is within users real mount points, then set it temporarily:
345 if ($temporaryMountPoint > 0 && $GLOBALS['BE_USER']->isInWebMount($temporaryMountPoint)) {
346 if ($this->active_tempMountPoint = t3lib_BEfunc::readPageAccess($temporaryMountPoint, $GLOBALS['BE_USER']->getPagePermsClause(1))) {
347 $this->pagetree->MOUNTS = array($temporaryMountPoint);
348 } else {
349 // Clear temporary mount point as we have no access to it any longer
350 $this->settingTemporaryMountPoint(0);
351 }
352 }
353 }
354
355 /**
356 * Setting temporary page id as DB mount
357 *
358 * @param integer $pageId The page id to set as DB mount
359 * @return void
360 */
361 function settingTemporaryMountPoint($pageId) {
362 $GLOBALS['BE_USER']->setAndSaveSessionData('pageTree_temporaryMountPoint', intval($pageId));
363 }
364
365 /**********************************
366 *
367 * AJAX Calls
368 *
369 **********************************/
370
371 /**
372 * Makes the AJAX call to expand or collapse the pagetree.
373 * Called by typo3/ajax.php
374 *
375 * @param array $params Additional parameters (not used here)
376 * @param TYPO3AJAX $ajaxObj The TYPO3AJAX object of this request
377 * @return void
378 */
379 public function ajaxExpandCollapse($params, $ajaxObj) {
380 $this->init();
381 $tree = $this->pagetree->getBrowsableTree();
382 if (!$this->pagetree->ajaxStatus) {
383 $ajaxObj->setError($tree);
384 } else {
385 $ajaxObj->addContent('tree', $tree);
386 }
387 }
388 }
389
390 // Make instance if it is not an AJAX call
391 if (!(TYPO3_REQUESTTYPE & TYPO3_REQUESTTYPE_AJAX)) {
392 $SOBE = t3lib_div::makeInstance('SC_alt_db_navframe');
393 $SOBE->init();
394 $SOBE->initPage();
395 $SOBE->main();
396 $SOBE->printContent();
397 }
398
399 ?>