mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-23 22:10:55 +01:00
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
This commit is contained in:
parent
14ae5eee1c
commit
75408d1381
6 changed files with 94 additions and 4 deletions
|
@ -1492,6 +1492,7 @@ phutil_register_library_map(array(
|
||||||
'PhabricatorCalendarEventViewController' => 'applications/calendar/controller/PhabricatorCalendarEventViewController.php',
|
'PhabricatorCalendarEventViewController' => 'applications/calendar/controller/PhabricatorCalendarEventViewController.php',
|
||||||
'PhabricatorCalendarHoliday' => 'applications/calendar/storage/PhabricatorCalendarHoliday.php',
|
'PhabricatorCalendarHoliday' => 'applications/calendar/storage/PhabricatorCalendarHoliday.php',
|
||||||
'PhabricatorCalendarHolidayTestCase' => 'applications/calendar/storage/__tests__/PhabricatorCalendarHolidayTestCase.php',
|
'PhabricatorCalendarHolidayTestCase' => 'applications/calendar/storage/__tests__/PhabricatorCalendarHolidayTestCase.php',
|
||||||
|
'PhabricatorCalendarRemarkupRule' => 'applications/calendar/remarkup/PhabricatorCalendarRemarkupRule.php',
|
||||||
'PhabricatorCalendarViewController' => 'applications/calendar/controller/PhabricatorCalendarViewController.php',
|
'PhabricatorCalendarViewController' => 'applications/calendar/controller/PhabricatorCalendarViewController.php',
|
||||||
'PhabricatorCampfireProtocolAdapter' => 'infrastructure/daemon/bot/adapter/PhabricatorCampfireProtocolAdapter.php',
|
'PhabricatorCampfireProtocolAdapter' => 'infrastructure/daemon/bot/adapter/PhabricatorCampfireProtocolAdapter.php',
|
||||||
'PhabricatorCelerityApplication' => 'applications/celerity/application/PhabricatorCelerityApplication.php',
|
'PhabricatorCelerityApplication' => 'applications/celerity/application/PhabricatorCelerityApplication.php',
|
||||||
|
@ -4799,6 +4800,7 @@ phutil_register_library_map(array(
|
||||||
'PhabricatorCalendarEvent' => array(
|
'PhabricatorCalendarEvent' => array(
|
||||||
'PhabricatorCalendarDAO',
|
'PhabricatorCalendarDAO',
|
||||||
'PhabricatorPolicyInterface',
|
'PhabricatorPolicyInterface',
|
||||||
|
'PhabricatorMarkupInterface',
|
||||||
),
|
),
|
||||||
'PhabricatorCalendarEventDeleteController' => 'PhabricatorCalendarController',
|
'PhabricatorCalendarEventDeleteController' => 'PhabricatorCalendarController',
|
||||||
'PhabricatorCalendarEventEditController' => 'PhabricatorCalendarController',
|
'PhabricatorCalendarEventEditController' => 'PhabricatorCalendarController',
|
||||||
|
@ -4810,6 +4812,7 @@ phutil_register_library_map(array(
|
||||||
'PhabricatorCalendarEventViewController' => 'PhabricatorCalendarController',
|
'PhabricatorCalendarEventViewController' => 'PhabricatorCalendarController',
|
||||||
'PhabricatorCalendarHoliday' => 'PhabricatorCalendarDAO',
|
'PhabricatorCalendarHoliday' => 'PhabricatorCalendarDAO',
|
||||||
'PhabricatorCalendarHolidayTestCase' => 'PhabricatorTestCase',
|
'PhabricatorCalendarHolidayTestCase' => 'PhabricatorTestCase',
|
||||||
|
'PhabricatorCalendarRemarkupRule' => 'PhabricatorObjectRemarkupRule',
|
||||||
'PhabricatorCalendarViewController' => 'PhabricatorCalendarController',
|
'PhabricatorCalendarViewController' => 'PhabricatorCalendarController',
|
||||||
'PhabricatorCampfireProtocolAdapter' => 'PhabricatorBotBaseStreamingProtocolAdapter',
|
'PhabricatorCampfireProtocolAdapter' => 'PhabricatorBotBaseStreamingProtocolAdapter',
|
||||||
'PhabricatorCelerityApplication' => 'PhabricatorApplication',
|
'PhabricatorCelerityApplication' => 'PhabricatorApplication',
|
||||||
|
|
|
@ -32,6 +32,12 @@ final class PhabricatorCalendarApplication extends PhabricatorApplication {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getRemarkupRules() {
|
||||||
|
return array(
|
||||||
|
new PhabricatorCalendarRemarkupRule(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
public function getRoutes() {
|
public function getRoutes() {
|
||||||
return array(
|
return array(
|
||||||
'/E(?P<id>[1-9]\d*)' => 'PhabricatorCalendarEventViewController',
|
'/E(?P<id>[1-9]\d*)' => 'PhabricatorCalendarEventViewController',
|
||||||
|
|
|
@ -29,8 +29,12 @@ final class PhabricatorCalendarEventPHIDType extends PhabricatorPHIDType {
|
||||||
$event = $objects[$phid];
|
$event = $objects[$phid];
|
||||||
|
|
||||||
$id = $event->getID();
|
$id = $event->getID();
|
||||||
|
$name = pht('Event %d', $id);
|
||||||
|
|
||||||
$handle->setName(pht('Event %d', $id));
|
$handle
|
||||||
|
->setName(pht('Event %d', $id))
|
||||||
|
->setFullName(pht('E%d: %s', $id, $name))
|
||||||
|
->setURI('/E'.$id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,19 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
final class PhabricatorCalendarRemarkupRule
|
||||||
|
extends PhabricatorObjectRemarkupRule {
|
||||||
|
|
||||||
|
protected function getObjectNamePrefix() {
|
||||||
|
return 'E';
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function loadObjects(array $ids) {
|
||||||
|
$viewer = $this->getEngine()->getConfig('viewer');
|
||||||
|
|
||||||
|
return id(new PhabricatorCalendarEventQuery())
|
||||||
|
->setViewer($viewer)
|
||||||
|
->withIDs($ids)
|
||||||
|
->execute();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -1,8 +1,8 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
final class PhabricatorCalendarEvent
|
final class PhabricatorCalendarEvent extends PhabricatorCalendarDAO
|
||||||
extends PhabricatorCalendarDAO
|
implements PhabricatorPolicyInterface,
|
||||||
implements PhabricatorPolicyInterface {
|
PhabricatorMarkupInterface {
|
||||||
|
|
||||||
protected $userPHID;
|
protected $userPHID;
|
||||||
protected $dateFrom;
|
protected $dateFrom;
|
||||||
|
@ -56,6 +56,10 @@ final class PhabricatorCalendarEvent
|
||||||
PhabricatorCalendarEventPHIDType::TYPECONST);
|
PhabricatorCalendarEventPHIDType::TYPECONST);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getMonogram() {
|
||||||
|
return 'E'.$this->getID();
|
||||||
|
}
|
||||||
|
|
||||||
public function getTerseSummary(PhabricatorUser $viewer) {
|
public function getTerseSummary(PhabricatorUser $viewer) {
|
||||||
$until = phabricator_date($this->dateTo, $viewer);
|
$until = phabricator_date($this->dateTo, $viewer);
|
||||||
if ($this->status == PhabricatorCalendarEvent::STATUS_SPORADIC) {
|
if ($this->status == PhabricatorCalendarEvent::STATUS_SPORADIC) {
|
||||||
|
@ -95,6 +99,52 @@ final class PhabricatorCalendarEvent
|
||||||
return parent::save();
|
return parent::save();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* -( Markup Interface )--------------------------------------------------- */
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @task markup
|
||||||
|
*/
|
||||||
|
public function getMarkupFieldKey($field) {
|
||||||
|
$hash = PhabricatorHash::digest($this->getMarkupText($field));
|
||||||
|
$id = $this->getID();
|
||||||
|
return "calendar:T{$id}:{$field}:{$hash}";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @task markup
|
||||||
|
*/
|
||||||
|
public function getMarkupText($field) {
|
||||||
|
return $this->getDescription();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @task markup
|
||||||
|
*/
|
||||||
|
public function newMarkupEngine($field) {
|
||||||
|
return PhabricatorMarkupEngine::newCalendarMarkupEngine();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @task markup
|
||||||
|
*/
|
||||||
|
public function didMarkupText(
|
||||||
|
$field,
|
||||||
|
$output,
|
||||||
|
PhutilMarkupEngine $engine) {
|
||||||
|
return $output;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @task markup
|
||||||
|
*/
|
||||||
|
public function shouldUseMarkupCache($field) {
|
||||||
|
return (bool)$this->getID();
|
||||||
|
}
|
||||||
|
|
||||||
/* -( PhabricatorPolicyInterface )----------------------------------------- */
|
/* -( PhabricatorPolicyInterface )----------------------------------------- */
|
||||||
|
|
||||||
|
|
|
@ -353,6 +353,14 @@ final class PhabricatorMarkupEngine {
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @task engine
|
||||||
|
*/
|
||||||
|
public static function newCalendarMarkupEngine() {
|
||||||
|
return self::newMarkupEngine(array(
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @task engine
|
* @task engine
|
||||||
|
|
Loading…
Reference in a new issue