* @access public\r
* @return void\r
*/\r
- public function genarateFeed()\r
+ public function genarateFeed($withHeaders = true)\r
{\r
- header('Content-type: text/xml; charset=UTF-8');\r
- // this line prevents Chrome 20 from prompting download\r
- // used by Google: https://news.google.com/news/feeds?ned=us&topic=b&output=rss\r
- header('X-content-type-options: nosniff');\r
+ if ($withHeaders) {\r
+ if ($this->version == RSS2) {\r
+ header('Content-type: text/xml; charset=UTF-8');\r
+ // this line prevents Chrome 20 from prompting download\r
+ // used by Google: https://news.google.com/news/feeds?ned=us&topic=b&output=rss\r
+ header('X-content-type-options: nosniff');\r
+ } elseif ($this->version == JSON) {\r
+ header('Content-type: application/json; charset=UTF-8');\r
+ } elseif ($this->version == JSONP) {\r
+ header('Content-type: application/javascript; charset=UTF-8');\r
+ }\r
+ }\r
+ \r
+ if ($this->version == JSON || $this->version == JSONP) {\r
+ $this->json = new stdClass();\r
+ }\r
+ \r
\r
$this->printHead();\r
$this->printChannels();\r
// add effective URL (URL after redirects)\r
if (isset($effective_url)) {\r
//TODO: ensure $effective_url is valid witout - sometimes it causes problems, e.g.\r
- //http://www.siasat.pk/forum/showthread.php?108883-Pakistan-Chowk-by-Rana-Mubashir-\96-25th-March-2012-Special-Program-from-Liari-(Karachi)\r
+ //http://www.siasat.pk/forum/showthread.php?108883-Pakistan-Chowk-by-Rana-Mubashir-�-25th-March-2012-Special-Program-from-Liari-(Karachi)\r
//temporary measure: use utf8_encode()\r
$newitem->addElement('dc:identifier', remove_url_cruft(utf8_encode($effective_url)));\r
} else {\r
}\r
if ($add_to_cache) {\r
ob_start();\r
- $output->genarateFeed();\r
+ $output->genarateFeed(false);\r
$output = ob_get_contents();\r
ob_end_clean();\r
if ($html_only && $item_count == 0) {\r
}\r
echo $output;\r
} else {\r
- $output->genarateFeed();\r
+ $output->genarateFeed(false);\r
}\r
if ($callback) echo ');';\r
}\r