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']); }
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']); } }
/** * 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 ''; } }
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; }
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; }
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; }
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')); }
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'); } }
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; } }
/** * 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())); }
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'); }
/** * 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; }
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'])); }
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'])); }
/** * 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); } }
public function stepComments($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("\n \t\t\t\tSELECT MAX(post.post_id) AS max, COUNT(post.post_id) AS rows\n \t\t\t\tFROM xf_post as post\n\t\t\t\t\t\tLEFT JOIN xf_thread as thread\n\t\t\t\t\t\t\tON (thread.thread_id = post.thread_id)\n\t\t\t\t\tWHERE thread.node_id = ?\n\t\t\t\t\t\tAND post.position > 0\n\t\t\t\t\t\tAND post.message_state = 'visible'\n\t\t\t", $this->_config['node_id']); $options = array_merge($options, $data); return array(0, $options, "Processing Comments ..."); } $comments = $db->fetchAll($db->limit("\n \t\t\t\tSELECT post.*\n\t\t\t\t\tFROM xf_post as post\n\t\t\t\t\t\tLEFT JOIN xf_thread as thread\n\t\t\t\t\t\t\tON (thread.thread_id = post.thread_id)\n\t\t\t\t\tWHERE thread.node_id = ?\n\t\t\t\t\t\tAND post.post_id > ?\n\t\t\t\t\t\tAND post.position > 0\n\t\t\t\t\t\tAND post.message_state = 'visible'\n\t\t\t\t\tORDER BY post.post_id ASC\n \t\t\t", $options['limit']), array($this->_config['node_id'], $start)); if (!$comments) { return true; } $next = 0; $last = 0; $total = 0; $formatter = XenForo_BbCode_Formatter_Base::create('XenForo_BbCode_Formatter_Text'); $parser = new XenForo_BbCode_Parser($formatter); $albumIdMap = $model->getPhotoIdsMapFromArray($comments, 'thread_id'); foreach ($comments as $comment) { $next = $comment['post_id']; if (empty($comment['user_id'])) { continue; } if (empty($albumIdMap[$comment['thread_id']])) { continue; } $message = $parser->render($comment['message']); $message = preg_replace('/\\[(.*?)\\]\\s*(.*?)\\s*\\[(.*?)\\]/', '[$1]$2[/$3]', $message); if (empty($message)) { continue; } if ($last != $next) { $last = $next; $import = array('content_type' => sonnb_XenGallery_Model_Album::$contentType, 'content_id' => $albumIdMap[$comment['thread_id']], 'user_id' => $comment['user_id'], 'username' => $comment['username'], 'message' => $message, 'comment_state' => $comment['message_state'], 'comment_date' => $comment['post_date'], 'likes' => $comment['likes'], 'like_users' => $comment['like_users']); $commentId = $model->importXenGalleryComment($comment['post_id'], $import); $model->logImportData('sonnb_xengallery_comment', $comment['post_id'], $commentId); } $this->_importModel->importContentLike('post', $comment['post_id'], 'sonnb_xengallery_comment', $commentId, $comment['user_id']); $total++; } $options['processed'] += $total; $this->_session->incrementStepImportTotal($total); return array($next, $options, $this->_getProgressOutput($options['processed'], $options['rows'])); }
/** * Strips out quoted text from the specified string, allowing for quoted text * up to a specified depth. * * @param string $string * @param integer $allowedDepth -1 for unlimited depth * @param boolean $censorResults * * @return string Quotes stripped */ public static function stripQuotes($string, $allowedDepth = -1, $censorResults = true) { if ($allowedDepth == -1) { return $string; } else { $formatter = XenForo_BbCode_Formatter_Base::create('XenForo_BbCode_Formatter_BbCode_Strip', false); $formatter->setMaxQuoteDepth($allowedDepth); $formatter->setCensoring($censorResults); $parser = new XenForo_BbCode_Parser($formatter); return $parser->render($string); } }
public function renderJson() { $bbCodeParser = new XenForo_BbCode_Parser(XenForo_BbCode_Formatter_Base::create('Wysiwyg', array('view' => $this))); return array('html' => $bbCodeParser->render($this->_params['bbCode'])); }
public function renderJson() { $bbCodeParser = new XenForo_BbCode_Parser(XenForo_BbCode_Formatter_Base::create('Wysiwyg', array('view' => $this))); return XenForo_ViewRenderer_Json::jsonEncodeForOutput(array('quote' => $this->_params['quote'], 'quoteHtml' => $bbCodeParser->render($this->_params['quote']))); }
public function stepVisitorMessages($start, array $options) { $options = array_merge(array('limit' => 200, 'max' => false), $options); $sDb = $this->_sourceDb; $prefix = $this->_prefix; /* @var $model XenForo_Model_Import */ $model = $this->_importModel; if ($options['max'] === false) { $options['max'] = $sDb->fetchOne(' SELECT MAX(vmid) FROM ' . $prefix . 'visitormessage '); } $vms = $sDb->fetchAll($sDb->limit(' SELECT vm.*, IF(user.username IS NULL, vm.postusername, user.username) AS username FROM ' . $prefix . 'visitormessage AS vm LEFT JOIN ' . $prefix . 'user AS user ON (vm.postuserid = user.userid) WHERE vm.vmid > ' . $sDb->quote($start) . ' ORDER BY vm.vmid ', $options['limit'])); if (!$vms) { return true; } $next = 0; $total = 0; $userIds = array(); foreach ($vms as $vm) { $userIds[] = $vm['userid']; $userIds[] = $vm['postuserid']; } $userIdMap = $model->getImportContentMap('user', $userIds); XenForo_Db::beginTransaction(); $formatter = XenForo_BbCode_Formatter_Base::create('XenForo_BbCode_Formatter_Text'); $parser = new XenForo_BbCode_Parser($formatter); foreach ($vms as $vm) { if (trim($vm['postusername']) === '') { continue; } $next = $vm['vmid']; $profileUserId = $this->_mapLookUp($userIdMap, $vm['userid']); if (!$profileUserId) { continue; } $postUserId = $this->_mapLookUp($userIdMap, $vm['postuserid'], 0); $import = array('profile_user_id' => $profileUserId, 'user_id' => $postUserId, 'username' => $this->_convertToUtf8($vm['postusername'], true), 'post_date' => $vm['dateline'], 'message' => $parser->render($this->_convertToUtf8($vm['pagetext'])), 'ip' => $vm['ipaddress']); switch ($vm['state']) { case 'deleted': $import['message_state'] = 'deleted'; break; case 'moderation': $import['message_state'] = 'moderated'; break; default: $import['message_state'] = 'visible'; } if ($model->importProfilePost($vm['vmid'], $import)) { $total++; } } XenForo_Db::commit(); $this->_session->incrementStepImportTotal($total); return array($next, $options, $this->_getProgressOutput($next, $options['max'])); }
/** * Gets the HTML value of the media field. * * @param array|string $field If string, field ID * @param mixed $value Value of the field; if null, pulls from field_value in field * @param XenForo_BbCode_Parser $parser * * @return string */ public static function getMediaFieldValueHtml($field, $value = null, $parser = null) { if (!is_array($field)) { $fields = self::_getModelFromCache('XenGallery_Model_Field')->getGalleryFieldCache(); if (!isset($fields[$field])) { return ''; } $field = $fields[$field]; } if ($value === null && isset($field['field_value'])) { $value = $field['field_value']; } if ($value === '' || $value === null) { return ''; } $multiChoice = false; $choice = ''; switch ($field['field_type']) { case 'radio': case 'select': $choice = $value; $value = new XenForo_Phrase("xengallery_field_{$field['field_id']}_choice_{$value}"); $value->setPhraseNameOnInvalid(false); 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("xengallery_field_{$field['field_id']}_choice_{$choice}"); $phrase->setPhraseNameOnInvalid(false); $newValues[$choice] = $phrase; } $value = $newValues; break; case 'bbcode': if (!$parser instanceof XenForo_BbCode_Parser) { trigger_error('BB code parser not specified correctly.', E_USER_WARNING); break; } $value = $parser->render($value, array()); break; case 'textbox': case 'textarea': default: $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, '{$valueUrl}' => urlencode($thisValue), '{$choice}' => $choice)); } } else { $value = strtr($field['display_template'], array('{$fieldId}' => $field['field_id'], '{$value}' => $value, '{$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; }
/** * Returns a list of posts. */ public function getPosts($conditions = array(), $fetchOptions = array('limit' => 10), $user = NULL) { if (!empty($conditions['node_id']) || !empty($fetchOptions['order']) && strtolower($fetchOptions['order']) == 'node_id') { // We need to grab the thread info to get the node_id. $fetchOptions = array_merge($fetchOptions, array('join' => XenForo_Model_Post::FETCH_THREAD)); } $this->getModels()->checkModel('post', XenForo_Model::create('XenForo_Model_Post')); if ($user !== NULL) { // User is set, we need to include permissions. if (!isset($fetchOptions['join'])) { // WE need to grab the thread to get the node permissions. $fetchOptions = array_merge($fetchOptions, array('join' => XenForo_Model_Post::FETCH_THREAD)); } // User is set, we therefore have to grab the permissions to check if the user is allowed to view the post. $fetchOptions = array_merge($fetchOptions, array('permissionCombinationId' => $user->data['permission_combination_id'])); } // Prepare query conditions. $whereConditions = Post::preparePostConditions($this->getModels()->getModel('database'), $this->getModels()->getModel('post'), $conditions); $sqlClauses = $this->getModels()->getModel('post')->preparePostJoinOptions($fetchOptions); $limitOptions = $this->getModels()->getModel('post')->prepareLimitFetchOptions($fetchOptions); // Since the Post model of XenForo does not have order by implemented, we have to do it ourselves. if (!empty($fetchOptions['order'])) { $orderBySecondary = ''; switch ($fetchOptions['order']) { case 'post_id': case 'thread_id': case 'user_id': case 'username': case 'attach_count': case 'likes': $orderBy = 'post.' . $fetchOptions['order']; break; case 'node_id': $orderBy = 'thread.' . $fetchOptions['order']; break; case 'post_date': default: $orderBy = 'post.post_date'; } // Check if order direction is set. if (!isset($fetchOptions['orderDirection']) || $fetchOptions['orderDirection'] == 'desc') { $orderBy .= ' DESC'; } else { $orderBy .= ' ASC'; } $orderBy .= $orderBySecondary; } $sqlClauses['orderClause'] = isset($orderBy) ? "ORDER BY {$orderBy}" : ''; // Execute the query and get the result. $post_list = $this->getModels()->getModel('post')->fetchAllKeyed($this->getModels()->getModel('post')->limitQueryResults(' SELECT post.* ' . $sqlClauses['selectFields'] . ' FROM xf_post AS post ' . $sqlClauses['joinTables'] . ' WHERE ' . $whereConditions . ' ' . $sqlClauses['orderClause'] . ' ', $limitOptions['limit'], $limitOptions['offset']), 'post_id'); // Loop through the posts to unset some values that are not needed. foreach ($post_list as $key => &$post) { if ($user !== NULL) { // Check if the user has permissions to view the post. $permissions = XenForo_Permission::unserializePermissions($post['node_permission_cache']); if (!$this->getModels()->getModel('post')->canViewPost($post, array('node_id' => $post['node_id']), array(), $null, $permissions, $user->getData())) { // User does not have permission to view this post, unset it and continue the loop. unset($post_list[$key]); continue; } // Unset the permissions values. unset($post_list[$key]['node_permission_cache']); } if (isset($fetchOptions['join'])) { // Unset some not needed thread values. Post::stripThreadValues($post_list[$key]); } if ($post !== FALSE && $post !== NULL) { // Add HTML as well $formatter = XenForo_BbCode_Formatter_Base::create(); $parser = new XenForo_BbCode_Parser($formatter); $post['message_html'] = str_replace("\n", '', $parser->render($post['message'])); $post['absolute_url'] = self::getBoardURL('posts', $post['post_id']); } else { $post = NULL; } } return array_values($post_list); }
/** * Check that the contents of the message are valid, based on length, images, etc. */ protected function _checkMessageValidity() { $message = $this->get('message'); $maxLength = $this->getOption(self::OPTION_MAX_MESSAGE_LENGTH); if ($maxLength && utf8_strlen($message) > $maxLength) { $this->error(new XenForo_Phrase('please_enter_message_with_no_more_than_x_characters', array('count' => $maxLength)), 'message'); } $maxImages = $this->getOption(self::OPTION_MAX_IMAGES); $maxMedia = $this->getOption(self::OPTION_MAX_MEDIA); if ($maxImages || $maxMedia) { $formatter = XenForo_BbCode_Formatter_Base::create('ImageCount', false); $parser = new XenForo_BbCode_Parser($formatter); $parser->render($message); if ($maxImages && $formatter->getImageCount() > $maxImages) { $this->error(new XenForo_Phrase('please_enter_message_with_no_more_than_x_images', array('count' => $maxImages)), 'message'); } if ($maxMedia && $formatter->getMediaCount() > $maxMedia) { $this->error(new XenForo_Phrase('please_enter_message_with_no_more_than_x_images', array('count' => $maxMedia)), 'message'); } } }
/** * Renders the text. * * @return string */ public function __toString() { return $this->_parser->render($this->_text, $this->_extraStates); }
public static function parseHashtags(&$bbCode, $editBbCode = false) { static $_declaredHashtagPick = false; static $_declaredAutoHashtag = false; static $_formatters = array(); $bbCodeFormatterClass = XenForo_Application::resolveDynamicClass('XenForo_BbCode_Formatter_Base', 'bb_code'); if (!$_declaredHashtagPick) { eval('class XFCP_Tinhte_XenTag_BbCode_Formatter_HashtagPick extends ' . $bbCodeFormatterClass . ' {}'); $_declaredHashtagPick = true; } $bbCodeFormatterClass = 'Tinhte_XenTag_BbCode_Formatter_HashtagPick'; if ($editBbCode) { if (!$_declaredAutoHashtag) { eval('class XFCP_Tinhte_XenTag_BbCode_Formatter_AutoHashtag extends ' . $bbCodeFormatterClass . ' {}'); $_declaredAutoHashtag = true; } $bbCodeFormatterClass = 'Tinhte_XenTag_BbCode_Formatter_AutoHashtag'; } if (!isset($_formatters[$bbCodeFormatterClass])) { $_formatters[$bbCodeFormatterClass] = new $bbCodeFormatterClass(); } $bbCodeFormatter = $_formatters[$bbCodeFormatterClass]; if (XenForo_Application::$versionId > 1020000) { $bbCodeParser = XenForo_BbCode_Parser::create($bbCodeFormatter); } else { $bbCodeParser = new XenForo_BbCode_Parser($bbCodeFormatter); } $bbCodeEdited = $bbCodeParser->render($bbCode); $tagTexts = $bbCodeFormatter->Tinhte_XenTag_getTagTexts(); if ($editBbCode) { $tagTexts = array_merge($tagTexts, $bbCodeFormatter->Tinhte_XenTag_getAutoHashtagTexts()); $bbCode = $bbCodeEdited; } $tagTexts = array_values($tagTexts); return $tagTexts; }
public static function controllerPreView(XenForo_FrontController $fc, XenForo_ControllerResponse_Abstract &$controllerResponse, XenForo_ViewRenderer_Abstract &$viewRenderer, array &$containerParams) { /* Listener - Execution order: #2 */ self::$_isControllerAdmin = strstr($controllerResponse->controllerName, 'ControllerAdmin') ? true : false; self::$_controllerName = isset($controllerResponse->controllerName) ? $controllerResponse->controllerName : NULL; self::$_controllerAction = isset($controllerResponse->controllerAction) ? $controllerResponse->controllerAction : NULL; self::$_viewName = isset($controllerResponse->viewName) ? $controllerResponse->viewName : NULL; self::$_isJson = $viewRenderer instanceof XenForo_ViewRenderer_Json ? true : false; if (XenForo_Application::get('options')->get('Bbm_ContentProtection') && self::$_isControllerAdmin === false) { if (self::$_isJson == true) { /*** * Protect Json Response here. It will not work with the controllerPostView listener (will generate an error) **/ if (isset($controllerResponse->params['post']['message'])) { /*** * Use for: - Edit inline * - Thread fast preview (small popup when mouse over title) * - Thread/post/conversation edit preview **/ $controllerResponse->params['post']['message'] = self::parsingProtection($controllerResponse->params['post']['message']); } if (isset($controllerResponse->params['quote'])) { /*** * Use for: - Quotes **/ $controllerResponse->params['quote'] = self::parsingProtection($controllerResponse->params['quote'], true, 'quotes'); } } } if (self::$_debug == 'pre' && self::$_isControllerAdmin === false) { $visitor = XenForo_Visitor::getInstance(); if ($visitor['is_admin']) { Zend_Debug::dump($controllerResponse); } } /*Extra function to hide tags in Thread fast preview*/ if (self::$_isJson == true && self::$_viewName == 'XenForo_ViewPublic_Thread_Preview' && XenForo_Application::get('options')->get('Bbm_HideTagsInFastPreview')) { if (isset($controllerResponse->params['post']['message'])) { if (XenForo_Application::get('options')->get('Bbm_HideTagsInFastPreviewInvisible')) { $formatter = XenForo_BbCode_Formatter_Base::create('BBM_Protection_BbCode_Formatter_BbCode_Eradicator', false); $formatter->setAllTagsAsProtected(); $formatter->invisibleMode(); } else { $formatter = XenForo_BbCode_Formatter_Base::create('BBM_Protection_BbCode_Formatter_BbCode_Lupin', false); } $parser = new XenForo_BbCode_Parser($formatter); $extraStates = array('bbmContentProtection' => true); $controllerResponse->params['post']['message'] = $parser->render($controllerResponse->params['post']['message'], $extraStates); } } }
public function actionGetPost() { // Whole function is an ugly hack. Revisit later. global $dependencies, $zresponse; $postid = $this->_input->filterSingle('postid', XenForo_Input::UINT); $type = $this->_input->filterSingle('type', XenForo_Input::STRING); $signature = $this->_input->filterSingle('signature', XenForo_Input::UINT); if (!$type || $type == '') { $type = 'html'; } $user_model = $this->getModelFromCache('XenForo_Model_User'); $session_model = $this->getModelFromCache('XenForo_Model_Session'); $thread_model = $this->getModelFromCache('XenForo_Model_Thread'); $forum_model = $this->getModelFromCache('XenForo_Model_Forum'); $attachment_model = $this->getModelFromCache('XenForo_Model_Attachment'); $helper = $this->getHelper('ForumThreadPost'); try { list($post, $thread, $forum) = $helper->assertPostValidAndViewable($postid); } catch (Exception $e) { json_error($e->getControllerResponse()->errorText->render()); } $post_model = $this->_getPostModel(); $post = $post_model->getPostById($postid, array('join' => XenForo_Model_Post::FETCH_THREAD | XenForo_Model_Post::FETCH_FORUM | XenForo_Model_Post::FETCH_USER | XenForo_Model_Post::FETCH_USER_PROFILE)); $user = $user_model->getUserById($post['user_id']); $online_info = $session_model->getSessionActivityRecords(array('user_id' => $post['user_id'], 'cutOff' => array('>', $session_model->getOnlineStatusTimeout()))); $is_online = false; if (count($online_info) == 1) { $is_online = true; } $avatarurl = ''; if ($user !== false) { $avatarurl = process_avatarurl(XenForo_Template_Helper_Core::getAvatarUrl($user, 'm')); if (strpos($avatarurl, '/xenforo/avatars/avatar_') !== false) { $avatarurl = ''; } } $attachments = $attachment_model->getAttachmentsByContentId('post', $postid); $message = fr_strip_smilies($this, $post['message']); list($text, $nuked_quotes, $images) = parse_post($message, true, array()); $image = ''; if ($type == 'html') { $css = <<<EOF <style type="text/css"> body { margin: 0; padding: 3; font: 13px Arial, Helvetica, sans-serif; } .alt2 { background-color: #e6edf5; font: 13px Arial, Helvetica, sans-serif; } html { -webkit-text-size-adjust: none; } </style> EOF; $formatter = XenForo_BbCode_Formatter_Base::create('ForumRunner_BbCode_Formatter_BbCode_Post', array('smilies' => XenForo_Application::get('smilies'))); $parser = new XenForo_BbCode_Parser($formatter); $html = $css . $parser->render($message); if ($signature && $post['signature']) { $html .= '<div style="border-top: 1px dashed grey; font-size: 9pt; margin-top: 5px; padding: 5px 0 0;">' . $parser->render(fr_strip_smilies($this, $post['signature'])) . '</div>'; } } else { if ($type == 'facebook') { $html = XenForo_Helper_String::censorString(XenForo_Helper_String::bbCodeStrip($message, true)); if (count($attachments)) { $attachments = array_values($attachments); $link = XenForo_Link::buildPublicLink('attachments', $attachments[0]); $image = fr_get_xenforo_bburl() . '/' . $link; } } } $post_page = floor($post['position'] / XenForo_Application::get('options')->messagesPerPage) + 1; $out = array('post_id' => $post['post_id'], 'thread_id' => $post['thread_id'], 'forum_id' => $post['node_id'], 'forum_title' => prepare_utf8_string(strip_tags($post['node_title'])), 'username' => prepare_utf8_string(strip_tags($post['username'])), 'joindate' => prepare_utf8_string(XenForo_Locale::date($post['register_date'], 'absolute')), 'usertitle' => XenForo_Template_Helper_Core::helperUserTitle($user), 'numposts' => $user ? $user['message_count'] : 0, 'userid' => $post['user_id'], 'title' => prepare_utf8_string($post['title']), 'online' => $is_online, 'post_timestamp' => prepare_utf8_string(XenForo_Locale::dateTime($post['post_date'], 'absolute')), 'html' => prepare_utf8_string($html), 'quotable' => $nuked_quotes, 'canpost' => $thread_model->canReplyToThread($thread, $forum), 'canattach' => $forum_model->canUploadAndManageAttachment($forum), 'post_link' => fr_get_xenforo_bburl() . '/' . XenForo_Link::buildPublicLink('threads', $thread, array('page' => $post_page)) . '#post-' . $post['post_id']); if ($image != '') { $out['image'] = $image; } if ($avatarurl != '') { $out['avatarurl'] = $avatarurl; } return $out; }
public function renderHtml() { $response = parent::renderHtml(); if (empty($this->_params['layout1'])) { return $response; } $this->_params['layout2'] = empty($this->_params['layout2']) ? false : $this->_params['layout2']; $this->_params['layout3'] = empty($this->_params['layout3']) ? false : $this->_params['layout3']; $this->_params['cookie'] = empty($this->_params['cookie']) ? false : $this->_params['cookie']; $this->_params['category'] = empty($this->_params['category']) ? false : $this->_params['category']; $isPortal = empty($this->_params['isPortal']) ? false : true; $isArticle = empty($this->_params['isArticle']) ? false : true; $blocksModel = XenForo_Model::create('EWRporta_Model_Blocks'); $blocks = $blocksModel->getBlocks($this->_params['cookie'], $this->_params['layout1'], $this->_params['layout2'], $this->_params['layout3']); if (empty($blocks)) { return $response; } if ($isArticle && !empty($this->_params['thread']['first_post_id'])) { $this->_params['posts'][$this->_params['thread']['first_post_id']]['attachments'] = false; $this->_params['posts'][$this->_params['thread']['first_post_id']]['signature'] = false; } $cachesModel = XenForo_Model::create('EWRporta_Model_Caches'); $caches = $cachesModel->getCaches(); $optionsModel = XenForo_Model::create('EWRporta_Model_Options'); $options = $optionsModel->getOptions(); $visitor = XenForo_Visitor::getInstance(); $_blocks = array('top-left' => array(), 'top-right' => array(), 'mid-left' => array(), 'mid-right' => array(), 'btm-left' => array(), 'btm-right' => array(), 'sidebar' => array()); foreach ($blocks as $block) { if ($block['position'] == 'disabled') { continue; } if (!$isPortal && ($block['position'] == 'mid-left' || $block['position'] == 'mid-right')) { continue; } if (!empty($block['groups'])) { $groups = explode(',', $block['groups']); $member = false; foreach ($groups as $group) { if ($visitor->isMemberOf($group)) { $member = true; break; } } if ($block['display'] == 'hide' && $member) { continue; } if ($block['display'] == 'show' && !$member) { continue; } } $block['layout'] = $this->_params['layout1']; $block['category'] = $this->_params['category']; $block['caches'] = !empty($caches[$block['block_id']]) ? $caches[$block['block_id']] : false; $block['options'] = !empty($options[$block['block_id']]) ? $options[$block['block_id']] : false; $page = $isPortal ? $this->_params['page'] : false; $params = $blocksModel->getBlockParams($block, $page); if (!empty($params[$block['block_id']]) && $params[$block['block_id']] == 'killModule') { continue; } if (!empty($params['option']['parseBB'])) { $bbCodeParser = new XenForo_BbCode_Parser(XenForo_BbCode_Formatter_Base::create('Base', array('view' => $this))); $bbCodeOptions = array('states' => array('viewAttachments' => true)); XenForo_ViewPublic_Helper_Message::bbCodeWrapMessages($params[$block['block_id']], $bbCodeParser, $bbCodeOptions); } if (!empty($params['option']['parseText'])) { foreach ($params[$block['block_id']] 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']); } } $object = $this->createTemplateObject('EWRblock_' . $block['block_id'], $params); switch ($block['position']) { case 'top-left': $_blocks['top-left'][] = $object; break; case 'top-right': $_blocks['top-right'][] = $object; break; case 'mid-left': $_blocks['mid-left'][] = $object; break; case 'mid-right': $_blocks['mid-right'][] = $object; break; case 'btm-left': $_blocks['btm-left'][] = $object; break; case 'btm-right': $_blocks['btm-right'][] = $object; break; case 'sidebar': $_blocks['sidebar'][] = $object; break; } } $this->_params['blocks'] = $_blocks; return $response; }