BBCode tô màu code cho xenforo add vào khung soạn thảo

xuanviet15

Private
Tham gia
14/04/2015
Bài viết
29
Được Like
4
Hiện tại mình có nhu cầu làm một forum về lập trình, muốn sử dụng mã nguồn Xenforo. Có bạn nào có thể giúp mình trong Xen thì mình thực hiện tô màu code như thế nào không?
Ví dụ code C#, Java, HTML, PHP, C/C++ ...
 

PVS

Super Moderator
Thành viên BQT
Tham gia
28/02/2015
Bài viết
17,093
Được Like
12,737
tô màu code hay code tô màu bạn, mình vẫn không hiểu lắm ^^
 

xuanviet15

Private
Tham gia
14/04/2015
Bài viết
29
Được Like
4

Là mình muốn bài post trong diễn đàn nếu có code thì nó sẽ hiện ra như thế này nè bạn:
16767281333_01e815232d_o.png
 

PVS

Super Moderator
Thành viên BQT
Tham gia
28/02/2015
Bài viết
17,093
Được Like
12,737
hii, thế thì mình bó tay ^^
 

dev.xf

Sergeant
Tham gia
28/02/2015
Bài viết
450
Được Like
519
PHP:
<?php

class Brivium_HideAttachment_ControllerPublic_Attachment extends XFCP_Brivium_HideAttachment_ControllerPublic_Attachment
{
    public function actionIndex()
    {
        $attachmentId = $this->_input->filterSingle('attachment_id', XenForo_Input::UINT);
        $attachment = $this->_getAttachmentOrError($attachmentId);
       
        if(isset($attachment)){
            if($attachment['content_type'] == 'post'){
                $ftpHelper = $this->getHelper('ForumThreadPost');
                list($post, $thread, $forum) = $ftpHelper->assertPostValidAndViewable($attachment['content_id']);
                $hideAttachment = $this->_getHideAttachmentModel();
                $visitorId = XenForo_Visitor::getUserId();
                if($hideAttachment->requirePermission($forum['node_id'],$post) && $hideAttachment->requirePermissionPost($post,$visitorId)){
                    $options = XenForo_Application::get('options');
                    $extensionMap =    preg_split('/\s+/', trim($options->BRHA_excludedFileExtensions));
                    $extension = XenForo_Helper_File::getFileExtension($attachment['filename']);
                   
                    if (!in_array($extension, $extensionMap))
                    {
                        $mustReply = false;
                        $mustLike = false;
                       
                        if($options->BRHA_likeRequired && !$this->getModelFromCache('XenForo_Model_Like')->getContentLikeByLikeUser('post',$post['post_id'],$visitorId)){
                            $mustLike = true;
                        }
                        if($options->BRHA_replyRequired && !$hideAttachment->checkReplied($thread['thread_id'],$visitorId)){
                            $mustReply = true;
                        }   

                        if($mustReply && $mustLike){
                            return $this->responseError(new XenForo_Phrase('BRHA_mustLikeAndReply'));
                        }else if($mustLike){
                            return $this->responseError(new XenForo_Phrase('BRHA_mustLike'));
                        }else if($mustReply){
                            return $this->responseError(new XenForo_Phrase('BRHA_mustReply'));
                        }
                       
                    }
                }
            }
        }
        return parent::actionIndex();
    }
   
    /**
     * @return Brivium_HideAttachment_Model_HideAttachment
     */
    protected function _getHideAttachmentModel()
    {
        return $this->getModelFromCache('Brivium_HideAttachment_Model_HideAttachment');
    }

}
 

xuanviet15

Private
Tham gia
14/04/2015
Bài viết
29
Được Like
4
PHP:
<?php

class Brivium_HideAttachment_ControllerPublic_Attachment extends XFCP_Brivium_HideAttachment_ControllerPublic_Attachment
{
    public function actionIndex()
    {
        $attachmentId = $this->_input->filterSingle('attachment_id', XenForo_Input::UINT);
        $attachment = $this->_getAttachmentOrError($attachmentId);
      
        if(isset($attachment)){
            if($attachment['content_type'] == 'post'){
                $ftpHelper = $this->getHelper('ForumThreadPost');
                list($post, $thread, $forum) = $ftpHelper->assertPostValidAndViewable($attachment['content_id']);
                $hideAttachment = $this->_getHideAttachmentModel();
                $visitorId = XenForo_Visitor::getUserId();
                if($hideAttachment->requirePermission($forum['node_id'],$post) && $hideAttachment->requirePermissionPost($post,$visitorId)){
                    $options = XenForo_Application::get('options');
                    $extensionMap =    preg_split('/\s+/', trim($options->BRHA_excludedFileExtensions));
                    $extension = XenForo_Helper_File::getFileExtension($attachment['filename']);
                  
                    if (!in_array($extension, $extensionMap))
                    {
                        $mustReply = false;
                        $mustLike = false;
                      
                        if($options->BRHA_likeRequired && !$this->getModelFromCache('XenForo_Model_Like')->getContentLikeByLikeUser('post',$post['post_id'],$visitorId)){
                            $mustLike = true;
                        }
                        if($options->BRHA_replyRequired && !$hideAttachment->checkReplied($thread['thread_id'],$visitorId)){
                            $mustReply = true;
                        }  

                        if($mustReply && $mustLike){
                            return $this->responseError(new XenForo_Phrase('BRHA_mustLikeAndReply'));
                        }else if($mustLike){
                            return $this->responseError(new XenForo_Phrase('BRHA_mustLike'));
                        }else if($mustReply){
                            return $this->responseError(new XenForo_Phrase('BRHA_mustReply'));
                        }
                      
                    }
                }
            }
        }
        return parent::actionIndex();
    }
  
    /**
     * @return Brivium_HideAttachment_Model_HideAttachment
     */
    protected function _getHideAttachmentModel()
    {
        return $this->getModelFromCache('Brivium_HideAttachment_Model_HideAttachment');
    }

}

Anh Dev.xf làm thế nào vậy ạ?
 

Top Bottom