Beispiel #1
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);
     }
 }
Beispiel #2
0
 /**
  * @see	\wcf\page\IPage::readData()
  */
 public function readData()
 {
     $this->languageID = $this->tagObj->languageID;
     parent::readData();
     if (empty($_POST)) {
         $this->name = $this->tagObj->name;
         $this->languageID = $this->tagObj->languageID;
     }
     $synonymList = new TagList();
     $synonymList->getConditionBuilder()->add('synonymFor = ?', array($this->tagObj->tagID));
     $synonymList->readObjects();
     $this->synonyms = array();
     foreach ($synonymList as $synonym) {
         $this->synonyms[] = $synonym->name;
     }
 }