The feed is now a class
This commit is contained in:
parent
fc55a4b9c0
commit
74ba0c896a
|
@ -1,10 +1,23 @@
|
|||
<?php
|
||||
/**
|
||||
* @file src/Protocol/Feed.php
|
||||
* @brief Imports RSS/RDF/Atom feeds
|
||||
*
|
||||
*/
|
||||
namespace Friendica\Protocol;
|
||||
|
||||
use Friendica\Database\DBM;
|
||||
use Friendica\Core\System;
|
||||
use dba;
|
||||
|
||||
require_once("include/html2bbcode.php");
|
||||
require_once("include/items.php");
|
||||
|
||||
/**
|
||||
* @brief This class contain functions to import feeds
|
||||
*
|
||||
*/
|
||||
class Feed {
|
||||
/**
|
||||
* @brief Read a RSS/RDF/Atom feed and create an item entry for it
|
||||
*
|
||||
|
@ -16,7 +29,7 @@ require_once("include/items.php");
|
|||
*
|
||||
* @return array In simulation mode it returns the header and the first item
|
||||
*/
|
||||
function feed_import($xml,$importer,&$contact, &$hub, $simulate = false) {
|
||||
function import($xml, $importer, &$contact, &$hub, $simulate = false) {
|
||||
|
||||
$a = get_app();
|
||||
|
||||
|
@ -236,10 +249,11 @@ function feed_import($xml,$importer,&$contact, &$hub, $simulate = false) {
|
|||
$item["parent-uri"] = $item["uri"];
|
||||
|
||||
if (!$simulate) {
|
||||
$r = q("SELECT `id` FROM `item` WHERE `uid` = %d AND `uri` = '%s' AND `network` IN ('%s', '%s')",
|
||||
intval($importer["uid"]), dbesc($item["uri"]), dbesc(NETWORK_FEED), dbesc(NETWORK_DFRN));
|
||||
if (DBM::is_result($r)) {
|
||||
logger("Item with uri ".$item["uri"]." for user ".$importer["uid"]." already existed under id ".$r[0]["id"], LOGGER_DEBUG);
|
||||
$condition = ["`uid` = ? AND `uri` = ? AND `network` IN (?, ?)",
|
||||
$importer["uid"], $item["uri"], NETWORK_FEED, NETWORK_DFRN];
|
||||
$previous = dba::select('item', ['id'], $condition, ['limit' => 1]);
|
||||
if (DBM::is_result($previous)) {
|
||||
logger("Item with uri ".$item["uri"]." for user ".$importer["uid"]." already existed under id ".$previous["id"], LOGGER_DEBUG);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
@ -436,3 +450,4 @@ function feed_import($xml,$importer,&$contact, &$hub, $simulate = false) {
|
|||
return array("header" => $author, "items" => $items);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user