Extension:PIM Support
From MediaWiki.org
|
PIM Support Release status: experimental |
|
|---|---|
| Implementation | Special page, Data extraction |
| Description | simple Personal Information Management support, currently for prefilled contact wikipages in seperate namespace |
| Author(s) | Florian Konnertz (groovehunter Talk) |
| Version | 0.1 (2008-03-20) |
| MediaWiki | 1.11. |
| Download | no link |
| Parameters | currently none |
| Added rights | currently none |
| Example | none public |
| Hooks used | OutputPageBeforeHTML |
Contents |
[edit] What can this extension do?
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.
[edit] Usage
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.
[edit] Download instructions
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.
[edit] Installation
To install this extension, add the following to LocalSettings.php:
$wgExtraNamespaces[210] = "K"; define("NS_K", 210); $wgContentNamespaces[] = 210; require_once("$IP/extensions/PIM_Support/PIM_Support.php");
export your contacts from kontact and move or copy the file to
$IP/extensions/PIM_Support/
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.
[edit] Configuration parameters
none yet
[edit] User rights
none yet
[edit] Code
<?php 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(); //var_dump($ns); 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) { //dump($line); $fields = split('","', $line); $ln = $fields[1]; $fn = $fields[2]; $ind = $ln."_".$fn; $data[$ind] = $fields; } ksort($data); return $data; } function indexAsNames($lines) { foreach ($lines as $k=>$line) { //dump($line); $fields = split('","', $line); $ln = $fields[1]; $fn = $fields[2]; $name = $fn." ".$ln; $ind = $ln."_".$fn; $names[$ind] = $name; ksort($names); } return $names; } function wfSpecialPIM_Support() { global $wgOut; $lines = loadData(); if ($lines) { $names = indexAsNames($lines); //sort($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'; } $wgOut->addWikiText($out); }
[edit] See also
not sure if there are related extensions. I will check soon, my next wish is email access, so to write wikified emails make sense

