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

Calendar event monograms, part 3. Remarkup for calendar event monograms.

Summary: Ref T7928, Calendar event monograms, part 3. Remarkup for calendar event monograms.

Test Plan: Create calendar event, open a maniphest task, add 'E{id}' and preview should show a hovertag for event that links to event.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: Korvin, epriestley

Maniphest Tasks: T7928

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

+94 -4
+3
src/__phutil_library_map__.php
··· 1492 1492 'PhabricatorCalendarEventViewController' => 'applications/calendar/controller/PhabricatorCalendarEventViewController.php', 1493 1493 'PhabricatorCalendarHoliday' => 'applications/calendar/storage/PhabricatorCalendarHoliday.php', 1494 1494 'PhabricatorCalendarHolidayTestCase' => 'applications/calendar/storage/__tests__/PhabricatorCalendarHolidayTestCase.php', 1495 + 'PhabricatorCalendarRemarkupRule' => 'applications/calendar/remarkup/PhabricatorCalendarRemarkupRule.php', 1495 1496 'PhabricatorCalendarViewController' => 'applications/calendar/controller/PhabricatorCalendarViewController.php', 1496 1497 'PhabricatorCampfireProtocolAdapter' => 'infrastructure/daemon/bot/adapter/PhabricatorCampfireProtocolAdapter.php', 1497 1498 'PhabricatorCelerityApplication' => 'applications/celerity/application/PhabricatorCelerityApplication.php', ··· 4799 4800 'PhabricatorCalendarEvent' => array( 4800 4801 'PhabricatorCalendarDAO', 4801 4802 'PhabricatorPolicyInterface', 4803 + 'PhabricatorMarkupInterface', 4802 4804 ), 4803 4805 'PhabricatorCalendarEventDeleteController' => 'PhabricatorCalendarController', 4804 4806 'PhabricatorCalendarEventEditController' => 'PhabricatorCalendarController', ··· 4810 4812 'PhabricatorCalendarEventViewController' => 'PhabricatorCalendarController', 4811 4813 'PhabricatorCalendarHoliday' => 'PhabricatorCalendarDAO', 4812 4814 'PhabricatorCalendarHolidayTestCase' => 'PhabricatorTestCase', 4815 + 'PhabricatorCalendarRemarkupRule' => 'PhabricatorObjectRemarkupRule', 4813 4816 'PhabricatorCalendarViewController' => 'PhabricatorCalendarController', 4814 4817 'PhabricatorCampfireProtocolAdapter' => 'PhabricatorBotBaseStreamingProtocolAdapter', 4815 4818 'PhabricatorCelerityApplication' => 'PhabricatorApplication',
+6
src/applications/calendar/application/PhabricatorCalendarApplication.php
··· 32 32 return true; 33 33 } 34 34 35 + public function getRemarkupRules() { 36 + return array( 37 + new PhabricatorCalendarRemarkupRule(), 38 + ); 39 + } 40 + 35 41 public function getRoutes() { 36 42 return array( 37 43 '/E(?P<id>[1-9]\d*)' => 'PhabricatorCalendarEventViewController',
+5 -1
src/applications/calendar/phid/PhabricatorCalendarEventPHIDType.php
··· 29 29 $event = $objects[$phid]; 30 30 31 31 $id = $event->getID(); 32 + $name = pht('Event %d', $id); 32 33 33 - $handle->setName(pht('Event %d', $id)); 34 + $handle 35 + ->setName(pht('Event %d', $id)) 36 + ->setFullName(pht('E%d: %s', $id, $name)) 37 + ->setURI('/E'.$id); 34 38 } 35 39 } 36 40
+19
src/applications/calendar/remarkup/PhabricatorCalendarRemarkupRule.php
··· 1 + <?php 2 + 3 + final class PhabricatorCalendarRemarkupRule 4 + extends PhabricatorObjectRemarkupRule { 5 + 6 + protected function getObjectNamePrefix() { 7 + return 'E'; 8 + } 9 + 10 + protected function loadObjects(array $ids) { 11 + $viewer = $this->getEngine()->getConfig('viewer'); 12 + 13 + return id(new PhabricatorCalendarEventQuery()) 14 + ->setViewer($viewer) 15 + ->withIDs($ids) 16 + ->execute(); 17 + } 18 + 19 + }
+53 -3
src/applications/calendar/storage/PhabricatorCalendarEvent.php
··· 1 1 <?php 2 2 3 - final class PhabricatorCalendarEvent 4 - extends PhabricatorCalendarDAO 5 - implements PhabricatorPolicyInterface { 3 + final class PhabricatorCalendarEvent extends PhabricatorCalendarDAO 4 + implements PhabricatorPolicyInterface, 5 + PhabricatorMarkupInterface { 6 6 7 7 protected $userPHID; 8 8 protected $dateFrom; ··· 56 56 PhabricatorCalendarEventPHIDType::TYPECONST); 57 57 } 58 58 59 + public function getMonogram() { 60 + return 'E'.$this->getID(); 61 + } 62 + 59 63 public function getTerseSummary(PhabricatorUser $viewer) { 60 64 $until = phabricator_date($this->dateTo, $viewer); 61 65 if ($this->status == PhabricatorCalendarEvent::STATUS_SPORADIC) { ··· 95 99 return parent::save(); 96 100 } 97 101 102 + /* -( Markup Interface )--------------------------------------------------- */ 103 + 104 + 105 + /** 106 + * @task markup 107 + */ 108 + public function getMarkupFieldKey($field) { 109 + $hash = PhabricatorHash::digest($this->getMarkupText($field)); 110 + $id = $this->getID(); 111 + return "calendar:T{$id}:{$field}:{$hash}"; 112 + } 113 + 114 + 115 + /** 116 + * @task markup 117 + */ 118 + public function getMarkupText($field) { 119 + return $this->getDescription(); 120 + } 121 + 122 + 123 + /** 124 + * @task markup 125 + */ 126 + public function newMarkupEngine($field) { 127 + return PhabricatorMarkupEngine::newCalendarMarkupEngine(); 128 + } 129 + 130 + 131 + /** 132 + * @task markup 133 + */ 134 + public function didMarkupText( 135 + $field, 136 + $output, 137 + PhutilMarkupEngine $engine) { 138 + return $output; 139 + } 140 + 141 + 142 + /** 143 + * @task markup 144 + */ 145 + public function shouldUseMarkupCache($field) { 146 + return (bool)$this->getID(); 147 + } 98 148 99 149 /* -( PhabricatorPolicyInterface )----------------------------------------- */ 100 150
+8
src/infrastructure/markup/PhabricatorMarkupEngine.php
··· 353 353 )); 354 354 } 355 355 356 + /** 357 + * @task engine 358 + */ 359 + public static function newCalendarMarkupEngine() { 360 + return self::newMarkupEngine(array( 361 + )); 362 + } 363 + 356 364 357 365 /** 358 366 * @task engine