/
product-rcd_hide_images.xml
239 lines (219 loc) · 9.26 KB
/
product-rcd_hide_images.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
<?xml version="1.0" encoding="ISO-8859-1"?>
<product productid="rcd_hide_images" active="1">
<title>Hide Images</title>
<description>Allows hiding images in posts</description>
<version>0.2</version>
<url><![CDATA[http://www.vbulletin.org/forum/misc.php?do=producthelp&pid=rcd_hide_images]]></url>
<versioncheckurl><![CDATA[http://www.vbulletin.org/forum/misc.php?do=productcheck&pid=rcd_hide_images]]></versioncheckurl>
<apm_releasedate>0</apm_releasedate>
<apm_author />
<apm_relatedurl />
<apm_extrainfo />
<apm_extraedit />
<dependencies>
</dependencies>
<codes>
<code version="0.1">
<installcode><![CDATA[$db->query_write("
ALTER TABLE " . TABLE_PREFIX . "user
ADD rcd_hide_images TINYINT( 1 ) NOT NULL DEFAULT '0'
");]]></installcode>
<uninstallcode><![CDATA[$db->query_write("
ALTER TABLE " . TABLE_PREFIX . "user
DROP rcd_hide_images
");]]></uninstallcode>
</code>
</codes>
<templates>
<template name="rcd_hi_global_btn" templatetype="template" date="1289047045" username="ruseinov" version="0.1"><![CDATA[<vb:if condition="$showimages">
<li class="popupmenu"><h6><a class="firstunread" style="background:none; color: {vb:stylevar toolsmenu_color};" href="{vb:raw hi_global_url}">{vb:rawphrase hi_hide_glob_txt} </a></h6></li>
<vb:else />
<li class="popupmenu"><h6><a class="firstunread" style="background:none; color: {vb:stylevar toolsmenu_color};" href="{vb:raw hi_global_url}">{vb:rawphrase hi_show_glob_txt} </a></h6></li>
</vb:if>]]></template>
<template name="rcd_hi_show_btn" templatetype="template" date="1290024444" username="Vitaly" version="0.2"><![CDATA[<vb:if condition="$show['rcd_hi_button']">
<div style="float:right; padding: {vb:stylevar padding}; padding-{vb:stylevar right}: 0;">
<a href="javascript://" class="textcontrol" style="cursor:pointer;" onclick="return display_post({vb:raw post.postid});" rel="nofollow">{vb:rawphrase hi_show_btn_text} ({vb:raw show.rcd_hi_img_num})</a>
</div>
<vb:if condition="!$post['title'] AND !$show['messageicon']">
<div class="title"> </div>
</vb:if>
</vb:if>]]></template>
</templates>
<stylevardfns>
</stylevardfns>
<stylevars>
</stylevars>
<plugins>
<plugin active="1" executionorder="5">
<title>Cache templates</title>
<hookname>cache_templates</hookname>
<phpcode><![CDATA[if (THIS_SCRIPT == 'showthread')
{
$cache[] = 'rcd_hi_show_btn';
$cache[] = 'rcd_hi_global_btn';
}]]></phpcode>
</plugin>
<plugin active="1" executionorder="5">
<title>Show/hide videos</title>
<hookname>global_complete</hookname>
<phpcode><![CDATA[if (strpos($output, 'tag:video'))
{
$search = '/<!\-\-tag:video=(.+?)\-\->(.+?)<!\-\-\/tag:video\-\->/s';
// Show video
$replace = '\\2';
// Show link if images are hidden
if (!$vbulletin->userinfo['showimages'])
{
$replace = '<a href="\\1">\\1</a>';
}
$output = preg_replace($search, $replace, $output);
}]]></phpcode>
</plugin>
<plugin active="1" executionorder="5">
<title>Save show/hide images setting</title>
<hookname>misc_start</hookname>
<phpcode><![CDATA[if (isset($_REQUEST['rcd_hide_images']) && !$show['guest'])
{
$userdata =& datamanager_init('User', $vbulletin, ERRTYPE_STANDARD);
$userdata->set_existing($vbulletin->userinfo);
if ($_REQUEST['rcd_hide_images'] == 1)
{
$userdata->set('rcd_hide_images', 1);
$rcd_hi_redir = 'hi_redir_msg_hide';
}
elseif ($_REQUEST['rcd_hide_images'] == 0)
{
$userdata->set('rcd_hide_images', 0);
$rcd_hi_redir = 'hi_redir_msg_show';
}
$userdata->save();
$vbulletin->url = fetch_seo_url('thread', $threadinfo, array('page' => intval($_REQUEST['pagenumber'])));
eval(print_standard_redirect($rcd_hi_redir, true, true));
}]]></phpcode>
</plugin>
<plugin active="1" executionorder="1">
<title>Template modifications</title>
<hookname>parse_templates</hookname>
<phpcode><![CDATA[if (THIS_SCRIPT == 'showthread' && !$show['guest'])
{
$before_patch = $vbulletin->templatecache['SHOWTHREAD'];
$search = 'if ($show[\'firstunreadlink\'])';
$replace = '$final_rendered .= $template_hook[\'showthread_thrd_ctrls_start\'];
if ($show[\'firstunreadlink\'])';
$vbulletin->templatecache['SHOWTHREAD'] = str_replace($search, $replace, $vbulletin->templatecache['SHOWTHREAD']);
if ($before_patch == $vbulletin->templatecache['SHOWTHREAD'])
{
$err_message = sprintf("Product '%s', error in hook %s : can't modify template '%s'",
'Hide images',
'parse_templates',
'SHOWTHREAD');
error_log($err_message); // Send to PHP error log
if ($vbulletin->debug)
{
trigger_error($err_message, E_USER_WARNING); // Display on page
require_once(DIR . '/includes/functions_log_error.php');
log_vbulletin_error($err_message, 'php'); // Send to vB error log
}
unset($err_message, $before_patch);
}
}
if (array_key_exists('bbcode_video', $vbulletin->templatecache))
{
$hi_tag_open = '$final_rendered .= \'<!--tag:video=\' . $url . \'-->';
$hi_tag_close = '<!--/tag:video-->\';';
$vbulletin->templatecache['bbcode_video'] = $hi_tag_open . vb_Template::fetch_template_raw('bbcode_video') . $hi_tag_close;
}]]></phpcode>
</plugin>
<plugin active="1" executionorder="5">
<title><![CDATA[Render "show" button template]]></title>
<hookname>postbit_display_complete</hookname>
<phpcode><![CDATA[if (THIS_SCRIPT == 'showthread')
{
$rcd_hi_templater = vB_Template::create('rcd_hi_show_btn');
$rcd_hi_templater->register('post', $this->post);
$template_hook['postbit_messagearea_start'] .= $rcd_hi_templater->render();
}]]></phpcode>
</plugin>
<plugin active="1" executionorder="5">
<title>Check for attachments and set flag</title>
<hookname>postbit_display_start</hookname>
<phpcode><![CDATA[global $vbulletin;
if (!$vbulletin->userinfo['showimages'] && !$show['guest'])
{
$rcd_hi_atchmnt_cnt = count($this->post['attachments']);
if ($rcd_hi_atchmnt_cnt)
{
$show['rcd_hi_button'] = true;
$show['rcd_hi_img_num'] += $rcd_hi_atchmnt_cnt;
}
}]]></phpcode>
</plugin>
<plugin active="1" executionorder="5">
<title>Count hidden images and videos in post text</title>
<hookname>showthread_postbit_create</hookname>
<phpcode><![CDATA[if (!$vbulletin->userinfo['showimages'])
{
$show['rcd_hi_button'] = false;
$show['rcd_hi_img_num'] = 0;
$show['rcd_hi_img_num'] += substr_count($post['pagetext'], '[/img]');
$show['rcd_hi_img_num'] += substr_count($post['pagetext'], '[/video]');
if ($show['rcd_hi_img_num'])
{
$show['rcd_hi_button'] = true;
}
}]]></phpcode>
</plugin>
<plugin active="1" executionorder="5">
<title>Show/hide images, construct url, render template</title>
<hookname>showthread_start</hookname>
<phpcode><![CDATA[$hi_url_param = 1;
if ($vbulletin->userinfo['showimages'] && $vbulletin->userinfo['rcd_hide_images'])
{
$vbulletin->userinfo['showimages'] = 0;
$show['postloader_js'] = 1;
$hi_url_param = 0;
}
$hi_global_url = '/misc.php?t=' . $threadinfo['threadid'] . '&rcd_hide_images=' . $hi_url_param . '&pagenumber=' . $vbulletin->GPC['pagenumber'];
$rcd_hi_templater = vB_Template::create('rcd_hi_global_btn');
$rcd_hi_templater->register('hi_global_url', $hi_global_url);
$rcd_hi_templater->register('showimages', $vbulletin->userinfo['showimages']);
$template_hook['showthread_thrd_ctrls_start'] = $rcd_hi_templater->render();]]></phpcode>
</plugin>
<plugin active="1" executionorder="5">
<title>Make rcd_hide_images valid.</title>
<hookname>userdata_start</hookname>
<phpcode><![CDATA[$this->validfields['rcd_hide_images'] = array(TYPE_UINT, REQ_NO);]]></phpcode>
</plugin>
<plugin active="1" executionorder="5">
<title>Remove video comments from xml</title>
<hookname>xml_print_output</hookname>
<phpcode><![CDATA[if (strpos($this->doc, 'tag:video'))
{
$search = '/<!\-\-tag:video=(.+?)\-\->(.+?)<!\-\-\/tag:video\-\->/s';
$replace = '\\2';
$this->doc = preg_replace($search, $replace, $this->doc);
}]]></phpcode>
</plugin>
</plugins>
<phrases>
<phrasetype name="Front-End Redirect Messages" fieldname="frontredirect">
<phrase name="hi_redir_msg_hide" date="1289043301" username="ruseinov" version=""><![CDATA[Images are now hidden]]></phrase>
<phrase name="hi_redir_msg_show" date="1289043333" username="ruseinov" version=""><![CDATA[Images are now shown]]></phrase>
</phrasetype>
<phrasetype name="Show Thread" fieldname="showthread">
<phrase name="hi_hide_glob_txt" date="1289047002" username="ruseinov" version=""><![CDATA[Hide images]]></phrase>
<phrase name="hi_show_btn_text" date="1289046968" username="ruseinov" version=""><![CDATA[Show images]]></phrase>
<phrase name="hi_show_glob_txt" date="1289047021" username="ruseinov" version=""><![CDATA[Show images]]></phrase>
</phrasetype>
</phrases>
<options>
</options>
<helptopics>
</helptopics>
<cronentries>
</cronentries>
<faqentries>
</faqentries>
<templateedits>
</templateedits>
</product>