1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-19 12:00: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:
lkassianik 2015-04-27 14:27:34 -07:00
parent 14ae5eee1c
commit 75408d1381
6 changed files with 94 additions and 4 deletions

View file

@ -1492,6 +1492,7 @@ phutil_register_library_map(array(
'PhabricatorCalendarEventViewController' => 'applications/calendar/controller/PhabricatorCalendarEventViewController.php',
'PhabricatorCalendarHoliday' => 'applications/calendar/storage/PhabricatorCalendarHoliday.php',
'PhabricatorCalendarHolidayTestCase' => 'applications/calendar/storage/__tests__/PhabricatorCalendarHolidayTestCase.php',
'PhabricatorCalendarRemarkupRule' => 'applications/calendar/remarkup/PhabricatorCalendarRemarkupRule.php',
'PhabricatorCalendarViewController' => 'applications/calendar/controller/PhabricatorCalendarViewController.php',
'PhabricatorCampfireProtocolAdapter' => 'infrastructure/daemon/bot/adapter/PhabricatorCampfireProtocolAdapter.php',
'PhabricatorCelerityApplication' => 'applications/celerity/application/PhabricatorCelerityApplication.php',
@ -4799,6 +4800,7 @@ phutil_register_library_map(array(
'PhabricatorCalendarEvent' => array(
'PhabricatorCalendarDAO',
'PhabricatorPolicyInterface',
'PhabricatorMarkupInterface',
),
'PhabricatorCalendarEventDeleteController' => 'PhabricatorCalendarController',
'PhabricatorCalendarEventEditController' => 'PhabricatorCalendarController',
@ -4810,6 +4812,7 @@ phutil_register_library_map(array(
'PhabricatorCalendarEventViewController' => 'PhabricatorCalendarController',
'PhabricatorCalendarHoliday' => 'PhabricatorCalendarDAO',
'PhabricatorCalendarHolidayTestCase' => 'PhabricatorTestCase',
'PhabricatorCalendarRemarkupRule' => 'PhabricatorObjectRemarkupRule',
'PhabricatorCalendarViewController' => 'PhabricatorCalendarController',
'PhabricatorCampfireProtocolAdapter' => 'PhabricatorBotBaseStreamingProtocolAdapter',
'PhabricatorCelerityApplication' => 'PhabricatorApplication',

View file

@ -32,6 +32,12 @@ final class PhabricatorCalendarApplication extends PhabricatorApplication {
return true;
}
public function getRemarkupRules() {
return array(
new PhabricatorCalendarRemarkupRule(),
);
}
public function getRoutes() {
return array(
'/E(?P<id>[1-9]\d*)' => 'PhabricatorCalendarEventViewController',

View file

@ -29,8 +29,12 @@ final class PhabricatorCalendarEventPHIDType extends PhabricatorPHIDType {
$event = $objects[$phid];
$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);
}
}

View file

@ -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();
}
}

View file

@ -1,8 +1,8 @@
<?php
final class PhabricatorCalendarEvent
extends PhabricatorCalendarDAO
implements PhabricatorPolicyInterface {
final class PhabricatorCalendarEvent extends PhabricatorCalendarDAO
implements PhabricatorPolicyInterface,
PhabricatorMarkupInterface {
protected $userPHID;
protected $dateFrom;
@ -56,6 +56,10 @@ final class PhabricatorCalendarEvent
PhabricatorCalendarEventPHIDType::TYPECONST);
}
public function getMonogram() {
return 'E'.$this->getID();
}
public function getTerseSummary(PhabricatorUser $viewer) {
$until = phabricator_date($this->dateTo, $viewer);
if ($this->status == PhabricatorCalendarEvent::STATUS_SPORADIC) {
@ -95,6 +99,52 @@ final class PhabricatorCalendarEvent
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 )----------------------------------------- */

View file

@ -353,6 +353,14 @@ final class PhabricatorMarkupEngine {
));
}
/**
* @task engine
*/
public static function newCalendarMarkupEngine() {
return self::newMarkupEngine(array(
));
}
/**
* @task engine