/** * 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; }