- $author["author-link"] = $xpath->evaluate('/rdf:RDF/rss:channel/rss:link/text()')->item(0)->nodeValue;
- $author["author-name"] = $xpath->evaluate('/rdf:RDF/rss:channel/rss:title/text()')->item(0)->nodeValue;
+ $author["author-link"] = XML::getFirstNodeValue($xpath, '/rdf:RDF/rss:channel/rss:link/text()');
+ $author["author-name"] = XML::getFirstNodeValue($xpath, '/rdf:RDF/rss:channel/rss:title/text()');
- if ($author["author-name"] == "") {
- $author["author-name"] = $xpath->evaluate('/rdf:RDF/rss:channel/rss:description/text()')->item(0)->nodeValue;
+ if (empty($author["author-name"])) {
+ $author["author-name"] = XML::getFirstNodeValue($xpath, '/rdf:RDF/rss:channel/rss:description/text()');
if (is_object($alternate)) {
foreach ($alternate AS $attribute) {
if ($attribute->name == "href") {
if (is_object($alternate)) {
foreach ($alternate AS $attribute) {
if ($attribute->name == "href") {
- if ($author["author-link"] == "") {
- $author["author-link"] = $author["author-id"];
- }
- if ($author["author-link"] == "") {
- $self = $xpath->query("atom:link[@rel='self']")->item(0)->attributes;
+ if (empty($author["author-link"])) {
+ $self = XML::getFirstAttributes($xpath, "atom:link[@rel='self']");
- if ($author["author-link"] == "") {
- $author["author-link"] = $xpath->evaluate('/atom:feed/atom:id/text()')->item(0)->nodeValue;
+ if (empty($author["author-link"])) {
+ $author["author-link"] = XML::getFirstNodeValue($xpath, '/atom:feed/atom:id/text()');
- if ($author["author-name"] == "") {
- $author["author-name"] = $xpath->evaluate('/atom:feed/atom:subtitle/text()')->item(0)->nodeValue;
+ if (empty($author["author-name"])) {
+ $author["author-name"] = XML::getFirstNodeValue($xpath, '/atom:feed/atom:subtitle/text()');
- if ($author["author-name"] == "") {
- $author["author-name"] = $xpath->evaluate('/atom:feed/atom:author/atom:name/text()')->item(0)->nodeValue;
+ if (empty($author["author-name"])) {
+ $author["author-name"] = XML::getFirstNodeValue($xpath, '/atom:feed/atom:author/atom:name/text()');
if (is_object($avatar)) {
foreach ($avatar AS $attribute) {
if ($attribute->name == "href") {
if (is_object($avatar)) {
foreach ($avatar AS $attribute) {
if ($attribute->name == "href") {
- $author["author-name"] = $xpath->evaluate('/rss/channel/title/text()')->item(0)->nodeValue;
- $author["author-avatar"] = $xpath->evaluate('/rss/channel/image/url/text()')->item(0)->nodeValue;
+ $author["author-name"] = XML::getFirstNodeValue($xpath, '/rss/channel/title/text()');
+ $author["author-avatar"] = XML::getFirstNodeValue($xpath, '/rss/channel/image/url/text()');
- if ($author["author-name"] == "") {
- $author["author-name"] = $xpath->evaluate('/rss/channel/copyright/text()')->item(0)->nodeValue;
+ if (empty($author["author-name"])) {
+ $author["author-name"] = XML::getFirstNodeValue($xpath, '/rss/channel/copyright/text()');
- if ($author["author-name"] == "") {
- $author["author-name"] = $xpath->evaluate('/rss/channel/description/text()')->item(0)->nodeValue;
+ if (empty($author["author-name"])) {
+ $author["author-name"] = XML::getFirstNodeValue($xpath, '/rss/channel/description/text()');
- if ($item["plink"] == "") {
- $item["plink"] = $xpath->evaluate('link/text()', $entry)->item(0)->nodeValue;
+ if (empty($item["plink"])) {
+ $item["plink"] = XML::getFirstNodeValue($xpath, 'link/text()', $entry);
- if ($item["plink"] == "") {
- $item["plink"] = $xpath->evaluate('rss:link/text()', $entry)->item(0)->nodeValue;
+ if (empty($item["plink"])) {
+ $item["plink"] = XML::getFirstNodeValue($xpath, 'rss:link/text()', $entry);
- if ($item["uri"] == "") {
- $item["uri"] = $xpath->evaluate('guid/text()', $entry)->item(0)->nodeValue;
+ if (empty($item["uri"])) {
+ $item["uri"] = XML::getFirstNodeValue($xpath, 'guid/text()', $entry);
if (!$simulate) {
$condition = ["`uid` = ? AND `uri` = ? AND `network` IN (?, ?)",
$importer["uid"], $item["uri"], NETWORK_FEED, NETWORK_DFRN];
if (!$simulate) {
$condition = ["`uid` = ? AND `uri` = ? AND `network` IN (?, ?)",
$importer["uid"], $item["uri"], NETWORK_FEED, NETWORK_DFRN];
- $previous = dba::selectFirst('item', ['id'], $condition);
- if (DBM::is_result($previous)) {
+ $previous = Item::selectFirst(['id'], $condition);
+ if (DBA::isResult($previous)) {
- if ($item["title"] == "") {
- $item["title"] = $xpath->evaluate('title/text()', $entry)->item(0)->nodeValue;
+ if (empty($item["title"])) {
+ $item["title"] = XML::getFirstNodeValue($xpath, 'title/text()', $entry);
- if ($item["title"] == "") {
- $item["title"] = $xpath->evaluate('rss:title/text()', $entry)->item(0)->nodeValue;
+ if (empty($item["title"])) {
+ $item["title"] = XML::getFirstNodeValue($xpath, 'rss:title/text()', $entry);
- if ($published == "") {
- $published = $xpath->query('pubDate/text()', $entry)->item(0)->nodeValue;
+ if (empty($published)) {
+ $published = XML::getFirstNodeValue($xpath, 'pubDate/text()', $entry);
- if ($published == "") {
- $published = $xpath->query('dc:date/text()', $entry)->item(0)->nodeValue;
+ if (empty($published)) {
+ $published = XML::getFirstNodeValue($xpath, 'dc:date/text()', $entry);