====== wikisign plugin ====== ---- plugin ---- description: Adds support for wikipedia style signatures by translating "~~~~" into signature/login name + date information. author : FeepingCreature email : default_357-line@yahoo.de type : action lastupdate : 2008-08-11 compatible : depends : conflicts : similar : tags : editing, mediawiki, users ---- ===== Download and Installation ===== Just create a folder in your lib/plugins dir, called "wikisign". In it, create a file called action.php containing the following code: 'FeepingCreature', 'email' => 'default_357-line@yahoo.de', 'date' => '2008-11-08', 'name' => 'WP-style signature', 'desc' => 'Translate ~~~~ into signature info', 'url' => '' ); } function register(Doku_Event_Handler $controller) { $controller->register_hook('IO_WIKIPAGE_WRITE', 'BEFORE', $this, 'signtranslate'); } function signtranslate(&$event, $param) { $pi = pageinfo(); global $USERINFO; $userinfo = $USERINFO['name']; if (empty($userinfo)) $userinfo = $_SERVER[REMOTE_ADDR]; $date = gmdate('H:i, d F Y e'); // $event->data[0][1] = str_replace('~~~~', '---//'.$userinfo.' '.$date.'//', $event->data[0][1]); // thanks to mystore for the next line (ignore ~~~~ in unparsed blocks) $event->data[0][1] = preg_replace('#[^(||| |%%)]~~~~#', '---//'.$userinfo.' '.$date.'//', $event->data[0][1]); } } ?> Have fun! ===== Discussions ===== Add compatibility with non-parsed block : Replace the last line by : $event->data[0][1] = preg_replace('#[^(||| |%%)]~~~~#', '---//'.$userinfo.' '.$date.'//', $event->data[0][1]); //myst6re 2008/10/05// ===== Bug ===== At least give an example of its use. ~~~~ (DOES NOT WORK!) > Strange. That's how it's SUPPOSED to work, and _does_ work here. Are you sure you installed it correctly? ---- Agree with the person above me. Does not parse at all (even after adding the closing PHP tag at the end), and just shows ~~~~. ---- Mine gives me the username and date, but adds a weird character after the date. example: —Admin 15:21, 12 December 2008 e > Your PHP's gmdate does not parse the "e" code correctly. > > $date = gmdate('H:i, d F Y e'); > Remove the "e" from that line. ---- I tried putting #~~~~#, it kind of works. but it leaves a trailing # Ok, same poster as above line. I've modified the last line to... $event->data[0][1] = preg_replace('/[ \t]+[^(|||%%)]~~~~ *$/x', '---//'.$userinfo.' '.$date.'//', $event->data[0][1]); Give it a shot --johncruise > This line works in Hrun. Thank you for the mod.a --- [[user>KaiMartin|KaiMartin]] //2015-02-27 19:18// >> This line produces the desired signature in hrun. However, the plugin breaks the download of images. Images cached in the browser still rendered fine in my set-up (Dokuwiki hrun, firefox 31.5). But new images were not displayed. Seems like there is a major conflict which makes the plugin unusable in its current state. --- [[user>kaimartin|KaiMartin]] //2015-03-12 01:44// ===== Requests ===== How can I change the code to insert a link to the user-page? like ... [[:wiki:user:Admin]] instead of "Admin"