Dotclear


Ignore:
Timestamp:
11/17/13 20:25:53 (12 years ago)
Author:
franck <carnet.franck.paul@…>
Branch:
2.6
Children:
2567:6c11245cbf04, 2568:61c67a7d17fa
Message:

Add some people in CREDITS, remove trailing spaces and tabs.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • plugins/importExport/inc/class.dc.import.wp.php

    r1719 r2566  
    1717     protected $prefix; 
    1818     protected $blog_id; 
    19       
     19 
    2020     protected $action = null; 
    2121     protected $step = 1; 
    22       
     22 
    2323     protected $post_offset = 0; 
    2424     protected $post_limit = 20; 
    2525     protected $post_count = 0; 
    26       
     26 
    2727     protected $has_table = array(); 
    28       
     28 
    2929     protected $vars; 
    3030     protected $base_vars = array( 
     
    4545          'permalink_template' => 'p=%post_id%', 
    4646          'permalink_tags' => array( 
    47                '%year%',  
    48                '%monthnum%',  
    49                '%day%',  
    50                '%hour%',  
    51                '%minute%',  
    52                '%second%',  
    53                '%postname%',  
    54                '%post_id%',  
    55                '%category%',  
     47               '%year%', 
     48               '%monthnum%', 
     49               '%day%', 
     50               '%hour%', 
     51               '%minute%', 
     52               '%second%', 
     53               '%postname%', 
     54               '%post_id%', 
     55               '%category%', 
    5656               '%author%' 
    5757          ) 
    5858     ); 
    5959     protected $formaters; 
    60       
     60 
    6161     protected function setInfo() 
    6262     { 
     
    6565          $this->description = __('Import a WordPress installation into your current blog.'); 
    6666     } 
    67       
     67 
    6868     public function init() 
    6969     { 
     
    7171          $this->prefix = $this->core->prefix; 
    7272          $this->blog_id = $this->core->blog->id; 
    73            
     73 
    7474          if (!isset($_SESSION['wp_import_vars'])) { 
    7575               $_SESSION['wp_import_vars'] = $this->base_vars; 
    7676          } 
    7777          $this->vars =& $_SESSION['wp_import_vars']; 
    78            
     78 
    7979          if ($this->vars['post_limit'] > 0) { 
    8080               $this->post_limit = $this->vars['post_limit']; 
     
    8383          $this->formaters = dcAdminCombos::getFormatersCombo(); 
    8484     } 
    85       
     85 
    8686     public function resetVars() 
    8787     { 
     
    8989          unset($_SESSION['wp_import_vars']); 
    9090     } 
    91       
     91 
    9292     public function process($do) 
    9393     { 
    9494          $this->action = $do; 
    9595     } 
    96       
     96 
    9797     # We handle process in another way to always display something to 
    9898     # user 
     
    159159          } 
    160160     } 
    161       
     161 
    162162     public function gui() 
    163163     { 
     
    167167               $this->error($e); 
    168168          } 
    169            
     169 
    170170          switch ($this->step) 
    171171          { 
     
    176176                    '<p class="warning">'.__('Please note that this process '. 
    177177                    'will empty your categories, blogroll, entries and comments on the current blog.').'</p>'; 
    178                      
     178 
    179179                    printf($this->imForm(1,__('General information'),__('Import my blog now')), 
    180180                    '<p>'.__('We first need some information about your old WordPress installation.').'</p>'. 
     
    218218                    form::field('post_limit',3,3,html::escapeHTML($this->vars['post_limit'])).'</p>'. 
    219219                    '</div>'. 
    220                      
     220 
    221221                    '</div>'. 
    222222 
     
    253253                    break; 
    254254               case 6: 
    255                     echo  
     255                    echo 
    256256                    '<p class="message">'.__('Every newly imported user has received a random password '. 
    257257                    'and will need to ask for a new one by following the "I forgot my password" link on the login page '. 
     
    261261          } 
    262262     } 
    263       
     263 
    264264     # Simple form for step by step process 
    265265     protected function imForm($step,$legend,$submit_value=null) 
     
    268268               $submit_value = __('next step').' >'; 
    269269          } 
    270            
     270 
    271271          return 
    272272          '<form action="'.$this->getURL(true).'" method="post">'. 
     
    279279          '</form>'; 
    280280     } 
    281       
     281 
    282282     # Error display 
    283283     protected function error($e) 
     
    286286          '<p>'.$e->getMessage().'</p></div>'; 
    287287     } 
    288       
     288 
    289289     # Database init 
    290290     protected function db() 
    291291     { 
    292292          $db = dbLayer::init('mysql',$this->vars['db_host'],$this->vars['db_name'],$this->vars['db_user'],$this->vars['db_pwd']); 
    293            
     293 
    294294          $rs = $db->select("SHOW TABLES LIKE '".$this->vars['db_prefix']."%'"); 
    295295          if ($rs->isEmpty()) { 
    296296               throw new Exception(__('WordPress tables not found')); 
    297297          } 
    298            
     298 
    299299          while ($rs->fetch()) { 
    300300               $this->has_table[$rs->f(0)] = true; 
    301301          } 
    302            
     302 
    303303          # Set this to read data as they were written 
    304304          try { 
    305305               $db->execute('SET NAMES DEFAULT'); 
    306306          } catch (Exception $e) {} 
    307            
     307 
    308308          $db->execute('SET CHARACTER SET DEFAULT'); 
    309309          $db->execute("SET COLLATION_CONNECTION = DEFAULT"); 
     
    311311          $db->execute("SET CHARACTER_SET_SERVER = DEFAULT"); 
    312312          $db->execute("SET CHARACTER_SET_DATABASE = DEFAULT"); 
    313            
     313 
    314314          $this->post_count = $db->select( 
    315315               'SELECT COUNT(ID) FROM '.$this->vars['db_prefix'].'posts '. 
    316316               'WHERE post_type = \'post\' OR post_type = \'page\'' 
    317317          )->f(0); 
    318            
     318 
    319319          return $db; 
    320320     } 
    321       
     321 
    322322     protected function cleanStr($str) 
    323323     { 
    324324          return text::cleanUTF8(@text::toUTF8($str)); 
    325325     } 
    326       
     326 
    327327     # Users import 
    328328     protected function importUsers() 
     
    331331          $prefix = $this->vars['db_prefix']; 
    332332          $rs = $db->select('SELECT * FROM '.$prefix.'users'); 
    333            
     333 
    334334          try 
    335335          { 
    336336               $this->con->begin(); 
    337                 
     337 
    338338               while ($rs->fetch()) 
    339339               { 
     
    352352                         $cur->user_tz          = $this->core->blog->settings->system->blog_timezone; 
    353353                         $permissions           = array(); 
    354                           
     354 
    355355                         $rs_meta = $db->select('SELECT * FROM '.$prefix.'usermeta WHERE user_id = '.$rs->ID); 
    356356                         while ($rs_meta->fetch()) 
     
    425425          } 
    426426     } 
    427       
     427 
    428428     # Categories import 
    429429     protected function importCategories() 
     
    438438               'ORDER BY t.term_id ASC' 
    439439          ); 
    440            
     440 
    441441          try 
    442442          { 
     
    445445                    "WHERE blog_id = '".$this->con->escape($this->blog_id)."' " 
    446446               ); 
    447                 
     447 
    448448               $ord = 2; 
    449449               while ($rs->fetch()) 
     
    456456                    $cur->cat_lft      = $ord++; 
    457457                    $cur->cat_rgt      = $ord++; 
    458                      
     458 
    459459                    $cur->cat_id = $this->con->select( 
    460460                         'SELECT MAX(cat_id) FROM '.$this->prefix.'category' 
     
    463463                    $cur->insert(); 
    464464               } 
    465                 
     465 
    466466               $db->close(); 
    467467          } 
     
    472472          } 
    473473     } 
    474       
     474 
    475475     # Blogroll import 
    476476     protected function importLinks() 
     
    479479          $prefix = $this->vars['db_prefix']; 
    480480          $rs = $db->select('SELECT * FROM '.$prefix.'links ORDER BY link_id ASC'); 
    481            
     481 
    482482          try 
    483483          { 
     
    486486                    "WHERE blog_id = '".$this->con->escape($this->blog_id)."' " 
    487487               ); 
    488                 
     488 
    489489               while ($rs->fetch()) 
    490490               { 
     
    495495                    $cur->link_desc     = $this->cleanStr($rs->link_description); 
    496496                    $cur->link_xfn      = $this->cleanStr($rs->link_rel); 
    497                      
     497 
    498498                    $cur->link_id = $this->con->select( 
    499499                         'SELECT MAX(link_id) FROM '.$this->prefix.'link' 
     
    501501                    $cur->insert(); 
    502502               } 
    503                 
     503 
    504504               $db->close(); 
    505505          } 
     
    510510          } 
    511511     } 
    512       
     512 
    513513     # Entries import 
    514514     protected function importPosts(&$percent) 
     
    516516          $db = $this->db(); 
    517517          $prefix = $this->vars['db_prefix']; 
    518            
     518 
    519519          $plink = $db->select( 
    520520                    'SELECT option_value FROM '.$prefix.'options '. 
     
    524524               $this->vars['permalink_template'] = substr($plink,1); 
    525525          } 
    526            
     526 
    527527          $rs = $db->select( 
    528528               'SELECT * FROM '.$prefix.'posts '. 
     
    531531               $db->limit($this->post_offset,$this->post_limit) 
    532532          ); 
    533            
     533 
    534534          try 
    535535          { 
     
    540540                         "WHERE blog_id = '".$this->con->escape($this->blog_id)."' " 
    541541                    ); 
    542                }     
    543                 
     542               } 
     543 
    544544               while ($rs->fetch()) { 
    545545                    $this->importPost($rs,$db); 
    546546               } 
    547                 
     547 
    548548               $db->close(); 
    549549          } 
     
    553553               throw $e; 
    554554          } 
    555            
     555 
    556556          if ($rs->count() < $this->post_limit) { 
    557557               return -1; 
     
    559559               $this->post_offset += $this->post_limit; 
    560560          } 
    561            
     561 
    562562          if ($this->post_offset > $this->post_count) { 
    563563               $percent = 100; 
     
    566566          } 
    567567     } 
    568       
     568 
    569569     protected function importPost($rs,$db) 
    570570     { 
     
    575575               $user_id = $this->vars['user_ids'][$rs->post_author]; 
    576576          } 
    577            
     577 
    578578          $cur = $this->con->openCursor($this->prefix.'post'); 
    579579          $cur->blog_id     = $this->blog_id; 
     
    583583          $cur->post_upddt  = $rs->post_modified; 
    584584          $cur->post_title  = $this->cleanStr($rs->post_title); 
    585            
     585 
    586586          if (!$cur->post_title) { 
    587587               $cur->post_title = 'No title'; 
    588588          } 
    589            
     589 
    590590          if ($this->vars['cat_import'] || $this->vars['cat_as_tags']) 
    591591          { 
     
    601601                    ' ORDER BY t.term_id ASC ' 
    602602                    ); 
    603                if (!$old_cat_ids->isEmpty() && $this->vars['cat_import'])  
     603               if (!$old_cat_ids->isEmpty() && $this->vars['cat_import']) 
    604604               { 
    605605                    $cur->cat_id = $this->vars['cat_ids'][(integer) $old_cat_ids->term_id]; 
    606606               } 
    607607          } 
    608            
     608 
    609609          $permalink_infos = array( 
    610                date('Y',strtotime($cur->post_dt)),  
    611                date('m',strtotime($cur->post_dt)),  
    612                date('d',strtotime($cur->post_dt)),  
    613                date('H',strtotime($cur->post_dt)),  
    614                date('i',strtotime($cur->post_dt)),  
    615                date('s',strtotime($cur->post_dt)),  
    616                $rs->post_name,  
    617                $rs->ID,  
    618                $cur->cat_id,  
     610               date('Y',strtotime($cur->post_dt)), 
     611               date('m',strtotime($cur->post_dt)), 
     612               date('d',strtotime($cur->post_dt)), 
     613               date('H',strtotime($cur->post_dt)), 
     614               date('i',strtotime($cur->post_dt)), 
     615               date('s',strtotime($cur->post_dt)), 
     616               $rs->post_name, 
     617               $rs->ID, 
     618               $cur->cat_id, 
    619619               $cur->user_id 
    620620          ); 
     
    625625          ); 
    626626          $cur->post_url = substr($cur->post_url,0,255); 
    627            
     627 
    628628          if (!$cur->post_url) { 
    629629               $cur->post_url = $rs->ID; 
    630630          } 
    631            
     631 
    632632          $cur->post_format = $this->vars['post_formater']; 
    633633          $_post_content = explode('<!--more-->',$rs->post_content,2); 
     
    639639               $cur->post_content = $this->cleanStr(array_shift($_post_content)); 
    640640          } 
    641            
     641 
    642642          $cur->post_content_xhtml = $this->core->callFormater($this->vars['post_formater'],$cur->post_content); 
    643643          $cur->post_excerpt_xhtml = $this->core->callFormater($this->vars['post_formater'],$cur->post_excerpt); 
    644            
     644 
    645645          switch ($rs->post_status) 
    646646          { 
     
    661661          $cur->post_open_comment = $rs->comment_status == 'open' ? 1 : 0; 
    662662          $cur->post_open_tb      = $rs->ping_status == 'open' ? 1 : 0; 
    663            
     663 
    664664          $cur->post_words = implode(' ',text::splitWords( 
    665665               $cur->post_title.' '. 
     
    667667               $cur->post_content_xhtml 
    668668          )); 
    669            
     669 
    670670          $cur->post_id = $this->con->select( 
    671671               'SELECT MAX(post_id) FROM '.$this->prefix.'post' 
    672672               )->f(0) + 1; 
    673            
     673 
    674674          $cur->post_url = $this->core->blog->getPostURL($cur->post_url,$cur->post_dt,$cur->post_title,$cur->post_id); 
    675            
     675 
    676676          $cur->insert(); 
    677677          $this->importComments($rs->ID,$cur->post_id,$db); 
    678678          $this->importPings($rs->ID,$cur->post_id,$db); 
    679            
     679 
    680680          # Create tags 
    681681          $this->importTags($rs->ID,$cur->post_id,$db); 
    682            
     682 
    683683          if (isset($old_cat_ids)) 
    684684          { 
    685                if (!$old_cat_ids->isEmpty() && $this->vars['cat_as_tags'])  
     685               if (!$old_cat_ids->isEmpty() && $this->vars['cat_as_tags']) 
    686686               { 
    687687                    $old_cat_ids->moveStart(); 
     
    692692          } 
    693693     } 
    694       
     694 
    695695     # Comments import 
    696696     protected function importComments($post_id,$new_post_id,$db) 
    697697     { 
    698698          $count_c = $count_t = 0; 
    699            
     699 
    700700          $rs = $db->select( 
    701701               'SELECT * FROM '.$this->vars['db_prefix'].'comments '. 
    702702               'WHERE comment_post_ID = '.(integer) $post_id.' ' 
    703703               ); 
    704            
     704 
    705705          while ($rs->fetch()) 
    706706          { 
     
    716716               $cur->comment_site = substr($this->cleanStr($rs->comment_author_url),0,255); 
    717717               if ($cur->comment_site == '') $cur->comment_site = NULL; 
    718                 
     718 
    719719               if ($rs->comment_approved == 'spam') { 
    720720                    $cur->comment_status = -2; 
    721721               } 
    722                 
     722 
    723723               $cur->comment_words = implode(' ',text::splitWords($cur->comment_content)); 
    724                 
     724 
    725725               $cur->comment_id = $this->con->select( 
    726726                    'SELECT MAX(comment_id) FROM '.$this->prefix.'comment' 
    727727               )->f(0) + 1; 
    728                 
     728 
    729729               $cur->insert(); 
    730                 
     730 
    731731               if ($cur->comment_trackback && $cur->comment_status == 1) { 
    732732                    $count_t++; 
     
    735735               } 
    736736          } 
    737            
     737 
    738738          if ($count_t > 0 || $count_c > 0) 
    739739          { 
     
    746746          } 
    747747     } 
    748       
     748 
    749749     # Pings import 
    750750     protected function importPings($post_id,$new_post_id,$db) 
     
    752752          $urls = array(); 
    753753          $pings = array(); 
    754            
     754 
    755755          $rs = $db->select( 
    756756               'SELECT pinged FROM '.$this->vars['db_prefix'].'posts '. 
     
    759759          $pings = explode ("\n",$rs->pinged); 
    760760          unset ($pings[0]); 
    761            
     761 
    762762          foreach($pings as $ping_url) 
    763763          { 
     
    766766                    continue; 
    767767               } 
    768                 
     768 
    769769               $cur = $this->con->openCursor($this->prefix.'ping'); 
    770770               $cur->post_id = (integer) $new_post_id; 
    771771               $cur->ping_url = $url; 
    772772               $cur->insert(); 
    773                 
     773 
    774774               $urls[$url] = true; 
    775775          } 
    776776     } 
    777       
     777 
    778778     # Meta import 
    779779     protected function importTags($post_id,$new_post_id,$db) 
     
    789789               ' ORDER BY t.term_id ASC' 
    790790          ); 
    791            
     791 
    792792          if ($rs->isEmpty()) { 
    793793               return; 
    794794          } 
    795            
     795 
    796796          while ($rs->fetch()) { 
    797797               $this->core->meta->setPostMeta($new_post_id,'tag',$this->cleanStr($rs->name)); 
     
    799799     } 
    800800} 
    801 ?> 
Note: See TracChangeset for help on using the changeset viewer.

Sites map