Changeset 4730 for trunk/includes/admin/converters/vBulletin.php
- Timestamp:
- 01/28/2013 02:41:19 AM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/includes/admin/converters/vBulletin.php
r4272 r4730 2 2 3 3 /** 4 * vBulletin Converter4 * Implementation of vBulletin v4.x Converter. 5 5 * 6 * @since bbPress (r) 6 * @since bbPress (r4724) 7 * @link Codex Docs http://codex.bbpress.org/import-forums/vbulletin 7 8 */ 8 9 class vBulletin extends BBP_Converter_Base { … … 33 34 ); 34 35 35 // Forum parent id (If no parent, th an 0. Stored in postmeta)36 // Forum parent id (If no parent, then 0. Stored in postmeta) 36 37 $this->field_map[] = array( 37 38 'from_tablename' => 'forum', … … 39 40 'to_type' => 'forum', 40 41 'to_fieldname' => '_bbp_forum_parent_id' 42 ); 43 44 // Forum topic count (Stored in postmeta) 45 $this->field_map[] = array( 46 'from_tablename' => 'forum', 47 'from_fieldname' => 'threadcount', 48 'to_type' => 'forum', 49 'to_fieldname' => '_bbp_topic_count' 50 ); 51 52 // Forum reply count (Stored in postmeta) 53 $this->field_map[] = array( 54 'from_tablename' => 'forum', 55 'from_fieldname' => 'replycount', 56 'to_type' => 'forum', 57 'to_fieldname' => '_bbp_reply_count' 41 58 ); 42 59 … … 75 92 ); 76 93 77 // Forum date update.94 // Forum dates. 78 95 $this->field_map[] = array( 79 96 'to_type' => 'forum', … … 107 124 ); 108 125 109 // Forum id (Stored in postmeta)126 // Topic parent forum id (If no parent, then 0. Stored in postmeta) 110 127 $this->field_map[] = array( 111 128 'from_tablename' => 'thread', … … 114 131 'to_fieldname' => '_bbp_forum_id', 115 132 'callback_method' => 'callback_forumid' 133 ); 134 135 // Topic reply count (Stored in postmeta) 136 $this->field_map[] = array( 137 'from_tablename' => 'thread', 138 'from_fieldname' => 'replycount', 139 'to_type' => 'topic', 140 'to_fieldname' => '_bbp_reply_count', 141 'callback_method' => 'callback_topic_reply_count' 116 142 ); 117 143 … … 142 168 ); 143 169 144 // Forum id (If no parent, than 0)170 // Topic parent forum id (If no parent, then 0) 145 171 $this->field_map[] = array( 146 172 'from_tablename' => 'thread', … … 164 190 ); 165 191 166 // Topic date update.192 // Topic dates. 167 193 $this->field_map[] = array( 168 194 'from_tablename' => 'thread', … … 192 218 'to_fieldname' => 'post_modified_gmt', 193 219 'callback_method' => 'callback_datetime' 220 ); 221 $this->field_map[] = array( 222 'from_tablename' => 'thread', 223 'from_fieldname' => 'lastpost', 224 'to_type' => 'topic', 225 'to_fieldname' => '_bbp_last_active_time', 226 'callback_method' => 'callback_datetime' 227 ); 228 229 // Topic status (Open or Closed) 230 $this->field_map[] = array( 231 'from_tablename' => 'thread', 232 'from_fieldname' => 'open', 233 'to_type' => 'topic', 234 'to_fieldname' => 'post_status', 235 'callback_method' => 'callback_topic_status' 194 236 ); 195 237 … … 205 247 ); 206 248 207 // Tags text. 249 // Taxonomy ID. 250 $this->field_map[] = array( 251 'from_tablename' => 'tagcontent', 252 'from_fieldname' => 'tagid', 253 'to_type' => 'tags', 254 'to_fieldname' => 'taxonomy' 255 ); 256 257 // Term text. 208 258 $this->field_map[] = array( 209 259 'from_tablename' => 'tag', … … 216 266 ); 217 267 218 /** Post Section ******************************************************/219 220 // Post id (Storesin postmeta)268 /** Reply Section *****************************************************/ 269 270 // Reply id (Stored in postmeta) 221 271 $this->field_map[] = array( 222 272 'from_tablename' => 'post', 223 273 'from_fieldname' => 'postid', 224 'from_expression' => 'WHERE post.parentid != 0',225 274 'to_type' => 'reply', 226 275 'to_fieldname' => '_bbp_post_id' 227 276 ); 228 277 229 // Forum id (Stores in postmeta) 230 $this->field_map[] = array( 231 'from_tablename' => 'post', 232 'from_fieldname' => 'threadid', 278 // Reply parent forum id (If no parent, then 0. Stored in postmeta) 279 $this->field_map[] = array( 280 'from_tablename' => 'thread', 281 'from_fieldname' => 'forumid', 282 'join_tablename' => 'post', 283 'join_type' => 'INNER', 284 'join_expression' => 'USING (threadid) WHERE post.parentid != 0', 233 285 'to_type' => 'reply', 234 286 'to_fieldname' => '_bbp_forum_id', … … 236 288 ); 237 289 238 // Topic id (Storesin postmeta)290 // Reply parent topic id (If no parent, then 0. Stored in postmeta) 239 291 $this->field_map[] = array( 240 292 'from_tablename' => 'post', … … 245 297 ); 246 298 247 // Author ip.299 // Reply author ip (Stored in postmeta) 248 300 $this->field_map[] = array( 249 301 'from_tablename' => 'post', … … 253 305 ); 254 306 255 // Postauthor.307 // Reply author. 256 308 $this->field_map[] = array( 257 309 'from_tablename' => 'post', … … 262 314 ); 263 315 264 // Topic title. 265 $this->field_map[] = array( 266 'from_tablename' => 'post', 267 'from_fieldname' => 'title', 268 'to_type' => 'reply', 269 'to_fieldname' => 'post_title' 270 ); 271 272 // Topic slug (Clean name) 273 $this->field_map[] = array( 274 'from_tablename' => 'post', 316 // Reply title. 317 // Note: We join the thread table because post table does not include topic title. 318 $this->field_map[] = array( 319 'from_tablename' => 'thread', 275 320 'from_fieldname' => 'title', 276 'to_type' => 'reply', 277 'to_fieldname' => 'post_name', 278 'callback_method' => 'callback_slug' 279 ); 280 281 // Post content. 321 'join_tablename' => 'post', 322 'join_type' => 'INNER', 323 'join_expression' => 'USING (threadid) WHERE post.parentid != 0', 324 'to_type' => 'reply', 325 'to_fieldname' => 'post_title', 326 'callback_method' => 'callback_reply_title' 327 ); 328 329 // Reply content. 282 330 $this->field_map[] = array( 283 331 'from_tablename' => 'post', … … 288 336 ); 289 337 290 // Topic id (If no parent, than 0)338 // Reply parent topic id (If no parent, then 0) 291 339 $this->field_map[] = array( 292 340 'from_tablename' => 'post', … … 297 345 ); 298 346 299 // Topic date update.347 // Reply dates. 300 348 $this->field_map[] = array( 301 349 'from_tablename' => 'post', … … 329 377 /** User Section ******************************************************/ 330 378 331 // Store old User id (Store sin usermeta)379 // Store old User id (Stored in usermeta) 332 380 $this->field_map[] = array( 333 381 'from_tablename' => 'user', … … 337 385 ); 338 386 339 // Store old User password (Store sin usermeta serialized with salt)387 // Store old User password (Stored in usermeta serialized with salt) 340 388 $this->field_map[] = array( 341 389 'from_tablename' => 'user', … … 346 394 ); 347 395 348 // Store old User Salt (This is only used for the SELECT row info for 349 // the above password save) 396 // Store old User Salt (This is only used for the SELECT row info for the above password save) 350 397 $this->field_map[] = array( 351 398 'from_tablename' => 'user', … … 355 402 ); 356 403 357 // User password verify class (Store sin usermeta for verifying password)404 // User password verify class (Stored in usermeta for verifying password) 358 405 $this->field_map[] = array( 359 406 'to_type' => 'user', … … 368 415 'to_type' => 'user', 369 416 'to_fieldname' => 'user_login' 370 );371 372 // User nice name.373 $this->field_map[] = array(374 'from_tablename' => 'user',375 'from_fieldname' => 'user_nicename',376 'to_type' => 'user',377 'to_fieldname' => 'user_nicename'378 417 ); 379 418 … … 403 442 ); 404 443 405 // User aim.444 // User AIM (Stored in usermeta) 406 445 $this->field_map[] = array( 407 446 'from_tablename' => 'user', … … 411 450 ); 412 451 413 // User yahoo.452 // User Yahoo (Stored in usermeta) 414 453 $this->field_map[] = array( 415 454 'from_tablename' => 'user', … … 417 456 'to_type' => 'user', 418 457 'to_fieldname' => 'yim' 458 ); 459 460 // User ICQ (Stored in usermeta) 461 $this->field_map[] = array( 462 'from_tablename' => 'user', 463 'from_fieldname' => 'icq', 464 'to_type' => 'user', 465 'to_fieldname' => '_bbp_vbulletin_user_icq' 466 ); 467 468 // User MSN (Stored in usermeta) 469 $this->field_map[] = array( 470 'from_tablename' => 'user', 471 'from_fieldname' => 'msn', 472 'to_type' => 'user', 473 'to_fieldname' => '_bbp_vbulletin_user_msn' 474 ); 475 476 // User Skype (Stored in usermeta) 477 $this->field_map[] = array( 478 'from_tablename' => 'user', 479 'from_fieldname' => 'skype', 480 'to_type' => 'user', 481 'to_fieldname' => '_bbp_vbulletin_user_skype' 419 482 ); 420 483 } … … 427 490 return ''; 428 491 } 492 429 493 430 494 /** … … 441 505 * This method is to take the pass out of the database and compare 442 506 * to a pass the user has typed in. 507 * 508 * vBulletin passwords do not work. Maybe use the below plugin's approach? 509 * 510 * @link http://wordpress.org/extend/plugins/vb-user-copy/ 511 * @link http://plugins.trac.wordpress.org/browser/vb-user-copy/trunk/vb_user_copy.php 443 512 */ 444 513 public function authenticate_pass( $password, $serialized_pass ) { … … 446 515 return ( $pass_array['hash'] == md5( md5( $password ) . $pass_array['salt'] ) ); 447 516 } 517 518 /** 519 * Verify the topic reply count. 520 * 521 * @param int $count vBulletin v4.x reply count 522 * @return string WordPress safe 523 */ 524 public function callback_topic_reply_count( $count = 1 ) { 525 $count = absint( (int) $count - 1 ); 526 return $count; 527 } 528 529 /** 530 * Set the reply title 531 * 532 * @param string $title vBulletin v4.x topic title of this reply 533 * @return string Prefixed topic title, or empty string 534 */ 535 public function callback_reply_title( $title = '' ) { 536 $title = !empty( $title ) ? __( 'Re: ', 'bbpress' ) . html_entity_decode( $title ) : ''; 537 return $title; 538 } 539 540 /** 541 * Translate the post status from vBulletin numeric's to WordPress's strings. 542 * 543 * @param int $status vBulletin v4.x numeric topic status 544 * @return string WordPress safe 545 */ 546 public function callback_topic_status( $status = 1 ) { 547 switch ( $status ) { 548 case 0 : 549 $status = 'closed'; 550 break; 551 552 case 1 : 553 default : 554 $status = 'publish'; 555 break; 556 } 557 return $status; 558 } 559 560 /** 561 * This callback processes any custom parser.php attributes and custom code with preg_replace 562 */ 563 protected function callback_html( $field ) { 564 565 // Strips vBulletin custom HTML first from $field before parsing $field to parser.php 566 $vbulletin_markup = $field; 567 $vbulletin_markup = html_entity_decode( $vbulletin_markup ); 568 569 // Replace '[QUOTE]' with '<blockquote>' 570 $vbulletin_markup = preg_replace( '/\[QUOTE\]/', '<blockquote>', $vbulletin_markup ); 571 // Replace '[QUOTE=User Name($1);PostID($2)]' with '<em>@$1 $2 wrote:</em><blockquote>" 572 $vbulletin_markup = preg_replace( '/\[QUOTE=(.*?);(.*?)\]/' , '<em>@$1 $2 wrote:</em><blockquote>', $vbulletin_markup ); 573 // Replace '[/QUOTE]' with '</blockquote>' 574 $vbulletin_markup = preg_replace( '/\[\/QUOTE\]/', '</blockquote>', $vbulletin_markup ); 575 // Replace '[MENTION=###($1)]User Name($2)[/MENTION]' with '@$2" 576 $vbulletin_markup = preg_replace( '/\[MENTION=(.*?)\](.*?)\[\/MENTION\]/', '@$2', $vbulletin_markup ); 577 578 // Replace '[video=youtube;$1]$2[/video]' with '$2" 579 $vbulletin_markup = preg_replace( '/\[video\=youtube;(.*?)\](.*?)\[\/video\]/', '$2', $vbulletin_markup ); 580 581 // Now that vBulletin custom HTML has been stripped put the cleaned HTML back in $field 582 $field = $vbulletin_markup; 583 584 // Parse out any bbCodes in $field with the BBCode 'parser.php' 585 require_once( bbpress()->admin->admin_dir . 'parser.php' ); 586 $bbcode = BBCode::getInstance(); 587 $bbcode->enable_smileys = false; 588 $bbcode->smiley_regex = false; 589 return html_entity_decode( $bbcode->Parse( $field ) ); 590 } 448 591 }
Note: See TracChangeset
for help on using the changeset viewer.