function pugpig_get_atom_container($edition_id, $include_hidden = false, $search_term = null, $links = null, $content_filter = null)
{
    $edition = pugpig_get_edition($edition_id, $include_hidden, true, $search_term, $content_filter);
    $d = new DomDocument('1.0', 'UTF-8');
    $feed = $d->createElement('feed');
    $feed->setAttribute('xmlns', 'http://www.w3.org/2005/Atom');
    $feed->setAttribute('xmlns:app', 'http://www.w3.org/2007/app');
    $feed->setAttribute('xmlns:dcterms', 'http://purl.org/dc/terms/');
    $atom_edition_id = _pugpig_get_atom_tag_internal($edition['key']);
    // Generate unqiue IDs for each search
    if ($search_term) {
        $atom_edition_id .= "." . time();
    }
    $feed->appendChild(newElement($d, 'id', $atom_edition_id));
    $comment = ' ' . ($include_hidden ? "Atom Including Hidden Files - " : "Atom Contents Feeds - ");
    $comment .= "Generated: " . date(DATE_RFC822) . ' ';
    $feed->appendChild($d->createComment($comment));
    if ($content_filter) {
        $feed->appendChild($d->createComment(" Filter: " . $content_filter . ' '));
    }
    _pugpig_create_xml_link($d, $feed, array('rel' => 'self', 'type' => 'application/atom+xml', 'href' => pugpig_self_link()));
    // Enclosures
    if ($links) {
        foreach ($links as $link) {
            _pugpig_create_xml_link($d, $feed, $link);
        }
    }
    if ($search_term) {
        $feed->appendChild(newElement($d, 'title', "Search results for: '{$search_term}' - " . $edition['title']));
        $feed->appendChild(newElement($d, 'updated', pugpig_date3339()));
    } else {
        $feed->appendChild(newElement($d, 'title', $edition['title']));
        $feed->appendChild(newElement($d, 'updated', pugpig_date3339(pugpig_get_edition_update_date($edition, true))));
    }
    $author = $d->createElement('author');
    $author->appendChild($d->createElement('name', 'Pugpig'));
    $feed->appendChild($author);
    $all_pages = array();
    foreach ($edition['page_ids'] as $page_id) {
        $pages = pugpig_get_pages($page_id, $edition_id, $content_filter);
        $all_pages = array_merge($all_pages, $pages);
    }
    $all_pages = pugpig_post_process_pages($all_pages, $edition_id, $content_filter);
    foreach ($all_pages as $page) {
        if ($page['status'] == 'published') {
            // We only ever want published pages in these feeds
            $entry = pugpig_get_atom_entry($d, $page, $edition);
            $feed->appendChild($entry);
        }
    }
    $d->appendChild($feed);
    return $d;
}
function pugpig_get_atom_container($edition_id, $include_hidden = FALSE)
{
    $edition = pugpig_get_edition($edition_id, $include_hidden);
    $d = new DomDocument('1.0', 'UTF-8');
    $feed = $d->createElement('feed');
    $feed->setAttribute('xmlns', 'http://www.w3.org/2005/Atom');
    $feed->setAttribute('xmlns:app', 'http://www.w3.org/2007/app');
    $feed->appendChild(newElement($d, 'id', pugpig_get_atom_tag($edition['key'])));
    $comment = ' ' . ($include_hidden ? "Atom Including Hidden Files - " : "Atom Contents Feeds - ");
    $comment .= "Generated: " . date(DATE_RFC822) . ' ';
    $feed->appendChild($d->createComment($comment));
    $link = $d->createElement('link');
    $link->setAttribute('rel', 'self');
    $link->setAttribute('type', 'application/atom+xml');
    $link->setAttribute('href', pugpig_self_link());
    $feed->appendChild($link);
    $feed->appendChild(newElement($d, 'title', $edition['title']));
    $feed->appendChild(newElement($d, 'updated', pugpig_date3339(pugpig_get_edition_update_date($edition, TRUE))));
    $author = $d->createElement('author');
    $author->appendChild($d->createElement('name', 'Pugpig'));
    $feed->appendChild($author);
    foreach ($edition['page_ids'] as $page_id) {
        $page = pugpig_get_page($page_id, $edition_id);
        // We only ever want published pages in these feeds
        if ($page['status'] == 'published') {
            $entry = pugpig_get_atom_entry($d, $page, $edition);
            $feed->appendChild($entry);
        }
    }
    $d->appendChild($feed);
    return $d;
}