public function create_atom_wrapper($alternate, $self, $id, $updated = null)
{
// Store handler vars since we'll be using them a lot.
$handler_vars = Controller::get_handler_vars();
// Retrieve the current matched rule and store its name and argument values.
$rr = URL::get_matched_rule();
$rr_name = $rr->name;
$rr_args = $rr->named_arg_values;
// Build the namespaces, plugins can alter it to override or insert their own.
$namespaces = array('default' => 'http://www.w3.org/2005/Atom');
$namespaces = Plugins::filter('atom_get_collection_namespaces', $namespaces);
$namespaces = array_map(function ($value, $key) {
return ($key == "default" ? "xmlns" : "xmlns:" . $key) . "=\"" . $value . "\"";
}, $namespaces, array_keys($namespaces));
$namespaces = implode(' ', $namespaces);
$xml = new SimpleXMLElement('<feed ' . $namespaces . '></feed>');
$feed_generator = $xml->addChild('generator', 'Habari');
$feed_generator->addAttribute('uri', 'http://www.habariproject.org/');
$feed_generator->addAttribute('version', Version::get_habariversion());
$feed_id = $xml->addChild('id', 'tag:' . Site::get_url('hostname') . ',' . date("Y-m-d") . ':' . $id . '/' . Options::get('public-GUID'));
$feed_title = $xml->addChild('title', Utils::htmlspecialchars(Options::get('title')));
if ($tagline = Options::get('tagline')) {
$feed_subtitle = $xml->addChild('subtitle', Utils::htmlspecialchars($tagline));
}
if ($updated == null) {
$feed_updated = $xml->addChild('updated', DateTime::create()->get('c'));
} else {
$feed_updated = $xml->addChild('updated', $updated->get('c'));
}
$feed_link = $xml->addChild('link');
$feed_link->addAttribute('rel', 'alternate');
$feed_link->addAttribute('href', $alternate);
$feed_link = $xml->addChild('link');
$feed_link->addAttribute('rel', 'self');
$feed_link->addAttribute('href', $self);
Plugins::act('atom_create_wrapper', $xml);
return $xml;
}