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