PluginProbe
bbPress / 2.6.17
bbPress v2.6.17
2.6.17 trunk 2.0 2.0-beta-1 2.0-beta-2b 2.0-beta-3 2.0-beta-3b 2.0-rc-2 2.0-rc-3 2.0-rc-4 2.0-rc-5 2.0.1 2.0.2 2.0.3 2.1 2.1-beta-1 2.1-rc1 2.1-rc2 2.1-rc3 2.1-rc4 2.1.1 2.1.2 2.1.3 2.2 2.2.1 All 72 releases
bbpress / includes / admin / converters / SMF.php

SMF.php in bbPress 2.6.17, at includes/admin/converters/SMF.php

835 lines 24.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * bbPress SMF Converter
5 *
6 * @package bbPress
7 * @subpackage Converters
8 */
9
10 /**
11 * Implementation of SMF Forum converter.
12 *
13 * @since 2.5.0 bbPress (r5189)
14 *
15 * @link Codex Docs https://codex.bbpress.org/import-forums/smf
16 */
17 class SMF extends BBP_Converter_Base {
18
19 /**
20 * Main Constructor
21 *
22 */
23 public function __construct() {
24 parent::__construct();
25 }
26
27 /**
28 * Sets up the field mappings
29 */
30 public function setup_globals() {
31
32 // Setup smiley URL & path
33 $this->bbcode_parser_properties = array(
34 'smiley_url' => false,
35 'smiley_dir' => false
36 );
37
38 /** Forum Section ******************************************************/
39
40 // Old forum id (Stored in postmeta)
41 $this->field_map[] = array(
42 'from_tablename' => 'boards',
43 'from_fieldname' => 'id_board',
44 'to_type' => 'forum',
45 'to_fieldname' => '_bbp_old_forum_id'
46 );
47
48 // Forum parent id (If no parent, then 0, Stored in postmeta)
49 $this->field_map[] = array(
50 'from_tablename' => 'boards',
51 'from_fieldname' => 'id_parent',
52 'to_type' => 'forum',
53 'to_fieldname' => '_bbp_old_forum_parent_id'
54 );
55
56 // Forum topic count (Stored in postmeta)
57 $this->field_map[] = array(
58 'from_tablename' => 'boards',
59 'from_fieldname' => 'num_topics',
60 'to_type' => 'forum',
61 'to_fieldname' => '_bbp_topic_count'
62 );
63
64 // Forum reply count (Stored in postmeta)
65 $this->field_map[] = array(
66 'from_tablename' => 'boards',
67 'from_fieldname' => 'num_posts',
68 'to_type' => 'forum',
69 'to_fieldname' => '_bbp_reply_count'
70 );
71
72 // Forum total topic count (Stored in postmeta)
73 $this->field_map[] = array(
74 'from_tablename' => 'boards',
75 'from_fieldname' => 'num_topics',
76 'to_type' => 'forum',
77 'to_fieldname' => '_bbp_total_topic_count'
78 );
79
80 // Forum total reply count (Stored in postmeta)
81 $this->field_map[] = array(
82 'from_tablename' => 'boards',
83 'from_fieldname' => 'num_posts',
84 'to_type' => 'forum',
85 'to_fieldname' => '_bbp_total_reply_count'
86 );
87
88 // Forum title.
89 $this->field_map[] = array(
90 'from_tablename' => 'boards',
91 'from_fieldname' => 'name',
92 'to_type' => 'forum',
93 'to_fieldname' => 'post_title'
94 );
95
96 // Forum slug (Clean name to avoid conflicts)
97 $this->field_map[] = array(
98 'from_tablename' => 'boards',
99 'from_fieldname' => 'name',
100 'to_type' => 'forum',
101 'to_fieldname' => 'post_name',
102 'callback_method' => 'callback_slug'
103 );
104
105 // Forum description.
106 $this->field_map[] = array(
107 'from_tablename' => 'boards',
108 'from_fieldname' => 'description',
109 'to_type' => 'forum',
110 'to_fieldname' => 'post_content',
111 'callback_method' => 'callback_null'
112 );
113
114 // Forum display order (Starts from 1)
115 $this->field_map[] = array(
116 'from_tablename' => 'boards',
117 'from_fieldname' => 'board_order',
118 'to_type' => 'forum',
119 'to_fieldname' => 'menu_order'
120 );
121
122 // Forum type (Set a default value 'forum', Stored in postmeta)
123 $this->field_map[] = array(
124 'to_type' => 'forum',
125 'to_fieldname' => '_bbp_forum_type',
126 'default' => 'forum'
127 );
128
129 // Forum status (Set a default value 'open', Stored in postmeta)
130 $this->field_map[] = array(
131 'to_type' => 'forum',
132 'to_fieldname' => '_bbp_status',
133 'default' => 'open'
134 );
135
136 // Forum dates.
137 $this->field_map[] = array(
138 'to_type' => 'forum',
139 'to_fieldname' => 'post_date',
140 'default' => date( 'Y-m-d H:i:s' ) // phpcs:ignore WordPress.DateTime.RestrictedFunctions.date_date
141 );
142 $this->field_map[] = array(
143 'to_type' => 'forum',
144 'to_fieldname' => 'post_date_gmt',
145 'default' => date( 'Y-m-d H:i:s' ) // phpcs:ignore WordPress.DateTime.RestrictedFunctions.date_date
146 );
147 $this->field_map[] = array(
148 'to_type' => 'forum',
149 'to_fieldname' => 'post_modified',
150 'default' => date( 'Y-m-d H:i:s' ) // phpcs:ignore WordPress.DateTime.RestrictedFunctions.date_date
151 );
152 $this->field_map[] = array(
153 'to_type' => 'forum',
154 'to_fieldname' => 'post_modified_gmt',
155 'default' => date( 'Y-m-d H:i:s' ) // phpcs:ignore WordPress.DateTime.RestrictedFunctions.date_date
156 );
157
158 /** Forum Subscriptions Section ***************************************/
159
160 // Subscribed forum ID (Stored in usermeta)
161 $this->field_map[] = array(
162 'from_tablename' => 'log_notify',
163 'from_fieldname' => 'id_board',
164 'from_expression' => 'WHERE log_notify.id_board != 0',
165 'to_type' => 'forum_subscriptions',
166 'to_fieldname' => '_bbp_forum_subscriptions'
167 );
168
169 // Subscribed user ID (Stored in usermeta)
170 $this->field_map[] = array(
171 'from_tablename' => 'log_notify',
172 'from_fieldname' => 'id_member',
173 'from_expression' => 'WHERE log_notify.id_board != 0',
174 'to_type' => 'forum_subscriptions',
175 'to_fieldname' => 'user_id',
176 'callback_method' => 'callback_userid'
177 );
178
179 /** Topic Section ******************************************************/
180
181 // Old topic id (Stored in postmeta)
182 $this->field_map[] = array(
183 'from_tablename' => 'topics',
184 'from_fieldname' => 'id_topic',
185 'to_type' => 'topic',
186 'to_fieldname' => '_bbp_old_topic_id'
187 );
188
189 // Topic reply count (Stored in postmeta)
190 $this->field_map[] = array(
191 'from_tablename' => 'topics',
192 'from_fieldname' => 'num_replies',
193 'to_type' => 'topic',
194 'to_fieldname' => '_bbp_reply_count',
195 'callback_method' => 'callback_topic_reply_count'
196 );
197
198 // Topic total reply count (Includes unpublished replies, Stored in postmeta)
199 $this->field_map[] = array(
200 'from_tablename' => 'topics',
201 'from_fieldname' => 'num_replies',
202 'to_type' => 'topic',
203 'to_fieldname' => '_bbp_total_reply_count',
204 'callback_method' => 'callback_topic_reply_count'
205 );
206
207 // Topic parent forum id (If no parent, then 0. Stored in postmeta)
208 $this->field_map[] = array(
209 'from_tablename' => 'topics',
210 'from_fieldname' => 'id_board',
211 'to_type' => 'topic',
212 'to_fieldname' => '_bbp_forum_id',
213 'callback_method' => 'callback_forumid'
214 );
215
216 // Topic author.
217 $this->field_map[] = array(
218 'from_tablename' => 'topics',
219 'from_fieldname' => 'id_member_started',
220 'to_type' => 'topic',
221 'to_fieldname' => 'post_author',
222 'callback_method' => 'callback_userid'
223 );
224
225 // Topic author name (Stored in postmeta as _bbp_anonymous_name)
226 $this->field_map[] = array(
227 'from_tablename' => 'messages',
228 'from_fieldname' => 'poster_name',
229 'join_tablename' => 'topics',
230 'join_type' => 'LEFT',
231 'join_expression' => 'ON topics.id_first_msg = messages.id_msg',
232 'to_type' => 'topic',
233 'to_fieldname' => '_bbp_old_topic_author_name_id'
234 );
235
236 // Is the topic anonymous (Stored in postmeta)
237 $this->field_map[] = array(
238 'from_tablename' => 'topics',
239 'from_fieldname' => 'id_member_started',
240 'to_type' => 'topic',
241 'to_fieldname' => '_bbp_old_is_topic_anonymous_id',
242 'callback_method' => 'callback_check_anonymous'
243 );
244
245 // Topic Author ip (Stored in postmeta)
246 $this->field_map[] = array(
247 'from_tablename' => 'messages',
248 'from_fieldname' => 'poster_ip',
249 'join_tablename' => 'topics',
250 'join_type' => 'LEFT',
251 'join_expression' => 'ON topics.id_first_msg = messages.id_msg',
252 'to_type' => 'topic',
253 'to_fieldname' => '_bbp_author_ip'
254 );
255
256 // Topic content.
257 // Note: We join the 'messages' table because 'topics' table does not have content.
258 $this->field_map[] = array(
259 'from_tablename' => 'messages',
260 'from_fieldname' => 'body',
261 'join_tablename' => 'topics',
262 'join_type' => 'LEFT',
263 'join_expression' => 'ON topics.id_first_msg = messages.id_msg',
264 'to_type' => 'topic',
265 'to_fieldname' => 'post_content',
266 'callback_method' => 'callback_html'
267 );
268
269 // Topic title.
270 $this->field_map[] = array(
271 'from_tablename' => 'messages',
272 'from_fieldname' => 'subject',
273 'join_tablename' => 'topics',
274 'join_type' => 'LEFT',
275 'join_expression' => 'ON topics.id_first_msg = messages.id_msg',
276 'to_type' => 'topic',
277 'to_fieldname' => 'post_title'
278 );
279
280 // Topic slug (Clean name to avoid conflicts)
281 $this->field_map[] = array(
282 'from_tablename' => 'messages',
283 'from_fieldname' => 'subject',
284 'join_tablename' => 'topics',
285 'join_type' => 'LEFT',
286 'join_expression' => 'ON topics.id_first_msg = messages.id_msg',
287 'to_type' => 'topic',
288 'to_fieldname' => 'post_name',
289 'callback_method' => 'callback_slug'
290 );
291
292 // Topic parent forum id (If no parent, then 0)
293 $this->field_map[] = array(
294 'from_tablename' => 'topics',
295 'from_fieldname' => 'id_board',
296 'to_type' => 'topic',
297 'to_fieldname' => 'post_parent',
298 'callback_method' => 'callback_forumid'
299 );
300
301 // Topic status (Open or Closed, SMF v2.0.4 0=open & 1=closed)
302 $this->field_map[] = array(
303 'from_tablename' => 'topics',
304 'from_fieldname' => 'locked',
305 'to_type' => 'topic',
306 'to_fieldname' => '_bbp_old_closed_status_id',
307 'callback_method' => 'callback_topic_status'
308 );
309
310 // Sticky status (Stored in postmeta)
311 $this->field_map[] = array(
312 'from_tablename' => 'topics',
313 'from_fieldname' => 'is_sticky',
314 'to_type' => 'topic',
315 'to_fieldname' => '_bbp_old_sticky_status_id',
316 'callback_method' => 'callback_sticky_status'
317 );
318
319 // Topic dates.
320 $this->field_map[] = array(
321 'from_tablename' => 'messages',
322 'from_fieldname' => 'poster_time',
323 'join_tablename' => 'topics',
324 'join_type' => 'LEFT',
325 'join_expression' => 'ON topics.id_first_msg = messages.id_msg',
326 'to_type' => 'topic',
327 'to_fieldname' => 'post_date',
328 'callback_method' => 'callback_datetime'
329 );
330 $this->field_map[] = array(
331 'from_tablename' => 'messages',
332 'from_fieldname' => 'poster_time',
333 'join_tablename' => 'topics',
334 'join_type' => 'LEFT',
335 'join_expression' => 'ON topics.id_first_msg = messages.id_msg',
336 'to_type' => 'topic',
337 'to_fieldname' => 'post_date_gmt',
338 'callback_method' => 'callback_datetime'
339 );
340 $this->field_map[] = array(
341 'from_tablename' => 'messages',
342 'from_fieldname' => 'poster_time',
343 'join_tablename' => 'topics',
344 'join_type' => 'LEFT',
345 'join_expression' => 'ON topics.id_first_msg = messages.id_msg',
346 'to_type' => 'topic',
347 'to_fieldname' => 'post_modified',
348 'callback_method' => 'callback_datetime'
349 );
350 $this->field_map[] = array(
351 'from_tablename' => 'messages',
352 'from_fieldname' => 'poster_time',
353 'join_tablename' => 'topics',
354 'join_type' => 'LEFT',
355 'join_expression' => 'ON topics.id_first_msg = messages.id_msg',
356 'to_type' => 'topic',
357 'to_fieldname' => 'post_modified_gmt',
358 'callback_method' => 'callback_datetime'
359 );
360 $this->field_map[] = array(
361 'from_tablename' => 'messages',
362 'from_fieldname' => 'poster_time',
363 'join_tablename' => 'topics',
364 'join_type' => 'LEFT',
365 'join_expression' => 'ON topics.id_first_msg = messages.id_msg',
366 'to_type' => 'topic',
367 'to_fieldname' => '_bbp_last_active_time',
368 'callback_method' => 'callback_datetime'
369 );
370
371 /** Tags Section ******************************************************/
372
373 /**
374 * SMF v2.0.4 Forums do not support topic tags out of the box
375 */
376
377 /** Topic Subscriptions Section ***************************************/
378
379 // Subscribed topic ID (Stored in usermeta)
380 $this->field_map[] = array(
381 'from_tablename' => 'log_notify',
382 'from_fieldname' => 'id_topic',
383 'from_expression' => 'WHERE log_notify.id_topic != 0',
384 'to_type' => 'topic_subscriptions',
385 'to_fieldname' => '_bbp_subscriptions'
386 );
387
388 // Subscribed user ID (Stored in usermeta)
389 $this->field_map[] = array(
390 'from_tablename' => 'log_notify',
391 'from_fieldname' => 'id_member',
392 'from_expression' => 'WHERE log_notify.id_topic != 0',
393 'to_type' => 'topic_subscriptions',
394 'to_fieldname' => 'user_id',
395 'callback_method' => 'callback_userid'
396 );
397
398 /** Reply Section *****************************************************/
399
400 // Old reply id (Stored in postmeta)
401 $this->field_map[] = array(
402 'from_tablename' => 'messages',
403 'from_fieldname' => 'id_msg',
404 'to_type' => 'reply',
405 'to_fieldname' => '_bbp_old_reply_id'
406 );
407
408 // Reply parent forum id (If no parent, then 0. Stored in postmeta)
409 $this->field_map[] = array(
410 'from_tablename' => 'topics',
411 'from_fieldname' => 'id_board',
412 'join_tablename' => 'messages',
413 'join_type' => 'LEFT',
414 'join_expression' => 'USING (id_topic) WHERE topics.id_first_msg != messages.id_msg',
415 'to_type' => 'reply',
416 'to_fieldname' => '_bbp_forum_id',
417 'callback_method' => 'callback_topicid_to_forumid'
418 );
419
420 // Reply parent topic id (If no parent, then 0. Stored in postmeta)
421 $this->field_map[] = array(
422 'from_tablename' => 'messages',
423 'from_fieldname' => 'id_topic',
424 'to_type' => 'reply',
425 'to_fieldname' => '_bbp_topic_id',
426 'callback_method' => 'callback_topicid'
427 );
428
429 // Reply author ip (Stored in postmeta)
430 $this->field_map[] = array(
431 'from_tablename' => 'messages',
432 'from_fieldname' => 'poster_ip',
433 'to_type' => 'reply',
434 'to_fieldname' => '_bbp_author_ip'
435 );
436
437 // Reply author.
438 $this->field_map[] = array(
439 'from_tablename' => 'messages',
440 'from_fieldname' => 'id_member',
441 'to_type' => 'reply',
442 'to_fieldname' => 'post_author',
443 'callback_method' => 'callback_userid'
444 );
445
446 // Reply author name (Stored in postmeta as _bbp_anonymous_name)
447 $this->field_map[] = array(
448 'from_tablename' => 'messages',
449 'from_fieldname' => 'poster_name',
450 'to_type' => 'reply',
451 'to_fieldname' => '_bbp_old_reply_author_name_id'
452 );
453
454 // Is the reply anonymous (Stored in postmeta)
455 $this->field_map[] = array(
456 'from_tablename' => 'messages',
457 'from_fieldname' => 'id_member',
458 'to_type' => 'reply',
459 'to_fieldname' => '_bbp_old_is_reply_anonymous_id',
460 'callback_method' => 'callback_check_anonymous'
461 );
462
463 // Reply content.
464 $this->field_map[] = array(
465 'from_tablename' => 'messages',
466 'from_fieldname' => 'body',
467 'to_type' => 'reply',
468 'to_fieldname' => 'post_content',
469 'callback_method' => 'callback_html'
470 );
471
472 // Reply parent topic id (If no parent, then 0)
473 $this->field_map[] = array(
474 'from_tablename' => 'messages',
475 'from_fieldname' => 'id_topic',
476 'to_type' => 'reply',
477 'to_fieldname' => 'post_parent',
478 'callback_method' => 'callback_topicid'
479 );
480
481 // Reply dates.
482 $this->field_map[] = array(
483 'from_tablename' => 'messages',
484 'from_fieldname' => 'poster_time',
485 'to_type' => 'reply',
486 'to_fieldname' => 'post_date',
487 'callback_method' => 'callback_datetime'
488 );
489 $this->field_map[] = array(
490 'from_tablename' => 'messages',
491 'from_fieldname' => 'poster_time',
492 'to_type' => 'reply',
493 'to_fieldname' => 'post_date_gmt',
494 'callback_method' => 'callback_datetime'
495 );
496 $this->field_map[] = array(
497 'from_tablename' => 'messages',
498 'from_fieldname' => 'poster_time',
499 'to_type' => 'reply',
500 'to_fieldname' => 'post_modified',
501 'callback_method' => 'callback_datetime'
502 );
503 $this->field_map[] = array(
504 'from_tablename' => 'messages',
505 'from_fieldname' => 'poster_time',
506 'to_type' => 'reply',
507 'to_fieldname' => 'post_modified_gmt',
508 'callback_method' => 'callback_datetime'
509 );
510
511 /** User Section ******************************************************/
512
513 // Store old user id (Stored in usermeta)
514 $this->field_map[] = array(
515 'from_tablename' => 'members',
516 'from_fieldname' => 'id_member',
517 'to_type' => 'user',
518 'to_fieldname' => '_bbp_old_user_id'
519 );
520
521 // Store old user password (Stored in usermeta serialized with salt)
522 $this->field_map[] = array(
523 'from_tablename' => 'members',
524 'from_fieldname' => 'passwd',
525 'to_type' => 'user',
526 'to_fieldname' => '_bbp_password',
527 'callback_method' => 'callback_savepass'
528 );
529
530 // User password verify class (Stored in usermeta for verifying password)
531 $this->field_map[] = array(
532 'to_type' => 'user',
533 'to_fieldname' => '_bbp_class',
534 'default' => 'SMF'
535 );
536
537 // User name.
538 $this->field_map[] = array(
539 'from_tablename' => 'members',
540 'from_fieldname' => 'member_name',
541 'to_type' => 'user',
542 'to_fieldname' => 'user_login'
543 );
544
545 // User nice name.
546 $this->field_map[] = array(
547 'from_tablename' => 'members',
548 'from_fieldname' => 'member_name',
549 'to_type' => 'user',
550 'to_fieldname' => 'user_nicename'
551 );
552
553 // User email.
554 $this->field_map[] = array(
555 'from_tablename' => 'members',
556 'from_fieldname' => 'email_address',
557 'to_type' => 'user',
558 'to_fieldname' => 'user_email'
559 );
560
561 // User homepage.
562 $this->field_map[] = array(
563 'from_tablename' => 'members',
564 'from_fieldname' => 'website_url',
565 'to_type' => 'user',
566 'to_fieldname' => 'user_url'
567 );
568
569 // User registered.
570 $this->field_map[] = array(
571 'from_tablename' => 'members',
572 'from_fieldname' => 'date_registered',
573 'to_type' => 'user',
574 'to_fieldname' => 'user_registered',
575 'callback_method' => 'callback_datetime'
576 );
577
578 // User display name.
579 $this->field_map[] = array(
580 'from_tablename' => 'members',
581 'from_fieldname' => 'real_name',
582 'to_type' => 'user',
583 'to_fieldname' => 'display_name'
584 );
585
586 // User AIM (Stored in usermeta)
587 $this->field_map[] = array(
588 'from_tablename' => 'members',
589 'from_fieldname' => 'aim',
590 'to_type' => 'user',
591 'to_fieldname' => '_bbp_smf_user_aim'
592 );
593
594 // User Yahoo (Stored in usermeta)
595 $this->field_map[] = array(
596 'from_tablename' => 'members',
597 'from_fieldname' => 'yim',
598 'to_type' => 'user',
599 'to_fieldname' => '_bbp_smf_user_yim'
600 );
601
602 // Store ICQ (Stored in usermeta)
603 $this->field_map[] = array(
604 'from_tablename' => 'members',
605 'from_fieldname' => 'icq',
606 'to_type' => 'user',
607 'to_fieldname' => '_bbp_smf_user_icq'
608 );
609
610 // Store MSN (Stored in usermeta)
611 $this->field_map[] = array(
612 'from_tablename' => 'members',
613 'from_fieldname' => 'msn',
614 'to_type' => 'user',
615 'to_fieldname' => '_bbp_smf_user_msn'
616 );
617
618 // Store Signature (Stored in usermeta)
619 $this->field_map[] = array(
620 'from_tablename' => 'members',
621 'from_fieldname' => 'signature',
622 'to_type' => 'user',
623 'to_fieldname' => '_bbp_smf_user_sig',
624 'callback_method' => 'callback_html'
625 );
626
627 // Store Avatar (Stored in usermeta)
628 $this->field_map[] = array(
629 'from_tablename' => 'members',
630 'from_fieldname' => 'avatar',
631 'to_type' => 'user',
632 'to_fieldname' => '_bbp_smf_user_avatar',
633 'callback_method' => 'callback_html'
634 );
635
636 // Store Location (Stored in usermeta)
637 $this->field_map[] = array(
638 'from_tablename' => 'members',
639 'from_fieldname' => 'location',
640 'to_type' => 'user',
641 'to_fieldname' => '_bbp_smf_user_location',
642 'callback_method' => 'callback_html'
643 );
644
645 // Store Personal Text (Stored in usermeta)
646 $this->field_map[] = array(
647 'from_tablename' => 'members',
648 'from_fieldname' => 'personal_text',
649 'to_type' => 'user',
650 'to_fieldname' => '_bbp_smf_user_personal_text',
651 'callback_method' => 'callback_html'
652 );
653 }
654
655 /**
656 * This method allows us to indicates what is or is not converted for each
657 * converter.
658 */
659 public function info() {
660 return '';
661 }
662
663 /**
664 * This method is to save the salt and password together. That
665 * way when we authenticate it we can get it out of the database
666 * as one value. Array values are auto sanitized by WordPress.
667 */
668 public function callback_savepass( $field, $row ) {
669 $pass_array = array(
670 'hash' => $field,
671 'username' => $row['member_name']
672 );
673
674 return $pass_array;
675 }
676
677 /**
678 * This method is to take the pass out of the database and compare
679 * to a pass the user has typed in.
680 */
681 public function authenticate_pass( $password, $serialized_pass ) {
682
683 // Unserialize the password, with safeguards
684 $pass_array = unserialize(
685 $serialized_pass,
686 array(
687 'allowed_classes' => false,
688 'max_depth' => 1
689 )
690 );
691
692 // Bail if missing values
693 if ( ! is_array( $pass_array ) || ! isset( $pass_array['hash'], $pass_array['username'] ) ) {
694 return false;
695 }
696
697 // Return comparison
698 return hash_equals(
699 $pass_array['hash'],
700 sha1( strtolower( $pass_array['username'] ) . $password )
701 );
702 }
703
704 /**
705 * Translate the post status from SMF v2.0.4 numerics to WordPress's strings.
706 *
707 * @param int $status SMF v2.0.4 numeric topic status
708 * @return string WordPress safe
709 */
710 public function callback_topic_status( $status = 0 ) {
711 switch ( $status ) {
712 case 1 :
713 $status = 'closed';
714 break;
715
716 case 0 :
717 default :
718 $status = 'publish';
719 break;
720 }
721 return $status;
722 }
723
724 /**
725 * Translate the topic sticky status type from SMF v2.0.4 numerics to WordPress's strings.
726 *
727 * @param int $status SMF v2.0.4 numeric forum type
728 * @return string WordPress safe
729 */
730 public function callback_sticky_status( $status = 0 ) {
731 switch ( $status ) {
732 case 1 :
733 $status = 'sticky'; // SMF Sticky 'is_sticky = 1'
734 break;
735
736 case 0 :
737 default :
738 $status = 'normal'; // SMF normal topic 'is_sticky = 0'
739 break;
740 }
741 return $status;
742 }
743
744 /**
745 * Verify the topic/reply count.
746 *
747 * @param int $count SMF v2.0.4 topic/reply counts
748 * @return string WordPress safe
749 */
750 public function callback_topic_reply_count( $count = 1 ) {
751 $count = absint( (int) $count - 1 );
752 return $count;
753 }
754
755 /**
756 * This callback processes any custom parser.php attributes and custom code with preg_replace
757 */
758 protected function callback_html( $field ) {
759
760 // Strips SMF custom HTML first from $field before parsing $field to parser.php
761 $smf_markup = $field;
762 $smf_markup = html_entity_decode( $smf_markup );
763
764 // Replace '[quote]' with '<blockquote>'
765 $smf_markup = preg_replace( '/\[quote\]/', '<blockquote>', $smf_markup );
766 // Replace '[quote ($1)]' with '<blockquote>"
767 $smf_markup = preg_replace( '/\[quote (.*?)\]/', '<blockquote>', $smf_markup );
768 // Replace '[/quote]' with '</blockquote>'
769 $smf_markup = preg_replace( '/\[\/quote\]/', '</blockquote>', $smf_markup );
770
771 // Replace '[glow]' with ''
772 $smf_markup = preg_replace( '/\[glow\]/', '', $smf_markup );
773 // Replace '[glow]' with ''
774 $smf_markup = preg_replace( '/\[glow=(.*?)\]/', '', $smf_markup );
775 // Replace '[/glow]' with ''
776 $smf_markup = preg_replace( '/\[\/glow\]/', '', $smf_markup );
777
778 // Replace '[shadow]' with ''
779 $smf_markup = preg_replace( '/\[shadow\]/', '', $smf_markup );
780 // Replace '[shadow]' with ''
781 $smf_markup = preg_replace( '/\[shadow=(.*?)\]/', '', $smf_markup );
782 // Replace '[/shadow]' with ''
783 $smf_markup = preg_replace( '/\[\/shadow\]/', '', $smf_markup );
784
785 // Replace '[move]' with ''
786 $smf_markup = preg_replace( '/\[move\]/', '', $smf_markup );
787 // Replace '[/move]' with ''
788 $smf_markup = preg_replace( '/\[\/move\]/', '', $smf_markup );
789
790 // Replace '[table]' with '<table>'
791 $smf_markup = preg_replace( '/\[table\]/', '<table>', $smf_markup );
792 // Replace '[/table]' with '</table>'
793 $smf_markup = preg_replace( '/\[\/table\]/', '</table>', $smf_markup );
794 // Replace '[tr]' with '<tr>'
795 $smf_markup = preg_replace( '/\[tr\]/', '<tr>', $smf_markup );
796 // Replace '[/tr]' with '</tr>'
797 $smf_markup = preg_replace( '/\[\/tr\]/', '</tr>', $smf_markup );
798 // Replace '[td]' with '<td>'
799 $smf_markup = preg_replace( '/\[td\]/', '<td>', $smf_markup );
800 // Replace '[/td]' with '</td>'
801 $smf_markup = preg_replace( '/\[\/td\]/', '</td>', $smf_markup );
802
803 // Replace '[list]' with '<ul>'
804 $smf_markup = preg_replace( '/\[list\]/', '<ul>', $smf_markup );
805 // Replace '[liist type=decimal]' with '<ol type="a">'
806 $smf_markup = preg_replace( '/\[list\ type=decimal\]/', '<ol type="a">', $smf_markup );
807 // Replace '[li]' with '<li>'
808 $smf_markup = preg_replace( '/\[li\]/', '<li>', $smf_markup );
809 // Replace '[/li]' with '</li>'
810 $smf_markup = preg_replace( '/\[\/li\]/', '</li>', $smf_markup );
811
812 // Replace '[tt]' with '<tt>'
813 $smf_markup = preg_replace( '/\[tt\]/', '<tt>', $smf_markup );
814 // Replace '[/tt]' with '</tt>'
815 $smf_markup = preg_replace( '/\[\/tt\]/', '</tt>', $smf_markup );
816
817 // Replace '<br />' with '<br>'
818 $smf_markup = preg_replace( '/\<br \/\>/', '<br>', $smf_markup );
819
820 // Replace '[size=$1]' with '<span style="font-size:$1%;">$3</span>'
821 $smf_markup = preg_replace( '/\[size=(.*?)\]/', '<span style="font-size:$1">', $smf_markup );
822 // Replace '[/size]' with '</span>'
823 $smf_markup = preg_replace( '/\[\/size\]/', '</span>', $smf_markup );
824
825 // Replace non-break space '&nbsp;' with space ' '
826 $smf_markup = preg_replace( '/&nbsp;/', ' ', $smf_markup );
827
828 // Now that SMF custom HTML has been stripped put the cleaned HTML back in $field
829 $field = $smf_markup;
830
831 // Parse out any bbCodes in $field with the BBCode 'parser.php'
832 return parent::callback_html( $field );
833 }
834 }
835