/** * Called when generating Atom XML ActivityStreams output from an * ActivityObject belonging to this plugin. Gives the plugin * a chance to add custom output. * * Note that you can only add output of additional XML elements, * not change existing stuff here. * * If output is already handled by the base Activity classes, * you can leave this base implementation as a no-op. * * @param ActivityObject $obj * @param XMLOutputter $out to add elements at end of object */ function activityObjectOutputAtom(ActivityObject $obj, XMLOutputter $out) { if (isset($obj->pollQuestion)) { /** * <poll:poll xmlns:poll="http://apinamespace.org/activitystreams/object/poll"> * <poll:question>Who wants a poll question?</poll:question> * <poll:option>Option one</poll:option> * <poll:option>Option two</poll:option> * <poll:option>Option three</poll:option> * </poll:poll> */ $data = array('xmlns:poll' => self::POLL_OBJECT); $out->elementStart('poll:poll', $data); $out->element('poll:question', array(), $obj->pollQuestion); foreach ($obj->pollOptions as $opt) { $out->element('poll:option', array(), $opt); } $out->elementEnd('poll:poll'); } if (isset($obj->pollSelection)) { /** * <poll:response xmlns:poll="http://apinamespace.org/activitystreams/object/poll"> * poll="http://..../poll/...." * selection="3" /> */ $data = array('xmlns:poll' => self::POLL_OBJECT, 'poll' => $obj->pollUri, 'selection' => $obj->pollSelection); $out->element('poll:response', $data, ''); } }