* Updated prototype.js to version 1.5.0
[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 $BACK_PATH = '';
58 require('init.php');
59 require('template.php');
60 require_once('class.filelistfoldertree.php');
61
62
63 /**
64 * Main script class for rendering of the folder tree
65 *
66 * @author Kasper Skaarhoj <kasperYYYY@typo3.com>
67 * @package TYPO3
68 * @subpackage core
69 */
70 class SC_alt_file_navframe {
71
72 // Internal, dynamic:
73 var $content; // Content accumulates in this variable.
74 var $foldertree; // Folder tree object.
75 var $doc; // Template object.
76 var $backPath;
77
78 // Internal, static: GPvar:
79 var $ajax; // Is set, if an AJAX call should be handled.
80 var $currentSubScript;
81 var $cMR;
82
83
84 /**
85 * Initialiation of the script class
86 *
87 * @return void
88 */
89 function init() {
90 global $BE_USER,$BACK_PATH,$CLIENT;
91
92 // Setting backPath
93 $this->backPath = $BACK_PATH;
94 $this->doc->backPath = $BACK_PATH;
95
96 // Setting GPvars:
97 $this->ajax = t3lib_div::_GP('ajax');
98 $this->currentSubScript = t3lib_div::_GP('currentSubScript');
99 $this->cMR = t3lib_div::_GP('cMR');
100
101 // Create folder tree object:
102 $this->foldertree = t3lib_div::makeInstance('filelistFolderTree');
103 $this->foldertree->ext_IconMode = $BE_USER->getTSConfigVal('options.folderTree.disableIconLinkToContextmenu');
104 $this->foldertree->thisScript = 'alt_file_navframe.php';
105
106 // Use template rendering only if this is a non-AJAX call:
107 if (!$this->ajax) {
108 // Setting highlight mode:
109 $this->doHighlight = !$BE_USER->getTSConfigVal('options.pageTree.disableTitleHighlight');
110
111 // Create template object:
112 $this->doc = t3lib_div::makeInstance('template');
113 $this->doc->docType = 'xhtml_trans';
114
115 // Adding javascript code for AJAX (prototype), drag&drop and the pagetree
116 $this->doc->JScode = '
117 <script type="text/javascript" src="'.$this->backPath.'contrib/prototype.js"></script>
118 <script type="text/javascript" src="'.$this->backPath.'tree.js"></script>'."\n";
119
120 // Setting JavaScript for menu.
121 $this->doc->JScode .= $this->doc->wrapScriptTags(
122 ($this->currentSubScript?'top.currentSubScript=unescape("'.rawurlencode($this->currentSubScript).'");':'').'
123
124 // setting prefs for pagetree and drag & drop
125 Tree.thisScript = "'.$this->foldertree->thisScript.'";
126 DragDrop.changeURL = "'.$this->backPath.'alt_clickmenu.php";
127 DragDrop.backPath = "'.t3lib_div::shortMD5(''.'|'.$GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey']).'";
128 DragDrop.table = "folders";
129
130 // Function, loading the list frame from navigation tree:
131 function jumpTo(id, linkObj, highlightID, bank) {
132 var theUrl = top.TS.PATH_typo3 + top.currentSubScript + "?id=" + id;
133 top.fsMod.currentBank = bank;
134
135 if (top.condensedMode) top.content.location.href = theUrl;
136 else parent.list_frame.location.href = theUrl;
137
138 '.($this->doHighlight ? 'Tree.highlightActiveItem("file", highlightID + "_" + bank);' : '').'
139 '.(!$GLOBALS['CLIENT']['FORMSTYLE'] ? '' : 'if (linkObj) linkObj.blur(); ').'
140 return false;
141 }
142 '.($this->cMR ? " jumpTo(top.fsMod.recentIds['file'],'');" : '')
143 );
144
145 // Click menu code is added:
146 $CMparts=$this->doc->getContextMenuCode();
147 $this->doc->bodyTagAdditions = $CMparts[1];
148 $this->doc->JScode.= $CMparts[0];
149 $this->doc->postCode.= $CMparts[2];
150 }
151 }
152
153 /**
154 * Main function, rendering the folder tree
155 *
156 * @return void
157 */
158 function main() {
159 global $LANG,$CLIENT;
160
161 // Produce browse-tree:
162 $tree = $this->foldertree->getBrowsableTree();
163
164 // Output only the tree if this is an AJAX call:
165 if ($this->ajax) {
166 $this->content = $LANG->csConvObj->utf8_encode($tree, $LANG->charSet);
167 return;
168 }
169
170 $this->content = $this->doc->startPage('TYPO3 Folder Tree');
171
172 // Outputting page tree:
173 $this->content.= $tree;
174
175 // Outputting refresh-link
176 $this->content.= '
177 <p class="c-refresh">
178 <a href="'.htmlspecialchars(t3lib_div::getIndpEnv('REQUEST_URI')).'">'.
179 '<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="" />'.
180 $LANG->sL('LLL:EXT:lang/locallang_core.php:labels.refresh',1).'</a>
181 </p>
182 <br />';
183
184 // CSH icon:
185 $this->content.= t3lib_BEfunc::cshItem('xMOD_csh_corebe', 'filetree', $GLOBALS['BACK_PATH']);
186
187 // Adding javascript for drag & drop activation and highlighting
188 $this->content .=$this->doc->wrapScriptTags('
189 '.($this->doHighlight ? 'Tree.highlightActiveItem("", top.fsMod.navFrameHighlightedID["file"]);' : '').'
190 '.(!$this->doc->isCMlayers() ? 'Tree.activateDragDrop = false;' : 'Tree.registerDragDropHandlers();')
191 );
192
193 }
194
195 /**
196 * Outputting the accumulated content to screen
197 *
198 * @return void
199 */
200 function printContent() {
201 // If we handle an AJAX call, send headers:
202 if ($this->ajax) {
203 header('Content-type: text/html; charset=utf-8');
204 // If it's the regular call to fully output the tree:
205 } else {
206 $this->content.= $this->doc->endPage();
207 $this->content = $this->doc->insertStylesAndJS($this->content);
208 }
209 echo $this->content;
210 }
211 }
212
213 // Include extension?
214 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/alt_file_navframe.php']) {
215 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/alt_file_navframe.php']);
216 }
217
218
219
220
221
222
223
224
225
226
227
228
229 // Make instance:
230 $SOBE = t3lib_div::makeInstance('SC_alt_file_navframe');
231 $SOBE->init();
232 $SOBE->main();
233 $SOBE->printContent();
234 ?>