$extra_comments[] = "Region Filter: " . $_GET["region"]; } // This might be needed for caching in the future // $cache_key = ($internal ? "INT_" : "EXT_") . ($atom_mode ? "ATOM_" : "PACK_") . ($newsstand_mode ? "NEWS" : "OPDS"); $extra_comments[] = "Status: {$status}. Number of editions to include: " . pugpig_get_num_editions(); $editions = pugpig_get_editions($status, pugpig_get_num_editions()); $edition_ids = array(); $modified = null; foreach ($editions as $edition) { if (pugpig_should_keep_edition_in_feed($edition)) { $edition_ids[] = $edition->ID; $atom_timestamp = pugpig_get_page_modified($edition); if ($atom_mode) { $this_time = $atom_timestamp; } else { $package_timestamp = pugpig_get_edition_update_date(pugpig_get_edition($edition->ID), false); $this_time = max($package_timestamp, $atom_timestamp); // so cover changes etc. are picked up } if ($modified == NULL || $modified < $this_time) { $modified = $this_time; } } } pugpig_set_cache_headers($modified, $ttl); $d = pugpig_get_opds_container($edition_ids, $internal, $atom_mode, $newsstand_mode, $extra_comments); // Add any static OPDS entries to the feed $entry_xml_string = pugpig_get_extra_opds_entries(); if (!empty($entry_xml_string)) { $fragment = $d->createDocumentFragment(); $fragment->appendChild($d->createComment("Adding static entries from pugpig_static_entry_xml setting"));
function pugpig_get_rss_root($edition_id) { $edition = pugpig_get_edition($edition_id, false); $d = new DomDocument('1.0', 'UTF-8'); $feed = $d->createElement('rss'); $feed->setAttribute('version', '2.0'); $channel = $d->createElement('channel'); $feed->appendChild($channel); $channel->appendChild(newElement($d, 'title', $edition['title'])); $channel->appendChild(newElement($d, 'link', pugpig_self_link())); $channel->appendChild(newElement($d, 'pubDate', pugpig_date_kindle(pugpig_get_edition_update_date($edition, true)))); $item = null; foreach (pugpig_get_kindle_page_array($edition) as $page) { if ($page['level'] == 1) { $item = $d->createElement('item'); $abs_path = pugpig_abs_link('editions/' . pugpig_get_atom_tag($edition['key']) . '/data/' . $page['id'] . '/kindle.rss'); $item->appendChild(newElement($d, 'link', $abs_path)); // $channel->appendChild($item); } // If we have a Level 1 node, attach it once we know we have a child // Having a section without any children breaks everything if ($page['level'] > 1 && $item != null) { // print_r($page['title']); $channel->appendChild($item); $item = null; } } $d->appendChild($feed); return $d; }