Skip to:
Content

bbPress.org

Changeset 5150


Ignore:
Timestamp:
11/08/2013 03:47:31 AM (7 years ago)
Author:
netweb
Message:

phpBB Importer Improvements. Props netweb. Fixes #2467

  • Added forum type callback for if forum is a Forum or Category
  • Added reply title callback for clean reply titles
  • Improved inline docs
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/includes/admin/converters/phpBB.php

    r4726 r5150  
    2424    public function setup_globals() {
    2525
    26         /** Forum Section ******************************************************/
     26        /** Forum Section *****************************************************/
    2727
    2828        // Forum id (Stored in postmeta)
     
    6666        );
    6767
    68         // Forum total reply count (Stored in postmeta)
     68        // Forum total reply count (Includes unpublished replies, Stored in postmeta)
    6969        $this->field_map[] = array(
    7070            'from_tablename' => 'forums',
     
    108108        );
    109109
    110         // Forum status (Locked =1 Unlocked =0, Stored in postmeta)
     110        // Forum type (Category = 0 or Forum = 1, Stored in postmeta)
     111        $this->field_map[] = array(
     112            'from_tablename'  => 'forums',
     113            'from_fieldname'  => 'forum_type',
     114            'to_type'         => 'forum',
     115            'to_fieldname'    => '_bbp_forum_type',
     116            'callback_method' => 'callback_forum_type'
     117        );
     118
     119        // Forum status (Unlocked = 0 or Locked = 1, Stored in postmeta)
    111120        $this->field_map[] = array(
    112121            'from_tablename'  => 'forums',
     
    139148        );
    140149
    141         /** Topic Section ******************************************************/
     150        /** Topic Section *****************************************************/
    142151
    143152        // Topic id (Stored in postmeta)
     
    186195
    187196        // Topic content.
    188         // Note: We join the posts table because topics do not have content.
     197        // Note: We join the 'posts' table because 'topics' do not have content.
    189198        $this->field_map[] = array(
    190199            'from_tablename'  => 'posts',
     
    280289            'to_fieldname'    => '_bbp_author_ip'
    281290        );
    282 
    283         // Sticky Status
    284291
    285292        /** Tags Section ******************************************************/
     
    346353        // Reply title.
    347354        $this->field_map[] = array(
    348             'from_tablename' => 'posts',
    349             'from_fieldname' => 'post_subject',
    350             'to_type'        => 'reply',
    351             'to_fieldname'   => 'post_title'
     355            'from_tablename'  => 'posts',
     356            'from_fieldname'  => 'post_subject',
     357            'to_type'         => 'reply',
     358            'to_fieldname'    => 'post_title',
     359            'callback_method' => 'callback_reply_title'
    352360        );
    353361
     
    692700
    693701    /**
     702     * Translate the forum type from phpBB v3.x numeric's to WordPress's strings.
     703     *
     704     * @param int $status phpBB v3.x numeric forum type
     705     * @return string WordPress safe
     706     */
     707    public function callback_forum_type( $status = 1 ) {
     708        switch ( $status ) {
     709            case 0 :
     710                $status = 'category';
     711                break;
     712
     713            case 1  :
     714            default :
     715                $status = 'forum';
     716                break;
     717        }
     718        return $status;
     719    }
     720
     721    /**
    694722     * Translate the forum status from phpBB v3.x numeric's to WordPress's strings.
    695723     *
     
    723751                break;
    724752
    725             case 0  :
     753            case 0 :
    726754            default :
    727755                $status = 'publish';
     
    740768        $count = absint( (int) $count - 1 );
    741769        return $count;
     770    }
     771
     772    /**
     773     * Set the reply title
     774     *
     775     * @param string $title phpBB v3.x topic title of this reply
     776     * @return string Prefixed topic title, or empty string
     777     */
     778    public function callback_reply_title( $title = '' ) {
     779        $title = !empty( $title ) ? __( 'Re: ', 'bbpress' ) . html_entity_decode( $title ) : '';
     780        return $title;
    742781    }
    743782
Note: See TracChangeset for help on using the changeset viewer.