/** * Loads associated smilies from cache. */ public function loadSmilies() { if ($this->smilies === null) { $this->smilies = SmileyCache::getInstance()->getCategorySmilies($this->categoryID ?: null); $this->indexToObject = array_keys($this->smilies); } }
/** * @see \wcf\system\option\IOptionType::getFormElement() */ public function getFormElement(Option $option, $value) { $allowedBBCodes = array(); if ($option->allowedbbcodepermission) { $allowedBBCodes = explode(',', WCF::getSession()->getPermission($option->allowedbbcodepermission)); } else { $allowedBBCodes = array_keys(BBCodeCache::getInstance()->getBBCodes()); } BBCodeHandler::getInstance()->setAllowedBBCodes($allowedBBCodes); WCF::getTPL()->assign(array('defaultSmilies' => SmileyCache::getInstance()->getCategorySmilies(), 'option' => $option, 'value' => $value)); return WCF::getTPL()->fetch('messageOptionType'); }
/** * @see \wcf\system\SingletonFactory::init() */ protected function init() { parent::init(); if (MODULE_SMILEY == 1) { // get smilies $smilies = SmileyCache::getInstance()->getSmilies(); $categories = SmileyCache::getInstance()->getCategories(); foreach ($smilies as $categoryID => $categorySmilies) { if ($categories[$categoryID ?: null]->isDisabled) { continue; } foreach ($categorySmilies as $smiley) { foreach ($smiley->smileyCodes as $smileyCode) { $this->smilies[$smileyCode] = '<img src="' . $smiley->getURL() . '" alt="' . StringUtil::encodeHTML($smiley->smileyCode) . '" />'; } } } krsort($this->smilies); } }
/** * process content for display in mobile app * * @params Object $var $var is $oViewablePost or $oViewableConversationMessage * @params Boolean $returnHtml * @return String */ public function processContentForDisplay($var = null, $returnHtml = false) { /* support bbcode:url/img/quote support html:br/i/b/u/font+color(red/blue) <strong> -> <b> attention input param:return_html attention output param:post_content */ $post = $this->customReplacement($var->getDecoratedObject()->getFormattedMessage()); if ($returnHtml) { // [quote] - Needs attention! $post = preg_replace('/<blockquote class="container containerPadding quoteBox"[^>]*?>.*?<header>.*?<h3>.*?<a href="[^>]*?">(.*?) wrote:<\\/a>.*?<\\/h3>.*?<\\/header>.*?(.*?)<\\/blockquote>/is', '$1 wrote:[quote]$2[/quote]', $post); // [u] $post = preg_replace('/<span style="text-decoration: underline">(.*?)<\\/span>/i', '<u>$1</u>', $post); // [list] if (preg_match_all('/<[ou]l[^>]*?list-style-type: (\\S+)[\'"][^>]*?>(.*?)<\\/[ou]l>/i', $post, $match, PREG_SET_ORDER)) { foreach ($match as $value) { $content = ''; $listType = $value[1]; $listContent = $value[2]; preg_match_all('/<li>(.*?)<\\/li>/i', $listContent, $match2, PREG_SET_ORDER); if ($listType == 'decimal') { foreach ($match2 as $key => $value) { $content .= "\t\t<li>" . ($key + 1) . '. ' . $value[1] . "</li><br />"; } $content = '<ol>' . $content . '</ol>'; } else { foreach ($match2 as $value) { $content .= "\t\t<li> * " . $value[1] . "</li><br />"; } $content = '<ul>' . $content . '</ul>'; } $post = preg_replace('/<[ou]l[^>]*?list-style-type: (\\S+)[\'"][^>]*?>(.*?)<\\/[ou]l>/i', $content, $post, 1); } } // [color] $post = preg_replace_callback('/<span style="color: (\\#.*?)">(.*?)<\\/span>/is', create_function('$matches', 'return MbqMain::$oMbqCm->mbColorConvert($matches[1], $matches[2]);'), $post); // [media] $post = preg_replace('~https?://(?:www\\.)?clipfish\\.de/embed_video/\\?vid=(\\d+)[^"]*~i', 'http://www.clipfish.de/video/$1/', $post); $post = preg_replace('~https?://(?:www\\.)?dailymotion\\.com/embed/video/([^"]+)~i', 'https://www.dailymotion.com/video/$1', $post); $post = preg_replace('~https?://gist\\.github.com/([^\\.]+)\\.js~i', 'https://gist.github.com/$1', $post); $post = preg_replace('~https?://(?:www\\.)?myvideo\\.de/movie/([^"]+)~i', 'http://www.myvideo.de/watch/$1', $post); $post = preg_replace('~https://w\\.soundcloud\\.com/player/\\?url=http%3A%2F%2Fsoundcloud\\.com%2F([^%]+)%2F([^"]+)~i', 'https://soundcloud.com/$1/$2', $post); $post = preg_replace('~https://w\\.soundcloud\\.com/player/\\?url=http%3A%2F%2Fsoundcloud\\.com%2F([^%]+)%2Fsets%2F([^"]+)~i', 'https://soundcloud.com/$1/sets/$2', $post); $post = preg_replace('~https?://(?:www\\.)?veoh\\.com/swf/webplayer/WebPlayer\\.swf\\?version=AFrontend\\.5\\.7\\.0\\.1308&permalinkId=([^&]+)[^"]*~i', 'http://www.veoh.com/watch/$1', $post); $post = preg_replace('~https?://player\\.vimeo\\.com/video/(\\d+)~i', 'https://vimeo.com/$1', $post); $post = preg_replace('~https?://(?:www\\.)?youtube-nocookie.com/embed/([^\\?]+)[^"]*~i', 'https://www.youtube.com/watch?v=$1', $post); $post = preg_replace('~<object.*data=("|\')([^"\']+)\\1.*</object>~i', '[url]$2[/url]', $post); $post = preg_replace('~<(iframe|script|embed).*src=("|\')([^"\']+)\\2.*</\\1>~i', '[url]$3[/url]', $post); // smilies $smileyCache = SmileyCache::getInstance()->getSmilies(); foreach ($smileyCache as $smileys) { foreach ($smileys as $smileyObj) { $post = preg_replace('~<img src="' . preg_quote($smileyObj->getURL(), '~') . '" alt="([^"]+)" />~i', '$1', $post); } } // [img] $post = preg_replace('/<a [^>]*?href="([^>]*?)"[^>]*?><img [^>]*?src="([^>]*?)"[^>]*?\\/><\\/a>/i', '[img]$2[/img]', $post); $post = preg_replace('/<img [^>]*?src="([^>]*?)"[^>]*?\\/>/i', '[img]$1[/img]', $post); // [url] $post = preg_replace('/<a [^>]*?href="([^>]*?)"[^>]*?>([^>]*?)<\\/a>/i', '[url=$1]$2[/url]', $post); // [table] $post = str_ireplace('</tr>', '</tr><br />', $post); $post = str_ireplace('</td>', "</td>", $post); // other stuff $post = str_ireplace('<hr />', '<br />' . str_repeat('_', 35) . '<br />', $post); $post = str_ireplace('</div>', '</div><br />', $post); $post = str_ireplace(' ', ' ', $post); $post = strip_tags($post, '<br><i><b><u><font>'); } else { $post = strip_tags($post); } return StringUtil::trim($post); }
/** * @see \wcf\page\IPage::readData() */ public function readData() { parent::readData(); $this->categories = SmileyCache::getInstance()->getCategories(); }
/** * @see \wcf\data\IMessageInlineEditorAction::beginEdit() */ public function beginEdit() { BBCodeHandler::getInstance()->setAllowedBBCodes(explode(',', WCF::getSession()->getPermission('user.message.allowedBBCodes'))); WCF::getTPL()->assign(array('defaultSmilies' => SmileyCache::getInstance()->getCategorySmilies(), 'message' => $this->message, 'permissionCanUseSmilies' => 'user.message.canUseSmilies', 'wysiwygSelector' => 'messageEditor' . $this->message->messageID)); if (MODULE_ATTACHMENT) { $tmpHash = StringUtil::getRandomID(); $attachmentHandler = new AttachmentHandler('com.woltlab.wcf.conversation.message', $this->message->messageID, $tmpHash); $attachmentList = $attachmentHandler->getAttachmentList(); WCF::getTPL()->assign(array('attachmentHandler' => $attachmentHandler, 'attachmentList' => $attachmentList->getObjects(), 'attachmentObjectID' => $this->message->messageID, 'attachmentObjectType' => 'com.woltlab.wcf.conversation.message', 'attachmentParentObjectID' => 0, 'tmpHash' => $tmpHash)); } return array('actionName' => 'beginEdit', 'template' => WCF::getTPL()->fetch('conversationMessageInlineEditor')); }
/** * @see \wcf\page\IPage::readData() */ public function readData() { // get attachments if (MODULE_ATTACHMENT && $this->attachmentObjectType) { $this->attachmentHandler = new AttachmentHandler($this->attachmentObjectType, $this->attachmentObjectID, $this->tmpHash, $this->attachmentParentObjectID); } if (empty($_POST)) { $this->enableBBCodes = ENABLE_BBCODES_DEFAULT_VALUE && WCF::getSession()->getPermission($this->permissionCanUseBBCodes) ? 1 : 0; $this->enableHtml = ENABLE_HTML_DEFAULT_VALUE && WCF::getSession()->getPermission($this->permissionCanUseHtml) ? 1 : 0; $this->enableSmilies = ENABLE_SMILIES_DEFAULT_VALUE && WCF::getSession()->getPermission($this->permissionCanUseSmilies) ? 1 : 0; $this->preParse = PRE_PARSE_DEFAULT_VALUE; $this->showSignature = SHOW_SIGNATURE_DEFAULT_VALUE; $this->languageID = WCF::getLanguage()->languageID; } parent::readData(); // get default smilies if (MODULE_SMILEY) { $this->smileyCategories = SmileyCache::getInstance()->getVisibleCategories(); $firstCategory = reset($this->smileyCategories); if ($firstCategory) { $this->defaultSmilies = SmileyCache::getInstance()->getCategorySmilies($firstCategory->categoryID ?: null); } } if ($this->enableBBCodes && $this->allowedBBCodesPermission) { BBCodeHandler::getInstance()->setAllowedBBCodes(explode(',', WCF::getSession()->getPermission($this->allowedBBCodesPermission))); } }
/** * @see \wcf\page\IPage::assignVariables() */ public function assignVariables() { parent::assignVariables(); MessageQuoteManager::getInstance()->assignVariables(); $tmpHash = StringUtil::getRandomID(); $attachmentHandler = new AttachmentHandler('com.woltlab.wcf.conversation.message', 0, $tmpHash, 0); WCF::getTPL()->assign(array('attachmentHandler' => $attachmentHandler, 'attachmentObjectID' => 0, 'attachmentObjectType' => 'com.woltlab.wcf.conversation.message', 'attachmentParentObjectID' => 0, 'tmpHash' => $tmpHash, 'attachmentList' => $this->objectList->getAttachmentList(), 'labelList' => $this->labelList, 'modificationLogList' => $this->modificationLogList, 'sortOrder' => $this->sortOrder, 'conversation' => $this->conversation, 'conversationID' => $this->conversationID, 'participants' => $this->participantList->getObjects(), 'defaultSmilies' => SmileyCache::getInstance()->getCategorySmilies(), 'permissionCanUseSmilies' => 'user.message.canUseSmilies')); BBCodeHandler::getInstance()->setAllowedBBCodes(explode(',', WCF::getSession()->getPermission('user.message.allowedBBCodes'))); }