@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
fork

Configure Feed

Select the types of activity you want to include in your feed.

Use AphrontDialog for New/Move Phame Posts

Summary: Moves New Post and Move Post to be separate Controllers with Dialogs. Ref T9897

Test Plan: Move a post to a new blog, see message and see post. Click New Post, get dialog, pick blog, edit new post.

Reviewers: epriestley

Reviewed By: epriestley

Subscribers: Korvin

Maniphest Tasks: T9897

Differential Revision: https://secure.phabricator.com/D14698

+110 -73
+2
src/__phutil_library_map__.php
··· 3338 3338 'PhamePostListController' => 'applications/phame/controller/post/PhamePostListController.php', 3339 3339 'PhamePostListView' => 'applications/phame/view/PhamePostListView.php', 3340 3340 'PhamePostMailReceiver' => 'applications/phame/mail/PhamePostMailReceiver.php', 3341 + 'PhamePostMoveController' => 'applications/phame/controller/post/PhamePostMoveController.php', 3341 3342 'PhamePostNewController' => 'applications/phame/controller/post/PhamePostNewController.php', 3342 3343 'PhamePostNotLiveController' => 'applications/phame/controller/post/PhamePostNotLiveController.php', 3343 3344 'PhamePostPreviewController' => 'applications/phame/controller/post/PhamePostPreviewController.php', ··· 7687 7688 'PhamePostListController' => 'PhamePostController', 7688 7689 'PhamePostListView' => 'AphrontTagView', 7689 7690 'PhamePostMailReceiver' => 'PhabricatorObjectMailReceiver', 7691 + 'PhamePostMoveController' => 'PhamePostController', 7690 7692 'PhamePostNewController' => 'PhamePostController', 7691 7693 'PhamePostNotLiveController' => 'PhamePostController', 7692 7694 'PhamePostPreviewController' => 'PhamePostController',
+1 -1
src/applications/phame/application/PhabricatorPhameApplication.php
··· 54 54 'preview/' => 'PhabricatorMarkupPreviewController', 55 55 'framed/(?P<id>\d+)/' => 'PhamePostFramedController', 56 56 'new/' => 'PhamePostNewController', 57 - 'move/(?P<id>\d+)/' => 'PhamePostNewController', 57 + 'move/(?P<id>\d+)/' => 'PhamePostMoveController', 58 58 'comment/(?P<id>[1-9]\d*)/' => 'PhamePostCommentController', 59 59 ), 60 60 'blog/' => array(
+7
src/applications/phame/controller/PhameHomeController.php
··· 86 86 87 87 $crumbs->addAction( 88 88 id(new PHUIListItemView()) 89 + ->setName(pht('New Post')) 90 + ->setHref($this->getApplicationURI('/post/new/')) 91 + ->setIcon('fa-plus-square') 92 + ->setWorkflow(true)); 93 + 94 + $crumbs->addAction( 95 + id(new PHUIListItemView()) 89 96 ->setName(pht('New Blog')) 90 97 ->setHref($this->getApplicationURI('/blog/new/')) 91 98 ->setIcon('fa-plus-square')
+78
src/applications/phame/controller/post/PhamePostMoveController.php
··· 1 + <?php 2 + 3 + final class PhamePostMoveController extends PhamePostController { 4 + 5 + public function handleRequest(AphrontRequest $request) { 6 + $viewer = $request->getViewer(); 7 + $id = $request->getURIData('id'); 8 + 9 + $post = id(new PhamePostQuery()) 10 + ->setViewer($viewer) 11 + ->withIDs(array($id)) 12 + ->requireCapabilities( 13 + array( 14 + PhabricatorPolicyCapability::CAN_EDIT, 15 + PhabricatorPolicyCapability::CAN_VIEW, 16 + )) 17 + ->executeOne(); 18 + 19 + if (!$post) { 20 + return new Aphront404Response(); 21 + } 22 + 23 + $view_uri = '/post/view/'.$post->getID().'/'; 24 + $view_uri = $this->getApplicationURI($view_uri); 25 + 26 + if ($request->isFormPost()) { 27 + $blog = id(new PhameBlogQuery()) 28 + ->setViewer($viewer) 29 + ->withIDs(array($request->getInt('blog'))) 30 + ->requireCapabilities( 31 + array( 32 + PhabricatorPolicyCapability::CAN_EDIT, 33 + )) 34 + ->executeOne(); 35 + 36 + if ($blog) { 37 + $post->setBlogPHID($blog->getPHID()); 38 + $post->save(); 39 + 40 + return id(new AphrontRedirectResponse()) 41 + ->setURI($view_uri.'?moved=1'); 42 + } 43 + } 44 + 45 + $blogs = id(new PhameBlogQuery()) 46 + ->setViewer($viewer) 47 + ->requireCapabilities( 48 + array( 49 + PhabricatorPolicyCapability::CAN_EDIT, 50 + )) 51 + ->execute(); 52 + 53 + $options = mpull($blogs, 'getName', 'getID'); 54 + asort($options); 55 + 56 + $selected_value = null; 57 + if ($post && $post->getBlog()) { 58 + $selected_value = $post->getBlog()->getID(); 59 + } 60 + 61 + $form = id(new PHUIFormLayoutView()) 62 + ->setUser($viewer) 63 + ->appendChild( 64 + id(new AphrontFormSelectControl()) 65 + ->setLabel(pht('Blog')) 66 + ->setName('blog') 67 + ->setOptions($options) 68 + ->setValue($selected_value)); 69 + 70 + return $this->newDialog() 71 + ->setTitle(pht('Move Post')) 72 + ->appendChild($form) 73 + ->addSubmitButton(pht('Move Post')) 74 + ->addCancelButton($view_uri); 75 + 76 + } 77 + 78 + }
+12 -69
src/applications/phame/controller/post/PhamePostNewController.php
··· 4 4 5 5 public function handleRequest(AphrontRequest $request) { 6 6 $viewer = $request->getViewer(); 7 - $id = $request->getURIData('id'); 7 + $id = $request->getInt('blog'); 8 8 9 - $post = null; 10 - $view_uri = null; 11 9 if ($id) { 12 - $post = id(new PhamePostQuery()) 10 + $blog = id(new PhameBlogQuery()) 13 11 ->setViewer($viewer) 14 12 ->withIDs(array($id)) 15 13 ->requireCapabilities( ··· 17 15 PhabricatorPolicyCapability::CAN_EDIT, 18 16 )) 19 17 ->executeOne(); 20 - if (!$post) { 18 + if (!$blog) { 21 19 return new Aphront404Response(); 22 20 } 23 21 24 - $view_uri = '/post/view/'.$post->getID().'/'; 22 + $view_uri = '/post/edit/?blog='.$blog->getID(); 25 23 $view_uri = $this->getApplicationURI($view_uri); 26 24 27 - if ($request->isFormPost()) { 28 - $blog = id(new PhameBlogQuery()) 29 - ->setViewer($viewer) 30 - ->withIDs(array($request->getInt('blog'))) 31 - ->requireCapabilities( 32 - array( 33 - PhabricatorPolicyCapability::CAN_EDIT, 34 - )) 35 - ->executeOne(); 36 - 37 - if ($blog) { 38 - $post->setBlogPHID($blog->getPHID()); 39 - $post->save(); 40 - 41 - return id(new AphrontRedirectResponse())->setURI($view_uri); 42 - } 43 - } 44 - 45 - $title = pht('Move Post'); 46 - } else { 47 - $title = pht('Create Post'); 48 - $view_uri = $this->getApplicationURI('/post/new'); 25 + return id(new AphrontRedirectResponse())->setURI($view_uri); 49 26 } 50 27 51 28 $blogs = id(new PhameBlogQuery()) ··· 56 33 )) 57 34 ->execute(); 58 35 59 - $crumbs = $this->buildApplicationCrumbs(); 60 - $crumbs->addTextCrumb($title, $view_uri); 61 - 62 - $notification = null; 63 - $form_box = null; 64 36 if (!$blogs) { 65 - $notification = id(new PHUIInfoView()) 37 + $form = id(new PHUIInfoView()) 66 38 ->setSeverity(PHUIInfoView::SEVERITY_NODATA) 67 39 ->appendChild( 68 40 pht('You do not have permission to post to any blogs. Create a blog '. ··· 72 44 $options = mpull($blogs, 'getName', 'getID'); 73 45 asort($options); 74 46 75 - $selected_value = null; 76 - if ($post && $post->getBlog()) { 77 - $selected_value = $post->getBlog()->getID(); 78 - } 79 - 80 - $form = id(new AphrontFormView()) 47 + $form = id(new PHUIFormLayoutView()) 81 48 ->setUser($viewer) 82 49 ->appendChild( 83 50 id(new AphrontFormSelectControl()) 84 51 ->setLabel(pht('Blog')) 85 52 ->setName('blog') 86 - ->setOptions($options) 87 - ->setValue($selected_value)); 88 - 89 - if ($post) { 90 - $form 91 - ->appendChild( 92 - id(new AphrontFormSubmitControl()) 93 - ->setValue(pht('Move Post')) 94 - ->addCancelButton($view_uri)); 95 - } else { 96 - $form 97 - ->setAction($this->getApplicationURI('post/edit/')) 98 - ->setMethod('GET') 99 - ->appendChild( 100 - id(new AphrontFormSubmitControl()) 101 - ->setValue(pht('Continue'))); 102 - } 103 - 104 - $form_box = id(new PHUIObjectBoxView()) 105 - ->setHeaderText($title) 106 - ->setForm($form); 53 + ->setOptions($options)); 107 54 } 108 55 109 - return $this->newPage() 110 - ->setTitle($title) 111 - ->setCrumbs($crumbs) 112 - ->appendChild( 113 - array( 114 - $notification, 115 - $form_box, 116 - )); 56 + return $this->newDialog() 57 + ->setTitle(pht('New Post')) 58 + ->appendChild($form) 59 + ->addSubmitButton(pht('Continue')); 117 60 118 61 } 119 62
+10 -3
src/applications/phame/controller/post/PhamePostViewController.php
··· 8 8 9 9 public function handleRequest(AphrontRequest $request) { 10 10 $viewer = $request->getViewer(); 11 + $moved = $request->getStr('moved'); 11 12 12 13 $post = id(new PhamePostQuery()) 13 14 ->setViewer($viewer) ··· 56 57 57 58 $document = id(new PHUIDocumentViewPro()) 58 59 ->setHeader($header); 60 + 61 + if ($moved) { 62 + $document->appendChild( 63 + id(new PHUIInfoView()) 64 + ->setSeverity(PHUIInfoView::SEVERITY_NOTICE) 65 + ->appendChild(pht('Post moved successfully.'))); 66 + } 59 67 60 68 if ($post->isDraft()) { 61 69 $document->appendChild( ··· 169 177 ->setIcon('fa-pencil') 170 178 ->setHref($this->getApplicationURI('post/edit/'.$id.'/')) 171 179 ->setName(pht('Edit Post')) 172 - ->setDisabled(!$can_edit) 173 - ->setWorkflow(!$can_edit)); 180 + ->setDisabled(!$can_edit)); 174 181 175 182 $actions->addAction( 176 183 id(new PhabricatorActionView()) ··· 178 185 ->setHref($this->getApplicationURI('post/move/'.$id.'/')) 179 186 ->setName(pht('Move Post')) 180 187 ->setDisabled(!$can_edit) 181 - ->setWorkflow(!$can_edit)); 188 + ->setWorkflow(true)); 182 189 183 190 $actions->addAction( 184 191 id(new PhabricatorActionView())