getUrl() public method

得到商品URL地址
public getUrl ( ) : string
return string the URL that shows the detail of the item
Example #1
0
 public function addItem(Item $item)
 {
     $loc = $item->getUrl();
     $lastmod = $item->getLastmod();
     $changefreq = $item->getChangefreq();
     $priority = $item->getPriority();
     $alternateLinks = $item->getAlternateMediaLinks();
     $this->add($loc, $lastmod, $changefreq, $priority);
     $this->addAlternateMediaLinks($alternateLinks);
 }
Example #2
0
 public function testSetMagnetUrl()
 {
     $item = new Item();
     $item->setUrl('magnet://link.com');
     $this->assertEquals('magnet://link.com', $item->getUrl());
 }
Example #3
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;
    }