Esempio n. 1
0
 /**
  * Handles the RSS action. Constructs the rss feed of the latest posts. The
  * number of posts to return is stored in the configuration section
  *
  * @return Response
  */
 public function rssAction()
 {
     $feed = new RSS2();
     $feed->setEncoding('UTF-8');
     $feed->setTitle($this->config->rss->title);
     $feed->setDescription($this->config->rss->description);
     $feed->setLink($this->getFullUrl());
     $posts = $this->finder->getLatest(1);
     foreach ($posts as $post) {
         $feedItem = new Item();
         $feedItem->setTitle($post->getTitle());
         $feedItem->setLink($this->getFullUrl('/post/' . $post->getSlug()));
         $feedItem->setDescription($post->getContent());
         $feedItem->setDate($post->getDate());
         $feed->addItem($feedItem);
     }
     $response = new Response();
     $response->setHeader('Content-Type', 'application/xml');
     $response->setContent($feed->generateFeed());
     return $response;
 }
Esempio n. 2
0
    $TestFeed->setLink($row['link']);
    $TestFeed->setDescription($row['description']);
    $TestFeed->setChannelElement('language', 'zh-CN');
    $TestFeed->setDate(date(DATE_RSS, time()));
    $TestFeed->setChannelElement('copyright', $row['account']);
    $TestFeed->addGenerator();
    mysql_query("set character set 'utf8'");
    $sql = "SELECT * FROM `{$name}` ORDER BY lastModified DESC";
    mysql_select_db('weixincrawler');
    $retval = mysql_query($sql);
    if (!$retval) {
        die('Could not get data: ' . mysql_error());
    }
    while ($row = mysql_fetch_array($retval, MYSQL_ASSOC)) {
        $newItem = $TestFeed->createNewItem();
        $newItem->setTitle($row["title"]);
        $newItem->setLink($row["url"]);
        $newItem->setDescription($row["description"]);
        $newItem->setDate($row["lastModified"]);
        $newItem->setAuthor($name);
        $newItem->setId($row["url"], true);
        $TestFeed->addItem($newItem);
    }
    // OK. Everything is done. Now generate the feed.
    // If you want to send the feed directly to the browser, use the printFeed() method.
    $myFeed = $TestFeed->generateFeed();
    // Do anything you want with the feed in $myFeed. Why not send it to the browser? ;-)
    // You could also save it to a file if you don't want to invoke your script every time.
    echo $myFeed;
    mysql_close($conn);
}
Esempio n. 3
0
$urlParams = parse_url($_GET["url"]);
if (!empty($urlParams["query"])) {
    parse_str($urlParams["query"], $aQuery);
    if (!empty($aQuery["q"])) {
        $title .= " - " . $aQuery["q"];
    }
}
$feeds = new RSS2();
$feeds->setTitle($siteConfig->getOption("site_name"));
$feeds->setLink($siteConfig->getOption("site_url"));
$feeds->setSelfLink(!empty($_SERVER["HTTPS"]) && $_SERVER["HTTPS"] == "on" ? "https" : "http" . "://" . $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"]);
$feeds->setDescription("Flux RSS de la recherche : " . $_GET["url"]);
$feeds->setChannelElement("language", "fr-FR");
// The date when this feed was lastly updated. The publication date is also set.
$feeds->setDate(date(DATE_RSS, time()));
$feeds->setChannelElement("pubDate", date(\DATE_RSS, strtotime("2013-04-06")));
$feeds->addGenerator();
if (count($ads)) {
    foreach ($ads as $ad) {
        $item = $feeds->createNewItem();
        $item->setTitle($ad->getTitle());
        $item->setLink($ad->getLink());
        $item->setDescription(require DOCUMENT_ROOT . "/app/rss/views/rss-ad.phtml");
        $item->setDate($ad->getDate());
        $item->setId(md5($ad->getId()));
        $feeds->addItem($item);
    }
}
$content = $feeds->generateFeed();
file_put_contents($cache_filename, $content);
echo $content;
Esempio n. 4
0
$TestFeed->setImage($title, $url, $image);
if ($emission != "") {
    $jsonObject = json_decode(file_get_contents("http://" . $_SERVER['HTTP_HOST'] . "/onair/podcast/player/ws/search.php?q=" . urlencode($emission)));
} else {
    if ($sans100) {
        $jsonObject = json_decode(file_get_contents("http://" . $_SERVER['HTTP_HOST'] . "/onair/podcast/player/ws/search.php?action=sans100"));
    } else {
        $jsonObject = json_decode(file_get_contents("http://" . $_SERVER['HTTP_HOST'] . "/onair/podcast/player/ws/search.php?action=all"));
    }
}
$m2Txt = array("janvier", "février", "mars", "avril", "mai", "juin", "juillet", "août", "septembre", "octobre", "novembre", "décembre");
$i = 0;
foreach ($jsonObject as $entry) {
    if ($i > 64) {
        break;
    }
    if ($entry[3] == "1") {
        $item = $TestFeed->createNewItem();
        $details = explode("-", $entry[0]);
        $item->setTitle($entry[2] . " du " . intval($details[2]) . " " . $m2Txt[$details[1] - 1] . " " . $details[0]);
        $item->setLink("http://www.campus-clermont.net/onair/podcast/player/?date=" . $entry[0] . "&time=" . $entry[1]);
        $item->setEnclosure("http://www.campus-clermont.net/onair/podcast/player/mp3.php?dh=" . $entry[0] . "_" . $entry[1], 0, "audio/mp3", false);
        $item->setDate(strtotime($entry[0] . " " . $entry[1] . ":00:00"));
        $item->setDescription("Émission " . $entry[2] . " diffusée le " . intval($details[2]) . " " . $m2Txt[$details[1] - 1] . " à " . $entry[1] . "h sur les ondes de Radio Campus Clermont-Ferrand");
        $TestFeed->addItem($item);
        $i = $i + 1;
    }
}
$content = $TestFeed->generateFeed();
$c->store($feedkey, $content, 3600);
echo $content;
Esempio n. 5
0
 /**
  * Get RSS feed
  *
  * Converts a JSON array of event objects into an RSS feed
  * 
  * @param mixed $events Array of events to be converted
  *
  * @return string Complete markup for RSS feed
  */
 public function RSSify($events)
 {
     $feed = new RSS2();
     $this->getBuildings(null, false);
     $feed->setTitle('Upcoming Events');
     $feed->setLink('http://events.uoit.ca');
     $feed->setImage('Upcoming Events', 'http://events.uoit.ca', 'http://events.uoit.ca/img/uoit_logo.svg');
     $feed->setDescription('Upcoming events, deadlines and more at the University of Ontario Institute of Technology');
     $feed->setChannelElement('language', 'en-US');
     $feed->setDate(date(DATE_RSS, time()));
     $feed->setSelfLink(currentURL);
     $feed->setAtomLink('http://feeds.feedburner.com/uoit/events', 'hub');
     foreach ($events as $key => $event) {
         $time = date('g:i', strtotime($event['event_startdate']));
         $ampm = date('a', strtotime($event['event_startdate'])) == 'am' ? 'a.m.' : 'p.m.';
         $item = $feed->createNewItem();
         $item->setTitle($event['event_name']);
         $item->setLink('http://events.uoit.ca/event/' . $event['id']);
         $item->setId($event['id'], false);
         $item->setDescription($event['event_description']);
         $item->setDate(date("Y-m-d H:i:s"));
         $item->addElement('date', strtotime($event['event_startdate']));
         $item->addElement('time', $time . ' ' . $ampm);
         if ($event['contact_event_firstname'] && $event['contact_event_lastname'] && $event['contact_event_email']) {
             $item->setAuthor($event['contact_event_firstname'] . ' ' . $event['contact_event_lastname'], $event['contact_event_email']);
         }
         $item->addElement('location', $this->parseLocation($this->buildings, $event['location_campus'], $event['location_building'], $event['location_room'], $event['location_other']));
         $feed->addItem($item);
     }
     $output = $feed->generateFeed();
     return $output;
 }