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

Update Legalpad to use comment transactions

Summary: Updates Legalpad to use comment transactions

Test Plan: Leave some comments.

Reviewers: epriestley

Reviewed By: epriestley

Subscribers: Korvin

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

+9 -102
-2
src/__phutil_library_map__.php
··· 1404 1404 'LegalpadDefaultViewCapability' => 'applications/legalpad/capability/LegalpadDefaultViewCapability.php', 1405 1405 'LegalpadDocument' => 'applications/legalpad/storage/LegalpadDocument.php', 1406 1406 'LegalpadDocumentBody' => 'applications/legalpad/storage/LegalpadDocumentBody.php', 1407 - 'LegalpadDocumentCommentController' => 'applications/legalpad/controller/LegalpadDocumentCommentController.php', 1408 1407 'LegalpadDocumentDatasource' => 'applications/legalpad/typeahead/LegalpadDocumentDatasource.php', 1409 1408 'LegalpadDocumentDoneController' => 'applications/legalpad/controller/LegalpadDocumentDoneController.php', 1410 1409 'LegalpadDocumentEditController' => 'applications/legalpad/controller/LegalpadDocumentEditController.php', ··· 6436 6435 'LegalpadDAO', 6437 6436 'PhabricatorMarkupInterface', 6438 6437 ), 6439 - 'LegalpadDocumentCommentController' => 'LegalpadController', 6440 6438 'LegalpadDocumentDatasource' => 'PhabricatorTypeaheadDatasource', 6441 6439 'LegalpadDocumentDoneController' => 'LegalpadController', 6442 6440 'LegalpadDocumentEditController' => 'LegalpadController',
-1
src/applications/legalpad/application/PhabricatorLegalpadApplication.php
··· 57 57 => 'LegalpadDocumentListController', 58 58 $this->getEditRoutePattern('edit/') 59 59 => 'LegalpadDocumentEditController', 60 - 'comment/(?P<id>\d+)/' => 'LegalpadDocumentCommentController', 61 60 'view/(?P<id>\d+)/' => 'LegalpadDocumentManageController', 62 61 'done/' => 'LegalpadDocumentDoneController', 63 62 'verify/(?P<code>[^/]+)/'
-72
src/applications/legalpad/controller/LegalpadDocumentCommentController.php
··· 1 - <?php 2 - 3 - final class LegalpadDocumentCommentController extends LegalpadController { 4 - 5 - public function handleRequest(AphrontRequest $request) { 6 - $viewer = $request->getViewer(); 7 - $id = $request->getURIData('id'); 8 - 9 - if (!$request->isFormPost()) { 10 - return new Aphront400Response(); 11 - } 12 - 13 - $document = id(new LegalpadDocumentQuery()) 14 - ->setViewer($viewer) 15 - ->withIDs(array($id)) 16 - ->needDocumentBodies(true) 17 - ->executeOne(); 18 - 19 - if (!$document) { 20 - return new Aphront404Response(); 21 - } 22 - 23 - $is_preview = $request->isPreviewRequest(); 24 - 25 - $draft = PhabricatorDraft::buildFromRequest($request); 26 - 27 - $document_uri = $this->getApplicationURI('view/'.$document->getID()); 28 - 29 - $comment = $request->getStr('comment'); 30 - 31 - $xactions = array(); 32 - 33 - if (strlen($comment)) { 34 - $xactions[] = id(new LegalpadTransaction()) 35 - ->setTransactionType(PhabricatorTransactions::TYPE_COMMENT) 36 - ->attachComment( 37 - id(new LegalpadTransactionComment()) 38 - ->setDocumentID($document->getID()) 39 - ->setLineNumber(0) 40 - ->setLineLength(0) 41 - ->setContent($comment)); 42 - } 43 - 44 - $editor = id(new LegalpadDocumentEditor()) 45 - ->setActor($viewer) 46 - ->setContentSourceFromRequest($request) 47 - ->setContinueOnNoEffect($request->isContinueRequest()) 48 - ->setIsPreview($is_preview); 49 - 50 - try { 51 - $xactions = $editor->applyTransactions($document, $xactions); 52 - } catch (PhabricatorApplicationTransactionNoEffectException $ex) { 53 - return id(new PhabricatorApplicationTransactionNoEffectResponse()) 54 - ->setCancelURI($document_uri) 55 - ->setException($ex); 56 - } 57 - 58 - if ($draft) { 59 - $draft->replaceOrDelete(); 60 - } 61 - 62 - if ($request->isAjax() && $is_preview) { 63 - return id(new PhabricatorApplicationTransactionResponse()) 64 - ->setViewer($viewer) 65 - ->setTransactions($xactions) 66 - ->setIsPreview($is_preview); 67 - } else { 68 - return id(new AphrontRedirectResponse())->setURI($document_uri); 69 - } 70 - } 71 - 72 - }
+9 -27
src/applications/legalpad/controller/LegalpadDocumentManageController.php
··· 37 37 $document, 38 38 new LegalpadTransactionQuery(), 39 39 $engine); 40 + $timeline->setQuoteRef($document->getMonogram()); 40 41 41 42 $title = $document_body->getTitle(); 42 43 ··· 50 51 $properties = $this->buildPropertyView($document, $engine); 51 52 $document_view = $this->buildDocumentView($document, $engine); 52 53 53 - $comment_form_id = celerity_generate_unique_node_id(); 54 - 55 - $add_comment = $this->buildAddCommentView($document, $comment_form_id); 54 + $comment_form = $this->buildCommentView($document, $timeline); 56 55 57 56 $crumbs = $this->buildApplicationCrumbs(); 58 57 $crumbs->addTextCrumb( ··· 69 68 $properties, 70 69 $document_view, 71 70 $timeline, 72 - $add_comment, 71 + $comment_form, 73 72 )); 74 73 75 74 return $this->newPage() ··· 181 180 ->setBackground(PHUIObjectBoxView::BLUE_PROPERTY); 182 181 } 183 182 184 - private function buildAddCommentView( 185 - LegalpadDocument $document, 186 - $comment_form_id) { 183 + private function buildCommentView(LegalpadDocument $document, $timeline) { 187 184 $viewer = $this->getViewer(); 185 + $box = id(new LegalpadDocumentEditEngine()) 186 + ->setViewer($viewer) 187 + ->buildEditEngineCommentView($document) 188 + ->setTransactionTimeline($timeline); 188 189 189 - $draft = PhabricatorDraft::newFromUserAndKey($viewer, $document->getPHID()); 190 - 191 - $is_serious = PhabricatorEnv::getEnvConfig('phabricator.serious-business'); 192 - 193 - $title = $is_serious 194 - ? pht('Add Comment') 195 - : pht('Debate Legislation'); 196 - 197 - $form = id(new PhabricatorApplicationTransactionCommentView()) 198 - ->setUser($viewer) 199 - ->setObjectPHID($document->getPHID()) 200 - ->setFormID($comment_form_id) 201 - ->setHeaderText($title) 202 - ->setDraft($draft) 203 - ->setSubmitButtonName(pht('Add Comment')) 204 - ->setAction($this->getApplicationURI('/comment/'.$document->getID().'/')) 205 - ->setRequestURI($this->getRequest()->getRequestURI()); 206 - 207 - return $form; 208 - 190 + return $box; 209 191 } 210 192 211 193 }