-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathclass.Forum.php
63 lines (50 loc) · 1.28 KB
/
class.Forum.php
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
57
58
59
60
61
62
63
<?php
/* A class representing a single Forum. Each Forum contains a number of topics.
In other words, it is the largest category.
Each forum has a forumId, a forum name, a description, a number of posts and a
number of topics.
The noOfTopics and noOfPosts are cached here for performance reasons instead of
recounting the number of posts each time it is required.
The object is constructed from a string in the following format:
forumId~forumName~description~noOfTopics~noOfPosts
Each forum is a line in a file:
db/forumList.dat
*/
class Forum
{
private $forumId;
private $forumName;
private $description;
private $posts;
private $topics;
public function __construct($str)
{
$arr = explode("~",$str);
$this->forumId = trim($arr[0]);
$this->forumName = trim($arr[1]);
$this->description = trim($arr[2]);
$this->topics = trim($arr[3]);
$this->posts = trim($arr[4]);
}
public function getDescription()
{
return $this->description;
}
public function getForumId()
{
return trim($this->forumId);
}
public function getForumName()
{
return trim($this->forumName);
}
public function getTotalPosts()
{
return $this->posts;
}
public function getTotalTopics()
{
return $this->topics;
}
}
?>