51 (edited by jacobswell 2004-07-12 12:56)

Re: punBB bbcode button MOD 1.0 released

http://jacobswell.nared.net/upload/bbcodeMOD1.0.2.rar

Maciek's code: version 1.0.2.

52 (edited by lebel 2004-07-21 07:46)

Re: punBB bbcode button MOD 1.0 released

For smileys only, i make another script more easy ...
the only thing is to add and remove some lines in post.php

AFTER
require $pun_root.'include/common.php';
PASTE
require $pun_root.'include/parser.php';


REMOVE ALL OTHER LINES WITH
require $pun_root.'include/parser.php';


AFTER
    if (!$cookie['is_guest'])
        $focus_element = (isset($_GET['fid'])) ? 'req_subject' : 'req_message';
    else
        $focus_element = 'req_username';

    require $pun_root.'header.php';

    $cur_index = 1;

[/b]ADD[/b]
<?
function pun_smileys($smiley_img, $smiley_text){
    $data="\n\n<table cellspacing=\"1\" cellpadding=\"3\" align=\"center\">\n";
    for ($i=0; $i<count($smiley_text); $i++){
        if ($j==0) $data.="<tr>";
        $data.="<td align=\"center\"><img src=\"img/smilies/" . $smiley_img[$i] . "\" alt=\"" . $smiley_text[$i] . "\" onclick=\"insertsmileys('" . $smiley_text[$i] . "')\"></td>";
        if (($j==2) || ($i==count($smiley_text))){
            $data.="</tr>\n";
            $j=0;
        }else{   
            $j++;
        }
    }
    $data.="</table>\n";
    return $data;
}
?>

<script language="JavaScript" type="text/JavaScript">
function insertsmileys(text) {
    var txtarea = document.getElementById("req_message");
   
    text = ' ' + text + ' ';
    if (txtarea.createTextRange && txtarea.caretPos) {
        var caretPos = txtarea.caretPos;
        caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? caretPos.text + text + ' ' : caretPos.text + text;
        txtarea.focus();
    } else {
        txtarea.value  += text;
        txtarea.focus();
    }
}
</script>


BEFORE
<a href="help.php#bbcode" target="_blank"><?php echo $lang_common['BBCode'] ?></a>: <?php echo ($pun_config['p_message_bbcode'] == '1') ? $lang_common['on'] : $lang_common['off']; ?>  <br>
ADD
<?php echo pun_smileys($smiley_img, $smiley_text);?>

53

Re: punBB bbcode button MOD 1.0 released

again more easy the bbcode button

modify post.php

BEFORE
<table class="punspacer" cellspacing="1" cellpadding="4">
    <tr>
        <td><b><a href="index.php"><?php echo pun_htmlspecialchars($pun_config['o_board_title']) ?></a> / <?php echo $forum ?><?php if (isset($subject)) echo ' / '.pun_htmlspecialchars($subject) ?></b></td>
    </tr>
</table>

ADD
function button_bbcode(){
$button_bbcode=array('b', 'i', 'u', 'url', 'img', 'quote');
    $data="\n\n<table cellspacing=\"1\" cellpadding=\"3\">\n<tr>\n";
    for ($i=0; $i<count($button_bbcode); $i++){
        $value=$button_bbcode[$i];
        $data.="<td align=\"center\"><input type=\"button\" class=\"punbutton\" value=\"" . strtoupper($value) . "\" onClick=\"Javascript:insert_bbcode('[$value]','[/$value]');\"></td>";
    }
    $data.="</tr>\n</table>\n";
    return $data;
}


ADD the javascript function
function insert_bbcode(bbopen,bbclose){
    var txtarea = document.getElementById("req_message");
    theSelection = document.selection.createRange().text;
    if (!theSelection) {
        txtarea.value += typeformat = bbopen + bbclose;
        txtarea.focus();
        return;
    }else{
        document.selection.createRange().text = bbopen + theSelection + bbclose;
        txtarea.focus();
        theSelection = '';
        return;
    }
}       


BEFORE
<textarea name="req_message" rows="20" cols="70" tabindex="<?php echo $cur_index++ ?>">

ADD
<? echo button_bbcode();?>



modify your CSS template file *.css
ADD
.punbutton { border:1px solid #B8B8B8; background-color: #FFF; font-size: 11px; font-family: verdana, helvetica, sans-serif; vertical-align: middle; padding:2px; font-weight: bold; }

the same button css than jacobswell