Иконка ресурса

HTML BBCode (permission protected) 1.0.8

Нет прав для скачивания
Если Вы хотите разрешить использование данного тега в XenPorta, то Вам необходимо в файле library/EWRporta/ViewPublic/Custom.php заменить:
PHP:
$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);


На:
PHP:
$formatter = Dark_ParseHTML_BbCode_Formatter_Ritsu::create('Dark_ParseHTML_BbCode_Formatter_Ritsu', array('view' => $this));
$bbCodeParser = new Dark_ParseHTML_BbCode_Parser($formatter);            
$bbCodeOptions = array('states' => array('viewAttachments' => true));
Dark_ParseHTML_ViewPublic_Helper_Message::bbCodeWrapMessages($params[$block['block_id']], $bbCodeParser, $bbCodeOptions);


Если Вы хотите, чтобы данный BB-код работал в менеджере ресурсов, то откройте файл library/XenResource/ViewPublic/Resource/Description.php и замените всё его содержимое на:
PHP:
<?php

class XenResource_ViewPublic_Resource_Description extends XenForo_ViewPublic_Base
{
    public function renderHtml()
    {
        XenForo_Application::set('view', $this);

        $formatter = Dark_ParseHTML_BbCode_Formatter_Ritsu::create('Dark_ParseHTML_BbCode_Formatter_Ritsu', array('view' => $this));
        $bbCodeParser = new Dark_ParseHTML_BbCode_Parser($formatter);
        $bbCodeOptions = array(
            'states' => array(
                'viewAttachments' => $this->_params['canViewImages']
            ),
            'showSignature' => false
        );

        $this->_params['update']['messageHtml'] = Dark_ParseHTML_ViewPublic_Helper_Message::getBbCodeWrapper(
            $this->_params['update'], $bbCodeParser, $bbCodeOptions
        );

    }
}


Для того, чтобы этот BB-код работал и на XenZine, откройте файл library/XenZine/ViewPublic/Article/View.php и всё его содержимое замените на:
PHP:
<?php

class XenZine_ViewPublic_Article_View extends XenForo_ViewPublic_Base
{
    public function renderHtml()
    {
        $formatter = Dark_ParseHTML_BbCode_Formatter_Ritsu::create('Dark_ParseHTML_BbCode_Formatter_Ritsu', array('view' => $this));
        $bbCodeParser = new Dark_ParseHTML_BbCode_Parser($formatter);
        $bbCodeOptions = array(
            'states' => array(
                'viewAttachments' => true
            )
        );
    
        $article = $this->_params['article']; // referance unalterd copy
    
        $this->_params['article']['message'] = $this->_params['article']['body'];
        $this->_params['article']['body'] = Dark_ParseHTML_ViewPublic_Helper_Message::getBbCodeWrapper($this->_params['article'], $bbCodeParser, $bbCodeOptions);
    
    
        $this->_params['article']['message'] = $this->_params['article']['resource_box'];
        $this->_params['article']['resource_box'] = XenForo_ViewPublic_Helper_Message::getBbCodeWrapper($this->_params['article'], $bbCodeParser, $bbCodeOptions);
    

    
        // we also want to render all of the different types of custom fields
        $customFieldModel = $this->_getCustomFieldModel();
        
        $customFieldsFromCache = $customFieldModel->getCustomFieldsFromCache();
    
        $customValues = $this->_params['customFieldsBottom'];
        $this->customFeildsBbCodeWrapper($this->_params['customFieldsBottom'], $customValues, $customFieldsFromCache, $article, $customFieldModel, $bbCodeParser, $bbCodeOptions);
    
        $customValues = $this->_params['customFieldsSide'];
        $this->customFeildsBbCodeWrapper($this->_params['customFieldsSide'], $customValues, $customFieldsFromCache, $article, $customFieldModel, $bbCodeParser, $bbCodeOptions);
    
        $customValues = $this->_params['customFieldsTop'];
        $this->customFeildsBbCodeWrapper($this->_params['customFieldsTop'], $customValues, $customFieldsFromCache, $article, $customFieldModel, $bbCodeParser, $bbCodeOptions);
    
        $tabs = $this->_params['customTabs'];
        if($tabs)
        {
            foreach($tabs as $tabKey=>$tab)
            {
                $customValues = $this->_params['customTabs'][$tabKey]['customFields'];
                $this->customFeildsBbCodeWrapper($this->_params['customTabs'][$tabKey]['customFields'], $customValues, $customFieldsFromCache, $article, $customFieldModel, $bbCodeParser, $bbCodeOptions);
            }
        }
            
    }


    public function customFeildsBbCodeWrapper(&$paramKey, $customValues, $customFieldsFromCache, $article, $customFieldModel, $bbCodeParser, $bbCodeOptions)
    {

        if($customValues)
        {
            foreach($customValues as $customValueKey => $customValue)
            {
                if($customValue)
                {
                    $field_id = $customValue['field_id'];
                    $field = $customFieldModel->getCustomFieldById($field_id, $customFieldsFromCache);    
                    $fieldMap = $customFieldModel->getCustomFieldMapByType($field['field_type']);
                    if($fieldMap == "text" || $fieldMap == "single")
                    {
                        $field_value = $customValue['field_value'];
                        $nArticle = $article; // use a referance, so we can keep using it, it gets moddifed on passing through getBbCodeWrapper
                        $nArticle['message'] = $field_value;
                        $field_value = XenForo_ViewPublic_Helper_Message::getBbCodeWrapper($nArticle, $bbCodeParser, $bbCodeOptions);
                        $paramKey[$customValueKey]['field_value'] = $field_value;
                        $this->removeCustomAttachments($nArticle['message'], $this->_params['article']);
                    }
                    if($fieldMap == "multiple" )
                    {
                        foreach($customValue['field_value'] as $vKey => $v)
                        {
                            $nArticle = $article; // use a referance, so we can keep using it, it gets moddifed on passing through getBbCodeWrapper
                            $nArticle['message'] = $v;
                            $v = XenForo_ViewPublic_Helper_Message::getBbCodeWrapper($nArticle, $bbCodeParser, $bbCodeOptions);
                            $paramKey[$customValueKey]['field_value'][$vKey] = $v;
                            $this->removeCustomAttachments($nArticle['message'], $this->_params['article']);                            
                        }
                    }                
                    if($fieldMap == "tablerows" )
                    {                
                        foreach($customValue['field_value']['rows'] as $rowKey => $row)
                        {
                                
                            foreach($row['value'] as $cellKey => $cell)
                            {
                                $nArticle = $article; // use a referance, so we can keep using it, it gets moddifed on passing through getBbCodeWrapper
                                $nArticle['message'] = $cell;
                                $cell = XenForo_ViewPublic_Helper_Message::getBbCodeWrapper($nArticle, $bbCodeParser, $bbCodeOptions);
                                $paramKey[$customValueKey]['field_value']['rows'][$rowKey]['value'][$cellKey]    = $cell;
                                   $this->removeCustomAttachments($nArticle['message'], $this->_params['article']);    
                            }
                        }    
                    }
                }
            }    
        
        }
    
            
    }


    public function removeCustomAttachments($text, &$message) // remove attachments from body message that are found in cusotm Attachments
    {
            if (stripos($text, '[/attach]') !== false)
            {
                if (preg_match_all('#\[attach(=[^\]]*)?\](?P<id>\d+)(\D.*)?\[/attach\]#iU', $text, $matches))
                {
                    foreach ($matches['id'] AS $attachId)
                    {
                        unset($message['attachments'][$attachId]);
                    }
                }
            }
    }

    protected function _getCustomFieldModel()
    {
        return XenForo_Model::create('XenZine_Model_CustomField');
    }    
}
Назад
Сверху Снизу