From c34ccc130e2a507c266ee54a163cdf3a5886d63d Mon Sep 17 00:00:00 2001 From: deva Date: Tue, 2 Mar 2010 15:00:35 +0000 Subject: Made a lot of changes, making it possible to entirely remove th config.php file from the project. These changes includes the creation of a new rss config module, the adding of some config vars in both the events and news modules. --- utils/rss.php | 54 ++++++++++++++++++++++-------------------------------- 1 file changed, 22 insertions(+), 32 deletions(-) (limited to 'utils/rss.php') 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 @@ \n"; - echo "
" . - htmlspecialchars_decode($this->title, ENT_QUOTES) . "
\n"; - echo "
" . date("D M jS Y G:i", $this->time) . "
\n"; - echo "
" . - htmlspecialchars_decode($this->description, ENT_QUOTES) . "
\n"; - echo "\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, "\n"); fwrite($fp, "\n"); fwrite($fp, " \n"); - fwrite($fp, " ".$RSS_TITLE."\n"); - fwrite($fp, " \n"); - fwrite($fp, " ".$RSS_URL."\n"); - fwrite($fp, " ".$RSS_DESCRIPTION."\n"); + fwrite($fp, " ".$this->config->title."\n"); + fwrite($fp, " config->url."/rss.xml\" rel=\"self\" type=\"application/rss+xml\" />\n"); + fwrite($fp, " ".$this->config->url."\n"); + fwrite($fp, " ".$this->config->description."\n"); fwrite($fp, " en-us\n"); fwrite($fp, " ".$this->date(time())."\n"); fwrite($fp, " ".$this->date(time())."\n"); fwrite($fp, " http://blogs.law.harvard.edu/tech/rss\n"); fwrite($fp, " ExecutionRoom CMS\n"); - fwrite($fp, " ".$RSS_EDITOR."\n"); - fwrite($fp, " ".$RSS_WEBMASTER."\n"); + fwrite($fp, " ".$this->config->editoremail."\n"); + fwrite($fp, " ".$this->config->webmasteremail."\n"); $i = 0; foreach($this->news as $newsentry) { fwrite($fp, " \n"); fwrite($fp, " ".$newsentry->title."\n"); - fwrite($fp, " ".$RSS_URL."/?page=".$RSS_TARGET_PAGE."&newsid=".$newsentry->time."\n"); + fwrite($fp, " ".$this->config->url."/?page=".$this->newspage."&newsid=".$newsentry->time."\n"); $content = htmlspecialchars(Markdown(htmlspecialchars_decode($newsentry->description), true)); fwrite($fp, " ".$content."\n"); fwrite($fp, " ".$this->date($newsentry->time)."\n"); - fwrite($fp, " ".$RSS_URL."/?page=".$RSS_TARGET_PAGE."&newsid=".$newsentry->time."\n"); + fwrite($fp, " ".$this->config->url."/?page=".$this->newspage."&newsid=".$newsentry->time."\n"); fwrite($fp, " \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(); } -- cgit v1.2.3