f0bb591c3b79230ec4254a5d377a109a3ed98840
[Packages/TYPO3.CMS.git] / typo3 / sysext / rtehtmlarea / pi3 / class.tx_rtehtmlarea_pi3.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 2005-2011 Stanislas Rolland <typo3(arobas)sjbr.ca>
6 * All rights reserved
7 *
8 * This script is part of the TYPO3 project. The TYPO3 project is
9 * free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * The GNU General Public License can be found at
15 * http://www.gnu.org/copyleft/gpl.html.
16 * A copy is found in the textfile GPL.txt and important notices to the license
17 * from the author is found in LICENSE.txt distributed with these scripts.
18 *
19 *
20 * This script is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
24 *
25 * This copyright notice MUST APPEAR in all copies of the script!
26 ***************************************************************/
27 /**
28 * Render custom attribute clickenlarge
29 *
30 * @author Stanislas Rolland <typo3(arobas)sjbr.ca>
31 */
32 class tx_rtehtmlarea_pi3 extends tslib_pibase {
33
34 // Default plugin variables:
35 var $prefixId = 'tx_rtehtmlarea_pi3'; // Same as class name
36 var $scriptRelPath = 'pi3/class.tx_rtehtmlarea_pi3.php'; // Path to this script relative to the extension dir.
37 var $extKey = 'rtehtmlarea'; // The extension key.
38 var $conf = array();
39
40 /**
41 * cObj object
42 *
43 * @var tslib_cObj
44 */
45 var $cObj;
46
47 /**
48 * Rendering the "clickenlarge" custom attribute, called from TypoScript
49 *
50 * @param string Content input. Not used, ignore.
51 * @param array TypoScript configuration
52 * @return string HTML output.
53 * @access private
54 */
55 function render_clickenlarge($content,$conf) {
56
57 $clickenlarge = isset($this->cObj->parameters['clickenlarge']) ? $this->cObj->parameters['clickenlarge'] : 0;
58 $path = $this->cObj->parameters['src'];
59 $pathPre = $GLOBALS['TYPO3_CONF_VARS']['BE']['RTE_imageStorageDir'] . 'RTEmagicC_';
60 if (t3lib_div::isFirstPartOfStr($path,$pathPre)) {
61 // Find original file:
62 $pI = pathinfo(substr($path,strlen($pathPre)));
63 $filename = substr($pI['basename'],0,-strlen('.'.$pI['extension']));
64 $file = $GLOBALS['TYPO3_CONF_VARS']['BE']['RTE_imageStorageDir'] . 'RTEmagicP_' . $filename;
65 } else {
66 $file = $this->cObj->parameters['src'];
67 }
68
69 unset($this->cObj->parameters['clickenlarge']);
70 unset($this->cObj->parameters['allParams']);
71 $content = '<img '. t3lib_div::implodeAttributes($this->cObj->parameters, TRUE, TRUE) . ' />';
72
73 if ($clickenlarge && is_array($conf['imageLinkWrap.'])) {
74 $theImage = $file ? $GLOBALS['TSFE']->tmpl->getFileName($file) : '';
75 if ($theImage) {
76 $this->cObj->parameters['origFile'] = $theImage;
77 if ($this->cObj->parameters['title']) {
78 $conf['imageLinkWrap.']['title'] = $this->cObj->parameters['title'];
79 }
80 if ($this->cObj->parameters['alt']) {
81 $conf['imageLinkWrap.']['alt'] = $this->cObj->parameters['alt'];
82 }
83 $content = $this->cObj->imageLinkWrap($content,$theImage,$conf['imageLinkWrap.']);
84 $content = $this->cObj->stdWrap($content,$conf['stdWrap.']);
85 }
86 }
87 return $content;
88 }
89 }
90
91 if (defined('TYPO3_MODE') && isset($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/rtehtmlarea/pi3/class.tx_rtehtmlarea_pi3.php'])) {
92 include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/rtehtmlarea/pi3/class.tx_rtehtmlarea_pi3.php']);
93 }
94
95 ?>