pn2tiki.zip

Glenn Henshaw, AKA thraxisp contributed a package of scripts on this patch tracker on 2003-11-13. You should not expect these to work independently of the versions used, but they should be a good help for someone that has to convert. Feel free to document better those scripts and contribute your fixes.

Scripts provided :

  • move and reformat the wiki
  • move articles and comments
  • move faqs masquerading as articles
  • move the faqs

pn_article2tiki.php

Name

pn_article2tiki.php - Migrate your postnuke articles into Tiki Articles.

Synopsis

I wanted a slightly different script for importing Postnuke articles over. The underlying principle was to be able to run the conversion script any number of times to update Postnuke articles into Tiki and not have to worry about balooning overlapping records into your database. Then I decided I wanted html to wiki syntax conversion built-in which is when things got out of hand. pn_article2tiki.php is my script to handle all this.

This script works on my particular installation (php-4.4.0 and MySql-4.1.15). Although I expect the code to be reasonably portable, I make no guarantees. Expect to get your hands dirty.

The program relies heavily on PHP MySQL functions and Perl-Compatible Regular Expression Functions. You'll need to have those extensions installed and be using a MySQL database then for this to work.

Features

  • Import Postnuke Articles with corresponding comments
  • Import Article Topics and assign articles to them
  • Import Categories and assign articles to them
  • Optionally import Postnuke users
  • Option to translate article author names over to a different Tiki username.
  • Users, Categories and Topics are only added once so if you update them from within Tiki, your changes will not be affected by re-running the script. That is, overlapping records are not ported, while new ones are appended.
  • Articles and Comments are either replaced with database UPDATE for overlapping records or new ones are INSERTED based on object timestamp. So if you modify a record you already imported in Tiki and then run the script again, the colliding record will create a new instance of itself (for example, if you update an article in Tiki and then run pn_article2tiki.php, the colliding document from Postnuke will come in as a new articleId). Otherwise objects of identical timestamp are replaced with the Postnuke data.
  • Option to parse article hometext and body through included html2wiki function
    • html2wiki function recognizes tags to passthru data you don't want converted. If you surround a portion of your Postnuke article with <!noconversion> <!/noconversion> tags, it will not be parsed by the html to wiki translator. This is particuilarly useful for complex html syntax (eg. layered tables) that the html2wiki function is likely to mutilate.
    • Handled Conversion Rules:
      • Bulleted/Enumerated Lists
      • Break and paragraph tags
      • Bold, Italic and Bold/Italic types
      • Blockquote and monospaced text
      • Horizontal rules
      • Rudimentary tables
      • External links
      • Image references
      • Ampersand entities: lt, gt, amp, quot, nbsp

Installation

MAKE A BACKUP OF YOUR DATABASE. Seriously. There's no guarantee that the script won't munge everything.

Unzip pn_article2tiki.tgz into a directory you can point your browser to. I strongly suggest you secure this directory (eg. user authentication). It will soon contain a config file with your database password in clear text. (You could also dump the files in some private directory and parse it by php manually but the output won't be as pleasant).

Edit the pn_article2tiki_cfg.php file. You'll basically need to change just about every line to properly configure the script for your system. The file comments will tell you what to do.

Point your browser to pn_article2tiki.php. Perhaps it will work.

After the script has run, you must manually:

  • Assign users to any groups you want them to belong to.
  • Assign any special permissions to categories that should have them.
  • Upload images to Article Topics if desired.
  • Manually update user info. The only information imported over is the username, password and email address.

Known Bugs

  • If there are any articles posted at exactly the same time, only one will be transferred over (in my installation this wasn't anything to be worried about).
  • Extraneous linebreaks may appear in some places
  • Handling of carriage returns (\r's) and linefeeds (\n's) was messy and may not be the most portable code.

Todo

Author

Art Davis

Files

See attached.