Resource icon

Custom BB Code Manager v1.3.4

No permission to download
Version 1.3.5.3 - Change Log:
  • Installer modified (quick fix, would need to be fully rewritten)
  • Fix a bug when disable/enable buttons (quick fix too)
To upgrade: use the AutoInstaller addon or upload files/import xml


Link to download
 
Thanks Cedric the error went away now. But one strange thing is happening. I had the addon unistalled and reinstalled but strangely the "copy plain" function is still working and the bb code isn't there to deactivate.
 
Plain is a XenForo bbcode (like strike, code,...). It's not a custom bbcode.

Salud2

Let me clarify; There was a feature where all copy-paste content would be applied as "plain text". Although the BB Code isn't present anymore, all my text is applied as "plain text". The BB Code doesn't exist anymore, I can't disable it. Or am I missing something?

Thanks for the help.
 
Let me clarify; There was a feature where all copy-paste content would be applied as "plain text". Although the BB Code isn't present anymore, all my text is applied as "plain text". The BB Code doesn't exist anymore, I can't disable it. Or am I missing something?

Thanks for the help.
I don't understand. As lms said it, the PLAIN Bb Code is a default XenForo Bb Code. It will not be displayed inside the Custom Bb Codes Manager.
Now if you're talking about TinyMCE Enhancements addon and the plain text copy function it's different... but I don't see the point.

Which Bb Code are you talking about?
What do you mean with "plain text" ?
 
I don't understand. As lms said it, the PLAIN Bb Code is a default XenForo Bb Code. It will not be displayed inside the Custom Bb Codes Manager.
Now if you're talking about TinyMCE Enhancements addon and the plain text copy function it's different... but I don't see the point.

Which Bb Code are you talking about?
What do you mean with "plain text" ?

Sorry, some words get lost in translation. I guess I'm referring to your "Premium BB Code Toolbar" addon. It had a bb code, if I'm not mistaken, that added a bb code to the editor that when you copy-paste rich text into the editor, it would strip it to only text.

I have unistalled that addon (to debug which addon was acting weird), removed the BB Code. However, if I paste anything it's stripping all the rich content (bold, italik, images, paragraphs etc.)

Hope this was clear enough. Weird issue indeed.
 
Sorry, some words get lost in translation. I guess I'm referring to your "Premium BB Code Toolbar" addon. It had a bb code, if I'm not mistaken, that added a bb code to the editor that when you copy-paste rich text into the editor, it would strip it to only text.
No it doesn't have. This function is from the TinyMCE Enhancements addon. You should reinstall it again and configure its option again. Please post in this addon topic.
 
Version 1.3.5.4 - Change Log:
  • Add two new tools for Bb Code developers (who are using callbacks)
  1. A tool to render a template directly from the callback
  2. A tool to cache this template to avoid database queries
  • See documentation below
To upgrade:use the AutoInstaller addon or upload files/import xml
Link to download


Developer Tools to cache and to render a template from a Bb Code Callback

I- Render a template from the callback
A short example:
PHP:
            $template = $parentClass->renderCustomTemplate('templateName', array(
                'content' => $content,
                'misc' => $misc_variables
            ));
 
            if($template !== false)
            {
                return $template;
            }
 
            /*****
            *  The parent class variable $this->_view was null (I'm not sure when/if it happens)
            *  Then the $template variable returned false
            *  Let's return some direct html code
            ****/
            return "<b>Direct Html Code</b>";
This example is inside the Callback Bb Code function

II- Cache one or several templates from the callback
If you only use the above command to render a template, it will add database extra queries. To avoid this, you will have to cache the templates you use inside your callback. To do this, it's very easy. You just need to add a new static function to your callback class. It must be called "preloadTemplates".

The return can be a simple string:

PHP:
    public static function preloadTemplates($callbackFunction)
    {
        return 'TemplateName';
    }

or an array:
PHP:
    public static function preloadTemplates($callbackFunction)
    {
        return array('TemplateName_1', 'TemplateName_2');
    }

Or this way:
PHP:
    public static function preloadTemplates($callbackFunction)
    {
        switch($callbackFunction)
        {
            case 'parseTagBbCode1':
                return 'TemplateName_1';
            break;
        }
    }
 
Excellent work Ragtek, this also makes it easier for users to modify the final rendered output :)
Thank you but I really don't have the level of Ragtek for php ^^

Speaking of php, in a next release I will add an argument to the function preloadTemplates($arg) to get the trace of which method is being called (I should have done it at the first place, sorry). If a callback has several Bb Codes in it but some of them are disabled, it will avoid to preload their template(s) for nothing.

In a next release I would have liked to add a system that detects in which posts the Bb Code is being rendered but I didn't find a way. It's possible to get the thread and posts information (if they are available) but we get all of them at the same time in a big array and not post by post. I guess it would be possible to implement a counting system (for BbCodes which are using the callbacks) to trace back the post, but it would not be very elegant... If we can access the post information by Bb Code, then it's possible to parse it or not according to the author (a function that many people seem to want) or to parse it differently according to the date... which would be great for a subscription system (like the Premium Bb Codes... <= which I need to rewrite by the way). The idea: display the content of a Bb Code during 24 hours then hides it if not a premium member. I would really like to have such a tool. But again this is just theory and just a wish :)
 
In a next release I would have liked to add a system that detects in which posts the Bb Code is being rendered but I didn't find a way. It's possible to get the thread and posts information (if they are available) but we get all of them at the same time in a big array and not post by post. I guess it would be possible to implement a counting system (for BbCodes which are using the callbacks) to trace back the post, but it would not be very elegant... If we can access the post information by Bb Code, then it's possible to parse it or not according to the author (a function that many people seem to want) or to parse it differently according to the date... which would be great for a subscription system (like the Premium Bb Codes... <= which I need to rewrite by the way). The idea: display the content of a Bb Code during 24 hours then hides it if not a premium member. I would really like to have such a tool. But again this is just theory and just a wish :)

I've found a way and quite a clean one. If some developers can test it, it would be nice: http://pastebin.com/mJx0vZKM
So this class implements 4 new functions that can be used inside the Bb Code callback:
  1. $parentClass->getThreadParams(); //Get all thread parameters
  2. $parentClass->getThreadParam('myParam');//Get one thread parameter
  3. $parentClass->getPostParams(); //Get all current post parameters
  4. $parentClass->getPostParam('myParam'); //Get one parameter of the current post
Of course to get these parameters, the BbCode must have been used inside a thread or a post otherwise it will return a NULL value. I could do the same thing for Conversations, but I don't really see the purpose to do it here. Now I haven't tried yet if it works or not with XenPorta.
 
Teasing of the next version. It's already working but I still need to test it on a fresh install & to test it with XenPorta. I will do this later.
present1.webp
I would also like to add a new Parser Method that allows to load directly a template with a $content & $options variables. But that will be may be in a future version, not the next one.
 

Attachments

  • present2.webp
    present2.webp
    33.9 KB · Views: 6
Version 1.3.5.5 - Change Log:
Link to download
  • The installer has been modified:
    • On a fresh install, no more Bb Code will be automatically installed.
    • You will need to install the Bb Code xml file from the "extras" directory of this archive.
  • New parsing method from templates added
    • It's easy and safe to use (see the demo of the new highlighting Bb Code)
    • This new template parsing method has also its own callback (easier to use than the callback parsing method)
  • New parsing permissions added - only works in posts (doesn't work with XenPorta check this for XenPorta - needs to be confirmed)
    • Parsing permission based on usergroups
    • When the user is unauthorised, the parser return can be modified
    • See the demo of the new Html Bb Code (again, it will only work in posts. This is just for the demo - no support given)
  • New option to parse or not Bb Codes inside the options of the opening tag
    • Example: [bbcode=[b]Caption[/b]]Content[/bbcode]
    • You can test this with importing again the spoiler Bb Code.
  • The highlighting, Html and spoiler Bb Codes are provided with Buttons
  • The layout of the Bb Code add/edit page has been modified, new phrases, new categories, new explanations, etc.
  • A bug of the Button Manager has been corrected when setting permissions to the button
  • Some code of the Bbcm Datawriter has been modified to give better information when an error occurs
  • Tested on two forums (update) + 1 forum (fresh install)
To upgrade: use the AutoInstaller addon or upload files/import xml

pa1.webp
pa2.webp
pa3.webp
pa4.webp
pa5.webp
pa6.webp
pa7.webp
pa8.webp
 
I think I found an easy way to make the parser permissions work with XenPorta.
You just need to add a small line of code to this file: {yourForum}/library/EWRporta/ViewPublic/Custom.php

Search for:
PHP:
                $bbCodeParser = new XenForo_BbCode_Parser(XenForo_BbCode_Formatter_Base::create('Base', array('view' => $this)));

Replace with:
PHP:
                $this->_params['posts'] = $params[$block['block_id']];
                $bbCodeParser = new XenForo_BbCode_Parser(XenForo_BbCode_Formatter_Base::create('Base', array('view' => $this)));

I did a quick test and it seems ok. It needs to be confirm by other users.
 
Top Bottom