Cleanup: Updated copyright comments
[Packages/TYPO3.CMS.git] / typo3 / alt_file_navframe.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 1999-2010 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_once('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
76 /**
77 * document template object
78 *
79 * @var template
80 */
81 var $doc;
82 var $backPath;
83
84 // Internal, static: GPvar:
85 var $currentSubScript;
86 var $cMR;
87
88
89 /**
90 * Initialiation of the script class
91 *
92 * @return void
93 */
94 function init() {
95 global $BE_USER, $BACK_PATH;
96
97 // Setting backPath
98 $this->backPath = $BACK_PATH;
99
100 // Setting GPvars:
101 $this->currentSubScript = t3lib_div::_GP('currentSubScript');
102 $this->cMR = t3lib_div::_GP('cMR');
103
104 // Create folder tree object:
105 $this->foldertree = t3lib_div::makeInstance('filelistFolderTree');
106 $this->foldertree->ext_IconMode = $BE_USER->getTSConfigVal('options.folderTree.disableIconLinkToContextmenu');
107 $this->foldertree->thisScript = 'alt_file_navframe.php';
108 }
109
110
111 /**
112 * initialization for the visual parts of the class
113 * Use template rendering only if this is a non-AJAX call
114 *
115 * @return void
116 */
117 public function initPage() {
118 global $BE_USER, $BACK_PATH, $CLIENT;
119
120 // Setting highlight mode:
121 $this->doHighlight = !$BE_USER->getTSConfigVal('options.pageTree.disableTitleHighlight');
122
123 // Create template object:
124 $this->doc = t3lib_div::makeInstance('template');
125 $this->doc->backPath = $BACK_PATH;
126 $this->doc->setModuleTemplate('templates/alt_file_navframe.html');
127 $this->doc->showFlashMessages = FALSE;
128
129 // Adding javascript code for AJAX (prototype), drag&drop and the filetree as well as the click menu code
130 $this->doc->getDragDropCode('folders');
131 $this->doc->getContextMenuCode();
132
133 // Setting JavaScript for menu.
134 $this->doc->JScode .= $this->doc->wrapScriptTags(
135
136 ($this->currentSubScript?'top.currentSubScript=unescape("'.rawurlencode($this->currentSubScript).'");':'').'
137
138 function initFlashUploader(path) {
139 path = decodeURIComponent(path);
140 var flashUploadOptions = {
141 uploadURL: top.TS.PATH_typo3 + "ajax.php",
142 uploadFileSizeLimit: "' . t3lib_div::getMaxUploadFileSize() . '",
143 uploadFileTypes: {
144 allow: "' . $GLOBALS['TYPO3_CONF_VARS']['BE']['fileExtensions']['webspace']['allow'] . '",
145 deny: "' . $GLOBALS['TYPO3_CONF_VARS']['BE']['fileExtensions']['webspace']['deny'] . '"
146 },
147 uploadFilePostName: "upload_1",
148 uploadPostParams: {
149 "file[upload][1][target]": path,
150 "file[upload][1][data]": 1,
151 "file[upload][1][charset]": "utf-8",
152 "ajaxID": "TYPO3_tcefile::process"
153 }
154 };
155
156 // get the flashUploaderWindow instance from the parent frame
157 var flashUploader = top.TYPO3.FileUploadWindow.getInstance(flashUploadOptions);
158 // add an additional function inside the container to show the checkbox option
159 var infoComponent = new top.Ext.Panel({
160 autoEl: { tag: "div" },
161 height: "auto",
162 bodyBorder: false,
163 border: false,
164 hideBorders: true,
165 cls: "t3-upload-window-infopanel",
166 id: "t3-upload-window-infopanel-addition",
167 html: \'<label for="overrideExistingFilesCheckbox"><input id="overrideExistingFilesCheckbox" type="checkbox" onclick="setFlashPostOptionOverwriteExistingFiles(this);" />\' + top.String.format(top.TYPO3.LLL.fileUpload.infoComponentOverrideFiles) + \'</label>\'
168 });
169 flashUploader.add(infoComponent);
170
171 // do a reload of this frame once all uploads are done
172 flashUploader.on("totalcomplete", function() {
173 jumpTo (top.rawurlencode(path), "", "", "");
174 });
175
176 // this is the callback function that delivers the additional post parameter to the flash application
177 top.setFlashPostOptionOverwriteExistingFiles = function(checkbox) {
178 var uploader = top.TYPO3.getInstance("FileUploadWindow");
179 if (uploader.isVisible()) {
180 uploader.swf.addPostParam("overwriteExistingFiles", (checkbox.checked == true ? 1 : 0));
181 }
182 };
183 }
184
185
186 // setting prefs for foldertree
187 Tree.ajaxID = "SC_alt_file_navframe::expandCollapse";
188
189 // Function, loading the list frame from navigation tree:
190 function jumpTo(id, linkObj, highlightID, bank) {
191 var theUrl = top.TS.PATH_typo3 + top.currentSubScript ;
192 if (theUrl.indexOf("?") != -1) {
193 theUrl += "&id=" + id
194 } else {
195 theUrl += "?id=" + id
196 }
197 top.fsMod.currentBank = bank;
198
199 if (top.TYPO3.configuration.condensedMode) {
200 top.content.location.href = theUrl;
201 } else {
202 parent.list_frame.location.href=theUrl;
203 }
204
205 '.($this->doHighlight ? 'Tree.highlightActiveItem("file", highlightID + "_" + bank);' : '').'
206 '.(!$CLIENT['FORMSTYLE'] ? '' : 'if (linkObj) linkObj.blur(); ').'
207 return false;
208 }
209 '.($this->cMR ? " jumpTo(top.fsMod.recentIds['file'],'');" : '')
210 );
211 }
212
213
214 /**
215 * Main function, rendering the folder tree
216 *
217 * @return void
218 */
219 function main() {
220 global $LANG,$CLIENT;
221
222 // Produce browse-tree:
223 $tree = $this->foldertree->getBrowsableTree();
224
225 // Outputting page tree:
226 $this->content.= $tree;
227
228 // Adding javascript for drag & drop activation and highlighting
229 $this->content .=$this->doc->wrapScriptTags('
230 '.($this->doHighlight ? 'Tree.highlightActiveItem("", top.fsMod.navFrameHighlightedID["file"]);' : '').'
231 '.(!$this->doc->isCMlayers() ? 'Tree.activateDragDrop = false;' : 'Tree.registerDragDropHandlers();')
232 );
233
234 // Setting up the buttons and markers for docheader
235 $docHeaderButtons = $this->getButtons();
236 $markers = array(
237 'IMG_RESET' => '<img' . t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'], 'gfx/close_gray.gif', ' width="16" height="16"') .
238 ' id="treeFilterReset" alt="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:labels.resetFilter') . '" ' .
239 'title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:labels.resetFilter') . '" />',
240 'CONTENT' => $this->content
241 );
242
243 $subparts = array();
244
245 // Possible filter/search like in page tree
246 $subparts['###SECOND_ROW###'] = '';
247
248 // Build the <body> for the module
249 $this->content = $this->doc->startPage('TYPO3 Folder Tree');
250 $this->content.= $this->doc->moduleBody($this->pageinfo, $docHeaderButtons, $markers, $subparts);
251 $this->content.= $this->doc->endPage();
252 $this->content = $this->doc->insertStylesAndJS($this->content);
253 }
254
255 /**
256 * Outputting the accumulated content to screen
257 *
258 * @return void
259 */
260 function printContent() {
261 echo $this->content;
262 }
263
264 /**
265 * Create the panel of buttons for submitting the form or otherwise perform operations.
266 *
267 * @return array all available buttons as an assoc. array
268 */
269 protected function getButtons() {
270 $buttons = array(
271 'csh' => '',
272 'refresh' => '',
273 );
274
275 // Refresh
276 $buttons['refresh'] = '<a href="' . htmlspecialchars(t3lib_div::getIndpEnv('REQUEST_URI')) . '">' .
277 t3lib_iconWorks::getSpriteIcon('actions-system-refresh') .
278 '</a>';
279
280 // CSH
281 $buttons['csh'] = str_replace('typo3-csh-inline','typo3-csh-inline show-right',t3lib_BEfunc::cshItem('xMOD_csh_corebe', 'filetree', $GLOBALS['BACK_PATH']));
282
283 return $buttons;
284 }
285
286 /**********************************
287 *
288 * AJAX Calls
289 *
290 **********************************/
291
292 /**
293 * Makes the AJAX call to expand or collapse the foldertree.
294 * Called by typo3/ajax.php
295 *
296 * @param array $params: additional parameters (not used here)
297 * @param TYPO3AJAX $ajaxObj: The TYPO3AJAX object of this request
298 * @return void
299 */
300 public function ajaxExpandCollapse($params, $ajaxObj) {
301 global $LANG;
302
303 $this->init();
304 $tree = $this->foldertree->getBrowsableTree();
305 if (!$this->foldertree->ajaxStatus) {
306 $ajaxObj->setError($tree);
307 } else {
308 $ajaxObj->addContent('tree', $tree);
309 }
310 }
311 }
312
313
314 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/alt_file_navframe.php']) {
315 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/alt_file_navframe.php']);
316 }
317
318
319 // Make instance if it is not an AJAX call
320 if (!(TYPO3_REQUESTTYPE & TYPO3_REQUESTTYPE_AJAX)) {
321 $SOBE = t3lib_div::makeInstance('SC_alt_file_navframe');
322 $SOBE->init();
323 $SOBE->initPage();
324 $SOBE->main();
325 $SOBE->printContent();
326 }
327
328 ?>