TYPO3 CMS  TYPO3_7-6
CustomAttributeController.php
Go to the documentation of this file.
1 <?php
3 
4 /*
5  * This file is part of the TYPO3 CMS project.
6  *
7  * It is free software; you can redistribute it and/or modify it under
8  * the terms of the GNU General Public License, either version 2
9  * of the License, or any later version.
10  *
11  * For the full copyright and license information, please read the
12  * LICENSE.txt file that was distributed with this source code.
13  *
14  * The TYPO3 project - inspiring people to share!
15  */
16 
21 {
22  // Default plugin variables:
26  public $prefixId = 'tx_rtehtmlarea_pi3';
27 
28  // Same as class name
32  public $scriptRelPath = 'pi3/class.tx_rtehtmlarea_pi3.php';
33 
34  // Path to this script relative to the extension dir.
38  public $extKey = 'rtehtmlarea';
39 
40  // The extension key.
44  public $conf = [];
45 
51  public $cObj;
52 
61  public function render_clickenlarge($content, $conf)
62  {
63  $clickenlarge = isset($this->cObj->parameters['data-htmlarea-clickenlarge']) ? $this->cObj->parameters['data-htmlarea-clickenlarge'] : 0;
64  if (!$clickenlarge) {
65  // Backward compatibility
66  $clickenlarge = isset($this->cObj->parameters['clickenlarge']) ? $this->cObj->parameters['clickenlarge'] : 0;
67  }
69  $fileUid = $this->cObj->parameters['data-htmlarea-file-uid'];
70  if ($fileUid) {
71  $fileObject = $fileFactory->getFileObject($fileUid);
72  $filePath = $fileObject->getForLocalProcessing(false);
74  } else {
75  // Pre-FAL backward compatibility
76  $path = $this->cObj->parameters['src'];
77  $magicFolder = $fileFactory->getFolderObjectFromCombinedIdentifier($GLOBALS['TYPO3_CONF_VARS']['BE']['RTE_imageStorageDir']);
78  if ($magicFolder instanceof \TYPO3\CMS\Core\Resource\Folder) {
79  $magicFolderPath = $magicFolder->getPublicUrl();
80  $pathPre = $magicFolderPath . 'RTEmagicC_';
81  if (\TYPO3\CMS\Core\Utility\GeneralUtility::isFirstPartOfStr($path, $pathPre)) {
82  // Find original file:
83  $pI = pathinfo(substr($path, strlen($pathPre)));
84  $filename = substr($pI['basename'], 0, -strlen(('.' . $pI['extension'])));
85  $file = $magicFolderPath . 'RTEmagicP_' . $filename;
86  } else {
87  $file = $this->cObj->parameters['src'];
88  }
89  }
90  }
91  // Unset clickenlarge custom attribute
92  unset($this->cObj->parameters['data-htmlarea-clickenlarge']);
93  // Backward compatibility
94  unset($this->cObj->parameters['clickenlarge']);
95  unset($this->cObj->parameters['allParams']);
96  $content = '<img ' . \TYPO3\CMS\Core\Utility\GeneralUtility::implodeAttributes($this->cObj->parameters, true, true) . ' />';
97  if ($clickenlarge && is_array($conf['imageLinkWrap.'])) {
98  $theImage = $file ? $this->frontendController->tmpl->getFileName($file) : '';
99  if ($theImage) {
100  $this->cObj->parameters['origFile'] = $theImage;
101  if ($this->cObj->parameters['title']) {
102  $conf['imageLinkWrap.']['title'] = $this->cObj->parameters['title'];
103  }
104  if ($this->cObj->parameters['alt']) {
105  $conf['imageLinkWrap.']['alt'] = $this->cObj->parameters['alt'];
106  }
107  $content = $this->cObj->imageLinkWrap($content, $theImage, $conf['imageLinkWrap.']);
108  $content = $this->cObj->stdWrap($content, $conf['stdWrap.']);
109  }
110  }
111  return $content;
112  }
113 }
static implodeAttributes(array $arr, $xhtmlSafe=false, $dontOmitBlankAttribs=false)
static isFirstPartOfStr($str, $partStr)
if(TYPO3_MODE==='BE') $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tsfebeuserauth.php']['frontendEditingController']['default']