2 /***************************************************************
5 * (c) 1999-2011 Kasper Skårhøj (kasperYYYY@typo3.com)
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.
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.
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.
25 * This copyright notice MUST APPEAR in all copies of the script!
26 ***************************************************************/
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!
32 * Revised for TYPO3 3.6 November/2003 by Kasper Skårhøj
35 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
39 require ('template.php');
40 $LANG->includeLLFile('EXT:lang/locallang_browse_links.xml');
42 require_once (PATH_typo3
.'/class.browse_links.php');
57 * Script class for the Element Browser window.
59 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
63 class SC_browse_links
{
67 * The mode determines the main kind of output from the element browser.
68 * There are these options for values: rte, db, file, filedrag, wizard.
69 * "rte" will show the link selector for the Rich Text Editor (see main_rte())
70 * "db" will allow you to browse for pages or records in the page tree (for TCEforms, see main_db())
71 * "file"/"filedrag" will allow you to browse for files or folders in the folder mounts (for TCEforms, main_file())
72 * "wizard" will allow you to browse for links (like "rte") which are passed back to TCEforms (see main_rte(1))
79 * holds Instance of main browse_links class
80 * needed fo intercommunication between various classes that need access to variables via $GLOBALS['SOBE']
81 * Not the most nice solution but introduced since we don't have another general way to return class-instances or registry for now
88 * document template object
95 * not really needed but for backwards compatibility ...
102 $this->mode
= t3lib_div
::_GP('mode');
107 // Creating backend template object:
108 // this might not be needed but some classes refer to $GLOBALS['SOBE']->doc, so ...
109 $this->doc
= t3lib_div
::makeInstance('template');
110 $this->doc
->backPath
= $GLOBALS['BACK_PATH'];
115 * Main function, detecting the current mode of the element browser and branching out to internal methods.
121 // Clear temporary DB mounts
122 $tmpMount = t3lib_div
::_GET('setTempDBmount');
123 if (isset($tmpMount)) {
124 $GLOBALS['BE_USER']->setAndSaveSessionData('pageTree_temporaryMountPoint', intval($tmpMount));
127 // Set temporary DB mounts
128 $tempDBmount = intval($GLOBALS['BE_USER']->getSessionData('pageTree_temporaryMountPoint'));
130 $altMountPoints = $tempDBmount;
133 if ($altMountPoints) {
134 $GLOBALS['BE_USER']->groupData
['webmounts'] = implode(',', array_unique(t3lib_div
::intExplode(',', $altMountPoints)));
135 $GLOBALS['WEBMOUNTS'] = $GLOBALS['BE_USER']->returnWebmounts();
140 // look for alternativ mountpoints
141 switch((string)$this->mode
) {
145 // Setting alternative browsing mounts (ONLY local to browse_links.php this script so they stay "read-only")
146 $altMountPoints = trim($GLOBALS['BE_USER']->getTSConfigVal('options.pageTree.altElementBrowserMountPoints'));
147 if ($altMountPoints) {
148 $GLOBALS['BE_USER']->groupData
['webmounts'] = implode(',', array_unique(t3lib_div
::intExplode(',', $altMountPoints)));
149 $GLOBALS['WEBMOUNTS'] = $GLOBALS['BE_USER']->returnWebmounts();
154 // Setting additional read-only browsing file mounts
155 // @todo: add this feature for FAL and TYPO3 6.0
156 $altMountPoints = trim($GLOBALS['BE_USER']->getTSConfigVal('options.folderTree.altElementBrowserMountPoints'));
157 if ($altMountPoints) {
158 $altMountPoints = t3lib_div
::trimExplode(',', $altMountPoints);
159 foreach($altMountPoints as $filePathRelativeToFileadmindir) {
160 $GLOBALS['BE_USER']->addFileMount('', $filePathRelativeToFileadmindir, $filePathRelativeToFileadmindir, 1, 'readonly');
162 $GLOBALS['FILEMOUNTS'] = $GLOBALS['BE_USER']->returnFilemounts();
168 // render type by user func
169 $browserRendered = FALSE;
170 if (is_array ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/browse_links.php']['browserRendering'])) {
171 foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/browse_links.php']['browserRendering'] as $classRef) {
172 $browserRenderObj = t3lib_div
::getUserObj($classRef);
173 if (is_object($browserRenderObj) && method_exists($browserRenderObj, 'isValid') && method_exists($browserRenderObj, 'render')) {
174 if ($browserRenderObj->isValid($this->mode
, $this)) {
175 $this->content
.= $browserRenderObj->render($this->mode
, $this);
176 $browserRendered = TRUE;
183 // if type was not rendered use default rendering functions
184 if(!$browserRendered) {
185 $this->browser
= t3lib_div
::makeInstance('browse_links');
186 $this->browser
->init();
187 $modData = $GLOBALS['BE_USER']->getModuleData('browse_links.php', 'ses');
188 list($modData, $store) = $this->browser
->processSessionData($modData);
189 $GLOBALS['BE_USER']->pushModuleData('browse_links.php', $modData);
191 // Output the correct content according to $this->mode
192 switch((string)$this->mode
) {
194 $this->content
= $this->browser
->main_rte();
197 $this->content
= $this->browser
->main_db();
201 $this->content
= $this->browser
->main_file();
204 $this->content
= $this->browser
->main_folder();
207 $this->content
= $this->browser
->main_rte(1);
214 * Print module content
218 function printContent() {
224 $SOBE = t3lib_div
::makeInstance('SC_browse_links');
227 $SOBE->printContent();