1 | <?php |
---|
2 | /*********************************************************************** |
---|
3 | |
---|
4 | Copyright (C) 2002-2005 Rickard Andersson (rickard@punbb.org) |
---|
5 | |
---|
6 | This file is part of PunBB. |
---|
7 | |
---|
8 | PunBB is free software; you can redistribute it and/or modify it |
---|
9 | under the terms of the GNU General Public License as published |
---|
10 | by the Free Software Foundation; either version 2 of the License, |
---|
11 | or (at your option) any later version. |
---|
12 | |
---|
13 | PunBB is distributed in the hope that it will be useful, but |
---|
14 | WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
16 | GNU General Public License for more details. |
---|
17 | |
---|
18 | You should have received a copy of the GNU General Public License |
---|
19 | along with this program; if not, write to the Free Software |
---|
20 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
---|
21 | MA 02111-1307 USA |
---|
22 | |
---|
23 | ************************************************************************/ |
---|
24 | |
---|
25 | |
---|
26 | if (!isset($bbcode_form)) |
---|
27 | $bbcode_form = 'post'; |
---|
28 | if (!isset($bbcode_field)) |
---|
29 | $bbcode_field = 'req_message'; |
---|
30 | |
---|
31 | ?> |
---|
32 | <script type="text/javascript"> |
---|
33 | <!-- |
---|
34 | function fonction() { |
---|
35 | element.onclick = insert_text('[font='+(this.value)+']','[/font]', 'false'); |
---|
36 | } |
---|
37 | |
---|
38 | function insert_text(open, close, isSmiley) |
---|
39 | { |
---|
40 | msgfield = (document.all) ? document.all.req_message : document.forms['<?php echo $bbcode_form ?>']['<?php echo $bbcode_field ?>']; |
---|
41 | |
---|
42 | // IE support |
---|
43 | if (document.selection && document.selection.createRange) |
---|
44 | { |
---|
45 | msgfield.focus(); |
---|
46 | sel = document.selection.createRange(); |
---|
47 | sel.text = open + sel.text + close; |
---|
48 | msgfield.focus(); |
---|
49 | } |
---|
50 | |
---|
51 | // Moz support |
---|
52 | else if (msgfield.selectionStart || msgfield.selectionStart == '0') |
---|
53 | { |
---|
54 | var startPos = msgfield.selectionStart; |
---|
55 | var endPos = msgfield.selectionEnd; |
---|
56 | |
---|
57 | msgfield.value = msgfield.value.substring(0, startPos) + open + msgfield.value.substring(startPos, endPos) + close + msgfield.value.substring(endPos, msgfield.value.length); |
---|
58 | if (isSmiley == 'true') { |
---|
59 | msgfield.selectionStart = msgfield.selectionEnd = endPos + open.length + close.length; |
---|
60 | } |
---|
61 | else { |
---|
62 | msgfield.selectionStart = startPos; |
---|
63 | msgfield.selectionEnd = endPos + open.length + close.length; |
---|
64 | } |
---|
65 | msgfield.focus(); |
---|
66 | } |
---|
67 | |
---|
68 | // Fallback support for other browsers |
---|
69 | else |
---|
70 | { |
---|
71 | msgfield.value += open + close; |
---|
72 | msgfield.focus(); |
---|
73 | } |
---|
74 | |
---|
75 | return; |
---|
76 | } |
---|
77 | --> |
---|
78 | </script> |
---|
79 | <div style="padding-top: 4px"> |
---|
80 | <input type="button" value=" B " name="B" onClick="insert_text('[b]','[/b]', 'false')" /> |
---|
81 | <input type="button" value=" I " name="I" onClick="insert_text('[i]','[/i]', 'false')" /> |
---|
82 | <input type="button" value=" U " name="U" onClick="insert_text('[u]','[/u]', 'false')" /> |
---|
83 | <input type="button" value="http://" name="Url" onClick="insert_text('[url]','[/url]', 'false')" /> |
---|
84 | <input type="button" value="Img" name="Img" onClick="insert_text('[img]','[/img]', 'false')" /> |
---|
85 | <input type="button" value="Code" name="Code" onClick="insert_text('[code]','[/code]', 'false')" /> |
---|
86 | <input type="button" value="Quote" name="Quote" onClick="insert_text('[quote]','[/quote]', 'false')" /> |
---|
87 | </div> |
---|
88 | <div style="padding-top: 4px"> |
---|
89 | <?php |
---|
90 | |
---|
91 | // Display the smiley set |
---|
92 | require_once PUN_ROOT.'include/parser.php'; |
---|
93 | |
---|
94 | $smiley_dups = array(); |
---|
95 | $num_smilies = count($smiley_text); |
---|
96 | for ($i = 0; $i < $num_smilies; ++$i) |
---|
97 | { |
---|
98 | // Is there a smiley at the current index? |
---|
99 | if (!isset($smiley_text[$i])) |
---|
100 | continue; |
---|
101 | |
---|
102 | if (!in_array($smiley_img[$i], $smiley_dups)) |
---|
103 | echo "\t\t\t\t\t\t\t".'<a href="javascript:insert_text(\''.$smiley_text[$i].'\', \'\', \'true\');"><img src="img/smilies/'.$smiley_img[$i].'" width="15" height="15" alt="'.$smiley_text[$i].'" /></a>'."\n"; |
---|
104 | |
---|
105 | $smiley_dups[] = $smiley_img[$i]; |
---|
106 | } |
---|
107 | |
---|
108 | ?> |
---|
109 | </div> |
---|