Wiki allow [[~alias]] ==> Prenom NOM Xxxxx (aka Surnom)
authorx2003bruneau <x2003bruneau@839d8a87-29fc-0310-9880-83ba4fa771e5>
Mon, 31 Jul 2006 15:36:00 +0000 (15:36 +0000)
committerx2003bruneau <x2003bruneau@839d8a87-29fc-0310-9880-83ba4fa771e5>
Mon, 31 Jul 2006 15:36:00 +0000 (15:36 +0000)
and [[~alias|title]] ==> title

git-svn-id: svn+ssh://murphy/home/svn/platal/trunk@748 839d8a87-29fc-0310-9880-83ba4fa771e5

plugins/pmwiki.config.php

index 9f6f8c6..a93ae66 100644 (file)
@@ -51,8 +51,8 @@ $InputTags['e_form'] = array(
     type='hidden' name='basetime' value='\$EditBaseTime' /></div>");
 
 // set profiles to point to plat/al fiche
-Markup('[[~platal', '<[[~', '/\[\[~([^|\]]*)\|([^\]]*)\]\]/e',
-    'PreserveText("=", \'<a href="profile/$1" class="popup2">$2</a>\', "")');
+Markup('[[~platal', '<[[~', '/\[\[~([^|\]]*)(?:\|([^\]]*))?\]\]/e',
+    'PreserveText("=", doPlatalLink("$1", "$2"), "")');
 
 // prevent restorelinks before block apply (otherwise [[Sécurité]] will give
 //  .../S<span class='e9curit'>e9'>Sécurité</a>
@@ -78,6 +78,23 @@ function doBicol($column=false)
     }
 }
 
+function doPlatalLink($link, $text)
+{
+    if (strlen(trim($text)) == 0) { 
+        $res = XDB::query("SELECT u.nom, u.prenom, u.promo, q.profile_nick AS surnom
+                             FROM auth_user_md5   AS u
+                       INNER JOIN auth_user_quick AS q USING(user_id)
+                       INNER JOIN aliases         AS a ON u.user_id = a.id
+                            WHERE a.alias = {?}", $link);
+        $row = $res->fetchOneAssoc();
+        $text = $row['prenom'] . ' ' . $row['nom'] . ' X' . $row['promo'];
+        if ($row['surnom']) {
+            $text .= ' (aka ' . $row['surnom'] . ')';
+        }
+    }
+    return '<a href="profile/' . $link . '" class="popup2">' . $text . '</a>';
+}
+
 // }}}
 
 $AuthFunction = 'ReadPage';