Subversion Repositories svnkaklik

Rev

Details | Last modification | View Log

Rev Author Line No. Line
6 kaklik 1
<?php
2
/*************************
3
  Coppermine Photo Gallery
4
  ************************
5
  Copyright (c) 2003-2005 Coppermine Dev Team
6
  v1.1 originaly written by Gregory DEMAR
7
 
8
  This program is free software; you can redistribute it and/or modify
9
  it under the terms of the GNU General Public License as published by
10
  the Free Software Foundation; either version 2 of the License, or
11
  (at your option) any later version.
12
  ********************************************
13
  Coppermine version: 1.3.3
14
  $Source: /cvsroot/coppermine/stable/include/smilies.inc.php,v $
15
  $Revision: 1.6 $
16
  $Author: gaugau $
17
  $Date: 2005/04/19 03:17:11 $
18
**********************************************/
19
 
20
// ------------------------------------------------------------------------- //
21
// CODE IN THIS MODULE IS TAKEN FROM phpBB                                   //
22
// ------------------------------------------------------------------------- //
23
 
24
define('SMILIES_PHP', true);
25
function get_smilies_table1()
26
{
27
    global $lang_smilies_inc_php;
28
 
29
    return array(
30
        array(':!:', 'icon_exclaim.gif', $lang_smilies_inc_php['Exclamation']),
31
        array(':?:', 'icon_question.gif', $lang_smilies_inc_php['Question']),
32
        array(':D', 'icon_biggrin.gif', $lang_smilies_inc_php['Very Happy']),
33
        array(':-D', 'icon_biggrin.gif', $lang_smilies_inc_php['Very Happy']),
34
        array(':grin:', 'icon_biggrin.gif', $lang_smilies_inc_php['Very Happy']),
35
        array(':)', 'icon_smile.gif', $lang_smilies_inc_php['Smile']),
36
        array(':-)', 'icon_smile.gif', $lang_smilies_inc_php['Smile']),
37
        array(':smile:', 'icon_smile.gif', $lang_smilies_inc_php['Smile']),
38
        array(':(', 'icon_sad.gif', $lang_smilies_inc_php['Sad']),
39
        array(':-(', 'icon_sad.gif', $lang_smilies_inc_php['Sad']),
40
        array(':sad:', 'icon_sad.gif', $lang_smilies_inc_php['Sad']),
41
        array(':o', 'icon_surprised.gif', $lang_smilies_inc_php['Surprised']),
42
        array(':-o', 'icon_surprised.gif', $lang_smilies_inc_php['Surprised']),
43
        array(':eek:', 'icon_surprised.gif', $lang_smilies_inc_php['Surprised']),
44
        array(':shock:', 'icon_eek.gif', $lang_smilies_inc_php['Shocked']),
45
        array(':?', 'icon_confused.gif', $lang_smilies_inc_php['Confused']),
46
        array(':-?', 'icon_confused.gif', $lang_smilies_inc_php['Confused']),
47
        array(':???:', 'icon_confused.gif', $lang_smilies_inc_php['Confused']),
48
        array('8)', 'icon_cool.gif', $lang_smilies_inc_php['Cool']),
49
        array('8-)', 'icon_cool.gif', $lang_smilies_inc_php['Cool']),
50
        array(':cool:', 'icon_cool.gif', $lang_smilies_inc_php['Cool']),
51
        array(':lol:', 'icon_lol.gif', $lang_smilies_inc_php['Laughing']),
52
        array(':x', 'icon_mad.gif', $lang_smilies_inc_php['Mad']),
53
        array(':-x', 'icon_mad.gif', $lang_smilies_inc_php['Mad']),
54
        array(':mad:', 'icon_mad.gif', $lang_smilies_inc_php['Mad']),
55
        array(':P', 'icon_razz.gif', $lang_smilies_inc_php['Razz']),
56
        array(':-P', 'icon_razz.gif', $lang_smilies_inc_php['Razz']),
57
        array(':razz:', 'icon_razz.gif', $lang_smilies_inc_php['Razz']),
58
        array(':oops:', 'icon_redface.gif', $lang_smilies_inc_php['Embarassed']),
59
        array(':cry:', 'icon_cry.gif', $lang_smilies_inc_php['Crying or Very sad']),
60
        array(':evil:', 'icon_evil.gif', $lang_smilies_inc_php['Evil or Very Mad']),
61
        array(':twisted:', 'icon_twisted.gif', $lang_smilies_inc_php['Twisted Evil']),
62
        array(':roll:', 'icon_rolleyes.gif', $lang_smilies_inc_php['Rolling Eyes']),
63
        array(':wink:', 'icon_wink.gif', $lang_smilies_inc_php['Wink']),
64
        array(';)', 'icon_wink.gif', $lang_smilies_inc_php['Wink']),
65
        array(';-)', 'icon_wink.gif', $lang_smilies_inc_php['Wink']),
66
        array(':idea:', 'icon_idea.gif', $lang_smilies_inc_php['Idea']),
67
        array(':arrow:', 'icon_arrow.gif', $lang_smilies_inc_php['Arrow']),
68
        array(':|', 'icon_neutral.gif', $lang_smilies_inc_php['Neutral']),
69
        array(':-|', 'icon_neutral.gif', $lang_smilies_inc_php['Neutral']),
70
        array(':neutral:', 'icon_neutral.gif', $lang_smilies_inc_php['Neutral']),
71
        array(':mrgreen:', 'icon_mrgreen.gif', $lang_smilies_inc_php['Mr. Green'])
72
        );
73
}
74
 
75
function get_smilies_table2()
76
{
77
    global $lang_smilies_inc_php;
78
 
79
    return array(
80
        array(':lol:', 'icon_lol.gif', $lang_smilies_inc_php['Laughing']),
81
        array(':-P', 'icon_razz.gif', $lang_smilies_inc_php['Razz']),
82
        array(':-D', 'icon_biggrin.gif', $lang_smilies_inc_php['Very Happy']),
83
        array(':-)', 'icon_smile.gif', $lang_smilies_inc_php['Smile']),
84
        array(':-|', 'icon_neutral.gif', $lang_smilies_inc_php['Neutral']),
85
        array(':-(', 'icon_sad.gif', $lang_smilies_inc_php['Sad']),
86
        array(':cry:', 'icon_cry.gif', $lang_smilies_inc_php['Crying or Very sad']),
87
        array('8-)', 'icon_cool.gif', $lang_smilies_inc_php['Cool']),
88
        array(':-o', 'icon_surprised.gif', $lang_smilies_inc_php['Surprised']),
89
        array(':-?', 'icon_confused.gif', $lang_smilies_inc_php['Confused']),
90
        array(':oops:', 'icon_redface.gif', $lang_smilies_inc_php['Embarassed']),
91
        array(':shock:', 'icon_eek.gif', $lang_smilies_inc_php['Shocked']),
92
        array(':-x', 'icon_mad.gif', $lang_smilies_inc_php['Mad']),
93
        array(':roll:', 'icon_rolleyes.gif', $lang_smilies_inc_php['Rolling Eyes']),
94
        array(';-)', 'icon_wink.gif', $lang_smilies_inc_php['Wink']),
95
        array(':idea:', 'icon_idea.gif', $lang_smilies_inc_php['Idea']),
96
        array(':!:', 'icon_exclaim.gif', $lang_smilies_inc_php['Exclamation']),
97
        array(':?:', 'icon_question.gif', $lang_smilies_inc_php['Question'])
98
        );
99
}
100
// Smilies code ... would this be better tagged on to the end of bbcode.php?
101
// Probably so and I'll move it before B2
102
 
103
function process_smilies($message, $url_prefix = '')
104
{
105
    static $orig, $repl;
106
 
107
    if (!isset($orig)) {
108
        global $db, $board_config;
109
        $orig = $repl = array();
110
 
111
        $smilies = get_smilies_table1();
112
 
113
        for($i = 0; $i < count($smilies); $i++) {
114
            $orig[] = "/(?<=.\W|\W.|^\W)" . preg_quote($smilies[$i][0], "/") . "(?=.\W|\W.|\W$)/";
115
            $repl[] = '<img src="' . $url_prefix . 'images/smiles' . '/' . ($smilies[$i][1]) . '" alt="' . ($smilies[$i][2]) . '" border="0" />';
116
        }
117
    }
118
 
119
    if (count($orig)) {
120
        $message = preg_replace($orig, $repl, ' ' . $message . ' ');
121
        $message = substr($message, 1, -1);
122
    }
123
    return $message;
124
}
125
 
126
// Fill smiley templates (or just the variables) with smileys
127
// Either in a window or inline
128
 
129
function generate_smilies($form = 'post', $field = 'message')
130
{
131
    $smilies = get_smilies_table2();
132
 
133
    $html = '<table width="100%" border="0" cellspacing="0" cellpadding="0">' . "\n" . '        <tr align="center" valign="middle">' . "\n";
134
 
135
    foreach($smilies as $smiley) {
136
        $caption = $smiley[2] . " " . $smiley[0];
137
        $html .= '                <td width="5%"><a href="javascript:emoticon_' . $form . '(\'' . $smiley[0] . '\')"><img src="images/smiles/' . $smiley[1] . '" alt="' . $caption . '" width="15" height="15" border="0" title="' . $caption . '"></a></td>' . "\n";
138
    }
139
 
140
    $html .= '        </tr>' . "\n" . '</table>' . "\n";
141
 
142
    $html .= <<<EOT
143
 
144
<script language="JavaScript" type="text/javascript">
145
<!--
146
function emoticon_$form(text) {
147
        text = ' ' + text + ' ';
148
        if (document.$form.$field.createTextRange && document.post.message.caretPos) {
149
                var caretPos = document.$form.$field.caretPos;
150
                caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? text + ' ' : text;
151
                document.$form.$field.focus();
152
        } else {
153
                document.$form.$field.value  += text;
154
                document.$form.$field.focus();
155
        }
156
}
157
 
158
function storeCaret_$form(textEl) {
159
        if (textEl.createTextRange) textEl.caretPos = document.selection.createRange().duplicate();
160
}
161
//-->
162
 
163
EOT;
164
    $html .= "</script>\n";
165
    return $html;
166
}
167
 
168
?>