Activity.php

Summary
Activity.php
ActivityClass abstraction for Activity verbs
ActivityAn activity in the ActivityStrea.ms world
__constructTurns a regular old Atom <entry> into a magical activity
_fromAtomEntry
_fromRssItem
toAtomEntryIn theory, returns an Atom <entry> based on this activity.
asArrayReturns an array based on this activity suitable for encoding as a JSON object
asString
outputToDumps the Activity into an XML stream
_childEasy creation of a child class
iso8601DateFor consistency, we’ll always output UTC rather than local time.

Activity

Class abstraction for Activity verbs

postActiv

the micro-blogging software

Copyright

Copyright © 2016-2017, Maiyannah Bishop

Derived from code copyright various sources

  • GNU Social © 2013-2016, Free Software Foundation, Inc
  • StatusNet © 2008-2012, StatusNet, Inc

License

This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License along with this program.  If not, see http://www.gnu.org/licenses/.

https://www.gnu.org/licenses/agpl.html

About

An activity verb in class form, and the related scaffolding.

This file also now consolidates the ActivityContext, ActivityImporter, ActivityMover, ActivitySink, and ActivitySource classes, formerly at /lib/<class>.php

  • Activity abstracts the class for an activity verb.
  • ActivityContext contains information of the context of the activity verb.
  • ActivityImporter abstracts a means that is importing activity verbs into the system as part of a user’s timeline.
  • ActivityMover abstracts the means to transport activity verbs.
  • ActivitySink abstracts a class to receive activity verbs.
  • ActivitySource abstracts a class to represent the source of a received activity verb.

ActivityObject is a noun in the activity universe basically, from the original file: A noun-ish thing in the activity universe

The activity streams spec talks about activity objects, while also having a tag activity:object, which is in fact an activity object.  Aaaaaah!

This is just a thing in the activity universe.  Can be the subject, object, or indirect object (target!) of an activity verb.  Rotten name, and I’m propagating it.  sigh It’s large enough that I’ve left it seperate in activityobject.php

PHP version

Tested with PHP 5.6

File Authors

Web

Activity

An activity in the ActivityStrea.ms world

An activity is kind of like a sentence: someone did something to something else.

’someone’ is the ‘actor’; ‘did something’ is the verb; ‘something else’ is the object.

Defines

Variables

  • $actor - an ActivityObject
  • $verb - a string (the URL)
  • $objects - an array of ActivityObjects
  • $target - an ActivityObject
  • $context - an ActivityObject
  • $time - Time of the activity
  • $link - an ActivityObject
  • $entry - the source entry
  • $feed - the source feed
  • $summary - summary of activity
  • $content - HTML content of activity
  • $id - ID of the activity
  • $title - title of the activity
  • $categories - list of AtomCategory objects
  • $enclosures - list of enclosure URL references
  • $attachments - list of attachments
  • $extra - extra elements as array(tag, attrs, content)
  • $source - ActivitySource object representing ‘home feed’
  • $selfLink - <link rel=’self’ type=’application/atom+xml’>
  • $editLink - <link rel=’edit’ type=’application/atom+xml’>
  • $generator - ActivityObject representing the generating application
Summary
__constructTurns a regular old Atom <entry> into a magical activity
_fromAtomEntry
_fromRssItem
toAtomEntryIn theory, returns an Atom <entry> based on this activity.
asArrayReturns an array based on this activity suitable for encoding as a JSON object
asString
outputToDumps the Activity into an XML stream
_childEasy creation of a child class
iso8601DateFor consistency, we’ll always output UTC rather than local time.

__construct

function __construct($entry =  null,
$feed =  null)

Turns a regular old Atom <entry> into a magical activity

Parameters

  • DOMElement $entry Atom entry to poke at
  • DOMElement $feed Atom feed, for context

_fromAtomEntry

function _fromAtomEntry($entry,
$feed)

Parameters

  • entry
  • feed

_fromRssItem

function _fromRssItem($item,
$channel)

Parameters

  • item
  • channel

toAtomEntry

function toAtomEntry()

In theory, returns an Atom <entry> based on this activity.

In reality, a stub/null function.

asArray

function asArray()

Returns an array based on this activity suitable for encoding as a JSON object

Returns

  • array $activity

asString

function asString($namespace = false,
$author = true,
$source = false)

Parameters

  • namespace - default false
  • author - default true
  • source - default true

Returns

  • string

outputTo

function outputTo($xs,  
$namespace = false,
$author = true,
$source = false,
$tag = 'entry')

Dumps the Activity into an XML stream

Parameters

  • xs - XML stream object
  • namespace - boolean, default false
  • author - boolean, default true
  • source - boolean, default false
  • tag - string, default ‘entry’

Returns

  • void

_child

private function _child($element,  
$tag,  
$namespace = self::SPEC)

Easy creation of a child class

iso8601Date

static function iso8601Date($tm)

For consistency, we’ll always output UTC rather than local time.  Note that clients should accept any timezone we give them as long as it’s properly formatted.

MB footnote: “should” doesn’t mean “actually will”

Parameter

  • int $tm Unix timestamp

Returns

  • string
function __construct($entry =  null,
$feed =  null)
Turns a regular old Atom entry into a magical activity
function _fromAtomEntry($entry,
$feed)
function _fromRssItem($item,
$channel)
function toAtomEntry()
In theory, returns an Atom entry based on this activity.
function asArray()
Returns an array based on this activity suitable for encoding as a JSON object
function asString($namespace = false,
$author = true,
$source = false)
function outputTo($xs,  
$namespace = false,
$author = true,
$source = false,
$tag = 'entry')
Dumps the Activity into an XML stream
private function _child($element,  
$tag,  
$namespace = self::SPEC)
Easy creation of a child class
static function iso8601Date($tm)
For consistency, we’ll always output UTC rather than local time.