[ Index ] |
PHP Cross Reference of Phabricator |
[Summary view] [Print] [Text view]
1 <?php 2 3 final class PhameBlogFeedController extends PhameController { 4 5 private $id; 6 7 public function shouldRequireLogin() { 8 return false; 9 } 10 11 public function willProcessRequest(array $data) { 12 $this->id = $data['id']; 13 } 14 15 public function processRequest() { 16 $request = $this->getRequest(); 17 $user = $request->getUser(); 18 19 $blog = id(new PhameBlogQuery()) 20 ->setViewer($user) 21 ->withIDs(array($this->id)) 22 ->executeOne(); 23 if (!$blog) { 24 return new Aphront404Response(); 25 } 26 27 $posts = id(new PhamePostQuery()) 28 ->setViewer($user) 29 ->withBlogPHIDs(array($blog->getPHID())) 30 ->withVisibility(PhamePost::VISIBILITY_PUBLISHED) 31 ->execute(); 32 33 $blog_uri = PhabricatorEnv::getProductionURI( 34 $this->getApplicationURI('blog/feed/'.$blog->getID().'/')); 35 $content = array(); 36 $content[] = phutil_tag('title', array(), $blog->getName()); 37 $content[] = phutil_tag('id', array(), $blog_uri); 38 $content[] = phutil_tag('link', 39 array( 40 'rel' => 'self', 41 'type' => 'application/atom+xml', 42 'href' => $blog_uri, 43 )); 44 45 $updated = $blog->getDateModified(); 46 if ($posts) { 47 $updated = max($updated, max(mpull($posts, 'getDateModified'))); 48 } 49 $content[] = phutil_tag('updated', array(), date('c', $updated)); 50 51 $description = $blog->getDescription(); 52 if ($description != '') { 53 $content[] = phutil_tag('subtitle', array(), $description); 54 } 55 56 $engine = id(new PhabricatorMarkupEngine())->setViewer($user); 57 foreach ($posts as $post) { 58 $engine->addObject($post, PhamePost::MARKUP_FIELD_BODY); 59 } 60 $engine->process(); 61 62 $blogger_phids = mpull($posts, 'getBloggerPHID'); 63 $bloggers = id(new PhabricatorHandleQuery()) 64 ->setViewer($user) 65 ->withPHIDs($blogger_phids) 66 ->execute(); 67 68 foreach ($posts as $post) { 69 $content[] = hsprintf('<entry>'); 70 $content[] = phutil_tag('title', array(), $post->getTitle()); 71 $content[] = phutil_tag('link', array('href' => $post->getViewURI())); 72 73 $content[] = phutil_tag('id', array(), PhabricatorEnv::getProductionURI( 74 '/phame/post/view/'.$post->getID().'/')); 75 76 $content[] = hsprintf( 77 '<author><name>%s</name></author>', 78 $bloggers[$post->getBloggerPHID()]->getFullName()); 79 80 $content[] = phutil_tag( 81 'updated', 82 array(), 83 date('c', $post->getDateModified())); 84 85 $content[] = hsprintf( 86 '<content type="xhtml">'. 87 '<div xmlns="http://www.w3.org/1999/xhtml">%s</div>'. 88 '</content>', 89 $engine->getOutput($post, PhamePost::MARKUP_FIELD_BODY)); 90 91 $content[] = hsprintf('</entry>'); 92 } 93 94 $content = phutil_tag( 95 'feed', 96 array('xmlns' => 'http://www.w3.org/2005/Atom'), 97 $content); 98 99 return id(new AphrontFileResponse()) 100 ->setMimeType('application/xml') 101 ->setContent($content); 102 } 103 104 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Sun Nov 30 09:20:46 2014 | Cross-referenced by PHPXref 0.7.1 |