SMF

Implementation of SMF Forum converter.

Defined (1)

The class is defined in the following location(s).

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