d6380c1539ec919dc91100b99381fda3f025e2e5
[atutor.git] / mods / wiki / plugins / aview / downloadlist.php
1 <?php
2
3 #  this plugin appends the list of uploaded attachments at the bottom of
4 #  each page, the downloads / attachments plugin must be loaded too
5 #
6 #  you could alternatively define EWIKI_AUTOVIEW to 0, and call the
7 #  ewiki_attachments() wrapper function anywhere on yoursite.php
8
9
10 if (!defined("EWIKI_AUTOVIEW") || !EWIKI_AUTOVIEW) {
11    $ewiki_plugins["view_append"][] = "ewiki_view_append_attachments";
12 }
13
14
15 $ewiki_t["en"]["ATTACHMENTS"] = "attachments";
16 $ewiki_t["de"]["ATTACHMENTS"] = "Anhänge";
17
18
19
20 function ewiki_view_append_attachments($id, $data, $action) {
21
22    $o = '<hr><h4><a href="' . ewiki_script(EWIKI_ACTION_ATTACHMENTS, $id) .
23         '">' . ewiki_t("ATTACHMENTS") . '</a></h4>';
24
25    $scan = 's:7:"section";' . serialize($id);
26    $result = ewiki_db::SEARCH("meta", $scan);
27
28    $ord = array();
29    while ($row = $result->get()) {
30       $ord[$row["id"]] = $row["created"];
31    }
32    arsort($ord);
33
34     foreach ($ord as $id => $uu) {    
35         $row = ewiki_db::GET($id);
36         if (EWIKI_PROTECTED_MODE && EWIKI_PROTECTED_MODE_HIDING && !ewiki_auth($row["id"], $row, "view")) {
37             continue;
38         }           
39         $o .= ewiki_entry_downloads($row, "*");    
40     }
41
42    return($o);
43 }
44
45
46
47
48 function ewiki_attachments() {
49    global $ewiki_title, $ewiki_id;
50    return(ewiki_view_append_attachments($ewiki_title, array("id"=>$ewiki_id), "view"));
51 }
52
53
54
55 ?>