BBcode testing No New Posts Tavern

Started by
moyack

0 Members and 1 Guest are viewing this topic.

BBcode testing
on: December 05, 2010, 09:35:27 AM

This is a test of all the BBcode features this board offers.

Bold text
Italic text
Underlined text
Striked text

Horizontal rule:


Glowing text
Shadowed text
Marquee text
 :) ;) :D ;D >:( :( :o 8) ??? ::) :P :-[ :-X :-\ :-* :'(

« Last Edit: December 20, 2010, 08:36:24 AM by moyack »



Re: BBcode testing
Reply #1 on: December 26, 2010, 08:17:25 PM

<?php
    
function regex_trigger_tag($code '')
    {
       
//$code_orig = base64_encode($code);
       
$code explode("\n"$code);

       
$lut_types = array(
          
'actions' => 'action.gif',
          
'ai' => 'ai.gif',
          
'animation' => 'animation.gif',
          
'camera' => 'camera.gif',
          
'cinematic' => 'camera.gif',
          
'conditions' => 'condition.gif',
          
'countdown' => 'timer.gif',
          
//'custom' => 'general.gif',
          
'destructible' => 'destructible.gif',
          
'dialog' => 'dialog.gif',
          
'else' => 'action.gif',
          
'environment' => 'environment.gif',
          
'events' => 'event.gif',
          
'for' => 'if.gif',
          
'game' => 'game.gif',
          
'hero' => 'hero.gif',
          
'if - conditions' => 'condition.gif',
          
'if' => 'if.gif',
          
'item' => 'item.gif',
          
'leaderboard' => 'quest.gif',
          
'loop' => 'action.gif',
          
//'map' => 'general.gif',
          
'melee' => 'melee.gif',
          
'multiboard' => 'quest.gif',
          
'player group' => 'playergroup.gif',
          
'player' => 'player.gif',
          
'quest' => 'quest.gif',
          
'selection' => 'selection',
          
'set' => 'set.gif',
          
'special' => 'animation.gif',
          
'then' => 'action.gif',
          
'time' => 'timer.gif',
          
//'trigger' => 'general.gif',
          
'unit group' => 'unitgroup.gif',
          
'unit' => 'unit.gif',
          
'visibility' => 'visibility.gif',
          
'wait' => 'wait.gif',
          
'--------' => 'comment.gif'
       
);

       
$image_default   'general.gif';
       
$image_cond   'if.gif';
       
$image_start   'start.gif';
       
$image_tee   'tree_tee.gif';
       
$image_vert   'tree_vert.gif';
       
$image_el   'tree_el.gif';
       
$image_blank   'tree_spacer.gif';

       
//$image_prefix   = $this->ipsclass->vars['img_url'] . '/trigger/';
       
$image_prefix 'images/';

       
// Start an output buffer to catch all printed lines
       // which happens to be a bit faster than concatenating onto a string.
       
ob_start();
       print 
'<!--trigcode-->';

       
// Loop through the lines
       
       
$type_count count($lut_types);
       
$is_start true;
       
$is_cond false;
       for (
$i 0$ic count($code); $i $ic$i++)
       {
          
// Get indentation depth (fast divide by 4)
          
$depth strspn($code[$i], ' ') >> 2;

          
// Check for an empty line
          
if (($line trim($code[$i])) == '')
          {
             continue;
          }

          
// Check for first line
          
if ($depth == && $is_start)
          {
             
// Print the image
             
print '<!--trigim--><img src="' $image_prefix $image_start '" alt="" /> <!--trigeim-->' htmlspecialchars($line) . "<br />\n";
             
$is_start false;
             continue;
          }

          
// Parse line type
          
$image = ($is_cond) ? $image_cond $image_default;
          
reset($lut_types);
          foreach (
$lut_types as $key => $value)
          {
             if (
$key == strtolower(substr($line0strlen($key))))
             {
                
// Found the correct line type
                
$image $value;

                
// Conditions block?
                
$is_cond = ($key == 'conditions' || $key == 'if - conditions');

                break;
             }
          }

          
// Print tree   
          
for ($j 0$j $depth$j++)
          {
             print 
'<!--trigind--><img src="' $image_prefix 'tree_spacer.gif" alt="" /><!--trigeind-->';
          }

          
// Print the image and code
          
print '<!--trigim--><img src="' $image_prefix $image '" alt="" /> <!--trigeim-->' htmlspecialchars($line) . "<br />\n";
       }

       print 
'<!--trigecode-->';

       
// Return contents of the output buffer
       
return ob_get_clean();
    }

    
// Parses trigger HTML back into code
    // By: PiRho (July 14, 2006)
    // terralith@yahoo.com

    
function regex_trigger_revert($code)
    {
       
// Replace tree/spacer images with spaces
       
$code preg_replace('#<!--trigind-->.*?<!--trigeind-->#''    '$code);

       
// Remove extra images
       
return preg_replace('#<!--trigim-->.*?<!--trigeim-->#'''str_replace('<br />'''$code));
    }

    
?>


 

Vivir aprendiendo.co - A place for learning stuff, in Spanish   Chaos Realm - The world of Game modders and wc3 addicts   Diplo, a gaming community   Power of Corruption, an altered melee featuring Naga and Demon. Play it now!!!   WC3JASS.com - The JASS Vault + vJASS and Zinc   Jetcraft - A Starcraft II mod   WormTastic Clan (wTc)   Warcraft RESOURCES Reforged: Modelos, mapas, proyectos y mas...