示例#1
0
 public function save()
 {
     if (!$this->_contentId) {
         throw new Exception("Cannot save without a content ID");
     }
     if ($this->getErrors()) {
         throw new Exception("Cannot save when there are tagging errors");
     }
     $db = XenForo_Application::getDb();
     XenForo_Db::beginTransaction($db);
     foreach ($this->_newTags as $tag) {
         $id = $this->_tagModel->createTag($tag);
         $this->_addTags[$id] = $tag;
     }
     $cache = $this->_tagModel->adjustContentTags($this->_handler->getContentType(), $this->_contentId, array_keys($this->_addTags), array_keys($this->_removeTags));
     XenForo_Db::commit($db);
     return $cache;
 }
示例#2
0
 public function Tinhte_XenTag_getContentTagCacheOnSave(XenForo_Model_Tag $model, array $cache)
 {
     if (!Tinhte_XenTag_Option::get('keepOrder') || empty($this->_Tinhte_XenTag_orderedTags)) {
         return $cache;
     }
     $cacheOrdered = $model->getFoundTagsInList($this->_Tinhte_XenTag_orderedTags, $cache);
     foreach ($cache as $tagId => $tag) {
         if (!isset($cacheOrdered[$tagId])) {
             $cacheOrdered[$tagId] = $tag;
         }
     }
     return $cacheOrdered;
 }