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