/** * Transformation handler: 'txdam_media' / direction: "rte" * Processing linked images from database content going into the RTE. * Processing includes converting the src attribute to an absolute URL. * * @param string Content input * @return string Content output */ function transform_rte($value, &$pObj) { // Split content by the TYPO3 pseudo tag "<media>": $blockSplit = $pObj->splitIntoBlock('media', $value, 1); foreach ($blockSplit as $k => $v) { $error = ''; if ($k % 2) { // block: $tagCode = t3lib_div::unQuoteFilenames(trim(substr($pObj->getFirstTag($v), 0, -1)), true); $link_param = $tagCode[1]; $href = ''; $useDAMColumn = FALSE; // Checking if the id-parameter is int and get meta data if (t3lib_div::testInt($link_param)) { $meta = tx_dam::meta_getDataByUid($link_param); } if (is_array($meta)) { $href = tx_dam::file_url($meta); if (!$tagCode[4]) { require_once PATH_txdam . 'lib/class.tx_dam_guifunc.php'; $displayItems = ''; if (t3lib_div::inList($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['rtehtmlarea']['plugins']['TYPO3Link']['additionalAttributes'], 'usedamcolumn') && $pObj->thisConfig['buttons.']['link.']['media.']['properties.']['title.']['useDAMColumn']) { $displayItems = $pObj->thisConfig['buttons.']['link.']['media.']['properties.']['title.']['useDAMColumn.']['displayItems'] ? $pObj->thisConfig['buttons.']['link.']['media.']['properties.']['title.']['useDAMColumn.']['displayItems'] : ''; $useDAMColumn = TRUE; } $tagCode[4] = tx_dam_guiFunc::meta_compileHoverText($meta, $displayItems, ', '); } } else { $href = $link_param; $error = 'No media file found: ' . $link_param; } // Setting the A-tag: $bTag = '<a href="' . htmlspecialchars($href) . '" txdam="' . htmlspecialchars($link_param) . '"' . ($tagCode[2] && $tagCode[2] != '-' ? ' target="' . htmlspecialchars($tagCode[2]) . '"' : '') . ($tagCode[3] && $tagCode[3] != '-' ? ' class="' . htmlspecialchars($tagCode[3]) . '"' : '') . ($tagCode[4] ? ' title="' . htmlspecialchars($tagCode[4]) . '"' : '') . ($useDAMColumn ? ' usedamcolumn="true"' : '') . ($error ? ' rteerror="' . htmlspecialchars($error) . '" style="background-color: yellow; border:2px red solid; color: black;"' : '') . '>'; $eTag = '</a>'; $blockSplit[$k] = $bTag . $this->transform_rte($pObj->removeFirstAndLastTag($blockSplit[$k]), $pObj) . $eTag; } } $value = implode('', $blockSplit); return $value; }