2 /***************************************************************
5 * (c) 1999-2011 Kasper Skårhøj (kasperYYYY@typo3.com)
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.
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.
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.
25 * This copyright notice MUST APPEAR in all copies of the script!
26 ***************************************************************/
28 * Folder tree in the File main module.
30 * Revised for TYPO3 3.6 2/2003 by Kasper Skårhøj
33 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
37 require_once('init.php');
38 require('template.php');
39 require_once('class.filelistfoldertree.php');
43 * Main script class for rendering of the folder tree
45 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
49 class SC_alt_file_navframe
{
52 var $content; // Content accumulates in this variable.
55 * @var filelistFolderTree $foldertree the folder tree object
60 * document template object
67 // Internal, static: GPvar:
68 var $currentSubScript;
73 * Initialiation of the script class
80 $this->backPath
= $GLOBALS['BACK_PATH'];
83 $this->currentSubScript
= t3lib_div
::_GP('currentSubScript');
84 $this->cMR
= t3lib_div
::_GP('cMR');
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';
95 * initialization for the visual parts of the class
96 * Use template rendering only if this is a non-AJAX call
100 public function initPage() {
102 // Setting highlight mode:
103 $this->doHighlight
= !$GLOBALS['BE_USER']->getTSConfigVal('options.pageTree.disableTitleHighlight');
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;
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();
115 // Setting JavaScript for menu.
116 $this->doc
->JScode
.= $this->doc
->wrapScriptTags(
118 ($this->currentSubScript?
'top.currentSubScript=unescape("'.rawurlencode($this->currentSubScript
).'");':'').'
120 function initFlashUploader(path) {
121 path = decodeURIComponent(path);
122 var flashUploadOptions = {
123 uploadURL: top.TS.PATH_typo3 + "ajax.php",
124 uploadFileSizeLimit: "' . t3lib_div
::getMaxUploadFileSize() . '",
126 allow: "' . $GLOBALS['TYPO3_CONF_VARS']['BE']['fileExtensions']['webspace']['allow'] . '",
127 deny: "' . $GLOBALS['TYPO3_CONF_VARS']['BE']['fileExtensions']['webspace']['deny'] . '"
129 uploadFilePostName: "upload_1",
131 "file[upload][1][target]": path,
132 "file[upload][1][data]": 1,
133 "file[upload][1][charset]": "utf-8",
134 "ajaxID": "TYPO3_tcefile::process"
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" },
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>\'
151 flashUploader.add(infoComponent);
153 // do a reload of this frame once all uploads are done
154 flashUploader.on("totalcomplete", function() {
155 jumpTo (top.rawurlencode(path), "", "", "");
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));
168 // setting prefs for foldertree
169 Tree.ajaxID = "SC_alt_file_navframe::expandCollapse";
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
177 theUrl += "?id=" + id
179 top.fsMod.currentBank = bank;
180 top.TYPO3.Backend.ContentContainer.setUrl(theUrl);
182 '.($this->doHighlight ?
'Tree.highlightActiveItem("file", highlightID + "_" + bank);' : '').'
183 '.(!$GLOBALS['CLIENT']['FORMSTYLE'] ?
'' : 'if (linkObj) linkObj.blur(); ').'
186 '.($this->cMR ?
" jumpTo(top.fsMod.recentIds['file'],'');" : '')
192 * Main function, rendering the folder tree
198 // Produce browse-tree:
199 $tree = $this->foldertree
->getBrowsableTree();
201 // Outputting page tree:
202 $this->content
.= $tree;
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();')
210 // Setting up the buttons and markers for docheader
211 $docHeaderButtons = $this->getButtons();
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
221 // Possible filter/search like in page tree
222 $subparts['###SECOND_ROW###'] = '';
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
);
232 * Outputting the accumulated content to screen
236 function printContent() {
241 * Create the panel of buttons for submitting the form or otherwise perform operations.
243 * @return array all available buttons as an assoc. array
245 protected function getButtons() {
252 $buttons['refresh'] = '<a href="' . htmlspecialchars(t3lib_div
::getIndpEnv('REQUEST_URI')) . '">' .
253 t3lib_iconWorks
::getSpriteIcon('actions-system-refresh') .
257 $buttons['csh'] = str_replace('typo3-csh-inline','typo3-csh-inline show-right',t3lib_BEfunc
::cshItem('xMOD_csh_corebe', 'filetree', $GLOBALS['BACK_PATH']));
262 /**********************************
266 **********************************/
269 * Makes the AJAX call to expand or collapse the foldertree.
270 * Called by typo3/ajax.php
272 * @param array $params: additional parameters (not used here)
273 * @param TYPO3AJAX $ajaxObj: The TYPO3AJAX object of this request
276 public function ajaxExpandCollapse($params, $ajaxObj) {
278 $tree = $this->foldertree
->getBrowsableTree();
279 if ($this->foldertree
->getAjaxStatus() === FALSE) {
280 $ajaxObj->setError($tree);
282 $ajaxObj->addContent('tree', $tree);
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');
293 $SOBE->printContent();