@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.)
hq.recaptime.dev/wiki/Phorge
phorge
phabricator
1<?php
2
3final class PhamePostEditController extends PhamePostController {
4
5 private $blog;
6
7 public function setBlog(PhameBlog $blog) {
8 $this->blog = $blog;
9 return $this;
10 }
11
12 public function getBlog() {
13 return $this->blog;
14 }
15
16 public function handleRequest(AphrontRequest $request) {
17 $viewer = $request->getViewer();
18 $id = $request->getURIData('id');
19
20 if ($id) {
21 $post = id(new PhamePostQuery())
22 ->setViewer($viewer)
23 ->withIDs(array($id))
24 ->executeOne();
25 if (!$post) {
26 return new Aphront404Response();
27 }
28 $blog = $post->getBlog();
29 } else {
30 $blog_id = head($request->getArr('blog'));
31 if (!$blog_id) {
32 $blog_id = $request->getStr('blog');
33 }
34
35 $query = id(new PhameBlogQuery())
36 ->setViewer($viewer)
37 ->requireCapabilities(
38 array(
39 PhabricatorPolicyCapability::CAN_VIEW,
40 PhabricatorPolicyCapability::CAN_EDIT,
41 ));
42
43 if (ctype_digit($blog_id)) {
44 $query->withIDs(array($blog_id));
45 } else {
46 $query->withPHIDs(array($blog_id));
47 }
48
49 $blog = $query->executeOne();
50 if (!$blog) {
51 return new Aphront404Response();
52 }
53 }
54
55 $this->setBlog($blog);
56
57 return id(new PhamePostEditEngine())
58 ->setController($this)
59 ->setBlog($blog)
60 ->buildResponse();
61 }
62
63 protected function buildApplicationCrumbs() {
64 $crumbs = parent::buildApplicationCrumbs();
65
66 $blog = $this->getBlog();
67 if ($blog) {
68 $crumbs->addTextCrumb(
69 $blog->getName(),
70 $blog->getViewURI());
71 }
72
73 return $crumbs;
74 }
75
76
77}