Loading...
 
Skip to main content

Import blog

Status
Open
Subject
Import blog
Category
  • Feature request
Feature
Wiki (page view, edit, history, rename, etc)
Blog
Submitted by
Nicolamr
Lastmod by
Nicolamr
Rating
(0)
Description
It should be easier for new users to migrate to tikiwiki: an import blog function (e.g. from wordpress) would help.
Workaround

Ok, lets release early!

tikiwiki 3.0
exported file from wordpress 2.7.1

  • doesn't consider page creators
  • doesn't import comments
  • no wiki 2 html
  • no file validation
  • doesn't import history

tiki-import_wpdump.php
Copy to clipboard
<?php error_reporting( E_ALL ); require_once( 'tiki-setup.php' ); require_once( 'import/import_wordpress_dump.php' ); header( 'Content-Type: text/plain' ); if( $tiki_p_admin != 'y' ) die( 'Admin access required' ); if( $_SERVER['REQUEST_METHOD'] == 'POST' ) { $dom = new DOMDocument; $dom->load( $_FILES['importfile']['tmp_name'] ); echo "Processing...\n"; flush(); $importer = new ImportWordPressDump; $importer->import( $dom ); exit; } header( 'Content-Type: text/html' ); ?> <html> <head> <title>Import Wordpress-Style Tiki Dump</title> </head> <body> <form method="post" enctype="multipart/form-data" action=""> <input type="file" name="importfile"/> <input type="submit" value="Import"/> </form> </body> </html>

/import/import_wordpress_dump.php
Copy to clipboard
<?php //this script may only be included - so its better to die if called directly. if ( basename($_SERVER['SCRIPT_NAME']) == basename(__FILE__) ) { header("location: index.php"); exit; } class ImportWordPressDump { function import( DOMDocument $dom ) { $pages = $dom->getElementsByTagName('item'); foreach( $pages as $page ) { $data = $this->extractInfo( $page ); $this->importPage( $data ); } } function extractInfo( DOMElement $element ) { $data = array(); $data['revisions'] = array(); foreach( $element->childNodes as $node ) if( $node instanceof DOMElement ) { $data[$node->tagName] = (string) $node->textContent; } return $data; } function importPage($data) { global $tikilib; if( $tikilib->page_exists( $data['title'] ) ) { print "Page already exists, no action taken: {$data['title']}\n"; return; } $tikilib->create_page($data['title'], 0, $data['content:encoded'], strtotime($data['wp:post_date'])); $this->oldidnames['wp:post_id'] = $data['title']; } } ?>
Priority
25
Demonstrate Bug on Tiki 19+
Demonstrate Bug (older Tiki versions)
Ticket ID
2673
Created
Thursday 13 August, 2009 12:44:49 UTC
by Unknown
LastModif
Sunday 16 August, 2009 17:26:38 UTC


Show PHP error messages