Robust
Well-known member
OK, so I want to disable BB Code parsing for some codes using XenPorta 2.0. The author hasn't made it a feature yet, so I've been editing the core to try and do it.
I used this resource's source code to take a look at the BB Code formatter to disable tags. Problem is, I can't integrate that into the ViewPublic_ArticleList file. So my second approach was editing the base parser it uses, which wasn't exactly helpful since it's not really made to filter. Third attempt was adding some of the disabled tags part of the filter into the formatter base for XenPorta, which didn't work either. I think I'm just taking this the completely wrong way.
I can't figure out on how to use the data that's needed for the add-on to function (the bbCodeParser) and still use a formatter to filter out certain BB Codes before.
$formatter = XenForo_BbCode_Formatter_Base::create('XenForo_BbCode_Formatter_BbCode_Filter', array('view' => $this));
$formatter->disableTags(array('u', 'i'));
That's what I think needs to be done somewhere in the code, but I don't have a clue where without causing the entire website to die with an error.
I'd appreciate some assistance I guess the solution is easier than I've been trying to do for the last 2 hours... Damn time flies when you're frustrated.
Edit: I just split it up a bit, I guess it might help in finding out what I actually need to fix. Luckily this didn't break anything.
I used this resource's source code to take a look at the BB Code formatter to disable tags. Problem is, I can't integrate that into the ViewPublic_ArticleList file. So my second approach was editing the base parser it uses, which wasn't exactly helpful since it's not really made to filter. Third attempt was adding some of the disabled tags part of the filter into the formatter base for XenPorta, which didn't work either. I think I'm just taking this the completely wrong way.
I can't figure out on how to use the data that's needed for the add-on to function (the bbCodeParser) and still use a formatter to filter out certain BB Codes before.
$formatter = XenForo_BbCode_Formatter_Base::create('XenForo_BbCode_Formatter_BbCode_Filter', array('view' => $this));
$formatter->disableTags(array('u', 'i'));
That's what I think needs to be done somewhere in the code, but I don't have a clue where without causing the entire website to die with an error.
PHP:
<?php
class EWRporta2_ViewPublic_ArticleList extends XenForo_ViewPublic_Base
{
public function renderHtml()
{
$options = XenForo_Application::get('options');
$attachModel = XenForo_Model::create('XenForo_Model_Attachment');
$bbCodeParser = new XenForo_BbCode_Parser(XenForo_BbCode_Formatter_Base::create('Base', array('view' => $this)));
$bbCodeOptions = array('viewAttachments' => true);
if (!empty($this->_params['author']))
{
$this->_params['author']['html'] = new XenForo_BbCode_TextWrapper($this->_params['author']['author_byline'], $bbCodeParser);
}
foreach($this->_params['articles'] AS &$article)
{
if ($options->EWRporta2_articles_stripnl)
{
$article['article_excerpt'] = str_ireplace("\n", ' ', $article['article_excerpt']);
}
if (stripos($article['article_excerpt'], '[/attach]') !== false && $article['attach_count'])
{
$article['attachments'] = $attachModel->getAttachmentsByContentId('post', $article['first_post_id']);
$article['attachments'] = $attachModel->prepareAttachments($article['attachments']);
}
$bbCodeOptions['attachments'] = !empty($article['attachments']) ? $article['attachments'] : null;
$article['messageHtml'] = new XenForo_BbCode_TextWrapper($article['article_excerpt'], $bbCodeParser, $bbCodeOptions);
}
}
}
I'd appreciate some assistance I guess the solution is easier than I've been trying to do for the last 2 hours... Damn time flies when you're frustrated.
Edit: I just split it up a bit, I guess it might help in finding out what I actually need to fix. Luckily this didn't break anything.
PHP:
$options = XenForo_Application::get('options');
$attachModel = XenForo_Model::create('XenForo_Model_Attachment');
$formatter = XenForo_BbCode_Formatter_Base::create('Base', array('view' => $this));
$bbCodeParser = new XenForo_BbCode_Parser($formatter);
$bbCodeOptions = array('viewAttachments' => true);
Last edited: