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/dotclear.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    }
     
    136136        echo '</div>';
    137137    }
    138    
     138
    139139    function greet()
    140140    {
     
    154154        set_magic_quotes_runtime(0);
    155155        $prefix = get_option('tpre');
    156        
     156
    157157        // Get Categories
    158158        return $dcdb->get_results('SELECT * FROM dc_categorie', ARRAY_A);
    159159    }
    160    
     160
    161161    function get_dc_users()
    162162    {
     
    166166        set_magic_quotes_runtime(0);
    167167        $prefix = get_option('tpre');
    168        
     168
    169169        // Get Users
    170        
     170
    171171        return $dcdb->get_results('SELECT * FROM dc_user', ARRAY_A);
    172172    }
    173    
     173
    174174    function get_dc_posts()
    175175    {
     
    178178        set_magic_quotes_runtime(0);
    179179        $prefix = get_option('tpre');
    180        
     180
    181181        // Get Posts
    182182        return $dcdb->get_results('SELECT dc_post.*, dc_categorie.cat_libelle_url AS post_cat_name
     
    184184                          ON dc_post.cat_id = dc_categorie.cat_id', ARRAY_A);
    185185    }
    186    
     186
    187187    function get_dc_comments()
    188188    {
     
    192192        set_magic_quotes_runtime(0);
    193193        $prefix = get_option('tpre');
    194        
     194
    195195        // Get Comments
    196196        return $dcdb->get_results('SELECT * FROM dc_comment', ARRAY_A);
    197197    }
    198    
     198
    199199    function get_dc_links()
    200200    {
     
    206206        return $dcdb->get_results('SELECT * FROM dc_link ORDER BY position', ARRAY_A);
    207207    }
    208    
     208
    209209    function cat2wp($categories='')
    210210    {
     
    221221                $count++;
    222222                extract($category);
    223                
     223
    224224                // Make Nice Variables
    225225                $name = $wpdb->escape($cat_libelle_url);
     
    237237                $dccat2wpcat[$id] = $ret_id;
    238238            }
    239            
     239
    240240            // Store category translation for future use
    241241            add_option('dccat2wpcat',$dccat2wpcat);
     
    246246        return false;
    247247    }
    248    
     248
    249249    function users2wp($users='')
    250250    {
     
    253253        $count = 0;
    254254        $dcid2wpid = array();
    255        
     255
    256256        // Midnight Mojo
    257257        if(is_array($users))
     
    262262                $count++;
    263263                extract($user);
    264                
     264
    265265                // Make Nice Variables
    266266                $name = $wpdb->escape(csc ($name));
    267267                $RealName = $wpdb->escape(csc ($user_pseudo));
    268                
     268
    269269                if($uinfo = get_userdatabylogin($name))
    270270                {
    271                    
     271
    272272                    $ret_id = wp_insert_user(array(
    273273                                'ID'        => $uinfo->ID,
     
    290290                }
    291291                $dcid2wpid[$user_id] = $ret_id;
    292                
     292
    293293                // Set Dotclear-to-WordPress permissions translation
    294                
     294
    295295                // Update Usermeta Data
    296296                $user = new WP_User($ret_id);
     
    303303                else if(2  <= $wp_perms) { $user->set_role('contributor'); }
    304304                else                     { $user->set_role('subscriber'); }
    305                
     305
    306306                update_usermeta( $ret_id, 'wp_user_level', $wp_perms);
    307307                update_usermeta( $ret_id, 'rich_editing', 'false');
     
    309309                update_usermeta( $ret_id, 'last_name', csc ($user_nom));
    310310            }// End foreach($users as $user)
    311            
     311
    312312            // Store id translation array for future use
    313313            add_option('dcid2wpid',$dcid2wpid);
    314            
    315            
     314
     315
    316316            echo '<p>'.sprintf(__('Done! <strong>%1$s</strong> users imported.'), $count).'<br /><br /></p>';
    317317            return true;
    318318        }// End if(is_array($users)
    319        
     319
    320320        echo __('No Users to Import!');
    321321        return false;
    322        
     322
    323323    }// End function user2wp()
    324    
     324
    325325    function posts2wp($posts='')
    326326    {
     
    339339                $count++;
    340340                extract($post);
    341                
     341
    342342                // Set Dotclear-to-WordPress status translation
    343343                $stattrans = array(0 => 'draft', 1 => 'publish');
    344344                $comment_status_map = array (0 => 'closed', 1 => 'open');
    345                
     345
    346346                //Can we do this more efficiently?
    347347                $uinfo = ( get_userdatabylogin( $user_id ) ) ? get_userdatabylogin( $user_id ) : 1;
     
    357357                $post_content = $wpdb->escape ($post_content);
    358358                $post_status = $stattrans[$post_pub];
    359                
     359
    360360                // Import Post data into WordPress
    361                
     361
    362362                if($pinfo = post_exists($Title,$post_content))
    363363                {
     
    398398                }
    399399                $dcposts2wpposts[$post_id] = $ret_id;
    400                
     400
    401401                // Make Post-to-Category associations
    402402                $cats = array();
     
    408408        // Store ID translation for later use
    409409        add_option('dcposts2wpposts',$dcposts2wpposts);
    410        
     410
    411411        echo '<p>'.sprintf(__('Done! <strong>%1$s</strong> posts imported.'), $count).'<br /><br /></p>';
    412         return true;   
    413     }
    414    
     412        return true;
     413    }
     414
    415415    function comments2wp($comments='')
    416416    {
     
    420420        $dccm2wpcm = array();
    421421        $postarr = get_option('dcposts2wpposts');
    422        
     422
    423423        // Magic Mojo
    424424        if(is_array($comments))
     
    429429                $count++;
    430430                extract($comment);
    431                
     431
    432432                // WordPressify Data
    433433                $comment_ID = ltrim($comment_id, '0');
     
    438438                $web = "http://".$wpdb->escape($comment_site);
    439439                $message = $wpdb->escape(textconv ($comment_content));
    440                
     440
    441441                if($cinfo = comment_exists($name, $comment_dt))
    442442                {
     
    473473            }
    474474            // Store Comment ID translation for future use
    475             add_option('dccm2wpcm', $dccm2wpcm);           
    476            
     475            add_option('dccm2wpcm', $dccm2wpcm);
     476
    477477            // Associate newly formed categories with posts
    478478            get_comment_count($ret_id);
    479            
    480            
     479
     480
    481481            echo '<p>'.sprintf(__('Done! <strong>%1$s</strong> comments imported.'), $count).'<br /><br /></p>';
    482482            return true;
     
    485485        return false;
    486486    }
    487    
     487
    488488    function links2wp($links='')
    489489    {
     
    491491        global $wpdb;
    492492        $count = 0;
    493        
     493
    494494        // Deal with the links
    495495        if(is_array($links))
     
    500500                $count++;
    501501                extract($link);
    502                
     502
    503503                if ($title != "") {
    504504                    if ($cinfo = link_cat_exists (csc ($title))) {
     
    512512                    $linkname = $wpdb->escape(csc ($label));
    513513                    $description = $wpdb->escape(csc ($title));
    514                
     514
    515515                    if($linfo = link_exists($linkname)) {
    516516                        $ret_id = wp_insert_link(array(
     
    541541        return false;
    542542    }
    543        
     543
    544544    function import_categories()
    545     {   
    546         // Category Import 
     545    {
     546        // Category Import
    547547        $cats = $this->get_dc_cats();
    548548        $this->cat2wp($cats);
    549549        add_option('dc_cats', $cats);
    550        
    551        
    552            
     550
     551
     552
    553553        echo '<form action="admin.php?import=dotclear&amp;step=2" method="post">';
    554554        printf('<input type="submit" name="submit" value="%s" />', __('Import Users'));
     
    556556
    557557    }
    558    
     558
    559559    function import_users()
    560560    {
     
    562562        $users = $this->get_dc_users();
    563563        $this->users2wp($users);
    564        
     564
    565565        echo '<form action="admin.php?import=dotclear&amp;step=3" method="post">';
    566566        printf('<input type="submit" name="submit" value="%s" />', __('Import Posts'));
    567567        echo '</form>';
    568568    }
    569    
     569
    570570    function import_posts()
    571571    {
     
    573573        $posts = $this->get_dc_posts();
    574574        $this->posts2wp($posts);
    575        
     575
    576576        echo '<form action="admin.php?import=dotclear&amp;step=4" method="post">';
    577577        printf('<input type="submit" name="submit" value="%s" />', __('Import Comments'));
    578578        echo '</form>';
    579579    }
    580    
     580
    581581    function import_comments()
    582582    {
     
    584584        $comments = $this->get_dc_comments();
    585585        $this->comments2wp($comments);
    586        
     586
    587587        echo '<form action="admin.php?import=dotclear&amp;step=5" method="post">';
    588588        printf('<input type="submit" name="submit" value="%s" />', __('Import Links'));
    589589        echo '</form>';
    590590    }
    591    
     591
    592592    function import_links()
    593593    {
     
    596596        $this->links2wp($links);
    597597        add_option('dc_links', $links);
    598        
     598
    599599        echo '<form action="admin.php?import=dotclear&amp;step=6" method="post">';
    600600        printf('<input type="submit" name="submit" value="%s" />', __('Finish'));
    601601        echo '</form>';
    602602    }
    603    
     603
    604604    function cleanup_dcimport()
    605605    {
     
    618618        $this->tips();
    619619    }
    620    
     620
    621621    function tips()
    622622    {
     
    637637        echo '<p>'.sprintf(__('That\'s it! What are you waiting for? Go <a href="%1$s">login</a>!'), '/wp-login.php').'</p>';
    638638    }
    639    
     639
    640640    function db_form()
    641641    {
     
    649649        echo '</ul>';
    650650    }
    651    
     651
    652652    function dispatch()
    653653    {
     
    658658            $step = (int) $_GET['step'];
    659659        $this->header();
    660        
     660
    661661        if ( $step > 0 )
    662662        {
     
    664664            {
    665665                if(get_option('dcuser'))
    666                     delete_option('dcuser');   
     666                    delete_option('dcuser');
    667667                add_option('dcuser',$_POST['dbuser']);
    668668            }
     
    670670            {
    671671                if(get_option('dcpass'))
    672                     delete_option('dcpass');   
     672                    delete_option('dcpass');
    673673                add_option('dcpass',$_POST['dbpass']);
    674674            }
    675            
     675
    676676            if($_POST['dbname'])
    677677            {
    678678                if(get_option('dcname'))
    679                     delete_option('dcname');   
     679                    delete_option('dcname');
    680680                add_option('dcname',$_POST['dbname']);
    681681            }
     
    691691                    delete_option('dccharset');
    692692                add_option('dccharset',$_POST['dccharset']);
    693             }           
     693            }
    694694            if($_POST['dbprefix'])
    695695            {
     
    697697                    delete_option('tpre');
    698698                add_option('tpre',$_POST['dbprefix']);
    699             }           
     699            }
    700700
    701701
     
    727727                break;
    728728        }
    729        
     729
    730730        $this->footer();
    731731    }
     
    733733    function Dotclear_Import()
    734734    {
    735         // Nothing. 
     735        // Nothing.
    736736    }
    737737}
Note: See TracChangeset for help on using the changeset viewer.