[TASK] Merge submodule fluid into core
[Packages/TYPO3.CMS.git] / typo3 / sysext / rtehtmlarea / Classes / Controller / SelectImageController.php
1 <?php
2 namespace TYPO3\CMS\Rtehtmlarea\Controller;
3
4 /***************************************************************
5 * Copyright notice
6 *
7 * (c) 1999-2013 Kasper Skårhøj (kasper@typo3.com)
8 * (c) 2004-2013 Stanislas Rolland <typo3(arobas)jbr.ca>
9 * All rights reserved
10 *
11 * This script is part of the TYPO3 project. The TYPO3 project is
12 * free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
16 *
17 * The GNU General Public License can be found at
18 * http://www.gnu.org/copyleft/gpl.html.
19 * A copy is found in the textfile GPL.txt and important notices to the license
20 * from the author is found in LICENSE.txt distributed with these scripts.
21 *
22 *
23 * This script is distributed in the hope that it will be useful,
24 * but WITHOUT ANY WARRANTY; without even the implied warranty of
25 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26 * GNU General Public License for more details.
27 *
28 * This copyright notice MUST APPEAR in all copies of the script!
29 ***************************************************************/
30
31 /**
32 * Script class for the Element Browser window.
33 *
34 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
35 */
36 class SelectImageController {
37
38 public $mode = 'rte';
39
40 public $button = 'image';
41
42 protected $content = '';
43
44 /**
45 * Main function, rendering the element browser in RTE mode.
46 *
47 * @return void
48 * @todo Define visibility
49 */
50 public function main() {
51 // Setting alternative browsing mounts (ONLY local to browse_links.php this script so they stay "read-only")
52 $altMountPoints = trim($GLOBALS['BE_USER']->getTSConfigVal('options.folderTree.altElementBrowserMountPoints'));
53 if ($altMountPoints) {
54 $altMountPoints = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $altMountPoints);
55 foreach ($altMountPoints as $filePathRelativeToFileadmindir) {
56 $GLOBALS['BE_USER']->addFileMount('', $filePathRelativeToFileadmindir, $filePathRelativeToFileadmindir, 1, 'readonly');
57 }
58 $GLOBALS['BE_USER']->getFileStorages();
59 $GLOBALS['FILEMOUNTS'] = $GLOBALS['BE_USER']->groupData['filemounts'];
60 }
61 // Rendering type by user function
62 $browserRendered = FALSE;
63 if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/TYPO3\\CMS\\Recordlist\\Browser\\ElementBrowser.php']['browserRendering'])) {
64 foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/TYPO3\\CMS\\Recordlist\\Browser\\ElementBrowser.php']['browserRendering'] as $classRef) {
65 $browserRenderObj = \TYPO3\CMS\Core\Utility\GeneralUtility::getUserObj($classRef);
66 if (is_object($browserRenderObj) && method_exists($browserRenderObj, 'isValid') && method_exists($browserRenderObj, 'render')) {
67 if ($browserRenderObj->isValid($this->mode, $this)) {
68 $this->content .= $browserRenderObj->render($this->mode, $this);
69 $browserRendered = TRUE;
70 break;
71 }
72 }
73 }
74 }
75 // If type was not rendered, use default rendering functions
76 if (!$browserRendered) {
77 $GLOBALS['SOBE']->browser = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Rtehtmlarea\\SelectImage');
78 $GLOBALS['SOBE']->browser->init();
79 $modData = $GLOBALS['BE_USER']->getModuleData('select_image.php', 'ses');
80 list($modData, $store) = $GLOBALS['SOBE']->browser->processSessionData($modData);
81 $GLOBALS['BE_USER']->pushModuleData('select_image.php', $modData);
82 $this->content = $GLOBALS['SOBE']->browser->main_rte();
83 }
84 }
85
86 /**
87 * Print module content
88 *
89 * @return void
90 * @todo Define visibility
91 */
92 public function printContent() {
93 echo $this->content;
94 }
95
96 }
97
98
99 ?>