Example #1
0
 $rssFeed->setLink('http://www.mywebsite.com/blog/rss/posts.php');
 // Set the feed publication date
 $rssFeed->setPubDate('2007-08-01');
 // Set the feed last build date
 $rssFeed->setLastBuildDate(date('Y-m-d'));
 // Set the feed webmaster
 $rssFeed->setWebMaster('*****@*****.**', 'John Doe');
 // Set the feed managing editor
 $rssFeed->setManagingEditor('*****@*****.**', 'John Doe');
 // Set the feed image
 $rssFeed->setImage('http://www.mywebsite.com/image/logo.jpg', 'My Logo', 'My blog', 100, 200);
 // Adding items
 $request = mysql_query('SELECT post_id, post_title, post_description, post_author_email, post_author_name, post_date FROM post WHERE post_valid=1 LIMIT 10');
 while ($row = mysql_fetch_object($request)) {
     // Creating a new feed item
     $rssItem = new RSSFeedItem();
     $rssItem->setTitle($row->post_title);
     $rssItem->setDescription($row->post_description);
     $rssItem->setLink('http://www.mywebsite.com/blog/post.php?id=' . $row->post_id);
     $rssItem->setGuid('http://www.mywebsite.com/blog/post.php?id=' . $row->post_id, true);
     $rssItem->setComments('http://www.mywebsite.com/blog/post.php?id=' . $row->post_id . '#comments');
     $rssItem->setAuthor($row->post_author_email, $row->post_author_name);
     $rssItem->setPubDate($row->post_date);
     // Add the item to the feed
     $rssFeed->appendItem($rssItem);
 }
 // Save the feed
 $rssFeed->save();
 // SQL connection closing
 mysql_close();
 // Send headers to the browser
Example #2
0
 private function _generateSource(RSSFeedItem $item)
 {
     // Local data structures
     $source = '';
     $arraySource = $item->getSource();
     if (sizeof($arraySource) > 0) {
         $source .= str_repeat("\t", 3) . '<source url="' . $arraySource['url'] . '">' . $this->_protectString($arraySource['content']) . '</source>' . "\n";
     }
     // Return the generated string
     return $source;
 }
Example #3
0
    $oRssItem = new RSSFeedItem();
    $oRssItem->setTitle('Le cahier de textes est vide');
    $oRssItem->setDescription('Rien &agrave; afficher -> Il faut toujours revoir les le&ccedil;ons du jour.');
    $oRssItem->setLink($ServerProtocole . $_SERVER["SERVER_NAME"] . $gepiPath . '/login.php');
    $oRssItem->setGuid($ServerProtocole . $_SERVER["SERVER_NAME"] . $gepiPath . '/login.php', true);
    if (!empty($sEmail)) {
        $oRssItem->setAuthor($sEmail, 'ADMIN');
    }
    $oRssItem->setPubDate(date("Y-m-d h:i:s"));
    $oRssFeed->appendItem($oRssItem);
    $oRssItem = null;
} else {
    // Récupération de l'email
    //$sEmail = getSettingValue("gepiSchoolEmail");
    $sEmail = $rss_email_defaut;
    $oRssItem = new RSSFeedItem();
    $oRssItem->setTitle('ERREUR sur le CDT');
    $oRssItem->setDescription('Rien &agrave; afficher -> Il faut toujours apprendre les le&ccedil;ons du jour.');
    $oRssItem->setLink($ServerProtocole . $_SERVER["SERVER_NAME"] . $gepiPath . '/login.php');
    $oRssItem->setGuid($ServerProtocole . $_SERVER["SERVER_NAME"] . $gepiPath . '/login.php', true);
    if (!empty($sEmail)) {
        $oRssItem->setAuthor($sEmail, 'ADMIN');
    }
    $oRssItem->setPubDate(date("Y-m-d h:i:s"));
    $oRssFeed->appendItem($oRssItem);
    $oRssItem = null;
}
// Sauvegarde du flux RSS
$oRssFeed->save('../temp/rss-news.xml');
// Affichage sur la sortie standard
header('Content-Type: text/xml; charset=UTF-8');