Random BBCODE

Started by Nibogo, June 05, 2008, 02:42:36 AM

Previous topic - Next topic

Nibogo


Random BBCODE v1.2.1 - NIBOGO
Enables [random][/random] bbcode to randomly select one or more from your random tags.





Important Info:
o This Mod was created by SMFPacks.com - The #1 Website for the Customization of your SMF.

SMFPacks.com Provides Other Great Packages:
- Reason for Editing Mod.
- Yet Another Global Announcements Mod.
- SMF Social Groups.
- SMF Links Directory.
- SMF Downloads Directory.
- SMF Dynamic Directory.
- Advanced Topic Prefix Mod.
- Advanced Invitations System.
- Move Topic Notification.
- PM to New Members.
- Permissions Info.
- Next Post Level.
- Karma Buttons.
- SMF Multi Quote.
- Attachments in Topics.
- and much more visit us on SMFPacks.com

Original Author:
- karlbenson

Previous Developer:
- Sleepy Arcade

Developer:
- NIBOGO

Features:
o BBCode Button

Compatibility:
- 1.1.X
- 2.0

Special Thanks:
- karlbenson (Original Author of the Mod)
- Sleepy Arcade (Previous Developer)




Changelog:

1.0 - 17th August 2007
o Initial release

1.0 - 23rd November 2007
o Added English-utf8 support
o Added English_British/English_British-utf8 support

Apllicmz

Nice work

uPDATE linguage portuguese and brazlian

<file name="$themedir/languages/Modifications.portuguese.php" error="skip">
<operation>
<search position="after"><![CDATA[?>]]></search>
<add><![CDATA[
$txt['random_desc'] = 'Random BBCodigo';
]]></add>
</operation>
</file>
<file name="$themedir/languages/Modifications.brazilian.php" error="skip">
<operation>
<search position="after"><![CDATA[?>]]></search>
<add><![CDATA[
$txt['random_desc'] = 'Random BBCodigo';
]]></add>
</operation>
</file>



SA™

http://samods.github.io/SAChatBar/

Xbox Live: smokerthecheese 360 or xbone
My Work
Piano Movers / Delivery service
QuoteMy allies are dead.
I'm 'bout to be too.
Zombies are chasing me.
F*** it, I'm screwed -___-

GawdSpeed

Parse error: syntax error, unexpected ',' in /home/taaf/public_html/Sources/Subs.php on line 4051
No problems with installation and I end up with this  :'(

SA™

can you post up your subs.php
http://samods.github.io/SAChatBar/

Xbox Live: smokerthecheese 360 or xbone
My Work
Piano Movers / Delivery service
QuoteMy allies are dead.
I'm 'bout to be too.
Zombies are chasing me.
F*** it, I'm screwed -___-

Bazil Greyson

Quote from: wdm2005 on August 18, 2008, 06:00:19 PM
can you post up your subs.php

I can.. since I am having the same troubles. I have singled out the section of code by removing chunks until my site would load. Here is where I have found the error to exist. To be more specific, it exists between the first array( and the last ),


// Creates an image/text button
function create_button($name, $alt, $label = '', $custom = '')
{
global $settings, $txt, $context;

if (!$settings['use_image_buttons'])
return $txt[$alt];
elseif (!empty($settings['use_buttons']))
return '<img src="' . $settings['images_url'] . '/buttons/' . $name . '" alt="' . $txt[$alt] . '" ' . $custom . ' />' . ($label != '' ? '<b>' . $txt[$label] . '</b>' : '');
else
return '<img src="' . $settings['images_url'] . '/' . $context['user']['language'] . '/' . $name . '" alt="' . $txt[$alt] . '" ' . $custom . ' />';
}

array(
'tag' => 'random',
'type' => 'unparsed_content',
'content' => '$1',
'validate' => create_function('&$tag, &$data, $disabled', '
$data = strtr($data, array(\'<br />\' => \'\'));
$data = random_bbcode($data);
'),
),
array(
'tag' => 'random',
'type' => 'unparsed_equals_content',
'content' => '$1',
'disallow_children' => array('email', 'ftp', 'url', 'iurl'),
'disabled_after' => ' ($1)',
'validate' => create_function('&$tag, &$data, $disabled', '
$data[1] = strtr($data[1], array(\'<br />\' => \'\'));
$data[0] = random_bbcode($data);
'),
),

//random funtion

SA™

if you can post up the whole file with the code inpolace it will be much easyer to see wahts going on
http://samods.github.io/SAChatBar/

Xbox Live: smokerthecheese 360 or xbone
My Work
Piano Movers / Delivery service
QuoteMy allies are dead.
I'm 'bout to be too.
Zombies are chasing me.
F*** it, I'm screwed -___-

Bazil Greyson

Quote from: wdm2005 on November 13, 2008, 04:39:06 PM
if you can post up the whole file with the code inpolace it will be much easyer to see wahts going on

Here it is, as a .txt attachment. Just cut and pasting the code for my Subs.php file was too many characters for the message to handle.

If you would just like the code concerning your mod, here that is in a code snippit.

// Creates an image/text button
function create_button($name, $alt, $label = '', $custom = '')
{
   global $settings, $txt, $context;

   if (!$settings['use_image_buttons'])
      return $txt[$alt];
   elseif (!empty($settings['use_buttons']))
      return '<img src="' . $settings['images_url'] . '/buttons/' . $name . '" alt="' . $txt[$alt] . '" ' . $custom . ' />' . ($label != '' ? '<b>' . $txt[$label] . '</b>' : '');
   else
      return '<img src="' . $settings['images_url'] . '/' . $context['user']['language'] . '/' . $name . '" alt="' . $txt[$alt] . '" ' . $custom . ' />';
}

         array(
            'tag' => 'random',
            'type' => 'unparsed_content',
            'content' => '$1',
            'validate' => create_function('&$tag, &$data, $disabled', '
                  $data = strtr($data, array(\'<br />\' => \'\'));
                  $data = random_bbcode($data);
               '),
         ),
         array(
            'tag' => 'random',
            'type' => 'unparsed_equals_content',
            'content' => '$1',
            'disallow_children' => array('email', 'ftp', 'url', 'iurl'),
            'disabled_after' => ' ($1)',
            'validate' => create_function('&$tag, &$data, $disabled', '
                  $data[1] = strtr($data[1], array(\'<br />\' => \'\'));
                  $data[0] = random_bbcode($data);
               '),
         ),

//random funtion
function random_bbcode($data) {

//change these if you wish to change how the bbcode should be delimitered
    $delimiter = '|';

//and then how the selected options are separated afterwards
$separator = ' ';


//if its just plain tagthen make into an array
if(!is_array($data))
$data = array($data, '1');


//validate the random must be a number1-9
$data[1] = (int) $data[1];

//random figure must be between 1-9
$data[1] = (($data[1] < 9) && ($data[1] > 0)) ? $data[1] : 1 ;


//get out of doge if too short
if(strlen($data[0]) < 1 || (trim($data[0]) == $delimiter)) {
return;
}

//setup the options ready for you own random draw
$options = explode($delimiter, $data[0]);
$max = count($options);

//if wants to select more than the one of elements reduce the number
$data[1] = ($data[1] > $max) ? $max : $data[1];

//randomly select
$str = '';
for($i=1;$i<=$data[1];$i++) {
$sel = array_rand($options, 1);
$str .= $separator.$options[$sel];

//ensure we only ever get unique- never the same twice
unset($options[$sel]);
}
return trim($str);
}

SA™

http://samods.github.io/SAChatBar/

Xbox Live: smokerthecheese 360 or xbone
My Work
Piano Movers / Delivery service
QuoteMy allies are dead.
I'm 'bout to be too.
Zombies are chasing me.
F*** it, I'm screwed -___-

Bazil Greyson

Well, the site no longer crashes due to errors. However, the bbc code does nothing.

[random]One|Two|Three|Four[/random]

For example, just prints that exact message into the forum.

Also, does this work only for numbers 1-9, or will it work for a percentile? 1-100.

Bazil Greyson

Nevermind, works fine now! Thank you. Apparently the browser app I use to edit my files did not save properly the first time I replaced the subs file. This time I edited it by hand and re-uploaded it.

You rock good sir!

SA™

lol yeah that happens to me a lot  ;D
http://samods.github.io/SAChatBar/

Xbox Live: smokerthecheese 360 or xbone
My Work
Piano Movers / Delivery service
QuoteMy allies are dead.
I'm 'bout to be too.
Zombies are chasing me.
F*** it, I'm screwed -___-

Bugo

In file install.xml replace block:
<file name="$sourcedir/Subs.php">
<operation>
<search position="before" /><![CDATA[

with this:
<file name="$sourcedir/Subs.php">
<operation>
<search position="before"><![CDATA[



Jessica.

just saying, the link is wrong, should be http://custom.simplemachines.org/mods/index.php?mod=1247

links to mod=1233 in the first post
Testing Zone - SMF 2.0.7, default Curve
School & Chat - phpBB3, over 170 mods installed, official live forum

I use the latest version of Chrome

phpBB: Forum = a section; Board = whole site
SMF: Forum = whole site; Board = a section

luuuciano

I do not fully understand the mod description... wich tags are randomly selected??
No me agradan los foros que no te dejan borrar TU PROPIO usuario, como por ejemplo smfsimple.com.
E incluso te mandan emails no solicitados, de los cuales, quizá, no puedas escapar porque NO te dejan posibilidad a deshabilitarlos (a menos que NO te tengan en su lista negra).

Advertisement: