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