6d6f3708ad075b7cffe82b10448bba4618054929
[atutor.git] / mods / wiki / plugins / page / orphanedpages.php
1 <?php
2
3 /*
4    -- OBSOLETED by according spages/ plugin --
5    lists all pages, which are not referenced from others
6    (works rather unclean and dumb)
7 */
8
9
10 define("EWIKI_PAGE_ORPHANEDPAGES", "OrphanedPages");
11 $ewiki_plugins["page"][EWIKI_PAGE_ORPHANEDPAGES] = "ewiki_page_orphanedpages";
12
13
14 function ewiki_page_orphanedpages($id, $data, $action) {
15
16    global $ewiki_links;
17
18    $o = ewiki_make_title($id, $id, 2);
19
20    $pages = array();
21    $refs = array();
22    $orphaned = array();
23
24    #-- read database
25    $db = ewiki_db::GETALL(array("refs", "flags"));
26    $n=0;
27    while ($row = $db->get()) {
28
29       $p = $row["id"];
30
31       #-- remove self-reference
32       $row["refs"] = str_replace("\n$p\n", "\n", $row["refs"]);
33
34       #-- add to list of referenced pages
35       $rf = explode("\n", trim($row["refs"]));
36       $refs = array_merge($refs, $rf);
37       if ($n++ > 299) {
38          $refs = array_unique($refs);
39          $n=0;
40       } // (clean-up only every 300th loop)
41
42       #-- add page name
43       if (($row["flags"] & EWIKI_DB_F_TYPE) == EWIKI_DB_F_TEXT) {
44          $pages[] = $row["id"];
45       }
46    }
47    $refs = array_unique($refs);
48
49    #-- check pages to be referenced from somewhere
50    foreach ($pages as $p) {
51       if (!ewiki_in_array($p, $refs)) {
52          if (!EWIKI_PROTECTED_MODE || !EWIKI_PROTECTED_MODE_HIDING || ewiki_auth($p, $uu, "view")) {
53             $orphaned[] = $p;    
54          }  
55       }
56    }
57
58    #-- output
59    $o .= ewiki_list_pages($orphaned, 0);
60
61    return($o);
62 }
63
64
65 ?>