Ejemplo n.º 1
0
    public function save(Feed $feed, $folderid)
    {
        $title = $feed->getTitle();
        $url = $feed->getUrl();
        $url_hash = md5($url);
        if (empty($title)) {
            $l = \OC_L10N::get('news');
            $title = $l->t('no title');
        }
        $favicon = $feed->getFavicon();
        //FIXME: Detect when feed contains already a database id
        $feedid = $this->findIdFromUrl($url);
        if ($feedid === null) {
            $query = \OCP\DB::prepare("\n\t\t\t\tINSERT INTO " . self::tableName . "(url, url_hash, title, favicon_link, folder_id, user_id, added, lastmodified)\n\t\t\t\tVALUES (?, ?, ?, ?, ?, ?, UNIX_TIMESTAMP(), UNIX_TIMESTAMP())\n\t\t\t\t");
            $params = array($url, $url_hash, $title, $favicon, $folderid, $this->userid);
            $query->execute($params);
            $feedid = \OCP\DB::insertid(self::tableName);
        } else {
            //update the db. it needs to be done, since it might be the first save after a full fetch
            $stmt = \OCP\DB::prepare('
					UPDATE ' . self::tableName . ' SET favicon_link = ? , lastmodified = UNIX_TIMESTAMP() , folder_id = ?
					WHERE id = ?
					');
            $params = array($favicon, $folderid, $feedid);
            $stmt->execute($params);
        }
        $feed->setId($feedid);
        $itemMapper = new ItemMapper();
        $items = $feed->getItems();
        if ($items !== null) {
            foreach ($items as $item) {
                $itemMapper->save($item, $feedid);
            }
        }
        return $feedid;
    }
Ejemplo n.º 2
0
    /*i*/
}
/*i*/
define('INSIGHT_IPS', '*');
/*i*/
define('INSIGHT_AUTHKEYS', '*');
/*i*/
define('INSIGHT_PATHS', dirname(__FILE__));
/*i*/
define('INSIGHT_SERVER_PATH', './index.php');
/*i*/
require_once 'FirePHP/Init.php';
/*i*/
FirePHP::plugin('firephp')->trapProblems();
/*i*/
FirePHP::plugin('firephp')->recordEnvironment(FirePHP::to('request')->console('Environment')->on('Show Environment'));
/*i*/
FirePHP::to('request')->console('Feed')->info('Startup');
// Application Code
require_once dirname(__FILE__) . '/feed.php';
$feed = new Feed('http://www.phpdeveloper.org/feed');
$items = $feed->getItems();
echo '<p><b>See:</b> <a target="_blank" href="http://www.christophdorn.com/Blog/2010/08/24/gain-insight-into-your-cache-interaction-with-firephp-companion/">http://www.christophdorn.com/Blog/2010/08/24/gain-insight-into-your-cache-interaction-with-firephp-companion/</a></p>' . "\n";
if ($feed->didLoad()) {
    echo '<p><b>Loading feed from: ' . $feed->getUrl() . '</b></p>' . "\n";
}
foreach ($items as $item) {
    echo '<p><a href="' . $item['link'] . '">' . $item['title'] . '</a></p>' . "\n";
}
/*i*/
FirePHP::to('request')->console('Feed')->info('Shutdown');
Ejemplo n.º 3
0
 public function testSetXSSUrl()
 {
     $feed = new Feed();
     $feed->setUrl('javascript:alert()');
     $this->assertEquals('', $feed->getUrl());
 }