当前位置: 首页>>代码示例>>PHP>>正文


PHP XenForo_Helper_String::wholeWordTrim方法代码示例

本文整理汇总了PHP中XenForo_Helper_String::wholeWordTrim方法的典型用法代码示例。如果您正苦于以下问题:PHP XenForo_Helper_String::wholeWordTrim方法的具体用法?PHP XenForo_Helper_String::wholeWordTrim怎么用?PHP XenForo_Helper_String::wholeWordTrim使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在XenForo_Helper_String的用法示例。


在下文中一共展示了XenForo_Helper_String::wholeWordTrim方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: _Tinhte_XenTag_prepareRssEntry

 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;
 }
开发者ID:maitandat1507,项目名称:Tinhte_XenTag,代码行数:34,代码来源:View.php

示例2: renderVerification

 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();
 }
开发者ID:VoDongMy,项目名称:xenforo-laravel5.1,代码行数:7,代码来源:Totp.php

示例3: renderRss

 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' => 'invalid@example.com', 'uri' => XenForo_Link::buildPublicLink('canonical:members', $thread)));
             if ($thread['reply_count']) {
                 $entry->setCommentCount($thread['reply_count']);
             }
         }
         $feed->addEntry($entry);
     }
     return $feed->export('rss');
 }
开发者ID:VoDongMy,项目名称:xenforo-laravel5.1,代码行数:46,代码来源:GlobalRss.php

示例4: publish

 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)));
     }
 }
开发者ID:Sywooch,项目名称:forums,代码行数:41,代码来源:Twitter.php

示例5: prepareMessage

 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;
 }
开发者ID:NixFifty,项目名称:XenForo-SimplePortal,代码行数:22,代码来源:Item.php

示例6: _updateSocialForum

 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');
 }
开发者ID:AndroidOS,项目名称:SocialGroups,代码行数:36,代码来源:Update.php

示例7: _nodeForumLevel2

 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);
     }
 }
开发者ID:ThemeHouse-XF,项目名称:LastPostAvatar,代码行数:36,代码来源:TemplatePostRender.php

示例8: _insertDiscussionThread

 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');
 }
开发者ID:Sywooch,项目名称:forums,代码行数:32,代码来源:Team.php

示例9: _verifyTitle

 /**
  * 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;
 }
开发者ID:namgiangle90,项目名称:tokyobaito,代码行数:26,代码来源:Discussion.php

示例10: helperWordTrim

 /**
  * 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));
 }
开发者ID:hahuunguyen,项目名称:DTUI_201105,代码行数:10,代码来源:Core.php

示例11: _postSave

 /**
  *
  * @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\'');
     }
 }
开发者ID:Sywooch,项目名称:forums,代码行数:77,代码来源:ConversationMaster.php

示例12: _convertUserFieldChoices

 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;
 }
开发者ID:darkearl,项目名称:projectT122015,代码行数:50,代码来源:vBulletin.php

示例13: _updateThread

 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');
 }
开发者ID:Sywooch,项目名称:forums,代码行数:32,代码来源:Update.php

示例14: _insertFeedEntry

    /**
     * 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;
    }
开发者ID:namgiangle90,项目名称:tokyobaito,代码行数:51,代码来源:Feed.php

示例15: actionUpdate

 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));
     }
 }
开发者ID:Sywooch,项目名称:forums,代码行数:45,代码来源:Resource.php


注:本文中的XenForo_Helper_String::wholeWordTrim方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。