/** * @see \wcf\form\IForm::save() */ public function save() { AbstractForm::save(); if ($this->showButton) { $this->buttonLabel = 'wcf.bbcode.buttonLabel' . $this->bbcode->bbcodeID; if (I18nHandler::getInstance()->isPlainValue('buttonLabel')) { I18nHandler::getInstance()->remove($this->buttonLabel); $this->buttonLabel = I18nHandler::getInstance()->getValue('buttonLabel'); } else { I18nHandler::getInstance()->save('buttonLabel', $this->buttonLabel, 'wcf.bbcode', 1); } } // update bbcode $this->objectAction = new BBCodeAction(array($this->bbcodeID), 'update', array('data' => array_merge($this->additionalFields, array('allowedChildren' => $this->allowedChildren, 'bbcodeTag' => $this->bbcodeTag, 'buttonLabel' => $this->buttonLabel, 'className' => $this->className, 'htmlClose' => $this->htmlClose, 'htmlOpen' => $this->htmlOpen, 'isSourceCode' => $this->isSourceCode ? 1 : 0, 'showButton' => $this->showButton ? 1 : 0, 'wysiwygIcon' => $this->wysiwygIcon)))); $this->objectAction->executeAction(); // clear existing attributes $sql = "DELETE FROM\twcf" . WCF_N . "_bbcode_attribute\n\t\t\tWHERE\t\tbbcodeID = ?"; $statement = WCF::getDB()->prepareStatement($sql); $statement->execute(array($this->bbcodeID)); foreach ($this->attributes as $attribute) { $attributeAction = new BBCodeAttributeAction(array(), 'create', array('data' => array('bbcodeID' => $this->bbcodeID, 'attributeNo' => $attribute->attributeNo, 'attributeHtml' => $attribute->attributeHtml, 'validationPattern' => $attribute->validationPattern, 'required' => $attribute->required, 'useText' => $attribute->useText))); $attributeAction->executeAction(); } $this->saved(); // show success WCF::getTPL()->assign(array('success' => true)); }
/** * @see \wcf\form\IForm::save() */ public function save() { parent::save(); // save bbcode $this->objectAction = new BBCodeAction(array(), 'create', array('data' => array_merge($this->additionalFields, array('allowedChildren' => $this->allowedChildren, 'bbcodeTag' => $this->bbcodeTag, 'buttonLabel' => $this->buttonLabel, 'className' => $this->className, 'htmlOpen' => $this->htmlOpen, 'htmlClose' => $this->htmlClose, 'isSourceCode' => $this->isSourceCode ? 1 : 0, 'packageID' => 1, 'showButton' => $this->showButton ? 1 : 0, 'wysiwygIcon' => $this->wysiwygIcon)))); $returnValues = $this->objectAction->executeAction(); foreach ($this->attributes as $attribute) { $attributeAction = new BBCodeAttributeAction(array(), 'create', array('data' => array('bbcodeID' => $returnValues['returnValues']->bbcodeID, 'attributeNo' => $attribute->attributeNo, 'attributeHtml' => $attribute->attributeHtml, 'validationPattern' => $attribute->validationPattern, 'required' => $attribute->required, 'useText' => $attribute->useText))); $attributeAction->executeAction(); } if ($this->showButton && !I18nHandler::getInstance()->isPlainValue('buttonLabel')) { $bbcodeID = $returnValues['returnValues']->bbcodeID; I18nHandler::getInstance()->save('buttonLabel', 'wcf.bbcode.buttonLabel' . $bbcodeID, 'wcf.bbcode', 1); // update button label $bbcodeEditor = new BBCodeEditor($returnValues['returnValues']); $bbcodeEditor->update(array('buttonLabel' => 'wcf.bbcode.buttonLabel' . $bbcodeID)); } $this->saved(); // reset values $this->bbcodeTag = $this->htmlOpen = $this->htmlClose = $this->className = $this->buttonLabel = $this->wysiwygIcon = ''; $this->allowedChildren = 'all'; $this->attributes = array(); $this->isSourceCode = $this->showButton = false; I18nHandler::getInstance()->reset(); // show success WCF::getTPL()->assign(array('success' => true)); }