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