Example #1
0
 public function export(WriterResult $result)
 {
     switch ($result->getType()) {
         case WriterInterface::ATOM:
             $entry = $result->getWriter()->createEntry();
             $entry->setTitle(Util::stripAndTruncateHtml($this->text));
             $entry->setId('urn:uuid:' . $this->globalId);
             $entry->setUpdated($this->getDate());
             $entry->addAuthor($this->authorName, $this->authorProfileUrl);
             $entry->setContent($this->text, 'html');
             return $entry;
             break;
         case WriterInterface::JAS:
             $image = new ActivityStream\MediaLink();
             $image->setUrl($this->authorThumbnailUrl);
             $actor = new ActivityStream\Object();
             $actor->setObjectType('person');
             $actor->setDisplayName($this->authorName);
             $actor->setUrl($this->authorProfileUrl);
             $actor->setImage($image);
             $object = new ActivityStream\Object();
             $object->setObjectType('comment');
             $object->setId('urn:uuid:' . $this->globalId);
             $object->setDisplayName(Util::stripAndTruncateHtml($this->text));
             $object->setPublished($this->getDate());
             $object->setContent($this->text);
             $activity = new ActivityStream\Activity();
             $activity->setActor($actor);
             $activity->setVerb('post');
             $activity->setObject($object);
             return $activity;
             break;
         default:
             return parent::export($result);
             break;
     }
 }
Example #2
0
 public function export(WriterResult $result)
 {
     switch ($result->getType()) {
         case WriterInterface::ATOM:
             $entry = $result->getWriter()->createEntry();
             $entry->setTitle(Util::stripAndTruncateHtml($this->summary));
             $entry->setId('urn:uuid:' . $this->globalId);
             $entry->setUpdated($this->getDate());
             $entry->addAuthor($this->authorName, 'urn:uuid:' . $this->authorGlobalId);
             $entry->setContent($this->summary, 'html');
             if ($this->parentId > 0) {
                 $writer = $result->getWriter()->writer;
                 $parent = $this->_table->select(array('id', 'globalId', 'date'))->where('id', '=', $this->parentId)->getRow();
                 $writer->startElementNS('thr', 'in-reply-to', 'http://purl.org/syndication/thread/1.0');
                 $writer->writeAttribute('ref', 'urn:uuid:' . $parent['globalId']);
                 $writer->endElement();
             }
             return $entry;
             break;
         case WriterInterface::JAS:
             $object = $this->getObject();
             if (empty($object)) {
                 $image = new ActivityStream\MediaLink();
                 $image->setUrl($this->authorThumbnailUrl);
                 $actor = new ActivityStream\Object();
                 $actor->setObjectType('person');
                 $actor->setDisplayName($this->authorName);
                 $actor->setUrl($this->authorProfileUrl);
                 $actor->setImage($image);
                 $object = new ActivityStream\Object();
                 $object->setObjectType('note');
                 $object->setId('urn:uuid:' . $this->globalId);
                 $object->setDisplayName(Util::stripAndTruncateHtml($this->summary));
                 $object->setPublished($this->getDate());
                 $object->setContent($this->summary);
                 $activity = new ActivityStream\Activity();
                 $activity->setActor($actor);
                 $activity->setVerb('post');
                 $activity->setObject($object);
                 return $activity;
             } else {
                 return $object;
             }
             break;
         default:
             return parent::export($result);
             break;
     }
 }