BbCodes & Buttons Manager

BbCodes & Buttons Manager 3.3.5

No permission to download

cclaerhout

Well-known member
cclaerhout submitted a new resource:

BbCodes & Buttons Manager - Create some Bb Codes & Buttons - Configure XenForo default Bb Codes

Bb Codes & Buttons Manager

Addon Presentation

This addon will allow you to create some Bb Codes & Buttons and will help you to configure XenForo default Bb Codes.


Bb Codes Creation
  • Three parsing methods to create your Bb Codes:
    1. direct replacement with fallbacks (not recommended to deal with options)
    2. Template (callbacks available)...

Read more about this resource...
 
FAQ

  1. There are three rendering methods, which one should I use if I want to begin with?
    If your Bb Code is basic, just use the Replacement method. But I still recommend to use the Template method.

    The big advantage of the Template Method is that it's easier to customize & write a Bb Code. For example, to include a javascript you don't need to worry to use a hook listener (or a replacement with TMS). You just use the xen tag <xen:require js="js/directory/file.js" /> and the javascript will be automatically loaded, and this only once, when the Bb Code is used. Same thing for css.

    It is also more comfortable to manage Bb Codes options thanks to the XenForo template conditionals and helpers. Speaking of Bb Codes options, I've got only one recommendation: always keep the control on which final value will be used at the end. See the highlighter template code: the background color can be selected by the user, but it's you (and not the user) who decides if the option is valid or not.

  2. I was using before the StopAutolinkingPatch. Should I do something before remove it and use this addon stop autolinking function?
    Yes. Read here.

  3. How can I make the parser permissions work with XenPorta?
    Disclaimer: I remind you the parser permissions is an experimental feature
    Try this:
    Edit 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)));

  4. The "Custom Bb code Manager" BbCode xml files don't work with this addon, is this normal?
    Yes, you will need to recreate them. With the 1.1 version, a converter/exporter is available, just use it.

  5. I'm using PHP 5.2.x and I have problems: most of the tags are disappearing. What can I do?
    You will have to edit a XenForo file. Sorry there is no other alternative.
    This file is: XenForo_BbCode_Formatter_Base
    Path: {yourForum}/library/XenForo/BbCode/Formatter/Base.php

    Search:
    PHP:
                return call_user_func($tagInfo['callback'], $tag, $rendererStates, $this);

    Replace:
    PHP:
                /*return call_user_func($tagInfo['callback'], $tag, $rendererStates, $this);*/
                return call_user_func_array(array($tagInfo['callback'][0], $tagInfo['callback'][1]), array($tag, $rendererStates, $this));

    Explanation (as far as I'm able to explain...): $this doesn't seem to be recognized using call_user_func in an extended class (xfcp). Using call_user_func_array fixes the problem.

  6. How to configure buttons with XenForo Redactor Editor ?
    A tool is now included in this addon. If you want to do it manually, see this section.

  7. Should I modify the "BbCodes Options Separator" option in this addon general options or should I modify the "Custom options separator" option in the bbcode options ("Parser configuration tab") ?
    If you have any other bbcodes using [coma+blank] as separator, don't modify the global options:
    View attachment 56413
    But modify it here
    View attachment 56412

    If you don't have any other bbcodes using [coma+blank] as separtor, don't hesitate to modify the goblal option.

  8. Using some bbcodes inside the options of a Bb Code breaks the opening tag, ie: [bbcode=[b]Text[/b]]Content[/bbcode], how can I avoid this?
    Check this.

  9. I want to select an icon for my button, but the XenForo default sprite has not the icon I need, what can I do ?
    Use your imagination & talent to create an icon or go there: http://icomoon.io/app/, then select a free pack of icons, ajust the size,and download the ones you will have selected (png format is available).
 

Attachments

  • 12_bbm_buttons_01.webp
    12_bbm_buttons_01.webp
    33.2 KB · Views: 176
  • 13_bbm_buttons_02.webp
    13_bbm_buttons_02.webp
    31.8 KB · Views: 171
  • 14_bbm_buttons_03.webp
    14_bbm_buttons_03.webp
    14.8 KB · Views: 159
  • 15_bbm_bbcodes_bulk_export.webp
    15_bbm_bbcodes_bulk_export.webp
    18.6 KB · Views: 160
  • 16_bbm_editor_config_index.webp
    16_bbm_editor_config_index.webp
    26.9 KB · Views: 154
  • 17_bbm_editor_config_add.webp
    17_bbm_editor_config_add.webp
    25 KB · Views: 163
  • 18_bbm_editor_config_buttons.webp
    18_bbm_editor_config_buttons.webp
    23.8 KB · Views: 175
  • 19_bbm_editor_config_button_edit.webp
    19_bbm_editor_config_button_edit.webp
    39.2 KB · Views: 163
  • 20_bbm_bbcodes_options_01.webp
    20_bbm_bbcodes_options_01.webp
    43.6 KB · Views: 161
  • 21_bbm_bbcodes_options_02.webp
    21_bbm_bbcodes_options_02.webp
    27.2 KB · Views: 169
  • 22_bbm_xenbbcodes_options_01.webp
    22_bbm_xenbbcodes_options_01.webp
    34.9 KB · Views: 160
  • 23_bbm_xenbbcodes_options_02.webp
    23_bbm_xenbbcodes_options_02.webp
    30.7 KB · Views: 162
Last edited:
Tools for developers to use in callbacks

> Get thread datas (when a Bb Code is used inside a XenForo thread)
  • $parentClass->getThreadParams(); //Get all thread parameters
  • $parentClass->getThreadParam('myParam');//Get one thread parameter
Returns null if the Bb Code has not been used inside a thread

Example:
PHP:
$nodeid = $parentClass->getThreadParam('node_id');

> Get post datas (when a Bb Code is used inside a XenForo thread)
  • $parentClass->getPostParams(); //Get all current post parameters
  • $parentClass->getPostParam('myParam'); //Get one parameter of the current post
Returns null if the Bb Code has not been used inside a thread

Example:
PHP:
$post_date = $this->getPostParam('post_date');

Disclaimer: this function is using a reverse processing method to get post datas from the thread datas (see the "parser permissions" section of this addon presentation)

> Add/Remove a wrapper to a Bb Code
  • $parentClass->addWrapper('wrappingTag', 'wrapping Tag Options');
  • $parentClass->removeWrapper();
Example:
If you want to make a text container and want to automatically wrap it inside the spoiler tag of your forum:
PHP:
$parentClass->addWrapper('spoiler', 'Inside this spoiler... a magical picture !');


> Render a template with the PHP callback Method
  • $parentClass->renderCustomTemplate('templateName', $params); //params being an array
Example:
PHP:
    $template = $parentClass->renderCustomTemplate('templateName', array(
        'content' => $yourBbContent,
        'misc' => $yourMiscVariables
    ));

    if($template !== false)
    {
        return $template;
    }

    /*****
    *  The parent class variable $this->_view was null (must be a template admin)
    *  Then the $template variable returned false
    *  Let's return some direct html code
    ****/
    return "<b>Your Fallback</b>";

Important: if you render a template from a php callback, you must first cache it (see below)

> Cache one or several templates with the PHP callback Method
In this situation you can't call a direct function from your Bb Code callback. You need to create one static function for your class. It doesn't matter if your class renders one or several Bb Codes. This static function must be named "preloadTemplates". The method called (the Bb Code function use to parse it) is passed as an argument.

PHP:
public static function preloadTemplates($callbackFunction)
{
    switch($callbackFunction)
    {
        case 'parseTagBbCode1':
            return 'TemplateName_1';
        break;
    }
}

public static function parseTagBbCode1(array $tag, $bboptions, $options, $parentClass)
{
    //your own code
}

Important: no need to cache a template with the Template Callback Method. It is automatically done, unless you redirect it to another template. But don't bother you to do this. Once in the main template, you can play with conditionals and with the xen tag include.

> Buffer extra information (add/get) during the page building
The parser is called by page and not by post. This means when a Bb Code is parsed it's possible to add & stock extra information in the parent class in order to retrieve it the next time the Bb Code will be parsed in the page. Here are two functions to use this buffer: the first one is to add extra information in that buffer (all added information are sorted by tags), the second one is to get information from that buffer.
  • $parentClass->addTagExtra($infoKey, $info)
    • $info can be an array or a string
    • a third parameter exists: true/false (default is false). Its purpose to activate an "array mode". Example: $parentClass->addTagExtra($infoKey, $info, true). Once activated if each added $info will not erase the previous one, but will create an array for the $infoKey
  • $parentClass->getTagExtra($infoKey)
    • a second parameter exists. If the value of the $infoKey is an array you can match one of its element directly: $parentClass->getTagExtra($infoKey, $arrayKey)
    • As mentioned previously all information are added or extracted by tag. If you want all extra information for all the tags, use this: $parentClass->getTagExtra() (without any parameter).
For an example, please have a look at the picasa Bb Code available in this addon.


> Get attachments parameters
  • Basic command: $parentClass->getAttachmentParams('ID');
  • Optional parameters:
    • Valid Extensions: array
      $parentClass->getAttachmentParams('ID', $validExtensions);
    • Extra Permissions: arraymade with another array with three keys:
      • 'permissions' ; optional, if not specified will use the "permissions" key of the visitor object
      • 'group'
      • 'permission'
      $parentClass->getAttachmentParams('ID', $validExtensions, $extraPerms);

      These extra permissions are a fallback when the attachment parameters don't exist, which means the attachment is not in the post but can be available in the thread or another post
    • Return: arraywith these keys:
      • 'attachment': if valid Attachment, array with attachment data (the attachment must be inside the post to get this)
      • 'validAttachment': true or false (if not authorised extension: false)
      • 'canView': true or false
      • 'url': url to the attachement
      • 'fallbackPerms': true or false
Example:
PHP:
                $validExtensions = array('gif', 'png', 'jpg', 'jpeg');
                $permsFallback[] = array('group' => 'forum', 'permission' => 'viewAttachment');
                $attachmentParams = $parentClass->getAttachmentParams($attachmentID, $validExtensions, $permsFallback);
 

Attachments

  • 24_bbm_xenbbcodes_options_03.webp
    24_bbm_xenbbcodes_options_03.webp
    12.9 KB · Views: 231
  • 25_bbm_buttons_options_01.webp
    25_bbm_buttons_options_01.webp
    44.5 KB · Views: 151
  • 26_bbm_buttons_options_02.webp
    26_bbm_buttons_options_02.webp
    42.6 KB · Views: 151
  • 27_bbm_buttons_options_03.webp
    27_bbm_buttons_options_03.webp
    29 KB · Views: 148
  • 28_bbm_buttons_options_04.webp
    28_bbm_buttons_options_04.webp
    36.9 KB · Views: 146
  • 29_bbm_editor.webp
    29_bbm_editor.webp
    8.6 KB · Views: 149
  • 30_bbm_notice.webp
    30_bbm_notice.webp
    50.6 KB · Views: 180
  • 31-callback_integrity_checker.webp
    31-callback_integrity_checker.webp
    40.4 KB · Views: 135
  • 32-bbcm_convert_export_tool_01.webp
    32-bbcm_convert_export_tool_01.webp
    52 KB · Views: 217
  • 33-bbcm_convert_export_tool_02.webp
    33-bbcm_convert_export_tool_02.webp
    33.1 KB · Views: 134
  • 34-bbcm_convert_export_tool_03.webp
    34-bbcm_convert_export_tool_03.webp
    20.2 KB · Views: 134
  • 35_bbm2_bm01.webp
    35_bbm2_bm01.webp
    28.6 KB · Views: 112
Last edited:
How to configure buttons with XenForo Redactor Editor ?

Edit: with the version 2.2.0 of this addon, there is now a feature to avoid the below steps. Of course the below steps are still working and might give your more possibilities to customize your buttons.

Presentation
If you don't want to use the TinyQuattro editor and still want to use the XenForo Redactor Editor, you will have to check the html code and get the button class (see the example in the next section below). It should be like this: .redactor_btn_bbm_yourBbCodeTag. You need to create your own sprite (a sprite is an image with several icons) and then use css to set the position of your icon in the sprite. You can also use the XenForo default sprite and play with this code (move background position):

Code:
.redactor_toolbar li a.redactor_btn_bbm_yourBbCodeTag,
.redactor_toolbar li a.redactor_btn_bbm_yourBbCodeTag:hover {
   background-position: 0 0;
}

Demo with the XenForo default sprite and the default XenForo smiley icon
Click here to display the XenForo default sprite. We're going to change the smiley icon with another one, let's say the one above inside the sprite:
redactor_editor.webp

To get the smiley icon class, just use any developer tool provided with your browser (for example with Firefox: Firebug). So with Firebug: right click on the smiley icon, then select "Inspect with Firebug". You should see this then:
redactor_editor2.webp

As you can see, the css class for the smiley icon is: redactor_btn_smilies. It will be the same thing for your custom buttons with the BBM, except the class format will be: redactor_btn_bbm_yourBbCodeTag (a prefix "bbm" is used before your bbcode tag).

The previous screenshot has also an important information about css (see in green):
redactor_editor3.webp

If you want to use another icon of the XenForo default sprite, you will only have to modify the background position. You can do it in live with Firebug:
redactor_editor4.webp

So the new background position will be: 3px -2365px. You just need to add this information into your EXTRA.css template. Since you're overriding the XenForo default configuration of the smiley icon, you will have to add !important to the css:
Code:
.redactor_toolbar li a.redactor_btn_smilies {
   background-position: 3px -2365px !important;
}

If you want to set the same icon for a custom button using the XenForo default sprite:
Code:
.redactor_toolbar li a.redactor_btn_bbm_yourBbCodeTag,
.redactor_toolbar li a.redactor_btn_bbm_yourBbCodeTag:hover {
   background-position: 3px -2365px;
}
P.S: the hover extra configuration seems to be needed according to Mike West (source). I don't use Redactor, so I can't confirm but do as Mike West recommends.

You can also use your own sprite, which means you will have to create your own image with several icons in it. Once you created your sprite, the logic is the same as above. You just need to add what sprite you want to use:
Code:
.redactor_toolbar li a.redactor_btn_bbm_yourBbCodeTag,
.redactor_toolbar li a.redactor_btn_bbm_yourBbCodeTag:hover {
  background-image: url("styles/default/xenforo/editor/mySprite.png");
   background-position: 0 0;
}
P.S: You can of course change your sprite path. You will have to set your background position too.

The below information are very detailed. Once you understand how to use css, you will spend no more than 20 seconds to configure one custom button.
 

Attachments

  • 36_bbm2_bm02.webp
    36_bbm2_bm02.webp
    31.3 KB · Views: 120
  • 37_bbm2_bbcodes_new_options.webp
    37_bbm2_bbcodes_new_options.webp
    61.9 KB · Views: 117
  • 38_bbm2_bm03.webp
    38_bbm2_bm03.webp
    27.5 KB · Views: 114
Last edited:
So does this replace the other BB Code Manager?

I know it was released under someone else, but I'm fairly sure you helped maintain that one. Just wondering if I need to uninstall the other one or do they play nice?
 
So does this replace the other BB Code Manager?

I know it was released under someone else, but I'm fairly sure you helped maintain that one. Just wondering if I need to uninstall the other one or do they play nice?

Yes, holding off installation of this (and two of your other addons) until I get an answer.
 
So does this replace the other BB Code Manager?

I know it was released under someone else, but I'm fairly sure you helped maintain that one. Just wondering if I need to uninstall the other one or do they play nice?
Yes, holding off installation of this (and two of your other addons) until I get an answer.

Please have a look at this addon presentation and read the "Important" paragraph (in orange) of the "Installation" section. You can also refer to the last screenshot for more information. If you believe the Important paragraph can be rephrased in a proper and more understable English, please do and I will correct.
 
Please have a look at this addon presentation and read the "Important" paragraph (in orange) of the "Installation" section. You can also refer to the last screenshot for more information. If you believe the Important paragraph can be rephrased in a proper and more understable English, please do and I will correct.

This is what you get for not reading :P Sorry about that.
 
so after creating the template i need to go to the style and put the code there and save it right ?!

i hope u put some explanation about how to make the code =( cuz i try before with bbcode manager and i didn`t understand how its work and none answer any question i ask =(
so i hope working with this addon is different
 
when i try to import xml file
its says

Fatal error: Call to undefined method SimpleXMLElement::count() in /home/user/public_html/forum/library/BBM/ControllerAdmin/BbCodes.php on line 418
 
i dont know :$
but the host is hostgator =\ so i think they update for the last version i don`t know exactly i will ask them ><"

You must be on PHP 5.2, because that function only exists on PHP 5.3.

Untested solution:

In that file, Line 418, find:
$BbCodes = $file->BbCode->count();
Replace with
$BbCodes = count($file->BbCode);
 
You must be on PHP 5.2, because that function only exists on PHP 5.3.

Untested solution:

In that file, Line 418, find:
$BbCodes = $file->BbCode->count();
Replace with
$BbCodes = count($file->BbCode);
yes its 5.2.17

ok i will try this solution ^,^
 
You must be on PHP 5.2, because that function only exists on PHP 5.3.

Untested solution:

In that file, Line 418, find:
$BbCodes = $file->BbCode->count();
Replace with
$BbCodes = count($file->BbCode);
Thank you, I've tested and it works, but it must be confirmed by a php 5.2 user. I will wait a little before publishing an update to see if there's no other problem.
 
so after creating the template i need to go to the style and put the code there and save it right ?!

i hope u put some explanation about how to make the code =( cuz i try before with bbcode manager and i didn`t understand how its work and none answer any question i ask =(
so i hope working with this addon is different

The easiest to do is to have a look at the highlighter Bb Code or this Bb Code (more complex => has a template callback).

The big advantage of the Template Method is that it's easier to customize & write your Bb Code. For example if you want to include a javascript you don't need to worry to use a hook listener (or a replacement with TMS). You just use the xen tag <xen:require js="js/directory/file.js" /> and the javascript will be automatically loaded, and this only once, when the Bb Code is used. Same thing for css.

It is also more comfortable to manage Bb Codes options thanks to the XenForo template conditionals and helpers. Speaking of Bb Codes options, I've got only one recommendation: always keep the control on which final value will be used at the end. See the highlighter template code: the background color can be selected by the user, but it's you (and not the user) who decides if the option is valid or not.

I might create some helpers to check Bb Codes options (is it a number, how many figures has it, etc) but I didn't think clearly about it and I can't spend too much time on developing new functions. I would be nice if users can help each others like tyteen4a03 just did.
 
its 5.2.17

Upgrade your version of PHP

5.2.x reached end of life December 2010 (almost 2 1/2 years ago). There is also a few known security issues which have not been patched or addressed.

Suggest you upgrade to php 5.4 as 5.5 will soon be released.

If you can't do this because you don't know how, ask for help and I'll be happy to do it for you. OR if you're on a shared hosting account, ask your host if they offer something newer and if not, find a new host.
 
Top Bottom