Loading...
 

ConversionFromWikini

Objectives

The goal of this page is my notes on how to convert articles from Wikini to Tikiwiki
Wikini: http://www.wikini.net/ 1.4.3
Tikiwiki: http://www.tiki.org 1.9
My experience was based on converting from Wikini 1.4.3 to Tikiwiki 1.9

Status: Currently Testing Conversion _ Ok I have successfully converted from wikini to tiki
Just need extra conversions for wikini syntax to tiki syntax. Seems tiki doesn't like french characters.
Need to convert them.

Data

Database structure


Source: Wikini Version
The following table has been identified as the one which contains the articles in wikini.
This table also contains history of the pages.

Table: wikini_pages

Champ Type Null Défaut
id int(10) Non
tag varchar(50) Non
time datetime Non 0000-00-00 00:00:00
body text Non
body_r text Non
owner varchar(50) Non
user varchar(50) Non
latest enum('Y', 'N') Non N
handler varchar(30) Non page
comment_on varchar(50) Non


The following table has been identified as the one which contains the articles in tikiwiki.
At the opposite of wikini, the history of the pages are stored in a table tiki_history (or something like that) but at this stage we do not need this table.

Table: tiki_pages


Champ Type Null Défaut Relié à Commentaires MIME
page_id int(14) Non
pageName varchar(160) Non
hits int(8) Oui NULL
data text Oui NULL
description varchar(200) Oui NULL
lastModif int(14) Oui NULL
comment varchar(200) Oui NULL
version int(8) Non 0
user varchar(200) Oui NULL
ip varchar(15) Oui NULL
flag char(1) Oui NULL
points int(8) Oui NULL
votes int(8) Oui NULL
cache text Oui NULL
wiki_cache int(10) Oui NULL
cache_timestamp int(14) Oui NULL
pageRank decimal(4,3) Oui NULL
creator varchar(200) Oui NULL
page_size int(10) Oui 0
lang varchar(16) Oui NULL
lockedby varchar(200) Oui NULL
created int(14) Oui NULL
is_html tinyint(1) Oui 0

Conversion process


1°) Backup your data
First of all, make a backup or a copy of wikini_pages and the tiki_pages tables.
You can do different ways (export files, rename and copy tables, SQL requests...)

2°) Copy wikini_pages in the same db as tiki_pages
Wikini and Tikiwiki are maybe not on the same database, copy wikini_tables into the database where tiki is stored.

3°) Prepare the environment
How do I proceed: Basically, I select all the wiki pages (latest versions only) and insert them
into the tiki_pages table. To ensure no duplicate page name, you either delete all the current pages
or make sure no pages with the same name exists in your tiki table.

DELETE FROM tiki_pages;


SQL Request to get all data from Wikini

SELECT tag, body FROM `wikini_pages` WHERE latest='Y' and user<>'WikiNiInstaller'


This request get the latest pages from Wikini and exclude information pages that come by default with Wikini (those created by user WikiNiInstaller).

3°) Insert into Tikiwiki

Be sure to remove any similar pages with the same name

DELETE FROM tiki_pages;
INSERT INTO tiki_pages(pageName,data,user,version,creator,lastModif) SELECT tag, body, 'admin',1,'admin',1115680000 FROM `wikini_pages` WHERE latest='Y' and user<>'WikiNiInstaller';

UPDATE tiki_pages SET page_size = CHAR_LENGTH(data);


Pages created in tikiwiki have as new attributes:
1°) User = admin
2°) Creator = admin
3°) LastModif = 1115680000
4°) page_size = size of the 'data' field
5°) version = 1

The number 1115780000 is a date encoded. You can change as you wish or use timestamp functions.

__4°) Convert data correctly

We need at this stage to use regular expressions

For instance, the wiki syntax need to be replaced [[ x y ]] by (( x | y ))
Regular expression to catch Wikini pages: \[\[(\w*)\s((\w|\s)*)\]\]

In Visual Basic, the macro should be:

Copy to clipboard
Private Sub Test() Dim reg_exp As New RegExp Dim t As String Selection.WholeStory t = Selection.Text reg_exp.Pattern = "\[\[(\w*)\s((\w|\s)*)\]\]" reg_exp.Global = True MsgBox reg_exp.Replace(t, "(($1 | $2))") End Sub

I'll keep this code here as I might create a Macro (unless it exists).

This piece of code tries to convert the wiki syntax from wiki links to tikiwiki links syntax + bold syntax (from double star characters to double underscore characters). There may be additional characters to convert also.

Copy to clipboard
<?php error_reporting (E_ALL); $pattern[0] = "/\*\*(.*)\*\*/"; $replacement[0] = "__ $1 __"; $pattern[1] = "/\[\[(\w*)\s((\w|\s|é|è|à|\')*)\]\]/"; $replacement[1] = "(($1 | $2))"; //for french characters $pattern[2]="/é/"; $replacement[2]="é"; $pattern[3]="/è/"; $replacement[3]="è"; $pattern[4]="/à/"; $replacement[4]="à "; $pattern[5]="/ê/"; $replacement[5]="ê"; $pattern[6]="/ç/"; $replacement[6]="ç"; $pattern[7]="/ë/"; $replacement[7]="ë"; $pattern[8]="/’/"; $replacement[8]="'"; $pattern[9]="/â/"; $replacement[9]="â"; $pattern[10]="/ô/"; $pattern[11]="/ö/"; $pattern[12]="/î/"; $pattern[13]="/ï/"; $pattern[14]="/ù/"; $replacement[10]="ô"; $replacement[11]="ö"; $replacement[12]="î"; $replacement[13]="ï"; $replacement[14]="ù"; echo "<pre>"; // echo preg_replace($pattern, $replacement, $string); mysql_connect("localhost", "root", "") or die("Could not connect: " . mysql_error()); mysql_select_db("db_tiki"); $result = mysql_query("SELECT pageName, data FROM tiki_pages"); while ($row = mysql_fetch_array($result, MYSQL_BOTH)) { $newtext= addslashes(preg_replace($pattern,$replacement,$row["data"])); $query = "UPDATE tiki_pages SET data = '$newtext' WHERE pageName='".$row["pageName"]."'"; $result2 = mysql_query($query); echo $result2."\n".$row["pageName"]. " updated $result2\n \r"; if (!$result2) { $message = 'Invalid query: ' . mysql_error() . "\n"; $message .= 'Whole query: ' . $query; die($message); } } mysql_free_result($result); ?>

Extra: To correct french accents, add the additional SQL requests. If you have run the script above, this should not be necessary.

UPDATE tiki_pages SET data = REPLACE(data, "é","é");
UPDATE tiki_pages SET data = REPLACE(data, "è","è");
UPDATE tiki_pages SET data = REPLACE(data, "à","Ã ");
UPDATE tiki_pages SET data = REPLACE(data, "ê","ê");
UPDATE tiki_pages SET data = REPLACE(data, "ç","ç");
UPDATE tiki_pages SET data = REPLACE(data, "â","â");
UPDATE tiki_pages SET data = REPLACE(data, "ë","ë");
UPDATE tiki_pages SET data = REPLACE(data, "’","'");
UPDATE tiki_pages SET data = REPLACE(data, "û","û");
UPDATE tiki_pages SET data = REPLACE(data, "€,"€");



...
^
Maybe other characters to be added. I haven't covered all.


-


Page last modified on Friday 20 September 2019 15:38:33 GMT-0000

Upcoming Events

1)  18 Apr 2024 14:00 GMT-0000
Tiki Roundtable Meeting
2)  16 May 2024 14:00 GMT-0000
Tiki Roundtable Meeting
3)  20 Jun 2024 14:00 GMT-0000
Tiki Roundtable Meeting
4)  18 Jul 2024 14:00 GMT-0000
Tiki Roundtable Meeting
5)  15 Aug 2024 14:00 GMT-0000
Tiki Roundtable Meeting
6)  19 Sep 2024 14:00 GMT-0000
Tiki Roundtable Meeting
7) 
Tiki birthday
8)  17 Oct 2024 14:00 GMT-0000
Tiki Roundtable Meeting
9)  21 Nov 2024 14:00 GMT-0000
Tiki Roundtable Meeting
10)  19 Dec 2024 14:00 GMT-0000
Tiki Roundtable Meeting