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