Example #1
0
 public function testMakeLinksInBodyOpenNewTab()
 {
     $item = new Item();
     $item->setBody("<a href=\"test\">ha</a>");
     $this->assertEquals("<a target=\"_blank\" rel=\"noreferrer\" href=\"test\">ha</a>", $item->getBody());
 }
Example #2
0
    /**
     * @brief Save the feed and all its items into the database
     * @returns The id of the feed in the database table.
     */
    public function save(Item $item, $feedid)
    {
        $guid = $item->getGuid();
        $guid_hash = md5($guid);
        $status = $item->getStatus();
        $itemid = $this->findIdFromGuid($guid_hash, $guid, $feedid);
        if ($itemid == null) {
            $title = $item->getTitle();
            $body = $item->getBody();
            $author = $item->getAuthor();
            $stmt = \OCP\DB::prepare('
				INSERT INTO ' . self::tableName . '(url, title, body, author, guid, guid_hash, pub_date, feed_id, status)
				VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)
				');
            if (empty($title)) {
                $l = \OC_L10N::get('news');
                $title = $l->t('no title');
            }
            if (empty($body)) {
                $l = \OC_L10N::get('news');
                $body = $l->t('no body');
            }
            $pub_date = Utils::unixtimeToDbtimestamp($item->getDate());
            $params = array($item->getUrl(), $title, $body, $author, $guid, $guid_hash, $pub_date, $feedid, $status);
            $stmt->execute($params);
            $itemid = \OCP\DB::insertid(self::tableName);
        } else {
            $this->update($item);
        }
        $item->setId($itemid);
        return $itemid;
    }