示例#1
0
文件: Index.php 项目: visapi/amun
 protected function buildAccount(DocumentAbstract $document, Account\Record $account)
 {
     // subject
     $subject = $account->name . '@' . $this->base->getHost();
     $document->setSubject($subject);
     // alias
     $document->setAliases(array($account->profileUrl));
     // id
     $document->addProperty('http://ns.amun-project.org/2011/meta/id', $account->globalId);
     $document->addProperty('http://ns.amun-project.org/2011/meta/name', $account->name);
     $document->addProperty('http://ns.amun-project.org/2011/meta/date', $account->getDate()->format(DateTime::ATOM));
     // profile
     $link = new Link();
     $link->setRel('profile');
     $link->setType('text/html');
     $link->setHref($account->profileUrl);
     $document->addLink($link);
     // activity atom feed
     $href = $this->config['psx_url'] . '/' . $this->config['psx_dispatch'] . 'api/my/activity/' . $account->id . '?format=atom';
     $link = new Link();
     $link->setRel('alternate');
     $link->setType('application/atom+xml');
     $link->setHref($href);
     $document->addLink($link);
     // json activity streams
     $href = $this->config['psx_url'] . '/' . $this->config['psx_dispatch'] . 'api/my/activity/' . $account->id . '?format=jas';
     $link = new Link();
     $link->setRel('alternate');
     $link->setType('application/stream+json');
     $link->setHref($href);
     $document->addLink($link);
 }
示例#2
0
文件: Jrd.php 项目: k42b3/psx-ws
 protected function buildLink(Link $link)
 {
     $row = array('rel' => $link->getRel());
     $type = $link->getType();
     if (!empty($type)) {
         $row['type'] = $type;
     }
     $href = $link->getHref();
     if (!empty($href)) {
         $row['href'] = $href;
     }
     $template = $link->getTemplate();
     if (!empty($template)) {
         $row['template'] = $template;
     }
     $titles = $link->getTitles();
     if (!empty($titles)) {
         $row['titles'] = $titles;
     }
     $properties = $link->getProperties();
     if (!empty($properties)) {
         $row['properties'] = $properties;
     }
     return $row;
 }
示例#3
0
文件: Xrd.php 项目: k42b3/psx-ws
 protected function buildLink(XMLWriter $writer, Link $link)
 {
     $writer->startElement('Link');
     $writer->writeAttribute('rel', $link->getRel());
     $type = $link->getType();
     if (!empty($type)) {
         $writer->writeAttribute('type', $type);
     }
     $href = $link->getHref();
     $template = $link->getTemplate();
     if (!empty($href)) {
         $writer->writeAttribute('href', $href);
     } else {
         if (!empty($template)) {
             $writer->writeAttribute('template', $template);
         }
     }
     $titles = $link->getTitles();
     if (!empty($titles)) {
         foreach ($titles as $lang => $title) {
             if ($lang == 'default') {
                 $writer->writeElement('Title', $title);
             } else {
                 $writer->startElement('Title');
                 $writer->writeAttribute('xml:lang', $lang);
                 $writer->text($title);
                 $writer->endElement();
             }
         }
     }
     $properties = $link->getProperties();
     if (!empty($properties)) {
         foreach ($properties as $type => $value) {
             if ($value === null) {
                 $writer->startElement('Property');
                 $writer->writeAttribute('type', $type);
                 $writer->writeAttribute('xsi:nil', 'true');
                 $writer->endElement();
             } else {
                 $writer->startElement('Property');
                 $writer->writeAttribute('type', $type);
                 $writer->text($value);
                 $writer->endElement();
             }
         }
     }
     $writer->endElement();
 }