4 This plugin implements the LinkDatabase like by UseMod/MeatballWiki
5 (which summarizes pages and all links inside of it, each entry line
6 separated by a <br />).
10 $ewiki_plugins["page"]["LinkDatabase"] = "ewiki_linkdatabase";
11 $ewiki_plugins["handler"][] = "ewiki_linkdatabase";
14 function ewiki_linkdatabase($id, &$data, $action) {
16 if (($_REQUEST["action"]=="links") && ($id=="action=links") && empty($_REQUEST["id"])) {
22 "unique" => 1, #012 unimplemented
29 $o = array_merge($o, $_REQUEST);
31 #-- first read in all pages
32 $res = ewiki_db::GETALL(array("flags", "version", "refs"));
34 while ($row = $res->get()) {
35 if (($row["version"]&EWIKI_DB_F_TYPE) == EWIKI_DB_F_TEXT) {
36 $refs = trim($row["refs"]);
37 if (!$o["empty"] && empty($refs)) {
40 $all[$row["id"]] = $refs;
49 foreach ($all as $i=>$refs) {
50 $refs = explode("\n", $refs);
52 $refs = ewiki_db::FIND($refs);
54 foreach ($refs as $ri=>$rv) {
55 if ($o["exists"]!= 2) {
56 if ($rv != $o["exists"]) {
61 if ($o["url"] XOR strpos($ri, "://")) {
65 if ($o["inter"] != 1) {
66 if ($o["inter"] XOR strpos($ri, ":") && !strpos($ri, "://")) {
70 if ($o["search"] && (strpos($ri, $o["search"])===false)) {
74 if (!$o["empty"] && empty($refs)) {
80 $out .= "<a href=\"" . ewiki_script("", $i) . "\">$i</a> ";
81 foreach ($refs as $i=>$rv) {
82 $title = $o[names] ? $i : " ";
84 $out .= " <a href=\"" . ewiki_script("", $i) . "\">$title</a>";
89 $out .= "<a href=\"" . ewiki_script("", $i) . "\">?</a>";
95 return("\n<pre>\n\n\n\n$out</pre>\n");
97 elseif ($id == "LinkDatabase") {
99 # $url = "ErfurtWiki:";
100 return ewiki_format(<<<EOT
103 The LinkDatabase provides a list of all internal pages together with the
104 links outgoing from each.
106 * [{$url}action=links] list pages and links, using default options
107 * [{$url}action=links&editlink=1] add the "?" link for not existent pages
108 * [{$url}action=links&empty=1] allowes listing of pages without forward links
109 * [{$url}action=links&names=0] no link title, just the <a href="...">
110 * [{$url}action=links&sort=0] order pages and their links
111 * [{$url}action=links&exists=0] only links to not existing pages
112 * [{$url}action=links&exists=1] only existing page links
113 * [{$url}action=links&url=1] add URLs
114 * [{$url}action=links&url=2] __only__ URLs
115 * [{$url}action=links&inter=1] add ~InterWiki:Links
116 * [{$url}action=links&inter=2] __only__ ~InterWiki:Links
117 * [{$url}action=links&search=google] apply search pattern to page links
120 * [{$url}action=links&inter=1&editlink=1&empty=1&url=1&sort=0&names=1] show all links
121 * [{$url}action=links&search=sourceforge&url=2] only URL links to sourceforge
122 * [{$url}action=links&sort=0&exists=0] unsorted missing pages
124 Only [{$url}action=links&unique=0] has not been implemented.