/**
* @file mod/salmon.php
*/
+
use Friendica\App;
use Friendica\Core\Logger;
use Friendica\Core\PConfig;
use Friendica\Core\Protocol;
-use Friendica\Core\System;
use Friendica\Database\DBA;
use Friendica\Model\Contact;
-use Friendica\Protocol\Activity\Namespaces;
+use Friendica\Protocol\Activity\ANamespace;
use Friendica\Protocol\OStatus;
use Friendica\Protocol\Salmon;
use Friendica\Util\Crypto;
-use Friendica\Util\Strings;
use Friendica\Util\Network;
+use Friendica\Util\Strings;
function salmon_post(App $a, $xml = '') {
// parse the xml
- $dom = simplexml_load_string($xml,'SimpleXMLElement',0, Namespaces::SALMON_ME);
+ $dom = simplexml_load_string($xml,'SimpleXMLElement',0, ANamespace::SALMON_ME);
$base = null;
use Friendica\Core\L10n;
use Friendica\Core\Logger;
use Friendica\Core\Protocol;
-use Friendica\Core\System;
use Friendica\Core\Session;
+use Friendica\Core\System;
use Friendica\Core\Worker;
use Friendica\Database\DBA;
use Friendica\Network\Probe;
use Friendica\Protocol\DFRN;
use Friendica\Protocol\Diaspora;
use Friendica\Protocol\OStatus;
-use Friendica\Protocol\PortableContact;
use Friendica\Protocol\Salmon;
use Friendica\Util\DateTimeFormat;
use Friendica\Util\Network;
} elseif (in_array($protocol, [Protocol::OSTATUS, Protocol::DFRN])) {
// create an unfollow slap
$item = [];
- $item['verb'] = Activity\Namespaces::OSTATUS . "/unfollow";
+ $item['verb'] = Activity\ANamespace::OSTATUS . "/unfollow";
$item['follow'] = $contact["url"];
$item['body'] = '';
$item['title'] = '';
use Friendica\BaseModule;
use Friendica\Core\Hook;
-use Friendica\Database\DBA;
use Friendica\Core\Renderer;
-use Friendica\Core\System;
-use Friendica\Model\User;
+use Friendica\Database\DBA;
use Friendica\Model\Photo;
-use Friendica\Protocol\Activity\Namespaces;
+use Friendica\Model\User;
+use Friendica\Protocol\Activity\ANamespace;
use Friendica\Protocol\Salmon;
use Friendica\Util\Strings;
],
'links' => [
[
- 'rel' => Namespaces::DFRN ,
+ 'rel' => ANamespace::DFRN ,
'href' => $owner['url'],
],
[
- 'rel' => Namespaces::FEED,
+ 'rel' => ANamespace::FEED,
'type' => 'application/atom+xml',
'href' => $owner['poll'],
],
'href' => $baseURL . '/hcard/' . $owner['nickname'],
],
[
- 'rel' => Namespaces::POCO,
+ 'rel' => ANamespace::POCO,
'href' => $owner['poco'],
],
[
use Friendica\Core\System;
use Friendica\Database\DBA;
use Friendica\Model\Profile;
-use Friendica\Protocol\Activity\Namespaces;
+use Friendica\Protocol\Activity\ANamespace;
use Friendica\Protocol\ActivityPub;
use Friendica\Protocol\Email;
use Friendica\Protocol\Feed;
use Friendica\Util\Crypto;
-use Friendica\Util\DateTimeFormat;
use Friendica\Util\Network;
use Friendica\Util\Strings;
use Friendica\Util\XML;
Logger::log('webfingerDfrn: '.$webbie.':'.print_r($links, true), Logger::DATA);
if (!empty($links) && is_array($links)) {
foreach ($links as $link) {
- if ($link['@attributes']['rel'] === Namespaces::DFRN) {
+ if ($link['@attributes']['rel'] === ANamespace::DFRN) {
$profile_link = $link['@attributes']['href'];
}
- if (($link['@attributes']['rel'] === Namespaces::OSTATUSSUB) && ($profile_link == "")) {
+ if (($link['@attributes']['rel'] === ANamespace::OSTATUSSUB) && ($profile_link == "")) {
$profile_link = 'stat:'.$link['@attributes']['template'];
}
if ($link['@attributes']['rel'] === 'http://microformats.org/profile/hcard') {
$has_key = false;
foreach ($webfinger['links'] as $link) {
- if ($link['rel'] == Namespaces::OSTATUSSUB) {
+ if ($link['rel'] == ANamespace::OSTATUSSUB) {
$is_ostatus = true;
}
if ($link['rel'] == 'magic-public-key') {
// The array is reversed to take into account the order of preference for same-rel links
// See: https://tools.ietf.org/html/rfc7033#section-4.4.4
foreach (array_reverse($webfinger["links"]) as $link) {
- if (($link["rel"] == Namespaces::DFRN) && !empty($link["href"])) {
+ if (($link["rel"] == ANamespace::DFRN) && !empty($link["href"])) {
$data["network"] = Protocol::DFRN;
- } elseif (($link["rel"] == Namespaces::FEED) && !empty($link["href"])) {
+ } elseif (($link["rel"] == ANamespace::FEED) && !empty($link["href"])) {
$data["poll"] = $link["href"];
} elseif (($link["rel"] == "http://webfinger.net/rel/profile-page") && (($link["type"] ?? "") == "text/html") && !empty($link["href"])) {
$data["url"] = $link["href"];
} elseif (($link["rel"] == "http://microformats.org/profile/hcard") && !empty($link["href"])) {
$hcard_url = $link["href"];
- } elseif (($link["rel"] == Namespaces::POCO) && !empty($link["href"])) {
+ } elseif (($link["rel"] == ANamespace::POCO) && !empty($link["href"])) {
$data["poco"] = $link["href"];
} elseif (($link["rel"] == "http://webfinger.net/rel/avatar") && !empty($link["href"])) {
$data["photo"] = $link["href"];
$data["guid"] = $link["href"];
} elseif (($link["rel"] == "http://webfinger.net/rel/profile-page") && (($link["type"] ?? "") == "text/html") && !empty($link["href"])) {
$data["url"] = $link["href"];
- } elseif (($link["rel"] == Namespaces::FEED) && !empty($link["href"])) {
+ } elseif (($link["rel"] == ANamespace::FEED) && !empty($link["href"])) {
$data["poll"] = $link["href"];
- } elseif (($link["rel"] == Namespaces::POCO) && !empty($link["href"])) {
+ } elseif (($link["rel"] == ANamespace::POCO) && !empty($link["href"])) {
$data["poco"] = $link["href"];
} elseif (($link["rel"] == "salmon") && !empty($link["href"])) {
$data["notify"] = $link["href"];
$data["url"] = $link["href"];
} elseif (($link["rel"] == "salmon") && !empty($link["href"])) {
$data["notify"] = $link["href"];
- } elseif (($link["rel"] == Namespaces::FEED) && !empty($link["href"])) {
+ } elseif (($link["rel"] == ANamespace::FEED) && !empty($link["href"])) {
$data["poll"] = $link["href"];
} elseif (($link["rel"] == "magic-public-key") && !empty($link["href"])) {
$pubkey = $link["href"];
namespace Friendica\Protocol;
-use Friendica\Protocol\Activity\Namespaces;
+use Friendica\Protocol\Activity\ANamespace;
/**
- * Base class for the Activity constants and match method
+ * Base class for the Activity constants and particular method
*/
final class Activity
{
- const LIKE = Namespaces::ACTIVITY_SCHEMA . 'like';
+ const LIKE = ANamespace::ACTIVITY_SCHEMA . 'like';
- const DISLIKE = Namespaces::DFRN . '/dislike';
- const ATTEND = Namespaces::ZOT . '/activity/attendyes';
- const ATTENDNO = Namespaces::ZOT . '/activity/attendno';
- const ATTENDMAYBE = Namespaces::ZOT . '/activity/attendmaybe';
- const OBJ_HEART = Namespaces::DFRN . '/heart';
+ const DISLIKE = ANamespace::DFRN . '/dislike';
+ const ATTEND = ANamespace::ZOT . '/activity/attendyes';
+ const ATTENDNO = ANamespace::ZOT . '/activity/attendno';
+ const ATTENDMAYBE = ANamespace::ZOT . '/activity/attendmaybe';
+ const OBJ_HEART = ANamespace::DFRN . '/heart';
- const FRIEND = Namespaces::ACTIVITY_SCHEMA . 'make-friend';
- const REQ_FRIEND = Namespaces::ACTIVITY_SCHEMA . 'request-friend';
- const UNFRIEND = Namespaces::ACTIVITY_SCHEMA . 'remove-friend';
- const FOLLOW = Namespaces::ACTIVITY_SCHEMA . 'follow';
- const UNFOLLOW = Namespaces::ACTIVITY_SCHEMA . 'stop-following';
- const JOIN = Namespaces::ACTIVITY_SCHEMA . 'join';
- const POST = Namespaces::ACTIVITY_SCHEMA . 'post';
- const UPDATE = Namespaces::ACTIVITY_SCHEMA . 'update';
- const TAG = Namespaces::ACTIVITY_SCHEMA . 'tag';
- const FAVORITE = Namespaces::ACTIVITY_SCHEMA . 'favorite';
- const UNFAVORITE = Namespaces::ACTIVITY_SCHEMA . 'unfavorite';
- const SHARE = Namespaces::ACTIVITY_SCHEMA . 'share';
- const DELETE = Namespaces::ACTIVITY_SCHEMA . 'delete';
- const ANNOUNCE = Namespaces::ACTIVITY2 . 'Announce';
+ const FRIEND = ANamespace::ACTIVITY_SCHEMA . 'make-friend';
+ const REQ_FRIEND = ANamespace::ACTIVITY_SCHEMA . 'request-friend';
+ const UNFRIEND = ANamespace::ACTIVITY_SCHEMA . 'remove-friend';
+ const FOLLOW = ANamespace::ACTIVITY_SCHEMA . 'follow';
+ const UNFOLLOW = ANamespace::ACTIVITY_SCHEMA . 'stop-following';
+ const JOIN = ANamespace::ACTIVITY_SCHEMA . 'join';
+ const POST = ANamespace::ACTIVITY_SCHEMA . 'post';
+ const UPDATE = ANamespace::ACTIVITY_SCHEMA . 'update';
+ const TAG = ANamespace::ACTIVITY_SCHEMA . 'tag';
+ const FAVORITE = ANamespace::ACTIVITY_SCHEMA . 'favorite';
+ const UNFAVORITE = ANamespace::ACTIVITY_SCHEMA . 'unfavorite';
+ const SHARE = ANamespace::ACTIVITY_SCHEMA . 'share';
+ const DELETE = ANamespace::ACTIVITY_SCHEMA . 'delete';
+ const ANNOUNCE = ANamespace::ACTIVITY2 . 'Announce';
- const POKE = Namespaces::ZOT . '/activity/poke';
+ const POKE = ANamespace::ZOT . '/activity/poke';
- const OBJ_BOOKMARK = Namespaces::ACTIVITY_SCHEMA . 'bookmark';
- const OBJ_COMMENT = Namespaces::ACTIVITY_SCHEMA . 'comment';
- const OBJ_NOTE = Namespaces::ACTIVITY_SCHEMA . 'note';
- const OBJ_PERSON = Namespaces::ACTIVITY_SCHEMA . 'person';
- const OBJ_IMAGE = Namespaces::ACTIVITY_SCHEMA . 'image';
- const OBJ_PHOTO = Namespaces::ACTIVITY_SCHEMA . 'photo';
- const OBJ_VIDEO = Namespaces::ACTIVITY_SCHEMA . 'video';
- const OBJ_P_PHOTO = Namespaces::ACTIVITY_SCHEMA . 'profile-photo';
- const OBJ_ALBUM = Namespaces::ACTIVITY_SCHEMA . 'photo-album';
- const OBJ_EVENT = Namespaces::ACTIVITY_SCHEMA . 'event';
- const OBJ_GROUP = Namespaces::ACTIVITY_SCHEMA . 'group';
- const OBJ_TAGTERM = Namespaces::DFRN . '/tagterm';
- const OBJ_PROFILE = Namespaces::DFRN . '/profile';
+ const OBJ_BOOKMARK = ANamespace::ACTIVITY_SCHEMA . 'bookmark';
+ const OBJ_COMMENT = ANamespace::ACTIVITY_SCHEMA . 'comment';
+ const OBJ_NOTE = ANamespace::ACTIVITY_SCHEMA . 'note';
+ const OBJ_PERSON = ANamespace::ACTIVITY_SCHEMA . 'person';
+ const OBJ_IMAGE = ANamespace::ACTIVITY_SCHEMA . 'image';
+ const OBJ_PHOTO = ANamespace::ACTIVITY_SCHEMA . 'photo';
+ const OBJ_VIDEO = ANamespace::ACTIVITY_SCHEMA . 'video';
+ const OBJ_P_PHOTO = ANamespace::ACTIVITY_SCHEMA . 'profile-photo';
+ const OBJ_ALBUM = ANamespace::ACTIVITY_SCHEMA . 'photo-album';
+ const OBJ_EVENT = ANamespace::ACTIVITY_SCHEMA . 'event';
+ const OBJ_GROUP = ANamespace::ACTIVITY_SCHEMA . 'group';
+ const OBJ_TAGTERM = ANamespace::DFRN . '/tagterm';
+ const OBJ_PROFILE = ANamespace::DFRN . '/profile';
const OBJ_QUESTION = 'http://activityschema.org/object/question';
{
return (($haystack === $needle) ||
((basename($needle) === $haystack) &&
- strstr($needle, Namespaces::ACTIVITY_SCHEMA)));
+ strstr($needle, ANamespace::ACTIVITY_SCHEMA)));
}
}
--- /dev/null
+<?php
+
+namespace Friendica\Protocol\Activity;
+
+/**
+ * Activity namespaces constants
+ */
+final class ANamespace
+{
+ const ZOT = 'http://purl.org/zot';
+ const DFRN = 'http://purl.org/macgirvin/dfrn/1.0';
+ const THREAD = 'http://purl.org/syndication/thread/1.0';
+ const TOMB = 'http://purl.org/atompub/tombstones/1.0';
+ const ACTIVITY2 = 'https://www.w3.org/ns/activitystreams#';
+ const ACTIVITY = 'http://activitystrea.ms/spec/1.0/';
+ const ACTIVITY_SCHEMA = 'http://activitystrea.ms/schema/1.0/';
+ const MEDIA = 'http://purl.org/syndication/atommedia';
+ const SALMON_ME = 'http://salmon-protocol.org/ns/magic-env';
+ const OSTATUSSUB = 'http://ostatus.org/schema/1.0/subscribe';
+ const GEORSS = 'http://www.georss.org/georss';
+ const POCO = 'http://portablecontacts.net/spec/1.0';
+ const FEED = 'http://schemas.google.com/g/2010#updates-from';
+ const OSTATUS = 'http://ostatus.org/schema/1.0';
+ const STATUSNET = 'http://status.net/schema/api/1/';
+ const ATOM1 = 'http://www.w3.org/2005/Atom';
+ const MASTODON = 'http://mastodon.social/schema/1.0';
+}
+++ /dev/null
-<?php
-
-namespace Friendica\Protocol\Activity;
-
-/**
- * Activity namespaces constants
- */
-final class Namespaces
-{
- const ZOT = 'http://purl.org/zot';
- const DFRN = 'http://purl.org/macgirvin/dfrn/1.0';
- const THREAD = 'http://purl.org/syndication/thread/1.0';
- const TOMB = 'http://purl.org/atompub/tombstones/1.0';
- const ACTIVITY2 = 'https://www.w3.org/ns/activitystreams#';
- const ACTIVITY = 'http://activitystrea.ms/spec/1.0/';
- const ACTIVITY_SCHEMA = 'http://activitystrea.ms/schema/1.0/';
- const MEDIA = 'http://purl.org/syndication/atommedia';
- const SALMON_ME = 'http://salmon-protocol.org/ns/magic-env';
- const OSTATUSSUB = 'http://ostatus.org/schema/1.0/subscribe';
- const GEORSS = 'http://www.georss.org/georss';
- const POCO = 'http://portablecontacts.net/spec/1.0';
- const FEED = 'http://schemas.google.com/g/2010#updates-from';
- const OSTATUS = 'http://ostatus.org/schema/1.0';
- const STATUSNET = 'http://status.net/schema/api/1/';
- const ATOM1 = 'http://www.w3.org/2005/Atom';
- const MASTODON = 'http://mastodon.social/schema/1.0';
-}
use DOMDocument;
use DOMXPath;
-use Friendica\App;
use Friendica\App\BaseURL;
use Friendica\BaseObject;
use Friendica\Content\OEmbed;
use Friendica\Core\Logger;
use Friendica\Core\Protocol;
use Friendica\Core\System;
-use Friendica\Core\Session;
use Friendica\Database\DBA;
use Friendica\Model\Contact;
use Friendica\Model\Conversation;
use Friendica\Model\User;
use Friendica\Network\Probe;
use Friendica\Object\Image;
-use Friendica\Protocol\Activity\Namespaces;
+use Friendica\Protocol\Activity\ANamespace;
use Friendica\Util\Crypto;
use Friendica\Util\DateTimeFormat;
use Friendica\Util\Network;
$type = 'html';
if ($conversation) {
- $root = $doc->createElementNS(Namespaces::ATOM1, 'feed');
+ $root = $doc->createElementNS(ANamespace::ATOM1, 'feed');
$doc->appendChild($root);
- $root->setAttribute("xmlns:thr", Namespaces::THREAD);
- $root->setAttribute("xmlns:at", Namespaces::TOMB);
- $root->setAttribute("xmlns:media", Namespaces::MEDIA);
- $root->setAttribute("xmlns:dfrn", Namespaces::DFRN);
- $root->setAttribute("xmlns:activity", Namespaces::ACTIVITY);
- $root->setAttribute("xmlns:georss", Namespaces::GEORSS);
- $root->setAttribute("xmlns:poco", Namespaces::POCO);
- $root->setAttribute("xmlns:ostatus", Namespaces::OSTATUS);
- $root->setAttribute("xmlns:statusnet", Namespaces::STATUSNET);
+ $root->setAttribute("xmlns:thr", ANamespace::THREAD);
+ $root->setAttribute("xmlns:at", ANamespace::TOMB);
+ $root->setAttribute("xmlns:media", ANamespace::MEDIA);
+ $root->setAttribute("xmlns:dfrn", ANamespace::DFRN);
+ $root->setAttribute("xmlns:activity", ANamespace::ACTIVITY);
+ $root->setAttribute("xmlns:georss", ANamespace::GEORSS);
+ $root->setAttribute("xmlns:poco", ANamespace::POCO);
+ $root->setAttribute("xmlns:ostatus", ANamespace::OSTATUS);
+ $root->setAttribute("xmlns:statusnet", ANamespace::STATUSNET);
//$root = self::addHeader($doc, $owner, "dfrn:owner", "", false);
$alternatelink = $owner['url'];
}
- $root = $doc->createElementNS(Namespaces::ATOM1, 'feed');
+ $root = $doc->createElementNS(ANamespace::ATOM1, 'feed');
$doc->appendChild($root);
- $root->setAttribute("xmlns:thr", Namespaces::THREAD);
- $root->setAttribute("xmlns:at", Namespaces::TOMB);
- $root->setAttribute("xmlns:media", Namespaces::MEDIA);
- $root->setAttribute("xmlns:dfrn", Namespaces::DFRN);
- $root->setAttribute("xmlns:activity", Namespaces::ACTIVITY);
- $root->setAttribute("xmlns:georss", Namespaces::GEORSS);
- $root->setAttribute("xmlns:poco", Namespaces::POCO);
- $root->setAttribute("xmlns:ostatus", Namespaces::OSTATUS);
- $root->setAttribute("xmlns:statusnet", Namespaces::STATUSNET);
+ $root->setAttribute("xmlns:thr", ANamespace::THREAD);
+ $root->setAttribute("xmlns:at", ANamespace::TOMB);
+ $root->setAttribute("xmlns:media", ANamespace::MEDIA);
+ $root->setAttribute("xmlns:dfrn", ANamespace::DFRN);
+ $root->setAttribute("xmlns:activity", ANamespace::ACTIVITY);
+ $root->setAttribute("xmlns:georss", ANamespace::GEORSS);
+ $root->setAttribute("xmlns:poco", ANamespace::POCO);
+ $root->setAttribute("xmlns:ostatus", ANamespace::OSTATUS);
+ $root->setAttribute("xmlns:statusnet", ANamespace::STATUSNET);
XML::addElement($doc, $root, "id", System::baseUrl()."/profile/".$owner["nick"]);
XML::addElement($doc, $root, "title", $owner["name"]);
if (!$single) {
$entry = $doc->createElement("entry");
} else {
- $entry = $doc->createElementNS(Namespaces::ATOM1, 'entry');
+ $entry = $doc->createElementNS(ANamespace::ATOM1, 'entry');
$doc->appendChild($entry);
- $entry->setAttribute("xmlns:thr", Namespaces::THREAD);
- $entry->setAttribute("xmlns:at", Namespaces::TOMB);
- $entry->setAttribute("xmlns:media", Namespaces::MEDIA);
- $entry->setAttribute("xmlns:dfrn", Namespaces::DFRN);
- $entry->setAttribute("xmlns:activity", Namespaces::ACTIVITY);
- $entry->setAttribute("xmlns:georss", Namespaces::GEORSS);
- $entry->setAttribute("xmlns:poco", Namespaces::POCO);
- $entry->setAttribute("xmlns:ostatus", Namespaces::OSTATUS);
- $entry->setAttribute("xmlns:statusnet", Namespaces::STATUSNET);
+ $entry->setAttribute("xmlns:thr", ANamespace::THREAD);
+ $entry->setAttribute("xmlns:at", ANamespace::TOMB);
+ $entry->setAttribute("xmlns:media", ANamespace::MEDIA);
+ $entry->setAttribute("xmlns:dfrn", ANamespace::DFRN);
+ $entry->setAttribute("xmlns:activity", ANamespace::ACTIVITY);
+ $entry->setAttribute("xmlns:georss", ANamespace::GEORSS);
+ $entry->setAttribute("xmlns:poco", ANamespace::POCO);
+ $entry->setAttribute("xmlns:ostatus", ANamespace::OSTATUS);
+ $entry->setAttribute("xmlns:statusnet", ANamespace::STATUSNET);
}
if ($item['private']) {
$obj_doc = new DOMDocument("1.0", "utf-8");
$obj_doc->formatOutput = true;
- $obj_element = $obj_doc->createElementNS( Namespaces::ATOM1, $element);
+ $obj_element = $obj_doc->createElementNS( ANamespace::ATOM1, $element);
$activity_type = $xpath->query("activity:object-type/text()", $activity)->item(0)->nodeValue;
XML::addElement($obj_doc, $obj_element, "type", $activity_type);
@$doc->loadXML($xml);
$xpath = new DOMXPath($doc);
- $xpath->registerNamespace("atom", Namespaces::ATOM1);
- $xpath->registerNamespace("thr", Namespaces::THREAD);
- $xpath->registerNamespace("at", Namespaces::TOMB);
- $xpath->registerNamespace("media", Namespaces::MEDIA);
- $xpath->registerNamespace("dfrn", Namespaces::DFRN);
- $xpath->registerNamespace("activity", Namespaces::ACTIVITY);
- $xpath->registerNamespace("georss", Namespaces::GEORSS);
- $xpath->registerNamespace("poco", Namespaces::POCO);
- $xpath->registerNamespace("ostatus", Namespaces::OSTATUS);
- $xpath->registerNamespace("statusnet", Namespaces::STATUSNET);
+ $xpath->registerNamespace("atom", ANamespace::ATOM1);
+ $xpath->registerNamespace("thr", ANamespace::THREAD);
+ $xpath->registerNamespace("at", ANamespace::TOMB);
+ $xpath->registerNamespace("media", ANamespace::MEDIA);
+ $xpath->registerNamespace("dfrn", ANamespace::DFRN);
+ $xpath->registerNamespace("activity", ANamespace::ACTIVITY);
+ $xpath->registerNamespace("georss", ANamespace::GEORSS);
+ $xpath->registerNamespace("poco", ANamespace::POCO);
+ $xpath->registerNamespace("ostatus", ANamespace::OSTATUS);
+ $xpath->registerNamespace("statusnet", ANamespace::STATUSNET);
$header = [];
$header["uid"] = $importer["importer_uid"];
use Friendica\Model\Profile;
use Friendica\Model\User;
use Friendica\Network\Probe;
-use Friendica\Protocol\Activity\Namespaces;
+use Friendica\Protocol\Activity\ANamespace;
use Friendica\Util\Crypto;
use Friendica\Util\DateTimeFormat;
use Friendica\Util\Map;
}
}
- $base = $basedom->children(Namespaces::SALMON_ME);
+ $base = $basedom->children(ANamespace::SALMON_ME);
// Not sure if this cleaning is needed
$data = str_replace([" ", "\t", "\r", "\n"], ["", "", "", ""], $base->data);
$author_link = str_replace('acct:', '', $idom->author_id);
}
- $dom = $basedom->children(Namespaces::SALMON_ME);
+ $dom = $basedom->children(ANamespace::SALMON_ME);
// figure out where in the DOM tree our data is hiding
use Friendica\Core\System;
use Friendica\Database\DBA;
use Friendica\Model\Item;
-use Friendica\Protocol\Activity\Namespaces;
+use Friendica\Protocol\Activity\ANamespace;
use Friendica\Util\Network;
use Friendica\Util\XML;
$doc = new DOMDocument();
@$doc->loadXML(trim($xml));
$xpath = new DOMXPath($doc);
- $xpath->registerNamespace('atom', Namespaces::ATOM1);
+ $xpath->registerNamespace('atom', ANamespace::ATOM1);
$xpath->registerNamespace('dc', "http://purl.org/dc/elements/1.1/");
$xpath->registerNamespace('content', "http://purl.org/rss/1.0/modules/content/");
$xpath->registerNamespace('rdf', "http://www.w3.org/1999/02/22-rdf-syntax-ns#");
$xpath->registerNamespace('rss', "http://purl.org/rss/1.0/");
$xpath->registerNamespace('media', "http://search.yahoo.com/mrss/");
- $xpath->registerNamespace('poco', Namespaces::POCO);
+ $xpath->registerNamespace('poco', ANamespace::POCO);
$author = [];
$entries = null;
use Friendica\Content\Text\HTML;
use Friendica\Core\Cache;
use Friendica\Core\Config;
-use Friendica\Core\PConfig;
use Friendica\Core\L10n;
-use Friendica\Core\Logger;
use Friendica\Core\Lock;
+use Friendica\Core\Logger;
+use Friendica\Core\PConfig;
use Friendica\Core\Protocol;
use Friendica\Core\System;
use Friendica\Database\DBA;
+use Friendica\Model\APContact;
use Friendica\Model\Contact;
use Friendica\Model\Conversation;
use Friendica\Model\GContact;
-use Friendica\Model\APContact;
use Friendica\Model\Item;
use Friendica\Model\User;
use Friendica\Network\Probe;
use Friendica\Object\Image;
-use Friendica\Protocol\Activity\Namespaces;
+use Friendica\Protocol\Activity\ANamespace;
use Friendica\Util\DateTimeFormat;
use Friendica\Util\Network;
use Friendica\Util\Proxy as ProxyUtils;
@$doc->loadXML($xml);
$xpath = new DOMXPath($doc);
- $xpath->registerNamespace('atom', Namespaces::ATOM1);
- $xpath->registerNamespace('thr', Namespaces::THREAD);
- $xpath->registerNamespace('georss', Namespaces::GEORSS);
- $xpath->registerNamespace('activity', Namespaces::ACTIVITY);
- $xpath->registerNamespace('media', Namespaces::MEDIA);
- $xpath->registerNamespace('poco', Namespaces::POCO);
- $xpath->registerNamespace('ostatus', Namespaces::OSTATUS);
- $xpath->registerNamespace('statusnet', Namespaces::STATUSNET);
+ $xpath->registerNamespace('atom', ANamespace::ATOM1);
+ $xpath->registerNamespace('thr', ANamespace::THREAD);
+ $xpath->registerNamespace('georss', ANamespace::GEORSS);
+ $xpath->registerNamespace('activity', ANamespace::ACTIVITY);
+ $xpath->registerNamespace('media', ANamespace::MEDIA);
+ $xpath->registerNamespace('poco', ANamespace::POCO);
+ $xpath->registerNamespace('ostatus', ANamespace::OSTATUS);
+ $xpath->registerNamespace('statusnet', ANamespace::STATUSNET);
$contact = ["id" => 0];
@$doc->loadXML($xml);
$xpath = new DOMXPath($doc);
- $xpath->registerNamespace('atom', Namespaces::ATOM1);
- $xpath->registerNamespace('thr', Namespaces::THREAD);
- $xpath->registerNamespace('georss', Namespaces::GEORSS);
- $xpath->registerNamespace('activity', Namespaces::ACTIVITY);
- $xpath->registerNamespace('media', Namespaces::MEDIA);
- $xpath->registerNamespace('poco', Namespaces::POCO);
- $xpath->registerNamespace('ostatus', Namespaces::OSTATUS);
- $xpath->registerNamespace('statusnet', Namespaces::STATUSNET);
+ $xpath->registerNamespace('atom', ANamespace::ATOM1);
+ $xpath->registerNamespace('thr', ANamespace::THREAD);
+ $xpath->registerNamespace('georss', ANamespace::GEORSS);
+ $xpath->registerNamespace('activity', ANamespace::ACTIVITY);
+ $xpath->registerNamespace('media', ANamespace::MEDIA);
+ $xpath->registerNamespace('poco', ANamespace::POCO);
+ $xpath->registerNamespace('ostatus', ANamespace::OSTATUS);
+ $xpath->registerNamespace('statusnet', ANamespace::STATUSNET);
$hub = "";
$hub_items = $xpath->query("/atom:feed/atom:link[@rel='hub']")->item(0);
continue;
}
- if (in_array($item["verb"], [Namespaces::OSTATUS . "/unfavorite", Activity::UNFAVORITE])) {
+ if (in_array($item["verb"], [ANamespace::OSTATUS . "/unfavorite", Activity::UNFAVORITE])) {
// Ignore "Unfavorite" message
Logger::log("Ignore unfavorite message ".print_r($item, true), Logger::DEBUG);
continue;
continue;
}
- if ($item["verb"] == Namespaces::OSTATUS."/unfollow") {
+ if ($item["verb"] == ANamespace::OSTATUS . "/unfollow") {
$dummy = null;
Contact::removeFollower($importer, $contact, $item, $dummy);
continue;
@$doc->loadXML($xml);
$xpath = new DOMXPath($doc);
- $xpath->registerNamespace('atom', Namespaces::ATOM1);
- $xpath->registerNamespace('thr', Namespaces::THREAD);
- $xpath->registerNamespace('ostatus', Namespaces::OSTATUS);
+ $xpath->registerNamespace('atom', ANamespace::ATOM1);
+ $xpath->registerNamespace('thr', ANamespace::THREAD);
+ $xpath->registerNamespace('ostatus', ANamespace::OSTATUS);
$entries = $xpath->query('/atom:feed/atom:entry');
*/
private static function addHeader(DOMDocument $doc, array $owner, $filter, $feed_mode = false)
{
- $root = $doc->createElementNS(Namespaces::ATOM1, 'feed');
+ $root = $doc->createElementNS(ANamespace::ATOM1, 'feed');
$doc->appendChild($root);
- $root->setAttribute("xmlns:thr", Namespaces::THREAD);
- $root->setAttribute("xmlns:georss", Namespaces::GEORSS);
- $root->setAttribute("xmlns:activity", Namespaces::ACTIVITY);
- $root->setAttribute("xmlns:media", Namespaces::MEDIA);
- $root->setAttribute("xmlns:poco", Namespaces::POCO);
- $root->setAttribute("xmlns:ostatus", Namespaces::OSTATUS);
- $root->setAttribute("xmlns:statusnet", Namespaces::STATUSNET);
- $root->setAttribute("xmlns:mastodon", Namespaces::MASTODON);
+ $root->setAttribute("xmlns:thr", ANamespace::THREAD);
+ $root->setAttribute("xmlns:georss", ANamespace::GEORSS);
+ $root->setAttribute("xmlns:activity", ANamespace::ACTIVITY);
+ $root->setAttribute("xmlns:media", ANamespace::MEDIA);
+ $root->setAttribute("xmlns:poco", ANamespace::POCO);
+ $root->setAttribute("xmlns:ostatus", ANamespace::OSTATUS);
+ $root->setAttribute("xmlns:statusnet", ANamespace::STATUSNET);
+ $root->setAttribute("xmlns:mastodon", ANamespace::MASTODON);
$title = '';
$selfUri = '/feed/' . $owner["nick"] . '/';
if ($item["verb"] == Activity::LIKE) {
return self::likeEntry($doc, $item, $owner, $toplevel);
- } elseif (in_array($item["verb"], [Activity::FOLLOW, Namespaces::OSTATUS . "/unfollow"])) {
+ } elseif (in_array($item["verb"], [Activity::FOLLOW, ANamespace::OSTATUS . "/unfollow"])) {
return self::followEntry($doc, $item, $owner, $toplevel);
} else {
return self::noteEntry($doc, $item, $owner, $toplevel, $feed_mode);
$as_object = $doc->createElement("activity:object");
- XML::addElement($doc, $as_object, "activity:object-type", Namespaces::ACTIVITY_SCHEMA . "activity");
+ XML::addElement($doc, $as_object, "activity:object-type", ANamespace::ACTIVITY_SCHEMA . "activity");
self::entryContent($doc, $as_object, $repeated_item, $owner, "", "", false);
$entry = self::entryHeader($doc, $owner, $item, $toplevel);
- $verb = Activity\Namespaces::ACTIVITY_SCHEMA."favorite";
+ $verb = Activity\ANamespace::ACTIVITY_SCHEMA . "favorite";
self::entryContent($doc, $entry, $item, $owner, "Favorite", $verb, false);
$parent = Item::selectFirst([], ['uri' => $item["thr-parent"], 'uid' => $item["uid"]]);
$entry->appendChild($author);
}
} else {
- $entry = $doc->createElementNS(Namespaces::ATOM1, "entry");
-
- $entry->setAttribute("xmlns:thr", Namespaces::THREAD);
- $entry->setAttribute("xmlns:georss", Namespaces::GEORSS);
- $entry->setAttribute("xmlns:activity", Namespaces::ACTIVITY);
- $entry->setAttribute("xmlns:media", Namespaces::MEDIA);
- $entry->setAttribute("xmlns:poco", Namespaces::POCO);
- $entry->setAttribute("xmlns:ostatus", Namespaces::OSTATUS);
- $entry->setAttribute("xmlns:statusnet", Namespaces::STATUSNET);
- $entry->setAttribute("xmlns:mastodon", Namespaces::MASTODON);
+ $entry = $doc->createElementNS(ANamespace::ATOM1, "entry");
+
+ $entry->setAttribute("xmlns:thr", ANamespace::THREAD);
+ $entry->setAttribute("xmlns:georss", ANamespace::GEORSS);
+ $entry->setAttribute("xmlns:activity", ANamespace::ACTIVITY);
+ $entry->setAttribute("xmlns:media", ANamespace::MEDIA);
+ $entry->setAttribute("xmlns:poco", ANamespace::POCO);
+ $entry->setAttribute("xmlns:ostatus", ANamespace::OSTATUS);
+ $entry->setAttribute("xmlns:statusnet", ANamespace::STATUSNET);
+ $entry->setAttribute("xmlns:mastodon", ANamespace::MASTODON);
$author = self::addAuthor($doc, $owner);
$entry->appendChild($author);
],
'withNamespace' => [
'haystack' => 'tagterm',
- 'needle' => Activity\Namespaces::ACTIVITY_SCHEMA . Activity::OBJ_TAGTERM,
+ 'needle' => Activity\ANamespace::ACTIVITY_SCHEMA . Activity::OBJ_TAGTERM,
'assert' => true,
],
'invalidSimple' => [
],
'withSubPath' => [
'haystack' => 'tagterm',
- 'needle' => Activity\Namespaces::ACTIVITY_SCHEMA . '/bla/' . Activity::OBJ_TAGTERM,
+ 'needle' => Activity\ANamespace::ACTIVITY_SCHEMA . '/bla/' . Activity::OBJ_TAGTERM,
'assert' => true,
],
];