$value) { $translation[$key] = '&#' . ord ($key) . ';'; } $translation[chr(38)] = '&'; $newstr=preg_replace("/&(?![A-Za-z]{0,4}\w{2,3};|#[0-9]{2,3};)/","&", strtr($str, $translation)); $newstr=str_replace("’","'",$newstr); return $newstr=str_replace("&rsquo","'",$newstr); } // the class constructor is executed when creating an instance of the class function RSSFactory($title, $newsdate,$description) { // save feed data to local class members $this->_title = $title; $this->_newsdate = $newsdate; $this->_description=$description; } // adds a new feed item function addItem($title, $newsdate,$id,$shortDesc) { // add feed item $this->_items[] = array_merge(array('title' => $title, 'pubDate' => $newsdate, 'description' =>strip_tags(stripslashes($shortDesc)), 'guid' => $id.' at http://www.stinkyjournalism.org', 'link'=>'http://www.stinkyjournalism.org/latest-journalism-news-updates-'.$id.'.php')) ; } // generates feed function get() { // initial preparations header('Content-type: text/xml'); // generate feed header echo '' . '' . '' . RSSFactory::_escapeXML($this->_title). '' . '' . RSSFactory::_escapeXML($this->_newsdate) . ' GMT' . '_description).']]>'. 'http://www.stinkyjournalism.org/latest-journalism-news-updates.php'; // add feed items foreach ($this->_items as $i) { echo '' ; foreach ($i as $index => $_i) { //print $_i; if (!$_i) continue; if($index=='pubDate') { echo "<$index>" .RSSFactory::_escapeXML($_i).' '.date('h:i:s'). " GMT"; } else { if ($index=='description' ){ $descChunks = explode("####", $_i); echo "<$index> '; } echo RSSFactory::_escapeXML($descChunks[1])."]]>"; }else echo "<$index>" .RSSFactory::_escapeXML($_i).""; } } echo ''; } // close channel and rss elements echo ''; // return feed data return ob_get_contents(); } } ?>