4 this _link_regex_callback() plugin scans for icons in a
5 given directory and prepends it before all links generated
10 $ewiki_plugins["link_final"][] = "ewiki_link_icons";
12 define("EWIKI_LINK_ICONS_DIR", "/icons/"); # absolute to www root
13 define("EWIKI_LINK_ICONS_LOOKUP_DIR", "./icons"); # to access the files
14 define("EWIKI_LINK_ICONS_LOOKUP_SIZE", 1); # use getimagesize()
15 define("EWIKI_LINK_ICONS_DEFAULT_SIZE", 'width="14" height="14"'); # fallback
17 $ewiki_link_icons = array(
19 "notfound" => "bomb.png",
20 "email" => "letter.gif",
21 "binary" => "disk.jpeg",
23 "mailto" => "letter.gif",
29 function ewiki_link_icons(&$html, $type, $href, $title) {
31 global $ewiki_link_icons;
34 foreach (array_reverse($type) as $probe) {
36 if ($probe == "image") {
39 $probe = strtolower($probe);
42 $ewiki_link_icons[$probe],
49 foreach ($test as $f) {
51 if (strlen($f) && file_exists($fn2 = EWIKI_LINK_ICONS_LOOKUP_DIR . "/" . $f)) {
53 if (EWIKI_LINK_ICONS_LOOKUP_SIZE && ($uu = @getimagesize($fn2))) {
57 $img_sizes = EWIKI_LINK_ICONS_DEFAULT_SIZE;
60 $img = '<img src="' . EWIKI_LINK_ICONS_DIR . $f . '" ' .
61 $img_sizes . ' alt="\'" border="0" />';
63 $html = strtok($html, ">") . ">" . $img . strtok("\000");