• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

As designed load_class_bb_code Event Listener Not Always Called

digitalpoint

Well-known member
#1
When loading the BBCode class, the load_class_bb_code event listener isn't firing (probably loading the class direct instead of via loader?)...

Specifically if you edit a post, the AJAX editor that is overlayed doesn't have it fired, nor is the editor if you if you click on "More Options..." from that AJAX overlay.

Actually, now that I test... it just seems like it's not firing anytime for things within the WYSIWYG editor.
 

Jake Bunce

XenForo moderator
Staff member
#2
I see no reason for this. Which class are you extending? The inline post editor would use XenForo_BbCode_Formatter_Wysiwyg (assuming the rich editor is active).
 

digitalpoint

Well-known member
#5
It's XenForo_BbCode_Formatter_Base... Again, it works fine when viewing a thread, but not within the editor. All I'm really doing it wrapping a <span> around the smilie images...
PHP:
<?php

class DigitalPointLittleThings_BbCode_Formatter_Base extends XFCP_DigitalPointLittleThings_BbCode_Formatter_Base
{
	protected $_smilieSpriteTemplate = '<span class="smileWrapper"><img src="styles/default/xenforo/clear.png" class="mceSmilieSprite mceSmilie%1$d" alt="%2$s" title="%3$s    %2$s" /></span>';
}
 

Jake Bunce

XenForo moderator
Staff member
#6
The thread view uses "Base":

XenForo_ViewPublic_Thread_View::renderHtml

Code:
		$bbCodeParser = new XenForo_BbCode_Parser(XenForo_BbCode_Formatter_Base::create('Base', array('view' => $this)));
The inline post editor uses "Wysiwyg":

XenForo_ViewPublic_Helper_Editor::getEditorTemplate

Code:
				$bbCodeParser = new XenForo_BbCode_Parser(XenForo_BbCode_Formatter_Base::create('Wysiwyg', array('view' => $view)));
That's why your extended class isn't working. You would have to extend "Wysiwyg" as well in your "load_class_bb_code" listener. Even though Wysiwyg extends Base, your extended Base class will only work when Base is created in the loader. So you need to name the other formatters as well.

Also, this might be relevant when you extend the other formatters:

http://xenforo.com/community/threads/redeclaration-error-for-extended-class.24773/

I am going to call this "as designed" but leave it in the bug forum so the devs can have the final word.