[CLEANUP] Remove deprecated filemount functions in BE_USER
[Packages/TYPO3.CMS.git] / typo3 / sysext / rtehtmlarea / Classes / Controller / CustomAttributeController.php
1 <?php
2 namespace TYPO3\CMS\Rtehtmlarea\Controller;
3
4 /***************************************************************
5 * Copyright notice
6 *
7 * (c) 2005-2013 Stanislas Rolland <typo3(arobas)sjbr.ca>
8 * All rights reserved
9 *
10 * This script is part of the TYPO3 project. The TYPO3 project is
11 * free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * The GNU General Public License can be found at
17 * http://www.gnu.org/copyleft/gpl.html.
18 * A copy is found in the text file GPL.txt and important notices to the license
19 * from the author is found in LICENSE.txt distributed with these scripts.
20 *
21 *
22 * This script is distributed in the hope that it will be useful,
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 * GNU General Public License for more details.
26 *
27 * This copyright notice MUST APPEAR in all copies of the script!
28 ***************************************************************/
29 /**
30 * Render custom attribute data-htmlarea-clickenlarge
31 *
32 * @author Stanislas Rolland <typo3(arobas)sjbr.ca>
33 */
34 class CustomAttributeController extends \TYPO3\CMS\Frontend\Plugin\AbstractPlugin {
35
36 // Default plugin variables:
37 /**
38 * @todo Define visibility
39 */
40 public $prefixId = 'tx_rtehtmlarea_pi3';
41
42 // Same as class name
43 /**
44 * @todo Define visibility
45 */
46 public $scriptRelPath = 'pi3/class.tx_rtehtmlarea_pi3.php';
47
48 // Path to this script relative to the extension dir.
49 /**
50 * @todo Define visibility
51 */
52 public $extKey = 'rtehtmlarea';
53
54 // The extension key.
55 /**
56 * @todo Define visibility
57 */
58 public $conf = array();
59
60 /**
61 * cObj object
62 *
63 * @var \TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer
64 * @todo Define visibility
65 */
66 public $cObj;
67
68 /**
69 * Rendering the "data-htmlarea-clickenlarge" custom attribute, called from TypoScript
70 *
71 * @param string Content input. Not used, ignore.
72 * @param array TypoScript configuration
73 * @return string HTML output.
74 * @access private
75 * @todo Define visibility
76 */
77 public function render_clickenlarge($content, $conf) {
78 $clickenlarge = isset($this->cObj->parameters['data-htmlarea-clickenlarge']) ? $this->cObj->parameters['data-htmlarea-clickenlarge'] : 0;
79 if (!$clickenlarge) {
80 // Backward compatibility
81 $clickenlarge = isset($this->cObj->parameters['clickenlarge']) ? $this->cObj->parameters['clickenlarge'] : 0;
82 }
83 $fileFactory = \TYPO3\CMS\Core\Resource\ResourceFactory::getInstance();
84 $fileTable = $this->cObj->parameters['data-htmlarea-file-table'];
85 $fileUid = $this->cObj->parameters['data-htmlarea-file-uid'];
86 if ($fileUid) {
87 $fileObject = $fileFactory->getFileObject($fileUid);
88 $filePath = $fileObject->getForLocalProcessing(FALSE);
89 $file = \TYPO3\CMS\Core\Utility\PathUtility::stripPathSitePrefix($filePath);
90 } else {
91 // Pre-FAL backward compatibility
92 $path = $this->cObj->parameters['src'];
93 $magicFolder = $fileFactory->getFolderObjectFromCombinedIdentifier($GLOBALS['TYPO3_CONF_VARS']['BE']['RTE_imageStorageDir']);
94 if ($magicFolder instanceof \TYPO3\CMS\Core\Resource\Folder) {
95 $magicFolderPath = $magicFolder->getPublicUrl();
96 $pathPre = $magicFolderPath . 'RTEmagicC_';
97 if (\TYPO3\CMS\Core\Utility\GeneralUtility::isFirstPartOfStr($path, $pathPre)) {
98 // Find original file:
99 $pI = pathinfo(substr($path, strlen($pathPre)));
100 $filename = substr($pI['basename'], 0, -strlen(('.' . $pI['extension'])));
101 $file = $magicFolderPath . 'RTEmagicP_' . $filename;
102 } else {
103 $file = $this->cObj->parameters['src'];
104 }
105 }
106 }
107 // Unset clickenlarge custom attribute
108 unset($this->cObj->parameters['data-htmlarea-clickenlarge']);
109 // Backward compatibility
110 unset($this->cObj->parameters['clickenlarge']);
111 unset($this->cObj->parameters['allParams']);
112 $content = '<img ' . \TYPO3\CMS\Core\Utility\GeneralUtility::implodeAttributes($this->cObj->parameters, TRUE, TRUE) . ' />';
113 if ($clickenlarge && is_array($conf['imageLinkWrap.'])) {
114 $theImage = $file ? $GLOBALS['TSFE']->tmpl->getFileName($file) : '';
115 if ($theImage) {
116 $this->cObj->parameters['origFile'] = $theImage;
117 if ($this->cObj->parameters['title']) {
118 $conf['imageLinkWrap.']['title'] = $this->cObj->parameters['title'];
119 }
120 if ($this->cObj->parameters['alt']) {
121 $conf['imageLinkWrap.']['alt'] = $this->cObj->parameters['alt'];
122 }
123 $content = $this->cObj->imageLinkWrap($content, $theImage, $conf['imageLinkWrap.']);
124 $content = $this->cObj->stdWrap($content, $conf['stdWrap.']);
125 }
126 }
127 return $content;
128 }
129
130 }