コード例 #1
0
ファイル: TaggedThreads.php プロジェクト: Sywooch/forums
 protected function _render(array $widget, $positionCode, array $params, XenForo_Template_Abstract $template)
 {
     $threads = array();
     $tags = Tinhte_XenTag_Helper::explodeTags($widget['options']['tags']);
     $tagsText = array();
     foreach ($tags as $tag) {
         $tag = trim($tag);
         if (!empty($tag)) {
             $tagsText[] = $tag;
         }
     }
     if (!empty($tagsText)) {
         $core = WidgetFramework_Core::getInstance();
         /* @var $threadModel XenForo_Model_Thread */
         $threadModel = $core->getModelFromCache('XenForo_Model_Thread');
         /* @var $tagModel Tinhte_XenTag_Model_Tag */
         $tagModel = $core->getModelFromCache('Tinhte_XenTag_Model_Tag');
         $tags = $tagModel->getTagsByText($tagsText);
         $threadIds = array();
         foreach ($tags as $tag) {
             $latest = Tinhte_XenTag_Helper::unserialize($tag['latest_tagged_contents']);
             if (empty($latest)) {
                 // for some reason, the latest_tagged_contents field is empty
                 // this is illogical because at least there is 1 tagged content (current thread)
                 // so we will rebuild the tag...
                 $latest = $tagModel->updateTag($tag['tag_id']);
             }
             if (!empty($latest)) {
                 foreach ($latest as $taggedContent) {
                     if ($taggedContent['content_type'] == 'thread') {
                         $threadIds[] = $taggedContent['content_id'];
                     }
                 }
             }
         }
         if (!empty($threadIds)) {
             $threadIds = array_unique($threadIds);
             $forumIds = $this->_helperGetForumIdsFromOption(array(), $params, empty($widget['options']['as_guest']) ? false : true);
             // quick way to get all viewable forum ids
             $conditions = array('node_id' => $forumIds, Tinhte_XenTag_XenForo_Model_Thread::CONDITIONS_THREAD_ID => $threadIds, 'deleted' => false, 'moderated' => false);
             $fetchOptions = array('limit' => $widget['options']['limit'], 'join' => XenForo_Model_Thread::FETCH_AVATAR, 'order' => 'post_date', 'orderDirection' => 'desc');
             $threads = $threadModel->getThreads($conditions, $fetchOptions);
         }
     }
     $template->setParam('threads', $threads);
     return $template->render();
 }
コード例 #2
0
ファイル: Tag.php プロジェクト: Sywooch/forums
 public function processInput(XenForo_Input $input)
 {
     $data = $input->filter(array(Tinhte_XenTag_Constants::FORM_TAGS_ARRAY => XenForo_Input::ARRAY_SIMPLE, Tinhte_XenTag_Constants::FORM_TAGS_TEXT => XenForo_Input::STRING, Tinhte_XenTag_Constants::FORM_INCLUDED => XenForo_Input::UINT, Tinhte_XenTag_Constants::FORM_TAGS_TEXT_NO_INCLUDED => XenForo_Input::STRING));
     if (!empty($data[Tinhte_XenTag_Constants::FORM_INCLUDED])) {
         $tagTexts = $data[Tinhte_XenTag_Constants::FORM_TAGS_ARRAY];
         if (!empty($data[Tinhte_XenTag_Constants::FORM_TAGS_TEXT])) {
             $tagTexts2 = Tinhte_XenTag_Helper::explodeTags($data[Tinhte_XenTag_Constants::FORM_TAGS_TEXT]);
         } else {
             $tagTexts2 = array();
         }
         $merged = array_merge($tagTexts, $tagTexts2);
         foreach (array_keys($merged) as $key) {
             $merged[$key] = trim($merged[$key]);
             if (empty($merged[$key])) {
                 unset($merged[$key]);
             }
         }
         return $merged;
     } elseif (!empty($data[Tinhte_XenTag_Constants::FORM_TAGS_TEXT_NO_INCLUDED])) {
         // used as a checkbox in search bar
         // so no *_included field is coming with it
         // we just use it as it's is
         $tagTexts = Tinhte_XenTag_Helper::explodeTags($data[Tinhte_XenTag_Constants::FORM_TAGS_TEXT_NO_INCLUDED]);
         foreach (array_keys($tagTexts) as $key) {
             $tagTexts[$key] = trim($tagTexts[$key]);
             if (empty($tagTexts[$key])) {
                 unset($tagTexts[$key]);
             }
         }
         return $tagTexts;
     } else {
         return false;
     }
 }