/** * Get instanz of the object (Singelton) * * @return SemanticHTML5Helper */ public static function getInstance() { if (self::$objInstance == NULL) { self::$objInstance = new SemanticHTML5Helper(); } return self::$objInstance; }
/** * Insert tl_content semantic_html5_end element after the current if not exists and update if exists * * @param DataContainer $dc */ public function onsubmitCallback(DataContainer $dc) { // Get current record $objElement = $dc->activeRecord; // Check if we have a semantic_html5 start element if ($objElement->type == 'semantic_html5' && $objElement->sh5_tag == 'start') { if ($objElement->id != $objElement->sh5_pid) { $this->Database->prepare("UPDATE tl_content %s WHERE id = ?")->set(array('sh5_pid' => $objElement->id))->executeUncached($objElement->id); } // Check if we have allready a semantic_html end tag $objElementEnd = $this->Database->prepare("SELECT * FROM tl_content WHERE sh5_pid = ? AND type = 'semantic_html5' AND sh5_tag = 'end'")->limit(1)->execute($objElement->id); // If we have no end tag, create one if ($objElementEnd->numRows == 0) { SemanticHTML5Helper::getInstance()->createEndTag($objElement); } else { // Update endTag with sh5_type $this->Database->prepare("UPDATE tl_content %s WHERE sh5_pid = ?")->set(array('sh5_type' => $objElement->sh5_type, 'sh5_additional' => $objElement->sh5_additional))->executeUncached($objElement->id); } } else { $objElementsEnd = $this->Database->prepare("SELECT * FROM tl_content WHERE sh5_pid = ? AND type = 'semantic_html5' AND sh5_tag = 'end'")->execute($objElement->id); if ($objElementsEnd->numRows != 0) { while ($objElementsEnd->next()) { $this->insertUndo("DELETE FROM tl_content WHERE id = " . $objElementsEnd->id, "SELECT * FROM tl_content WHERE id = " . $objElementsEnd->id, "tl_content"); $this->Database->prepare("DELETE FROM tl_content WHERE id = ?")->execute($objElementsEnd->id); } } } }