<?php /** * eSales Media reveal toolkit for Contao Open Source CMS * * Copyright (C) 2015 eSales Media * * @package eSM_onePage * @link http://www.esales-media.de * @license commercial * * @author Benjamin Roth <benjamin@esales-media.de> */ namespace eSalesMedia\Reveal; class RevealHooks extends \Controller { /** * Array containing all fields which shouldn't use reveal options * @var array */ protected $arrNoReveal = array('__selector__','html'); /** * Hook for adding reveal fields to content elements * @param $strName */ public function eSMLoadDataContainer($strName) { if ($strName != 'tl_content') { return; } // Hook in the reveal fields if (is_array($GLOBALS['TL_DCA']['tl_content']['palettes'])) { foreach (array_keys($GLOBALS['TL_DCA']['tl_content']['palettes']) as $k) { if (!in_array($k,$this->arrNoReveal)) { $strReveal = ';{reveal_legend:hide},eSM_rv_reveal'; $intPos = strpos($GLOBALS['TL_DCA']['tl_content']['palettes'][$k], ';{expert_legend'); $intDupe = strpos($GLOBALS['TL_DCA']['tl_content']['palettes'][$k], ';{reveal_legend:hide'); if ($intPos !== false && $intDupe === false) { $GLOBALS['TL_DCA']['tl_content']['palettes'][$k] = substr($GLOBALS['TL_DCA']['tl_content']['palettes'][$k], 0, $intPos) . $strReveal . substr($GLOBALS['TL_DCA']['tl_content']['palettes'][$k], $intPos); } else if ($intDupe === false) { $GLOBALS['TL_DCA']['tl_content']['palettes'][$k] .= $strReveal; } } } } } }