Follow-up to #12381: Scheduler: BLOB database fields may not be NOT NULL
[Packages/TYPO3.CMS.git] / typo3 / alt_db_navframe.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 1999-2009 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 var $template; // a static HTML template, usually in templates/alt_db_navframe.html
89 var $hasFilterBox; //depends on userTS-setting
90
91 /**
92 * Initialiation of the class
93 *
94 * @return void
95 */
96 function init() {
97 global $BE_USER,$BACK_PATH;
98
99 // Setting backPath
100 $this->backPath = $BACK_PATH;
101
102 // Setting GPvars:
103 $this->cMR = t3lib_div::_GP('cMR');
104 $this->currentSubScript = t3lib_div::_GP('currentSubScript');
105 $this->setTempDBmount = t3lib_div::_GP('setTempDBmount');
106
107 // look for User setting
108 $this->hasFilterBox = !$BE_USER->getTSConfigVal('options.pageTree.hideFilter');
109
110 // Create page tree object:
111 $this->pagetree = t3lib_div::makeInstance('webPageTree');
112 $this->pagetree->ext_IconMode = $BE_USER->getTSConfigVal('options.pageTree.disableIconLinkToContextmenu');
113 $this->pagetree->ext_showPageId = $BE_USER->getTSConfigVal('options.pageTree.showPageIdWithTitle');
114 $this->pagetree->ext_showNavTitle = $BE_USER->getTSConfigVal('options.pageTree.showNavTitle');
115 $this->pagetree->ext_separateNotinmenuPages = $BE_USER->getTSConfigVal('options.pageTree.separateNotinmenuPages');
116 $this->pagetree->ext_alphasortNotinmenuPages = $BE_USER->getTSConfigVal('options.pageTree.alphasortNotinmenuPages');
117 $this->pagetree->thisScript = 'alt_db_navframe.php';
118 $this->pagetree->addField('alias');
119 $this->pagetree->addField('shortcut');
120 $this->pagetree->addField('shortcut_mode');
121 $this->pagetree->addField('mount_pid');
122 $this->pagetree->addField('mount_pid_ol');
123 $this->pagetree->addField('nav_hide');
124 $this->pagetree->addField('nav_title');
125 $this->pagetree->addField('url');
126
127 // Temporary DB mounts:
128 $this->initializeTemporaryDBmount();
129 }
130
131
132 /**
133 * initialization for the visual parts of the class
134 * Use template rendering only if this is a non-AJAX call
135 *
136 * @return void
137 */
138 public function initPage() {
139 global $BE_USER;
140
141 // Setting highlight mode:
142 $this->doHighlight = !$BE_USER->getTSConfigVal('options.pageTree.disableTitleHighlight');
143
144 // If highlighting is active, define the CSS class for the active item depending on the workspace
145 if ($this->doHighlight) {
146 $hlClass = ($BE_USER->workspace === 0 ? 'active' : 'active active-ws wsver'.$BE_USER->workspace);
147 }
148
149 // Create template object:
150 $this->doc = t3lib_div::makeInstance('template');
151 $this->doc->backPath = $BACK_PATH;
152 $this->doc->setModuleTemplate('templates/alt_db_navframe.html');
153 $this->doc->showFlashMessages = FALSE;
154
155 // get HTML-Template
156
157
158 // Adding javascript code for AJAX (prototype), drag&drop and the pagetree as well as the click menu code
159 $this->doc->getDragDropCode('pages');
160 $this->doc->getContextMenuCode();
161 $this->doc->getPageRenderer()->loadScriptaculous('effects');
162
163 $this->doc->JScode .= $this->doc->wrapScriptTags(
164 ($this->currentSubScript?'top.currentSubScript=unescape("'.rawurlencode($this->currentSubScript).'");':'').'
165 // setting prefs for pagetree and drag & drop
166 '.($this->doHighlight ? 'Tree.highlightClass = "'.$hlClass.'";' : '').'
167
168 // Function, loading the list frame from navigation tree:
169 function jumpTo(id, linkObj, highlightID, bank) { //
170 var theUrl = top.TS.PATH_typo3 + top.currentSubScript ;
171 if (theUrl.indexOf("?") != -1) {
172 theUrl += "&id=" + id
173 } else {
174 theUrl += "?id=" + id
175 }
176 top.fsMod.currentBank = bank;
177
178 if (top.condensedMode) {
179 top.content.location.href = theUrl;
180 } else {
181 parent.list_frame.location.href=theUrl;
182 }
183
184 '.($this->doHighlight ? 'Tree.highlightActiveItem("web", highlightID + "_" + bank);' : '').'
185 '.(!$GLOBALS['CLIENT']['FORMSTYLE'] ? '' : 'if (linkObj) linkObj.blur(); ').'
186 return false;
187 }
188 '.($this->cMR?"jumpTo(top.fsMod.recentIds['web'],'');":'').
189
190 ($this->hasFilterBox ? 'var TYPO3PageTreeFilter = new PageTreeFilter();' : '') . '
191
192 ');
193
194 $this->doc->bodyTagId = 'typo3-pagetree';
195 }
196
197
198 /**
199 * Main function, rendering the browsable page tree
200 *
201 * @return void
202 */
203 function main() {
204 global $LANG,$CLIENT;
205
206 // Produce browse-tree:
207 $tree = $this->pagetree->getBrowsableTree();
208
209
210 // Outputting Temporary DB mount notice:
211 if ($this->active_tempMountPoint) {
212 $this->content.= '
213 <div class="bgColor4 c-notice">
214 <img'.t3lib_iconWorks::skinImg('','gfx/icon_note.gif','width="18" height="16"').' align="top" alt="" />'.
215 '<a href="'.htmlspecialchars(t3lib_div::linkThisScript(array('setTempDBmount' => 0))).'">'.
216 $LANG->sl('LLL:EXT:lang/locallang_core.xml:labels.temporaryDBmount',1).
217 '</a><br />
218 '.$LANG->sl('LLL:EXT:lang/locallang_core.xml:labels.path',1).': <span title="'.htmlspecialchars($this->active_tempMountPoint['_thePathFull']).'">'.htmlspecialchars(t3lib_div::fixed_lgd_cs($this->active_tempMountPoint['_thePath'],-50)).'</span>
219 </div>
220 ';
221 }
222
223 // Outputting page tree:
224 $this->content .= '<div id="PageTreeDiv">'.$tree.'</div>';
225
226 // Adding javascript for drag & drop activation and highlighting
227 $this->content .= $this->doc->wrapScriptTags('
228 '.($this->doHighlight ? 'Tree.highlightActiveItem("",top.fsMod.navFrameHighlightedID["web"]);' : '').'
229 '.(!$this->doc->isCMlayers() ? 'Tree.activateDragDrop = false;' : 'Tree.registerDragDropHandlers();')
230 );
231
232 // Setting up the buttons and markers for docheader
233 $docHeaderButtons = $this->getButtons();
234 $markers = array(
235 'IMG_RESET' => '<img' . t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'], 'gfx/close_gray.gif', ' width="16" height="16"') .
236 ' id="treeFilterReset" alt="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:labels.resetFilter') . '" ' .
237 'title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:labels.resetFilter') . '" />',
238 'WORKSPACEINFO' => $this->getWorkspaceInfo(),
239 'CONTENT' => $this->content
240 );
241 $subparts = array();
242
243 if (!$this->hasFilterBox) {
244 $subparts['###SECOND_ROW###'] = '';
245 }
246 // Build the <body> for the module
247 $this->content = $this->doc->startPage('TYPO3 Page Tree');
248 $this->content.= $this->doc->moduleBody($this->pageinfo, $docHeaderButtons, $markers, $subparts);
249 $this->content.= $this->doc->endPage();
250
251 $this->content = $this->doc->insertStylesAndJS($this->content);
252 }
253
254 /**
255 * Outputting the accumulated content to screen
256 *
257 * @return void
258 */
259 function printContent() {
260 echo $this->content;
261 }
262
263 /**
264 * Create the panel of buttons for submitting the form or otherwise perform operations.
265 *
266 * @return array all available buttons as an assoc. array
267 */
268 protected function getButtons() {
269 global $LANG;
270
271 $buttons = array(
272 'csh' => '',
273 'new_page' => '',
274 'refresh' => '',
275 );
276
277 // New Page
278 $onclickNewPageWizard = 'top.content.list_frame.location.href=top.TS.PATH_typo3+\'db_new.php?pagesOnly=1&amp;id=\'+Tree.pageID;';
279 $buttons['new_page'] = '<a href="#" onclick="' . $onclickNewPageWizard . '"><img' . t3lib_iconWorks::skinImg('', 'gfx/new_page.gif') . ' title="' . $LANG->sL('LLL:EXT:cms/layout/locallang.xml:newPage', 1) . '" alt="" /></a>';
280
281 // Refresh
282 $buttons['refresh'] = '<a href="' . htmlspecialchars(t3lib_div::getIndpEnv('REQUEST_URI')) . '"><img' . t3lib_iconWorks::skinImg('', 'gfx/refresh_n.gif') . ' title="' . $LANG->sL('LLL:EXT:lang/locallang_core.php:labels.refresh', 1) . '" alt="" /></a>';
283
284 // CSH
285 $buttons['csh'] = str_replace('typo3-csh-inline','typo3-csh-inline show-right',t3lib_BEfunc::cshItem('xMOD_csh_corebe', 'pagetree', $GLOBALS['BACK_PATH'], '', TRUE));
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 global $LANG;
297
298 if ($GLOBALS['BE_USER']->workspace!==0 || $GLOBALS['BE_USER']->getTSConfigVal('options.pageTree.onlineWorkspaceInfo')) {
299 switch($GLOBALS['BE_USER']->workspace) {
300 case 0:
301 $wsTitle = '&nbsp;'.$this->doc->icons(2).'['.$LANG->sL('LLL:EXT:lang/locallang_misc.xml:shortcut_onlineWS',1).']';
302 break;
303 case -1:
304 $wsTitle = '['.$LANG->sL('LLL:EXT:lang/locallang_misc.xml:shortcut_offlineWS',1).']';
305 break;
306 default:
307 $wsTitle = '['.$GLOBALS['BE_USER']->workspace.'] '.htmlspecialchars($GLOBALS['BE_USER']->workspaceRec['title']);
308 break;
309 }
310
311 $workspaceInfo = '
312 <div class="bgColor4 workspace-info">
313 <a href="'.htmlspecialchars('mod/user/ws/index.php').'" target="content">'.
314 '<img'.t3lib_iconWorks::skinImg('','gfx/i/sys_workspace.png','width="18" height="16"').' align="top" alt="" />'.
315 '</a>'.$wsTitle.'
316 </div>
317 ';
318 }
319
320 return $workspaceInfo;
321 }
322
323
324 /**********************************
325 *
326 * Temporary DB mounts
327 *
328 **********************************/
329
330 /**
331 * Getting temporary DB mount
332 *
333 * @return void
334 */
335 function initializeTemporaryDBmount(){
336 global $BE_USER;
337
338 // Set/Cancel Temporary DB Mount:
339 if (strlen($this->setTempDBmount)) {
340 $set = t3lib_div::intInRange($this->setTempDBmount,0);
341 if ($set>0 && $BE_USER->isInWebMount($set)) { // Setting...:
342 $this->settingTemporaryMountPoint($set);
343 } else { // Clear:
344 $this->settingTemporaryMountPoint(0);
345 }
346 }
347
348 // Getting temporary mount point ID:
349 $temporaryMountPoint = intval($BE_USER->getSessionData('pageTree_temporaryMountPoint'));
350
351 // If mount point ID existed and is within users real mount points, then set it temporarily:
352 if ($temporaryMountPoint > 0 && $BE_USER->isInWebMount($temporaryMountPoint)) {
353 if ($this->active_tempMountPoint = t3lib_BEfunc::readPageAccess($temporaryMountPoint, $BE_USER->getPagePermsClause(1))) {
354 $this->pagetree->MOUNTS = array($temporaryMountPoint);
355 }
356 else {
357 // Clear temporary mount point as we have no access to it any longer
358 $this->settingTemporaryMountPoint(0);
359 }
360 }
361 }
362
363
364 /**
365 * Setting temporary page id as DB mount
366 *
367 * @param integer The page id to set as DB mount
368 * @return void
369 */
370 function settingTemporaryMountPoint($pageId) {
371 $GLOBALS['BE_USER']->setAndSaveSessionData('pageTree_temporaryMountPoint',intval($pageId));
372 }
373
374
375 /**********************************
376 *
377 * AJAX Calls
378 *
379 **********************************/
380
381 /**
382 * Makes the AJAX call to expand or collapse the pagetree.
383 * Called by typo3/ajax.php
384 *
385 * @param array $params: additional parameters (not used here)
386 * @param TYPO3AJAX $ajaxObj: The TYPO3AJAX object of this request
387 * @return void
388 */
389 public function ajaxExpandCollapse($params, $ajaxObj) {
390 global $LANG;
391
392 $this->init();
393 $tree = $this->pagetree->getBrowsableTree();
394 if (!$this->pagetree->ajaxStatus) {
395 $ajaxObj->setError($tree);
396 } else {
397 $ajaxObj->addContent('tree', $tree);
398 }
399 }
400 }
401
402
403
404 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/alt_db_navframe.php']) {
405 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/alt_db_navframe.php']);
406 }
407
408
409 // Make instance if it is not an AJAX call
410 if (!(TYPO3_REQUESTTYPE & TYPO3_REQUESTTYPE_AJAX)) {
411 $SOBE = t3lib_div::makeInstance('SC_alt_db_navframe');
412 $SOBE->init();
413 $SOBE->initPage();
414 $SOBE->main();
415 $SOBE->printContent();
416 }
417
418 ?>