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


PHP vB_BbCodeParser::getPreview方法代码示例

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


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

示例1: getDataForParse

 /**
  * Gets the data the presentation layer needs to have to parse the rawtext.
  *
  * @param  mixed nodeId or array of nodeIds
  *
  * @return mixed array includes bbcodeoptions, attachments, and rawtext
  */
 public function getDataForParse($nodeIds)
 {
     if (is_int($nodeIds)) {
         $nodeIds = array($nodeIds);
     } else {
         if (!is_array($nodeIds)) {
             throw new vB_Exception_Api('invalid_data');
         }
     }
     $results = array();
     $bfMiscForumoptions = vB::getDatastore()->getValue('bf_misc_forumoptions');
     $pmType = vB_Types::instance()->getContentTypeID('vBForum_PrivateMessage');
     $galleryTypeid = vB_Types::instance()->getContentTypeId('vBForum_Gallery');
     $photoTypeid = vB_Types::instance()->getContentTypeId('vBForum_Photo');
     $userContext = vB::getUserContext();
     $channelTypes = vB::getDatastore()->getValue('vBChannelTypes');
     if (!empty($nodeIds)) {
         $nodes = $this->assertor->assertQuery('vBForum:getDataForParse', array('nodeid' => $nodeIds));
         foreach ($nodes as $node) {
             try {
                 if ($this->validate($node, self::ACTION_VIEW, $node['nodeid'], array($node))) {
                     $attachments = $this->nodeApi->getNodeAttachments($node['nodeid']);
                     // We don't need to show attachments for gallery. See VBV-6389.
                     // Or rather, we need to unset attachments that are part of a gallery, but want to show other attachments. See VBV-11058
                     if ($galleryTypeid == $node['contenttypeid']) {
                         foreach ($attachments as $key => &$attachment) {
                             // attachments have contenttype vBForum_Attach, while photos of a gallery have contenttype vBForum_Photo
                             if ($photoTypeid == $attachment['contenttypeid']) {
                                 unset($attachments[$key]);
                             }
                         }
                     }
                     if ($node['contenttypeid'] == $pmType) {
                         $bbCodeOptions = vB_Api::instance('content_privatemessage')->getBbcodeOptions();
                     } else {
                         if ($userContext->getChannelPermission('forumpermissions', 'canviewthreads', $node['nodeid'], false, $node['parentid'])) {
                             $bbCodeOptions = array();
                             foreach ($bfMiscForumoptions as $optionName => $optionVal) {
                                 $bbCodeOptions[$optionName] = (bool) ($node['options'] & $optionVal);
                             }
                         } else {
                             $bbCodeOptions = array();
                         }
                     }
                     $results[$node['nodeid']] = array('bbcodeoptions' => $bbCodeOptions, 'rawtext' => $node['rawtext'], 'previewtext' => $node['previewtext'], 'attachments' => $attachments, 'title' => $node['title'], 'channelid' => $node['channelid'], 'htmlstate' => $node['htmlstate'], 'disable_bbcode' => $node['nodeoptions'] & vB_Api_Node::OPTION_NODE_DISABLE_BBCODE);
                 } else {
                     if ($node['public_preview'] > 0) {
                         $results[$node['nodeid']] = array('bbcodeoptions' => array(), 'rawtext' => '', 'title' => $node['title'], 'channelid' => $node['channelid'], 'htmlstate' => 'off', 'preview_only' => 1, 'disable_bbcode' => $node['nodeoptions'] & vB_Api_Node::OPTION_NODE_DISABLE_BBCODE);
                         require_once DIR . '/includes/class_bbcode.php';
                         $tags = fetch_tag_list();
                         $registry = vB::get_registry();
                         $bbcode_parser = new vB_BbCodeParser($registry, $tags);
                         $previewBbcodeOptions = array('allowsmilies' => 1, 'allowbbcode', 'allowimagecode' => 1);
                         if ($node['htmlstate'] != 'off') {
                             $previewBbcodeOptions['allowhtml'] = 1;
                         }
                         if ($node['nodeid'] == $node['starter']) {
                             $channel = vB_Library::instance('node')->getNodeFullContent($node['parentid']);
                         } else {
                             $starter = $this->nodeApi->getNode($node['starter']);
                             $channel = vB_Library::instance('node')->getNodeFullContent($starter['parentid']);
                         }
                         $channel = array_pop($channel);
                         if ($channel['channeltype'] == 'article') {
                             $previewBbcodeOptions['allowPRBREAK'] = 1;
                         }
                         if (vB::getUserContext()->getChannelPermission('forumpermissions2', 'cangetimgattachment', $node['nodeid'])) {
                             $previewBbcodeOptions['allowimages'] = 1;
                         }
                         $results[$node['nodeid']]['previewtext'] = $bbcode_parser->getPreview($node['rawtext'], 0, FALSE, $node['htmlstate'] == 'on_nl2br', null, $previewBbcodeOptions);
                     } else {
                         $results[$node['nodeid']] = array('bbcodeoptions' => array(), 'rawtext' => '', 'previewtext' => '', 'title' => '', 'attachments' => array(), 'channelid' => $node['channelid'], 'htmlstate' => 'off', 'disable_bbcode' => $node['nodeoptions'] & vB_Api_Node::OPTION_NODE_DISABLE_BBCODE);
                         // not much point since there is no rawtext, but ensure that it's set.
                     }
                 }
                 //channeltype
                 if (isset($channelTypes[$node['channelid']])) {
                     $results[$node['nodeid']]['channeltype'] = $channelTypes[$node['channelid']];
                     if ($channelTypes[$node['channelid']] == 'article') {
                         $results[$node['nodeid']]['previewLength'] = vB::getDatastore()->getOption('def_cms_previewlength');
                         // VBV-12048 For articles, if preview break is present, use the length of the preview text instead of
                         // the global cms preview length
                         $prbreak = stripos($results[$node['nodeid']]['rawtext'], '[PRBREAK][/PRBREAK]');
                         if ($prbreak !== FALSE) {
                             $results[$node['nodeid']]['previewLength'] = $prbreak;
                         }
                     } else {
                         $results[$node['nodeid']]['previewLength'] = vB::getDatastore()->getOption('threadpreview');
                     }
                 } else {
                     $results[$node['nodeid']]['channeltype'] = '';
                 }
             } catch (exception $e) {
//.........这里部分代码省略.........
开发者ID:cedwards-reisys,项目名称:nexus-web,代码行数:101,代码来源:text.php


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