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