ActivityObject.php

Summary
ActivityObject.php
ActivityObjectClass abstraction for the actual Activity object
ActivityObjectA noun-ish thing in the activity universe
__constructClass constructor
_fromAuthorCreate an activity object given an element
_fromAtomEntryCreate an activity object given an element
_fromRssItemCreate an activity object from a RSS item
fromRssAuthor
fromDcCreator
fromRssChannel
fromPosterousAuthor
_childContent
_getSourceTry to get a unique id for the source feed
fromGroup
fromPeopletag
fromFile
fromNoticeSource
fromMessage
outputTo
asStringReturns the ActivityObject as an XML string
asArrayReturns an array based on this Activity Object suitable for encoding as JSON.
getIdentifiers
canonicalType:
mimeTypeToObjectType

ActivityObject

Class abstraction for the actual Activity object

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

PHP version

Tested with PHP 5.6

File Authors

Web

ActivityObject

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 we’re propagating it.  sigh

Defines

Constants for the schemas

ATOM feed bits we look for

  • TITLE - ‘title’;
  • SUMMARY - ‘summary’;
  • ID - ‘id’;
  • SOURCE - ‘source’;
  • NAME - ‘name’;
  • URI - ‘uri’;
  • EMAIL - ‘email’;

Posterous stuff

  • POSTEROUS - ‘http://posterous.com/help/rss/1.0’;
  • AUTHOR - ‘author’;
  • USERIMAGE - ‘userImage’;
  • PROFILEURL - ‘profileUrl’;
  • NICKNAME - ‘nickName’;
  • DISPLAYNAME - ‘displayName’;
Summary
__constructClass constructor
_fromAuthorCreate an activity object given an element
_fromAtomEntryCreate an activity object given an element
_fromRssItemCreate an activity object from a RSS item
fromRssAuthor
fromDcCreator
fromRssChannel
fromPosterousAuthor
_childContent
_getSourceTry to get a unique id for the source feed
fromGroup
fromPeopletag
fromFile
fromNoticeSource
fromMessage
outputTo
asStringReturns the ActivityObject as an XML string
asArrayReturns an array based on this Activity Object suitable for encoding as JSON.
getIdentifiers
canonicalType:
mimeTypeToObjectType

__construct

function __construct($element =  null)

Class constructor

This probably needs to be refactored to generate a local class (ActivityPerson, ActivityFile, ...) based on the object type.

Parameters

  • DOMElement $element DOM thing to turn into an Activity thing

_fromAuthor

private function _fromAuthor($element)

Create an activity object given an element

Parameters

  • element

_fromAtomEntry

private function _fromAtomEntry($element)

Create an activity object given an element

Parameters

  • element

_fromRssItem

private function _fromRssItem($item)

Create an activity object from a RSS item

Parameters

  • item

Todo

  • rationalize with Activity::_fromRssItem()

fromRssAuthor

public static function fromRssAuthor($el)

Parameters

  • el

Returns

  • ActivityObject object

fromDcCreator

public static function fromDcCreator($el)

Parameters

  • el

Returns

  • ActivityObject

fromRssChannel

public static function fromRssChannel($el)

Parameters

  • el

Returns

  • ActivityObject

fromPosterousAuthor

public static function fromPosterousAuthor($el)

Parameters

  • el

Returns

  • ActivityObject obj

_childContent

private function _childContent($element,  
$tag,  
$namespace = ActivityUtils::ATOM)

Parameters

  • element
  • tag
  • namespace

Returns

  • content of child

_getSource

private function _getSource($element)

Try to get a unique id for the source feed

Parameters

  • element

Returns

  • link to child if exists, NULL if not

fromGroup

static function fromGroup(User_group $group)

Parameters

  • User_group group

Returns

  • ActivityObject object

fromPeopletag

static function fromPeopletag($ptag)

Parameters

  • tag ptag

Returns

  • ActivityObject object

fromFile

static function fromFile(File $file)

Parameters

  • File file

Returns

  • ActivityObject object

fromNoticeSource

static function fromNoticeSource(Notice_source $source)

Parameters

  • Notice_source source

Returns

  • ActivityObject object

fromMessage

static function fromMessage(Message $message)

Parameters

  • Message message

Returns

  • ActivityObject object

outputTo

function outputTo($xo,  
$tag = 'activity:object')

Parameters

  • xo
  • tag

Returns: void

asString

function asString($tag = 'activity:object')

Returns the ActivityObject as an XML string

Parameters

  • tag - default: “activity:object”

Returns

  • string

asArray

function asArray()

Returns an array based on this Activity Object suitable for encoding as JSON.

Returns

  • array $object the activity object array

getIdentifiers

public function getIdentifiers()

Returns

  • array

canonicalType:

Parameters

  • type

Returns

  • string URI

mimeTypeToObjectType

static function mimeTypeToObjectType($mimeType)

Parameters

  • string mimeType

Returns

  • string ot
function __construct($element =  null)
Class constructor
private function _fromAuthor($element)
Create an activity object given an element
private function _fromAtomEntry($element)
Create an activity object given an element
private function _fromRssItem($item)
Create an activity object from a RSS item
public static function fromRssAuthor($el)
public static function fromDcCreator($el)
public static function fromRssChannel($el)
public static function fromPosterousAuthor($el)
private function _childContent($element,  
$tag,  
$namespace = ActivityUtils::ATOM)
private function _getSource($element)
Try to get a unique id for the source feed
static function fromGroup(User_group $group)
static function fromPeopletag($ptag)
static function fromFile(File $file)
static function fromNoticeSource(Notice_source $source)
static function fromMessage(Message $message)
function outputTo($xo,  
$tag = 'activity:object')
function asString($tag = 'activity:object')
Returns the ActivityObject as an XML string
function asArray()
Returns an array based on this Activity Object suitable for encoding as JSON.
public function getIdentifiers()
static function mimeTypeToObjectType($mimeType)