Ticket #1884: 1884.2.diff
File 1884.2.diff, 12.4 KB (added by , 8 years ago) |
---|
-
bbPress/admin/converters/phpBB.php
diff --git a/bbPress/admin/converters/phpBB.php b/bbPress/admin/converters/phpBB.php index 8f3a03c..1b5e020 100644
a b 1 1 <?php 2 2 3 3 /** 4 * Implementation of phpBB converter. 4 * phpBB v3 converter 5 * 6 * @since bbPress (r) 5 7 */ 6 8 class phpBB extends BBP_Converter_Base { 9 10 /** 11 * Main Constructor 12 * 13 * @uses phpBB::setup_globals() 14 */ 7 15 function __construct() { 8 16 parent::__construct(); 9 17 $this->setup_globals(); 10 18 } 11 19 20 /** 21 * Sets up the field mappings 22 */ 12 23 public function setup_globals() { 13 24 14 25 /** Forum Section ******************************************************/ 15 26 16 // Forum id . Stored in postmeta.27 // Forum id (Stored in postmeta) 17 28 $this->field_map[] = array( 18 29 'from_tablename' => 'forums', 19 30 'from_fieldname' => 'forum_id', … … class phpBB extends BBP_Converter_Base { 21 32 'to_fieldname' => '_bbp_forum_id' 22 33 ); 23 34 24 // Forum parent id . If no parent, than 0. Stored in postmeta.35 // Forum parent id (If no parent, than 0, Stored in postmeta) 25 36 $this->field_map[] = array( 26 37 'from_tablename' => 'forums', 27 38 'from_fieldname' => 'parent_id', 28 39 'to_type' => 'forum', 29 'to_fieldname' => '_bbp_ parent_id'40 'to_fieldname' => '_bbp_forum_parent_id' 30 41 ); 31 42 32 43 // Forum title. … … class phpBB extends BBP_Converter_Base { 37 48 'to_fieldname' => 'post_title' 38 49 ); 39 50 40 // Forum slug . Clean name.51 // Forum slug (Clean name to avoid conflicts) 41 52 $this->field_map[] = array( 42 53 'from_tablename' => 'forums', 43 54 'from_fieldname' => 'forum_name', … … class phpBB extends BBP_Converter_Base { 55 66 'callback_method' => 'callback_null' 56 67 ); 57 68 58 // Forum display order . Starts from 1.69 // Forum display order (Starts from 1) 59 70 $this->field_map[] = array( 60 71 'from_tablename' => 'forums', 61 72 'from_fieldname' => 'display_on_index', … … class phpBB extends BBP_Converter_Base { 87 98 88 99 /** Topic Section ******************************************************/ 89 100 90 // Topic id . Stored in postmeta.101 // Topic id (Stored in postmeta) 91 102 $this->field_map[] = array( 92 103 'from_tablename' => 'topics', 93 104 'from_fieldname' => 'topic_id', … … class phpBB extends BBP_Converter_Base { 95 106 'to_fieldname' => '_bbp_topic_id' 96 107 ); 97 108 98 // Forum id . Stored in postmeta.109 // Forum id (Stored in postmeta) 99 110 $this->field_map[] = array( 100 111 'from_tablename' => 'topics', 101 112 'from_fieldname' => 'forum_id', … … class phpBB extends BBP_Converter_Base { 114 125 ); 115 126 116 127 // Topic content. 128 // Note: We join the posts table because topics do not have content. 117 129 $this->field_map[] = array( 118 130 'from_tablename' => 'posts', 119 131 'from_fieldname' => 'post_text', … … class phpBB extends BBP_Converter_Base { 133 145 'to_fieldname' => 'post_title' 134 146 ); 135 147 136 // Topic slug . Clean name.148 // Topic slug (Clean name to avoid conflicts) 137 149 $this->field_map[] = array( 138 150 'from_tablename' => 'topics', 139 151 'from_fieldname' => 'topic_title', … … class phpBB extends BBP_Converter_Base { 142 154 'callback_method' => 'callback_slug' 143 155 ); 144 156 145 // Forum id . If no parent, than 0.157 // Forum id (If no parent, than 0) 146 158 $this->field_map[] = array( 147 159 'from_tablename' => 'topics', 148 160 'from_fieldname' => 'forum_id', … … class phpBB extends BBP_Converter_Base { 190 202 'callback_method' => 'callback_topic_status' 191 203 ); 192 204 193 /** Tags Section ****************************************************** /205 /** Tags Section *******************************************************/ 194 206 /* 195 207 // Topic id. 196 208 $this->field_map[] = array( … … class phpBB extends BBP_Converter_Base { 213 225 ); 214 226 */ 215 227 216 /** PostSection ******************************************************/228 /** Reply Section ******************************************************/ 217 229 218 // Post id . Stored in postmeta.230 // Post id (Stored in postmeta) 219 231 $this->field_map[] = array( 220 232 'from_tablename' => 'posts', 221 233 'from_fieldname' => 'post_id', … … class phpBB extends BBP_Converter_Base { 233 245 'to_type' => 'reply' 234 246 ); 235 247 236 // Forum id . Stored in postmeta.248 // Forum id (Stored in postmeta) 237 249 $this->field_map[] = array( 238 250 'from_tablename' => 'posts', 239 251 'from_fieldname' => 'forum_id', … … class phpBB extends BBP_Converter_Base { 242 254 'callback_method' => 'callback_topicid_to_forumid' 243 255 ); 244 256 245 // Topic id . Stored in postmeta.257 // Topic id (Stored in postmeta) 246 258 $this->field_map[] = array( 247 259 'from_tablename' => 'posts', 248 260 'from_fieldname' => 'topic_id', … … class phpBB extends BBP_Converter_Base { 251 263 'callback_method' => 'callback_topicid' 252 264 ); 253 265 254 // Author ip . Stored in postmeta.266 // Author ip (Stored in postmeta) 255 267 $this->field_map[] = array( 256 268 'from_tablename' => 'posts', 257 269 'from_fieldname' => 'poster_ip', … … class phpBB extends BBP_Converter_Base { 276 288 'to_fieldname' => 'post_title' 277 289 ); 278 290 279 // Topic slug . Clean name.291 // Topic slug (Clean name to avoid conflicts) 280 292 $this->field_map[] = array( 281 293 'from_tablename' => 'posts', 282 294 'from_fieldname' => 'post_subject', … … class phpBB extends BBP_Converter_Base { 294 306 'callback_method' => 'callback_html' 295 307 ); 296 308 297 // Topic id . If no parent, than 0.309 // Topic id (If no parent, than 0) 298 310 $this->field_map[] = array( 299 311 'from_tablename' => 'posts', 300 312 'from_fieldname' => 'topic_id', … … class phpBB extends BBP_Converter_Base { 335 347 336 348 /** User Section ******************************************************/ 337 349 338 // Store old User id . Stored in usermeta.350 // Store old User id (Stored in usermeta) 339 351 $this->field_map[] = array( 340 352 'from_tablename' => 'users', 341 353 'from_fieldname' => 'user_id', … … class phpBB extends BBP_Converter_Base { 343 355 'to_fieldname' => '_bbp_user_id' 344 356 ); 345 357 346 // Store old User password . Stored in usermeta serialized with salt.358 // Store old User password (Stored in usermeta serialized with salt) 347 359 $this->field_map[] = array( 348 360 'from_tablename' => 'users', 349 361 'from_fieldname' => 'user_password', … … class phpBB extends BBP_Converter_Base { 352 364 'callback_method' => 'callback_savepass' 353 365 ); 354 366 355 // Store old User Salt . This is only used for the SELECT row info for the above password save367 // Store old User Salt (This is only used for the SELECT row info for the above password save) 356 368 $this->field_map[] = array( 357 369 'from_tablename' => 'users', 358 370 'from_fieldname' => 'user_form_salt', … … class phpBB extends BBP_Converter_Base { 360 372 'to_fieldname' => '' 361 373 ); 362 374 363 // User password verify class . Stored in usermeta for verifying password.375 // User password verify class (Stored in usermeta for verifying password) 364 376 $this->field_map[] = array( 365 377 'to_type' => 'user', 366 378 'to_fieldname' => '_bbp_class', … … class phpBB extends BBP_Converter_Base { 563 575 } 564 576 return $status; 565 577 } 566 } 578 579 /** 580 * This callback processes any custom parser.php attributes and custom code with preg_replace 581 */ 582 protected function callback_html( $field ) { 583 584 // Parse out bbCodes 585 require_once( bbpress()->admin->admin_dir . 'parser.php' ); 586 $bbcode = BBCode::getInstance(); 587 $bbcode->enable_smileys = false; 588 $bbcode->smiley_regex = false; 589 $field = html_entity_decode( $bbcode->Parse( $field ) ); 590 591 // Replace phpBB 'magic_url' and 'bbcode_uid' with SimplePress smilies with the equivelant WordPress 592 593 // Replace '[b:XXXXXXX]' with '<strong>' 594 $phpbb_uid = preg_replace ( '/\[b:(.*?)\]/' , '<strong>' , $phpbb_uid ); 595 // Replace '[/b:XXXXXXX]' with '</strong>' 596 $phpbb_uid = preg_replace ( '/\[\/b:(.*?)\]/' , '</strong>' , $phpbb_uid ); 597 598 // Replace '[i:XXXXXXX]' with '<em>' 599 $phpbb_uid = preg_replace ( '/\[i:(.*?)\]/' , '<em>' , $phpbb_uid ); 600 // Replace '[/i:XXXXXXX]' with '</em>' 601 $phpbb_uid = preg_replace ( '/\[\/i:(.*?)\]/' , '</em>' , $phpbb_uid ); 602 603 // Replace '[u:XXXXXXX]' with '<u>' 604 $phpbb_uid = preg_replace ( '/\[u:(.*?)\]/' , '<u>' , $phpbb_uid ); 605 // Replace '[/u:XXXXXXX]' with '</u>' 606 $phpbb_uid = preg_replace ( '/\[\/u:(.*?)\]/' , '</u>' , $phpbb_uid ); 607 608 // Replace '[quote:XXXXXXX]' with '<blockquote>' 609 $phpbb_uid = preg_replace ( '/\[quote:(.*?)\]/' , '<blockquote>' , $phpbb_uid ); 610 // Replace '[quote="$1"]' with '<em>$1 wrote:</em><blockquote>" 611 $phpbb_uid = preg_replace ( '/\[quote="(.*?)":(.*?)\]/' , '<em>$1 wrote:</em><blockquote>' , $phpbb_uid ); 612 // Replace '[/quote:XXXXXXX]' with '</blockquote>' 613 $phpbb_uid = preg_replace ( '/\[\/quote:(.*?)\]/' , '</blockquote>' , $phpbb_uid ); 614 615 // Replace '[img:XXXXXXX]' with '<img src="' 616 $phpbb_uid = preg_replace ( '/\[img:(.*?)\]/' , '<img src="' , $phpbb_uid ); 617 // Replace '[/img:XXXXXXX]' with ' alt="">' 618 $phpbb_uid = preg_replace ( '/\[\/img:(.*?)\]/' , '" alt="">' , $phpbb_uid ); 619 620 // Replace '<!-- s$1 --><img src=\"{SMILIES_PATH}$2 -->' with '$1' 621 $phpbb_uid = preg_replace ( '/<!-- s(.*?) --><img src=\"{SMILIES_PATH}(.*?)-->/' , '$1' , $phpbb_uid ); 622 623 // Replace '<!-- m --><a class="postlink" href="$1">$1</a><!-- m -->' with '$1' 624 $phpbb_uid = preg_replace ( '/\<!-- m --\>\<a class="postlink" href="([^\[]+?)"\>([^\[]+?)\<\/a\>\<!-- m --\>/' , '$1' , $phpbb_uid ); 625 626 // Replace '[url:XXXXXXX]$1[/url:XXXXXXX]' with '<a href="http://$1">$1</a>' 627 $phpbb_uid = preg_replace ( '/\[url:(?:[^\]]+)\]([^\[]+?)\[\/url:(?:[^\]]+)\]/' , '<a href="http://$1">$1</a>' , $phpbb_uid ); 628 // Replace '[url=http://$1:XXXXXXX]$3[/url:XXXXXXX]' with '<a href="http://$1">$3</a>' 629 $phpbb_uid = preg_replace ( '/\[url\=http\:\/\/(.*?)\:(.*?)\](.*?)\[\/url:(.*?)\]/i' , '<a href="http://$1">$3</a>' , $phpbb_uid ); 630 // Replace '[url=https://$1:XXXXXXX]$3[/url:XXXXXXX]' with '<a href="http://$1">$3</a>' 631 $phpbb_uid = preg_replace ( '/\[url\=https\:\/\/(.*?)\:(.*?)\](.*?)\[\/url:(.*?)\]/i' , '<a href="https://$1">$3</a>' , $phpbb_uid ); 632 633 // Replace '[email:XXXXXXX]' with '<a href="mailto:$2">$2</a>' 634 $phpbb_uid = preg_replace ( '/\[email:(.*?)\](.*?)\[\/email:(.*?)\]/' , '<a href="mailto:$2">$2</a>' , $phpbb_uid ); 635 636 // Replace '[code:XXXXXXX]' with '<pre><code>' 637 $phpbb_uid = preg_replace ( '/\[code:(.*?)\]/' , '<pre><code>' , $phpbb_uid ); 638 // Replace '[/code:XXXXXXX]' with '</code></pre>' 639 $phpbb_uid = preg_replace ( '/\[\/code:(.*?)\]/' , '</code></pre>' , $phpbb_uid ); 640 641 // Replace '[color=$1:XXXXXXXX]' with '<span style="color:$1">' 642 $phpbb_uid = preg_replace ( '/\[color=(.*?):(.*?)\]/' , '<span style="color:$1">' , $phpbb_uid ); 643 // Replace '[/color:XXXXXXX]' with '</span>' 644 $phpbb_uid = preg_replace ( '/\[\/color:(.*?)\]/' , '</span>' , $phpbb_uid ); 645 646 // Replace '[size=$1:XXXXXXXX]' with '<span style="font-size:$1%;">$3</span>' 647 $phpbb_uid = preg_replace ( '/\[size=(.*?):(.*?)\]/' , '<span style="font-size:$1%;">' , $phpbb_uid ); 648 // Replace '[/size:XXXXXXX]' with '' 649 $phpbb_uid = preg_replace ( '/\[\/size:(.*?)\]/' , '</span>' , $phpbb_uid ); 650 651 // Replace '[list:XXXXXXX]' with '<ul>' 652 $phpbb_uid = preg_replace ( '/\[list:(.*?)\]/' , '<ul>' , $phpbb_uid ); 653 // Replace '[list=a:XXXXXXX]' with '<ol type="a">' 654 $phpbb_uid = preg_replace ( '/\[list=a:(.*?)\]/' , '<ol type="a">' , $phpbb_uid ); 655 // Replace '[list=1:XXXXXXX]' with '<ol>' 656 $phpbb_uid = preg_replace ( '/\[list=1:(.*?)\]/' , '<ol>' , $phpbb_uid ); 657 // Replace '[*:XXXXXXX]' with '<li>' 658 $phpbb_uid = preg_replace ( '/\[\*:(.*?)\]/' , '<li>' , $phpbb_uid ); 659 // Replace '[/*:m:XXXXXXX]' with '</li>' 660 $phpbb_uid = preg_replace ( '/\[\/\*:m:(.*?)\]/' , '</li>' , $phpbb_uid ); 661 // Replace '[/list:u:XXXXXXX]' with '</ul>' 662 $phpbb_uid = preg_replace ( '/\[\/list:u:(.*?)\]/' , '</ul>' , $phpbb_uid ); 663 // Replace '[/list:o:XXXXXXX]' with '</ol>' 664 $phpbb_uid = preg_replace ( '/\[\/list:o:(.*?)\]/' , '</ol>' , $phpbb_uid ); 665 666 return $field; 667 } 668 } 669 No newline at end of file