Beispiel #1
0
 function show()
 {
     $url = 'https://foodl.org/api/e/feed/uninett-sj3gr86sb3';
     $as = new Data_EventStream($this->fdb);
     $feed = $this->parameters[0];
     $as->prepareFeed($feed);
     // $feed = $this->parameters[0];
     // header('Content-type: text/plain; charset=utf-8');
     // echo "hello world\n" . $feed;
     // print_r($as->getData());
     $feedData = $as->getData();
     $rssfeed = new RSS2FeedWriter();
     $rssfeed->setTitle('UNINETT Foodle');
     $rssfeed->setLink('https://foodl.org');
     $rssfeed->setDescription('Foodle is a simple tool for meeting invitations and polls');
     // $rssfeed->setImage('Testing the RSS writer class','http://www.ajaxray.com/projects/rss','http://www.rightbrainsolution.com/_resources/img/logo.png');
     foreach ($feedData as $feedItem) {
         $rssitem = $rssfeed->createNewItem();
         $rssitem->setTitle($feedItem['foodle']['name']);
         $rssitem->setLink('https://foodl.org/foodle/' . $feedItem['foodle']['id']);
         //The parameter is a timestamp for setDate() function
         $rssitem->setDate($feedItem['foodle']['unix']);
         $rssitem->setDescription($feedItem['foodle']['descr']);
         $rssfeed->addItem($rssitem);
     }
     $rssfeed->generateFeed();
     exit;
 }
Beispiel #2
0
        $datetext = str_replace('agost', 'August', $datetext);
        $datetext = str_replace('setembre', 'September', $datetext);
        $datetext = str_replace('octubre', 'October', $datetext);
        $datetext = str_replace('novembre', 'November', $datetext);
        $datetext = str_replace('desembre', 'December', $datetext);
        $date = date_create_from_format('F d, Y H:i:s', $datetext . ' 00:00:00');
        $newItem->setDate($date->format('Y-m-d H:i:s'));
        //Now add the feed item
        $TestFeed->addItem($newItem);
        $feed_count++;
    }
    $texts = $html->find('text');
    $go_on = FALSE;
    foreach ($texts as $text) {
        if ($text->plaintext == '« Older Entries') {
            //Not sleeping, Wordpress.com does not appear to be rate-limited
            $html_text = file_get_contents($text->parent->href) or exit(1);
            $tidy = tidy_parse_string($html_text, $tidy_config, 'UTF8');
            tidy_clean_repair($tidy);
            $html = str_get_html(tidy_get_output($tidy));
            $go_on = TRUE;
            break;
        }
    }
}
if ($feed_count == 0) {
    //No error but no feeds, this is wrong
    exit(1);
}
$TestFeed->generateFeed();
Beispiel #3
0
 /**
  * rss feed
  *
  * @return void
  */
 public function rss()
 {
     $this->needsLoggedInOrPublicMode();
     $feedWriter = new \RSS2FeedWriter();
     $feedWriter->setTitle(\F3::get('rss_title'));
     $feedWriter->setLink($this->view->base);
     // get sources
     $sourceDao = new \daos\Sources();
     $lastSourceId = 0;
     $lastSourceName = "";
     // set options
     $options = array();
     if (count($_GET) > 0) {
         $options = $_GET;
     }
     $options['items'] = \F3::get('rss_max_items');
     if (\F3::get('PARAMS["tag"]') != null) {
         $options['tag'] = \F3::get('PARAMS["tag"]');
     }
     if (\F3::get('PARAMS["type"]') != null) {
         $options['type'] = \F3::get('PARAMS["type"]');
     }
     // get items
     $newestEntryDate = false;
     $lastid = -1;
     $itemDao = new \daos\Items();
     foreach ($itemDao->get($options) as $item) {
         if ($newestEntryDate === false) {
             $newestEntryDate = $item['datetime'];
         }
         $newItem = $feedWriter->createNewItem();
         // get Source Name
         if ($item['source'] != $lastSourceId) {
             foreach ($sourceDao->get() as $source) {
                 if ($source['id'] == $item['source']) {
                     $lastSourceId = $source['id'];
                     $lastSourceName = $source['title'];
                     break;
                 }
             }
         }
         $newItem->setTitle(str_replace('&', '&', $this->UTF8entities($item['title'] . " (" . $lastSourceName . ")")));
         @$newItem->setLink($item['link']);
         $newItem->setDate($item['datetime']);
         $newItem->setDescription(str_replace('"', '"', $item['content']));
         // add tags in category node
         $itemsTags = explode(",", $item['tags']);
         foreach ($itemsTags as $tag) {
             $tag = trim($tag);
             if (strlen($tag) > 0) {
                 $newItem->addElement('category', $tag);
             }
         }
         $feedWriter->addItem($newItem);
         $lastid = $item['id'];
         // mark as read
         if (\F3::get('rss_mark_as_read') == 1 && $lastid != -1) {
             $itemDao->mark($lastid);
         }
     }
     if ($newestEntryDate === false) {
         $newestEntryDate = date(\DATE_ATOM, time());
     }
     $feedWriter->setChannelElement('updated', $newestEntryDate);
     $feedWriter->generateFeed();
 }
Beispiel #4
0
//$feed->setImage('Testing the RSS writer class','http://www.ajaxray.com/projects/rss','http://www.rightbrainsolution.com/_resources/img/logo.png');
$feed->setChannelElement('language', 'en-us');
$feed->setChannelElement('pubDate', date(DATE_RSS, time()));
$contents = ORM::for_table('contents')->where('enabled', 1)->find_many();
if (sizeof($contents) > 0) {
    foreach ($contents as $content) {
        $item = $feed->createNewItem();
        $item->setTitle($content->title);
        $item->setLink($content_url . $content->id);
        $item->setDate(strtotime($content->created));
        $item->setDescription(strip_tags($content->text));
        //$item->addElement('author', 'admin@ajaxray.com (Anis uddin Ahmad)');
        $feed->addItem($item);
    }
}
$feed->generateFeed();
function idiorm($path)
{
    if (is_file($path) && is_readable($path)) {
        include $path;
    } else {
        return false;
    }
    if (!isset(MSettings::$db_host) || !strlen(MSettings::$db_host) > 0) {
        return false;
    }
    if (!isset(MSettings::$db) || !strlen(MSettings::$db) > 0) {
        return false;
    }
    if (!isset(MSettings::$db_user) || !strlen(MSettings::$db_user) > 0) {
        return false;