As designed load_class_bb_code Event Listener Not Always Called

digitalpoint

Well-known member
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.
 
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).
 
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>';
}
 
The thread view uses "Base":

XenForo_ViewPublic_Thread_View::renderHtml

Rich (BB 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

Rich (BB 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.
 
Top Bottom