Committed AJAX pagetree and filetree by Benjamin Mack
[Packages/TYPO3.CMS.git] / typo3 / alt_file_navframe.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 1999-2005 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 * Folder tree in the File main 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 *
41 * 72: class localFolderTree extends t3lib_folderTree
42 * 81: function localFolderTree()
43 * 92: function wrapIcon($icon,&$row)
44 * 121: function wrapTitle($title,$row,$bank=0)
45 *
46 *
47 * 146: class SC_alt_file_navframe
48 * 163: function init()
49 * 253: function main()
50 * 284: function printContent()
51 *
52 * TOTAL FUNCTIONS: 6
53 * (This index is automatically created/updated by the extension "extdeveval")
54 *
55 */
56
57 $BACK_PATH = '';
58 require('init.php');
59 require('template.php');
60 require_once('class.filelistfoldertree.php');
61
62
63 /**
64 * Main script class for rendering of the folder tree
65 *
66 * @author Kasper Skaarhoj <kasperYYYY@typo3.com>
67 * @package TYPO3
68 * @subpackage core
69 */
70 class SC_alt_file_navframe {
71
72 // Internal, dynamic:
73 var $content; // Content accumulates in this variable.
74 var $foldertree; // Folder tree object.
75 var $doc; // Template object.
76
77 // Internal, static: GPvar:
78 var $currentSubScript;
79 var $cMR;
80
81
82 /**
83 * Initialiation of the script class
84 *
85 * @return void
86 */
87 function init() {
88 global $BE_USER,$BACK_PATH,$CLIENT;
89
90 // Setting GPvars:
91 $this->currentSubScript = t3lib_div::_GP('currentSubScript');
92 $this->cMR = t3lib_div::_GP('cMR');
93
94 // Create folder tree object:
95 $this->foldertree = t3lib_div::makeInstance('filelistFolderTree');
96 $this->foldertree->ext_IconMode = $BE_USER->getTSConfigVal('options.folderTree.disableIconLinkToContextmenu');
97 $this->foldertree->thisScript = 'alt_file_navframe.php';
98
99 // Setting highlight mode:
100 $this->doHighlight = !$BE_USER->getTSConfigVal('options.pageTree.disableTitleHighlight');
101
102 // Create template object:
103 $this->doc = t3lib_div::makeInstance('template');
104 $this->doc->docType = 'xhtml_trans';
105
106 // Setting backPath
107 $this->doc->backPath = $BACK_PATH;
108
109 // Adding javascript code for AJAX (prototype), drag&drop and the pagetree
110 $this->doc->JScode = '
111 <script type="text/javascript" src="prototype.js"></script>
112 <script type="text/javascript" src="tree.js"></script>'."\n";
113
114 // Setting JavaScript for menu.
115 $this->doc->JScode .= $this->doc->wrapScriptTags(
116 ($this->currentSubScript?'top.currentSubScript=unescape("'.rawurlencode($this->currentSubScript).'");':'').'
117
118 // setting prefs for pagetree and drag & drop
119 Tree.thisScript = "'.$this->foldertree->thisScript.'";
120 DragDrop.changeURL = "'.$this->backPath.'alt_clickmenu.php";
121 DragDrop.backPath = "'.t3lib_div::shortMD5(''.'|'.$GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey']).'";
122 DragDrop.table = "folders";
123
124 // Function, loading the list frame from navigation tree:
125 function jumpTo(id, linkObj, highlightID, bank) {
126 var theUrl = top.TS.PATH_typo3 + top.currentSubScript + "?id=" + id;
127 top.fsMod.currentBank = bank;
128
129 if (top.condensedMode) top.content.location.href = theUrl;
130 else parent.list_frame.location.href = theUrl;
131
132 '.($this->doHighlight ? 'Tree.highlightActiveItem("file", highlightID + "_" + bank);' : '').'
133 '.(!$GLOBALS['CLIENT']['FORMSTYLE'] ? '' : 'if (linkObj) linkObj.blur(); ').'
134 return false;
135 }
136 '.($this->cMR ? " jumpTo(top.fsMod.recentIds['file'],'');" : '')
137 );
138
139 // Click menu code is added:
140 $CMparts=$this->doc->getContextMenuCode();
141 $this->doc->bodyTagAdditions = $CMparts[1];
142 $this->doc->JScode.= $CMparts[0];
143 $this->doc->postCode.= $CMparts[2];
144 }
145
146 /**
147 * Main function, rendering the folder tree
148 *
149 * @return void
150 */
151 function main() {
152 global $LANG,$CLIENT;
153
154 // Produce browse-tree:
155 $tree = $this->foldertree->getBrowsableTree();
156
157 // output only the tree if this is an ajax call
158 if (t3lib_div::_GP('ajax')) {
159 $this->content = $tree;
160 return;
161 }
162
163 $this->content = $this->doc->startPage('TYPO3 Folder Tree');
164
165 // Outputting page tree:
166 $this->content.= $tree;
167
168 // Outputting refresh-link
169 $this->content.= '
170 <p class="c-refresh">
171 <a href="'.htmlspecialchars(t3lib_div::getIndpEnv('REQUEST_URI')).'">'.
172 '<img'.t3lib_iconWorks::skinImg('','gfx/refresh_n.gif','width="14" height="14"').' title="'.$LANG->sL('LLL:EXT:lang/locallang_core.php:labels.refresh',1).'" alt="" />'.
173 $LANG->sL('LLL:EXT:lang/locallang_core.php:labels.refresh',1).'</a>
174 </p>
175 <br />';
176
177 // CSH icon:
178 $this->content.= t3lib_BEfunc::cshItem('xMOD_csh_corebe', 'filetree', $GLOBALS['BACK_PATH']);
179
180 // Adding javascript for drag & drop activation and highlighting
181 $this->content .=$this->doc->wrapScriptTags('
182 '.($this->doHighlight ? 'Tree.highlightActiveItem("", top.fsMod.navFrameHighlightedID["file"]);' : '').'
183 '.(!$this->doc->isCMlayers() ? 'Tree.activateDragDrop = false;' : 'Tree.registerDragDropHandlers();')
184 );
185
186 }
187
188 /**
189 * Outputting the accumulated content to screen
190 *
191 * @return void
192 */
193 function printContent() {
194 if (!t3lib_div::_GP('ajax')) {
195 $this->content.= $this->doc->endPage();
196 $this->content = $this->doc->insertStylesAndJS($this->content);
197 }
198 echo $this->content;
199 }
200 }
201
202 // Include extension?
203 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/alt_file_navframe.php']) {
204 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/alt_file_navframe.php']);
205 }
206
207
208
209
210
211
212
213
214
215
216
217
218 // Make instance:
219 $SOBE = t3lib_div::makeInstance('SC_alt_file_navframe');
220 $SOBE->init();
221 $SOBE->main();
222 $SOBE->printContent();
223 ?>