4 You can embed smilies into pages, if you load this plugin. Only the
5 location and URL to the images must be configured, the directory is
6 read in at initialization.
7 Images with a textual name then can be referenced as :word:
8 from within any WikiPage, and ordinary smilies can be written as is
9 and get replaced by their graphical counterpart (if there is one).
11 A prepared "_smilies.tar.gz" package is available from
12 http://erfurtwiki.sourceforge.net/downloads/contrib-add-ons/
13 Just untar it in the ewiki main directory, due to the 'special'
14 characters this however only works on Unix filesystems.
18 define("SMILIES_DIR", "./img/smilies/");
19 define("SMILIES_BASE_HREF", "/img/smilies/");
20 $ewiki_config["smilies"] = array(
25 $ewiki_plugins["format_final"][] = "smilies_format_final";
27 function smilies_format_final(&$html) {
31 #-- read in directories
36 foreach (smilies_dir(SMILIES_DIR) as $fn) {
37 #-- check for file name extensions
38 if (($r = strrpos($fn, ".")) >= 2) {
39 $id = substr($fn, 0, $r);
40 if ($r = strrpos($fn, "/")) {
41 $id = substr($fn, $r+1);
46 if (($id0>="a") && ($id0<="z") || ($id0>="0") && ($id0<="9")) {
50 $id = htmlentities($id);
53 #-- decoding, encoding
54 if ((strpos($id, "%")!==false) && ($uu = urldecode($id))) {
58 $regex[] = preg_quote($id);
62 #-- append default images and aliases
63 foreach ($ewiki_config["smilies"] as $id=>$fn) {
65 $regex[] = preg_quote($id);
68 $regex = implode("|", $regex);
73 #-- use regex to insert <img> tags
76 '/(?!<[^>]*)('.$regex.')/e',
79 SMILIES_BASE_HREF . urlencode(stripslashes($imgs["$1"])) .
80 "\" alt=\"" . htmlentities("$1") . "\" />"
88 function smilies_dir($dir, $prep="") {
90 if ($dh = opendir($dir)) {
91 while ($fn = readdir($dh)) {
92 if (is_dir("$dir/$fn")) {
94 $r = array_merge($r, smilies_dir("$dir/$fn", "$fn/"));