aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorAndrew Manning <tamanning@zoho.com>2016-06-25 14:29:52 -0500
committerAndrew Manning <tamanning@zoho.com>2016-06-25 14:29:52 -0500
commit0df3978cc5891f1383dd0dbcdc1c6b4c0010e645 (patch)
tree26549c9d00b9af36faa5c452cbe0ac95379451e9 /include
parent241b257556826e172707689b89e6f07687f8f556 (diff)
downloadvolse-hubzilla-0df3978cc5891f1383dd0dbcdc1c6b4c0010e645.tar.gz
volse-hubzilla-0df3978cc5891f1383dd0dbcdc1c6b4c0010e645.tar.bz2
volse-hubzilla-0df3978cc5891f1383dd0dbcdc1c6b4c0010e645.zip
A page name wrapped in double brackets is converted into a link to another page in the current wiki
Diffstat (limited to 'include')
-rw-r--r--include/wiki.php20
1 files changed, 20 insertions, 0 deletions
diff --git a/include/wiki.php b/include/wiki.php
index fdbc704dc..63cf70f3c 100644
--- a/include/wiki.php
+++ b/include/wiki.php
@@ -473,4 +473,24 @@ function wiki_generate_page_filename($name) {
} else {
return $file . '.md';
}
+}
+
+function wiki_convert_links($s, $wikiURL) {
+
+ if (strpos($s,'[[') !== false) {
+ preg_match_all("/\[\[(.*?)\]\]/", $s, $match);
+ $pages = $pageURLs = array();
+ foreach ($match[1] as $m) {
+ // TODO: Why do we need to double urlencode for this to work?
+ $pageURLs[] = urlencode(urlencode(escape_tags($m)));
+ $pages[] = $m;
+ }
+ $idx = 0;
+ while(strpos($s,'[[') !== false) {
+ $replace = '<a href="'.$wikiURL.'/'.$pageURLs[$idx].'">'.$pages[$idx].'</a>';
+ $s = preg_replace("/\[\[(.*?)\]\]/", $replace, $s, 1);
+ $idx++;
+ }
+ }
+ return $s;
} \ No newline at end of file