Index: plugins/importExport/inc/class.dc.import.wp.php
===================================================================
--- plugins/importExport/inc/class.dc.import.wp.php	(revision 1719)
+++ plugins/importExport/inc/class.dc.import.wp.php	(revision 2566)
@@ -17,14 +17,14 @@
 	protected $prefix;
 	protected $blog_id;
-	
+
 	protected $action = null;
 	protected $step = 1;
-	
+
 	protected $post_offset = 0;
 	protected $post_limit = 20;
 	protected $post_count = 0;
-	
+
 	protected $has_table = array();
-	
+
 	protected $vars;
 	protected $base_vars = array(
@@ -45,18 +45,18 @@
 		'permalink_template' => 'p=%post_id%',
 		'permalink_tags' => array(
-			'%year%', 
-			'%monthnum%', 
-			'%day%', 
-			'%hour%', 
-			'%minute%', 
-			'%second%', 
-			'%postname%', 
-			'%post_id%', 
-			'%category%', 
+			'%year%',
+			'%monthnum%',
+			'%day%',
+			'%hour%',
+			'%minute%',
+			'%second%',
+			'%postname%',
+			'%post_id%',
+			'%category%',
 			'%author%'
 		)
 	);
 	protected $formaters;
-	
+
 	protected function setInfo()
 	{
@@ -65,5 +65,5 @@
 		$this->description = __('Import a WordPress installation into your current blog.');
 	}
-	
+
 	public function init()
 	{
@@ -71,10 +71,10 @@
 		$this->prefix = $this->core->prefix;
 		$this->blog_id = $this->core->blog->id;
-		
+
 		if (!isset($_SESSION['wp_import_vars'])) {
 			$_SESSION['wp_import_vars'] = $this->base_vars;
 		}
 		$this->vars =& $_SESSION['wp_import_vars'];
-		
+
 		if ($this->vars['post_limit'] > 0) {
 			$this->post_limit = $this->vars['post_limit'];
@@ -83,5 +83,5 @@
 		$this->formaters = dcAdminCombos::getFormatersCombo();
 	}
-	
+
 	public function resetVars()
 	{
@@ -89,10 +89,10 @@
 		unset($_SESSION['wp_import_vars']);
 	}
-	
+
 	public function process($do)
 	{
 		$this->action = $do;
 	}
-	
+
 	# We handle process in another way to always display something to
 	# user
@@ -159,5 +159,5 @@
 		}
 	}
-	
+
 	public function gui()
 	{
@@ -167,5 +167,5 @@
 			$this->error($e);
 		}
-		
+
 		switch ($this->step)
 		{
@@ -176,5 +176,5 @@
 				'<p class="warning">'.__('Please note that this process '.
 				'will empty your categories, blogroll, entries and comments on the current blog.').'</p>';
-				
+
 				printf($this->imForm(1,__('General information'),__('Import my blog now')),
 				'<p>'.__('We first need some information about your old WordPress installation.').'</p>'.
@@ -218,5 +218,5 @@
 				form::field('post_limit',3,3,html::escapeHTML($this->vars['post_limit'])).'</p>'.
 				'</div>'.
-				
+
 				'</div>'.
 
@@ -253,5 +253,5 @@
 				break;
 			case 6:
-				echo 
+				echo
 				'<p class="message">'.__('Every newly imported user has received a random password '.
 				'and will need to ask for a new one by following the "I forgot my password" link on the login page '.
@@ -261,5 +261,5 @@
 		}
 	}
-	
+
 	# Simple form for step by step process
 	protected function imForm($step,$legend,$submit_value=null)
@@ -268,5 +268,5 @@
 			$submit_value = __('next step').' >';
 		}
-		
+
 		return
 		'<form action="'.$this->getURL(true).'" method="post">'.
@@ -279,5 +279,5 @@
 		'</form>';
 	}
-	
+
 	# Error display
 	protected function error($e)
@@ -286,24 +286,24 @@
 		'<p>'.$e->getMessage().'</p></div>';
 	}
-	
+
 	# Database init
 	protected function db()
 	{
 		$db = dbLayer::init('mysql',$this->vars['db_host'],$this->vars['db_name'],$this->vars['db_user'],$this->vars['db_pwd']);
-		
+
 		$rs = $db->select("SHOW TABLES LIKE '".$this->vars['db_prefix']."%'");
 		if ($rs->isEmpty()) {
 			throw new Exception(__('WordPress tables not found'));
 		}
-		
+
 		while ($rs->fetch()) {
 			$this->has_table[$rs->f(0)] = true;
 		}
-		
+
 		# Set this to read data as they were written
 		try {
 			$db->execute('SET NAMES DEFAULT');
 		} catch (Exception $e) {}
-		
+
 		$db->execute('SET CHARACTER SET DEFAULT');
 		$db->execute("SET COLLATION_CONNECTION = DEFAULT");
@@ -311,18 +311,18 @@
 		$db->execute("SET CHARACTER_SET_SERVER = DEFAULT");
 		$db->execute("SET CHARACTER_SET_DATABASE = DEFAULT");
-		
+
 		$this->post_count = $db->select(
 			'SELECT COUNT(ID) FROM '.$this->vars['db_prefix'].'posts '.
 			'WHERE post_type = \'post\' OR post_type = \'page\''
 		)->f(0);
-		
+
 		return $db;
 	}
-	
+
 	protected function cleanStr($str)
 	{
 		return text::cleanUTF8(@text::toUTF8($str));
 	}
-	
+
 	# Users import
 	protected function importUsers()
@@ -331,9 +331,9 @@
 		$prefix = $this->vars['db_prefix'];
 		$rs = $db->select('SELECT * FROM '.$prefix.'users');
-		
+
 		try
 		{
 			$this->con->begin();
-			
+
 			while ($rs->fetch())
 			{
@@ -352,5 +352,5 @@
 					$cur->user_tz          = $this->core->blog->settings->system->blog_timezone;
 					$permissions           = array();
-					
+
 					$rs_meta = $db->select('SELECT * FROM '.$prefix.'usermeta WHERE user_id = '.$rs->ID);
 					while ($rs_meta->fetch())
@@ -425,5 +425,5 @@
 		}
 	}
-	
+
 	# Categories import
 	protected function importCategories()
@@ -438,5 +438,5 @@
 			'ORDER BY t.term_id ASC'
 		);
-		
+
 		try
 		{
@@ -445,5 +445,5 @@
 				"WHERE blog_id = '".$this->con->escape($this->blog_id)."' "
 			);
-			
+
 			$ord = 2;
 			while ($rs->fetch())
@@ -456,5 +456,5 @@
 				$cur->cat_lft      = $ord++;
 				$cur->cat_rgt      = $ord++;
-				
+
 				$cur->cat_id = $this->con->select(
 					'SELECT MAX(cat_id) FROM '.$this->prefix.'category'
@@ -463,5 +463,5 @@
 				$cur->insert();
 			}
-			
+
 			$db->close();
 		}
@@ -472,5 +472,5 @@
 		}
 	}
-	
+
 	# Blogroll import
 	protected function importLinks()
@@ -479,5 +479,5 @@
 		$prefix = $this->vars['db_prefix'];
 		$rs = $db->select('SELECT * FROM '.$prefix.'links ORDER BY link_id ASC');
-		
+
 		try
 		{
@@ -486,5 +486,5 @@
 				"WHERE blog_id = '".$this->con->escape($this->blog_id)."' "
 			);
-			
+
 			while ($rs->fetch())
 			{
@@ -495,5 +495,5 @@
 				$cur->link_desc     = $this->cleanStr($rs->link_description);
 				$cur->link_xfn      = $this->cleanStr($rs->link_rel);
-				
+
 				$cur->link_id = $this->con->select(
 					'SELECT MAX(link_id) FROM '.$this->prefix.'link'
@@ -501,5 +501,5 @@
 				$cur->insert();
 			}
-			
+
 			$db->close();
 		}
@@ -510,5 +510,5 @@
 		}
 	}
-	
+
 	# Entries import
 	protected function importPosts(&$percent)
@@ -516,5 +516,5 @@
 		$db = $this->db();
 		$prefix = $this->vars['db_prefix'];
-		
+
 		$plink = $db->select(
 				'SELECT option_value FROM '.$prefix.'options '.
@@ -524,5 +524,5 @@
 			$this->vars['permalink_template'] = substr($plink,1);
 		}
-		
+
 		$rs = $db->select(
 			'SELECT * FROM '.$prefix.'posts '.
@@ -531,5 +531,5 @@
 			$db->limit($this->post_offset,$this->post_limit)
 		);
-		
+
 		try
 		{
@@ -540,10 +540,10 @@
 					"WHERE blog_id = '".$this->con->escape($this->blog_id)."' "
 				);
-			}	
-			
+			}
+
 			while ($rs->fetch()) {
 				$this->importPost($rs,$db);
 			}
-			
+
 			$db->close();
 		}
@@ -553,5 +553,5 @@
 			throw $e;
 		}
-		
+
 		if ($rs->count() < $this->post_limit) {
 			return -1;
@@ -559,5 +559,5 @@
 			$this->post_offset += $this->post_limit;
 		}
-		
+
 		if ($this->post_offset > $this->post_count) {
 			$percent = 100;
@@ -566,5 +566,5 @@
 		}
 	}
-	
+
 	protected function importPost($rs,$db)
 	{
@@ -575,5 +575,5 @@
 			$user_id = $this->vars['user_ids'][$rs->post_author];
 		}
-		
+
 		$cur = $this->con->openCursor($this->prefix.'post');
 		$cur->blog_id     = $this->blog_id;
@@ -583,9 +583,9 @@
 		$cur->post_upddt  = $rs->post_modified;
 		$cur->post_title  = $this->cleanStr($rs->post_title);
-		
+
 		if (!$cur->post_title) {
 			$cur->post_title = 'No title';
 		}
-		
+
 		if ($this->vars['cat_import'] || $this->vars['cat_as_tags'])
 		{
@@ -601,20 +601,20 @@
 				' ORDER BY t.term_id ASC '
 				);
-			if (!$old_cat_ids->isEmpty() && $this->vars['cat_import']) 
+			if (!$old_cat_ids->isEmpty() && $this->vars['cat_import'])
 			{
 				$cur->cat_id = $this->vars['cat_ids'][(integer) $old_cat_ids->term_id];
 			}
 		}
-		
+
 		$permalink_infos = array(
-			date('Y',strtotime($cur->post_dt)), 
-			date('m',strtotime($cur->post_dt)), 
-			date('d',strtotime($cur->post_dt)), 
-			date('H',strtotime($cur->post_dt)), 
-			date('i',strtotime($cur->post_dt)), 
-			date('s',strtotime($cur->post_dt)), 
-			$rs->post_name, 
-			$rs->ID, 
-			$cur->cat_id, 
+			date('Y',strtotime($cur->post_dt)),
+			date('m',strtotime($cur->post_dt)),
+			date('d',strtotime($cur->post_dt)),
+			date('H',strtotime($cur->post_dt)),
+			date('i',strtotime($cur->post_dt)),
+			date('s',strtotime($cur->post_dt)),
+			$rs->post_name,
+			$rs->ID,
+			$cur->cat_id,
 			$cur->user_id
 		);
@@ -625,9 +625,9 @@
 		);
 		$cur->post_url = substr($cur->post_url,0,255);
-		
+
 		if (!$cur->post_url) {
 			$cur->post_url = $rs->ID;
 		}
-		
+
 		$cur->post_format = $this->vars['post_formater'];
 		$_post_content = explode('<!--more-->',$rs->post_content,2);
@@ -639,8 +639,8 @@
 			$cur->post_content = $this->cleanStr(array_shift($_post_content));
 		}
-		
+
 		$cur->post_content_xhtml = $this->core->callFormater($this->vars['post_formater'],$cur->post_content);
 		$cur->post_excerpt_xhtml = $this->core->callFormater($this->vars['post_formater'],$cur->post_excerpt);
-		
+
 		switch ($rs->post_status)
 		{
@@ -661,5 +661,5 @@
 		$cur->post_open_comment = $rs->comment_status == 'open' ? 1 : 0;
 		$cur->post_open_tb      = $rs->ping_status == 'open' ? 1 : 0;
-		
+
 		$cur->post_words = implode(' ',text::splitWords(
 			$cur->post_title.' '.
@@ -667,21 +667,21 @@
 			$cur->post_content_xhtml
 		));
-		
+
 		$cur->post_id = $this->con->select(
 			'SELECT MAX(post_id) FROM '.$this->prefix.'post'
 			)->f(0) + 1;
-		
+
 		$cur->post_url = $this->core->blog->getPostURL($cur->post_url,$cur->post_dt,$cur->post_title,$cur->post_id);
-		
+
 		$cur->insert();
 		$this->importComments($rs->ID,$cur->post_id,$db);
 		$this->importPings($rs->ID,$cur->post_id,$db);
-		
+
 		# Create tags
 		$this->importTags($rs->ID,$cur->post_id,$db);
-		
+
 		if (isset($old_cat_ids))
 		{
-			if (!$old_cat_ids->isEmpty() && $this->vars['cat_as_tags']) 
+			if (!$old_cat_ids->isEmpty() && $this->vars['cat_as_tags'])
 			{
 				$old_cat_ids->moveStart();
@@ -692,15 +692,15 @@
 		}
 	}
-	
+
 	# Comments import
 	protected function importComments($post_id,$new_post_id,$db)
 	{
 		$count_c = $count_t = 0;
-		
+
 		$rs = $db->select(
 			'SELECT * FROM '.$this->vars['db_prefix'].'comments '.
 			'WHERE comment_post_ID = '.(integer) $post_id.' '
 			);
-		
+
 		while ($rs->fetch())
 		{
@@ -716,17 +716,17 @@
 			$cur->comment_site = substr($this->cleanStr($rs->comment_author_url),0,255);
 			if ($cur->comment_site == '') $cur->comment_site = NULL;
-			
+
 			if ($rs->comment_approved == 'spam') {
 				$cur->comment_status = -2;
 			}
-			
+
 			$cur->comment_words = implode(' ',text::splitWords($cur->comment_content));
-			
+
 			$cur->comment_id = $this->con->select(
 				'SELECT MAX(comment_id) FROM '.$this->prefix.'comment'
 			)->f(0) + 1;
-			
+
 			$cur->insert();
-			
+
 			if ($cur->comment_trackback && $cur->comment_status == 1) {
 				$count_t++;
@@ -735,5 +735,5 @@
 			}
 		}
-		
+
 		if ($count_t > 0 || $count_c > 0)
 		{
@@ -746,5 +746,5 @@
 		}
 	}
-	
+
 	# Pings import
 	protected function importPings($post_id,$new_post_id,$db)
@@ -752,5 +752,5 @@
 		$urls = array();
 		$pings = array();
-		
+
 		$rs = $db->select(
 			'SELECT pinged FROM '.$this->vars['db_prefix'].'posts '.
@@ -759,5 +759,5 @@
 		$pings = explode ("\n",$rs->pinged);
 		unset ($pings[0]);
-		
+
 		foreach($pings as $ping_url)
 		{
@@ -766,14 +766,14 @@
 				continue;
 			}
-			
+
 			$cur = $this->con->openCursor($this->prefix.'ping');
 			$cur->post_id = (integer) $new_post_id;
 			$cur->ping_url = $url;
 			$cur->insert();
-			
+
 			$urls[$url] = true;
 		}
 	}
-	
+
 	# Meta import
 	protected function importTags($post_id,$new_post_id,$db)
@@ -789,9 +789,9 @@
 			' ORDER BY t.term_id ASC'
 		);
-		
+
 		if ($rs->isEmpty()) {
 			return;
 		}
-		
+
 		while ($rs->fetch()) {
 			$this->core->meta->setPostMeta($new_post_id,'tag',$this->cleanStr($rs->name));
@@ -799,3 +799,2 @@
 	}
 }
-?>
