示例#1
0
 protected function _Tinhte_XenTag_prepareRssEntry($result, Zend_Feed_Writer_Feed $feed)
 {
     $entry = false;
     if ($result[XenForo_Model_Search::CONTENT_TYPE] == 'thread') {
         $thread = $result['content'];
         $entry = $feed->createEntry();
         $entry->setTitle($thread['title']);
         $entry->setLink(XenForo_Link::buildPublicLink('canonical:threads', $thread));
         $entry->setDateCreated(new Zend_Date($thread['post_date'], Zend_Date::TIMESTAMP));
         $entry->setDateModified(new Zend_Date($thread['last_post_date'], Zend_Date::TIMESTAMP));
         $discussionRssContentLength = XenForo_Application::getOptions()->get('discussionRssContentLength');
         if (!empty($thread['message']) && $discussionRssContentLength > 0) {
             $bbCodeParser = $this->_Tinhte_XenTag_getBbCodeParser('Base');
             $bbCodeSnippetParser = $this->_Tinhte_XenTag_getBbCodeParser('XenForo_BbCode_Formatter_BbCode_Clean');
             $rendererStates = array('disableProxying' => true);
             $wordTrimmed = XenForo_Helper_String::wholeWordTrim($thread['message'], $discussionRssContentLength);
             $snippet = $bbCodeSnippetParser->render($wordTrimmed, $rendererStates);
             if ($snippet != $thread['message']) {
                 $snippet .= "\n\n[url='" . XenForo_Link::buildPublicLink('canonical:threads', $thread) . "']" . $thread['title'] . '[/url]';
             }
             $content = trim($bbCodeParser->render($snippet, $rendererStates));
             if (strlen($content)) {
                 $entry->setContent($content);
             }
         }
         if (!$this->_Tinhte_XenTag_isBuggyXmlNamespace()) {
             $entry->addAuthor(array('name' => $thread['username'], 'uri' => XenForo_Link::buildPublicLink('canonical:members', $thread)));
             if ($thread['reply_count']) {
                 $entry->setCommentCount($thread['reply_count']);
             }
         }
     }
     return $entry;
 }
示例#2
0
 public function renderVerification(XenForo_View $view, $context, array $user, array $providerData, array $triggerData)
 {
     $issuer = XenForo_Helper_String::wholeWordTrim(str_replace(':', '', XenForo_Application::getOptions()->boardTitle), 50);
     $user = str_replace(':', '', $user['username']);
     $params = array('secret' => $providerData['secret'], 'otpUrl' => $this->_getAuthHandler()->getOtpAuthUrl("{$issuer}: {$user}", $providerData['secret'], $issuer), 'data' => $providerData, 'context' => $context);
     return $view->createTemplateObject('two_step_totp', $params)->render();
 }
示例#3
0
 public function renderRss()
 {
     $options = XenForo_Application::get('options');
     $title = $options->boardTitle ? $options->boardTitle : XenForo_Link::buildPublicLink('canonical:index');
     $description = $options->boardDescription ? $options->boardDescription : $title;
     $buggyXmlNamespace = defined('LIBXML_DOTTED_VERSION') && LIBXML_DOTTED_VERSION == '2.6.24';
     $feed = new Zend_Feed_Writer_Feed();
     $feed->setEncoding('utf-8');
     $feed->setTitle($title);
     $feed->setDescription($description);
     $feed->setLink(XenForo_Link::buildPublicLink('canonical:index'));
     if (!$buggyXmlNamespace) {
         $feed->setFeedLink(XenForo_Link::buildPublicLink('canonical:forums/-/index.rss'), 'rss');
     }
     $feed->setDateModified(XenForo_Application::$time);
     $feed->setLastBuildDate(XenForo_Application::$time);
     $feed->setGenerator($title);
     $bbCodeSnippetParser = XenForo_BbCode_Parser::create(XenForo_BbCode_Formatter_Base::create('XenForo_BbCode_Formatter_BbCode_Clean', false));
     $bbCodeParser = XenForo_BbCode_Parser::create(XenForo_BbCode_Formatter_Base::create('Base', array('view' => $this)));
     $rendererStates = array('disableProxying' => true);
     foreach ($this->_params['threads'] as $thread) {
         $entry = $feed->createEntry();
         $entry->setTitle($thread['title'] ? $thread['title'] : $thread['title'] . ' ');
         $entry->setLink(XenForo_Link::buildPublicLink('canonical:threads', $thread));
         $entry->setDateCreated(new Zend_Date($thread['post_date'], Zend_Date::TIMESTAMP));
         $entry->setDateModified(new Zend_Date($thread['last_post_date'], Zend_Date::TIMESTAMP));
         if (!empty($thread['canViewContent']) && !empty($thread['message']) && XenForo_Application::getOptions()->discussionRssContentLength) {
             $snippet = $bbCodeSnippetParser->render(XenForo_Helper_String::wholeWordTrim($thread['message'], XenForo_Application::getOptions()->discussionRssContentLength), $rendererStates);
             if ($snippet != $thread['message']) {
                 $snippet .= "\n\n[url='" . XenForo_Link::buildPublicLink('canonical:threads', $thread) . "']" . $thread['title'] . '[/url]';
             }
             $content = trim($bbCodeParser->render($snippet, $rendererStates));
             if (strlen($content)) {
                 $entry->setContent($content);
             }
         }
         if (!$buggyXmlNamespace) {
             $entry->addAuthor(array('name' => $thread['username'], 'email' => '*****@*****.**', 'uri' => XenForo_Link::buildPublicLink('canonical:members', $thread)));
             if ($thread['reply_count']) {
                 $entry->setCommentCount($thread['reply_count']);
             }
         }
         $feed->addEntry($entry);
     }
     return $feed->export('rss');
 }
示例#4
0
 public function publish($targetId, bdSocialShare_Shareable_Abstract $shareable, $token)
 {
     $statusText = false;
     $userText = $shareable->getUserText($this);
     $title = $shareable->getTitle($this);
     $description = $shareable->getDescription($this);
     $userText = strval($userText);
     $title = strval($title);
     $description = strval($description);
     if (!empty($userText)) {
         $statusText = $userText;
     }
     if ($statusText === false) {
         if (!empty($title)) {
             $statusText = $title;
         }
         if (!empty($description)) {
             if (!empty($statusText)) {
                 $statusText .= ': ' . $description;
             } else {
                 $statusText = $description;
             }
         }
     }
     $link = $shareable->getLink($this);
     if (!empty($link)) {
         // minus short url length
         // minus one for the ellipsis character
         // minus another one for the space character
         $status = XenForo_Helper_String::wholeWordTrim($statusText, 140 - $this->getShortUrlLengthHttps($token) - 2, 0, '…') . ' ' . $link;
     } else {
         // minus one for the ellipsis character
         $status = XenForo_Helper_String::wholeWordTrim($statusText, 140 - 1, 0, '…');
     }
     $response = bdSocialShare_Helper_Twitter::statusesUpdate($token['oauth_token'], $token['oauth_token_secret'], $status);
     if (isset($response['id_str'])) {
         return $response;
     } else {
         throw new bdSocialShare_Exception_Interrupted(serialize(array($status, $response)));
     }
 }
示例#5
0
 public static function prepareMessage($item, XenForo_BbCode_Parser $bbCodeParser, array $bbCodeOptions, XenForo_View $view)
 {
     $message = $item['data']['message'];
     if ($bbCodeOptions['states']['viewAttachments']) {
         $string = preg_replace('#\\[(quoteee)[^\\]]*\\].*\\[/\\1\\]#siU', ' ', $message);
     } else {
         $string = preg_replace('#\\[(attach|quote)[^\\]]*\\].*\\[/\\1\\]#siU', ' ', $message);
     }
     $formatter = XenForo_BbCode_Formatter_Base::create('ImageCount');
     $parser = XenForo_BbCode_Parser::create($formatter);
     $parser->render($string);
     if (isset($item['data']['attachments'])) {
         $item['attachments'] = $item['data']['attachments'];
     }
     $item['mediaCount'] = $formatter->getMediaCount();
     $item['message'] = XenForo_Helper_String::wholeWordTrim($string, SimplePortal_Static::option('charlimit'));
     $item['messageHtml'] = XenForo_ViewPublic_Helper_Message::getBbCodeWrapper($item, $bbCodeParser, $bbCodeOptions);
     if (strpos($item['messageHtml'], SimplePortal_Static::PORTAL_PREVIEW_ENDSTRING)) {
         $item['messageHtml'] = strstr($item['messageHtml'], SimplePortal_Static::PORTAL_PREVIEW_ENDSTRING, true);
     }
     return $item;
 }
示例#6
0
 protected function _updateSocialForum($resource)
 {
     if (!$this->_isFirstVisible || !$resource || !$resource['social_forum_id']) {
         return false;
     }
     $socialForum = ThemeHouse_SocialGroups_SocialForum::setup($resource['social_forum_id'])->toArray();
     if (!$socialForum) {
         return false;
     }
     $forum = $this->getModelFromCache('XenForo_Model_Forum')->getForumById($socialForum['node_id']);
     if (!$forum) {
         return false;
     }
     $threadDw = XenForo_DataWriter::create('XenForo_DataWriter_Discussion_Thread', XenForo_DataWriter::ERROR_SILENT);
     $threadDw->setExtraData(XenForo_DataWriter_Discussion_Thread::DATA_FORUM, $forum);
     $threadDw->bulkSet(array('node_id' => $socialForum['node_id'], 'title' => $this->get('title'), 'user_id' => $resource['user_id'], 'username' => $resource['username'], 'discussion_type' => 'resource'));
     $threadDw->set('discussion_state', $this->getModelFromCache('XenForo_Model_Post')->getPostInsertMessageState(array(), $forum));
     $threadDw->setOption(XenForo_DataWriter_Discussion::OPTION_PUBLISH_FEED, false);
     $messageText = $this->get('message');
     // note: this doesn't actually strip the BB code - it will fix the BB code in the snippet though
     $parser = new XenForo_BbCode_Parser(XenForo_BbCode_Formatter_Base::create('XenForo_BbCode_Formatter_BbCode_AutoLink', false));
     $snippet = $parser->render(XenForo_Helper_String::wholeWordTrim($messageText, 500));
     $message = new XenForo_Phrase('resource_message_create_update', array('title' => $this->get('title'), 'username' => $resource['username'], 'userId' => $resource['user_id'], 'snippet' => $snippet, 'updateLink' => XenForo_Link::buildPublicLink('canonical:resources/update', $resource, array('update' => $this->get('resource_update_id'))), 'resourceTitle' => $resource['title'], 'resourceLink' => XenForo_Link::buildPublicLink('canonical:resources', $resource)), false);
     $postWriter = $threadDw->getFirstMessageDw();
     $postWriter->set('message', $message->render());
     $postWriter->setExtraData(XenForo_DataWriter_DiscussionMessage_Post::DATA_FORUM, $forum);
     $postWriter->setOption(XenForo_DataWriter_DiscussionMessage::OPTION_PUBLISH_FEED, false);
     if (!$threadDw->save()) {
         return false;
     }
     $this->set('discussion_thread_id', $threadDw->get('thread_id'), '', array('setAfterPreSave' => true));
     $postSaveChanges['discussion_thread_id'] = $threadDw->get('thread_id');
     $this->getModelFromCache('XenForo_Model_Thread')->markThreadRead($threadDw->getMergedData(), $forum, XenForo_Application::$time);
     $this->getModelFromCache('XenForo_Model_ThreadWatch')->setThreadWatchStateWithUserDefault($this->get('user_id'), $threadDw->get('thread_id'), $this->getExtraData(XenResource_DataWriter_Resource::DATA_THREAD_WATCH_DEFAULT));
     return $postWriter->get('post_id');
 }
 protected function _nodeForumLevel2()
 {
     $viewParams = $this->_fetchViewParams();
     $lastPostTitleMaxChars = XenForo_Application::get('options')->th_lastPostAvatar_lastPostTitleMaxLength;
     if (isset($viewParams['forum'])) {
         $node = $viewParams['forum'];
         if (!$node['lastPost']['date']) {
             return;
         }
         $rendered = $this->_render('th_node_forum_avatar_lastpostavatar');
         $title = XenForo_Helper_String::wholeWordTrim($node['lastPost']['title'], $lastPostTitleMaxChars);
     } else {
         if (isset($viewParams['category'])) {
             $node = $viewParams['category'];
             if (!$node['lastPost']['date']) {
                 return;
             }
             $rendered = $this->_render('th_node_category_avatar_lastpostavatar');
             $title = XenForo_Helper_String::wholeWordTrim($node['lastPost']['title'], $lastPostTitleMaxChars);
         } else {
             if (isset($viewParams['library'])) {
                 $node = $viewParams['library'];
                 if (!$node['lastArticlePage']['date']) {
                     return;
                 }
                 $rendered = $this->_render('th_node_library_avatar_lastpostavatar');
                 $title = XenForo_Helper_String::wholeWordTrim($node['lastArticlePage']['title'], $lastPostTitleMaxChars);
             }
         }
     }
     if (!isset($node['privateInfo']) || !$node['privateInfo']) {
         $pattern = '#(<div class="nodeLastPost(?: secondaryContent)?">)(.*)(<a[^>]*>)[^<]*(</a>)#Us';
         $replacement = '${1}' . $rendered . '${2}' . '${3}' . $title . '${4}';
         $this->_contents = preg_replace($pattern, $replacement, $this->_contents, 1);
     }
 }
示例#8
0
文件: Team.php 项目: Sywooch/forums
 protected function _insertDiscussionThread($nodeId, $prefixId = 0)
 {
     if (!$nodeId) {
         return false;
     }
     $forum = $this->getModelFromCache('XenForo_Model_Forum')->getForumById($nodeId);
     if (!$forum) {
         return false;
     }
     $threadDw = XenForo_DataWriter::create('XenForo_DataWriter_Discussion_Thread', XenForo_DataWriter::ERROR_SILENT);
     $threadDw->setExtraData(XenForo_DataWriter_Discussion_Thread::DATA_FORUM, $forum);
     $threadDw->bulkSet(array('node_id' => $nodeId, 'title' => $this->_getThreadTitle(), 'user_id' => $this->get('user_id'), 'username' => $this->get('username'), 'discussion_type' => 'team', 'prefix_id' => $prefixId));
     $threadDw->set('discussion_state', $this->getModelFromCache('XenForo_Model_Post')->getPostInsertMessageState(array(), $forum));
     $threadDw->setOption(XenForo_DataWriter_Discussion::OPTION_PUBLISH_FEED, false);
     $messageText = $this->get('about');
     // note: this doesn't actually strip the BB code - it will fix the BB code in the snippet though
     $parser = XenForo_BbCode_Parser::create(XenForo_BbCode_Formatter_Base::create('XenForo_BbCode_Formatter_BbCode_AutoLink', false));
     $snippet = $parser->render(XenForo_Helper_String::wholeWordTrim($messageText, 500));
     $message = new XenForo_Phrase('Teams_message_create_team', array('title' => $this->get('title'), 'tagLine' => $this->get('tag_line'), 'username' => $this->get('username'), 'userId' => $this->get('user_id'), 'snippet' => $snippet, 'teamLink' => XenForo_Link::buildPublicLink('canonical:' . Nobita_Teams_Model_Team::routePrefix(), $this->getMergedData())), false);
     $postWriter = $threadDw->getFirstMessageDw();
     $postWriter->set('message', $message->render());
     $postWriter->setExtraData(XenForo_DataWriter_DiscussionMessage_Post::DATA_FORUM, $forum);
     $postWriter->setOption(XenForo_DataWriter_DiscussionMessage::OPTION_PUBLISH_FEED, false);
     if (!$threadDw->save()) {
         return false;
     }
     $this->set('discussion_thread_id', $threadDw->get('thread_id'), '', array('setAfterPreSave' => true));
     $postSaveChanges['discussion_thread_id'] = $threadDw->get('thread_id');
     $this->getModelFromCache('XenForo_Model_Thread')->markThreadRead($threadDw->getMergedData(), $forum, \XenForo_Application::$time);
     $this->getModelFromCache('XenForo_Model_ThreadWatch')->setThreadWatchStateWithUserDefault($this->get('user_id'), $threadDw->get('thread_id'), $this->getExtraData(self::DATA_THREAD_WATCH_DEFAULT));
     return $threadDw->get('thread_id');
 }
示例#9
0
 /**
  * Verifies that the discussion title is valid
  *
  * @param string
  *
  * @return boolean
  */
 protected function _verifyTitle(&$title)
 {
     // TODO: send these to callbacks to allow hookability?
     switch ($this->getOption(self::OPTION_ADJUST_TITLE_CASE)) {
         case 'ucfirst':
             // sentence case
             $title = utf8_ucfirst(utf8_strtolower($title));
             break;
         case 'ucwords':
             // title case
             $title = utf8_ucwords(utf8_strtolower($title));
             break;
     }
     if ($this->getOption(self::OPTION_TRIM_TITLE)) {
         $table = reset($this->_fields);
         $title = XenForo_Helper_String::wholeWordTrim($title, $table['title']['maxLength'] - 5);
     }
     return true;
 }
示例#10
0
 /**
  * Word trims and HTML escapes the given string.
  *
  * @param string $string
  * @param integer $trimLength
  */
 public static function helperWordTrim($string, $trimLength)
 {
     return htmlspecialchars(XenForo_Helper_String::wholeWordTrim($string, $trimLength));
 }
示例#11
0
 /**
  *
  * @see XenForo_DataWriter_ConversationMaster::_postSave()
  */
 protected function _postSave()
 {
     parent::_postSave();
     $postSaveChanges = array();
     if ($this->isInsert() && $this->getOption(self::OPTION_CHECK_TAB_RULES)) {
         /* @var $tabModel Waindigo_Tabs_Model_Tab */
         $tabModel = $this->getModelFromCache('Waindigo_Tabs_Model_Tab');
         /* @var $tabRuleModel Waindigo_Tabs_Model_TabRule */
         $tabRuleModel = $this->getModelFromCache('Waindigo_Tabs_Model_TabRule');
         $tabRules = $tabRuleModel->getTabRules(array('match_content_type' => 'conversation'));
         $tabId = $this->get('tab_id');
         $extraTabData = array();
         if (isset($GLOBALS['XenForo_ControllerPublic_Conversation'])) {
             /* @var $controller XenForo_ControllerPublic_Conversation */
             $controller = $GLOBALS['XenForo_ControllerPublic_Conversation'];
             $extraTabData = $controller->getInput()->filterSingle('extra_tab_data', XenForo_Input::ARRAY_SIMPLE);
         }
         $conversation = $this->getMergedData();
         $firstMessage = $this->_firstMessageDw;
         if ($firstMessage) {
             $messageText = $firstMessage->get('message');
             $parser = XenForo_BbCode_Parser::create(XenForo_BbCode_Formatter_Base::create('XenForo_BbCode_Formatter_BbCode_AutoLink', false));
             $snippet = $parser->render(XenForo_Helper_String::wholeWordTrim($messageText, 500));
             $messageParams = array('title' => $this->get('title'), 'username' => $this->get('username'), 'contentLink' => XenForo_Link::buildPublicLink('canonical:conversations', $conversation), 'snippet' => $snippet);
             $defaultMessage = new XenForo_Phrase('waindigo_conversation_message_create_tabs', $messageParams, false);
             $params = array('user_id' => $this->get('user_id'), 'username' => $this->get('username'), 'title' => $this->get('title'), 'content_type' => 'conversation', 'content_id' => $this->get('conversation_id'), 'tag_line' => XenForo_Helper_String::wholeWordTrim(XenForo_Helper_string::bbCodeStrip($messageText), 100));
             $tabNameId = '';
             foreach ($tabRules as $tabRuleId => $tabRule) {
                 if (Waindigo_Tabs_Helper_Criteria::conversationMatchesCriteria($tabRule['match_criteria'], true, $conversation)) {
                     if ($tabRule['create_criteria']) {
                         $createCriteria = unserialize($tabRule['create_criteria']);
                     } else {
                         $createCriteria = array();
                     }
                     if (!empty($createCriteria['use_custom_message'])) {
                         $params['message'] = new XenForo_Phrase($tabRuleModel->getTabRuleCustomMessagePhraseName($tabRuleId), $messageParams, false);
                     } else {
                         $params['message'] = $defaultMessage;
                     }
                     if (!empty($extraTabData[$tabRuleId])) {
                         $params = array_merge($extraTabData[$tabRuleId], $params);
                     }
                     $tabId = $tabModel->createNewTab($tabRule['create_content_type'], $tabId, $tabRule['tab_name_id'], $createCriteria, $params);
                     if ($tabId && !$tabNameId) {
                         $tabNameId = $tabRule['match_tab_name_id'];
                     }
                 }
             }
             if ($tabId && $tabId != $this->get('tab_id')) {
                 $this->set('tab_id', $tabId, '', array('setAfterPreSave' => true));
                 $postSaveChanges['tab_id'] = $tabId;
                 if ($tabNameId) {
                     $tabModel->insertTab($this->get('tab_id'), 'conversation', $this->get('conversation_id'), $tabNameId);
                 }
             }
         }
     }
     if (isset($GLOBALS['XenForo_ControllerPublic_Conversation'])) {
         /* @var $controller XenForo_ControllerPublic_Conversation */
         $controller = $GLOBALS['XenForo_ControllerPublic_Conversation'];
         // TODO: check permissions?
         $tabNameId = $controller->getInput()->filterSingle('tab_name_id', XenForo_Input::UINT);
         if ($tabNameId) {
             $this->_db->update('xf_tab_content', array('tab_name_id' => $tabNameId), 'content_id = ' . $this->_db->quote($this->get('conversation_id')) . ' AND content_type = \'conversation\'');
         }
     }
     if ($postSaveChanges) {
         $this->_db->update('xf_conversation_master', $postSaveChanges, 'conversation_id = ' . $this->_db->quote($this->get('conversation_id')));
     }
     if ($this->isChanged('tab_id') && $this->getExisting('tab_id') && $this->get('tab_id')) {
         $this->_db->update('xf_tab_content', array('tab_id' => $this->get('tab_id')), 'content_id = ' . $this->_db->quote($this->getExisting('conversation_id')) . ' AND content_type = \'conversation\'');
     }
 }
示例#12
0
 protected function _convertUserFieldChoices(array $profileField, array &$fieldChoiceLookups)
 {
     try {
         $choiceData = @unserialize($profileField['data']);
     } catch (Exception $e) {
         // this is either corrupted data or an invalid char set. The latter isn't something we can automatically detect
         return array();
     }
     if (!is_array($choiceData)) {
         return array();
     }
     $choices = array();
     foreach ($choiceData as $key => $choice) {
         $choice = $this->_convertToUtf8($choice);
         $choiceId = XenForo_Helper_String::wholeWordTrim($choice, 23, 0, '');
         if ($choiceId != '') {
             $choiceId = str_replace('-', '_', XenForo_Link::getTitleForUrl($choiceId, true));
             $i = 1;
             $choiceIdBase = $choiceId;
             while (isset($choices[$choiceId])) {
                 $choiceId = $choiceIdBase . '_' . ++$i;
             }
         } else {
             $choiceId = $key;
         }
         $choices[$choiceId] = $choice;
     }
     $lookUps = array();
     switch ($profileField['type']) {
         case 'checkbox':
         case 'select_multiple':
             $multiple = true;
             $i = 1;
             foreach ($choices as $key => $value) {
                 $lookUps[$i] = $key;
                 $i = $i * 2;
             }
             break;
         case 'select':
         case 'radio':
         default:
             $multiple = false;
             foreach ($choices as $key => $value) {
                 $lookUps[$value] = $key;
             }
             break;
     }
     $fieldChoiceLookups[$profileField['profilefieldid']] = array('multiple' => $multiple, 'choices' => $lookUps);
     return $choices;
 }
示例#13
0
文件: Update.php 项目: Sywooch/forums
 protected function _updateThread(array $resource)
 {
     if (!$this->_isFirstVisible || !$resource || !$resource['discussion_thread_id']) {
         return false;
     }
     $thread = $this->getModelFromCache('XenForo_Model_Thread')->getThreadById($resource['discussion_thread_id']);
     if (!$thread || $thread['discussion_type'] != 'resource') {
         return false;
     }
     $forum = $this->getModelFromCache('XenForo_Model_Forum')->getForumById($thread['node_id']);
     if (!$forum) {
         return false;
     }
     $messageText = $this->get('message');
     // note: this doesn't actually strip the BB code - it will fix the BB code in the snippet though
     $parser = XenForo_BbCode_Parser::create(XenForo_BbCode_Formatter_Base::create('XenForo_BbCode_Formatter_BbCode_AutoLink', false));
     $snippet = $parser->render(XenForo_Helper_String::wholeWordTrim($messageText, 500));
     $message = new XenForo_Phrase('resource_message_create_update', array('title' => $this->get('title'), 'username' => $resource['username'], 'userId' => $resource['user_id'], 'snippet' => $snippet, 'updateLink' => XenForo_Link::buildPublicLink('canonical:resources/update', $resource, array('update' => $this->get('resource_update_id'))), 'resourceTitle' => $resource['title'], 'resourceLink' => XenForo_Link::buildPublicLink('canonical:resources', $resource)), false);
     $writer = XenForo_DataWriter::create('XenForo_DataWriter_DiscussionMessage_Post', XenForo_DataWriter::ERROR_SILENT);
     $writer->bulkSet(array('thread_id' => $thread['thread_id'], 'user_id' => $resource['user_id'], 'username' => $resource['username']));
     $writer->set('message', $message->render());
     $writer->set('message_state', $this->getModelFromCache('XenForo_Model_Post')->getPostInsertMessageState($thread, $forum));
     $writer->setOption(XenForo_DataWriter_DiscussionMessage::OPTION_IS_AUTOMATED, true);
     $writer->setOption(XenForo_DataWriter_DiscussionMessage::OPTION_PUBLISH_FEED, false);
     $writer->save();
     $threadReadDate = $this->getModelFromCache('XenForo_Model_Thread')->getUserThreadReadDate($resource['user_id'], $thread['thread_id']);
     $forumReadDate = $this->getModelFromCache('XenForo_Model_Forum')->getUserForumReadDate($resource['user_id'], $forum['node_id']);
     if (max($threadReadDate, $forumReadDate) >= $thread['last_post_date']) {
         $this->getModelFromCache('XenForo_Model_Thread')->markThreadRead($thread, $forum, XenForo_Application::$time);
     }
     return $writer->get('post_id');
 }
示例#14
0
    /**
     * Inserts the data of a single feed entry
     *
     * @param array $entryData
     * @param array $feedData
     * @param array $feed
     *
     * @return integer|boolean Thread ID on success, false on failure
     */
    protected function _insertFeedEntry(array $entryData, array $feedData, array $feed)
    {
        $db = $this->_getDb();
        XenForo_Db::beginTransaction($db);
        $writer = XenForo_DataWriter::create('XenForo_DataWriter_Discussion_Thread', XenForo_DataWriter::ERROR_SILENT);
        $writer->setOption(XenForo_DataWriter_Discussion::OPTION_TRIM_TITLE, true);
        $writer->bulkSet(array('node_id' => $feed['node_id'], 'prefix_id' => $feed['prefix_id'], 'discussion_state' => $feed['discussion_visible'] ? 'visible' : 'moderated', 'discussion_open' => $feed['discussion_open'], 'sticky' => $feed['discussion_sticky'], 'title' => $entryData['title'], 'user_id' => $feed['user_id']));
        // TODO: The wholeWordTrim() used here may not be exactly ideal. Any better ideas?
        if ($feed['user_id']) {
            // post as the specified registered user
            $writer->set('username', $feed['username']);
        } else {
            if ($entryData['author']) {
                // post as guest, using the author name(s) from the entry
                $writer->set('username', XenForo_Helper_String::wholeWordTrim($entryData['author'], 25, 0, ''));
            } else {
                // post as guest, using the feed title
                $writer->set('username', XenForo_Helper_String::wholeWordTrim($feed['title'], 25, 0, ''));
            }
        }
        $postWriter = $writer->getFirstMessageDw();
        $postWriter->setOption(XenForo_DataWriter_DiscussionMessage::OPTION_IS_AUTOMATED, true);
        $postWriter->setOption(XenForo_DataWriter_DiscussionMessage::OPTION_VERIFY_GUEST_USERNAME, false);
        $postWriter->set('message', $entryData['message']);
        $writer->save();
        $threadId = $writer->get('thread_id');
        if ($threadId) {
            try {
                $db->query('
					INSERT INTO xf_feed_log
						(feed_id, unique_id, hash, thread_id)
					VALUES
						(?, ?, ?, ?)
				', array($feed['feed_id'], utf8_substr($entryData['id'], 0, 250), $entryData['hash'], $threadId));
            } catch (Zend_Db_Exception $e) {
                XenForo_Db::rollback($db);
                return false;
            }
        }
        XenForo_Db::commit($db);
        return $threadId;
    }
示例#15
0
 public function actionUpdate()
 {
     $updateFetchOptions = array('likeUserId' => XenForo_Visitor::getUserId());
     $resourceFetchOptions = array('join' => XenResource_Model_Resource::FETCH_VERSION | XenResource_Model_Resource::FETCH_ATTACHMENT, 'watchUserId' => XenForo_Visitor::getUserId());
     $resourceUpdateId = $this->_input->filterSingle('update', XenForo_Input::UINT);
     if (!$resourceUpdateId) {
         $resourceUpdateId = $this->_input->filterSingle('resource_update_id', XenForo_Input::UINT);
     }
     list($update, $resource, $category) = $this->_getResourceHelper()->assertUpdateValidAndViewable($resourceUpdateId, $updateFetchOptions, $resourceFetchOptions);
     $this->canonicalizeRequestUrl(XenForo_Link::buildPublicLink('resources/update', $resource));
     $updateModel = $this->_getUpdateModel();
     $resourceModel = $this->_getResourceModel();
     $updateId = $update['resource_update_id'];
     $updates = array($updateId => $update);
     $updates = $updateModel->prepareUpdates($updates, $resource, $category);
     $updates = $updateModel->getAndMergeAttachmentsIntoUpdates($updates);
     $update = $updates[$updateId];
     $isLimited = false;
     $options = XenForo_Application::getOptions();
     if ($resource['is_fileless'] && !$resource['external_purchase_url'] && $options->get('resourceFilelessViewFull', 'limit') && !$resourceModel->canDownloadResource($resource, $category)) {
         $limit = max(500, $options->get('resourceFilelessViewFull', 'length'));
         if ($limit > 0) {
             $trimmed = XenForo_Helper_String::wholeWordTrim($update['message'], $limit);
             $isLimited = strlen($trimmed) < strlen($update['message']);
         } else {
             $trimmed = '';
             $isLimited = true;
         }
         if ($isLimited) {
             $parser = XenForo_BbCode_Parser::create(XenForo_BbCode_Formatter_Base::create('XenForo_BbCode_Formatter_BbCode_AutoLink', false));
             $update['message'] = $parser->render($trimmed);
             $update['isMessageTrimmed'] = true;
         }
     }
     $viewParams = array('resource' => $resource, 'category' => $category, 'update' => $update, 'isLimited' => $isLimited, 'canViewImages' => $updateModel->canViewUpdateImages($resource, $category));
     if ($this->_noRedirect()) {
         // ajax request for just the update
         return $this->responseView('XenResource_ViewPublic_Update_ViewAjax', 'resource_update', $viewParams);
     } else {
         if ($update['resource_update_id'] == $resource['description_update_id']) {
             return $this->responseRedirect(XenForo_ControllerResponse_Redirect::RESOURCE_CANONICAL_PERMANENT, XenForo_Link::buildPublicLink('resources', $resource));
         }
         return $this->_getResourceViewWrapper('updates', $resource, $category, $this->responseView('XenResource_ViewPublic_Update_View', 'resource_update_view', $viewParams));
     }
 }
示例#16
0
文件: Update.php 项目: Sywooch/forums
 public function snippetUpdateText($text, $length, &$isSnippet)
 {
     $parser = XenForo_BbCode_Parser::create(XenForo_BbCode_Formatter_Base::create('XenForo_BbCode_Formatter_BbCode_AutoLink', false));
     $newText = $parser->render(XenForo_Helper_String::wholeWordTrim($text, $length));
     $isSnippet = strlen($newText) < strlen($text);
     return $newText;
 }
示例#17
0
文件: Thread.php 项目: Sywooch/forums
 public function actionGalleryImport()
 {
     $visitor = XenForo_Visitor::getInstance();
     $threadId = $this->_input->filterSingle('thread_id', XenForo_Input::UINT);
     /* @var $ftpHelper XenForo_ControllerHelper_ForumThreadPost */
     $ftpHelper = $this->getHelper('ForumThreadPost');
     list($threadFetchOptions, $forumFetchOptions) = $this->_getThreadForumFetchOptions();
     if (isset($threadFetchOptions['join'])) {
         $threadFetchOptions['join'] |= XenForo_Model_Thread::FETCH_FIRSTPOST;
     } else {
         $threadFetchOptions['join'] = XenForo_Model_Thread::FETCH_FIRSTPOST;
     }
     list($thread, $forum) = $ftpHelper->assertThreadValidAndViewable($threadId, $threadFetchOptions, $forumFetchOptions);
     if (!$visitor->hasPermission('sonnb_xengallery', 'importAnyThread') && (!$visitor->hasPermission('sonnb_xengallery', 'importOwnThread') && $visitor['user_id'] == $thread['user_id'])) {
         return $this->responseNoPermission();
     }
     if ($thread['sonnb_xengallery_import'] && !XenForo_Application::getOptions()->sonnbXG_allowMultipleImport) {
         return $this->responseError(new XenForo_Phrase('sonnb_xengallery_this_thread_was_already_imported'));
     }
     if ($this->isConfirmedPost()) {
         $targetType = $this->_input->filterSingle('target_album', XenForo_Input::STRING);
         $importIds = $this->_input->filterSingle('import_id', XenForo_Input::ARRAY_SIMPLE);
         $importIds = array_filter($importIds);
         $importIds = array_map('intval', $importIds);
         if (!count($importIds)) {
             return $this->responseError(new XenForo_Phrase('sonnb_xengallery_there_is_no_image_selected'));
         }
         $attachments = $this->_getXenGalleryAttachmentModel()->getAttachmentsForXenGalleryByAttachmentIds($importIds);
         if (!count($attachments)) {
             return $this->responseError(new XenForo_Phrase('sonnb_xengallery_there_is_no_image_selected'));
         }
         @set_time_limit(0);
         ignore_user_abort(true);
         $importModel = $this->_getXenGalleryImportModel();
         switch ($targetType) {
             case 'existing':
                 $albumId = $this->_input->filterSingle('album_id', XenForo_Input::UINT);
                 foreach ($attachments as $attachment) {
                     $this->_importXenGalleryPhoto($attachment, $importModel, $albumId);
                 }
                 break;
             case 'new':
                 $postModel = $this->_getPostModel();
                 //TODO: limit???
                 $postFetchOptions = $this->_getPostFetchOptions($thread, $forum);
                 $posts = $postModel->getPostsInThread($threadId, $postFetchOptions);
                 $firstPost = array('likes' => 0, 'like_users' => 'a:0:{}', 'message' => '', 'post_id' => 0);
                 if ($thread['first_post_id'] && isset($posts[$thread['first_post_id']])) {
                     $firstPost = $posts[$thread['first_post_id']];
                     unset($posts[$thread['first_post_id']]);
                 }
                 $categoryId = $this->_input->filterSingle('category_id', XenForo_Input::UINT);
                 $importComment = $this->_input->filterSingle('import_comment', XenForo_Input::UINT);
                 $title = $this->_input->filterSingle('title', XenForo_Input::STRING);
                 /*
                 $formatter = XenForo_BbCode_Formatter_Base::create('XenForo_BbCode_Formatter_Text');
                 $parser = new XenForo_BbCode_Parser($formatter);
                 
                 $description = $parser->render($firstPost['message']);
                 $description = str_replace(array('[IMG]', '[ATTACH]', '[MEDIA]'), '', $description);
                 */
                 $albumPrivacy = array('allow_view' => 'everyone', 'allow_comment' => 'everyone', 'allow_download' => 'none', 'allow_add_photo' => 'none');
                 $visitor = XenForo_Visitor::getInstance();
                 if (!empty($visitor['xengallery'])) {
                     $albumPrivacy = array('allow_view' => $visitor['xengallery']['album_allow_view'], 'allow_comment' => $visitor['xengallery']['album_allow_comment'], 'allow_download' => $visitor['xengallery']['album_allow_download'], 'allow_add_photo' => $visitor['xengallery']['album_allow_add_photo']);
                 }
                 //TODO: allow to modify the description
                 $album = array('title' => $title, 'description' => XenForo_Helper_String::wholeWordTrim($firstPost['message'], 1990), 'user_id' => $thread['user_id'], 'username' => $thread['username'], 'album_state' => $thread['discussion_state'], 'comment_count' => 0, 'view_count' => $thread['view_count'], 'cover_content_id' => 0, 'album_date' => $thread['post_date'], 'album_updated_date' => $thread['last_post_date'], 'album_privacy' => serialize($albumPrivacy), 'category_id' => $categoryId, 'album_type' => sonnb_XenGallery_Model_Album::ALBUM_TYPE_NORMAL);
                 $albumId = $importModel->importXenGalleryAlbum($thread['thread_id'], $album, false);
                 if (!$albumId) {
                     return $this->responseError(new XenForo_Phrase('sonnb_xengallery_cannot_import_album_please_check_your_information'));
                 }
                 //Import photos
                 foreach ($attachments as $attachment) {
                     $this->_importXenGalleryPhoto($attachment, $importModel, $albumId);
                 }
                 //Import Comments
                 if ($posts && $importComment) {
                     foreach ($posts as $postId => $post) {
                         //$message = $parser->render($post['message']);
                         //$message = preg_replace('/\[(.*?)\]\s*(.*?)\s*\[(.*?)\]/', '[$1]$2[/$3]', $message);
                         $comment = array('content_type' => sonnb_XenGallery_Model_Album::$contentType, 'content_id' => $albumId, 'user_id' => $post['user_id'], 'username' => $post['username'], 'message' => $post['message'], 'comment_state' => $post['message_state'], 'comment_date' => $post['post_date']);
                         $importModel->importXenGalleryComment($postId, $comment, false);
                     }
                 }
                 break;
         }
         XenForo_Application::getDb()->update('xf_thread', array('sonnb_xengallery_import' => 1), array('thread_id = ?' => $thread['thread_id']));
         if (XenForo_Application::$versionId >= 1020000) {
             XenForo_Application::defer('Atomic', array('simple' => array('sonnb_XenGallery_Deferred_Album', 'sonnb_XenGallery_Deferred_Content')), 'importRebuild', false);
         }
         return $this->responseRedirect(XenForo_ControllerResponse_Redirect::SUCCESS, XenFOro_Link::buildPublicLink('gallery/albums', array('album_id' => $albumId)), new XenForo_Phrase('sonnb_xengallery_your_thread_has_been_imported_successful'));
     } else {
         $attachments = $this->_getXenGalleryAttachmentModel()->getAttachmentsForXenGalleryByThreadId($thread['thread_id']);
         $attachments = $this->_getAttachmentModel()->prepareAttachments($attachments);
         if (!count($attachments)) {
             return $this->responseError(new XenForo_Phrase('sonnb_xengallery_there_is_no_image_attached_to_this_thread'));
         }
         $albumConditions = array();
         $albumFetchOption = array('orderDirection' => 'DESC') + $this->_getXenGalleryAlbumModel()->getPermissionBasedAlbumFetchConditions();
         $albums = $this->_getXenGalleryAlbumModel()->getAlbumsByUserId($visitor['user_id'], $albumConditions, $albumFetchOption);
         return $this->responseView('sonnb_XenGallery_ViewPublic_Thread_Import', 'sonnb_xengallery_thread_import_index', array('thread' => $thread, 'forum' => $forum, 'categories' => $this->_getXenGalleryCategoryModel()->getAllCachedCategories(), 'albums' => $albums, 'attachments' => $attachments, 'totalAttachment' => count($attachments)));
     }
 }
示例#18
0
 public static function snippet($string, $maxLength = 0, array $options = array())
 {
     $gotCutOff = false;
     $posOpen = strpos($string, '<span class="prbreak"');
     if ($posOpen !== false) {
         if (preg_match('#<span class="prbreak"[^>]+>([^<]*)</span>#', $string, $matches, PREG_OFFSET_CAPTURE)) {
             $string = substr($string, 0, $matches[0][1]);
             $gotCutOff = true;
             if (!empty($options['link'])) {
                 if (!empty($matches[1][0])) {
                     $linkText = $matches[1][0];
                 } else {
                     $linkText = new XenForo_Phrase('wf_read_more');
                 }
                 /** @noinspection HtmlUnknownTarget */
                 $string .= sprintf('<div class="readMoreLink"><a href="%s">%s</a></div>', $options['link'], $linkText);
             }
         }
     }
     if ($maxLength > 0) {
         $string = strval($string);
         $string = XenForo_Helper_String::wholeWordTrim($string, $maxLength);
         $gotCutOff = true;
     }
     if ($gotCutOff) {
         // try to make valid HTML output
         $offset = 0;
         $opened = array();
         while (true) {
             $pos = strpos($string, '<', $offset);
             if ($pos === false) {
                 // while (true)
                 break;
             }
             $pos2 = strpos($string, '>', $pos);
             if ($pos2 !== false) {
                 $tag = strtolower(trim(substr($string, $pos + 1, $pos2 - $pos - 1)));
                 if (substr($tag, 0, 1) == '/') {
                     // closing
                     $pop = array_pop($opened);
                     if ($pop === substr($tag, 1)) {
                         // good closing
                     } else {
                         // bad closing
                         $opened[] = $pop;
                     }
                 } elseif (substr($tag, -1) == '/') {
                     // self-closing: ignore
                 } else {
                     // opening
                     $tagSpacePos = strpos($tag, ' ');
                     if ($tagSpacePos !== false) {
                         $tag = substr($tag, 0, $tagSpacePos);
                     }
                     $opened[] = $tag;
                 }
             } else {
                 // the opening/closing is not finished yet
                 // remove all of it, then stop
                 $string = substr($string, 0, $pos);
                 // while (true)
                 break;
             }
             $offset = $pos + 1;
         }
         while (count($opened) > 0) {
             // automatically add closing tags for opened ones
             $string .= sprintf('</%s>', array_pop($opened));
         }
     }
     return $string;
 }
示例#19
0
文件: Event.php 项目: Sywooch/forums
 public function getEventCalendarEntries(array $events)
 {
     $entries = array();
     $i = 0;
     foreach ($events as $eventId => $event) {
         $i++;
         $currentDate = XenForo_Locale::date($event['begin_date'], 'Y-m-d H:i:s');
         if ($event['end_date']) {
             $nextDate = XenForo_Locale::date($event['end_date'], 'Y-m-d H:i:s');
         } else {
             $nextDate = Date('Y-m-d', strtotime('+1 day', strtotime($currentDate)));
             $nextDate .= ' 00:00:00';
         }
         $entries[] = array('id' => $eventId, 'title' => XenForo_Helper_String::wholeWordTrim($event['event_title'], 25), 'start' => "{$currentDate}", 'url' => XenForo_Link::convertUriToAbsoluteUri(XenForo_Link::buildPublicLink(TEAM_ROUTE_ACTION . '/events', $event), true), 'allDay' => false, 'end' => "{$nextDate}", 'className' => 'eventEntry');
     }
     return $entries;
 }
示例#20
0
文件: Events.php 项目: Sywooch/forums
 public function updateEvent($input)
 {
     $input['event_mins'] = str_pad($input['event_mins'], 2, "0", STR_PAD_LEFT);
     $start = $input['event_date'] . " " . $input['event_time'] . ":" . $input['event_mins'] . " " . $input['event_ampm'] . " " . $input['event_timezone'];
     $expire = $input['event_recur_expire'] . " " . $input['event_time'] . ":" . $input['event_mins'] . " " . $input['event_ampm'] . " " . $input['event_timezone'];
     $input['event_strtime'] = strtotime($start);
     $input['event_recur_expire'] = strtotime($expire);
     $input['event_recur_units'] = $input['event_recur'] ? $input['event_recur_units'] : 'none';
     $input['event_recur_expire'] = $input['event_expire'] ? $input['event_recur_expire'] : '0';
     $input['event_endtime'] = $input['event_strtime'] + $input['event_length'] * 3600;
     $threadDate = new DateTime(date('r', $input['event_strtime']));
     $threadDate->setTimezone(new DateTimeZone($input['event_timezone']));
     $threadDate = $threadDate->format(XenForo_Application::get('options')->EWRatendo_dateformat);
     $threadCity = $input['event_citystate'] ? $input['event_citystate'] : $input['event_venue'];
     $dCount = strlen($threadDate);
     $cCount = strlen($threadCity);
     $input['event_title'] = XenForo_Helper_String::wholeWordTrim($input['event_title'], 90 - ($dCount + $cCount));
     $input['thread_title'] = XenForo_Application::get('options')->EWRatendo_threadformat;
     $input['thread_title'] = str_ireplace('{date}', $threadDate, $input['thread_title']);
     $input['thread_title'] = str_ireplace('{location}', $threadCity, $input['thread_title']);
     $input['thread_title'] = str_ireplace('{event}', $input['event_title'], $input['thread_title']);
     $dw = XenForo_DataWriter::create('EWRatendo_DataWriter_Events');
     if (!empty($input['event_id']) && ($event = $this->getEventById($input['event_id']))) {
         $dw->setExistingData($event);
     }
     $dw->bulkSet(array('event_title' => $input['event_title'], 'event_venue' => $input['event_venue'], 'event_address' => $input['event_address'], 'event_citystate' => $input['event_citystate'], 'event_zipcode' => $input['event_zipcode'], 'event_strtime' => $input['event_strtime'], 'event_endtime' => $input['event_endtime'], 'event_timezone' => $input['event_timezone'], 'event_rsvp' => $input['event_rsvp'], 'event_recur_count' => $input['event_recur_count'], 'event_recur_units' => $input['event_recur_units'], 'event_recur_expire' => $input['event_recur_expire'], 'event_state' => empty($input['bypass']) ? 'moderated' : 'visible'));
     if (empty($input['create_thread'])) {
         $dw->set('event_description', XenForo_Helper_String::autoLinkBbCode($input['event_description']));
     }
     $dw->save();
     $input['event_id'] = $dw->get('event_id');
     $input['thread_id'] = $dw->get('thread_id');
     if (!empty($input['thread_id'])) {
         $this->getModelFromCache('EWRatendo_Model_Threads')->updateThread($input);
     } elseif (!empty($input['create_thread'])) {
         $input['user_id'] = $dw->get('user_id');
         $input['username'] = $dw->get('username');
         $input['event_id'] = $dw->get('event_id');
         $input['thread_id'] = $this->getModelFromCache('EWRatendo_Model_Threads')->buildThread($input);
     }
     $this->getModelFromCache('EWRatendo_Model_Recurs')->buildRecursByEvent($input);
     return $input;
 }
示例#21
0
 public function getModule(&$options, $page, $category = false)
 {
     if ($page == 1) {
         $page = 6;
     } else {
         $page = ($page - 1) * $options['limit'];
     }
     $fromWhere = '';
     $fromOrder = '';
     if ($category) {
         $fromWhere = "INNER JOIN EWRporta_catlinks ON (EWRporta_catlinks.thread_id = xf_thread.thread_id)\r\n\t\t\t\tINNER JOIN EWRporta_categories ON (EWRporta_categories.category_id = EWRporta_catlinks.category_id AND EWRporta_categories.category_slug = '" . $category . "')";
     }
     if ($options['sticky']) {
         $fromOrder = "sticky DESC, ";
     }
     $news = $this->_getDb()->fetchAll("\r\n\t\t\tSELECT xf_thread.*, xf_user.*, xf_post.message, xf_post.attach_count, xf_node.title AS node_title, \r\n\t\t\t\tIF(xf_user.username IS NULL, xf_thread.username, xf_user.username) AS username,\r\n\t\t\t\tIF(EWRporta_promotes.promote_date IS NULL, xf_thread.post_date, EWRporta_promotes.promote_date) AS promote_date,\r\n\t\t\t\tEWRporta_promotes.promote_icon, EWRporta_promotes.promote_data\r\n\t\t\tFROM xf_thread\r\n\t\t\t\tLEFT JOIN xf_user ON (xf_user.user_id = xf_thread.user_id)\r\n\t\t\t\tINNER JOIN xf_post ON (xf_post.post_id = xf_thread.first_post_id)\r\n\t\t\t\tINNER JOIN xf_node ON (xf_node.node_id = xf_thread.node_id)\r\n\t\t\t\tLEFT JOIN EWRporta_promotes ON (EWRporta_promotes.thread_id = xf_thread.thread_id)\r\n\t\t\t{$fromWhere}\r\n\t\t\tWHERE (xf_thread.node_id IN (" . $this->_getDb()->quote($options['forum']) . ") OR EWRporta_promotes.promote_date < ?)\r\n\t\t\t\tAND xf_thread.discussion_state = 'visible'\r\n\t\t\t\tAND IF(EWRporta_promotes.promote_date IS NULL, xf_thread.post_date, EWRporta_promotes.promote_date) < ?\r\n\t\t\tORDER BY {$fromOrder} promote_date DESC\r\n\t\t\tLIMIT ?, ?\r\n\t\t", array(XenForo_Application::$time, XenForo_Application::$time, $page, $options['limit']));
     foreach ($news as &$post) {
         $strtime = new DateTime(date('r', $post['promote_date']));
         $strtime->setTimezone(new DateTimeZone(XenForo_Application::get('options')->guestTimeZone));
         list($post['month'], $post['day']) = explode('.', $strtime->format('n.d'));
         $post['month'] = new XenForo_Phrase('month_' . $post['month'] . '_short');
         if ($post['attach_count']) {
             $post['attachments'] = $this->getModelFromCache('XenForo_Model_Attachment')->getAttachmentsByContentId('post', $post['first_post_id']);
             $post['attachments'] = $this->getModelFromCache('XenForo_Model_Attachment')->prepareAttachments($post['attachments']);
         }
         if ($post['promote_icon'] != 'disabled') {
             switch ($post['promote_icon']) {
                 case 'avatar':
                     $post['showIcon'] = true;
                 case 'url':
                     $post['showIcon'] = true;
                     break;
                 case 'attach':
                     if ($post['attach'] = $this->getAttach($post)) {
                         $post['showIcon'] = true;
                     }
                     break;
                 case 'image':
                     if ($post['image'] = $this->getImage($post)) {
                         $post['showIcon'] = true;
                     }
                     break;
                 case 'medio':
                     if ($post['medio'] = $this->getMedio($post)) {
                         $post['showIcon'] = true;
                     }
                     break;
             }
             if (empty($post['showIcon'])) {
                 $post = $this->getDefault($post);
             }
         }
         $post['message'] = str_ireplace('prbreak]', 'prebreak]', $post['message']);
         $post['message'] = preg_replace('#\\n{3,}#', "\n\n", trim($post['message']));
         if ($trimLoc = stripos($post['message'], '[prebreak]')) {
             $prbreak = '';
             if (($breakLoc = stripos($post['message'], '[/prebreak]', $trimLoc + 10)) && ($length = $breakLoc - $trimLoc - 10)) {
                 $link = XenForo_Link::buildPublicLink('full:threads', $post);
                 $prbreak = " [url='" . $link . "']" . substr($post['message'], $trimLoc + 10, $length) . '[/url]...';
             }
             $post['message'] = substr($post['message'], 0, $trimLoc) . $prbreak;
         } else {
             $post['message'] = XenForo_Helper_String::wholeWordTrim($post['message'], $options['truncate']);
         }
     }
     $options['parseBB'] = true;
     $options['count'] = $this->getCount($options, $category);
     return $news;
 }
示例#22
0
 /**
  * Prepares a social forum for display.
  *
  * @param array $socialForum Unprepared social forum
  * @return array Prepared social forum
  */
 public function prepareSocialForum(array $socialForum, array $forum = array(), array $permissions = array())
 {
     $socialForum['hasNew'] = isset($socialForum['social_forum_read_date']) && $socialForum['social_forum_read_date'] < $socialForum['last_post_date'];
     $socialForum['lastPost'] = array('post_id' => $socialForum['last_post_id'], 'date' => $socialForum['last_post_date'], 'user_id' => $socialForum['last_post_user_id'], 'username' => $socialForum['last_post_username'], 'title' => $socialForum['last_thread_title']);
     $permissions = $this->getSocialForumPermissions($socialForum, $permissions);
     if (!isset($permissions['viewOthers']) || !$permissions['viewOthers']) {
         $socialForum['privateInfo'] = true;
     }
     $socialForum['description'] = XenForo_Helper_String::wholeWordTrim($socialForum['description'], 200);
     return $socialForum;
 }