'',
'db_name' => '',
'db_user' => '',
'db_pwd' => '',
'db_prefix' => 'wp_',
'ignore_first_cat' => 1,
'cat_import' => 1,
'cat_as_tags' => '',
'cat_tags_prefix' => 'cat: ',
'post_limit' => 20,
'post_formater' => 'xhtml',
'comment_formater' => 'xhtml',
'user_ids' => array(),
'cat_ids' => array(),
'permalink_template' => 'p=%post_id%',
'permalink_tags' => array(
'%year%',
'%monthnum%',
'%day%',
'%hour%',
'%minute%',
'%second%',
'%postname%',
'%post_id%',
'%category%',
'%author%'
)
);
protected $formaters;
protected function setInfo()
{
$this->type = 'i';
$this->name = __('WordPress import');
$this->description = __('Import a WordPress installation into your current blog.');
}
public function init()
{
$this->con =& $this->core->con;
$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'];
}
foreach ($this->core->getFormaters() as $v) {
$this->formaters[$v] = $v;
}
}
public function resetVars()
{
$this->vars = $this->base_vars;;
unset($_SESSION['wp_import_vars']);
}
public function process($do)
{
$this->action = $do;
}
# We handle process in another way to always display something to
# user
protected function guiprocess($do)
{
switch ($do)
{
case 'step1':
$this->vars['db_host'] = $_POST['db_host'];
$this->vars['db_name'] = $_POST['db_name'];
$this->vars['db_user'] = $_POST['db_user'];
$this->vars['db_pwd'] = $_POST['db_pwd'];
$this->vars['db_prefix'] = $_POST['db_prefix'];
$this->vars['ignore_first_cat'] = isset($_POST['ignore_first_cat']);
$this->vars['cat_import'] = isset($_POST['cat_import']);
$this->vars['cat_as_tags'] = isset($_POST['cat_as_tags']);
$this->vars['cat_tags_prefix'] = $_POST['cat_tags_prefix'];
$this->vars['post_limit'] = abs((integer) $_POST['post_limit']) > 0 ? $_POST['post_limit'] : 0;
$this->vars['post_formater'] = isset($this->formaters[$_POST['post_formater']]) ? $_POST['post_formater'] : 'xhtml';
$this->vars['comment_formater'] = isset($this->formaters[$_POST['comment_formater']]) ? $_POST['comment_formater'] : 'xhtml';
$db = $this->db();
$db->close();
$this->step = 2;
echo $this->progressBar(1);
break;
case 'step2':
$this->step = 2;
$this->importUsers();
$this->step = 3;
echo $this->progressBar(3);
break;
case 'step3':
$this->step = 3;
$this->importCategories();
if ($this->core->plugins->moduleExists('blogroll')) {
$this->step = 4;
echo $this->progressBar(5);
} else {
$this->step = 5;
echo $this->progressBar(7);
}
break;
case 'step4':
$this->step = 4;
$this->importLinks();
$this->step = 5;
echo $this->progressBar(7);
break;
case 'step5':
$this->step = 5;
$this->post_offset = !empty($_REQUEST['offset']) ? abs((integer) $_REQUEST['offset']) : 0;
if ($this->importPosts($percent) === -1) {
http::redirect($this->getURL().'&do=ok');
} else {
echo $this->progressBar(ceil($percent*0.93)+7);
}
break;
case 'ok':
$this->resetVars();
$this->core->blog->triggerBlog();
$this->step = 6;
echo $this->progressBar(100);
break;
}
}
public function gui()
{
try {
$this->guiprocess($this->action);
} catch (Exception $e) {
$this->error($e);
}
switch ($this->step)
{
case 1:
echo
'
'.sprintf(__('This will import your WordPress content as new content in the current blog: %s.'),
''.html::escapeHTML($this->core->blog->name).'').'
'.
'
'.__('Please note that this process '.
'will empty your categories, blogroll, entries and comments on the current blog.').'
'.
'
'.__('Depending on the size of your blog, it could take a few minutes.').'
';
printf($this->imForm(1,__('General information'),__('Import my blog now')),
'
'.__('We first need some information about your old WordPress installation.').'
'.
''.
''.
''.
''.
''.
'
'.__('Entries import options').'
'.
'
'.__('WordPress and Dotclear\'s handling of categories are quite different. '.
'You can assign several categories to a single post in WordPress. In the Dotclear world, '.
'we see it more like "One category, several tags." Therefore Dotclear can only import one '.
'category per post and will chose the lowest numbered one. If you want to keep a trace of '.
'every category, you can import them as tags, with an optional prefix.').'
'.
'
'.__('On the other hand, in WordPress, a post can not be uncategorized, and a default '.
'installation has a first category labelised "Uncategorized". If you did not change that '.
'category, you can just ignore it while importing your blog, as Dotclear allows you to '.
'actually keep your posts uncategorized.').'
'.
''.
''.
''.
''.
''.
'
'.__('Content filters').'
'.
'
'.__('You may want to process your post and/or comment content with the following filters.').'
'.
''.
''
);
break;
case 2:
printf($this->imForm(2,__('Importing users')),
$this->autoSubmit()
);
break;
case 3:
printf($this->imForm(3,__('Importing categories')),
$this->autoSubmit()
);
break;
case 4:
printf($this->imForm(4,__('Importing blogroll')),
$this->autoSubmit()
);
break;
case 5:
$t = sprintf(__('Importing entries from %d to %d / %d'),$this->post_offset,
min(array($this->post_offset+$this->post_limit,$this->post_count)),$this->post_count);
printf($this->imForm(5,$t),
form::hidden(array('offset'),$this->post_offset).
$this->autoSubmit()
);
break;
case 6:
echo
'
'.__('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 '.
'(Their registered email address has to be valid.)').'
'.
$this->congratMessage();
break;
}
}
# Simple form for step by step process
protected function imForm($step,$legend,$submit_value=null)
{
if (!$submit_value) {
$submit_value = __('next step').' >';
}
return
'';
}
# Error display
protected function error($e)
{
echo '