/**
* Render the document
*
* @param boolean $cache If true, cache the output
* @param array $params Associative array of attributes
*
* @return string The rendered data
*
* @since 1.7.0
* @throws \Exception
* @todo Make this cacheable
*/
public function render($cache = false, $params = array())
{
// Get the feed type
$type = CmsFactory::getApplication()->input->get('type', 'rss');
// Instantiate feed renderer and set the mime encoding
$renderer = $this->loadRenderer($type ?: 'rss');
if (!$renderer instanceof DocumentRenderer) {
throw new \Exception(Text::_('JGLOBAL_RESOURCE_NOT_FOUND'), 404);
}
$this->setMimeEncoding($renderer->getContentType());
// Output
// Generate prolog
$data = "<?xml version=\"1.0\" encoding=\"" . $this->_charset . "\"?>\n";
$data .= "<!-- generator=\"" . $this->getGenerator() . "\" -->\n";
// Generate stylesheet links
foreach ($this->_styleSheets as $src => $attr) {
$data .= "<?xml-stylesheet href=\"{$src}\" type=\"" . $attr['type'] . "\"?>\n";
}
// Render the feed
$data .= $renderer->render();
parent::render($cache, $params);
return $data;
}