Jump to content

who wrote the custom BB codes?


scoob

Recommended Posts

i think i have a way to make a functional [auction][/auction] tag & display, but i'm not entirely sure i'm on the right track as i've never worked with IPB directly.

 

as i understand it, the BB codes are simply regex text replacements in the /sources/lib/post_parser.php file

 

now, i don't pretend to know regex very well, either - but whoever wrote the current set of hand input scripts should be able to manage this.

 

have the tag accept up to 40 (?) values (i know that it's possible to have almost 400 calls in an auction, but i think 40 covers any auctions we'll be posting...)

 

ie. [auction=-,-,1H,1S,X,-,2C][/auction]

 

have the replacement start with a static header:

 

<table border="0" style="border-collapse: collapse; text-align: center" bordercolor="#111111" width="250" cellspacing="0" cellpadding="0">
 <tr>
   <th width="25%" bgcolor="#CCCCCC">N</th>
   <th width="25%" bgcolor="#CCCCCC">W</th>
   <th width="25%" bgcolor="#CCCCCC">S</th>
   <th width="25%" bgcolor="#CCCCCC">E</th>
 </tr>

 

then for each set of 4 values:

 

<tr>
   <td bgcolor="#CCCCCC"></td>
   <td bgcolor="#CCCCCC"></td>
   <td bgcolor="#CCCCCC"></td>
   <td bgcolor="#CCCCCC"></td>
 </tr>

 

filling in the values accordingly - null values left null so that unused rows aren't visible in the post.

 

and then a simple </table> to finish it off.

 

i can't think of a use for {content} but it could just put off to the side for comments like the current BB codes do already i guess.

Link to comment
Share on other sites

I did. Problem is, in those codes definitions the number of parameters is fixed, so you would need several codes for different bid auctions.

OTOH, probably it can be done passing only one parameter, and parsing it, will think about it, no promises (for now).

Link to comment
Share on other sites

that implies [auction=-,-,1H,1S,X,-,2C,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,][/auction]

yuck!

well i assumed you write one of them fancy popup forms so we'd never actually see that bit :)

 

also 40's just a # i through out there, it might not be the best suited.

Link to comment
Share on other sites

yes, i suppose you would.

 

but i submit that the usefulness of being able to post clean sensible auctions without having to use a series of ....... or spaces to line everything up will outweigh the unsightliness of the BB code in the eyes of the forum majority.

 

i understand your work here is voluntary, Ger, so please don't think i'm unappreciative or anything :)

 

in fact, i may actually have someone that can whip up the actual code additions to post_parse.php (i think that's what it's called from what i recall of my research)

 

if they pull through i should know before the end of the weekend and provide you the code :D

Link to comment
Share on other sites

ok below is what they gave me - hope it makes sense to you!

 

Open sources/lib/post_parser.php

 

Find:

var $allow_unicode  = 1;

Add Below:

var $auc_values = array();

 

Find:

$txt = preg_replace( "#\[code\](.+?)\[/code\]#ies", "\$this->regex_code_tag('\\1')", $txt );

Add Below:

                       //---------------------------------
 	// Take a bash at [AUCTION]
 	//---------------------------------
 	
 	$txt = preg_replace( "#\[auction=(.+?)\]#ies", "\$this->regex_auction('\\1')", $txt );

 

Find:

$txt = preg_replace( "#<!--QuoteEnd-->(.+?)<!--QuoteEEnd-->#"                    , '[/QUOTE]'        , $txt );

Add Below:

//Auction
 	$txt = preg_replace ("#<!--AucStart-->(.+?)<!--AucEnd-->#ies","\$this->unconvert_auc('\\1')",$txt);

 

Find:

return '[HTML]'.$html.'[/HTML]';
 
}

Add Below:

function unconvert_auc($text="")
{
$this->auc_values=array();
$text=preg_replace("/<!--AucValue:(.+?)-->/ies","\$this->auc_value('\\1')",$text);
return "[AUCTION=".implode(",",$this->auc_values)."]";
}
function auc_value($val)
{

$this->auc_values[]=$val;
return '';
}

 

Find:

  return "<!--html-->{$wrap['START']}<!--html1-->$html<!--html2-->{$wrap['END']}<!--html3-->";
}

Add Below:

	/**************************************************/
// regex_auction: Auction Tag
//
/**************************************************/

function regex_auction($data="")
{
$array_data=explode(",",$data);
$return='<!--AucStart--><table border="0" style="border-collapse: collapse; text-align: center" bordercolor="#111111" width="250" cellspacing="0" cellpadding="0"><tr><th width="25%" bgcolor="#CCCCCC">N</th><th width="25%" bgcolor="#CCCCCC">W</th><th width="25%" bgcolor="#CCCCCC">S</th><th width="25%" bgcolor="#CCCCCC">E</th></tr>';
$inrow=0;
$dofirst=0;
for($i=0;isset($array_data[$i]);$i++)
{
       if ($inrow == 4) { $inrow=0; }
if($inrow == 0)
{
if($dofirst)
{
$return.="</tr>";
}
$dofirst=1;
$return.="<tr>";
}
$return.=" <td bgcolor=\"#CCCCCC\"><!--AucValue:{$array_data[$i]}-->{$array_data[$i]}</td>";
$inrow++;
}
$return.="</tr></table><!--AucEnd-->";
return $return;
}

 

Save & upload.

 

P.S. You just use [auction=1,2,3,4] etc, there is no [/auction] needed.

Link to comment
Share on other sites

  • 1 month later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...