Make WordPress Core


Ignore:
Timestamp:
02/12/2006 07:53:23 AM (19 years ago)
Author:
ryan
Message:

Death to trailing tabs. Props Mark J. fixes #2405

File:
1 edited

Legend:

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

    r3424 r3517  
    88    {
    99    global $wpdb;
    10    
     10
    1111    $cat_id -= 0;   // force numeric
    1212    $name = $wpdb->get_var('SELECT cat_ID FROM '.$wpdb->categories.' WHERE category_nicename="'.$category_nicename.'"');
    13    
     13
    1414    return $name;
    1515    }
     
    5050        echo '</div>';
    5151    }
    52    
     52
    5353    function greet()
    5454    {
     
    6868        set_magic_quotes_runtime(0);
    6969        $prefix = get_option('tpre');
    70        
     70
    7171        // Get Categories
    7272        return $txpdb->get_results('SELECT
     
    7878                                     ARRAY_A);
    7979    }
    80    
     80
    8181    function get_txp_users()
    8282    {
     
    8686        set_magic_quotes_runtime(0);
    8787        $prefix = get_option('tpre');
    88        
     88
    8989        // Get Users
    90        
     90
    9191        return $txpdb->get_results('SELECT
    9292                                        user_id,
     
    9797                                    FROM '.$prefix.'txp_users', ARRAY_A);
    9898    }
    99    
     99
    100100    function get_txp_posts()
    101101    {
     
    104104        set_magic_quotes_runtime(0);
    105105        $prefix = get_option('tpre');
    106        
     106
    107107        // Get Posts
    108108        return $txpdb->get_results('SELECT
     
    123123                                    ', ARRAY_A);
    124124    }
    125    
     125
    126126    function get_txp_comments()
    127127    {
     
    131131        set_magic_quotes_runtime(0);
    132132        $prefix = get_option('tpre');
    133        
     133
    134134        // Get Comments
    135135        return $txpdb->get_results('SELECT * FROM '.$prefix.'txp_discuss', ARRAY_A);
    136136    }
    137    
     137
    138138        function get_txp_links()
    139139    {
     
    142142        set_magic_quotes_runtime(0);
    143143        $prefix = get_option('tpre');
    144        
     144
    145145        return $txpdb->get_results('SELECT
    146146                                        id,
     
    153153                                      ARRAY_A);                       
    154154    }
    155    
     155
    156156    function cat2wp($categories='')
    157157    {
     
    168168                $count++;
    169169                extract($category);
    170                
    171                
     170
     171
    172172                // Make Nice Variables
    173173                $name = $wpdb->escape($name);
    174174                $title = $wpdb->escape($title);
    175                
     175
    176176                if($cinfo = category_exists($name))
    177177                {
     
    184184                $txpcat2wpcat[$id] = $ret_id;
    185185            }
    186            
     186
    187187            // Store category translation for future use
    188188            add_option('txpcat2wpcat',$txpcat2wpcat);
     
    193193        return false;
    194194    }
    195    
     195
    196196    function users2wp($users='')
    197197    {
     
    200200        $count = 0;
    201201        $txpid2wpid = array();
    202        
     202
    203203        // Midnight Mojo
    204204        if(is_array($users))
     
    209209                $count++;
    210210                extract($user);
    211                
     211
    212212                // Make Nice Variables
    213213                $name = $wpdb->escape($name);
    214214                $RealName = $wpdb->escape($RealName);
    215                
     215
    216216                if($uinfo = get_userdatabylogin($name))
    217217                {
    218                    
     218
    219219                    $ret_id = wp_insert_user(array(
    220220                                'ID'            => $uinfo->ID,
     
    237237                }
    238238                $txpid2wpid[$user_id] = $ret_id;
    239                
     239
    240240                // Set Textpattern-to-WordPress permissions translation
    241241                $transperms = array(1 => '10', 2 => '9', 3 => '5', 4 => '4', 5 => '3', 6 => '2', 7 => '0');
    242                
     242
    243243                // Update Usermeta Data
    244244                $user = new WP_User($ret_id);
     
    250250                if('2'  == $transperms[$privs]) { $user->set_role('contributor'); }
    251251                if('0'  == $transperms[$privs]) { $user->set_role('subscriber'); }
    252                
     252
    253253                update_usermeta( $ret_id, 'wp_user_level', $transperms[$privs] );
    254254                update_usermeta( $ret_id, 'rich_editing', 'false');
    255255            }// End foreach($users as $user)
    256            
     256
    257257            // Store id translation array for future use
    258258            add_option('txpid2wpid',$txpid2wpid);
    259            
    260            
     259
     260
    261261            echo '<p>'.sprintf(__('Done! <strong>%1$s</strong> users imported.'), $count).'<br /><br /></p>';
    262262            return true;
    263263        }// End if(is_array($users)
    264        
     264
    265265        echo __('No Users to Import!');
    266266        return false;
    267        
     267
    268268    }// End function user2wp()
    269    
     269
    270270    function posts2wp($posts='')
    271271    {
     
    284284                $count++;
    285285                extract($post);
    286                
     286
    287287                // Set Textpattern-to-WordPress status translation
    288288                $stattrans = array(1 => 'draft', 2 => 'private', 3 => 'draft', 4 => 'publish', 5 => 'publish');
    289                
     289
    290290                //Can we do this more efficiently?
    291291                $uinfo = ( get_userdatabylogin( $AuthorID ) ) ? get_userdatabylogin( $AuthorID ) : 1;
     
    296296                $Excerpt = $wpdb->escape($Excerpt);
    297297                $post_status = $stattrans[$Status];
    298                
     298
    299299                // Import Post data into WordPress
    300                
     300
    301301                if($pinfo = post_exists($Title,$Body))
    302302                {
     
    333333                }
    334334                $txpposts2wpposts[$ID] = $ret_id;
    335                
     335
    336336                // Make Post-to-Category associations
    337337                $cats = array();
     
    344344        // Store ID translation for later use
    345345        add_option('txpposts2wpposts',$txpposts2wpposts);
    346        
     346
    347347        echo '<p>'.sprintf(__('Done! <strong>%1$s</strong> posts imported.'), $count).'<br /><br /></p>';
    348         return true;   
    349     }
    350    
     348        return true;
     349    }
     350
    351351    function comments2wp($comments='')
    352352    {
     
    356356        $txpcm2wpcm = array();
    357357        $postarr = get_option('txpposts2wpposts');
    358        
     358
    359359        // Magic Mojo
    360360        if(is_array($comments))
     
    365365                $count++;
    366366                extract($comment);
    367                
     367
    368368                // WordPressify Data
    369369                $comment_ID = ltrim($discussid, '0');
     
    374374                $web = $wpdb->escape($web);
    375375                $message = $wpdb->escape($message);
    376                
     376
    377377                if($cinfo = comment_exists($name, $posted))
    378378                {
     
    406406            }
    407407            // Store Comment ID translation for future use
    408             add_option('txpcm2wpcm', $txpcm2wpcm);         
    409            
     408            add_option('txpcm2wpcm', $txpcm2wpcm);
     409
    410410            // Associate newly formed categories with posts
    411411            get_comment_count($ret_id);
    412            
    413            
     412
     413
    414414            echo '<p>'.sprintf(__('Done! <strong>%1$s</strong> comments imported.'), $count).'<br /><br /></p>';
    415415            return true;
     
    418418        return false;
    419419    }
    420    
     420
    421421    function links2wp($links='')
    422422    {
     
    424424        global $wpdb;
    425425        $count = 0;
    426        
     426
    427427        // Deal with the links
    428428        if(is_array($links))
     
    433433                $count++;
    434434                extract($link);
    435                
     435
    436436                // Make nice vars
    437437                $category = $wpdb->escape($category);
    438438                $linkname = $wpdb->escape($linkname);
    439439                $description = $wpdb->escape($description);
    440                
     440
    441441                if($linfo = link_exists($linkname))
    442442                {
     
    471471        return false;
    472472    }
    473        
     473
    474474    function import_categories()
    475     {   
    476         // Category Import 
     475    {
     476        // Category Import
    477477        $cats = $this->get_txp_cats();
    478478        $this->cat2wp($cats);
    479479        add_option('txp_cats', $cats);
    480        
    481        
    482            
     480
     481
     482
    483483        echo '<form action="admin.php?import=textpattern&amp;step=2" method="post">';
    484484        printf('<input type="submit" name="submit" value="%s" />', __('Import Users'));
     
    486486
    487487    }
    488    
     488
    489489    function import_users()
    490490    {
     
    492492        $users = $this->get_txp_users();
    493493        $this->users2wp($users);
    494        
     494
    495495        echo '<form action="admin.php?import=textpattern&amp;step=3" method="post">';
    496496        printf('<input type="submit" name="submit" value="%s" />', __('Import Posts'));
    497497        echo '</form>';
    498498    }
    499    
     499
    500500    function import_posts()
    501501    {
     
    503503        $posts = $this->get_txp_posts();
    504504        $this->posts2wp($posts);
    505        
     505
    506506        echo '<form action="admin.php?import=textpattern&amp;step=4" method="post">';
    507507        printf('<input type="submit" name="submit" value="%s" />', __('Import Comments'));
    508508        echo '</form>';
    509509    }
    510    
     510
    511511    function import_comments()
    512512    {
     
    514514        $comments = $this->get_txp_comments();
    515515        $this->comments2wp($comments);
    516        
     516
    517517        echo '<form action="admin.php?import=textpattern&amp;step=5" method="post">';
    518518        printf('<input type="submit" name="submit" value="%s" />', __('Import Links'));
    519519        echo '</form>';
    520520    }
    521    
     521
    522522    function import_links()
    523523    {
     
    526526        $this->links2wp($links);
    527527        add_option('txp_links', $links);
    528        
     528
    529529        echo '<form action="admin.php?import=textpattern&amp;step=6" method="post">';
    530530        printf('<input type="submit" name="submit" value="%s" />', __('Finish'));
    531531        echo '</form>';
    532532    }
    533    
     533
    534534    function cleanup_txpimport()
    535535    {
     
    547547        $this->tips();
    548548    }
    549    
     549
    550550    function tips()
    551551    {
     
    566566        echo '<p>'.sprintf(__('That\'s it! What are you waiting for? Go <a href="%1$s">login</a>!'), '/wp-login.php').'</p>';
    567567    }
    568    
     568
    569569    function db_form()
    570570    {
     
    577577        echo '</ul>';
    578578    }
    579    
     579
    580580    function dispatch()
    581581    {
     
    586586            $step = (int) $_GET['step'];
    587587        $this->header();
    588        
     588
    589589        if ( $step > 0 )
    590590        {
     
    592592            {
    593593                if(get_option('txpuser'))
    594                     delete_option('txpuser');   
     594                    delete_option('txpuser');
    595595                add_option('txpuser',$_POST['dbuser']);
    596596            }
     
    598598            {
    599599                if(get_option('txppass'))
    600                     delete_option('txppass');   
     600                    delete_option('txppass');
    601601                add_option('txppass',$_POST['dbpass']);
    602602            }
    603            
     603
    604604            if($_POST['dbname'])
    605605            {
    606606                if(get_option('txpname'))
    607                     delete_option('txpname');   
     607                    delete_option('txpname');
    608608                add_option('txpname',$_POST['dbname']);
    609609            }
     
    619619                    delete_option('tpre');
    620620                add_option('tpre',$_POST['dbprefix']);
    621             }           
     621            }
    622622
    623623
     
    649649                break;
    650650        }
    651        
     651
    652652        $this->footer();
    653653    }
     
    655655    function Textpattern_Import()
    656656    {
    657         // Nothing. 
     657        // Nothing.
    658658    }
    659659}
Note: See TracChangeset for help on using the changeset viewer.