/**
  * @see	\wcf\form\IForm::save()
  */
 public function save()
 {
     AbstractForm::save();
     // update tag
     $this->objectAction = new TagAction(array($this->tagID), 'update', array('data' => array_merge($this->additionalFields, array('name' => $this->name))));
     $this->objectAction->executeAction();
     if ($this->tagObj->synonymFor === null) {
         // remove synonyms first
         $sql = "UPDATE\twcf" . WCF_N . "_tag\n\t\t\t\tSET\tsynonymFor = ?\n\t\t\t\tWHERE\tsynonymFor = ?";
         $statement = WCF::getDB()->prepareStatement($sql);
         $statement->execute(array(null, $this->tagID));
         $editor = new TagEditor($this->tagObj);
         foreach ($this->synonyms as $synonym) {
             if (empty($synonym)) {
                 continue;
             }
             // find existing tag
             $synonymObj = Tag::getTag($synonym, $this->tagObj->languageID);
             if ($synonymObj === null) {
                 $synonymAction = new TagAction(array(), 'create', array('data' => array('name' => $synonym, 'languageID' => $this->tagObj->languageID, 'synonymFor' => $this->tagID)));
                 $synonymAction->executeAction();
             } else {
                 $editor->addSynonym($synonymObj);
             }
         }
     }
     $this->saved();
     // show success
     WCF::getTPL()->assign(array('success' => true));
 }
Exemple #2
0
 /**
  * @see	\wcf\form\IForm::save()
  */
 public function save()
 {
     parent::save();
     // save tag
     $this->objectAction = new TagAction(array(), 'create', array('data' => array_merge($this->additionalFields, array('name' => $this->name, 'languageID' => $this->languageID))));
     $this->objectAction->executeAction();
     $returnValues = $this->objectAction->getReturnValues();
     $editor = new TagEditor($returnValues['returnValues']);
     foreach ($this->synonyms as $synonym) {
         if (empty($synonym)) {
             continue;
         }
         // find existing tag
         $synonymObj = Tag::getTag($synonym, $this->languageID);
         if ($synonymObj === null) {
             $synonymAction = new TagAction(array(), 'create', array('data' => array('name' => $synonym, 'languageID' => $this->languageID, 'synonymFor' => $editor->tagID)));
             $synonymAction->executeAction();
         } else {
             $editor->addSynonym($synonymObj);
         }
     }
     $this->saved();
     // reset values
     $this->name = '';
     $this->synonyms = array();
     // show success
     WCF::getTPL()->assign(array('success' => true));
 }