Fixed bug #14202: htmlArea RTE: Tables may get lost when using remove format feature
[Packages/TYPO3.CMS.git] / typo3 / browse_links.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 1999-2009 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 * Displays the page/file tree for browsing database records or files.
29 * Used from TCEFORMS an other elements
30 * In other words: This is the ELEMENT BROWSER!
31 *
32 * $Id$
33 * Revised for TYPO3 3.6 November/2003 by Kasper Skaarhoj
34 * XHTML compliant
35 *
36 * @author Kasper Skaarhoj <kasperYYYY@typo3.com>
37 */
38 /**
39 * [CLASS/FUNCTION INDEX of SCRIPT]
40 *
41 *
42 *
43 * 78: class SC_browse_links
44 * 99: function init ()
45 * 120: function main()
46 * 174: function printContent()
47 *
48 * TOTAL FUNCTIONS: 3
49 * (This index is automatically created/updated by the extension "extdeveval")
50 *
51 */
52 $BACK_PATH='';
53 require ('init.php');
54 require ('template.php');
55 $LANG->includeLLFile('EXT:lang/locallang_browse_links.xml');
56
57 require_once (PATH_typo3.'/class.browse_links.php');
58
59
60
61
62
63
64
65
66
67
68
69
70
71 /**
72 * Script class for the Element Browser window.
73 *
74 * @author Kasper Skaarhoj <kasperYYYY@typo3.com>
75 * @package TYPO3
76 * @subpackage core
77 */
78 class SC_browse_links {
79
80
81 /**
82 * The mode determines the main kind of output from the element browser.
83 * There are these options for values: rte, db, file, filedrag, wizard.
84 * "rte" will show the link selector for the Rich Text Editor (see main_rte())
85 * "db" will allow you to browse for pages or records in the page tree (for TCEforms, see main_db())
86 * "file"/"filedrag" will allow you to browse for files or folders in the folder mounts (for TCEforms, main_file())
87 * "wizard" will allow you to browse for links (like "rte") which are passed back to TCEforms (see main_rte(1))
88 *
89 * @see main()
90 */
91 var $mode;
92
93 /**
94 * holds Instance of main browse_links class
95 * needed fo intercommunication between various classes that need access to variables via $GLOBALS['SOBE']
96 * Not the most nice solution but introduced since we don't have another general way to return class-instances or registry for now
97 *
98 * @var browse_links
99 */
100 var $browser;
101
102 /**
103 * document template object
104 *
105 * @var template
106 */
107 var $doc;
108
109 /**
110 * not really needed but for backwards compatibility ...
111 *
112 * @return void
113 */
114 function init () {
115
116 // Find "mode"
117 $this->mode = t3lib_div::_GP('mode');
118 if (!$this->mode) {
119 $this->mode = 'rte';
120 }
121
122 // Creating backend template object:
123 // this might not be needed but some classes refer to $GLOBALS['SOBE']->doc, so ...
124 $this->doc = t3lib_div::makeInstance('template');
125 $this->doc->backPath = $GLOBALS['BACK_PATH'];
126 }
127
128
129 /**
130 * Main function, detecting the current mode of the element browser and branching out to internal methods.
131 *
132 * @return void
133 */
134 function main() {
135
136 // Clear temporary DB mounts
137 $tmpMount = t3lib_div::_GET('setTempDBmount');
138 if (isset($tmpMount)) {
139 $GLOBALS['BE_USER']->setAndSaveSessionData('pageTree_temporaryMountPoint', intval($tmpMount));
140 }
141
142 // Set temporary DB mounts
143 $tempDBmount = intval($GLOBALS['BE_USER']->getSessionData('pageTree_temporaryMountPoint'));
144 if ($tempDBmount) {
145 $altMountPoints = $tempDBmount;
146 }
147
148 if ($altMountPoints) {
149 $GLOBALS['BE_USER']->groupData['webmounts'] = implode(',', array_unique(t3lib_div::intExplode(',', $altMountPoints)));
150 $GLOBALS['WEBMOUNTS'] = $GLOBALS['BE_USER']->returnWebmounts();
151 }
152
153 $this->content = '';
154
155 // look for alternativ mountpoints
156 switch((string)$this->mode) {
157 case 'rte':
158 case 'db':
159 case 'wizard':
160 // Setting alternative browsing mounts (ONLY local to browse_links.php this script so they stay "read-only")
161 $altMountPoints = trim($GLOBALS['BE_USER']->getTSConfigVal('options.pageTree.altElementBrowserMountPoints'));
162 if ($altMountPoints) {
163 $GLOBALS['BE_USER']->groupData['webmounts'] = implode(',', array_unique(t3lib_div::intExplode(',', $altMountPoints)));
164 $GLOBALS['WEBMOUNTS'] = $GLOBALS['BE_USER']->returnWebmounts();
165 }
166 case 'file':
167 case 'filedrag':
168 case 'folder':
169 // Setting additional read-only browsing file mounts
170 $altMountPoints = trim($GLOBALS['BE_USER']->getTSConfigVal('options.folderTree.altElementBrowserMountPoints'));
171 if ($altMountPoints) {
172 $altMountPoints = t3lib_div::trimExplode(',', $altMountPoints);
173 foreach($altMountPoints as $filePathRelativeToFileadmindir) {
174 $GLOBALS['BE_USER']->addFileMount('', $filePathRelativeToFileadmindir, $filePathRelativeToFileadmindir, 1, 'readonly');
175 }
176 $GLOBALS['FILEMOUNTS'] = $GLOBALS['BE_USER']->returnFilemounts();
177 }
178 break;
179 }
180
181
182 // render type by user func
183 $browserRendered = false;
184 if (is_array ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/browse_links.php']['browserRendering'])) {
185 foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/browse_links.php']['browserRendering'] as $classRef) {
186 $browserRenderObj = t3lib_div::getUserObj($classRef);
187 if (is_object($browserRenderObj) && method_exists($browserRenderObj, 'isValid') && method_exists($browserRenderObj, 'render')) {
188 if ($browserRenderObj->isValid($this->mode, $this)) {
189 $this->content.= $browserRenderObj->render($this->mode, $this);
190 $browserRendered = true;
191 break;
192 }
193 }
194 }
195 }
196
197 // if type was not rendered use default rendering functions
198 if(!$browserRendered) {
199 $this->browser = t3lib_div::makeInstance('browse_links');
200 $this->browser->init();
201 $modData = $GLOBALS['BE_USER']->getModuleData('browse_links.php', 'ses');
202 list($modData, $store) = $this->browser->processSessionData($modData);
203 $GLOBALS['BE_USER']->pushModuleData('browse_links.php', $modData);
204
205 // Output the correct content according to $this->mode
206 switch((string)$this->mode) {
207 case 'rte':
208 $this->content = $this->browser->main_rte();
209 break;
210 case 'db':
211 $this->content = $this->browser->main_db();
212 break;
213 case 'file':
214 case 'filedrag':
215 $this->content = $this->browser->main_file();
216 break;
217 case 'folder':
218 $this->content = $this->browser->main_folder();
219 break;
220 case 'wizard':
221 $this->content = $this->browser->main_rte(1);
222 break;
223 }
224 }
225 }
226
227 /**
228 * Print module content
229 *
230 * @return void
231 */
232 function printContent() {
233 echo $this->content;
234 }
235
236
237 }
238
239
240
241 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/browse_links.php']) {
242 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/browse_links.php']);
243 }
244
245
246
247 // Make instance:
248 $SOBE = t3lib_div::makeInstance('SC_browse_links');
249 $SOBE->init();
250 $SOBE->main();
251 $SOBE->printContent();
252
253 ?>