a41420977c5de0aee93659e82f0a9616989ae08e
[Packages/TYPO3.CMS.git] / typo3 / sysext / rtehtmlarea / pi3 / class.tx_rtehtmlarea_pi3.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 2005-2008 Stanislas Rolland <stanislas.rolland(arobas)fructifor.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 <stanislas.rolland(arobas)fructifor.ca>
31 *
32 * $Id$ *
33 */
34
35 require_once(PATH_tslib.'class.tslib_pibase.php');
36
37 class tx_rtehtmlarea_pi3 extends tslib_pibase {
38
39 // Default plugin variables:
40 var $prefixId = 'tx_rtehtmlarea_pi3'; // Same as class name
41 var $scriptRelPath = 'pi3/class.tx_rtehtmlarea_pi3.php'; // Path to this script relative to the extension dir.
42 var $extKey = 'rtehtmlarea'; // The extension key.
43 var $conf = array();
44
45 /**
46 * cObj object
47 *
48 * @var tslib_cObj
49 */
50 var $cObj;
51
52 /**
53 * Rendering the "clickenlarge" custom attribute, called from TypoScript
54 *
55 * @param string Content input. Not used, ignore.
56 * @param array TypoScript configuration
57 * @return string HTML output.
58 * @access private
59 */
60 function render_clickenlarge($content,$conf) {
61 global $TYPO3_CONF_VARS;
62
63 $clickenlarge = isset($this->cObj->parameters['clickenlarge']) ? $this->cObj->parameters['clickenlarge'] : 0;
64 $path = $this->cObj->parameters['src'];
65 $pathPre = $TYPO3_CONF_VARS['BE']['RTE_imageStorageDir'].'RTEmagicC_';
66 if (t3lib_div::isFirstPartOfStr($path,$pathPre)) {
67 // Find original file:
68 $pI=pathinfo(substr($path,strlen($pathPre)));
69 $filename = substr($pI['basename'],0,-strlen('.'.$pI['extension']));
70 $file = $TYPO3_CONF_VARS['BE']['RTE_imageStorageDir'].'RTEmagicP_'.$filename;
71 } else {
72 $file = $this->cObj->parameters['src'];
73 }
74
75 unset($this->cObj->parameters['clickenlarge']);
76 unset($this->cObj->parameters['allParams']);
77 $content = '<img '. t3lib_div::implodeAttributes($this->cObj->parameters, TRUE, TRUE) . ' />';
78
79 if ($TYPO3_CONF_VARS['EXTCONF'][$this->extKey]['enableClickEnlarge'] && $clickenlarge && is_array($conf['imageLinkWrap.'])) {
80 $theImage = $file ? $GLOBALS['TSFE']->tmpl->getFileName($file) : '';
81 if ($theImage) {
82 if ($this->cObj->parameters['title']) $conf['imageLinkWrap.']['title'] = $this->cObj->parameters['title'];
83 if ($this->cObj->parameters['alt']) $conf['imageLinkWrap.']['alt'] = $this->cObj->parameters['alt'];
84 $content = $this->cObj->imageLinkWrap($content,$theImage,$conf['imageLinkWrap.']);
85 $content = $this->cObj->stdWrap($content,$conf['stdWrap.']);
86 }
87 }
88 return $content;
89 }
90 }
91
92 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/rtehtmlarea/pi3/class.tx_rtehtmlarea_pi3.php']) {
93 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/rtehtmlarea/pi3/class.tx_rtehtmlarea_pi3.php']);
94 }
95
96 ?>