summaryrefslogtreecommitdiff
path: root/utils/rss.php
diff options
context:
space:
mode:
Diffstat (limited to 'utils/rss.php')
-rw-r--r--utils/rss.php54
1 files changed, 22 insertions, 32 deletions
diff --git a/utils/rss.php b/utils/rss.php
index bed69ce..8eec881 100644
--- a/utils/rss.php
+++ b/utils/rss.php
@@ -1,7 +1,9 @@
<?php
+global $MODULE_DIR, $UTIL_DIR;
-include_once("convert.php");
+include_once($UTIL_DIR . "/convert.php");
include_once($UTIL_DIR . "/markdown.php");
+include_once($MODULES_DIR . "/rss.php");
class RSSEntry {
public $title;
@@ -9,18 +11,6 @@ class RSSEntry {
public $description;
public $category;
- /*
- public function show()
- {
- echo "<div class=\"news_entry\">\n";
- echo " <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\">" .
- htmlspecialchars_decode($this->description, ENT_QUOTES) . "</div>\n";
- echo "</div>\n";
- }
- */
public function RSSEntry($title, $time, $category, $description)
{
$this->title = $title;
@@ -32,9 +22,11 @@ class RSSEntry {
class RSS {
+ private $configfile;
+ private $config;
private $newsfile;
- private $rssfile;
private $news = array();
+ private $newspage;
public function add($newsentry) {
$key = $newsentry->time;
@@ -47,38 +39,31 @@ class RSS {
public function write()
{
- global $RSS_TITLE;
- global $RSS_URL;
- global $RSS_DESCRIPTION;
- global $RSS_EDITOR;
- global $RSS_WEBMASTER;
- global $RSS_TARGET_PAGE;
-
- $fp = fopen($this->rssfile, "w");
+ $fp = fopen($this->config->target, "w");
fwrite($fp, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
fwrite($fp, "<rss version=\"2.0\" xmlns:atom=\"http://www.w3.org/2005/Atom\">\n");
fwrite($fp, " <channel>\n");
- fwrite($fp, " <title>".$RSS_TITLE."</title>\n");
- fwrite($fp, " <atom:link href=\"".$RSS_URL."/rss.xml\" rel=\"self\" type=\"application/rss+xml\" />\n");
- fwrite($fp, " <link>".$RSS_URL."</link>\n");
- fwrite($fp, " <description>".$RSS_DESCRIPTION."</description>\n");
+ fwrite($fp, " <title>".$this->config->title."</title>\n");
+ fwrite($fp, " <atom:link href=\"".$this->config->url."/rss.xml\" rel=\"self\" type=\"application/rss+xml\" />\n");
+ fwrite($fp, " <link>".$this->config->url."</link>\n");
+ fwrite($fp, " <description>".$this->config->description."</description>\n");
fwrite($fp, " <language>en-us</language>\n");
fwrite($fp, " <pubDate>".$this->date(time())."</pubDate>\n");
fwrite($fp, " <lastBuildDate>".$this->date(time())."</lastBuildDate>\n");
fwrite($fp, " <docs>http://blogs.law.harvard.edu/tech/rss</docs>\n");
fwrite($fp, " <generator>ExecutionRoom CMS</generator>\n");
- fwrite($fp, " <managingEditor>".$RSS_EDITOR."</managingEditor>\n");
- fwrite($fp, " <webMaster>".$RSS_WEBMASTER."</webMaster>\n");
+ fwrite($fp, " <managingEditor>".$this->config->editoremail."</managingEditor>\n");
+ fwrite($fp, " <webMaster>".$this->config->webmasteremail."</webMaster>\n");
$i = 0;
foreach($this->news as $newsentry) {
fwrite($fp, " <item>\n");
fwrite($fp, " <title>".$newsentry->title."</title>\n");
- fwrite($fp, " <link>".$RSS_URL."/?page=".$RSS_TARGET_PAGE."&amp;newsid=".$newsentry->time."</link>\n");
+ fwrite($fp, " <link>".$this->config->url."/?page=".$this->newspage."&amp;newsid=".$newsentry->time."</link>\n");
$content = htmlspecialchars(Markdown(htmlspecialchars_decode($newsentry->description), true));
fwrite($fp, " <description>".$content."</description>\n");
fwrite($fp, " <pubDate>".$this->date($newsentry->time)."</pubDate>\n");
- fwrite($fp, " <guid>".$RSS_URL."/?page=".$RSS_TARGET_PAGE."&amp;newsid=".$newsentry->time."</guid>\n");
+ fwrite($fp, " <guid>".$this->config->url."/?page=".$this->newspage."&amp;newsid=".$newsentry->time."</guid>\n");
fwrite($fp, " </item>\n");
$i++;
if($i > 6) break;
@@ -92,10 +77,15 @@ class RSS {
private function read()
{
+ $this->config = new RSSConfig($this->configfile);
$dom = new DomDocument;
$dom->preserveWhiteSpace = FALSE;
$dom->load($this->newsfile);
+
+ $n = $dom->documentElement;
+ $this->newspage = $n->getAttribute('newspage');
+
$params = $dom->getElementsByTagName('newsentry');
foreach ($params as $param) {
@@ -110,10 +100,10 @@ class RSS {
krsort($this->news);
}
- public function RSS($newsfile, $rssfile)
+ public function RSS($newsfile, $configfile)
{
$this->newsfile = $newsfile;
- $this->rssfile = $rssfile;
+ $this->configfile = $configfile;
$this->read();
}