forked from butch2k/SMF-ILA
-
Notifications
You must be signed in to change notification settings - Fork 0
/
install-2.0.xml
313 lines (257 loc) · 12.6 KB
/
install-2.0.xml
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
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
<?xml version="1.0"?>
<!DOCTYPE modification SYSTEM "http://www.simplemachines.org/xml/modification">
<modification xmlns="http://www.simplemachines.org/xml/modification" xmlns:smf="http://www.simplemachines.org/">
<!--
==========================================================================
package "In Line Attachments (ILA)" Addon for SMF
author Spuds
copyright (c) 2011-2013 Spuds
license Mozilla Public License version 1.1 http://www.mozilla.org/MPL/1.1/.
==========================================================================
-->
<id>spuds:ILA</id>
<file name="$sourcedir/Subs.php">
<operation>
<search position="before"><![CDATA[ // Sift out the bbc for a performance improvement.]]></search>
<add><![CDATA[
// ILA in line attachment changes
if (empty($context['pmx']['forumReq']) && empty($context['pmx']['pageReq']) && empty($_GET['pmxerror']) && (isset($context['pmx']['settings']['frontpage']) && ($context['pmx']['settings']['frontpage'] != 'none')))
{
// Just a dummy comment so whether the portalMX front page is loaded or there is a page you can request to test
}
elseif (empty($parse_tags) && empty($context['uninstalling']) && !empty($modSettings['ila_enabled']) && strpos($message, '[attach') !== false)
ila_hide_bbc($message);
// End ILA in line attachment changes
]]></add>
</operation>
<operation>
<search position="after"><![CDATA[ // Cache the output if it took some time...]]></search>
<add><![CDATA[
// ILA in line attachment changes
if (empty($parse_tags) && empty($context['uninstalling']))
{
if (function_exists('ila_parse_bbc') && stripos($message, '[attach') !== false)
ila_parse_bbc($message, $cache_id);
}
// End ILA in line attachment changes
]]></add>
</operation>
<operation>
<search position="after"><![CDATA[
// This is done to allow theme authors to customize it as they want.]]></search>
<add><![CDATA[
// ILA in line attachment changes
$context['html_headers'] .= '<script type="text/javascript" src="' . $settings['default_theme_url'] . '/scripts/ila.js"></script>';
// End ILA in line attachment changes
]]></add>
</operation>
</file>
<file name="$sourcedir/Post.php">
<operation>
<search position="replace"><![CDATA[ while ($row = $smcFunc['db_fetch_assoc']($request))
{
if ($row['filesize'] <= 0)
continue;
$context['current_attachments'][] = array(
'name' => htmlspecialchars($row['filename']),
'id' => $row['id_attach'],
'approved' => $row['approved'],
);
}]]></search>
<add><![CDATA[ // ILA in line attachment changes
$temp = array();
while ($row = $smcFunc['db_fetch_assoc']($request))
{
if ($row['filesize'] <= 0)
continue;
$temp[$row['id_attach']] = $row;
}
// This is better than sorting it with the query...
ksort($temp);
foreach ($temp as $row)
{
$context['current_attachments'][] = array(
'name' => htmlspecialchars($row['filename']),
'id' => $row['id_attach'],
'approved' => $row['approved'],
);
}
// End ILA in line attachment changes
]]></add>
</operation>
<operation>
<search position="replace"><![CDATA[ // Load up 'em attachments!
foreach ($attachment_stuff as $attachment)
{
if ($attachment['filesize'] >= 0 && !empty($modSettings['attachmentEnable']))
$context['current_attachments'][] = array(
'name' => htmlspecialchars($attachment['filename']),
'id' => $attachment['id_attach'],
'approved' => $attachment['attachment_approved'],
);
}]]></search>
<add><![CDATA[ // Load up 'em attachments!
// ILA in line attachment changes
$temp = array();
foreach ($attachment_stuff as $attachment)
{
if ($attachment['filesize'] >= 0 && !empty($modSettings['attachmentEnable']))
$temp[$attachment['id_attach']] = $attachment;
}
ksort($temp);
foreach ($temp as $attachment)
{
$context['current_attachments'][] = array(
'name' => htmlspecialchars($attachment['filename']),
'id' => $attachment['id_attach'],
'approved' => $attachment['attachment_approved'],
);
}
// End ILA in line attachment changes]]></add>
</operation>
</file>
<file name="$themedir/Display.template.php">
<operation>
<search position="before"><![CDATA[ $last_approved_state = 1;
foreach ($message['attachment'] as $attachment)
{
]]></search>
<add><![CDATA[
// ILA in line attachment changes
if (!isset($context['ila_dont_show_attach_below']) || !array_key_exists($attachment['id'], $context['ila_dont_show_attach_below']))
{
// End ILA in line attachment changes
]]></add>
</operation>
<operation>
<search position="after"><![CDATA[ // If we had unapproved attachments clean up.
]]></search>
<add><![CDATA[
// ILA in line attachment changes
}
// End ILA in line attachment changes
]]></add>
</operation>
</file>
<file name="$themedir/Post.template.php">
<operation error="ignore">
<search position="replace" error="ignore"><![CDATA[ foreach ($context['current_attachments'] as $attachment)
echo '
<dd class="smalltext">
<label for="attachment_', $attachment['id'], '"><input type="checkbox" id= "attachment_', $attachment['id'], '" name="attach_del[]" value="', $attachment['id'], '"', empty($attachment['unchecked']) ? ' checked="checked"' : '', ' class="input_check" /> ', $attachment['name'], (empty($attachment['approved']) ? ' (' . $txt['awaiting_approval'] . ')' : ''), '</label>
</dd>';
]]></search>
<add><![CDATA[
// ILA in line attachment changes
foreach ($context['current_attachments'] as $attid => $attachment)
// For each existing attachment show the check box and link to do an ILA attach for the attachment
echo '
<dd class="smalltext">
<label for="attachment_', $attachment['id'], '"><input type="checkbox" id= "attachment_', $attachment['id'], '" name="attach_del[]" value="', $attachment['id'], '"', empty($attachment['unchecked']) ? ' checked="checked"' : '', ' class="input_check" /> ', $attachment['name'], (empty($attachment['approved']) ? ' (' . $txt['awaiting_approval'] . ')' : ''), '</label>
<a href="javascript:void(0);" onclick="
ila_text = \'[attach=',($attid+1),']\';
oEditorHandle_', $context['post_box_name'], '.insertText(ila_text, false, true);
return false;">[', $txt['ila_insert'] ,' ', ($attid+1),' ', $txt['ila_insert_next'] ,']</a>
</dd>';
// End ILA in line attachment changes';
]]></add>
</operation>
</file>
<file name="$themedir/Post.template.php">
<operation>
<search position="replace"><![CDATA[ <input type="file" size="60" name="attachment[]" id="attachment1" class="input_file" /> (<a href="javascript:void(0);" onclick="cleanFileInput(\'attachment1\');">', $txt['clean_attach'], '</a>)';
]]></search>
<add><![CDATA[ <input type="file" size="60" name="attachment[]" id="attachment1" class="input_file" />';
// ILA in line attachment changes
echo '
<select id="inline_format" onchange="if(this.value != \'\'){ila_text = \'[\'+this.value+\'=', (count($context['current_attachments']) + 1), ']\';oEditorHandle_', $context['post_box_name'], '.insertText(ila_text, false, true);return false;}">
<option value="" selected="selected">', $txt['ila_title'], ' </option>
<option value="attach">', $txt['ila_option1'], '</option>';
// Show all options or simple ILA menu
if (!isset($modSettings['ila_basicmenu']) || (isset($modSettings['ila_basicmenu']) && empty($modSettings['ila_basicmenu'])))
{
echo '
<option value="attachimg">', $txt['ila_option2'], '</option>
<option value="attachurl">', $txt['ila_option3'], '</option>
<option value="attachmini">', $txt['ila_option4'], '</option>';
}
echo '
</select>';
// Add help
echo '
<a href="', $scripturl, '?action=helpadmin;help=ILA_InLineAttachments_help" onclick="return reqWin(this.href);" class="help"><img src="', $settings['images_url'], '/helptopics.gif" alt="', $txt['help'], '" align="top" /></a>';
// Add clean me up back
echo '
(<a href="javascript:void(0);" onclick="cleanFileInput(\'attachment1\');">', $txt['clean_attach'], '</a>)';
// set more menu items
if (!isset($modSettings['ila_basicmenu']) || (isset($modSettings['ila_basicmenu']) && empty($modSettings['ila_basicmenu'])))
$ila_menu = '<option value="" selected>'. $txt['ila_title'] . '</option><option value="attach">' . $txt['ila_option1'] . '</option><option value="attachimg">' . $txt['ila_option2'] . '</option><option value="attachurl">' . $txt['ila_option3'] . '</option><option value="attachmini">' . $txt['ila_option4'] . '</option>';
else
$ila_menu = '<option value="" selected>' . $txt['ila_title'] . '</option><option value="attach">' . $txt['ila_option1'] . '</option>';
// END ILA in line attachment changes
]]></add>
</operation>
<operation>
<search position="replace"><![CDATA[
function addAttachment()
{
allowed_attachments = allowed_attachments - 1;
current_attachment = current_attachment + 1;
if (allowed_attachments <= 0)
return alert("', $txt['more_attachments_error'], '");
setOuterHTML(document.getElementById("moreAttachments"), \'<dd class="smalltext"><input type="file" size="60" name="attachment[]" id="attachment\' + current_attachment + \'" class="input_file" /> (<a href="javascript:void(0);" onclick="cleanFileInput(\\\'attachment\' + current_attachment + \'\\\');">', $txt['clean_attach'], '</a>)\' + \'</dd><dd class="smalltext" id="moreAttachments"><a href="#" onclick="addAttachment(); return false;">(', $txt['more_attachments'], ')<\' + \'/a><\' + \'/dd>\');
return true;
}
]]></search>
<add><![CDATA[
var count_attachments = ', count($context['current_attachments']) ,' + 1;
function createLink(count_attachments)
{
var insert_value = document.getElementById(\'inline_format\'+count_attachments).value;
if ( insert_value != "" ) {
ila_text = "["+insert_value+"="+count_attachments+"]";
oEditorHandle_', $context['post_box_name'], '.insertText(ila_text, false, true);
}
return false;
}
function addAttachment()
{
allowed_attachments = allowed_attachments - 1;
current_attachment = current_attachment + 1;
if (allowed_attachments <= 0)
return alert("', $txt['more_attachments_error'], '");
count_attachments = count_attachments + 1 ;
setOuterHTML(document.getElementById("moreAttachments"), \'<dd class="smalltext"><input type="file" size="60" name="attachment[]" id="attachment\' + current_attachment + \'" class="input_file" /> <select id="inline_format\'+count_attachments+\'" onchange="createLink(\\\'\'+ count_attachments +\'\\\')" style="">', $ila_menu ,'</select> <a href="', $scripturl, '?action=helpadmin;help=ILA_InLineAttachments_help" onclick="return reqWin(this.href);" class="help"><img src="', $settings['images_url'], '/helptopics.gif" alt="', $txt['help'], '" align="top" /></a> (<a href="javascript:void(0);" onclick="cleanFileInput(\\\'attachment\' + current_attachment + \'\\\');">', $txt['clean_attach'], '</a>)<dd class="smalltext" id="moreAttachments"><a href="#" onclick="addAttachment(); return false;">(', $txt['more_attachments'], ')<\' + \'/a><\' + \'/dd><\' + \'/dd>\');
return true;
}
]]></add>
</operation>
<operation>
<search position="before"><![CDATA[ var current_board = ', empty($context['current_board']) ? 'null' : $context['current_board'], ';]]></search>
<add><![CDATA[
var current_message = ', empty($_REQUEST['msg']) ? 'null' : (int) $_REQUEST['msg'], ';
var ilaAttach, ilaElem, ila =0;]]></add>
</operation>
<operation>
<search position="before"><![CDATA[ function previewPost()
{]]></search>
<add><![CDATA[
ilaAttach = "";
while (ilaElem = document.forms.postmodify.elements[ila++])
{
if (ilaElem.name == "attachment[]")
ilaAttach += ilaElem.value + ",";
}
if (ilaAttach != "")
ilaAttach = escape(ilaAttach.slice(0,-1));
ila = 0;
]]></add>
</operation>
<operation>
<search position="replace"><![CDATA[ sendXMLDocument(smf_prepareScriptUrl(smf_scripturl) + \'action=post2\' + (current_board ? \';board=\' + current_board : \'\') + (make_poll ? \';poll\' : \'\') + \';preview;xml\', x.join(\'&\'), onDocSent);
]]></search>
<add><![CDATA[ sendXMLDocument(smf_prepareScriptUrl(smf_scripturl) + \'action=post2\' + (current_message ? \';msg=\' + current_message : \'\') + (ilaAttach ? \';ila=\' + ilaAttach : \'\') + (current_board ? \';board=\' + current_board : \'\') + (make_poll ? \';poll\' : \'\') + \';preview;xml\', x.join(\'&\'), onDocSent);
]]></add>
</operation>
</file>
</modification>