1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2025-03-27 19:50:21 +01:00
phorge-phorge/src/applications/countdown/editor/PhabricatorCountdownEditEngine.php
epriestley cdec319143 Convert Countdown to EditEngine
Summary: Fixes T10684. Fixes T10520. This primarily implements a date/epoch field, and then does a bunch of standard plumbing.

Test Plan:
  - Created countdowns.
  - Edited countdowns.
  - Used HTTP prefilling.
  - Created a countdown ending on "Christmas Morning", etc.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T10520, T10684

Differential Revision: https://secure.phabricator.com/D15655
2016-04-07 12:34:07 -07:00

108 lines
3 KiB
PHP

<?php
final class PhabricatorCountdownEditEngine
extends PhabricatorEditEngine {
const ENGINECONST = 'countdown.countdown';
public function isEngineConfigurable() {
return false;
}
public function getEngineName() {
return pht('Countdowns');
}
public function getSummaryHeader() {
return pht('Edit Countdowns');
}
public function getSummaryText() {
return pht('Creates and edits countdowns.');
}
public function getEngineApplicationClass() {
return 'PhabricatorCountdownApplication';
}
protected function newEditableObject() {
return PhabricatorCountdown::initializeNewCountdown(
$this->getViewer());
}
protected function newObjectQuery() {
return id(new PhabricatorCountdownQuery());
}
protected function getObjectCreateTitleText($object) {
return pht('Create Countdown');
}
protected function getObjectCreateButtonText($object) {
return pht('Create Countdown');
}
protected function getObjectEditTitleText($object) {
return pht('Edit Countdown: %s', $object->getTitle());
}
protected function getObjectEditShortText($object) {
return pht('Edit Countdown');
}
protected function getObjectCreateShortText() {
return pht('Create Countdown');
}
protected function getObjectName() {
return pht('Countdown');
}
protected function getCommentViewHeaderText($object) {
return pht('Last Words');
}
protected function getCommentViewButtonText($object) {
return pht('Contemplate Infinity');
}
protected function getObjectViewURI($object) {
return $object->getURI();
}
protected function buildCustomEditFields($object) {
$epoch_value = $object->getEpoch();
if ($epoch_value === null) {
$epoch_value = PhabricatorTime::getNow();
}
return array(
id(new PhabricatorTextEditField())
->setKey('name')
->setLabel(pht('Name'))
->setIsRequired(true)
->setTransactionType(PhabricatorCountdownTransaction::TYPE_TITLE)
->setDescription(pht('The countdown name.'))
->setConduitDescription(pht('Rename the countdown.'))
->setConduitTypeDescription(pht('New countdown name.'))
->setValue($object->getTitle()),
id(new PhabricatorEpochEditField())
->setKey('epoch')
->setLabel(pht('End Date'))
->setTransactionType(PhabricatorCountdownTransaction::TYPE_EPOCH)
->setDescription(pht('Date when the countdown ends.'))
->setConduitDescription(pht('Change the end date of the countdown.'))
->setConduitTypeDescription(pht('New countdown end date.'))
->setValue($epoch_value),
id(new PhabricatorRemarkupEditField())
->setKey('description')
->setLabel(pht('Description'))
->setTransactionType(PhabricatorCountdownTransaction::TYPE_DESCRIPTION)
->setDescription(pht('Description of the countdown.'))
->setConduitDescription(pht('Change the countdown description.'))
->setConduitTypeDescription(pht('New description.'))
->setValue($object->getDescription()),
);
}
}