Thread: Error, Forum
View Single Post
  #4  
Old 22nd July 2009, 11:01
sammygo sammygo is offline
Senior Member
 
Join Date: May 2008
P2P
Posts: 141
Default
---------------------------------------------
New textbbcode function
---------------------------------------------
add this inside format_comment function
Code:
//[align=(center|left|right|justify)]text[/align]
$s = preg_replace("/\[align=([a-zA-Z]+)\]((\s|.)+?)\[\/align\]/i","<div style=\"text-align:\\1\">\\2</div>", $s); 
//[s]strike[/s]
$s = preg_replace("/\[s\]((\s|.)+?)\[\/s\]/i", "<s>\\1</s>", $s);
//[mail]mail[/mail]
$s = preg_replace("/\[mail\]((\s|.)+?)\[\/mail\]/i","<a href=\"mailto:\\1\" targe=\"_blank\">\\1</a>", $s);
The arhive is for this mod ^ scroll down and download it !
---------------------------------------------
Textbbcode function
---------------------------------------------
Don't forget to remove the space from java script ie.
Code:
 javascript
Replace your function with this in global.php
Code:
// Credits: original creator; improvements by t.bz team
function textbbcode($form,$name,$content="") {
?>

<script language=javascript>
function insertAtCursor(myField, myValue) {
//IE support
  if (document.selection) {
    myField.focus();
    sel = document.selection.createRange();
    sel.text = myValue;
  }

//MOZILLA/NETSCAPE support
  else if (myField.selectionStart || myField.selectionStart == '0') {
    var startPos = myField.selectionStart;
    var endPos = myField.selectionEnd;
    myField.value = myField.value.substring(0, startPos) + myValue + myField.value.substring(endPos, myField.value.length);
    myField.selectionEnd = startPos + myValue.length;
  } else {
    myField.value += myValue;
  }
  myField.focus();
}

// calling the function
function SmileIT(smile,form,text){
    insertAtCursor(document.forms[form].elements[text], smile)
}

function PopMoreSmiles(form,name) {
         link='moresmiles.php?form='+form+'&text='+name
         newWin=window.open(link,'moresmile','height=500,width=450,resizable=no,scrollbars=yes');
         if (window.focus) {newWin.focus()}
}

function PopMoreTags(form,name) {
         link='moretags.php?form='+form+'&text='+name
         newWin=window.open(link,'moresmile','height=500,width=775,resizable=no,scrollbars=yes');
         if (window.focus) {newWin.focus()}
}


function BBTag(tag,s,text,form){
  var df  = document.forms[form].elements[s];
  var ele = document.forms[form].elements[text];
  var tval;
  var ttag;
  switch(tag) {
    case '<<<@!1!@>>>";
            if(df.value == "QUOTE ") {
              tval = "QUOTE*";
              ttag  = "[quote]";
            }
            break;
    case '[img]':
            tval = "IMG ";
            ttag = "[/img]";
            if(df.value == "IMG ") {
              tval = "IMG*";
              ttag  = "[img]";
            }
            break;

    case '':
tval = "URL ";
ttag = "";
            if(df.value == "URL ") {
              tval = "URL*";
              ttag  = "[url]";
            }
            break;

    case '[*]':
            tval= "List ";
                        if(df.value == "List ") ttag  = "[*]";
            break;

            insertAtCursor(ele, tag);
            df.elements[s].value = tval;
            break;

    case '[hr]':
                        tval= "Hr ";
                        if(df.value =="HR "){
                            ttag="[HR]";
            }
                        insertAtCursor(ele,tag);
            df.elements[s].value=tval;
            break;

    case '
': tval= "Center"; ttag= "
"; if(df.value == "Center "){ tval = "Center* "; ttag="[center]"; } break; case '': tval = "B "; ttag = ""; if(df.value == "B ") { tval = "B*"; ttag = "[b]"; } break; case '': tval = "I "; ttag = ""; if(df.value == "I ") { tval = "I*"; ttag = "[i]"; } break; case '': tval = "U "; ttag = ""; if(df.value == "U ") { tval = "U*"; ttag = "[u]"; } break; } if(tval!="") df.value = tval; if(ttag!="") insertAtCursor(ele, ttag); } </script> <table width="100%" style='margin: 3px' cellpadding="0" cellspacing="0"> <tr> <td class=embedded colspan=2> <table cellpadding="2" cellspacing="1"> <tr> <td class=embedded><input style="font-weight: bold;" type="button" name="bold" value="B " onclick="java script: BBTag('[b]','bold','<? echo $name; ?>','<? echo $form; ?>')" /></td> <td class=embedded><input style="font-style: italic;" type="button" name="italic" value="I " onclick="java script: BBTag('[i]','italic','<? echo $name; ?>','<? echo $form; ?>')" /></td> <td class=embedded><input style="text-decoration: underline;" type="button" name="underline" value="U " onclick="java script: BBTag('[u]','underline','<? echo $name; ?>','<? echo $form; ?>')" /></td> <td class=embedded><input type="button" name="li" value="List " onclick="java script: BBTag('[*]','li','<? echo $name; ?>','<? echo $form; ?>')" /></td> <td class=embedded><input type="button" name="quote" value="QUOTE " onclick="java script: BBTag('[quote]','quote','<? echo $name; ?>','<? echo $form; ?>')" /></td> <td class=embedded><input type="button" name="url" value="URL " onclick="java script: BBTag('[url]','url','<? echo $name; ?>','<? echo $form; ?>')" /></td> <td class=embedded><input type="button" name="img" value="IMG " onclick="java script: BBTag('[img]','img','<? echo $name; ?>','<? echo $form; ?>')" /></td> <td class=embedded><input type="button" name="hr" value="HR " onclick="java script: BBTag('[hr]','hr','<? echo $name; ?>','<? echo $form; ?>')" /></td> <td class=embedded><input type="button" name="center" value="Center " onclick="java script: BBTag('[center]','center','<? echo $name; ?>','<? echo $form; ?>')" /></td> <td class=embedded>&nbsp;<a href="java script: PopMoreTags('<? echo $form; ?>','<? echo $name; ?>')"><? echo MORE_TAGS;?></a></td> </tr> </table> </td> </tr> <tr> <td class=embedded> <textarea name="<?=$name?>" rows="15" cols="80"><?=$content?></textarea> </td> <td class=embedded> <table cellpadding="3" cellspacing="1"> <? global $smilies, $BASEURL; while ((list($code, $url) = each($smilies)) && $count<20) { if ($count % 4==0) print("<tr>"); print("\n<td class=embedded style='padding: 3px; margin: 2px'><a href=\"java script: SmileIT('".str_replace("'","\'",$code)."','$form','$name')\"><img border=0 src=".$GLOBALS['pic_base_url']."/smilies/".$url."></a></td>"); $count++; if ($count % 4==0) print("</tr>"); } ?> </table> <center><a href="java script: PopMoreSmiles('<? echo $form; ?>','<? echo $name; ?>')"><? echo MORE_SMILES;?></a></center> </td> </tr> </table> <? }
Attached Files
File Type: rar bbcode.rar (12.7 KB, 12 views)
Reply With Quote