summaryrefslogtreecommitdiff
path: root/forum/utils/view.php
blob: 267339486da92e88580705e20f2c8f301ad611d9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<?php
echo "    <div class=\"navigation\">";
if($fid) {
  echo "Legend: <a href=\"?\">Forums</a>";
  if($tid) {
    include_once("forums.php");
    $forums = new Forums($FORUMS_DIR . "/forums.xml");
    $forum = $forums->getForum($fid);
    echo " :: <a href=\"?fid=" . $fid . "\">".$forum->name."</a>";

    include_once("posts.php");
    $posts = new Posts($FORUMS_DIR . "/" . $fid . "/" . $tid . ".xml");
    echo " :: ".$posts->thread->name;

    $posts->show();

  } else {
    include_once("forums.php");
    $forums = new Forums($FORUMS_DIR . "/forums.xml");
    $forum = $forums->getForum($fid);
    echo " :: ".$forum->name;

    echo "    <h1>Threads in '".$forum->name."'</h1>\n";
    echo "    <a href=\"?mode=editor&amp;task=new&amp;fid=".$fid.
      "&amp;tid=".time()."&amp;pid=-1\">New thread</a>\n";
    
    include_once("threads.php");
    $threads = new Threads($FORUMS_DIR . "/" . $fid);
    $threads->show();
  }
} else {
  echo "Legend: Forums";
  echo "    <h1>Forums</h1>\n";
  include_once("forums.php");
  $forums = new Forums($FORUMS_DIR . "/forums.xml");
  
  if($action == "addforum") {
    $newfid = 1;
    while($forums->getForum($newfid)) $newfid++;
    
    $forums->add(new Forum($newfid, $title));
    $forums->write();
  }
  
  $forums->show();
  
  if($current_user->uid == 0) {
?>
<form method="post" action="?mode=forum&amp;action=addforum">
Add new forum: <input name="title" value=""><button type="submit">Add</button>
</form>
<?php
   } 
}
echo "</div>\n";
?>