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


PHP XenForo_BbCode_Parser::render方法代码示例

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


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

示例1: renderHtml

 public function renderHtml()
 {
     $bbCodeParser = new XenForo_BbCode_Parser(XenForo_BbCode_Formatter_Base::create('Base', array('view' => $this)));
     $this->_params['media']['HTML'] = new XenForo_BbCode_TextWrapper($this->_params['media']['media_description'], $bbCodeParser);
     $bbCodeStripper = new XenForo_BbCode_Parser(XenForo_BbCode_Formatter_Base::create('XenForo_BbCode_Formatter_Text'));
     $this->_params['media']['TEXT'] = $bbCodeStripper->render($this->_params['media']['media_description']);
 }
开发者ID:Sywooch,项目名称:forums,代码行数:7,代码来源:MediaView.php

示例2: renderHtml

 public function renderHtml()
 {
     $previewLength = XenForo_Application::get('options')->discussionPreviewLength;
     if ($previewLength && !empty($this->_params['post'])) {
         $formatter = XenForo_BbCode_Formatter_Base::create('XenForo_BbCode_Formatter_Text');
         $parser = new XenForo_BbCode_Parser($formatter);
         $this->_params['post']['messageParsed'] = $parser->render($this->_params['post']['message']);
     }
 }
开发者ID:hahuunguyen,项目名称:DTUI_201105,代码行数:9,代码来源:Preview.php

示例3: __toString

    /**
     * Renders the text.
     *
     * @return string
     */
    public function __toString()
    {
        try {
            if (XenForo_Application::getOptions()->cacheBbCodeTree && !empty($this->_cache['contentType']) && !empty($this->_cache['contentId'])) {
                $tree = null;
                if (!empty($this->_cache['cache']) && !empty($this->_cache['cacheVersion']) && $this->_cache['cacheVersion'] == XenForo_Application::getOptions()->bbCodeCacheVersion) {
                    if (is_array($this->_cache['cache'])) {
                        $tree = $this->_cache['cache'];
                    } else {
                        $tree = @unserialize($this->_cache['cache']);
                    }
                }
                if (!$tree) {
                    try {
                        // need to update
                        $tree = $this->_parser->parse($this->_text);
                        $this->_cache['cache'] = $tree;
                        $this->_cache['cacheVersion'] = XenForo_Application::getOptions()->bbCodeCacheVersion;
                        $uniqueId = $this->_cache['contentType'] . '-' . $this->_cache['contentId'];
                        if (empty(self::$_cacheWritten[$uniqueId])) {
                            XenForo_Application::getDb()->query('
								INSERT INTO xf_bb_code_parse_cache
									(content_type, content_id, parse_tree, cache_version, cache_date)
								VALUES (?, ?, ?, ?, ?)
								ON DUPLICATE KEY UPDATE parse_tree = VALUES(parse_tree),
									cache_version = VALUES(cache_version),
									cache_date = VALUES(cache_date)
							', array($this->_cache['contentType'], $this->_cache['contentId'], serialize($tree), $this->_cache['cacheVersion'], XenForo_Application::$time));
                            self::$_cacheWritten[$uniqueId] = true;
                        }
                    } catch (Exception $e) {
                        return $this->_parser->render($this->_text, $this->_extraStates);
                    }
                }
                return $this->_parser->render($tree, $this->_extraStates);
            } else {
                return $this->_parser->render($this->_text, $this->_extraStates);
            }
        } catch (Exception $e) {
            XenForo_Error::logException($e, false, "BB code to string error:");
            return '';
        }
    }
开发者ID:namgiangle90,项目名称:tokyobaito,代码行数:48,代码来源:TextWrapper.php

示例4: actionGetSubscriptions

 public function actionGetSubscriptions()
 {
     $page = max($this->_input->filterSingle('page', XenForo_Input::UINT), 1);
     $perpage = $this->_input->filterSingle('perpage', XenForo_Input::UINT);
     if (!$perpage) {
         $perpage = XenForo_Application::get('options')->discussionsPerPage;
     }
     $previewtype = $this->_input->filterSingle('previewtype', XenForo_Input::UINT);
     if (!$previewtype) {
         $previewtype = 2;
     }
     $visitor = XenForo_Visitor::getInstance();
     $watch_model = $this->_getThreadWatchModel();
     $threads = $watch_model->getThreadsWatchedByUser($visitor['user_id'], false, array('join' => XenForo_Model_Thread::FETCH_FORUM | XenForo_Model_Thread::FETCH_USER, 'readUserId' => $visitor['user_id'], 'page' => $page, 'perPage' => $perpage, 'postCountUserId' => $visitor['user_id'], 'permissionCombinationId' => $visitor['permission_combination_id']));
     $threads = $watch_model->unserializePermissionsInList($threads, 'node_permission_cache');
     $threads = $watch_model->getViewableThreadsFromList($threads);
     $threads = $this->_prepareWatchedThreads($threads);
     $total = $watch_model->countThreadsWatchedByUser($visitor['user_id']);
     $this->canonicalizePageNumber($page, $perpage, $total, 'watched/threads/all');
     $thread_data = array();
     $thread_model = $this->_getThreadModel();
     $post_model = $this->getModelFromCache('XenForo_Model_Post');
     $preview_length = XenForo_Application::get('options')->discussionPreviewLength;
     $formatter = XenForo_BbCode_Formatter_Base::create('XenForo_BbCode_Formatter_Text');
     $parser = new XenForo_BbCode_Parser($formatter);
     foreach ($threads as &$thread) {
         $out = array('thread_id' => $thread['thread_id'], 'forum_title' => prepare_utf8_string($thread['node_title']), 'new_posts' => $thread['isNew'], 'forum_id' => $thread['node_id'], 'total_posts' => $thread['reply_count'] + 1, 'thread_title' => prepare_utf8_string(strip_tags($thread['title'])), 'post_lastposttime' => prepare_utf8_string(XenForo_Locale::dateTime($thread['last_post_date'], 'absolute')));
         if ($previewtype == 1) {
             $out += array('post_username' => prepare_utf8_string(strip_tags($thread['username'])), 'post_userid' => $thread['user_id']);
         } else {
             $out += array('post_username' => prepare_utf8_string(strip_tags($thread['last_post_username'])), 'post_userid' => $thread['last_post_user_id']);
         }
         $post = $post_model->getPostById($thread[$previewtype == 1 ? 'first_post_id' : 'last_post_id'], array('join' => XenForo_Model_Post::FETCH_USER));
         $avatarurl = process_avatarurl(XenForo_Template_Helper_Core::getAvatarUrl($post, 'm'));
         if (strpos($avatarurl, '/xenforo/avatars/avatar_') !== false) {
             $avatarurl = '';
         }
         if ($avatarurl != '') {
             $out['avatarurl'] = $avatarurl;
         }
         $preview = '';
         if ($preview_length) {
             $preview = $parser->render($post['message']);
         }
         if ($preview != '') {
             $out['thread_preview'] = prepare_utf8_string(html_entity_decode($preview));
         }
         if ($thread['discussion_type'] == 'poll') {
             $out['poll'] = true;
         }
         $thread_data[] = $out;
     }
     $out = array('threads' => $thread_data, 'total_threads' => $total);
     return $out;
 }
开发者ID:Sywooch,项目名称:forums,代码行数:55,代码来源:Subscriptions.php

示例5: renderJson

 public function renderJson()
 {
     $options = XenForo_Application::get('options');
     $formatter = XenForo_BbCode_Formatter_Base::create('Dark_TaigaChat_BbCode_Formatter_Tenori', array('view' => $this));
     switch ($options->dark_taigachat_bbcode) {
         case 'Full':
             $formatter->displayableTags = true;
             break;
         case 'Basic':
         default:
             $formatter->displayableTags = array('img', 'url', 'email', 'b', 'u', 'i', 's', 'color');
             break;
         case 'None':
             $formatter->displayableTags = array('url', 'email');
             break;
     }
     $formatter->getTagsAgain();
     $parser = new XenForo_BbCode_Parser($formatter);
     if ($options->dark_taigachat_imagemode == 'Link') {
         foreach ($this->_params['taigachat']['messages'] as &$message) {
             $message['message'] = str_ireplace(array("[img]", "[/img]"), array("[url]", "[/url]"), $message['message']);
         }
     }
     $maxid = $this->_params['taigachat']['lastrefresh'];
     foreach ($this->_params['taigachat']['messages'] as &$message) {
         if ($options->dark_taigachat_bbcode == 'Full') {
             $message['message'] = XenForo_Helper_String::autoLinkBbCode($message['message']);
         } else {
             // We don't want to parse youtube etc. urls if [media] is disabled
             $autoLinkParser = new XenForo_BbCode_Parser(XenForo_BbCode_Formatter_Base::create('Dark_TaigaChat_BbCode_Formatter_BbCode_AutoLink', false));
             $message['message'] = $autoLinkParser->render($message['message']);
         }
         if ($message['id'] > $maxid) {
             $maxid = $message['id'];
         }
     }
     XenForo_ViewPublic_Helper_Message::bbCodeWrapMessages($this->_params['taigachat']['messages'], $parser);
     if ($options->dark_taigachat_direction) {
         $this->_params['taigachat']['messages'] = array_reverse($this->_params['taigachat']['messages']);
     }
     $template = $this->createTemplateObject($this->_templateName, $this->_params);
     $template->setParams($this->_params);
     $rendered = $template->render();
     $rendered = preg_replace('/\\s+<\\/(.*?)>\\s+</si', ' </$1> <', $rendered);
     $rendered = preg_replace('/\\s+<(.*?)([ >])/si', ' <$1$2', $rendered);
     //$rendered = str_replace(array("\r", "\n", "\t"), "", $rendered);
     $derp = XenForo_ViewRenderer_Json::jsonEncodeForOutput(array("templateHtml" => $rendered, "reverse" => $options->dark_taigachat_direction, "lastrefresh" => $maxid));
     $extraHeaders = XenForo_Application::gzipContentIfSupported($derp);
     foreach ($extraHeaders as $extraHeader) {
         header("{$extraHeader['0']}: {$extraHeader['1']}", $extraHeader[2]);
     }
     return $derp;
 }
开发者ID:Sywooch,项目名称:forums,代码行数:53,代码来源:List.php

示例6: helperPreparePostDataForDisplay

 public static function helperPreparePostDataForDisplay($posts)
 {
     $bbCodeFormatter = XenForo_BbCode_Formatter_Base::create('Base');
     $bbCodeParser = new XenForo_BbCode_Parser($bbCodeFormatter);
     $bbCodeOptions = array('states' => array('viewAttachments' => true));
     XenForo_ViewPublic_Helper_Message::bbCodeWrapMessages($posts, $bbCodeParser, $bbCodeOptions);
     foreach ($posts as &$message) {
         $bbCodeParser = new XenForo_BbCode_Parser(XenForo_BbCode_Formatter_Base::create('XenForo_BbCode_Formatter_Text'));
         $message['messageText'] = $bbCodeParser->render(str_ireplace('\\n', ' ', $message['message']));
         $message['messageText'] = str_ireplace("\n", " ", $message['messageText']);
     }
     return $posts;
 }
开发者ID:Sywooch,项目名称:forums,代码行数:13,代码来源:Post.php

示例7: processMessagesForView

 public static function processMessagesForView(&$params, &$view)
 {
     $options = XenForo_Application::get('options');
     $formatter = XenForo_BbCode_Formatter_Base::create('Dark_TaigaChat_BbCode_Formatter_Tenori', array('view' => $view));
     switch ($options->dark_taigachat_bbcode) {
         case 'Full':
             $formatter->displayableTags = true;
             break;
         case 'Basic':
         default:
             $formatter->displayableTags = array('img', 'url', 'email', 'b', 'u', 'i', 's', 'color');
             break;
         case 'None':
             $formatter->displayableTags = array('url', 'email');
             break;
     }
     $formatter->getTagsAgain();
     $parser = new XenForo_BbCode_Parser($formatter);
     if ($options->dark_taigachat_imagemode == 'Link') {
         foreach ($params['taigachat']['messages'] as &$message) {
             $message['message'] = str_ireplace(array("[img]", "[/img]"), array("[url]", "[/url]"), $message['message']);
         }
     }
     $maxUpdate = $params['taigachat']['lastrefresh'];
     foreach ($params['taigachat']['messages'] as &$message) {
         if ($options->dark_taigachat_bbcode == 'Full') {
             $message['message'] = XenForo_Helper_String::autoLinkBbCode($message['message']);
         } else {
             // We don't want to parse youtube etc. urls if [media] is disabled
             $autoLinkParser = new XenForo_BbCode_Parser(XenForo_BbCode_Formatter_Base::create('Dark_TaigaChat_BbCode_Formatter_BbCode_AutoLink', false));
             $message['message'] = $autoLinkParser->render($message['message']);
         }
         if ($message['last_update'] > $maxUpdate) {
             $maxUpdate = $message['last_update'];
         }
         if (substr($message['message'], 0, 3) == '/me') {
             $message['message'] = substr($message['message'], 4);
             $message['me'] = true;
         }
     }
     if ($options->dark_taigachat_smilies) {
         XenForo_ViewPublic_Helper_Message::bbCodeWrapMessages($params['taigachat']['messages'], $parser);
     } else {
         XenForo_ViewPublic_Helper_Message::bbCodeWrapMessages($params['taigachat']['messages'], $parser, array("states" => array("stopSmilies" => true)));
     }
     if ($options->dark_taigachat_direction) {
         $params['taigachat']['messages'] = array_reverse($params['taigachat']['messages']);
     }
     return max($maxUpdate, XenForo_Application::getSimpleCacheData('taigachat_lastUpdate'));
 }
开发者ID:VoDongMy,项目名称:xenforo-laravel5.1,代码行数:50,代码来源:Global.php

示例8: renderRss

 public function renderRss()
 {
     $xenOptions = XenForo_Application::getOptions();
     if ($xenOptions->sonnbXG_enableRSS) {
         $title = new XenForo_Phrase('sonnb_xengallery');
         $title = $title->render();
         $description = new XenForo_Phrase('sonnb_xengallery_short_description', array('title' => $xenOptions->boardTitle));
         $description = $description->render();
         $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:gallery'));
         if (!$buggyXmlNamespace) {
             $feed->setFeedLink(XenForo_Link::buildPublicLink('canonical:gallery/index.rss'), 'rss');
         }
         $feed->setDateModified(XenForo_Application::$time);
         $feed->setLastBuildDate(XenForo_Application::$time);
         $feed->setGenerator($title);
         $formatter = XenForo_BbCode_Formatter_Base::create('XenForo_BbCode_Formatter_Text', array('view' => $this));
         $parser = new XenForo_BbCode_Parser($formatter);
         foreach ($this->_params['albums'] as $album) {
             $albumDescription = $parser->render($album['description']);
             $entry = $feed->createEntry();
             if (!empty($album['contents'])) {
                 $albumDescription .= '<br /><br />';
                 foreach ($album['contents'] as $content) {
                     $albumDescription .= '<a href="' . XenForo_Link::buildPublicLink('canonical:gallery/' . $content['content_type'] . 's', $content) . '"><img src="' . XenForo_Link::convertUriToAbsoluteUri($content['thumbnailUrl'], true) . '" /></a>';
                 }
             }
             if ($albumDescription) {
                 $entry->setDescription($albumDescription);
             }
             $entry->setTitle($album['title'] ? $album['title'] : $album['title'] . ' ');
             $entry->setLink(XenForo_Link::buildPublicLink('canonical:gallery/albums', $album));
             $entry->setDateCreated(new Zend_Date($album['album_date'], Zend_Date::TIMESTAMP));
             $entry->setDateModified(new Zend_Date($album['album_updated_date'], Zend_Date::TIMESTAMP));
             if (!$buggyXmlNamespace) {
                 $entry->addAuthor(array('name' => $album['username'], 'uri' => XenForo_Link::buildPublicLink('canonical:gallery/authors', $album)));
                 if ($album['comment_count']) {
                     $entry->setCommentCount($album['comment_count']);
                     $entry->setCommentLink(XenForo_Link::buildPublicLink('canonical:gallery/albums', $album) . '#album-' . $album['album_id']);
                 }
             }
             $feed->addEntry($entry);
         }
         return $feed->export('rss');
     }
 }
开发者ID:Sywooch,项目名称:forums,代码行数:50,代码来源:List.php

示例9: _processImageRestrictionLinks

 protected function _processImageRestrictionLinks()
 {
     $users = $this->get('imagerestriction_users');
     if (!is_array($users)) {
         $users = @unserialize($users);
     }
     if (empty($users)) {
         $users = array();
     }
     if (!empty($users)) {
         $message = $this->get('message');
         $bbCodeParser = new XenForo_BbCode_Parser(XenForo_BbCode_Formatter_Base::create('ThemeHouse_ImageRestrict_BbCode_Formatter_Reverse', array('smilies' => array(), 'bbCode' => array())));
         $message = $bbCodeParser->render($message, array('attachment_hash' => $this->getExtraData(XenForo_DataWriter_DiscussionMessage::DATA_ATTACHMENT_HASH), 'post_id' => $this->get('post_id'), 'stopLineBreakConversion' => true));
         $this->set('message', $message);
         $this->_updateImageRestrictionMask = true;
     }
 }
开发者ID:ThemeHouse-XF,项目名称:ImageRestrict,代码行数:17,代码来源:Post.php

示例10: getEditorTemplate

 /**
  * Gets the editor template. The WYSIWYG editor will be used if supported by
  * the browser.
  *
  * @param XenForo_View $view
  * @param string $formCtrlName Name of the textarea. If using the WYSIWYG editor, this will have _html appended to it.
  * @param string $message Default message to put in editor. This should contain BB code
  * @param array $editorOptions Array of options for the editor. Defaults are provided for any unspecified
  * 	Currently supported:
  * 		editorId - (string) override normal {formCtrlName}_html id
  * 		templateName - (string) override normal 'editor' name
  * 		disable - (boolean) true to prevent WYSIWYG from activating
  *
  * @return XenForo_Template_Abstract
  */
 public static function getEditorTemplate(XenForo_View $view, $formCtrlName, $message = '', array $editorOptions = array())
 {
     $messageHtml = '';
     if (!empty($editorOptions['disable'])) {
         $showWysiwyg = false;
     } else {
         if (!XenForo_Visitor::getInstance()->enable_rte) {
             $showWysiwyg = false;
         } else {
             $showWysiwyg = !XenForo_Visitor::isBrowsingWith('mobile');
         }
     }
     if ($showWysiwyg) {
         if (substr($formCtrlName, -1) == ']') {
             $formCtrlNameHtml = substr($formCtrlName, 0, -1) . '_html]';
         } else {
             $formCtrlNameHtml = $formCtrlName . '_html';
         }
         if ($message !== '') {
             $bbCodeParser = new XenForo_BbCode_Parser(XenForo_BbCode_Formatter_Base::create('Wysiwyg', array('view' => $view)));
             $messageHtml = $bbCodeParser->render($message, array('lightBox' => false));
         }
     } else {
         $formCtrlNameHtml = $formCtrlName;
     }
     // get editor id
     if (isset($editorOptions['editorId'])) {
         $editorId = $editorOptions['editorId'];
     } else {
         $ctrlInc = 0;
         do {
             $editorId = 'ctrl_' . $formCtrlName . ($ctrlInc ? "_{$ctrlInc}" : '');
             $ctrlInc++;
         } while (isset(self::$_editorIds[$editorId]) && $ctrlInc < 100);
         self::$_editorIds[$editorId] = true;
     }
     $templateName = isset($editorOptions['templateName']) ? $editorOptions['templateName'] : 'editor';
     $height = isset($editorOptions['height']) ? $editorOptions['height'] : '260px';
     return $view->createTemplateObject($templateName, array('showWysiwyg' => $showWysiwyg, 'height' => $height, 'formCtrlNameHtml' => $formCtrlNameHtml, 'formCtrlName' => $formCtrlName, 'editorId' => $editorId, 'message' => $message, 'messageHtml' => $messageHtml, 'smilies' => $showWysiwyg ? self::getEditorSmilies() : array()));
 }
开发者ID:hahuunguyen,项目名称:DTUI_201105,代码行数:55,代码来源:Editor.php

示例11: _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

示例12: getResourceFieldValueHtml

 /**
  * Gets the HTML value of the resource field.
  *
  * @param array $resource
  * @param array|string $field If string, field ID
  * @param mixed $value Value of the field; if null, pulls from field_value in field
  *
  * @return string
  */
 public static function getResourceFieldValueHtml(array $resource, $field, $value = null)
 {
     if (!is_array($field)) {
         $fields = XenForo_Model::create('XenResource_Model_ResourceField')->getResourceFieldCache();
         if (!isset($fields[$field])) {
             return '';
         }
         $field = $fields[$field];
     }
     if (!XenForo_Application::isRegistered('view')) {
         return 'No view registered';
     }
     if ($value === null && isset($field['field_value'])) {
         $value = $field['field_value'];
     }
     if ($value === '' || $value === null) {
         return '';
     }
     $multiChoice = false;
     $choice = '';
     $view = XenForo_Application::get('view');
     switch ($field['field_type']) {
         case 'radio':
         case 'select':
             $choice = $value;
             $value = new XenForo_Phrase("resource_field_{$field['field_id']}_choice_{$value}");
             $value->setPhraseNameOnInvalid(false);
             $valueRaw = $value;
             break;
         case 'checkbox':
         case 'multiselect':
             $multiChoice = true;
             if (!is_array($value) || count($value) == 0) {
                 return '';
             }
             $newValues = array();
             foreach ($value as $id => $choice) {
                 $phrase = new XenForo_Phrase("resource_field_{$field['field_id']}_choice_{$choice}");
                 $phrase->setPhraseNameOnInvalid(false);
                 $newValues[$choice] = $phrase;
             }
             $value = $newValues;
             $valueRaw = $value;
             break;
         case 'bbcode':
             $valueRaw = htmlspecialchars(XenForo_Helper_String::censorString($value));
             $bbCodeParser = new XenForo_BbCode_Parser(XenForo_BbCode_Formatter_Base::create('Base', array('view' => $view)));
             $value = $bbCodeParser->render($value, array('noFollowDefault' => empty($resource['isTrusted'])));
             break;
         case 'textbox':
         case 'textarea':
         default:
             $valueRaw = htmlspecialchars(XenForo_Helper_String::censorString($value));
             $value = XenForo_Template_Helper_Core::callHelper('bodytext', array($value));
     }
     if (!empty($field['display_template'])) {
         if ($multiChoice && is_array($value)) {
             foreach ($value as $choice => &$thisValue) {
                 $thisValue = strtr($field['display_template'], array('{$fieldId}' => $field['field_id'], '{$value}' => $thisValue, '{$valueRaw}' => $thisValue, '{$valueUrl}' => urlencode($thisValue), '{$choice}' => $choice));
             }
         } else {
             $value = strtr($field['display_template'], array('{$fieldId}' => $field['field_id'], '{$value}' => $value, '{$valueRaw}' => $valueRaw, '{$valueUrl}' => urlencode($value), '{$choice}' => $choice));
         }
     }
     if (is_array($value)) {
         if (empty($value)) {
             return '';
         }
         return '<ul class="plainList"><li>' . implode('</li><li>', $value) . '</li></ul>';
     }
     return $value;
 }
开发者ID:Sywooch,项目名称:forums,代码行数:81,代码来源:Resource.php

示例13: stepVideos

    public function stepVideos($start, array $options)
    {
        $options = array_merge(array('limit' => 50, 'processed' => 0, 'max' => false), $options);
        $db = $this->_db;
        $model = $this->_importModel;
        if ($options['max'] === false) {
            $data = $db->fetchRow('
    				SELECT MAX(media_id) AS max, COUNT(media_id) AS rows
    				FROM EWRmedio_media
			');
            $options = array_merge($options, $data);
            return array(0, $options, "Processing Videos ...");
        }
        $videos = $db->fetchAll($db->limit("\n    \t\t\t\tSELECT media.*, services.service_name\n    \t\t\t\tFROM EWRmedio_media AS media\n\n\t\t\t\t\tLEFT JOIN EWRmedio_services AS services\n\t\t\t\t\t\tON (services.service_id = media.service_id)\n\n    \t\t\t\tWHERE\n    \t\t\t\t    media.media_id > " . $db->quote($start) . "\n    \t\t\t\tORDER BY media.media_id ASC\n    \t\t\t", $options['limit']));
        if (!$videos) {
            return true;
        }
        $next = 0;
        $last = 0;
        $total = 0;
        $position = 0;
        if ($this->_config['importType'] == self::XENMEDIO_IMPORT_TYPE_CATEGORY_AS_ALBUM) {
            $albumIdMap = $model->getAlbumIdsMapFromArray($videos, 'category_id');
        } else {
            $albumIdMap = $model->getAlbumIdsMapFromArray($videos, 'user_id');
        }
        $formatter = XenForo_BbCode_Formatter_Base::create('XenForo_BbCode_Formatter_Text');
        $parser = new XenForo_BbCode_Parser($formatter);
        foreach ($videos as $video) {
            $next = $video['media_id'];
            if (empty($video['user_id'])) {
                continue;
            }
            if ($this->_config['importType'] == self::XENMEDIO_IMPORT_TYPE_CATEGORY_AS_ALBUM) {
                if (empty($albumIdMap[$video['category_id']])) {
                    continue;
                }
                $albumId = $albumIdMap[$video['category_id']];
            } else {
                if (empty($albumIdMap[$video['user_id']])) {
                    continue;
                }
                $albumId = $albumIdMap[$video['user_id']];
            }
            if ($last != $next) {
                $last = $next;
                $importVideoData = array('file_size' => 0, 'width' => 0, 'height' => 0, 'file_hash' => 0, 'upload_date' => $video['media_date'], 'duration' => $video['media_duration'], 'unassociated' => 1, 'extension' => 'jpg');
                $videoData = $model->importXenGalleryVideoData($video['media_id'], $importVideoData);
                $model->logImportData('sonnb_xengallery_data', $video['media_id'], $videoData['content_data_id']);
                $success = $this->_createPhotoData($options, $video, $videoData);
                if ($success === false) {
                    continue;
                }
                $model->importXenGalleryContentDataConfirm($videoData);
                $import = array('video_type' => strtolower($video['service_name']), 'video_key' => $video['service_value'], 'album_id' => $albumId, 'content_data_id' => $videoData['content_data_id'], 'title' => $parser->render($this->_convertToUtf8($video['media_title'], true)), 'description' => $parser->render($this->_convertToUtf8($video['media_description'], true)), 'user_id' => $video['user_id'], 'username' => $video['username'], 'content_privacy' => array('allow_view' => 'everyone', 'allow_view_data' => array(), 'allow_comment' => 'everyone', 'allow_comment_data' => array()), 'comment_count' => 0, 'view_count' => $video['media_views'], 'content_date' => $video['media_date'], 'content_updated_date' => $video['media_date'], 'likes' => $video['media_likes'], 'like_users' => $video['media_like_users'], 'position' => $position, 'content_state' => $video['media_state']);
                if ($this->_config['retainKeys']) {
                    $import['content_id'] = $video['media_id'];
                }
                $videoId = $model->importXenGalleryVideo($video['media_id'], $import);
                $model->logImportData('sonnb_xengallery_video', $video['media_id'], $videoId);
                $position++;
            }
            $total++;
        }
        $options['processed'] += $total;
        $this->_session->incrementStepImportTotal($total);
        return array($next, $options, $this->_getProgressOutput($options['processed'], $options['rows']));
    }
开发者ID:Sywooch,项目名称:forums,代码行数:68,代码来源:XenMedioFree.php

示例14: stepComments

 public function stepComments($start, array $options)
 {
     $options = array_merge(array('limit' => 50, 'processed' => 0, 'max' => false), $options);
     $sDb = $this->_sourceDb;
     $prefix = $this->_prefix;
     $model = $this->_importModel;
     if ($options['max'] === false) {
         $data = $sDb->fetchRow("\n    \t\t\t\tSELECT MAX(comment_id) AS max, COUNT(comment_id) AS rows\n    \t\t\t\tFROM " . $prefix . "gallery_comments\n\t\t\t");
         $options = array_merge($options, $data);
         return array(0, $options, "Processing Comments ...");
     }
     $comments = $sDb->fetchAll($sDb->limit("\n    \t\t\t\tSELECT comment.*\n    \t\t\t\tFROM " . $prefix . "gallery_comments AS comment\n    \t\t\t\tWHERE comment.comment_id > " . $sDb->quote($start) . "\n    \t\t\t\tORDER BY comment.comment_id ASC\n    \t\t\t", $options['limit']));
     if (!$comments) {
         return true;
     }
     $next = 0;
     $last = 0;
     $total = 0;
     $userIdMap = $model->getUserIdsMapFromArray($comments, 'comment_author_id');
     $photoIdMap = $model->getPhotoIdsMapFromArray($comments, 'comment_img_id');
     $formatter = XenForo_BbCode_Formatter_Base::create('XenForo_BbCode_Formatter_Text');
     $parser = new XenForo_BbCode_Parser($formatter);
     foreach ($comments as $comment) {
         $next = $comment['comment_id'];
         if (!isset($userIdMap[$comment['comment_author_id']])) {
             continue;
         }
         if (!isset($photoIdMap[$comment['comment_img_id']])) {
             continue;
         }
         if ($last != $next) {
             $last = $next;
             $userId = $userIdMap[$comment['comment_author_id']];
             $username = $this->_convertToUtf8($comment['comment_author_name'], true);
             $username = $this->_mbTrim($username, 50, $userId);
             $photoId = $photoIdMap[$comment['comment_img_id']];
             $import = array('content_type' => sonnb_XenGallery_Model_Photo::$contentType, 'content_id' => $photoId, 'user_id' => $userId, 'username' => $username, 'message' => $parser->render($this->_convertToUtf8($comment['comment_text'], true)), 'comment_state' => $comment['comment_approved'] ? 'visible' : 'moderated', 'comment_date' => $comment['comment_post_date']);
             $commentId = $model->importXenGalleryComment($comment['comment_id'], $import);
             $model->logImportData('sonnb_xengallery_comment', $comment['comment_id'], $commentId);
         }
         $total++;
     }
     $options['processed'] += $total;
     $this->_session->incrementStepImportTotal($total);
     return array($next, $options, $this->_getProgressOutput($options['processed'], $options['rows']));
 }
开发者ID:Sywooch,项目名称:forums,代码行数:46,代码来源:ipb.php

示例15: helperBbCode

 /**
  * Helper to render the specified text as BB code.
  *
  * @param XenForo_BbCode_Parser $parser
  * @param string $text
  *
  * @return string
  */
 public static function helperBbCode($parser, $text)
 {
     if (!$parser instanceof XenForo_BbCode_Parser) {
         trigger_error(E_USER_WARNING, 'BB code parser not specified correctly.');
         return '';
     } else {
         return $parser->render($text);
     }
 }
开发者ID:hahuunguyen,项目名称:DTUI_201105,代码行数:17,代码来源:Core.php


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