summaryrefslogtreecommitdiff
path: root/inc
diff options
context:
space:
mode:
authorAndreas Gohr <andi@splitbrain.org>2011-11-13 13:06:07 +0100
committerAndreas Gohr <andi@splitbrain.org>2011-11-13 13:06:07 +0100
commit850dbf1f4b1e2bdee8b2e5f0438a5625d0a1bedf (patch)
tree61591f405fce05acd259512b2522813170c47a8c /inc
parentf08086ec453c4529ae7361f9540b430ee61238f0 (diff)
downloadrpg-850dbf1f4b1e2bdee8b2e5f0438a5625d0a1bedf.tar.gz
rpg-850dbf1f4b1e2bdee8b2e5f0438a5625d0a1bedf.tar.bz2
allow image embeds in HTML mail templates
Using the place holder @MEDIA(<mediaid>)@ you now can directly embed images from the media repository into your HTML mail template. An example was added to the mailwrap.html, but because images are embedded as is (no prescaling) this is suboptimal. If we keep it, a smaller version of the DokuWiki logo should be shipped with DokuWiki.
Diffstat (limited to 'inc')
-rw-r--r--inc/Mailer.class.php22
-rw-r--r--inc/lang/en/mailwrap.html1
2 files changed, 23 insertions, 0 deletions
diff --git a/inc/Mailer.class.php b/inc/Mailer.class.php
index cdd4b266a..7e6889292 100644
--- a/inc/Mailer.class.php
+++ b/inc/Mailer.class.php
@@ -87,6 +87,24 @@ class Mailer {
}
/**
+ * Callback function to automatically embed images referenced in HTML templates
+ */
+ protected function autoembed_cb($matches){
+ static $embeds = 0;
+ $embeds++;
+
+ // get file and mime type
+ $media = cleanID($matches[1]);
+ list($ext, $mime) = mimetype($media);
+ $file = mediaFN($media);
+ if(!file_exists($file)) return $matches[0]; //bad reference, keep as is
+
+ // attach it and set placeholder
+ $this->attachFile($file,$mime,'','autoembed'.$embeds);
+ return '%%autoembed'.$embeds.'%%';
+ }
+
+ /**
* Add an arbitrary header to the mail
*
* If an empy value is passed, the header is removed
@@ -163,6 +181,10 @@ class Mailer {
}
}
+ // embed media from templates
+ $html = preg_replace_callback('/@MEDIA\(([^\)]+)\)@/',
+ array($this,'autoembed_cb'),$html);
+
// prepare default replacements
$ip = clientIP();
$cip = gethostsbyaddrs($ip);
diff --git a/inc/lang/en/mailwrap.html b/inc/lang/en/mailwrap.html
index d67644c95..00daf29ac 100644
--- a/inc/lang/en/mailwrap.html
+++ b/inc/lang/en/mailwrap.html
@@ -8,6 +8,7 @@
@HTMLBODY@
<br /><br /><hr />
+<img src="@MEDIA(wiki:dokuwiki-128.png)@" width="32" height="32" alt="DokuWiki" align="left" />
<small>This mail was generated by DokuWiki at @DOKUWIKIURL@.</small>
</body>
</html>