Changeset 3352

Show
Ignore:
Timestamp:
12/23/05 23:16:20 (3 years ago)
Author:
ryan
Message:

Enable MT importer.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/wp-admin/import/mt.php

    r3262 r3352  
    173173 
    174174    function process_posts() { 
     175        global $wpdb; 
    175176        $i = -1; 
    176177        echo "<ol>"; 
    177         foreach ($posts as $post) { 
     178        foreach ($this->posts as $post) { 
    178179            if ('' != trim($post)) { 
    179180                ++ $i; 
    180181                unset ($post_categories); 
    181                 echo '<li>'.__('Processing post...'); 
    182182 
    183183                // Take the pings out first 
     
    225225                        case 'TITLE' : 
    226226                            $post_title = $wpdb->escape($value); 
    227                             echo '<i>'.stripslashes($post_title).'</i>... '; 
    228227                            break; 
    229228                        case 'STATUS' : 
     
    253252                            break; 
    254253                        case 'PRIMARY CATEGORY' : 
    255                             $post_categories[] = $wpdb->escape($value); 
     254                            if (! empty ($value) ) 
     255                                $post_categories[] = $wpdb->escape($value); 
    256256                            break; 
    257257                        case 'CATEGORY' : 
    258                             $post_categories[] = $wpdb->escape($value); 
     258                            if (! empty ($value) ) 
     259                                $post_categories[] = $wpdb->escape($value); 
    259260                            break; 
    260261                        case 'DATE' : 
     
    262263                            $post_modified = date('Y-m-d H:i:s', $post_modified); 
    263264                            $post_modified_gmt = get_gmt_from_date("$post_modified"); 
     265                            $post_date = $post_modified; 
     266                            $post_date_gmt = $post_modified_gmt; 
    264267                            break; 
    265268                        default : 
     
    270273 
    271274                // Let's check to see if it's in already 
    272                 if ($post_id = posts_exists($post_title, '', $post_date)) { 
    273                     _e('Post already imported.'); 
     275                if ($post_id = post_exists($post_title, '', $post_date)) { 
     276                    echo '<li>'; 
     277                    printf(__('Post <i>%s</i> already exists.'), stripslashes($post_title)); 
    274278                } else { 
    275                     $post_author = checkauthor($post_author); //just so that if a post already exists, new users are not created by checkauthor 
     279                    echo '<li>'; 
     280                    printf(__('Importing post <i>%s</i>...'), stripslashes($post_title)); 
     281 
     282                    $post_author = $this->checkauthor($post_author); //just so that if a post already exists, new users are not created by checkauthor 
    276283 
    277284                    $postdata = compact('post_author', 'post_date', 'post_date_gmt', 'post_content', 'post_title', 'post_excerpt', 'post_status', 'comment_status', 'ping_status', 'post_modified', 'post_modified_gmt'); 
     
    279286                    // Add categories. 
    280287                    if (0 != count($post_categories)) { 
    281                         wp_create_categories($post_categories); 
     288                        wp_create_categories($post_categories, $post_id); 
    282289                    } 
    283                     _e(' Post imported successfully...'); 
    284290                } 
    285291 
     
    288294                // Now for comments 
    289295                $comments = explode("-----\nCOMMENT:", $comments[0]); 
     296                $num_comments = 0; 
    290297                foreach ($comments as $comment) { 
    291298                    if ('' != trim($comment)) { 
     
    318325                            $commentdata = wp_filter_comment($commentdata); 
    319326                            wp_insert_comment($commentdata); 
    320                             echo "Comment added."
     327                            $num_comments++
    321328                        } 
    322329                    } 
    323330                } 
     331                if ( $num_comments ) 
     332                    printf(__('(%s comments)'), $num_comments); 
    324333 
    325334                // Finally the pings 
     
    327336                $pings[0] = str_replace("-----\n\n", "-----\n", $pings[0]); 
    328337                $pings = explode("-----\nPING:", $pings[0]); 
     338                $num_pings = 0; 
    329339                foreach ($pings as $ping) { 
    330340                    if ('' != trim($ping)) { 
     
    363373                            $commentdata = wp_filter_comment($commentdata); 
    364374                            wp_insert_comment($commentdata); 
    365                             _e('Comment added.')
     375                            $num_pings++
    366376                        } 
    367377                    } 
    368378                } 
     379                if ( $num_pings ) 
     380                    printf(__('(%s pings)'), $num_pings); 
     381                 
    369382                echo "</li>"; 
    370383            } 
     
    413426$mt_import = new MT_Import(); 
    414427 
    415 //register_importer('mt', 'Movable Type', 'Import posts and comments from your Movable Type blog', array ($mt_import, 'dispatch')); 
     428register_importer('mt', 'Movable Type', 'Import posts and comments from your Movable Type blog', array ($mt_import, 'dispatch')); 
    416429?>