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.dc1.php

    r1622 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( 
     
    3737          'cat_ids' => array() 
    3838     ); 
    39       
     39 
    4040     protected function setInfo() 
    4141     { 
     
    4444          $this->description = __('Import a Dotclear 1.2 installation into your current blog.'); 
    4545     } 
    46       
     46 
    4747     public function init() 
    4848     { 
     
    5050          $this->prefix = $this->core->prefix; 
    5151          $this->blog_id = $this->core->blog->id; 
    52            
     52 
    5353          if (!isset($_SESSION['dc1_import_vars'])) { 
    5454               $_SESSION['dc1_import_vars'] = $this->base_vars; 
    5555          } 
    5656          $this->vars =& $_SESSION['dc1_import_vars']; 
    57            
     57 
    5858          if ($this->vars['post_limit'] > 0) { 
    5959               $this->post_limit = $this->vars['post_limit']; 
    6060          } 
    6161     } 
    62       
     62 
    6363     public function resetVars() 
    6464     { 
     
    6666          unset($_SESSION['dc1_import_vars']); 
    6767     } 
    68       
     68 
    6969     public function process($do) 
    7070     { 
    7171          $this->action = $do; 
    7272     } 
    73       
     73 
    7474     # We handle process in another way to always display something to 
    7575     # user 
     
    130130          } 
    131131     } 
    132       
     132 
    133133     public function gui() 
    134134     { 
     
    138138               $this->error($e); 
    139139          } 
    140            
     140 
    141141          switch ($this->step) 
    142142          { 
     
    147147                    '<p class="warning">'.__('Please note that this process '. 
    148148                    'will empty your categories, blogroll, entries and comments on the current blog.').'</p>'; 
    149                      
     149 
    150150                    printf($this->imForm(1,__('General information'),__('Import my blog now')), 
    151151                    '<p>'.__('We first need some information about your old Dotclear 1.2 installation.').'</p>'. 
     
    189189                    break; 
    190190               case 6: 
    191                     echo  
     191                    echo 
    192192                    '<h3 class="vertical-separator">'.__('Please read carefully').'</h3>'. 
    193193                    '<ul>'. 
     
    195195                    'and will need to ask for a new one by following the "I forgot my password" link on the login page '. 
    196196                    '(Their registered email address has to be valid.)').'</li>'. 
    197                      
     197 
    198198                    '<li>'.sprintf(__('Please note that Dotclear 2 has a new URL layout. You can avoid broken '. 
    199199                    'links by installing <a href="%s">DC1 redirect</a> plugin and activate it in your blog configuration.'), 
    200200                    'http://plugins.dotaddict.org/dc2/details/dc1redirect').'</li>'. 
    201201                    '</ul>'. 
    202                      
     202 
    203203                    $this->congratMessage(); 
    204                      
    205                     break; 
    206           } 
    207      } 
    208       
     204 
     205                    break; 
     206          } 
     207     } 
     208 
    209209     # Simple form for step by step process 
    210210     protected function imForm($step,$legend,$submit_value=null) 
     
    213213               $submit_value = __('next step').' >'; 
    214214          } 
    215            
     215 
    216216          return 
    217217          '<form action="'.$this->getURL(true).'" method="post">'. 
     
    224224          '</form>'; 
    225225     } 
    226       
     226 
    227227     # Error display 
    228228     protected function error($e) 
     
    231231          '<p>'.$e->getMessage().'</p></div>'; 
    232232     } 
    233       
     233 
    234234     # Database init 
    235235     protected function db() 
    236236     { 
    237237          $db = dbLayer::init('mysql',$this->vars['db_host'],$this->vars['db_name'],$this->vars['db_user'],$this->vars['db_pwd']); 
    238            
     238 
    239239          $rs = $db->select("SHOW TABLES LIKE '".$this->vars['db_prefix']."%'"); 
    240240          if ($rs->isEmpty()) { 
    241241               throw new Exception(__('Dotclear tables not found')); 
    242242          } 
    243            
     243 
    244244          while ($rs->fetch()) { 
    245245               $this->has_table[$rs->f(0)] = true; 
    246246          } 
    247            
     247 
    248248          # Set this to read data as they were written in Dotclear 1 
    249249          try { 
    250250               $db->execute('SET NAMES DEFAULT'); 
    251251          } catch (Exception $e) {} 
    252            
     252 
    253253          $db->execute('SET CHARACTER SET DEFAULT'); 
    254254          $db->execute("SET COLLATION_CONNECTION = DEFAULT"); 
     
    256256          $db->execute("SET CHARACTER_SET_SERVER = DEFAULT"); 
    257257          $db->execute("SET CHARACTER_SET_DATABASE = DEFAULT"); 
    258            
     258 
    259259          $this->post_count = $db->select( 
    260260               'SELECT COUNT(post_id) FROM '.$this->vars['db_prefix'].'post ' 
    261261          )->f(0); 
    262            
     262 
    263263          return $db; 
    264264     } 
    265       
     265 
    266266     protected function cleanStr($str) 
    267267     { 
    268268          return text::cleanUTF8(@text::toUTF8($str)); 
    269269     } 
    270       
     270 
    271271     # Users import 
    272272     protected function importUsers() 
     
    275275          $prefix = $this->vars['db_prefix']; 
    276276          $rs = $db->select('SELECT * FROM '.$prefix.'user'); 
    277            
     277 
    278278          try 
    279279          { 
    280280               $this->con->begin(); 
    281                 
     281 
    282282               while ($rs->fetch()) 
    283283               { 
     
    298298                              'post_format' => $rs->user_post_format 
    299299                         )); 
    300                           
     300 
    301301                         $permissions = array(); 
    302302                         switch ($rs->user_level) 
     
    317317                                   break; 
    318318                         } 
    319                           
     319 
    320320                         $this->core->addUser($cur); 
    321321                         $this->core->setUserBlogPermissions( 
     
    326326                    } 
    327327               } 
    328                 
     328 
    329329               $this->con->commit(); 
    330330               $db->close(); 
     
    337337          } 
    338338     } 
    339       
     339 
    340340     # Categories import 
    341341     protected function importCategories() 
     
    344344          $prefix = $this->vars['db_prefix']; 
    345345          $rs = $db->select('SELECT * FROM '.$prefix.'categorie ORDER BY cat_ord ASC'); 
    346            
     346 
    347347          try 
    348348          { 
     
    351351                    "WHERE blog_id = '".$this->con->escape($this->blog_id)."' " 
    352352               ); 
    353                 
     353 
    354354               $ord = 2; 
    355355               while ($rs->fetch()) 
     
    362362                    $cur->cat_lft      = $ord++; 
    363363                    $cur->cat_rgt      = $ord++; 
    364                      
     364 
    365365                    $cur->cat_id = $this->con->select( 
    366366                         'SELECT MAX(cat_id) FROM '.$this->prefix.'category' 
     
    369369                    $cur->insert(); 
    370370               } 
    371                 
     371 
    372372               $db->close(); 
    373373          } 
     
    378378          } 
    379379     } 
    380       
     380 
    381381     # Blogroll import 
    382382     protected function importLinks() 
     
    385385          $prefix = $this->vars['db_prefix']; 
    386386          $rs = $db->select('SELECT * FROM '.$prefix.'link ORDER BY link_id ASC'); 
    387            
     387 
    388388          try 
    389389          { 
     
    392392                    "WHERE blog_id = '".$this->con->escape($this->blog_id)."' " 
    393393               ); 
    394                 
     394 
    395395               while ($rs->fetch()) 
    396396               { 
     
    403403                    $cur->link_xfn      = $this->cleanStr($rs->rel); 
    404404                    $cur->link_position = (integer) $rs->position; 
    405                      
     405 
    406406                    $cur->link_id = $this->con->select( 
    407407                         'SELECT MAX(link_id) FROM '.$this->prefix.'link' 
     
    409409                    $cur->insert(); 
    410410               } 
    411                 
     411 
    412412               $db->close(); 
    413413          } 
     
    418418          } 
    419419     } 
    420       
     420 
    421421     # Entries import 
    422422     protected function importPosts(&$percent) 
     
    424424          $db = $this->db(); 
    425425          $prefix = $this->vars['db_prefix']; 
    426            
     426 
    427427          $count = $db->select('SELECT COUNT(post_id) FROM '.$prefix.'post')->f(0); 
    428            
     428 
    429429          $rs = $db->select( 
    430430               'SELECT * FROM '.$prefix.'post ORDER BY post_id ASC '. 
    431431               $db->limit($this->post_offset,$this->post_limit) 
    432432          ); 
    433            
     433 
    434434          try 
    435435          { 
     
    441441                    ); 
    442442               } 
    443                 
     443 
    444444               while ($rs->fetch()) { 
    445445                    $this->importPost($rs,$db); 
    446446               } 
    447                 
     447 
    448448               $db->close(); 
    449449          } 
     
    453453               throw $e; 
    454454          } 
    455            
     455 
    456456          if ($rs->count() < $this->post_limit) { 
    457457               return -1; 
     
    459459               $this->post_offset += $this->post_limit; 
    460460          } 
    461            
     461 
    462462          if ($this->post_offset > $this->post_count) { 
    463463               $percent = 100; 
     
    466466          } 
    467467     } 
    468       
     468 
    469469     protected function importPost($rs,$db) 
    470470     { 
     
    477477          $cur->post_upddt  = $rs->post_upddt; 
    478478          $cur->post_title  = html::decodeEntities($this->cleanStr($rs->post_titre)); 
    479            
     479 
    480480          $cur->post_url = date('Y/m/d/',strtotime($cur->post_dt)).$rs->post_id.'-'.$rs->post_titre_url; 
    481481          $cur->post_url = substr($cur->post_url,0,255); 
    482            
     482 
    483483          $cur->post_format        = $rs->post_content_wiki == '' ? 'xhtml' : 'wiki'; 
    484484          $cur->post_content_xhtml = $this->cleanStr($rs->post_content); 
    485485          $cur->post_excerpt_xhtml = $this->cleanStr($rs->post_chapo); 
    486            
     486 
    487487          if ($cur->post_format == 'wiki') { 
    488488               $cur->post_content = $this->cleanStr($rs->post_content_wiki); 
     
    492492               $cur->post_excerpt = $this->cleanStr($rs->post_chapo); 
    493493          } 
    494            
     494 
    495495          $cur->post_notes        = $this->cleanStr($rs->post_notes); 
    496496          $cur->post_status       = (integer) $rs->post_pub; 
     
    499499          $cur->post_open_tb      = (integer) $rs->post_open_tb; 
    500500          $cur->post_lang         = $rs->post_lang; 
    501            
     501 
    502502          $cur->post_words = implode(' ',text::splitWords( 
    503503               $cur->post_title.' '. 
     
    505505               $cur->post_content_xhtml 
    506506          )); 
    507            
     507 
    508508          $cur->post_id = $this->con->select( 
    509509               'SELECT MAX(post_id) FROM '.$this->prefix.'post' 
    510510               )->f(0) + 1; 
    511            
     511 
    512512          $cur->insert(); 
    513513          $this->importComments($rs->post_id,$cur->post_id,$db); 
    514514          $this->importPings($rs->post_id,$cur->post_id,$db); 
    515            
     515 
    516516          # Load meta if we have some in DC1 
    517517          if (isset($this->has_table[$this->vars['db_prefix'].'post_meta'])) { 
     
    519519          } 
    520520     } 
    521       
     521 
    522522     # Comments import 
    523523     protected function importComments($post_id,$new_post_id,$db) 
    524524     { 
    525525          $count_c = $count_t = 0; 
    526            
     526 
    527527          $rs = $db->select( 
    528528               'SELECT * FROM '.$this->vars['db_prefix'].'comment '. 
    529529               'WHERE post_id = '.(integer) $post_id.' ' 
    530530               ); 
    531            
     531 
    532532          while ($rs->fetch()) 
    533533          { 
     
    542542               $cur->comment_ip        = $rs->comment_ip; 
    543543               $cur->comment_trackback = (integer) $rs->comment_trackback; 
    544                 
     544 
    545545               $cur->comment_site = $this->cleanStr($rs->comment_site); 
    546546               if ($cur->comment_site != '' && !preg_match('!^http://.*$!',$cur->comment_site)) { 
    547547                    $cur->comment_site = substr('http://'.$cur->comment_site,0,255); 
    548548               } 
    549                 
     549 
    550550               if ($rs->exists('spam') && $rs->spam && $rs->comment_status = 0) { 
    551551                    $cur->comment_status = -2; 
    552552               } 
    553                 
     553 
    554554               $cur->comment_words = implode(' ',text::splitWords($cur->comment_content)); 
    555                 
     555 
    556556               $cur->comment_id = $this->con->select( 
    557557                    'SELECT MAX(comment_id) FROM '.$this->prefix.'comment' 
    558558               )->f(0) + 1; 
    559                 
     559 
    560560               $cur->insert(); 
    561                 
     561 
    562562               if ($cur->comment_trackback && $cur->comment_status == 1) { 
    563563                    $count_t++; 
     
    566566               } 
    567567          } 
    568            
     568 
    569569          if ($count_t > 0 || $count_c > 0) 
    570570          { 
     
    577577          } 
    578578     } 
    579       
     579 
    580580     # Pings import 
    581581     protected function importPings($post_id,$new_post_id,$db) 
    582582     { 
    583583          $urls = array(); 
    584            
     584 
    585585          $rs = $db->select( 
    586586               'SELECT * FROM '.$this->vars['db_prefix'].'ping '. 
    587587               'WHERE post_id = '.(integer) $post_id 
    588588               ); 
    589            
     589 
    590590          while ($rs->fetch()) 
    591591          { 
     
    594594                    continue; 
    595595               } 
    596                 
     596 
    597597               $cur = $this->con->openCursor($this->prefix.'ping'); 
    598598               $cur->post_id = (integer) $new_post_id; 
     
    600600               $cur->ping_dt = $rs->ping_dt; 
    601601               $cur->insert(); 
    602                 
     602 
    603603               $urls[$url] = true; 
    604604          } 
    605605     } 
    606       
     606 
    607607     # Meta import 
    608608     protected function importMeta($post_id,$new_post_id,$db) 
     
    612612               'WHERE post_id = '.(integer) $post_id.' ' 
    613613               ); 
    614            
     614 
    615615          if ($rs->isEmpty()) { 
    616616               return; 
    617617          } 
    618            
     618 
    619619          while ($rs->fetch()) { 
    620620               $this->core->meta->setPostMeta($new_post_id,$this->cleanStr($rs->meta_key),$this->cleanStr($rs->meta_value)); 
     
    622622     } 
    623623} 
    624 ?> 
Note: See TracChangeset for help on using the changeset viewer.

Sites map