View difference between Paste ID: RQt2SzhY and PmQWRr6Q
SHOW: | | - or go back to the newest paste.
1
##
2
##
3
##        Mod title:  Spoiler
4
##
5
##      Mod version:  1.0
6
##  Works on FluxBB:  1.5.*
7
##     Release date:  2014-01-17
8
##
9
##          Authors:  Faucheuse83 (http://www.black-omegadesign.fr)
10
##					  David18 (http://www.beargryllsvswild.fr)
11
##
12
##      Description:  Add new bbcode : [spoiler]
13
##					  You can hide or not content (image, video, text) with this tag.
14
##
15
##   Affected files:  include/search_idx.php
16
##					  include/parser.php
17
##					  style/style.php
18
##					  include/template/main.tpl
19
##
20
##       Affects DB:  No
21
##
22
##
23
##       DISCLAIMER:  Please note that "mods" are not officially supported by
24
##                    FluxBB. Installation of this modification is done at
25
##                    your own risk. Backup your forum database and any and
26
##                    all applicable files before proceeding.
27
##
28
##
29
30
#
31
#---------[ 1. OPEN ]-----------------------------------------------------------
32
#
33
34
/include/search_idx.php
35
36
#
37
#---------[ 2. FIND ]-----------------------------------------------------------
38
#
39
40
	// Remove BBCode
41
	$text = preg_replace('%\[/?(b|u|s|ins|del|em|i|h|colou?r|quote|code|img|url|email|list|topic|post|forum|user)(?:\=[^\]]*)?\]%', ' ', $text);
42
43
#
44
#---------[ 3. REPLACE WITH ]---------------------------------------------------
45
#
46
47
	// Remove BBCode // MODIFIED ||SPOILER
48
	$text = preg_replace('%\[/?(spoiler|b|u|s|ins|del|em|i|h|colou?r|quote|code|img|url|email|list|topic|post|forum|user)(?:\=[^\]]*)?\]%', ' ', $text);
49
50
#
51
#---------[ 4. SAVE ]-----------------------------------------------------------
52
#
53
54
/include/search_idx.php[/code]
55
56
#
57
#---------[ 5. OPEN ]-----------------------------------------------------------
58
#
59
60
/include/parser.php
61
62
#
63
#---------[ 6. FIND ]----------------------------------------------------------
64
#
65
66
		if (preg_match('%\[/?(?:quote|code|list|h)\b[^\]]*\]%i', $text))
67
			$errors[] = $lang_profile['Signature quote/code/list/h'];
68
69
#
70
#---------[ 7. REPLACE WITH ]--------------------------------------------------
71
#
72
73
		// MODIFIED ||SPOILER
74
		if (preg_match('%\[/?(?:spoiler|quote|code|list|h)\b[^\]]*\]%i', $text))
75
			$errors[] = $lang_profile['Signature quote/code/list/h'];
76
77
#
78
#---------[ 8. FIND ]----------------------------------------------------------
79
#
80
81
	// Remove empty tags
82
	while (!is_null($new_text = preg_replace('%\[(b|u|s|ins|del|em|i|h|colou?r|quote|img|url|email|list|topic|post|forum|user)(?:\=[^\]]*)?\]\s*\[/\1\]%', '', $text)))
83
84
#
85
#---------[ 9. REPLACE WITH ]--------------------------------------------------
86
#
87
88
	// Remove empty tags // MODIFIED ||SPOILER
89
	while (!is_null($new_text = preg_replace('%\[(spoiler|b|u|s|ins|del|em|i|h|colou?r|quote|img|url|email|list|topic|post|forum|user)(?:\=[^\]]*)?\]\s*\[/\1\]%', '', $text)))
90
91
#
92
#---------[ 10. FIND ]----------------------------------------------------------
93
#
94
95
	// List of all the tags
96
	$tags = array('quote', 'code', 'b', 'i', 'u', 's', 'ins', 'del', 'em', 'color', 'colour', 'url', 'email', 'img', 'list', '*', 'h', 'topic', 'post', 'forum', 'user');
97
98
#
99
#---------[ 11. REPLACE WITH ]--------------------------------------------------
100
#
101
102
	// List of all the tags // MODIFIED ||SPOILER
103
	$tags = array('spoiler', 'quote', 'code', 'b', 'i', 'u', 's', 'ins', 'del', 'em', 'color', 'colour', 'url', 'email', 'img', 'list', '*', 'h', 'topic', 'post', 'forum', 'user');
104
105
#
106
#---------[ 12. FIND ]----------------------------------------------------------
107
#
108
109
	// Tags we can nest and the depth they can be nested to
110
	$tags_nested = array('quote' => $pun_config['o_quote_depth'], 'list' => 5, '*' => 5);
111
112
#
113
#---------[ 13. REPLACE WITH ]--------------------------------------------------
114
#
115
116
	// Tags we can nest and the depth they can be nested to // MODIFIED ||SPOILER
117
	$tags_nested = array('quote' => $pun_config['o_quote_depth'], 'list' => 5, '*' => 5, 'spoiler' => 5);
118
119
#
120
#---------[ 14. FIND ]----------------------------------------------------------
121
#
122
123
	// Block tags, block tags can only go within another block tag, they cannot be in a normal tag
124
	$tags_block = array('quote', 'code', 'list', 'h', '*');
125
126
#
127
#---------[ 15. REPLACE WITH ]--------------------------------------------------
128
#
129
130
	// Block tags, block tags can only go within another block tag, they cannot be in a normal tag // MODIFIED ||SPOILER
131
	$tags_block = array('quote', 'code', 'list', 'h', '*', 'spoiler');
132
133
#
134
#---------[ 16. FIND ]----------------------------------------------------------
135
#
136
137
	$pattern[] = '%\[h\](.*?)\[/h\]%ms';
138
139
140
#
141
#---------[ 17. AFTER, ADD ]----------------------------------------------------------
142
#
143
144
	$pattern[] = '%\[spoiler\](.*?)\[/spoiler\]%ms'; // SPOILER
145
146
#
147
#---------[ 18. FIND ]-------------------------------------------------------------
148
#
149
150
	$replace[] = '</p><h5>$1</h5><p>';
151
	
152
#
153
#---------[ 19. AFTER, ADD ]----------------------------------------------------------
154
#
155
156
	$replace[] = '<div class="spoiler"><p class="teaser">Spoiler</p><div class="contenu">$1</div></div>'; // SPOILER
157
158
#
159
#---------[ 20. SAVE ]----------------------------------------------------------
160
#
161
162
/include/parser.php[/code]
163
164
#
165
#---------[ 21. OPEN ]----------------------------------------------------
166
#
167
168
/style/yourstyle.css
169
170
#
171
#---------[ 22. ADD ]-----------------------------------------------------------
172
#
173
.spoiler {
174
margin: 0 0 5px 0;
175
padding: 0;
176
width: 50%;
177
}
178
179
.teaser {
180
margin: 1px;
181
padding: 3px 10px;
182
cursor: pointer;
183
position: relative;
184
color: #ffffff;
185
background-color: #ff0000;
186
}
187
188
.contenu {
189
padding: 5px 10px;
190
background-color: #fafafa;
191
}
192
193
#
194
#---------[ 23. SAVE ]----------------------------------------------------------
195
#
196
197
/style/yourstyle.css
198
199
#
200
#---------[ 24. OPEN ]----------------------------------------------------
201
#
202
203
/include/template/main.tpl
204
205
#
206
#---------[ 25. FIND ]-----------------------------------------------------------
207
#
208
209
	<head>
210
	
211
#
212
#---------[ 26. AFTER, ADD ]-----------------------------------------------------------
213
#
214
215-
#---------[ END ]----------------------------------------------------------
215+
216
	<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
217
	<!-- END ADD -->
218
219
#
220
#---------[ 27. ADD (AT THE END) ]-----------------------------------------------------------
221
#
222
223
	<script> // ADD || SPOILER
224
	$(document).ready(function() {
225
	jQuery(".contenu").hide();
226
	jQuery(".teaser").click(function()
227
	{
228
	jQuery(this).next(".contenu").slideToggle(500);
229
	});
230
	});
231
	</script>
232
	
233
#
234
#---------[ 28. SAVE ]----------------------------------------------------------
235
#
236
237
/include/template/main.tpl
238
239
#
240
#---------[ END ]----------------------------------------------------------
241
#