Example #1
0
 /**
  * @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));
 }
Example #2
0
 /**
  * Adds the given tag, and all of it's synonyms as a synonym.
  * 
  * @param	\wcf\data\tag\Tag	$synonym
  */
 public function addSynonym(Tag $synonym)
 {
     if ($synonym->tagID == $this->tagID) {
         return;
     }
     // assign all associations for the synonym with this tag
     $sql = "UPDATE IGNORE\twcf" . WCF_N . "_tag_to_object\n\t\t\tSET\t\ttagID = ?\n\t\t\tWHERE\t\ttagID = ?";
     $statement = WCF::getDB()->prepareStatement($sql);
     $statement->execute(array($this->tagID, $synonym->tagID));
     // remove remaining associations (object was tagged with both tags => duplicate key previously ignored)
     $sql = "DELETE FROM\twcf" . WCF_N . "_tag_to_object\n\t\t\tWHERE\t\ttagID = ?";
     $statement = WCF::getDB()->prepareStatement($sql);
     $statement->execute(array($synonym->tagID));
     $editor = new TagEditor($synonym);
     $editor->update(array('synonymFor' => $this->tagID));
     $synonymList = new TagList();
     $synonymList->getConditionBuilder()->add('synonymFor = ?', array($synonym->tagID));
     $synonymList->readObjects();
     foreach ($synonymList as $synonym) {
         $this->addSynonym($synonym);
     }
 }
Example #3
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));
 }