[TASK] Ext:rtehtmlarea entry scripts cleanup
[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 text file 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 * Initialize language files
46 */
47 public function __construct() {
48 $GLOBALS['LANG']->includeLLFile('EXT:lang/locallang_TYPO3\\CMS\\Recordlist\\Browser\\ElementBrowser.xlf');
49 $GLOBALS['LANG']->includeLLFile('EXT:rtehtmlarea/mod4/locallang.xlf');
50 $GLOBALS['LANG']->includeLLFile('EXT:rtehtmlarea/htmlarea/locallang_dialogs.xlf');
51 }
52
53 /**
54 * Main function, rendering the element browser in RTE mode.
55 *
56 * @return void
57 * @todo Define visibility
58 */
59 public function main() {
60 // Setting alternative browsing mounts (ONLY local to browse_links.php this script so they stay "read-only")
61 $altMountPoints = trim($GLOBALS['BE_USER']->getTSConfigVal('options.folderTree.altElementBrowserMountPoints'));
62 if ($altMountPoints) {
63 $altMountPoints = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $altMountPoints);
64 foreach ($altMountPoints as $filePathRelativeToFileadmindir) {
65 $GLOBALS['BE_USER']->addFileMount('', $filePathRelativeToFileadmindir, $filePathRelativeToFileadmindir, 1, 'readonly');
66 }
67 }
68 // Rendering type by user function
69 $browserRendered = FALSE;
70 if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/TYPO3\\CMS\\Recordlist\\Browser\\ElementBrowser.php']['browserRendering'])) {
71 foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/TYPO3\\CMS\\Recordlist\\Browser\\ElementBrowser.php']['browserRendering'] as $classRef) {
72 $browserRenderObj = \TYPO3\CMS\Core\Utility\GeneralUtility::getUserObj($classRef);
73 if (is_object($browserRenderObj) && method_exists($browserRenderObj, 'isValid') && method_exists($browserRenderObj, 'render')) {
74 if ($browserRenderObj->isValid($this->mode, $this)) {
75 $this->content .= $browserRenderObj->render($this->mode, $this);
76 $browserRendered = TRUE;
77 break;
78 }
79 }
80 }
81 }
82 // If type was not rendered, use default rendering functions
83 if (!$browserRendered) {
84 $GLOBALS['SOBE']->browser = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Rtehtmlarea\\SelectImage');
85 $GLOBALS['SOBE']->browser->init();
86 $modData = $GLOBALS['BE_USER']->getModuleData('select_image.php', 'ses');
87 list($modData, $store) = $GLOBALS['SOBE']->browser->processSessionData($modData);
88 $GLOBALS['BE_USER']->pushModuleData('select_image.php', $modData);
89 $this->content = $GLOBALS['SOBE']->browser->main_rte();
90 }
91 }
92
93 /**
94 * Print module content
95 *
96 * @return void
97 * @todo Define visibility
98 */
99 public function printContent() {
100 echo $this->content;
101 }
102
103 }