MDL-11082 Improved groups upgrade performance 1.8x -> 1.9; thanks Eloy for telling...
[moodle-pu.git] / mod / wiki / ewiki / plugins / moodle / wantedpages.php
blobdc3869da4fc3cd984be0188e86b66c2267d06309
1 <?php // $Id$
3 # lists pages, which were referenced
4 # but not yet written
7 $ewiki_plugins["page"]["WantedPages"] = "ewiki_page_wantedpages";
8 #<off># $ewiki_plugins["page"]["DanglingSymlinks"] = "ewiki_page_wantedpages";
11 function ewiki_page_wantedpages($id, $data, $action) {
12 $wanted=array();
13 #-- collect referenced pages
14 $result = ewiki_database("GETALL", array("refs"));
15 while ($row = $result->get()) {
16 if (EWIKI_PROTECTED_MODE && EWIKI_PROTECTED_MODE_HIDING && !ewiki_auth($row["id"], $uu, "view")) {
17 continue;
19 $refs .= $row["refs"];
22 #-- build array
23 $refs = array_unique(explode("\n", $refs));
25 #-- strip existing pages from array
26 $refs = ewiki_database("FIND", $refs);
27 foreach ($refs as $id=>$exists) {
28 if (EWIKI_PROTECTED_MODE && EWIKI_PROTECTED_MODE_HIDING && !ewiki_auth($row["id"], $uu, "view")) {
29 continue;
31 if (!$exists && !strstr($id, "://") && strlen(trim($id))) {
32 $wanted[] = $id;
36 // to prevent empty <ul></ul> getting printed out, we have to interate twice.
37 // once to make sure the <ul></ul> is needed at all.
38 // MDL-7861, <ul></ul> does not validate.
40 $printul = false;
41 foreach ($wanted as $page) {
42 $link = ewiki_link_regex_callback(array($page, $page));
43 if (strstr($link, "?</a>")) {
44 $printul = true;
47 #-- print out
49 if ($printul) {
50 $o .= "<ul>";
51 foreach ($wanted as $page) {
53 $link = ewiki_link_regex_callback(array($page, $page));
55 if (strstr($link, "?</a>")) {
56 $o .= "<li>" . $link . "</li>";
60 $o .= "</ul>";
62 return($o);