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