Exemplo n.º 1
0
 public function testNewsBeuter()
 {
     $import = new Import(file_get_contents('tests/fixtures/newsbeuter.opml'));
     $entries = $import->execute();
     $this->assertEquals(35, count($entries));
     $this->assertEquals('', $entries[1]->category);
     $this->assertEquals('code.flickr.com', $entries[1]->title);
     $this->assertEquals('http://code.flickr.net/feed/', $entries[1]->feed_url);
     $this->assertEquals('http://code.flickr.net', $entries[1]->site_url);
 }
Exemplo n.º 2
0
function import_opml($content)
{
    $import = new Import($content);
    $feeds = $import->execute();
    if ($feeds) {
        $db = Database::get('db');
        $db->startTransaction();
        foreach ($feeds as $feed) {
            if (!$db->table('feeds')->eq('feed_url', $feed->feed_url)->count()) {
                $db->table('feeds')->save(array('title' => $feed->title, 'site_url' => $feed->site_url, 'feed_url' => $feed->feed_url));
            }
        }
        $db->closeTransaction();
        Config\write_debug();
        return true;
    }
    Config\write_debug();
    return false;
}