01fe2974bae4c52e39ed9d51872b29777685883f
[atutor.git] / mods / wiki / plugins / linking / shortwiki.php
1 <?php
2 /*
3    adds the markup extension to render  "User|Name"
4    into a link to "UserName" entitled
5    with just "User", or simply said: Short|Link ==> [Short|ShortLink]
6 */
7
8 $ewiki_plugins["format_source"][] = "ewiki_markup_short_wiki_links";
9
10 function ewiki_markup_short_wiki_links(&$src) {
11
12    $u = EWIKI_CHARS_U;
13    $l = EWIKI_CHARS_L;
14    
15    $src = "[" . $src;
16    $src = preg_replace(
17       "/([\]\n][^\[]*?)([$u]+[$l]+[$u$l]*)\|([$u]+[$l]+[$u$l]*)/ms",
18       '\1[\2|\2\3]',
19       $src
20    );
21    $src = substr($src, 1);
22 }
23
24 ?>