/** * Contao Open Source CMS * * @copyright MEN AT WORK 2013 * @package semantic_html5 * @license GNU/LGPL * @filesource */ /** * Table tl_content */ SemanticHTML5Content::initDataContainer(); /** * Palettes */ if (SemanticHTML5Content::checkForTag()) { $GLOBALS['TL_DCA']['tl_content']['palettes']['semantic_html5'] = '{type_legend},type,headline;{html5_legend},sh5_type,sh5_additional;{protected_legend:hide},protected;{expert_legend:hide},guests,invisible,cssID,space'; } else { $GLOBALS['TL_DCA']['tl_content']['palettes']['semantic_html5'] = '{type_legend}'; } /** * Callbacks */ $GLOBALS['TL_DCA']['tl_content']['config']['onsubmit_callback'][] = array('SemanticHTML5Content', 'onsubmitCallback'); $GLOBALS['TL_DCA']['tl_content']['config']['ondelete_callback'][] = array('SemanticHTML5Content', 'ondeleteCallback'); $GLOBALS['TL_DCA']['tl_content']['config']['oncopy_callback'][] = array('SemanticHTML5Helper', 'onContentCopyCallback'); /** * Fields */ $GLOBALS['TL_DCA']['tl_content']['fields']['sh5_type'] = array('label' => &$GLOBALS['TL_LANG']['tl_content']['sh5_type'], 'inputType' => 'select', 'options_callback' => array('SemanticHTML5Content', 'optionsCallbackType'), 'eval' => array('submitOnChange' => true, 'mandatory' => true, 'includeBlankOption' => true)); $GLOBALS['TL_DCA']['tl_content']['fields']['sh5_additional'] = array('label' => &$GLOBALS['TL_LANG']['tl_content']['sh5_additional'], 'exclude' => true, 'inputType' => 'multiColumnWizard', 'eval' => array('tl_class' => 'clr', 'columnFields' => array('property' => array('label' => &$GLOBALS['TL_LANG']['tl_content']['sh5_additional']['property'], 'inputType' => 'text', 'eval' => array('style' => 'width:290px', 'nospace' => true, 'rgxp' => 'alnum')), 'value' => array('label' => &$GLOBALS['TL_LANG']['tl_content']['sh5_additional']['value'], 'inputType' => 'text', 'eval' => array('style' => 'width:290px', 'nospace' => true)))));
/** * Add the type of content element * @param array * @return string */ public function addCteType($arrRow) { $callback = static::$defaultAddCteTypeCallback; $callbackObject = in_array('getInstance', get_class_methods($callback[0])) ? $callback[0]::getInstance() : new $callback[0](); $callbackMethod = static::$defaultAddCteTypeCallback[1]; // Build level for all elements if (self::$arrContentElements == null) { $arrSh5Stack = array(); self::$arrContentElements = array(); // Support GlobalContentelements extension if installed $where = array('', null); if (in_array('GlobalContentelements', $this->Config->getActiveModules())) { $where = array(' AND do=?', $this->Input->get('do')); } $arrResult = $this->Database->prepare('SELECT * FROM tl_content WHERE pid=?' . $where[0] . ' ORDER BY sorting')->execute($this->Input->get('id'), $where[1])->fetchAllAssoc(); foreach ($arrResult as $value) { // Check for sh5 start and end tags if ($value['type'] == 'semantic_html5' && $value['sh5_tag'] == 'start') { $arrSh5Stack[$value['id']] = true; } // Add level setting if (count($arrSh5Stack) != 0) { self::$arrContentElements[$value['id']] = count($arrSh5Stack); } if ($value['type'] == 'semantic_html5' && $value['sh5_tag'] == 'end') { unset($arrSh5Stack[$value['sh5_pid']]); } } } $strReturn = ''; // Add rendering settings if (count(self::$arrContentElements) != 0 && array_key_exists($arrRow['id'], self::$arrContentElements)) { $intLevel = self::$arrContentElements[$arrRow['id']]; if ($arrRow['type'] == 'semantic_html5') { for ($i = 0; $i < $intLevel; $i++) { if ($i == 0) { $strReturn .= '<div>'; } else { $strReturn .= '<div>'; } } $strReturn .= $callbackObject->{$callbackMethod}($arrRow); if ($arrRow['type'] == 'semantic_html5') { $strReturn = $this->colorize($strReturn, $arrRow); $strReturn = str_replace('limit_height', '', $strReturn); $strReturn = str_replace('h64', '', $strReturn); } for ($i = 0; $i < $intLevel; $i++) { $strReturn .= '</div>'; } } else { for ($i = 0; $i < $intLevel + 1; $i++) { if ($i == 0) { $strReturn .= '<div>'; } else { $strReturn .= '<div>'; } } $strReturn .= $callbackObject->{$callbackMethod}($arrRow); if ($arrRow['type'] == 'semantic_html5') { $strReturn = $this->colorize($strReturn, $arrRow); $strReturn = str_replace('limit_height', '', $strReturn); $strReturn = str_replace('h64', '', $strReturn); } for ($i = 0; $i < $intLevel + 1; $i++) { $strReturn .= '</div>'; } } } else { $strReturn = $callbackObject->{$callbackMethod}($arrRow); if ($arrRow['type'] == 'semantic_html5') { $strReturn = $this->colorize($strReturn, $arrRow); $strReturn = str_replace('limit_height', '', $strReturn); $strReturn = str_replace('h64', '', $strReturn); } } return $strReturn; }