summaryrefslogtreecommitdiff
path: root/utils/news.php
diff options
context:
space:
mode:
Diffstat (limited to 'utils/news.php')
-rw-r--r--utils/news.php36
1 files changed, 26 insertions, 10 deletions
diff --git a/utils/news.php b/utils/news.php
index 809e8dc..0493804 100644
--- a/utils/news.php
+++ b/utils/news.php
@@ -10,13 +10,14 @@ class NewsEntry {
public function show()
{
- echo "<div class=\"news_entry\">\n";
- echo " <div class=\"news_title\">" .
+ $str = "<div class=\"news_entry\">\n";
+ $str .= " <div class=\"news_title\">" .
htmlspecialchars_decode($this->title, ENT_QUOTES) . "</div>\n";
- echo " <div class=\"news_time\">" . date("D M jS Y G:i", $this->time) . "</div>\n";
- echo " <div class=\"news_description\">" .
+ $str .= " <div class=\"news_time\">" . date("D M jS Y G:i", $this->time) . "</div>\n";
+ $str .= " <div class=\"news_description\">" .
htmlspecialchars_decode($this->description, ENT_QUOTES) . "</div>\n";
- echo "</div>\n";
+ $str .= "</div>\n";
+ return $str;
}
public function NewsEntry($title, $time, $category, $description)
@@ -33,18 +34,34 @@ class News {
private $file;
private $news = array();
+ public function run($module)
+ {
+ global $show;
+
+ switch($module) {
+ case "news":
+ default:
+ if($show == "all") return $this->show(-1, "all");
+ else return $this->show(-1, "main");
+ break;
+ }
+ }
+
public function show($number, $category)
{
+ $str = "";
+
// If number is -1 show all shows.
if($number == -1) $number = 100000;
-
+
foreach($this->news as $newsentry) {
if($newsentry->category == $category || $category == "all") {
- $newsentry->show();
+ $str .= $newsentry->show();
$number--;
}
- if(!$number) return;
+ if(!$number) return $str;
}
+ return $str;
}
public function add($newsentry) {
@@ -74,7 +91,6 @@ class News {
private function read()
{
-
$dom = new DomDocument;
$dom->preserveWhiteSpace = FALSE;
$dom->load($this->file);
@@ -95,7 +111,7 @@ class News {
public function News($file)
{
$this->file = $file;
- $this->read();
+ if(file_exists($file)) $this->read();
}
}