Skip to content
Browse files

Added support for mailto links

  • Loading branch information...
1 parent 10696dc commit 28683e6c3b1834fa814e31306def00d533e3aef6 thepurpleblob committed Jul 8, 2003
Showing with 12 additions and 4 deletions.
  1. +6 −2 lang/en/help/wiki.html
  2. +6 −2 lib/wiki.php
View
8 lang/en/help/wiki.html
@@ -89,8 +89,12 @@
<h3>Hyper Links</h3>
-Links can be placed in the text and are followed (with no spaces) by the text to be displayed in brackets. Example: </em>http://www.google.com/(Search Now)</em> will be converted to
-<a href="http://www.google.com/">Search Now</a>.
+<p>Links can be placed in the text and are followed (with no spaces) by the text to be displayed in brackets. Example: </em>http://www.google.com/(Search Now)</em> will be converted to
+<a href="http://www.google.com/">Search Now</a>.</p>
+
+<p>Mail links can be acheived the same way, e.g.,</p>
+<p>nobody@example.com(Test User) will be converted to
+<a href="mailto:nobody@example.com">Test User</a></p>
<h3>Moodle Module Links</h3>
View
8 lib/wiki.php
@@ -244,6 +244,10 @@ function line_replace( $line ) {
$line = eregi_replace("([[:space:]])www\.([^[:space:]]*)([[:alnum:]#?/&=])",
"\\1<A HREF=\"http://www.\\2\\3\" TARGET=\"newpage\">www.\\2\\3</A>", $line);
+ // make email addresses into mailtos....
+ $line = eregi_replace("([[:space:]]|^)([a-zA-Z0-9@.]+)\(([^)]+)\)",
+ "\\1<a href=\"mailto:\\2\">\\3</a>", $line);
+
// !# at the beginning of any lines means a heading
$line = eregi_replace( "^!([1-6]) (.*)$", "<h\\1>\\2</h\\1>", $line );
@@ -260,10 +264,10 @@ function line_replace( $line ) {
global $course; // This is a bit risky - it won't work everywhere
if ($CFG->slasharguments) {
- $line = eregi_replace( "/([a-zA-Z./_-]+)(png|gif|jpg)\(([^)]+)\)",
+ $line = eregi_replace( "/([a-zA-Z0-9./_-]+)(png|gif|jpg)\(([^)]+)\)",
"<img src=\"$CFG->wwwroot/file.php/$course->id/\\1\\2\" alt=\"\\3\" />", $line );
} else {
- $line = eregi_replace( "/([a-zA-Z./_-]+)(png|gif|jpg)\(([^)]+)\)",
+ $line = eregi_replace( "/([a-zA-Z0-9./_-]+)(png|gif|jpg)\(([^)]+)\)",
"<img src=\"$CFG->wwwroot/file.php\?file=$course->id/\\1\\2\" alt=\"\\3\" />", $line );
}

0 comments on commit 28683e6

Please sign in to comment.
Something went wrong with that request. Please try again.