1359fb8d403094f2abda9b52bc05b5c9bd66434a
[atutor.git] / mods / wiki / spages / PageRefs.php
1 <?php
2 /*
3    page list, ordered by count of backlinks
4 */
5
6  echo ewiki_make_title($id, $id, 2);
7
8  #-- fetch all pages
9  $exist = array() + ewiki_array($ewiki_plugins["page"]);
10  $refs = array();
11  $result = ewiki_db::GETALL(array("refs"));
12  while ($r = $result->get(0, 0x0137, EWIKI_DB_F_TEXT)) {
13     $id = $r["id"];
14     $exist[strtolower($id)] = 1;
15     foreach (explode("\n", trim($r["refs"])) as $i) {
16        $refs[$i]++;
17     }
18  }
19  unset($refs[0]);
20
21  #-- beatify list
22  if (isset($_REQUEST["desc"])) {
23     asort($refs);
24  }
25  else {
26     arsort($refs);
27  }
28
29  #-- output
30  foreach ($refs as $id=>$num) {
31     echo "ยท "
32        . "(<a href=\"" . ewiki_script("links", $id) . "\">$num</a>) "
33        . ($exist[strtolower($id)]
34            ? ("<a href=\"" . ewiki_script("", $id) . "\">$id</a>")
35            : ("$id")  )
36        . "<br>\n";
37  }
38
39 ?>