\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;
$this->time = $time;
$this->category = $category;
$this->description = $description;
}
}
class RSS {
private $newsfile;
private $rssfile;
private $news = array();
public function add($newsentry) {
$key = $newsentry->time;
$this->news[$key] = $newsentry;
}
private function date($time) {
return date("r", $time);
}
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");
fwrite($fp, "\n");
fwrite($fp, "\n");
fwrite($fp, " \n");
fwrite($fp, " ".$RSS_TITLE."\n");
fwrite($fp, " ".$RSS_URL."\n");
fwrite($fp, " ".$RSS_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");
$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");
$content = Markdown(htmlspecialchars_decode($newsentry->description));
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, "
\n");
$i++;
if($i > 6) break;
}
fwrite($fp, " \n");
fwrite($fp, "\n");
fclose($fp);
}
private function read()
{
$dom = new DomDocument;
$dom->preserveWhiteSpace = FALSE;
$dom->load($this->newsfile);
$params = $dom->getElementsByTagName('newsentry');
foreach ($params as $param) {
$rssentry = new RSSEntry($param->getAttribute('title'),
$param->getAttribute('time'),
$param->getAttribute('category'),
$param->getAttribute('description'));
$this->add($rssentry);
}
// Key sort
krsort($this->news);
}
public function RSS($newsfile, $rssfile)
{
$this->newsfile = $newsfile;
$this->rssfile = $rssfile;
$this->read();
}
}
?>