mirror of
https://github.com/friendica/friendica
synced 2024-12-23 18:00:17 +00:00
The feed is now a class
This commit is contained in:
parent
fc55a4b9c0
commit
74ba0c896a
1 changed files with 378 additions and 363 deletions
|
@ -1,10 +1,23 @@
|
||||||
<?php
|
<?php
|
||||||
|
/**
|
||||||
|
* @file src/Protocol/Feed.php
|
||||||
|
* @brief Imports RSS/RDF/Atom feeds
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
namespace Friendica\Protocol;
|
||||||
|
|
||||||
use Friendica\Database\DBM;
|
use Friendica\Database\DBM;
|
||||||
use Friendica\Core\System;
|
use Friendica\Core\System;
|
||||||
|
use dba;
|
||||||
|
|
||||||
require_once("include/html2bbcode.php");
|
require_once("include/html2bbcode.php");
|
||||||
require_once("include/items.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
|
* @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
|
* @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();
|
$a = get_app();
|
||||||
|
|
||||||
|
@ -236,10 +249,11 @@ function feed_import($xml,$importer,&$contact, &$hub, $simulate = false) {
|
||||||
$item["parent-uri"] = $item["uri"];
|
$item["parent-uri"] = $item["uri"];
|
||||||
|
|
||||||
if (!$simulate) {
|
if (!$simulate) {
|
||||||
$r = q("SELECT `id` FROM `item` WHERE `uid` = %d AND `uri` = '%s' AND `network` IN ('%s', '%s')",
|
$condition = ["`uid` = ? AND `uri` = ? AND `network` IN (?, ?)",
|
||||||
intval($importer["uid"]), dbesc($item["uri"]), dbesc(NETWORK_FEED), dbesc(NETWORK_DFRN));
|
$importer["uid"], $item["uri"], NETWORK_FEED, NETWORK_DFRN];
|
||||||
if (DBM::is_result($r)) {
|
$previous = dba::select('item', ['id'], $condition, ['limit' => 1]);
|
||||||
logger("Item with uri ".$item["uri"]." for user ".$importer["uid"]." already existed under id ".$r[0]["id"], LOGGER_DEBUG);
|
if (DBM::is_result($previous)) {
|
||||||
|
logger("Item with uri ".$item["uri"]." for user ".$importer["uid"]." already existed under id ".$previous["id"], LOGGER_DEBUG);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -436,3 +450,4 @@ function feed_import($xml,$importer,&$contact, &$hub, $simulate = false) {
|
||||||
return array("header" => $author, "items" => $items);
|
return array("header" => $author, "items" => $items);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue