示例#1
0
文件: Index.php 项目: visapi/amun
 protected function setWriterConfig(WriterResult $writer)
 {
     switch ($writer->getType()) {
         case WriterInterface::ATOM:
             throw new Exception('Atom not supported');
             break;
     }
 }
示例#2
0
文件: Index.php 项目: visapi/amun
 protected function setWriterConfig(WriterResult $writer)
 {
     switch ($writer->getType()) {
         case WriterInterface::ATOM:
             $updated = $this->getSql()->getField('SELECT `date` FROM ' . $this->registry['table.forum'] . ' ORDER BY `date` DESC LIMIT 1');
             $title = 'Forum';
             $id = 'urn:uuid:' . $this->base->getUUID('forum');
             $updated = new DateTime($updated, $this->registry['core.default_timezone']);
             $writer = $writer->getWriter();
             $writer->setConfig($title, $id, $updated);
             $writer->setGenerator('amun ' . Base::getVersion());
             if (!empty($this->config['amun_hub'])) {
                 $writer->addLink($this->config['amun_hub'], 'hub');
             }
             break;
     }
 }
示例#3
0
文件: People.php 项目: visapi/amun
 public function export(WriterResult $result)
 {
     switch ($result->getType()) {
         case WriterInterface::JSON:
         case WriterInterface::XML:
             return parent::export($result);
             break;
         case WriterInterface::ATOM:
             $entry = $result->getWriter()->createEntry();
             $entry->setTitle($this->friendName);
             $entry->setId('urn:uuid:' . $this->friendGlobalId);
             $entry->setUpdated($this->getDate());
             $entry->addAuthor($this->authorName, $this->authorProfileUrl);
             $entry->addLink($this->friendProfileUrl, 'alternate', 'text/html');
             $entry->setContent($this, 'application/xml');
             return $entry;
             break;
         default:
             throw new Exception('Writer is not supported');
             break;
     }
 }
示例#4
0
文件: Record.php 项目: visapi/amun
 public function export(WriterResult $result)
 {
     switch ($result->getType()) {
         case WriterInterface::ATOM:
             $entry = $result->getWriter()->createEntry();
             $entry->setTitle($this->title);
             $entry->setId('urn:uuid:' . $this->globalId);
             $entry->setUpdated($this->getDate());
             $entry->addAuthor($this->authorName, $this->authorProfileUrl);
             $entry->addLink($this->getUrl(), 'alternate', 'text/html');
             $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('article');
             $object->setId('urn:uuid:' . $this->globalId);
             $object->setDisplayName($this->title);
             $object->setUrl($this->getUrl());
             $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;
     }
 }
示例#5
0
文件: Record.php 项目: visapi/amun
 public function export(WriterResult $result)
 {
     switch ($result->getType()) {
         case WriterInterface::ATOM:
             $entry = $result->getWriter()->createEntry();
             $entry->setTitle($this->title);
             $entry->setId('urn:uuid:' . $this->globalId);
             $entry->setUpdated($this->getDate());
             $entry->addAuthor('System');
             $entry->addLink($this->getUrl(), 'alternate', 'text/html');
             $entry->setContent($this, 'application/xml');
             return $entry;
             break;
         default:
             return parent::export($result);
             break;
     }
 }
示例#6
0
文件: Record.php 项目: visapi/amun
 public function export(WriterResult $result)
 {
     switch ($result->getType()) {
         case WriterInterface::JSON:
         case WriterInterface::XML:
             return parent::export($result);
             break;
         case WriterInterface::ATOM:
             $entry = $result->getWriter()->createEntry();
             $entry->setTitle('Revision ' . $this->revision . ': ' . $this->message);
             $entry->setId('urn:uuid:' . $this->globalId);
             $entry->setUpdated($this->getCommitDate());
             $entry->addAuthor($this->getAuthor()->name);
             $entry->addLink($this->url, 'alternate', 'text/html');
             return $entry;
             break;
         default:
             throw new Exception('Writer is not supported');
             break;
     }
 }
示例#7
0
文件: Record.php 项目: visapi/amun
 public function export(WriterResult $result)
 {
     switch ($result->getType()) {
         case WriterInterface::JSON:
         case WriterInterface::XML:
             return parent::export($result);
             break;
         case WriterInterface::ATOM:
             $entry = $result->getWriter()->createEntry();
             $entry->setTitle($this->title);
             $entry->setId('urn:uuid:' . $this->_base->getUUID('system:api:' . $this->id));
             $entry->setUpdated($this->getDate());
             $entry->addAuthor('System');
             $entry->addLink($this->url, 'alternate', 'text/html');
             $entry->setContent($this->description, 'text');
             return $entry;
             break;
         default:
             throw new Exception('Writer is not supported');
             break;
     }
 }
示例#8
0
文件: Record.php 项目: visapi/amun
 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;
     }
 }
示例#9
0
文件: Activity.php 项目: visapi/amun
 protected function setWriterConfig(WriterResult $writer)
 {
     switch ($writer->getType()) {
         case WriterInterface::ATOM:
             $account = $this->getHandler('AmunService\\User\\Account')->getOneById($this->userId, array('id', 'globalId', 'name', 'profileUrl', 'thumbnailUrl', 'updated'), Sql::FETCH_OBJECT);
             if ($account instanceof Account\Record) {
                 $writer = $writer->getWriter();
                 $writer->setConfig($account->name . ' activities', 'urn:uuid:' . $account->globalId, $account->getUpdated());
                 $writer->setGenerator('amun ' . Base::getVersion());
                 $writer->addAuthor($account->name, $account->profileUrl);
                 $writer->addLink($account->profileUrl, 'alternate', 'text/html');
                 $writer->addLink($account->thumbnailUrl, 'avatar');
                 $writer->setLogo($account->thumbnailUrl);
                 if (!empty($this->config['amun_hub'])) {
                     $writer->addLink($this->config['amun_hub'], 'hub');
                 }
             } else {
                 throw new Exception('Invalid user account');
             }
             break;
     }
 }