/*
HTML2BBCODE
HTML kodunu BBCODE etiketlerine cevirir
@Yns - http://yns.zaxaz.com
*/
class html2bbcode {
/* Replacer Function */
function getReady($text) {
$text = preg_replace("||i","[B]",$text);
$text = preg_replace("||i","[/B]",$text);
$text = preg_replace("||i","[B]",$text);
$text = preg_replace("||i","[/B]",$text);
$text = preg_replace("||i","[I]",$text);
$text = preg_replace("||i","[/I]",$text);
$text = preg_replace("||i","[S]",$text);
$text = preg_replace("||i","[/S]",$text);
$text = preg_replace("||i","[H1]",$text);
$text = preg_replace("|
|i","[/H1]",$text);
$text = preg_replace("||i","[H2]",$text);
$text = preg_replace("|
|i","[/H2]",$text);
$text = preg_replace("||i","[H3]",$text);
$text = preg_replace("|
|i","[/H3]",$text);
$text = preg_replace("||i","[H4]",$text);
$text = preg_replace("|
|i","[/H4]",$text);
$text = preg_replace("||i","[H5]",$text);
$text = preg_replace("|
|i","[/H5]",$text);
$text = preg_replace("||i","[H6]",$text);
$text = preg_replace("|
|i","[/H6]",$text);
$text = preg_replace("||i","[SUP]",$text);
$text = preg_replace("||i","[/SUP]",$text);
$text = preg_replace("||i","[SUB]",$text);
$text = preg_replace("||i","[/SUB]",$text);
$text = preg_replace("||i","[CODE]",$text);
$text = preg_replace("||i","[/CODE]",$text);
$text = preg_replace("||i","[PRE]",$text);
$text = preg_replace("||i","[/PRE]",$text);
$text = preg_replace("||i","[QUOTE]",$text);
$text = preg_replace("||i","[/QUOTE]",$text);
$text = preg_replace("||","[LEFT]",$text);
$text = preg_replace("|
|i","[/LEFT]",$text);
$text = preg_replace("||i","[RIGHT]",$text);
$text = preg_replace("|
|i","[/RIGHT]",$text);
$text = preg_replace("|i|","[CENTER]",$text);
$text = preg_replace("|
|i","[/CENTER]",$text);
$text = preg_replace("||i","[JUSTIFY]",$text);
$text = preg_replace("|
|i","[/JUSTIFY]",$text);
$text = preg_replace("||i","[LIST]",$text);
$text = preg_replace("|
|i","[/LIST]",$text);
$text = preg_replace("||i","[LIST1]",$text);
$text = preg_replace("|
|i","[/LIST1]",$text);
/* Define attributes for supported bb-code tags */
$urlATR = preg_match_all("||iU",$text,$returnText);
/* $returnText[1] = title value */
for( $i=0; $i < count($returnText[1]); $i++ ) {
$ad = array();
if(!empty($returnText[1][$i])) {
//$text = preg_replace("||i","[URL HREF=\"$1\"]$3[/URL]",$text);
$add[0] = " TITLE=\"\$2\"";
$add[1] = 'title=\"([^\"]*)\';
}
else {
$add[0] = "";
$add[1] = "";
}
$text = preg_replace("|(.*?)|i","[URL HREF=\"$1\" $add[0]]$3[/URL]",$text);
}
echo $text;
}
}
$x = new html2bbcode;
$text = ' s s ehe
ehe eheohe eaheh';
$x->getReady($text);
?>