Resource icon

Custom BB Code Manager v1.3.4

No permission to download
Ah! A simple space was all I needed.

Works fine now apart from the last option. That stays as {11} it should be SK

Code:
[442="GK, LB, CB, CB, RB, LW, CM, CM, RW, SK, SK"]text[/442]

I assume that is correct now ^

EDIT: Never mind. Seems to have started working now. Thanks for the help.
 
I've updated the patch for the Base.php file => will now use only 1 query in any case.
Information for users of the "Custom BB Code Manager" (v1.2.1)

If you create a custom bbcode using the regex (10/05/2012: not if you use regex sorry, but if you use 'Requires Advanced Options') OR if you use callback functionality, then you should update the following file:
"/library/KingK/BbCodeManager/BbCode/Formatter/Base.php".
Why ?
Because it's using 1 database request for each of thoses bbcode (not only once, but every time a bbcode is used inside a message). King Kovifor has been informed about the problem, but he is really busy at the moment. So here is the "Base.php" file i'm using on my own forum. It only fixes the problem for bbcode with customized callbacks (not those using regex functions).


UPDATE 10/05/2012
File updated => this patch fixes 'Callback' & 'Requires Advanced Options'
 

Attachments

Hello, I created a bbcode to simulate a dice roll.

PHP:
<?
    public static function bbcodeDes(array $tag, array $rendererStates, &$parentClass)
    {
            $nombreFaces = intval($tag['children'][0]); // Convert String to Int
 
            if($nombreFaces == 0 OR $nombreFaces == 1 OR $nombreFaces == null)
            {
                $nombreFaces = 6;
            }
 
            $result = rand(1, $nombreFaces);
            return $result;
    }

Example :

(Create message)
1bVrD.jpg


I would like => After Creation => (edition) =>

1bVsu.jpg


How can execute a bbcode treatment only once please ?
 
Gift:

[secret="userId,userId,userId,userId"]Private text[/secret]
[secret="1,7,15,22"]Private text diplayed only for user with id = 1, 7, 15 or 22 :)[/secret]

[secret="1,7,15,22"][/secret]

If empty, bbcode diplay list of user access :) =>

1bVzU.jpg


Code for callback:

PHP:
<?
 
    public static function parseSecret(array $tag, array $rendererStates, &$parentClass)
    {
        if (!empty($tag['option']) && $parentClass->parseMultipleOptions($tag['option']))
        { 
            $attributes = $parentClass->parseMultipleOptions($tag['option']); // Id's
            $userSecretMessage = $tag['children'][0]; // Message
 
            // On récupère l'id du visiteur courant
            $visitor = XenForo_Visitor::getInstance();
                $idMembreCourant = $visitor['user_id'];
 
            // ici on a un tableau avec tous les id des membres qui peuvent voir le message
            $TableauIds = explode(',',$attributes[0]);
 
            // On ajoute le membre courant aux membres pouvant voir le message
            // $TableauIds[idMembreCourant] = $idMembreCourant;
 
            // On explorer la liste des id
            foreach($TableauIds as $IdMembre)
            {
                // Si le membre courant fait partie de la liste on lui donne l'autorisation de voir le message
                if($IdMembre == $idMembreCourant)
                    { $secretAccess = True; }
 
                // On récupére le pseudo lié à chaque id on les stoque dans un tableau
                $user = XenForo_Model::create('XenForo_Model_User')->getUserById($IdMembre);
                $listeDesPseudo[] = $user['username'];
            }
 
            if($secretAccess == True)
            {
                if(isset($attributes[0]) AND empty($userSecretMessage) AND $secretAccess == True)
                {
                  $test = implode(", ", $listeDesPseudo);
 
                  return ' Seul les utilisateurs suivants <u><b>pourront voir</b></u> ce message secret :<br />' . $test . '.';
                }
                elseif($secretAccess == True)
                {
                    return $userSecretMessage;
                }
            }
        }
    }
 
Hello, I created a bbcode to simulate a dice roll.

PHP:
<?
    public static function bbcodeDes(array $tag, array $rendererStates, &$parentClass)
    {
            $nombreFaces = intval($tag['children'][0]); // Convert String to Int
 
            if($nombreFaces == 0 OR $nombreFaces == 1 OR $nombreFaces == null)
            {
                $nombreFaces = 6;
            }
 
            $result = rand(1, $nombreFaces);
            return $result;
    }

Example :

(Create message)
1bVrD.jpg


I would like => After Creation => (edition) =>

1bVsu.jpg


How can execute a bbcode treatment only once please ?
You would have to create a separate addon that "rolls" the dice and provides you with some type of ID. And statically call that upon every load.
 
A thing to remember: from a bbcode callback, you can't know
> the id of the post/thread
> the author of the post

If you want to get access those information you will need to use a different way than bbcode. You can extend the 'XenForo_Model_Post' model and use some regex here. But as King Kovifor said, you will need to have a fixed unique ID, so regex don't seem to be a good solution. You will certainly need to modify the content of the message before it is sent and saved inside the database. At this point, you will need:
> to create a fixed unique ID
> to get the result of the random dices roll
> to associate the ID&Result with the postidt (I know there is a way to get the postid after the message is send (no postid then) and before it is saved in the db (with a postid)
> to save it inside the database
Traditional way: 1 query to send BUT many queries after to read => not a good solution​
Simplecache: no query but if you often use roll, I'm not sure the simplecache can handle this​
=> may be not the good way to do it​
An other way would be to may to only create a code with the the fixed uniqueid, the result, and the postid and try to hide them in that code so users can't cheat (and why not add the posterid to make that code more complex and to make another check). Then you can use the 'XenForo_Model_Post' model to decode that code.​
Good luck !^^
 
King Kovifor updated Custom BB Code Manager with a new update entry:

v1.3 is released!

Thanks to the wonderful contributions of Cédric (cclaerhout) v1.3 is now available and ready for your consumption. This update is 100% his doing, and it works marvelously. I'd like to thank him for the hard work and time spent on this!

So, without further ado, I give you the changes:
  • EDITOR INTEGRATION!With 1.3, you are now able to add buttons to the TinyMCE editor with either CSS or uploading images. He provides a great interface for this!
  • TinyMCE Button Management
    You'll...

Read the rest of this update entry...
 
Server Error

Mysqli prepare error: Unknown column 'hasButton' in 'field list'
  1. Zend_Db_Statement_Mysqli->_prepare() in Zend/Db/Statement.php at line 115
  2. Zend_Db_Statement->__construct() in Zend/Db/Adapter/Mysqli.php at line 381
  3. Zend_Db_Adapter_Mysqli->prepare() in Zend/Db/Adapter/Abstract.php at line 478
  4. Zend_Db_Adapter_Abstract->query() in XenForo/Model.php at line 218
  5. XenForo_Model->fetchAllKeyed() in KingK/BbCodeManager/Model/CustomBbCode.php at line 112
  6. KingK_BbCodeManager_Model_CustomBbCode->getBbCodesWithButton() in KingK/BbCodeManager/ControllerAdmin/CustomButtons.php at line 29
  7. KingK_BbCodeManager_ControllerAdmin_CustomButtons->EditorConfig() in KingK/BbCodeManager/ControllerAdmin/CustomButtons.php at line 17
  8. KingK_BbCodeManager_ControllerAdmin_CustomButtons->actionEditorConfigltr() in XenForo/FrontController.php at line 310
  9. XenForo_FrontController->dispatch() in XenForo/FrontController.php at line 132
  10. XenForo_FrontController->run() in /home/xxxx/public_html/admin.php at line 13
 
Oh boy, sorry for the messages but it seems that I can't disable custom bb codes:

Mysqli prepare error: Table 'database_vt.kingk_bbcm_buttons' doesn't exist
  1. Zend_Db_Statement_Mysqli->_prepare() in Zend/Db/Statement.php at line 115
  2. Zend_Db_Statement->__construct() in Zend/Db/Adapter/Mysqli.php at line 381
  3. Zend_Db_Adapter_Mysqli->prepare() in Zend/Db/Adapter/Abstract.php at line 478
  4. Zend_Db_Adapter_Abstract->query() in XenForo/Model.php at line 218
  5. XenForo_Model->fetchAllKeyed() in KingK/BbCodeManager/Model/CustomButtons.php at line 38
  6. KingK_BbCodeManager_Model_CustomButtons->getAllConfig() in KingK/BbCodeManager/ControllerAdmin/CustomBbCodes.php at line 406
  7. KingK_BbCodeManager_ControllerAdmin_CustomBbCodes->_UpdateConfigsAfterEnableOrDisable() in KingK/BbCodeManager/ControllerAdmin/CustomBbCodes.php at line 381
  8. KingK_BbCodeManager_ControllerAdmin_CustomBbCodes->_enableDisable() in KingK/BbCodeManager/ControllerAdmin/CustomBbCodes.php at line 75
  9. KingK_BbCodeManager_ControllerAdmin_CustomBbCodes->actionDisable() in XenForo/FrontController.php at line 310
  10. XenForo_FrontController->dispatch() in XenForo/FrontController.php at line 132
  11. XenForo_FrontController->run() in /home/user/public_html/admin.php at line 13
 
Server Error

Mysqli prepare error: Unknown column 'hasButton' in 'field list'
  1. Zend_Db_Statement_Mysqli->_prepare() in Zend/Db/Statement.php at line 115
  2. Zend_Db_Statement->__construct() in Zend/Db/Adapter/Mysqli.php at line 381
  3. Zend_Db_Adapter_Mysqli->prepare() in Zend/Db/Adapter/Abstract.php at line 478
  4. Zend_Db_Adapter_Abstract->query() in XenForo/Model.php at line 218
  5. XenForo_Model->fetchAllKeyed() in KingK/BbCodeManager/Model/CustomBbCode.php at line 112
  6. KingK_BbCodeManager_Model_CustomBbCode->getBbCodesWithButton() in KingK/BbCodeManager/ControllerAdmin/CustomButtons.php at line 29
  7. KingK_BbCodeManager_ControllerAdmin_CustomButtons->EditorConfig() in KingK/BbCodeManager/ControllerAdmin/CustomButtons.php at line 17
  8. KingK_BbCodeManager_ControllerAdmin_CustomButtons->actionEditorConfigltr() in XenForo/FrontController.php at line 310
  9. XenForo_FrontController->dispatch() in XenForo/FrontController.php at line 132
  10. XenForo_FrontController->run() in /home/xxxx/public_html/admin.php at line 13

Appears upgrades aren't happening correctly... Run the following Queries via PHP my admin:

Code:
CREATE TABLE IF NOT EXISTS `kingk_bbcm_buttons` (           
                            `config_id` INT(200) NOT NULL AUTO_INCREMENT,
                        `config_type` TINYTEXT NOT NULL,
                        `config_buttons_order` TEXT NOT NULL,
                        `config_buttons_full` MEDIUMTEXT NOT NULL,
                        PRIMARY KEY (`config_id`)
                    )
                            ENGINE = InnoDB CHARACTER SET utf8 COLLATE utf8_general_ci;"

Code:
INSERT INTO `kingk_bbcm_buttons` (`config_id`, `config_type`, `config_buttons_order`, `config_buttons_full`) VALUES (1, 'ltr', '', ''), (2, 'rtl', '', '');
Code:
ALTER TABLE kingk_bbcm ADD hasButton int(1) NOT NULL DEFAULT '0'
Code:
ALTER TABLE kingk_bbcm ADD button_has_usr int(1) NOT NULL DEFAULT '0'
Code:
ALTER TABLE kingk_bbcm ADD button_usr TEXT DEFAULT NULL
Code:
ALTER TABLE kingk_bbcm ADD killCmd int(1) NOT NULL DEFAULT '0'
Code:
ALTER TABLE kingk_bbcm ADD custCmd varchar(50) DEFAULT NULL
Code:
ALTER TABLE kingk_bbcm ADD imgMethod varchar(20) DEFAULT NULL
Code:
ALTER TABLE kingk_bbcm ADD buttonDesc TINYTEXT DEFAULT NULL
Code:
ALTER TABLE kingk_bbcm ADD tagOptions TINYTEXT DEFAULT NULL
Code:
ALTER TABLE kingk_bbcm ADD tagContent TINYTEXT DEFAULT NULL
 
Server Error

Mysqli prepare error: Unknown column 'hasButton' in 'field list'
  1. Zend_Db_Statement_Mysqli->_prepare() in Zend/Db/Statement.php at line 115
  2. Zend_Db_Statement->__construct() in Zend/Db/Adapter/Mysqli.php at line 381
  3. Zend_Db_Adapter_Mysqli->prepare() in Zend/Db/Adapter/Abstract.php at line 478
  4. Zend_Db_Adapter_Abstract->query() in XenForo/Model.php at line 218
  5. XenForo_Model->fetchAllKeyed() in KingK/BbCodeManager/Model/CustomBbCode.php at line 112
  6. KingK_BbCodeManager_Model_CustomBbCode->getBbCodesWithButton() in KingK/BbCodeManager/ControllerAdmin/CustomButtons.php at line 29
  7. KingK_BbCodeManager_ControllerAdmin_CustomButtons->EditorConfig() in KingK/BbCodeManager/ControllerAdmin/CustomButtons.php at line 17
  8. KingK_BbCodeManager_ControllerAdmin_CustomButtons->actionEditorConfigltr() in XenForo/FrontController.php at line 310
  9. XenForo_FrontController->dispatch() in XenForo/FrontController.php at line 132
  10. XenForo_FrontController->run() in /home/xxxx/public_html/admin.php at line 13

Fixed, please update again. :(
 
Top Bottom