function generate_rss_item($qbk_file, $page)
    {
        assert($page->loaded);
        $rss_xml = new DOMDocument();
        $rss_xml->loadXML(<<<EOL
<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:boostbook="urn:boost.org:boostbook">
</rss>
EOL
);
        $page_link = "http://www.boost.org/{$page->location}";
        $item = $rss_xml->createElement('item');
        $node = new DOMDocument();
        $node->loadXML('<title>' . $this->encode_for_rss($page->title_xml) . '</title>');
        $item->appendChild($rss_xml->importNode($node->documentElement, true));
        $node = new DOMDocument();
        $node->loadXML('<link>' . $this->encode_for_rss($page_link) . '</link>');
        $item->appendChild($rss_xml->importNode($node->documentElement, true));
        $node = new DOMDocument();
        $node->loadXML('<guid>' . $this->encode_for_rss($page_link) . '</guid>');
        $item->appendChild($rss_xml->importNode($node->documentElement, true));
        # TODO: Convert date format?
        $node = $rss_xml->createElement('pubDate');
        $node->appendChild($rss_xml->createTextNode($page->pub_date));
        $item->appendChild($node);
        $node = $rss_xml->createElement('description');
        # Placing the description in a root element to make it well formed xml->
        $description = new DOMDocument();
        $description->loadXML('<x>' . $this->encode_for_rss($page->description_xml) . '</x>');
        BoostSiteTools::base_links($description, $page_link);
        foreach ($description->firstChild->childNodes as $child) {
            $node->appendChild($rss_xml->createTextNode($description->saveXML($child)));
        }
        $item->appendChild($node);
        return array('item' => $item, 'quickbook' => $qbk_file, 'last_modified' => $page->last_modified);
    }
示例#2
0
 function generate_rss_item($qbk_file, $page)
 {
     assert(!!$page->description_xml);
     $xml = '';
     $page_link = "http://www.boost.org/{$page->location}";
     $xml .= '<item>';
     $xml .= '<title>' . $this->encode_for_rss($page->title_xml) . '</title>';
     $xml .= '<link>' . $this->encode_for_rss($page_link) . '</link>';
     $xml .= '<guid>' . $this->encode_for_rss($page_link) . '</guid>';
     // Q: Maybe use $page->last_modified when there's no pub_date.
     $pub_date = null;
     if ($page->release_data && array_key_exists('release_date', $page->release_data)) {
         $pub_date = $page->release_data['release_date'];
     } else {
         $pub_date = $page->pub_date;
     }
     if ($pub_date) {
         $xml .= '<pubDate>' . $this->encode_for_rss($pub_date->format(DATE_RSS)) . '</pubDate>';
     }
     # Placing the description in a root element to make it well formed xml->
     $description = BoostSiteTools::base_links($page->description_xml, $page_link);
     $xml .= '<description>' . $this->encode_for_rss($description) . '</description>';
     $xml .= '</item>';
     // Q: Should this be using the page last_modified, or when the RSS
     //    feed item was last modified?
     return array('item' => $xml, 'quickbook' => $qbk_file, 'last_modified' => $page->last_modified);
 }