* Merging all changes from TYPO3_4-0 branch back into HEAD
[Packages/TYPO3.CMS.git] / typo3 / alt_file_navframe.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 1999-2005 Kasper Skaarhoj (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 * $Id$
31 * Revised for TYPO3 3.6 2/2003 by Kasper Skaarhoj
32 * XHTML compliant
33 *
34 * @author Kasper Skaarhoj <kasperYYYY@typo3.com>
35 */
36 /**
37 * [CLASS/FUNCTION INDEX of SCRIPT]
38 *
39 *
40 *
41 * 72: class localFolderTree extends t3lib_folderTree
42 * 81: function localFolderTree()
43 * 92: function wrapIcon($icon,&$row)
44 * 121: function wrapTitle($title,$row,$bank=0)
45 *
46 *
47 * 146: class SC_alt_file_navframe
48 * 163: function init()
49 * 253: function main()
50 * 284: function printContent()
51 *
52 * TOTAL FUNCTIONS: 6
53 * (This index is automatically created/updated by the extension "extdeveval")
54 *
55 */
56
57
58 $BACK_PATH='';
59 require ('init.php');
60 require ('template.php');
61 require_once (PATH_t3lib.'class.t3lib_foldertree.php');
62
63
64 /**
65 * Extension class for the t3lib_filetree class, needed for drag and drop functionality
66 *
67 * @author Sebastian Kurfuerst <sebastian@garbage-group.de>
68 * @package TYPO3
69 * @subpackage core
70 * @see class t3lib_browseTree
71 */
72 class localFolderTree extends t3lib_folderTree {
73
74 var $ext_IconMode;
75
76 /**
77 * Calls init functions
78 *
79 * @return void
80 */
81 function localFolderTree() {
82 parent::t3lib_folderTree();
83 }
84
85 /**
86 * Wrapping icon in browse tree
87 *
88 * @param string Icon IMG code
89 * @param array Data row for element.
90 * @return string Page icon
91 */
92 function wrapIcon($icon,&$row) {
93
94 // Add title attribute to input icon tag
95 $theFolderIcon = $this->addTagAttributes($icon,($this->titleAttrib ? $this->titleAttrib.'="'.$this->getTitleAttrib($row).'"' : ''));
96
97 // Wrap icon in click-menu link.
98 if (!$this->ext_IconMode) {
99 $theFolderIcon = $GLOBALS['TBE_TEMPLATE']->wrapClickMenuOnIcon($theFolderIcon,$row['path'],'',0);
100 } elseif (!strcmp($this->ext_IconMode,'titlelink')) {
101 $aOnClick = 'return jumpTo(\''.$this->getJumpToParam($row).'\',this,\''.$this->domIdPrefix.$this->getId($row).'\','.$this->bank.');';
102 $theFolderIcon='<a href="#" onclick="'.htmlspecialchars($aOnClick).'">'.$theFolderIcon.'</a>';
103 }
104 // Wrap icon in a drag/drop span.
105 $spanOnDrag = htmlspecialchars('return dragElement("'.$this->getJumpToParam($row).'", "'.$row['uid'].'")');
106 $spanOnDrop = htmlspecialchars('return dropElement("'.$this->getJumpToParam($row).'")');
107 $dragDropIcon = '<span id="dragIconID_'.$row['uid'].'" ondragstart="'.$spanOnDrag.'" onmousedown="'.$spanOnDrag.'" onmouseup="'.$spanOnDrop.'">'.$theFolderIcon.'</span>';
108
109 return $dragDropIcon;
110 }
111
112 /**
113 * Wrapping $title in a-tags.
114 *
115 * @param string Title string
116 * @param string Item record
117 * @param integer Bank pointer (which mount point number)
118 * @return string
119 * @access private
120 */
121 function wrapTitle($title,$row,$bank=0) {
122 $aOnClick = 'return jumpTo(\''.$this->getJumpToParam($row).'\',this,\''.$this->domIdPrefix.$this->getId($row).'\','.$bank.');';
123 $CSM = '';
124 if ($GLOBALS['TYPO3_CONF_VARS']['BE']['useOnContextMenuHandler']) {
125 $CSM = ' oncontextmenu="'.htmlspecialchars($GLOBALS['TBE_TEMPLATE']->wrapClickMenuOnIcon('',$row['path'],'',0,'&bank='.$this->bank,'',TRUE)).'"';
126 }
127 $theFolderTitle='<a href="#" onclick="'.htmlspecialchars($aOnClick).'"'.$CSM.'>'.$title.'</a>';
128
129 // Wrap title in a drag/drop span.
130 $spanOnDrag = htmlspecialchars('return dragElement("'.$this->getJumpToParam($row).'","'.$row['uid'].'")');
131 $spanOnDrop = htmlspecialchars('return dropElement("'.$this->getJumpToParam($row).'")');
132 $dragDropTitle = '<span id="dragTitleID_'.$row['uid'].'" ondragstart="'.$spanOnDrag.'" onmousedown="'.$spanOnDrag.'" onmouseup="'.$spanOnDrop.'">'.$theFolderTitle.'</span>';
133 return $dragDropTitle;
134 }
135 }
136
137
138
139 /**
140 * Main script class for rendering of the folder tree
141 *
142 * @author Kasper Skaarhoj <kasperYYYY@typo3.com>
143 * @package TYPO3
144 * @subpackage core
145 */
146 class SC_alt_file_navframe {
147
148 // Internal, dynamic:
149 var $content; // Content accumulates in this variable.
150 var $foldertree; // Folder tree object.
151 var $doc; // Template object.
152
153 // Internal, static: GPvar:
154 var $currentSubScript;
155 var $cMR;
156
157
158 /**
159 * Initialiation of the script class
160 *
161 * @return void
162 */
163 function init() {
164 global $BE_USER,$BACK_PATH,$CLIENT;
165
166 // Setting GPvars:
167 $this->currentSubScript = t3lib_div::_GP('currentSubScript');
168 $this->cMR = t3lib_div::_GP('cMR');
169
170 // Create folder tree object:
171 $this->foldertree = t3lib_div::makeInstance('localFolderTree');
172 $this->foldertree->ext_IconMode = $BE_USER->getTSConfigVal('options.folderTree.disableIconLinkToContextmenu');
173 $this->foldertree->thisScript = 'alt_file_navframe.php';
174
175 // Setting highlight mode:
176 $this->doHighlight = !$BE_USER->getTSConfigVal('options.pageTree.disableTitleHighlight');
177
178 // Create template object:
179 $this->doc = t3lib_div::makeInstance('template');
180 $this->doc->docType='xhtml_trans';
181
182 // Setting backPath
183 $this->doc->backPath = $BACK_PATH;
184
185 // Setting JavaScript for menu.
186 $this->doc->JScode=$this->doc->wrapScriptTags(
187 ($this->currentSubScript?'top.currentSubScript=unescape("'.rawurlencode($this->currentSubScript).'");':'').'
188
189 // Function, loading the list frame from navigation tree:
190 function jumpTo(id,linkObj,highLightID,bank) { //
191 var theUrl = top.TS.PATH_typo3+top.currentSubScript+"?id="+id;
192 top.fsMod.currentBank = bank;
193
194 if (top.condensedMode) {
195 top.content.location.href=theUrl;
196 } else {
197 parent.list_frame.location.href=theUrl;
198 }
199
200 '.($this->doHighlight?'hilight_row("file",highLightID+"_"+bank);':'').'
201 '.(!$CLIENT['FORMSTYLE'] ? '' : 'if (linkObj) {linkObj.blur();}').'
202 return false;
203 }
204
205
206 // Call this function, refresh_nav(), from another script in the backend if you want to refresh the navigation frame (eg. after having changed a page title or moved pages etc.)
207 // See t3lib_BEfunc::getSetUpdateSignal()
208 function refresh_nav() { //
209 window.setTimeout("_refresh_nav();",0);
210 }
211 function _refresh_nav() { //
212 window.location.href="'.$this->pagetree->thisScript.'?unique='.time().'";
213 }
214
215 // Highlighting rows in the folder tree:
216 function hilight_row(frameSetModule,highLightID) { //
217
218 // Remove old:
219 theObj = document.getElementById(top.fsMod.navFrameHighlightedID[frameSetModule]);
220 if (theObj) {
221 theObj.style.backgroundColor="";
222 }
223
224 // Set new:
225 top.fsMod.navFrameHighlightedID[frameSetModule] = highLightID;
226 theObj = document.getElementById(highLightID);
227 if (theObj) {
228 theObj.style.backgroundColor="'.t3lib_div::modifyHTMLColorAll($this->doc->bgColor,-20).'";
229 }
230 }
231
232 '.($this->cMR?"jumpTo(top.fsMod.recentIds['file'],'');":'').';
233 ');
234
235 // Click menu code is added:
236 $CMparts=$this->doc->getContextMenuCode();
237 $this->doc->bodyTagAdditions = $CMparts[1];
238 $this->doc->JScode.=$CMparts[0];
239 $this->doc->postCode.= $CMparts[2];
240
241 // Drag and Drop code is added:
242 $DDparts=$this->doc->getDragDropCode('folders');
243 // ignore the $DDparts[1] for now
244 $this->doc->JScode.= $DDparts[0];
245 $this->doc->postCode.= $DDparts[2];
246 }
247
248 /**
249 * Main function, rendering the folder tree
250 *
251 * @return void
252 */
253 function main() {
254 global $LANG,$CLIENT;
255
256 // Produce browse-tree:
257 $tree = $this->foldertree->getBrowsableTree();
258
259 $this->content = '';
260 $this->content.= $this->doc->startPage('Folder tree');
261 $this->content.= $tree;
262 $refreshUrl = t3lib_div::getIndpEnv('REQUEST_URI');
263 $this->content.= '
264 <p class="c-refresh">
265 <a href="'.htmlspecialchars($refreshUrl).'">'.
266 '<img'.t3lib_iconWorks::skinImg('','gfx/refresh_n.gif','width="14" height="14"').' title="'.$LANG->sL('LLL:EXT:lang/locallang_core.php:labels.refresh',1).'" alt="" />'.
267 '</a><a href="'.htmlspecialchars($refreshUrl).'">'.
268 $LANG->sL('LLL:EXT:lang/locallang_core.php:labels.refresh',1).'</a>
269 </p>
270 <br />';
271 $this->content.= t3lib_BEfunc::cshItem('xMOD_csh_corebe', 'filetree', $GLOBALS['BACK_PATH']);
272
273 // Adding highlight - JavaScript
274 if ($this->doHighlight) $this->content .=$this->doc->wrapScriptTags('
275 hilight_row("",top.fsMod.navFrameHighlightedID["file"]);
276 ');
277 }
278
279 /**
280 * Outputting the accumulated content to screen
281 *
282 * @return void
283 */
284 function printContent() {
285 $this->content.= $this->doc->endPage();
286 $this->content = $this->doc->insertStylesAndJS($this->content);
287 echo $this->content;
288 }
289 }
290
291 // Include extension?
292 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/alt_file_navframe.php']) {
293 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/alt_file_navframe.php']);
294 }
295
296
297
298
299
300
301
302
303
304
305
306
307 // Make instance:
308 $SOBE = t3lib_div::makeInstance('SC_alt_file_navframe');
309 $SOBE->init();
310 $SOBE->main();
311 $SOBE->printContent();
312 ?>