4 Fancyfication of page links with an <a href="..." title="..."> page
5 excerpt. This however slows down rendering a lot (pre-fetching all
6 associated pages is required) - eventually one could write another
11 $ewiki_plugins["handler"][] = "ewiki_handler_fancy_linkexcerpts";
12 $ewiki_plugins["link_final"][] = "ewiki_ahref_fancy_linkexcerpts";
15 function ewiki_handler_fancy_linkexcerpts($id, &$data, $action) {
16 global $ewiki_fancy_linkexcerpts;
17 if ($action == "view") {
18 $ewiki_fancy_linkexcerpts = array();
19 foreach (explode("\n", trim($data["refs"])) as $link) {
20 $row = ewiki_db::GET($link);
21 if (($row["flags"] & EWIKI_DB_F_TYPE) == EWIKI_DB_F_TEXT) {
22 $text = trim(substr($row["content"], 0, 160));
23 $text = substr($text, 0, strrpos($text, " "));
24 $text = strtr($text, "\t\r\n", " ");
25 $text = htmlentities($text);
26 $text = wordwrap($text, 40, " ", 0);
27 $ewiki_fancy_linkexcerpts[strtolower($link)] = $text;
35 function ewiki_ahref_fancy_linkexcerpts(&$str, &$type, &$href, &$title) {
36 global $ewiki_fancy_linkexcerpts;
37 if ($text = $ewiki_fancy_linkexcerpts[strtolower($href)]) {
38 $str = str_replace('<a ', '<a title="'.$text.'"', $str);