[ Index ]

PHP Cross Reference of BBPress

title

Body

[close]

/src/includes/admin/converters/ -> vBulletin.php (source)

   1  <?php
   2  
   3  /**
   4   * bbPress vBulletin 4.x Converter
   5   *
   6   * @package bbPress
   7   * @subpackage Converters
   8   */
   9  
  10  /**
  11   * Implementation of vBulletin v4.x Converter.
  12   *
  13   * @since 2.3.0 bbPress (r4724)
  14   *
  15   * @link Codex Docs https://codex.bbpress.org/import-forums/vbulletin
  16   */
  17  class vBulletin 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' => 'forum',
  43              'from_fieldname' => 'forumid',
  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' => 'forum',
  51              'from_fieldname' => 'parentid',
  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' => 'forum',
  59              'from_fieldname' => 'threadcount',
  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' => 'forum',
  67              'from_fieldname' => 'replycount',
  68              'to_type'        => 'forum',
  69              'to_fieldname'   => '_bbp_reply_count'
  70          );
  71  
  72          // Forum total topic count (Includes unpublished topics, Stored in postmeta)
  73          $this->field_map[] = array(
  74              'from_tablename'  => 'forum',
  75              'from_fieldname'  => 'threadcount',
  76              'to_type'         => 'forum',
  77              'to_fieldname'    => '_bbp_total_topic_count'
  78          );
  79  
  80          // Forum total reply count (Includes unpublished replies, Stored in postmeta)
  81          $this->field_map[] = array(
  82              'from_tablename'  => 'forum',
  83              'from_fieldname'  => 'replycount',
  84              'to_type'         => 'forum',
  85              'to_fieldname'    => '_bbp_total_reply_count'
  86          );
  87  
  88          // Forum title.
  89          $this->field_map[] = array(
  90              'from_tablename' => 'forum',
  91              'from_fieldname' => 'title',
  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'  => 'forum',
  99              'from_fieldname'  => 'title_clean',
 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'  => 'forum',
 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' => 'forum',
 117              'from_fieldname' => 'displayorder',
 118              'to_type'        => 'forum',
 119              'to_fieldname'   => 'menu_order'
 120          );
 121  
 122          // Forum type (Category = -1 or Forum > 0, Stored in postmeta)
 123          $this->field_map[] = array(
 124              'from_tablename'  => 'forum',
 125              'from_fieldname'  => 'parentid',
 126              'to_type'         => 'forum',
 127              'to_fieldname'    => '_bbp_forum_type',
 128              'callback_method' => 'callback_forum_type'
 129          );
 130  
 131          // Forum status (Set a default value 'open', Stored in postmeta)
 132          $this->field_map[] = array(
 133              'to_type'      => 'forum',
 134              'to_fieldname' => '_bbp_status',
 135              'default'      => 'open'
 136          );
 137  
 138          // Forum dates.
 139          $this->field_map[] = array(
 140              'to_type'      => 'forum',
 141              'to_fieldname' => 'post_date',
 142              'default'      => date( 'Y-m-d H:i:s' )
 143          );
 144          $this->field_map[]     = array(
 145              'to_type'      => 'forum',
 146              'to_fieldname' => 'post_date_gmt',
 147              'default'      => date( 'Y-m-d H:i:s' )
 148          );
 149          $this->field_map[]     = array(
 150              'to_type'      => 'forum',
 151              'to_fieldname' => 'post_modified',
 152              'default'      => date( 'Y-m-d H:i:s' )
 153          );
 154          $this->field_map[]     = array(
 155              'to_type'      => 'forum',
 156              'to_fieldname' => 'post_modified_gmt',
 157              'default'      => date( 'Y-m-d H:i:s' )
 158          );
 159  
 160          /** Forum Subscriptions Section ***************************************/
 161  
 162          // Subscribed forum ID (Stored in usermeta)
 163          $this->field_map[] = array(
 164              'from_tablename'  => 'subscribeforum',
 165              'from_fieldname'  => 'forumid',
 166              'to_type'         => 'forum_subscriptions',
 167              'to_fieldname'    => '_bbp_forum_subscriptions'
 168          );
 169  
 170          // Subscribed user ID (Stored in usermeta)
 171          $this->field_map[] = array(
 172              'from_tablename'  => 'subscribeforum',
 173              'from_fieldname'  => 'userid',
 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' => 'thread',
 184              'from_fieldname' => 'threadid',
 185              'to_type'        => 'topic',
 186              'to_fieldname'   => '_bbp_old_topic_id'
 187          );
 188  
 189          // Topic parent forum id (If no parent, then 0. Stored in postmeta)
 190          $this->field_map[] = array(
 191              'from_tablename'  => 'thread',
 192              'from_fieldname'  => 'forumid',
 193              'to_type'         => 'topic',
 194              'to_fieldname'    => '_bbp_forum_id',
 195              'callback_method' => 'callback_forumid'
 196          );
 197  
 198          // Topic reply count (Stored in postmeta)
 199          $this->field_map[] = array(
 200              'from_tablename'  => 'thread',
 201              'from_fieldname'  => 'replycount',
 202              'to_type'         => 'topic',
 203              'to_fieldname'    => '_bbp_reply_count',
 204              'callback_method' => 'callback_topic_reply_count'
 205          );
 206  
 207          // Topic total reply count (Includes unpublished replies, Stored in postmeta)
 208          $this->field_map[] = array(
 209              'from_tablename'  => 'thread',
 210              'from_fieldname'  => 'replycount',
 211              'to_type'         => 'topic',
 212              'to_fieldname'    => '_bbp_total_reply_count',
 213              'callback_method' => 'callback_topic_reply_count'
 214          );
 215  
 216          // Topic author.
 217          $this->field_map[] = array(
 218              'from_tablename'  => 'thread',
 219              'from_fieldname'  => 'postuserid',
 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'  => 'thread',
 228              'from_fieldname'  => 'postusername',
 229              'to_type'         => 'topic',
 230              'to_fieldname'    => '_bbp_old_topic_author_name_id'
 231          );
 232  
 233          // Is the topic anonymous (Stored in postmeta)
 234          $this->field_map[] = array(
 235              'from_tablename'  => 'thread',
 236              'from_fieldname'  => 'postuserid',
 237              'to_type'         => 'topic',
 238              'to_fieldname'    => '_bbp_old_is_topic_anonymous_id',
 239              'callback_method' => 'callback_check_anonymous'
 240          );
 241  
 242          // Topic Author ip (Stored in postmeta)
 243          // Note: We join the 'post' table because 'thread' table does not include topic content.
 244          $this->field_map[] = array(
 245              'from_tablename'  => 'post',
 246              'from_fieldname'  => 'ipaddress',
 247              'join_tablename'  => 'thread',
 248              'join_type'       => 'INNER',
 249              'join_expression' => 'USING (threadid) WHERE post.parentid = 0',
 250              'to_type'         => 'topic',
 251              'to_fieldname'    => '_bbp_author_ip'
 252          );
 253  
 254          // Topic title.
 255          $this->field_map[] = array(
 256              'from_tablename' => 'thread',
 257              'from_fieldname' => 'title',
 258              'to_type'        => 'topic',
 259              'to_fieldname'   => 'post_title'
 260          );
 261  
 262          // Topic slug (Clean name to avoid conflicts)
 263          $this->field_map[] = array(
 264              'from_tablename'  => 'thread',
 265              'from_fieldname'  => 'title',
 266              'to_type'         => 'topic',
 267              'to_fieldname'    => 'post_name',
 268              'callback_method' => 'callback_slug'
 269          );
 270  
 271          // Topic parent forum id (If no parent, then 0)
 272          $this->field_map[] = array(
 273              'from_tablename'  => 'thread',
 274              'from_fieldname'  => 'forumid',
 275              'to_type'         => 'topic',
 276              'to_fieldname'    => 'post_parent',
 277              'callback_method' => 'callback_forumid'
 278          );
 279  
 280          // Topic content.
 281          // Note: We join the 'post' table because 'thread' table does not include topic content.
 282          $this->field_map[] = array(
 283              'from_tablename'  => 'post',
 284              'from_fieldname'  => 'pagetext',
 285              'join_tablename'  => 'thread',
 286              'join_type'       => 'INNER',
 287              'join_expression' => 'USING (threadid) WHERE post.parentid = 0',
 288              'to_type'         => 'topic',
 289              'to_fieldname'    => 'post_content',
 290              'callback_method' => 'callback_html'
 291          );
 292  
 293          // Topic status (Open or Closed)
 294          $this->field_map[] = array(
 295              'from_tablename'  => 'thread',
 296              'from_fieldname'  => 'open',
 297              'to_type'         => 'topic',
 298              'to_fieldname'    => '_bbp_old_closed_status_id',
 299              'callback_method' => 'callback_topic_status'
 300          );
 301  
 302          // Sticky status (Stored in postmeta)
 303          $this->field_map[] = array(
 304              'from_tablename'  => 'thread',
 305              'from_fieldname'  => 'sticky',
 306              'to_type'         => 'topic',
 307              'to_fieldname'    => '_bbp_old_sticky_status_id',
 308              'callback_method' => 'callback_sticky_status'
 309          );
 310  
 311          // Topic dates.
 312          $this->field_map[] = array(
 313              'from_tablename'  => 'thread',
 314              'from_fieldname'  => 'dateline',
 315              'to_type'         => 'topic',
 316              'to_fieldname'    => 'post_date',
 317              'callback_method' => 'callback_datetime'
 318          );
 319          $this->field_map[] = array(
 320              'from_tablename'  => 'thread',
 321              'from_fieldname'  => 'dateline',
 322              'to_type'         => 'topic',
 323              'to_fieldname'    => 'post_date_gmt',
 324              'callback_method' => 'callback_datetime'
 325          );
 326          $this->field_map[] = array(
 327              'from_tablename'  => 'thread',
 328              'from_fieldname'  => 'dateline',
 329              'to_type'         => 'topic',
 330              'to_fieldname'    => 'post_modified',
 331              'callback_method' => 'callback_datetime'
 332          );
 333          $this->field_map[] = array(
 334              'from_tablename'  => 'thread',
 335              'from_fieldname'  => 'dateline',
 336              'to_type'         => 'topic',
 337              'to_fieldname'    => 'post_modified_gmt',
 338              'callback_method' => 'callback_datetime'
 339          );
 340          $this->field_map[] = array(
 341              'from_tablename' => 'thread',
 342              'from_fieldname' => 'lastpost',
 343              'to_type'        => 'topic',
 344              'to_fieldname'   => '_bbp_last_active_time',
 345              'callback_method' => 'callback_datetime'
 346          );
 347  
 348          /** Tags Section ******************************************************/
 349  
 350          // Topic id.
 351          $this->field_map[] = array(
 352              'from_tablename'  => 'tagcontent',
 353              'from_fieldname'  => 'contentid',
 354              'to_type'         => 'tags',
 355              'to_fieldname'    => 'objectid',
 356              'callback_method' => 'callback_topicid'
 357          );
 358  
 359          // Taxonomy ID.
 360          $this->field_map[] = array(
 361              'from_tablename'  => 'tagcontent',
 362              'from_fieldname'  => 'tagid',
 363              'to_type'         => 'tags',
 364              'to_fieldname'    => 'taxonomy'
 365          );
 366  
 367          // Term text.
 368          $this->field_map[] = array(
 369              'from_tablename'  => 'tag',
 370              'from_fieldname'  => 'tagtext',
 371              'join_tablename'  => 'tagcontent',
 372              'join_type'       => 'INNER',
 373              'join_expression' => 'USING (tagid)',
 374              'to_type'         => 'tags',
 375              'to_fieldname'    => 'name'
 376          );
 377  
 378          // Term slug.
 379          $this->field_map[] = array(
 380              'from_tablename'  => 'tag',
 381              'from_fieldname'  => 'tagtext',
 382              'join_tablename'  => 'tagcontent',
 383              'join_type'       => 'INNER',
 384              'join_expression' => 'USING (tagid)',
 385              'to_type'         => 'tags',
 386              'to_fieldname'    => 'slug',
 387              'callback_method' => 'callback_slug'
 388          );
 389  
 390          /** Topic Subscriptions Section ***************************************/
 391  
 392          // Subscribed topic ID (Stored in usermeta)
 393          $this->field_map[] = array(
 394              'from_tablename'  => 'subscribethread',
 395              'from_fieldname'  => 'threadid',
 396              'to_type'         => 'topic_subscriptions',
 397              'to_fieldname'    => '_bbp_subscriptions'
 398          );
 399  
 400          // Subscribed user ID (Stored in usermeta)
 401          $this->field_map[] = array(
 402              'from_tablename'  => 'subscribethread',
 403              'from_fieldname'  => 'userid',
 404              'to_type'         => 'topic_subscriptions',
 405              'to_fieldname'    => 'user_id',
 406              'callback_method' => 'callback_userid'
 407          );
 408  
 409          /** Reply Section *****************************************************/
 410  
 411          // Old reply id (Stored in postmeta)
 412          $this->field_map[] = array(
 413              'from_tablename'  => 'post',
 414              'from_fieldname'  => 'postid',
 415              'to_type'         => 'reply',
 416              'to_fieldname'    => '_bbp_old_reply_id'
 417          );
 418  
 419          // Reply parent forum id (If no parent, then 0. Stored in postmeta)
 420          $this->field_map[] = array(
 421              'from_tablename'  => 'post',
 422              'from_fieldname'  => 'threadid',
 423              'from_expression' => 'WHERE parentid != 0',
 424              'to_type'         => 'reply',
 425              'to_fieldname'    => '_bbp_forum_id',
 426              'callback_method' => 'callback_topicid_to_forumid'
 427          );
 428  
 429          // Reply parent topic id (If no parent, then 0, Stored in postmeta)
 430          $this->field_map[] = array(
 431              'from_tablename'  => 'post',
 432              'from_fieldname'  => 'threadid',
 433              'to_type'         => 'reply',
 434              'to_fieldname'    => '_bbp_topic_id',
 435              'callback_method' => 'callback_topicid'
 436          );
 437  
 438          // Reply author ip (Stored in postmeta)
 439          $this->field_map[] = array(
 440              'from_tablename' => 'post',
 441              'from_fieldname' => 'ipaddress',
 442              'to_type'        => 'reply',
 443              'to_fieldname'   => '_bbp_author_ip'
 444          );
 445  
 446          // Reply author.
 447          $this->field_map[] = array(
 448              'from_tablename'  => 'post',
 449              'from_fieldname'  => 'userid',
 450              'to_type'         => 'reply',
 451              'to_fieldname'    => 'post_author',
 452              'callback_method' => 'callback_userid'
 453          );
 454  
 455          // Reply author name (Stored in postmeta as _bbp_anonymous_name)
 456          $this->field_map[] = array(
 457              'from_tablename'  => 'post',
 458              'from_fieldname'  => 'username',
 459              'to_type'         => 'reply',
 460              'to_fieldname'    => '_bbp_old_reply_author_name_id'
 461          );
 462  
 463          // Is the reply anonymous (Stored in postmeta)
 464          $this->field_map[] = array(
 465              'from_tablename'  => 'post',
 466              'from_fieldname'  => 'userid',
 467              'to_type'         => 'reply',
 468              'to_fieldname'    => '_bbp_old_is_reply_anonymous_id',
 469              'callback_method' => 'callback_check_anonymous'
 470          );
 471  
 472          // Reply content.
 473          $this->field_map[] = array(
 474              'from_tablename'  => 'post',
 475              'from_fieldname'  => 'pagetext',
 476              'to_type'         => 'reply',
 477              'to_fieldname'    => 'post_content',
 478              'callback_method' => 'callback_html'
 479          );
 480  
 481          // Reply parent topic id (If no parent, then 0)
 482          $this->field_map[] = array(
 483              'from_tablename'  => 'post',
 484              'from_fieldname'  => 'threadid',
 485              'to_type'         => 'reply',
 486              'to_fieldname'    => 'post_parent',
 487              'callback_method' => 'callback_topicid'
 488          );
 489  
 490          // Reply dates.
 491          $this->field_map[] = array(
 492              'from_tablename'  => 'post',
 493              'from_fieldname'  => 'dateline',
 494              'to_type'         => 'reply',
 495              'to_fieldname'    => 'post_date',
 496              'callback_method' => 'callback_datetime'
 497          );
 498          $this->field_map[] = array(
 499              'from_tablename'  => 'post',
 500              'from_fieldname'  => 'dateline',
 501              'to_type'         => 'reply',
 502              'to_fieldname'    => 'post_date_gmt',
 503              'callback_method' => 'callback_datetime'
 504          );
 505          $this->field_map[] = array(
 506              'from_tablename'  => 'post',
 507              'from_fieldname'  => 'dateline',
 508              'to_type'         => 'reply',
 509              'to_fieldname'    => 'post_modified',
 510              'callback_method' => 'callback_datetime'
 511          );
 512          $this->field_map[]     = array(
 513              'from_tablename'  => 'post',
 514              'from_fieldname'  => 'dateline',
 515              'to_type'         => 'reply',
 516              'to_fieldname'    => 'post_modified_gmt',
 517              'callback_method' => 'callback_datetime'
 518          );
 519  
 520          /** User Section ******************************************************/
 521  
 522          // Store old user id (Stored in usermeta)
 523          $this->field_map[] = array(
 524              'from_tablename' => 'user',
 525              'from_fieldname' => 'userid',
 526              'to_type'        => 'user',
 527              'to_fieldname'   => '_bbp_old_user_id'
 528          );
 529  
 530          // Store old user password (Stored in usermeta serialized with salt)
 531          $this->field_map[] = array(
 532              'from_tablename'  => 'user',
 533              'from_fieldname'  => 'password',
 534              'to_type'         => 'user',
 535              'to_fieldname'    => '_bbp_password',
 536              'callback_method' => 'callback_savepass'
 537          );
 538  
 539          // Store old user salt (This is only used for the SELECT row info for the above password save)
 540          $this->field_map[] = array(
 541              'from_tablename' => 'user',
 542              'from_fieldname' => 'salt',
 543              'to_type'        => 'user',
 544              'to_fieldname'   => '_bbp_salt'
 545          );
 546  
 547          // User password verify class (Stored in usermeta for verifying password)
 548          $this->field_map[] = array(
 549              'to_type'      => 'user',
 550              'to_fieldname' => '_bbp_class',
 551              'default'      => 'vBulletin'
 552          );
 553  
 554          // User name.
 555          $this->field_map[] = array(
 556              'from_tablename' => 'user',
 557              'from_fieldname' => 'username',
 558              'to_type'        => 'user',
 559              'to_fieldname'   => 'user_login'
 560          );
 561  
 562          // User email.
 563          $this->field_map[] = array(
 564              'from_tablename' => 'user',
 565              'from_fieldname' => 'email',
 566              'to_type'        => 'user',
 567              'to_fieldname'   => 'user_email'
 568          );
 569  
 570          // User homepage.
 571          $this->field_map[] = array(
 572              'from_tablename' => 'user',
 573              'from_fieldname' => 'homepage',
 574              'to_type'        => 'user',
 575              'to_fieldname'   => 'user_url'
 576          );
 577  
 578          // User registered.
 579          $this->field_map[] = array(
 580              'from_tablename'  => 'user',
 581              'from_fieldname'  => 'joindate',
 582              'to_type'         => 'user',
 583              'to_fieldname'    => 'user_registered',
 584              'callback_method' => 'callback_datetime'
 585          );
 586  
 587          // User AIM (Stored in usermeta)
 588          $this->field_map[] = array(
 589              'from_tablename' => 'user',
 590              'from_fieldname' => 'aim',
 591              'to_type'        => 'user',
 592              'to_fieldname'   => '_bbp_vbulletin_user_aim'
 593          );
 594  
 595          // User Yahoo (Stored in usermeta)
 596          $this->field_map[] = array(
 597              'from_tablename' => 'user',
 598              'from_fieldname' => 'yahoo',
 599              'to_type'        => 'user',
 600              'to_fieldname'   => '_bbp_vbulletin_user_yim'
 601          );
 602  
 603          // User ICQ (Stored in usermeta)
 604          $this->field_map[] = array(
 605              'from_tablename' => 'user',
 606              'from_fieldname' => 'icq',
 607              'to_type'        => 'user',
 608              'to_fieldname'   => '_bbp_vbulletin_user_icq'
 609          );
 610  
 611          // User MSN (Stored in usermeta)
 612          $this->field_map[] = array(
 613              'from_tablename' => 'user',
 614              'from_fieldname' => 'msn',
 615              'to_type'        => 'user',
 616              'to_fieldname'   => '_bbp_vbulletin_user_msn'
 617          );
 618  
 619          // User Skype (Stored in usermeta)
 620          $this->field_map[] = array(
 621              'from_tablename' => 'user',
 622              'from_fieldname' => 'skype',
 623              'to_type'        => 'user',
 624              'to_fieldname'   => '_bbp_vbulletin_user_skype'
 625          );
 626      }
 627  
 628      /**
 629       * This method allows us to indicates what is or is not converted for each
 630       * converter.
 631       */
 632  	public function info() {
 633          return '';
 634      }
 635  
 636  
 637      /**
 638       * This method is to save the salt and password together.  That
 639       * way when we authenticate it we can get it out of the database
 640       * as one value. Array values are auto sanitized by WordPress.
 641       */
 642  	public function callback_savepass( $field, $row ) {
 643          $pass_array = array( 'hash' => $field, 'salt' => $row['salt'] );
 644          return $pass_array;
 645      }
 646  
 647      /**
 648       * This method is to take the pass out of the database and compare
 649       * to a pass the user has typed in.
 650       *
 651       */
 652  	public function authenticate_pass( $password, $serialized_pass ) {
 653          $pass_array = unserialize( $serialized_pass );
 654          return ( $pass_array['hash'] == md5( md5( $password ) . $pass_array['salt'] ) );
 655      }
 656  
 657      /**
 658       * Translate the forum type from vBulletin v4.x numerics to WordPress's strings.
 659       *
 660       * @param int $status vBulletin v4.x numeric forum type
 661       * @return string WordPress safe
 662       */
 663  	public function callback_forum_type( $status = 0 ) {
 664          if ( $status == -1 ) {
 665              $status = 'category';
 666          } else {
 667              $status = 'forum';
 668          }
 669          return $status;
 670      }
 671  
 672      /**
 673       * Translate the topic sticky status type from vBulletin v4.x numerics to WordPress's strings.
 674       *
 675       * @param int $status vBulletin v4.x numeric forum type
 676       * @return string WordPress safe
 677       */
 678  	public function callback_sticky_status( $status = 0 ) {
 679          switch ( $status ) {
 680              case 2 :
 681                  $status = 'super-sticky'; // vBulletin Super Sticky 'sticky = 2'
 682                  break;
 683  
 684              case 1 :
 685                  $status = 'sticky';       // vBulletin Sticky 'sticky = 1'
 686                  break;
 687  
 688              case 0  :
 689              default :
 690                  $status = 'normal';       // vBulletin Normal Topic 'sticky = 0'
 691                  break;
 692          }
 693          return $status;
 694      }
 695  
 696      /**
 697       * Verify the topic reply count.
 698       *
 699       * @param int $count vBulletin v4.x reply count
 700       * @return string WordPress safe
 701       */
 702  	public function callback_topic_reply_count( $count = 1 ) {
 703          $count = absint( (int) $count - 1 );
 704          return $count;
 705      }
 706  
 707      /**
 708       * Translate the post status from vBulletin numerics to WordPress's strings.
 709       *
 710       * @param int $status vBulletin v4.x numeric topic status
 711       * @return string WordPress safe
 712       */
 713  	public function callback_topic_status( $status = 1 ) {
 714          switch ( $status ) {
 715              case 0 :
 716                  $status = 'closed';
 717                  break;
 718  
 719              case 1  :
 720              default :
 721                  $status = 'publish';
 722                  break;
 723          }
 724          return $status;
 725      }
 726  
 727      /**
 728       * This callback processes any custom parser.php attributes and custom code with preg_replace
 729       */
 730  	protected function callback_html( $field ) {
 731  
 732          // Strips vBulletin custom HTML first from $field before parsing $field to parser.php
 733          $vbulletin_markup = $field;
 734          $vbulletin_markup = html_entity_decode( $vbulletin_markup );
 735  
 736          // Replace '[QUOTE]' with '<blockquote>'
 737          $vbulletin_markup = preg_replace( '/\[QUOTE\]/', '<blockquote>', $vbulletin_markup );
 738          // Replace '[QUOTE=User Name($1);PostID($2)]' with '<em>@$1 $2 wrote:</em><blockquote>"
 739          $vbulletin_markup = preg_replace( '/\[QUOTE=(.*?);(.*?)\]/', '<em>@$1 $2 wrote:</em><blockquote>', $vbulletin_markup );
 740          // Replace '[/QUOTE]' with '</blockquote>'
 741          $vbulletin_markup = preg_replace( '/\[\/QUOTE\]/', '</blockquote>', $vbulletin_markup );
 742          // Replace '[MENTION=###($1)]User Name($2)[/MENTION]' with '@$2"
 743          $vbulletin_markup = preg_replace( '/\[MENTION=(.*?)\](.*?)\[\/MENTION\]/', '@$2', $vbulletin_markup );
 744  
 745          // Replace '[video=youtube;$1]$2[/video]' with '$2"
 746          $vbulletin_markup = preg_replace( '/\[video\=youtube;(.*?)\](.*?)\[\/video\]/', '$2', $vbulletin_markup );
 747          // Replace '[video=youtube_share;$1]$2[/video]' with '$2"
 748          $vbulletin_markup = preg_replace( '/\[video\=youtube_share;(.*?)\](.*?)\[\/video\]/', '$2', $vbulletin_markup );
 749  
 750          // Now that vBulletin custom HTML has been stripped put the cleaned HTML back in $field
 751          $field = $vbulletin_markup;
 752  
 753          // Parse out any bbCodes in $field with the BBCode 'parser.php'
 754          return parent::callback_html( $field );
 755      }
 756  }


Generated: Sat Dec 7 01:00:51 2024 Cross-referenced by PHPXref 0.7.1