コード例 #1
0
ファイル: Resource.php プロジェクト: Sywooch/forums
 protected function _Tinhte_XenTag_updateTagsInDatabase()
 {
     $force = $this->getExtraData(self::DATA_FORCE_UPDATE_TAGS_IN_DATABASE);
     $skip = $this->getExtraData(self::DATA_SKIP_UPDATE_TAGS_IN_DATABASE);
     if ($force or $this->isChanged(Tinhte_XenTag_Constants::FIELD_RESOURCE_TAGS) and empty($skip)) {
         $tagsOrTexts = Tinhte_XenTag_Helper::unserialize($this->get(Tinhte_XenTag_Constants::FIELD_RESOURCE_TAGS));
         $tagTexts = Tinhte_XenTag_Helper::getTextsFromTagsOrTexts($tagsOrTexts);
         $updated = Tinhte_XenTag_Integration::updateTags(Tinhte_XenTag_Constants::CONTENT_TYPE_RESOURCE, $this->get('resource_id'), XenForo_Visitor::getUserId(), $tagTexts, $this);
         if (is_array($updated)) {
             $tagsCount = count($updated);
             $this->set(Tinhte_XenTag_Constants::FIELD_RESOURCE_TAGS, $updated, '', array('setAfterPreSave' => true));
             $this->_db->update('xf_resource', array(Tinhte_XenTag_Constants::FIELD_RESOURCE_TAGS => serialize($updated)), array('resource_id = ?' => $this->get('resource_id')));
         } else {
             $tagsCount = intval($updated);
         }
         $requiresTag = Tinhte_XenTag_Option::get('resourceRequiresTag');
         $maximumTags = intval($this->getModelFromCache('XenResource_Model_Resource')->Tinhte_XenTag_getMaximumTags());
         if ($requiresTag and $maximumTags !== 0 and $tagsCount == 0) {
             throw new XenForo_Exception(new XenForo_Phrase('tinhte_xentag_resource_requires_tag'), true);
         }
         if ($maximumTags !== -1 and $tagsCount > $maximumTags) {
             throw new XenForo_Exception(new XenForo_Phrase('tinhte_xentag_too_many_tags_x_of_y', array('maximum' => $maximumTags, 'count' => $tagsCount)), true);
         }
     }
 }
コード例 #2
0
ファイル: Post.php プロジェクト: Sywooch/forums
 protected function _Tinhte_XenTag_updateTagsInDatabase()
 {
     if ($this->_Tinhte_XenTag_tagTexts !== false) {
         $updated = Tinhte_XenTag_Integration::updateTags('post', $this->get('post_id'), $this->get('user_id'), $this->_Tinhte_XenTag_tagTexts, $this, array('throwException' => false));
         if (is_array($updated)) {
             $tagsCount = count($updated);
         } else {
             $tagsCount = intval($updated);
         }
         if ($tagsCount != count($this->_Tinhte_XenTag_tagTexts)) {
             // there are something wrong with the hashtag...
             // probably a new hashtag without tag creating permission
             // we have to remove the problematic hashtags
             $message = $this->get('message');
             $message = $this->_filterHashtagsFromMessage($message);
             parent::_setInternal('xf_post', 'message', $message);
             $this->_db->update('xf_post', array('message' => $message), array('post_id = ?' => $this->get('post_id')));
         }
         $forum = $this->_Tinhte_XenTag_getForumInfo();
         $maximumTags = intval($this->getModelFromCache('XenForo_Model_Forum')->Tinhte_XenTag_getMaximumHashtags($forum));
         if ($maximumTags !== -1 and $tagsCount > $maximumTags) {
             if ($maximumTags === 0) {
                 throw new XenForo_Exception(new XenForo_Phrase('tinhte_xentag_no_hashtags_allowed'), true);
             }
             throw new XenForo_Exception(new XenForo_Phrase('tinhte_xentag_too_many_hashtags_x_of_y_list_z', array('maximum' => $maximumTags, 'count' => $tagsCount, 'tagTexts' => '#' . implode(', #', $this->_Tinhte_XenTag_tagTexts))), true);
         }
         $this->_Tinhte_XenTag_tagTexts = false;
     }
 }
コード例 #3
0
ファイル: Page.php プロジェクト: Sywooch/forums
 protected function _Tinhte_XenTag_updateTagsInDatabase()
 {
     $force = $this->getExtraData(self::DATA_FORCE_UPDATE_TAGS_IN_DATABASE);
     $skip = $this->getExtraData(self::DATA_SKIP_UPDATE_TAGS_IN_DATABASE);
     if ($force or $this->isChanged(Tinhte_XenTag_Constants::FIELD_PAGE_TAGS) and empty($skip)) {
         $tagsOrTexts = Tinhte_XenTag_Helper::unserialize($this->get(Tinhte_XenTag_Constants::FIELD_PAGE_TAGS));
         $tagTexts = Tinhte_XenTag_Helper::getTextsFromTagsOrTexts($tagsOrTexts);
         $updated = Tinhte_XenTag_Integration::updateTags(Tinhte_XenTag_Constants::CONTENT_TYPE_PAGE, $this->get('node_id'), XenForo_Visitor::getUserId(), $tagTexts, $this);
         if (is_array($updated)) {
             $this->set(Tinhte_XenTag_Constants::FIELD_PAGE_TAGS, $updated, '', array('setAfterPreSave' => true));
             $this->_db->update('xf_page', array(Tinhte_XenTag_Constants::FIELD_PAGE_TAGS => serialize($updated)), array('node_id = ?' => $this->get('node_id')));
         }
     }
 }