Make WordPress Core


Ignore:
Timestamp:
06/14/2007 02:25:30 AM (19 years ago)
Author:
ryan
Message:

Trim empty lines. Nothing but newline.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/import/utw.php

    r5390 r5700  
    22
    33class UTW_Import {
    4        
     4
    55        function header()  {
    66                echo '<div class="wrap">';
    … …  
    2424                echo '</div>';
    2525        }
    26        
    27        
     26
     27
    2828        function dispatch () {
    2929                if ( empty( $_GET['step'] ) ) {
    … …  
    3232                        $step = (int) $_GET['step'];
    3333                }
    34                
     34
    3535                // load the header
    3636                $this->header();
    37                
     37
    3838                switch ( $step ) {
    3939                        case 0 :
    … …  
    5353                                break;
    5454                }
    55                
     55
    5656                // load the footer
    5757                $this->footer();
    5858        }
    59        
    60        
     59
     60
    6161        function import_tags ( ) {
    6262                echo '<div class="narrow">';
    6363                echo '<p><h3>'.__('Reading UTW Tags&#8230;').'</h3></p>';
    64                
     64
    6565                $tags = $this->get_utw_tags();
    66                
     66
    6767                // if we didn't get any tags back, that's all there is folks!
    6868                if ( !is_array($tags) ) {
    … …  
    7878
    7979                        add_option('utwimp_tags', $tags);
    80                        
     80
    8181
    8282                        $count = count($tags);
    83                        
     83
    8484                        echo '<p>' . sprintf( __('Done! <strong>%s</strong> tags were read.'), $count ) . '<br /></p>';
    8585                        echo '<p>' . __('The following tags were found:') . '</p>';
    86                        
     86
    8787                        echo '<ul>';
    88                        
     88
    8989                        foreach ( $tags as $tag_id => $tag_name ) {
    90                                
     90
    9191                                echo '<li>' . $tag_name . '</li>';
    92                                
     92
    9393                        }
    94                        
     94
    9595                        echo '</ul>';
    96                        
     96
    9797                        echo '<br />';
    98                        
     98
    9999                        echo '<p>' . __('If you don&#8217;t want to import any of these tags, you should delete them from the UTW tag management page and then re-run this import.') . '</p>';
    100                        
    101                        
    102                 }
    103                
     100
     101
     102                }
     103
    104104                echo '<form action="admin.php?import=utw&amp;step=2" method="post">';
    105105                echo '<p class="submit"><input type="submit" name="submit" value="'.__('Step 2 &raquo;').'" /></p>';
    … …  
    107107                echo '</div>';
    108108        }
    109        
    110        
     109
     110
    111111        function import_posts ( ) {
    112112                echo '<div class="narrow">';
    … …  
    129129
    130130                        add_option('utwimp_posts', $posts);
    131                                
     131
    132132
    133133                        $count = count($posts);
    134                                
     134
    135135                        echo '<p>' . sprintf( __('Done! <strong>%s</strong> tag to post relationships were read.'), $count ) . '<br /></p>';
    136                                
     136
    137137                }
    138138
    … …  
    143143
    144144        }
    145        
    146        
     145
     146
    147147        function import_t2p ( ) {
    148148
    … …  
    152152                // run that funky magic!
    153153                $tags_added = $this->tag2post();
    154                
     154
    155155                echo '<p>' . sprintf( __('Done! <strong>%s</strong> tags where added!'), $tags_added ) . '<br /></p>';
    156156
    … …  
    161161
    162162        }
    163        
    164        
     163
     164
    165165        function get_utw_tags ( ) {
    166        
     166
    167167                global $wpdb;
    168                
     168
    169169                // read in all the tags from the UTW tags table: should be wp_tags
    170170                $tags_query = "SELECT tag_id, tag FROM " . $wpdb->prefix . "tags";
    171                
     171
    172172                $tags = $wpdb->get_results($tags_query);
    173                
     173
    174174                // rearrange these tags into something we can actually use
    175175                foreach ( $tags as $tag ) {
    176                        
     176
    177177                        $new_tags[$tag->tag_id] = $tag->tag;
    178                        
    179                 }
    180                
     178
     179                }
     180
    181181                return $new_tags;
    182182
    183183        }
    184        
     184
    185185        function get_utw_posts ( ) {
    186                
     186
    187187                global $wpdb;
    188                
     188
    189189                // read in all the posts from the UTW post->tag table: should be wp_post2tag
    190190                $posts_query = "SELECT tag_id, post_id FROM " . $wpdb->prefix . "post2tag";
    191                
     191
    192192                $posts = $wpdb->get_results($posts_query);
    193                
     193
    194194                return $posts;
    195                
    196         }
    197        
    198        
     195
     196        }
     197
     198
    199199        function tag2post ( ) {
    200                
     200
    201201                // get the tags and posts we imported in the last 2 steps
    202202                $tags = get_option('utwimp_tags');
    203203                $posts = get_option('utwimp_posts');
    204                
     204
    205205                // null out our results
    206206                $tags_added = 0;
    207                
     207
    208208                // loop through each post and add its tags to the db
    209209                foreach ( $posts as $this_post ) {
    210                        
     210
    211211                        $the_post = (int) $this_post->post_id;
    212212                        $the_tag = (int) $this_post->tag_id;
    213                        
     213
    214214                        // what's the tag name for that id?
    215215                        $the_tag = $tags[$the_tag];
    216                        
     216
    217217                        // screw it, just try to add the tag
    218218                        wp_add_post_tags($the_post, $the_tag);
    219219
    220220                        $tags_added++;
    221                        
    222                 }
    223                
     221
     222                }
     223
    224224                // that's it, all posts should be linked to their tags properly, pending any errors we just spit out!
    225225                return $tags_added;
    226                
    227                
    228         }
    229        
    230        
     226
     227
     228        }
     229
     230
    231231        function cleanup_import ( ) {
    232                
     232
    233233                delete_option('utwimp_tags');
    234234                delete_option('utwimp_posts');
    235                
     235
    236236                $this->done();
    237                
    238         }
    239        
    240        
     237
     238        }
     239
     240
    241241        function done ( ) {
    242                
     242
    243243                echo '<div class="narrow">';
    244244                echo '<p><h3>'.__('Import Complete!').'</h3></p>';
    245                
     245
    246246                echo '<p>' . __('OK, so we lied about this being a 5-step program! You&#8217;re done!') . '</p>';
    247                
     247
    248248                echo '<p>' . __('Now wasn&#8217;t that easy?') . '</p>';
    249                
    250                 echo '</div>';
    251                
    252         }
    253        
     249
     250                echo '</div>';
     251
     252        }
     253
    254254
    255255        function UTW_Import ( ) {
    256                
     256
    257257                // Nothing.
    258                
    259         }
    260        
     258
     259        }
     260
    261261}
    262262
Note: See TracChangeset for help on using the changeset viewer.