From dc2858938d37e033ee4a0761c2f1e5c2082848cd Mon Sep 17 00:00:00 2001 From: Philipp Holzer Date: Fri, 25 Oct 2019 00:32:35 +0200 Subject: [PATCH] Renamed to ActivityNamespace --- mod/salmon.php | 4 +- src/Module/Xrd.php | 8 +- src/Network/Probe.php | 20 ++--- src/Protocol/Activity.php | 48 +++++------ .../{ANamespace.php => ActivityNamespace.php} | 2 +- src/Protocol/Activity/ObjectType.php | 28 +++---- src/Protocol/DFRN.php | 84 +++++++++---------- src/Protocol/Diaspora.php | 6 +- src/Protocol/Feed.php | 6 +- src/Protocol/OStatus.php | 80 +++++++++--------- tests/src/Protocol/ActivityTest.php | 4 +- 11 files changed, 145 insertions(+), 145 deletions(-) rename src/Protocol/Activity/{ANamespace.php => ActivityNamespace.php} (99%) diff --git a/mod/salmon.php b/mod/salmon.php index 9a6d0864a..2a7c4a4b3 100644 --- a/mod/salmon.php +++ b/mod/salmon.php @@ -9,7 +9,7 @@ use Friendica\Core\PConfig; use Friendica\Core\Protocol; use Friendica\Database\DBA; use Friendica\Model\Contact; -use Friendica\Protocol\Activity\ANamespace; +use Friendica\Protocol\Activity\ActivityNamespace; use Friendica\Protocol\OStatus; use Friendica\Protocol\Salmon; use Friendica\Util\Crypto; @@ -37,7 +37,7 @@ function salmon_post(App $a, $xml = '') { // parse the xml - $dom = simplexml_load_string($xml,'SimpleXMLElement',0, ANamespace::SALMON_ME); + $dom = simplexml_load_string($xml,'SimpleXMLElement',0, ActivityNamespace::SALMON_ME); $base = null; diff --git a/src/Module/Xrd.php b/src/Module/Xrd.php index a28d1eed2..77fa3959a 100644 --- a/src/Module/Xrd.php +++ b/src/Module/Xrd.php @@ -8,7 +8,7 @@ use Friendica\Core\Renderer; use Friendica\Database\DBA; use Friendica\Model\Photo; use Friendica\Model\User; -use Friendica\Protocol\Activity\ANamespace; +use Friendica\Protocol\Activity\ActivityNamespace; use Friendica\Protocol\Salmon; use Friendica\Util\Strings; @@ -95,11 +95,11 @@ class Xrd extends BaseModule ], 'links' => [ [ - 'rel' => ANamespace::DFRN , + 'rel' => ActivityNamespace::DFRN , 'href' => $owner['url'], ], [ - 'rel' => ANamespace::FEED, + 'rel' => ActivityNamespace::FEED, 'type' => 'application/atom+xml', 'href' => $owner['poll'], ], @@ -119,7 +119,7 @@ class Xrd extends BaseModule 'href' => $baseURL . '/hcard/' . $owner['nickname'], ], [ - 'rel' => ANamespace::POCO, + 'rel' => ActivityNamespace::POCO, 'href' => $owner['poco'], ], [ diff --git a/src/Network/Probe.php b/src/Network/Probe.php index 0014fa05d..e63224411 100644 --- a/src/Network/Probe.php +++ b/src/Network/Probe.php @@ -18,7 +18,7 @@ use Friendica\Core\Protocol; use Friendica\Core\System; use Friendica\Database\DBA; use Friendica\Model\Profile; -use Friendica\Protocol\Activity\ANamespace; +use Friendica\Protocol\Activity\ActivityNamespace; use Friendica\Protocol\ActivityPub; use Friendica\Protocol\Email; use Friendica\Protocol\Feed; @@ -200,10 +200,10 @@ class Probe Logger::log('webfingerDfrn: '.$webbie.':'.print_r($links, true), Logger::DATA); if (!empty($links) && is_array($links)) { foreach ($links as $link) { - if ($link['@attributes']['rel'] === ANamespace::DFRN) { + if ($link['@attributes']['rel'] === ActivityNamespace::DFRN) { $profile_link = $link['@attributes']['href']; } - if (($link['@attributes']['rel'] === ANamespace::OSTATUSSUB) && ($profile_link == "")) { + if (($link['@attributes']['rel'] === ActivityNamespace::OSTATUSSUB) && ($profile_link == "")) { $profile_link = 'stat:'.$link['@attributes']['template']; } if ($link['@attributes']['rel'] === 'http://microformats.org/profile/hcard') { @@ -492,7 +492,7 @@ class Probe $has_key = false; foreach ($webfinger['links'] as $link) { - if ($link['rel'] == ANamespace::OSTATUSSUB) { + if ($link['rel'] == ActivityNamespace::OSTATUSSUB) { $is_ostatus = true; } if ($link['rel'] == 'magic-public-key') { @@ -955,15 +955,15 @@ class Probe // 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"] == ANamespace::DFRN) && !empty($link["href"])) { + if (($link["rel"] == ActivityNamespace::DFRN) && !empty($link["href"])) { $data["network"] = Protocol::DFRN; - } elseif (($link["rel"] == ANamespace::FEED) && !empty($link["href"])) { + } elseif (($link["rel"] == ActivityNamespace::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"] == ANamespace::POCO) && !empty($link["href"])) { + } elseif (($link["rel"] == ActivityNamespace::POCO) && !empty($link["href"])) { $data["poco"] = $link["href"]; } elseif (($link["rel"] == "http://webfinger.net/rel/avatar") && !empty($link["href"])) { $data["photo"] = $link["href"]; @@ -1171,9 +1171,9 @@ class Probe $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"] == ANamespace::FEED) && !empty($link["href"])) { + } elseif (($link["rel"] == ActivityNamespace::FEED) && !empty($link["href"])) { $data["poll"] = $link["href"]; - } elseif (($link["rel"] == ANamespace::POCO) && !empty($link["href"])) { + } elseif (($link["rel"] == ActivityNamespace::POCO) && !empty($link["href"])) { $data["poco"] = $link["href"]; } elseif (($link["rel"] == "salmon") && !empty($link["href"])) { $data["notify"] = $link["href"]; @@ -1273,7 +1273,7 @@ class Probe $data["url"] = $link["href"]; } elseif (($link["rel"] == "salmon") && !empty($link["href"])) { $data["notify"] = $link["href"]; - } elseif (($link["rel"] == ANamespace::FEED) && !empty($link["href"])) { + } elseif (($link["rel"] == ActivityNamespace::FEED) && !empty($link["href"])) { $data["poll"] = $link["href"]; } elseif (($link["rel"] == "magic-public-key") && !empty($link["href"])) { $pubkey = $link["href"]; diff --git a/src/Protocol/Activity.php b/src/Protocol/Activity.php index 83e032752..d2c5eec4b 100644 --- a/src/Protocol/Activity.php +++ b/src/Protocol/Activity.php @@ -2,7 +2,7 @@ namespace Friendica\Protocol; -use Friendica\Protocol\Activity\ANamespace; +use Friendica\Protocol\Activity\ActivityNamespace; /** * Base class for the Activity Verbs @@ -15,14 +15,14 @@ final class Activity * @see http://activitystrea.ms/head/activity-schema.html#verbs * @var string */ - const LIKE = ANamespace::ACTIVITY_SCHEMA . 'like'; + const LIKE = ActivityNamespace::ACTIVITY_SCHEMA . 'like'; /** * Dislike a message ("I don't like the post") * * @see http://purl.org/macgirvin/dfrn/1.0/dislike * @var string */ - const DISLIKE = ANamespace::DFRN . '/dislike'; + const DISLIKE = ActivityNamespace::DFRN . '/dislike'; /** * Attend an event @@ -30,21 +30,21 @@ final class Activity * @see https://github.com/friendica/friendica/wiki/ActivityStreams#activity_attend * @var string */ - const ATTEND = ANamespace::ZOT . '/activity/attendyes'; + const ATTEND = ActivityNamespace::ZOT . '/activity/attendyes'; /** * Don't attend an event * * @see https://github.com/friendica/friendica/wiki/ActivityStreams#activity_attendno * @var string */ - const ATTENDNO = ANamespace::ZOT . '/activity/attendno'; + const ATTENDNO = ActivityNamespace::ZOT . '/activity/attendno'; /** * Attend maybe an event * * @see https://github.com/friendica/friendica/wiki/ActivityStreams#activity_attendmaybe * @var string */ - const ATTENDMAYBE = ANamespace::ZOT . '/activity/attendmaybe'; + const ATTENDMAYBE = ActivityNamespace::ZOT . '/activity/attendmaybe'; /** * Indicates the creation of a friendship that is reciprocated by the object. @@ -52,98 +52,98 @@ final class Activity * @see http://activitystrea.ms/head/activity-schema.html#verbs * @var string */ - const FRIEND = ANamespace::ACTIVITY_SCHEMA . 'make-friend'; + const FRIEND = ActivityNamespace::ACTIVITY_SCHEMA . 'make-friend'; /** * Indicates the creation of a friendship that has not yet been reciprocated by the object. * * @see http://activitystrea.ms/head/activity-schema.html#verbs * @var string */ - const REQ_FRIEND = ANamespace::ACTIVITY_SCHEMA . 'request-friend'; + const REQ_FRIEND = ActivityNamespace::ACTIVITY_SCHEMA . 'request-friend'; /** * Indicates that the actor has removed the object from the collection of friends. * * @see http://activitystrea.ms/head/activity-schema.html#verbs * @var string */ - const UNFRIEND = ANamespace::ACTIVITY_SCHEMA . 'remove-friend'; + const UNFRIEND = ActivityNamespace::ACTIVITY_SCHEMA . 'remove-friend'; /** * Indicates that the actor began following the activity of the object. * * @see http://activitystrea.ms/head/activity-schema.html#verbs * @var string */ - const FOLLOW = ANamespace::ACTIVITY_SCHEMA . 'follow'; + const FOLLOW = ActivityNamespace::ACTIVITY_SCHEMA . 'follow'; /** * Indicates that the actor has stopped following the object. * * @see http://activitystrea.ms/head/activity-schema.html#verbs * @var string */ - const UNFOLLOW = ANamespace::ACTIVITY_SCHEMA . 'stop-following'; + const UNFOLLOW = ActivityNamespace::ACTIVITY_SCHEMA . 'stop-following'; /** * Indicates that the actor has become a member of the object. * * @see http://activitystrea.ms/head/activity-schema.html#verbs * @var string */ - const JOIN = ANamespace::ACTIVITY_SCHEMA . 'join'; + const JOIN = ActivityNamespace::ACTIVITY_SCHEMA . 'join'; /** * Implementors SHOULD use verbs such as post where the actor is adding new items to a collection or similar. * * @see http://activitystrea.ms/head/activity-schema.html#verbs * @var string */ - const POST = ANamespace::ACTIVITY_SCHEMA . 'post'; + const POST = ActivityNamespace::ACTIVITY_SCHEMA . 'post'; /** * The "update" verb indicates that the actor has modified the object. * * @see http://activitystrea.ms/head/activity-schema.html#verbs * @var string */ - const UPDATE = ANamespace::ACTIVITY_SCHEMA . 'update'; + const UPDATE = ActivityNamespace::ACTIVITY_SCHEMA . 'update'; /** * Indicates that the actor has identified the presence of a target inside another object. * * @see http://activitystrea.ms/head/activity-schema.html#verbs * @var string */ - const TAG = ANamespace::ACTIVITY_SCHEMA . 'tag'; + const TAG = ActivityNamespace::ACTIVITY_SCHEMA . 'tag'; /** * Indicates that the actor marked the object as an item of special interest. * * @see http://activitystrea.ms/head/activity-schema.html#verbs * @var string */ - const FAVORITE = ANamespace::ACTIVITY_SCHEMA . 'favorite'; + const FAVORITE = ActivityNamespace::ACTIVITY_SCHEMA . 'favorite'; /** * Indicates that the actor has removed the object from the collection of favorited items. * * @see http://activitystrea.ms/head/activity-schema.html#verbs * @var string */ - const UNFAVORITE = ANamespace::ACTIVITY_SCHEMA . 'unfavorite'; + const UNFAVORITE = ActivityNamespace::ACTIVITY_SCHEMA . 'unfavorite'; /** * Indicates that the actor has called out the object to readers. * * @see http://activitystrea.ms/head/activity-schema.html#verbs * @var string */ - const SHARE = ANamespace::ACTIVITY_SCHEMA . 'share'; + const SHARE = ActivityNamespace::ACTIVITY_SCHEMA . 'share'; /** * Indicates that the actor has deleted the object. * * @see http://activitystrea.ms/head/activity-schema.html#verbs * @var string */ - const DELETE = ANamespace::ACTIVITY_SCHEMA . 'delete'; + const DELETE = ActivityNamespace::ACTIVITY_SCHEMA . 'delete'; /** * Indicates that the actor is calling the target's attention the object. * * @see https://www.w3.org/TR/activitystreams-vocabulary/#dfn-announce * @var string */ - const ANNOUNCE = ANamespace::ACTIVITY2 . 'Announce'; + const ANNOUNCE = ActivityNamespace::ACTIVITY2 . 'Announce'; /** * Pokes an user. @@ -151,11 +151,11 @@ final class Activity * @see https://github.com/friendica/friendica/wiki/ActivityStreams#activity_poke * @var string */ - const POKE = ANamespace::ZOT . '/activity/poke'; + const POKE = ActivityNamespace::ZOT . '/activity/poke'; - const O_UNFOLLOW = ANamespace::OSTATUS . '/unfollow'; - const O_UNFAVOURITE = ANamespace::OSTATUS . '/unfavorite'; + const O_UNFOLLOW = ActivityNamespace::OSTATUS . '/unfollow'; + const O_UNFAVOURITE = ActivityNamespace::OSTATUS . '/unfavorite'; /** * likes (etc.) can apply to other things besides posts. Check if they are post children, @@ -200,6 +200,6 @@ final class Activity { return (($haystack === $needle) || ((basename($needle) === $haystack) && - strstr($needle, ANamespace::ACTIVITY_SCHEMA))); + strstr($needle, ActivityNamespace::ACTIVITY_SCHEMA))); } } diff --git a/src/Protocol/Activity/ANamespace.php b/src/Protocol/Activity/ActivityNamespace.php similarity index 99% rename from src/Protocol/Activity/ANamespace.php rename to src/Protocol/Activity/ActivityNamespace.php index 55fcc8374..a821f069e 100644 --- a/src/Protocol/Activity/ANamespace.php +++ b/src/Protocol/Activity/ActivityNamespace.php @@ -5,7 +5,7 @@ namespace Friendica\Protocol\Activity; /** * Activity namespaces constants */ -final class ANamespace +final class ActivityNamespace { /** * Zot is a WebMTA which provides a decentralised identity and communications protocol using HTTPS/JSON. diff --git a/src/Protocol/Activity/ObjectType.php b/src/Protocol/Activity/ObjectType.php index 71c7a2157..7bed40d87 100644 --- a/src/Protocol/Activity/ObjectType.php +++ b/src/Protocol/Activity/ObjectType.php @@ -13,14 +13,14 @@ final class ObjectType * @see http://activitystrea.ms/head/activity-schema.html#bookmark * @var string */ - const BOOKMARK = ANamespace::ACTIVITY_SCHEMA . 'bookmark'; + const BOOKMARK = ActivityNamespace::ACTIVITY_SCHEMA . 'bookmark'; /** * The "comment" object type represents a textual response to another object. * * @see http://activitystrea.ms/head/activity-schema.html#comment * @var string */ - const COMMENT = ANamespace::ACTIVITY_SCHEMA . 'comment'; + const COMMENT = ActivityNamespace::ACTIVITY_SCHEMA . 'comment'; /** * The "comment" object type represents a textual response to another object. * (Default type for items) @@ -28,25 +28,25 @@ final class ObjectType * @see http://activitystrea.ms/head/activity-schema.html#note * @var string */ - const NOTE = ANamespace::ACTIVITY_SCHEMA . 'note'; + const NOTE = ActivityNamespace::ACTIVITY_SCHEMA . 'note'; /** * The "person" object type represents a user account. * * @see http://activitystrea.ms/head/activity-schema.html#person * @var string */ - const PERSON = ANamespace::ACTIVITY_SCHEMA . 'person'; + const PERSON = ActivityNamespace::ACTIVITY_SCHEMA . 'person'; /** * The "image" object type represents a graphical image. * * @see http://activitystrea.ms/head/activity-schema.html#image * @var string */ - const IMAGE = ANamespace::ACTIVITY_SCHEMA . 'image'; + const IMAGE = ActivityNamespace::ACTIVITY_SCHEMA . 'image'; /** * @var string */ - const PHOTO = ANamespace::ACTIVITY_SCHEMA . 'photo'; + const PHOTO = ActivityNamespace::ACTIVITY_SCHEMA . 'photo'; /** * The "video" object type represents video content, * which usually consists of a motion picture track and an audio track. @@ -54,43 +54,43 @@ final class ObjectType * @see http://activitystrea.ms/head/activity-schema.html#video * @var string */ - const VIDEO = ANamespace::ACTIVITY_SCHEMA . 'video'; + const VIDEO = ActivityNamespace::ACTIVITY_SCHEMA . 'video'; /** * @var string */ - const PROFILE_PHOTO = ANamespace::ACTIVITY_SCHEMA . 'profile-photo'; + const PROFILE_PHOTO = ActivityNamespace::ACTIVITY_SCHEMA . 'profile-photo'; /** * @var string */ - const ALBUM = ANamespace::ACTIVITY_SCHEMA . 'photo-album'; + const ALBUM = ActivityNamespace::ACTIVITY_SCHEMA . 'photo-album'; /** * The "event" object type represents an event that occurs in a certain place during a particular interval of time. * * @see http://activitystrea.ms/head/activity-schema.html#event * @var string */ - const EVENT = ANamespace::ACTIVITY_SCHEMA . 'event'; + const EVENT = ActivityNamespace::ACTIVITY_SCHEMA . 'event'; /** * The "group" object type represents a grouping of objects in which member objects can join or leave. * * @see http://activitystrea.ms/head/activity-schema.html#group * @var string */ - const GROUP = ANamespace::ACTIVITY_SCHEMA . 'group'; + const GROUP = ActivityNamespace::ACTIVITY_SCHEMA . 'group'; /** * @var string */ - const HEART = ANamespace::DFRN . '/heart'; + const HEART = ActivityNamespace::DFRN . '/heart'; /** * @var string */ - const TAGTERM = ANamespace::DFRN . '/tagterm'; + const TAGTERM = ActivityNamespace::DFRN . '/tagterm'; /** * @var string */ - const PROFILE = ANamespace::DFRN . '/profile'; + const PROFILE = ActivityNamespace::DFRN . '/profile'; /** diff --git a/src/Protocol/DFRN.php b/src/Protocol/DFRN.php index 6bf3e6e4f..6e84fdbb3 100644 --- a/src/Protocol/DFRN.php +++ b/src/Protocol/DFRN.php @@ -32,7 +32,7 @@ use Friendica\Model\Profile; use Friendica\Model\User; use Friendica\Network\Probe; use Friendica\Object\Image; -use Friendica\Protocol\Activity\ANamespace; +use Friendica\Protocol\Activity\ActivityNamespace; use Friendica\Util\Crypto; use Friendica\Util\DateTimeFormat; use Friendica\Util\Network; @@ -381,18 +381,18 @@ class DFRN $type = 'html'; if ($conversation) { - $root = $doc->createElementNS(ANamespace::ATOM1, 'feed'); + $root = $doc->createElementNS(ActivityNamespace::ATOM1, 'feed'); $doc->appendChild($root); - $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->setAttribute("xmlns:thr", ActivityNamespace::THREAD); + $root->setAttribute("xmlns:at", ActivityNamespace::TOMB); + $root->setAttribute("xmlns:media", ActivityNamespace::MEDIA); + $root->setAttribute("xmlns:dfrn", ActivityNamespace::DFRN); + $root->setAttribute("xmlns:activity", ActivityNamespace::ACTIVITY); + $root->setAttribute("xmlns:georss", ActivityNamespace::GEORSS); + $root->setAttribute("xmlns:poco", ActivityNamespace::POCO); + $root->setAttribute("xmlns:ostatus", ActivityNamespace::OSTATUS); + $root->setAttribute("xmlns:statusnet", ActivityNamespace::STATUSNET); //$root = self::addHeader($doc, $owner, "dfrn:owner", "", false); @@ -556,18 +556,18 @@ class DFRN $alternatelink = $owner['url']; } - $root = $doc->createElementNS(ANamespace::ATOM1, 'feed'); + $root = $doc->createElementNS(ActivityNamespace::ATOM1, 'feed'); $doc->appendChild($root); - $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->setAttribute("xmlns:thr", ActivityNamespace::THREAD); + $root->setAttribute("xmlns:at", ActivityNamespace::TOMB); + $root->setAttribute("xmlns:media", ActivityNamespace::MEDIA); + $root->setAttribute("xmlns:dfrn", ActivityNamespace::DFRN); + $root->setAttribute("xmlns:activity", ActivityNamespace::ACTIVITY); + $root->setAttribute("xmlns:georss", ActivityNamespace::GEORSS); + $root->setAttribute("xmlns:poco", ActivityNamespace::POCO); + $root->setAttribute("xmlns:ostatus", ActivityNamespace::OSTATUS); + $root->setAttribute("xmlns:statusnet", ActivityNamespace::STATUSNET); XML::addElement($doc, $root, "id", System::baseUrl()."/profile/".$owner["nick"]); XML::addElement($doc, $root, "title", $owner["name"]); @@ -940,18 +940,18 @@ class DFRN if (!$single) { $entry = $doc->createElement("entry"); } else { - $entry = $doc->createElementNS(ANamespace::ATOM1, 'entry'); + $entry = $doc->createElementNS(ActivityNamespace::ATOM1, 'entry'); $doc->appendChild($entry); - $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); + $entry->setAttribute("xmlns:thr", ActivityNamespace::THREAD); + $entry->setAttribute("xmlns:at", ActivityNamespace::TOMB); + $entry->setAttribute("xmlns:media", ActivityNamespace::MEDIA); + $entry->setAttribute("xmlns:dfrn", ActivityNamespace::DFRN); + $entry->setAttribute("xmlns:activity", ActivityNamespace::ACTIVITY); + $entry->setAttribute("xmlns:georss", ActivityNamespace::GEORSS); + $entry->setAttribute("xmlns:poco", ActivityNamespace::POCO); + $entry->setAttribute("xmlns:ostatus", ActivityNamespace::OSTATUS); + $entry->setAttribute("xmlns:statusnet", ActivityNamespace::STATUSNET); } if ($item['private']) { @@ -1749,7 +1749,7 @@ class DFRN $obj_doc = new DOMDocument("1.0", "utf-8"); $obj_doc->formatOutput = true; - $obj_element = $obj_doc->createElementNS( ANamespace::ATOM1, $element); + $obj_element = $obj_doc->createElementNS( ActivityNamespace::ATOM1, $element); $activity_type = $xpath->query("activity:object-type/text()", $activity)->item(0)->nodeValue; XML::addElement($obj_doc, $obj_element, "type", $activity_type); @@ -2730,16 +2730,16 @@ class DFRN @$doc->loadXML($xml); $xpath = new DOMXPath($doc); - $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); + $xpath->registerNamespace("atom", ActivityNamespace::ATOM1); + $xpath->registerNamespace("thr", ActivityNamespace::THREAD); + $xpath->registerNamespace("at", ActivityNamespace::TOMB); + $xpath->registerNamespace("media", ActivityNamespace::MEDIA); + $xpath->registerNamespace("dfrn", ActivityNamespace::DFRN); + $xpath->registerNamespace("activity", ActivityNamespace::ACTIVITY); + $xpath->registerNamespace("georss", ActivityNamespace::GEORSS); + $xpath->registerNamespace("poco", ActivityNamespace::POCO); + $xpath->registerNamespace("ostatus", ActivityNamespace::OSTATUS); + $xpath->registerNamespace("statusnet", ActivityNamespace::STATUSNET); $header = []; $header["uid"] = $importer["importer_uid"]; diff --git a/src/Protocol/Diaspora.php b/src/Protocol/Diaspora.php index 709dfa02f..6fcfa36bd 100644 --- a/src/Protocol/Diaspora.php +++ b/src/Protocol/Diaspora.php @@ -32,7 +32,7 @@ use Friendica\Model\Mail; use Friendica\Model\Profile; use Friendica\Model\User; use Friendica\Network\Probe; -use Friendica\Protocol\Activity\ANamespace; +use Friendica\Protocol\Activity\ActivityNamespace; use Friendica\Util\Crypto; use Friendica\Util\DateTimeFormat; use Friendica\Util\Map; @@ -466,7 +466,7 @@ class Diaspora } } - $base = $basedom->children(ANamespace::SALMON_ME); + $base = $basedom->children(ActivityNamespace::SALMON_ME); // Not sure if this cleaning is needed $data = str_replace([" ", "\t", "\r", "\n"], ["", "", "", ""], $base->data); @@ -578,7 +578,7 @@ class Diaspora $author_link = str_replace('acct:', '', $idom->author_id); } - $dom = $basedom->children(ANamespace::SALMON_ME); + $dom = $basedom->children(ActivityNamespace::SALMON_ME); // figure out where in the DOM tree our data is hiding diff --git a/src/Protocol/Feed.php b/src/Protocol/Feed.php index 816820bc4..31f54e50c 100644 --- a/src/Protocol/Feed.php +++ b/src/Protocol/Feed.php @@ -14,7 +14,7 @@ use Friendica\Core\Protocol; use Friendica\Core\System; use Friendica\Database\DBA; use Friendica\Model\Item; -use Friendica\Protocol\Activity\ANamespace; +use Friendica\Protocol\Activity\ActivityNamespace; use Friendica\Util\Network; use Friendica\Util\XML; @@ -60,13 +60,13 @@ class Feed { $doc = new DOMDocument(); @$doc->loadXML(trim($xml)); $xpath = new DOMXPath($doc); - $xpath->registerNamespace('atom', ANamespace::ATOM1); + $xpath->registerNamespace('atom', ActivityNamespace::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', ANamespace::POCO); + $xpath->registerNamespace('poco', ActivityNamespace::POCO); $author = []; $entries = null; diff --git a/src/Protocol/OStatus.php b/src/Protocol/OStatus.php index d0f7d7edf..9a41920ae 100644 --- a/src/Protocol/OStatus.php +++ b/src/Protocol/OStatus.php @@ -25,7 +25,7 @@ use Friendica\Model\Item; use Friendica\Model\User; use Friendica\Network\Probe; use Friendica\Object\Image; -use Friendica\Protocol\Activity\ANamespace; +use Friendica\Protocol\Activity\ActivityNamespace; use Friendica\Util\DateTimeFormat; use Friendica\Util\Network; use Friendica\Util\Proxy as ProxyUtils; @@ -262,14 +262,14 @@ class OStatus @$doc->loadXML($xml); $xpath = new DOMXPath($doc); - $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); + $xpath->registerNamespace('atom', ActivityNamespace::ATOM1); + $xpath->registerNamespace('thr', ActivityNamespace::THREAD); + $xpath->registerNamespace('georss', ActivityNamespace::GEORSS); + $xpath->registerNamespace('activity', ActivityNamespace::ACTIVITY); + $xpath->registerNamespace('media', ActivityNamespace::MEDIA); + $xpath->registerNamespace('poco', ActivityNamespace::POCO); + $xpath->registerNamespace('ostatus', ActivityNamespace::OSTATUS); + $xpath->registerNamespace('statusnet', ActivityNamespace::STATUSNET); $contact = ["id" => 0]; @@ -343,14 +343,14 @@ class OStatus @$doc->loadXML($xml); $xpath = new DOMXPath($doc); - $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); + $xpath->registerNamespace('atom', ActivityNamespace::ATOM1); + $xpath->registerNamespace('thr', ActivityNamespace::THREAD); + $xpath->registerNamespace('georss', ActivityNamespace::GEORSS); + $xpath->registerNamespace('activity', ActivityNamespace::ACTIVITY); + $xpath->registerNamespace('media', ActivityNamespace::MEDIA); + $xpath->registerNamespace('poco', ActivityNamespace::POCO); + $xpath->registerNamespace('ostatus', ActivityNamespace::OSTATUS); + $xpath->registerNamespace('statusnet', ActivityNamespace::STATUSNET); $hub = ""; $hub_items = $xpath->query("/atom:feed/atom:link[@rel='hub']")->item(0); @@ -804,9 +804,9 @@ class OStatus @$doc->loadXML($xml); $xpath = new DOMXPath($doc); - $xpath->registerNamespace('atom', ANamespace::ATOM1); - $xpath->registerNamespace('thr', ANamespace::THREAD); - $xpath->registerNamespace('ostatus', ANamespace::OSTATUS); + $xpath->registerNamespace('atom', ActivityNamespace::ATOM1); + $xpath->registerNamespace('thr', ActivityNamespace::THREAD); + $xpath->registerNamespace('ostatus', ActivityNamespace::OSTATUS); $entries = $xpath->query('/atom:feed/atom:entry'); @@ -1282,17 +1282,17 @@ class OStatus */ private static function addHeader(DOMDocument $doc, array $owner, $filter, $feed_mode = false) { - $root = $doc->createElementNS(ANamespace::ATOM1, 'feed'); + $root = $doc->createElementNS(ActivityNamespace::ATOM1, 'feed'); $doc->appendChild($root); - $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); + $root->setAttribute("xmlns:thr", ActivityNamespace::THREAD); + $root->setAttribute("xmlns:georss", ActivityNamespace::GEORSS); + $root->setAttribute("xmlns:activity", ActivityNamespace::ACTIVITY); + $root->setAttribute("xmlns:media", ActivityNamespace::MEDIA); + $root->setAttribute("xmlns:poco", ActivityNamespace::POCO); + $root->setAttribute("xmlns:ostatus", ActivityNamespace::OSTATUS); + $root->setAttribute("xmlns:statusnet", ActivityNamespace::STATUSNET); + $root->setAttribute("xmlns:mastodon", ActivityNamespace::MASTODON); $title = ''; $selfUri = '/feed/' . $owner["nick"] . '/'; @@ -1710,7 +1710,7 @@ class OStatus $as_object = $doc->createElement("activity:object"); - XML::addElement($doc, $as_object, "activity:object-type", ANamespace::ACTIVITY_SCHEMA . "activity"); + XML::addElement($doc, $as_object, "activity:object-type", ActivityNamespace::ACTIVITY_SCHEMA . "activity"); self::entryContent($doc, $as_object, $repeated_item, $owner, "", "", false); @@ -1760,7 +1760,7 @@ class OStatus $entry = self::entryHeader($doc, $owner, $item, $toplevel); - $verb = Activity\ANamespace::ACTIVITY_SCHEMA . "favorite"; + $verb = Activity\ActivityNamespace::ACTIVITY_SCHEMA . "favorite"; self::entryContent($doc, $entry, $item, $owner, "Favorite", $verb, false); $parent = Item::selectFirst([], ['uri' => $item["thr-parent"], 'uid' => $item["uid"]]); @@ -1951,16 +1951,16 @@ class OStatus $entry->appendChild($author); } } else { - $entry = $doc->createElementNS(ANamespace::ATOM1, "entry"); + $entry = $doc->createElementNS(ActivityNamespace::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); + $entry->setAttribute("xmlns:thr", ActivityNamespace::THREAD); + $entry->setAttribute("xmlns:georss", ActivityNamespace::GEORSS); + $entry->setAttribute("xmlns:activity", ActivityNamespace::ACTIVITY); + $entry->setAttribute("xmlns:media", ActivityNamespace::MEDIA); + $entry->setAttribute("xmlns:poco", ActivityNamespace::POCO); + $entry->setAttribute("xmlns:ostatus", ActivityNamespace::OSTATUS); + $entry->setAttribute("xmlns:statusnet", ActivityNamespace::STATUSNET); + $entry->setAttribute("xmlns:mastodon", ActivityNamespace::MASTODON); $author = self::addAuthor($doc, $owner); $entry->appendChild($author); diff --git a/tests/src/Protocol/ActivityTest.php b/tests/src/Protocol/ActivityTest.php index ac332a7f7..5249ebefa 100644 --- a/tests/src/Protocol/ActivityTest.php +++ b/tests/src/Protocol/ActivityTest.php @@ -22,7 +22,7 @@ class ActivityTest extends MockedTest ], 'withNamespace' => [ 'haystack' => 'tagterm', - 'needle' => Activity\ANamespace::ACTIVITY_SCHEMA . Activity\ObjectType::TAGTERM, + 'needle' => Activity\ActivityNamespace::ACTIVITY_SCHEMA . Activity\ObjectType::TAGTERM, 'assert' => true, ], 'invalidSimple' => [ @@ -37,7 +37,7 @@ class ActivityTest extends MockedTest ], 'withSubPath' => [ 'haystack' => 'tagterm', - 'needle' => Activity\ANamespace::ACTIVITY_SCHEMA . '/bla/' . Activity\ObjectType::TAGTERM, + 'needle' => Activity\ActivityNamespace::ACTIVITY_SCHEMA . '/bla/' . Activity\ObjectType::TAGTERM, 'assert' => true, ], ];