-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPortalShoutbox.template.php
270 lines (228 loc) · 8.93 KB
/
PortalShoutbox.template.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
<?php
/**
* @package SimplePortal
*
* @author SimplePortal Team
* @copyright 2014 SimplePortal Team
* @license BSD 3-clause
*
* @version 2.4
*/
/**
* The all template
*/
function template_shoutbox_all()
{
template_shoutbox_all_default();
}
/**
* Template to display all of the shouts in a system
*/
function template_shoutbox_all_default()
{
global $context, $txt;
echo '
<h3 class="category_header">
', $context['SPortal']['shoutbox']['name'], '
</h3>
<div class="windowbg">
<div class="sp_content_padding">';
template_pagesection();
echo '
<div class="shoutbox_body">
<ul class="shoutbox_list_all" id="shouts">';
if (!empty($context['SPortal']['shouts_history']))
foreach ($context['SPortal']['shouts_history'] as $shout)
echo '
', !$shout['is_me'] ? '<li class="smalltext"><strong>' . $shout['author']['link'] . ':</strong></li>' : '', '
<li class="smalltext">', str_replace('ignored_shout', 'history_ignored_shout', $shout['text']), '</li>
<li class="smalltext shoutbox_time">', $shout['delete_link'], $shout['time'], '</li>';
else
echo '
<li class="smalltext">', $txt['sp_shoutbox_no_shout'], '</li>';
echo '
</ul>
</div>';
template_pagesection();
echo '
</div>
</div>';
}
/**
* Embeds a shoutbox block on a page
*
* @param mixed[] $shoutbox
*/
function template_shoutbox_embed($shoutbox)
{
global $context, $scripturl, $settings, $txt;
echo '
<form method="post">
<div class="shoutbox_container">
<div class="shoutbox_info">
<div id="shoutbox_load_', $shoutbox['id'], '" style="float: right; display: none;"><i class="fa fa-spinner fa-spin"></i></div>
<a ', sp_embed_class('refresh'), ' href="', $scripturl, '?action=shoutbox;shoutbox_id=', $shoutbox['id'], '" onclick="sp_refresh_shout(', $shoutbox['id'], ', last_refresh_', $shoutbox['id'], '); return false;"></a>
<a ', sp_embed_class('history'), ' href="', $scripturl, '?action=shoutbox;shoutbox_id=', $shoutbox['id'], '"></a>';
if ($context['can_shout'])
echo ' <a ', sp_embed_class('smiley'), ' href="#smiley" onclick="sp_collapse_object(\'sb_smiley_', $shoutbox['id'], '\', false); return false;"></a> <a ', sp_embed_class('style'), ' href="#style" onclick="sp_collapse_object(\'sb_style_', $shoutbox['id'], '\', false); return false;"></a>';
echo '
</div>';
if ($context['can_shout'])
{
// Smiley box
echo '
<div id="sp_object_sb_smiley_', $shoutbox['id'], '" style="display: none;">';
foreach ($shoutbox['smileys']['normal'] as $smiley)
echo '
<a href="javascript:void(0);" onclick="replaceText(\' ', $smiley['code'], '\', document.getElementById(\'new_shout_', $shoutbox['id'], '\')); return false;"><img src="', $settings['smileys_url'], '/', $smiley['filename'], '" alt="', $smiley['description'], '" title="', $smiley['description'], '" /></a>';
if (!empty($shoutbox['smileys']['popup']))
echo '
<a onclick="sp_showMoreSmileys(\'', $shoutbox['id'], '\', \'', $txt['more_smileys_title'], '\', \'', $txt['more_smileys_pick'], '\', \'', $txt['more_smileys_close_window'], '\', \'', $settings['theme_url'], '\', \'', $settings['smileys_url'], '\'); return false;" href="javascript:void(0);">[', $txt['more_smileys'], ']</a>';
// BBC box
echo '
</div>
<div id="sp_object_sb_style_', $shoutbox['id'], '" class="shoutbox_bbc_container" style="display: none;">';
// For each bbc code we allow in this shoutbox
foreach ($shoutbox['bbc'] as $image => $tag)
{
if (!in_array($tag['code'], $shoutbox['allowed_bbc']))
continue;
// Add all enabled shoutbox BBC buttons
echo '
<a href="#" class="shoutbox-button shoutbox-', $image, '" title="', $tag['description'], '" ';
// Set the button click action
if (!isset($tag['after']))
echo 'onclick="replaceText(\'', $tag['before'], '\', document.getElementById(\'new_shout_', $shoutbox['id'], '\')); return false;">';
else
echo 'onclick="sp_surroundText(\'', $tag['before'], '\', \'', $tag['after'], '\', document.getElementById(\'new_shout_', $shoutbox['id'], '\')); return false;">';
echo '
<div></div>
</a>';
}
echo '
</div>';
}
// The shouts!
echo '
<div class="shoutbox_body">
<ul class="shoutbox_list_compact" id="shouts_', $shoutbox['id'], '"', !empty($shoutbox['height']) ? ' style="height: ' . $shoutbox['height'] . 'px;"' : '', '>';
if (!empty($shoutbox['warning']))
echo '
<li class="shoutbox_warning">', $shoutbox['warning'], '</li>';
if (!empty($shoutbox['shouts']))
foreach ($shoutbox['shouts'] as $shout)
echo '
<li>', !$shout['is_me'] ? '<strong>' . $shout['author']['link'] . ':</strong> ' : '', $shout['text'], '<br />', !empty($shout['delete_link_js']) ? '<span class="shoutbox_delete">' . $shout['delete_link_js'] . '</span>' : '', '<span class="smalltext shoutbox_time">', $shout['time'], '</span></li>';
else
echo '
<li>', $txt['sp_shoutbox_no_shout'], '</li>';
echo '
</ul>
</div>';
// Show an input box, if they can use it
if ($context['can_shout'])
echo '
<div class="submitbutton">
<input type="text" name="new_shout" id="new_shout_', $shoutbox['id'], '" class="shoutbox_input floatleft input_text"', isBrowser('is_ie8') ? ' onkeypress="if (sp_catch_enter(event)) { sp_submit_shout(' . $shoutbox['id'] . ', \'' . $context['session_var'] . '\', \'' . $context['session_id'] . '\'); return false; }"' : '', ' />
<input type="submit" name="submit_shout" value="', $txt['sp_shoutbox_button'], '" class="right_submit" onclick="sp_submit_shout(', $shoutbox['id'], ', \'', $context['session_var'], '\', \'', $context['session_id'], '\'); return false;" />
</div>';
echo '
</div>
<input type="hidden" name="shoutbox_id" value="', $shoutbox['id'], '" />
<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '" />
</form>
<script><!-- // --><![CDATA[
var last_refresh_', $shoutbox['id'], ' = ', time(), ';';
if ($shoutbox['reverse'])
echo '
var objDiv = document.getElementById("shouts_', $shoutbox['id'], '");
objDiv.scrollTop = objDiv.scrollHeight;';
if (!empty($shoutbox['refresh']))
echo '
var interval_id_', $shoutbox['id'], ' = setInterval("sp_auto_refresh_', $shoutbox['id'], '()", ', $shoutbox['refresh'], ' * 1000);
function sp_auto_refresh_', $shoutbox['id'], '()
{
if (window.XMLHttpRequest)
{
sp_refresh_shout(', $shoutbox['id'], ', last_refresh_', $shoutbox['id'], ');
last_refresh_', $shoutbox['id'], ' += ', $shoutbox['refresh'], ';
}
else
clearInterval(interval_id_', $shoutbox['id'], ');
}';
// Setup the data for the popup smileys.
if (!empty($shoutbox['smileys']['popup']))
{
echo '
if (sp_smileys == undefined)
var sp_smileys = [';
foreach ($shoutbox['smileys']['popup'] as $smiley)
{
echo '
["', $smiley['code'], '","', $smiley['filename'], '","', $smiley['js_description'], '"]';
if (empty($smiley['last']))
echo ',';
}
echo ']';
echo '
if (sp_moreSmileysTemplate == undefined)
{
var sp_moreSmileysTemplate = ', JavaScriptEscape('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>' . $txt['more_smileys_title'] . '</title>
<link rel="stylesheet" type="text/css" href="' . $settings['theme_url'] . '/css/index' . $context['theme_variant'] . '.css?rc2" />
</head>
<body id="help_popup">
<div class="padding windowbg">
<h3 class="category_header">
' . $txt['more_smileys_pick'] . '
</h3>
<div class="padding">
%smileyRows%
</div>
<div class="smalltext centertext">
<a href="javascript:window.close();">' . $txt['more_smileys_close_window'] . '</a>
</div>
</div>
</body>
</html>'), '
}';
}
echo '
// ]]></script>';
}
/**
* Return an xml response to a shoutbox
*/
function template_shoutbox_xml()
{
global $context, $txt;
echo '<', '?xml version="1.0" encoding="UTF-8"?', '>
<elk>
<shoutbox>', $context['SPortal']['shoutbox']['id'], '</shoutbox>';
if ($context['SPortal']['updated'])
{
echo '
<updated>1</updated>
<error>', empty($context['SPortal']['shouts']) ? $txt['sp_shoutbox_no_shout'] : 0, '</error>
<warning>', !empty($context['SPortal']['shoutbox']['warning']) ? htmlspecialchars($context['SPortal']['shoutbox']['warning']) : 0, '</warning>
<reverse>', !empty($context['SPortal']['shoutbox']['reverse']) ? 1 : 0, '</reverse>';
foreach ($context['SPortal']['shouts'] as $shout)
echo '
<shout>
<id>', $shout['id'], '</id>
<author>', htmlspecialchars($shout['author']['link']), '</author>
<time>', htmlspecialchars($shout['time']), '</time>
<timeclean>', htmlspecialchars(strip_tags($shout['time'])), '</timeclean>
<delete>', !empty($shout['delete_link_js']) ? htmlspecialchars($shout['delete_link_js']) : ' ', '</delete>
<content>', htmlspecialchars($shout['text']), '</content>
<is_me>', $shout['is_me'] ? 1 : 0, '</is_me>
</shout>';
}
else
echo '
<updated>0</updated>';
echo '
</elk>';
}