Extension:PIM Support

From mediawiki.org
Jump to navigation Jump to search
MediaWiki extensions manual
OOjs UI icon advanced.svg
PIM Support
Release status: unmaintained
Implementation Special page , Data extraction
Description simple Personal Information Management support, currently for prefilled contact wikipages in separate namespace
Author(s) Florian Konnertz (groovehuntertalk)
Latest version 0.1 (2008-03-20)
MediaWiki 1.11.
License No license specified
Download #Code
Example none public
currently none
currently none

Check usage and version matrix.

What can this extension do?[edit]

It provides a special page providing links to [[K:John Doe]]. "K" is a custom namespace, meaning Kontakt (german for contact). The data comes from csv export file from linux kontact PIM. PIM, for whom do not know is short for "Personal Information Management", so this extensions aims (in further development) to offer access to this information: dates, calendar, tasks, emails. For now it's a bit helpful for creating articles about your contacts without typing them and populating these pages with basic contact data.


View Special:PIM_Support to see all your contacts as links to wikipages. Create a page and you should see some basic contact data on that page.

Download instructions[edit]

Please cut and paste the code found below and place it in $IP/extensions/PIM_Support/PIM_Support.php. Note: $IP stands for the root directory of your MediaWiki installation, the same directory that holds LocalSettings.php.


To install this extension, add the following to LocalSettings.php:

$wgExtraNamespaces[210] = "K";
define("NS_K", 210);
$wgContentNamespaces[] = 210;


export your contacts from kontact and move or copy the file to


copy the file again to kontact_header.csv and remove all but the first line (the header line), leave it in that dir.

I guess you have to experiment a bit with the dir and filename variables in the code to get it running.

Configuration parameters[edit]

none yet

User rights[edit]

none yet


if (!defined('MEDIAWIKI')) die();

$dir = dirname(__FILE__) . '/';
$csv_fn = $dir.'kontact_export_20080307.csv';

$wgExtensionFunctions[] = "wfSetupPIM_Support";

$wgExtensionCredits['PIM Support'][] = array(
    'name'      =>  'PIM Support',
    'author'    =>  'Florian Konnertz',
    'url'       =>  'http://www.mediawiki.org/wiki/User:Groovehunter',
    'description' =>'Basic PIM (Personal Information Management) Support'

// XXX namen normalisieren , capitals?, zweite+ vornamen entfernen?
$wgHooks['OutputPageBeforeHTML'][] = 'PIM_OutputPageBeforeHTML';

function PIM_OutputPageBeforeHTML(&$out, &$text) {
    global $wgTitle;
    global $df;
    $out = '';
    $ns = $wgTitle->getNamespace();
    if ($ns == NS_K) {
        $title_text = $wgTitle->getText();
        $name = explode(' ', $title_text);
        $cfn = $name[0];
        $cln = $name[1];
        $lines = loadData();
        $names = indexAsData($lines);
        $ind = $cln."_".$cfn;
        $data = $names[$ind];
        if ($data) {
            $details = showDetails($data);
            $out .= $details;
    $text .= $out;
    return true;

function showDetails($line) {
    global $dir;
    $hfn = $dir.'kontact_header.csv';
    $hline = file_get_contents($hfn);
    $header = split('","', $hline);
    $dout = '';
    $dout .= '<b>Details des Kontakts</b><br>';
    $dout .= '<table border="1">';
    //$show_fields = array(1,2,7,8,9,11,15,17,20,21,22,28,36);
    $show_fields = array(7,8,9,11,15,17,20,21,22,28,36);
    foreach ($show_fields as $i=>$k) {
        $dout .= '<tr>';
        $dout .= '<td>';
        $dout .= "<b>{$header[$k]}</b></td>";
        $dout .= "<td>{$line[$k]}</td></tr>";
    $dout .= '</table>';
    return $dout;

function wfSetupPIM_Support() {
    // FIXME title of specialpage is not rendered correctly
    require_once( 'SpecialPage.php' );
    SpecialPage::addPage( new SpecialPage( 'PIM_Support', 'edit',
      /*listed*/ true, /*function*/ false, /*file*/ false )  );

      // XXX name indizieren, als file speichern f�r abruf bei artikel-kontakt-seite um
      // detail daten nachzuladen in artikel-text

function loadData() {
    global $csv_fn;
    if (file_exists( $csv_fn )) {
        $lines = file( $csv_fn );
        return $lines;

function indexAsData($lines) {
    $data = array();
    foreach ($lines as $k=>$line) {
        $fields = split('","', $line);
        $ln = $fields[1];
        $fn = $fields[2];
        $ind = $ln."_".$fn;
        $data[$ind] = $fields;
    return $data;

function indexAsNames($lines) {
    foreach ($lines as $k=>$line) {
        $fields = split('","', $line);
        $ln = $fields[1];
        $fn = $fields[2];
        $name = $fn." ".$ln;
        $ind = $ln."_".$fn;
        $names[$ind] = $name;
    return $names;

function wfSpecialPIM_Support() {
    global $wgOut;
    $lines = loadData();
    if ($lines) {
        $names = indexAsNames($lines);
        $num = count($names);

        $out = '';
        $out .= "[[PIM Support Extension]] - {$num} names \n\n";
        //for ($i=65; $i<=90; $i++) $abc[] = chr($i);
        //foreach ($abc as $v) {
        // XXX first letters!!

        foreach ($names as $k=>$name) {
            $ptitle_l = str_replace(' ', '_', $name);
            $out .= "* [[K:{$name}]]\t";
            //$out .= "[[xing:{$name}]]\n";   // XXX test for xing in notizen, substitute umlauts
    } else {
        $out .= 'Data file not found';

See also[edit]

not sure if there are related extensions. I will check soon, my next wish is email access, so to write wikified emails make sense