Path: blob/master/src/applications/calendar/editor/PhabricatorCalendarExportEditEngine.php
12256 views
<?php12final class PhabricatorCalendarExportEditEngine3extends PhabricatorEditEngine {45const ENGINECONST = 'calendar.export';67public function getEngineName() {8return pht('Calendar Exports');9}1011public function isEngineConfigurable() {12return false;13}1415public function getSummaryHeader() {16return pht('Configure Calendar Export Forms');17}1819public function getSummaryText() {20return pht('Configure how users create and edit exports.');21}2223public function getEngineApplicationClass() {24return 'PhabricatorCalendarApplication';25}2627protected function newEditableObject() {28return PhabricatorCalendarExport::initializeNewCalendarExport(29$this->getViewer());30}3132protected function newObjectQuery() {33return new PhabricatorCalendarExportQuery();34}3536protected function getObjectCreateTitleText($object) {37return pht('Create New Export');38}3940protected function getObjectEditTitleText($object) {41return pht('Edit Export: %s', $object->getName());42}4344protected function getObjectEditShortText($object) {45return pht('Export %d', $object->getID());46}4748protected function getObjectCreateShortText() {49return pht('Create Export');50}5152protected function getObjectName() {53return pht('Export');54}5556protected function getObjectViewURI($object) {57return $object->getURI();58}5960protected function getEditorURI() {61return $this->getApplication()->getApplicationURI('export/edit/');62}6364protected function buildCustomEditFields($object) {65$viewer = $this->getViewer();6667$export_modes = PhabricatorCalendarExport::getAvailablePolicyModes();68$export_modes = array_fuse($export_modes);6970$current_mode = $object->getPolicyMode();71if (empty($export_modes[$current_mode])) {72array_unshift($export_modes, $current_mode);73}7475$mode_options = array();76foreach ($export_modes as $export_mode) {77$mode_name = PhabricatorCalendarExport::getPolicyModeName($export_mode);78$mode_summary = PhabricatorCalendarExport::getPolicyModeSummary(79$export_mode);80$mode_options[$export_mode] = pht('%s: %s', $mode_name, $mode_summary);81}8283$fields = array(84id(new PhabricatorTextEditField())85->setKey('name')86->setLabel(pht('Name'))87->setDescription(pht('Name of the export.'))88->setIsRequired(true)89->setTransactionType(90PhabricatorCalendarExportNameTransaction::TRANSACTIONTYPE)91->setConduitDescription(pht('Rename the export.'))92->setConduitTypeDescription(pht('New export name.'))93->setValue($object->getName()),94id(new PhabricatorBoolEditField())95->setKey('disabled')96->setOptions(pht('Active'), pht('Disabled'))97->setLabel(pht('Disabled'))98->setDescription(pht('Disable the export.'))99->setTransactionType(100PhabricatorCalendarExportDisableTransaction::TRANSACTIONTYPE)101->setIsFormField(false)102->setConduitDescription(pht('Disable or restore the export.'))103->setConduitTypeDescription(pht('True to cancel the export.'))104->setValue($object->getIsDisabled()),105id(new PhabricatorTextEditField())106->setKey('queryKey')107->setLabel(pht('Query Key'))108->setDescription(pht('Query to execute.'))109->setIsRequired(true)110->setTransactionType(111PhabricatorCalendarExportQueryKeyTransaction::TRANSACTIONTYPE)112->setConduitDescription(pht('Change the export query key.'))113->setConduitTypeDescription(pht('New export query key.'))114->setValue($object->getQueryKey()),115id(new PhabricatorSelectEditField())116->setKey('mode')117->setLabel(pht('Mode'))118->setTransactionType(119PhabricatorCalendarExportModeTransaction::TRANSACTIONTYPE)120->setOptions($mode_options)121->setDescription(pht('Change the policy mode for the export.'))122->setConduitDescription(pht('Adjust export mode.'))123->setConduitTypeDescription(pht('New export mode.'))124->setValue($current_mode),125126);127128return $fields;129}130131132}133134135