Cleanup: Updated copyright comments
[Packages/TYPO3.CMS.git] / typo3 / sysext / rtehtmlarea / mod3 / browse_links.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 1999-2011 Kasper Skårhøj (kasperYYYY@typo3.com)
6 * (c) 2005-2011 Stanislas Rolland <typo3(arobas)sjbr.ca>
7 * All rights reserved
8 *
9 * This script is part of the TYPO3 project. The TYPO3 project is
10 * free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * The GNU General Public License can be found at
16 * http://www.gnu.org/copyleft/gpl.html.
17 * A copy is found in the textfile GPL.txt and important notices to the license
18 * from the author is found in LICENSE.txt distributed with these scripts.
19 *
20 *
21 * This script is distributed in the hope that it will be useful,
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 * GNU General Public License for more details.
25 *
26 * This copyright notice MUST APPEAR in all copies of the script!
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 * Adapted for htmlArea RTE by Stanislas Rolland
34 *
35 * $Id$
36 *
37 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
38 * @author Stanislas Rolland <typo3(arobas)sjbr.ca>
39 */
40
41 error_reporting (E_ALL ^ E_NOTICE);
42 unset($MCONF);
43 require('conf.php');
44 require($BACK_PATH.'init.php');
45 require($BACK_PATH.'template.php');
46 $LANG->includeLLFile('EXT:rtehtmlarea/mod3/locallang.xml');
47 $LANG->includeLLFile('EXT:rtehtmlarea/htmlarea/locallang_dialogs.xml');
48
49 /**
50 * Script class for the Element Browser window.
51 *
52 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
53 * @package TYPO3
54 * @subpackage core
55 */
56 class tx_rtehtmlarea_SC_browse_links {
57 public $mode = 'rte';
58 public $button = 'link';
59 protected $content = '';
60
61 /**
62 * Main function, rendering the element browser in RTE mode.
63 *
64 * @return void
65 */
66 function main() {
67 // Setting alternative web browsing mounts (ONLY local to browse_links.php this script so they stay "read-only")
68 $altMountPoints = trim($GLOBALS['BE_USER']->getTSConfigVal('options.pageTree.altElementBrowserMountPoints'));
69
70 // Clear temporary DB mounts
71 $tmpMount = t3lib_div::_GET('setTempDBmount');
72 if (isset($tmpMount)) {
73 $GLOBALS['BE_USER']->setAndSaveSessionData('pageTree_temporaryMountPoint', intval($tmpMount));
74 }
75
76 // Set temporary DB mounts
77 $tempDBmount = intval($GLOBALS['BE_USER']->getSessionData('pageTree_temporaryMountPoint'));
78 if ($tempDBmount) {
79 $altMountPoints = $tempDBmount;
80 }
81
82 if ($altMountPoints) {
83 $GLOBALS['BE_USER']->groupData['webmounts'] = implode(',', array_unique(t3lib_div::intExplode(',', $altMountPoints)));
84 $GLOBALS['WEBMOUNTS'] = $GLOBALS['BE_USER']->returnWebmounts();
85 }
86 // Setting alternative file browsing mounts (ONLY local to browse_links.php this script so they stay "read-only")
87 $altMountPoints = trim($GLOBALS['BE_USER']->getTSConfigVal('options.folderTree.altElementBrowserMountPoints'));
88 if ($altMountPoints) {
89 $altMountPoints = t3lib_div::trimExplode(',', $altMountPoints);
90 foreach ($altMountPoints as $filePathRelativeToFileadmindir) {
91 $GLOBALS['BE_USER']->addFileMount('', $filePathRelativeToFileadmindir, $filePathRelativeToFileadmindir, 1, 'readonly');
92 }
93 $GLOBALS['FILEMOUNTS'] = $GLOBALS['BE_USER']->returnFilemounts();
94 }
95 // Render type by user function
96 $browserRendered = false;
97 if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/browse_links.php']['browserRendering'])) {
98 foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/browse_links.php']['browserRendering'] as $classRef) {
99 $browserRenderObj = t3lib_div::getUserObj($classRef);
100 if (is_object($browserRenderObj) && method_exists($browserRenderObj, 'isValid') && method_exists($browserRenderObj, 'render')) {
101 if ($browserRenderObj->isValid($this->mode, $this)) {
102 $this->content .= $browserRenderObj->render($this->mode, $this);
103 $browserRendered = true;
104 break;
105 }
106 }
107 }
108 }
109 // If type was not rendered, use default rendering functions
110 if (!$browserRendered) {
111 $GLOBALS['SOBE']->browser = t3lib_div::makeInstance('tx_rtehtmlarea_browse_links');
112 $GLOBALS['SOBE']->browser->init();
113 $modData = $GLOBALS['BE_USER']->getModuleData('browse_links.php','ses');
114 list($modData, $store) = $GLOBALS['SOBE']->browser->processSessionData($modData);
115 $GLOBALS['BE_USER']->pushModuleData('browse_links.php',$modData);
116 $this->content = $GLOBALS['SOBE']->browser->main_rte();
117 }
118 }
119
120 /**
121 * Print module content
122 *
123 * @return void
124 */
125 function printContent() {
126 echo $this->content;
127 }
128 }
129
130 if (defined('TYPO3_MODE') && isset($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/rtehtmlarea/mod3/browse_links.php'])) {
131 include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/rtehtmlarea/mod3/browse_links.php']);
132 }
133
134 // Make instance:
135 $SOBE = t3lib_div::makeInstance('tx_rtehtmlarea_SC_browse_links');
136 $SOBE->main();
137 $SOBE->printContent();
138
139 ?>