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