mirror of
https://we.phorge.it/source/phorge.git
synced 2025-02-02 01:48:23 +01:00
9422596ebf
Summary: Fixes T11532. The language selection for pastes is now a typeahead that is backed by `pygments.dropdown-choices`. There is still a bit of weirdness around making "auto-detection" the default state. To actually select a different language, you first need to remove the "auto detect" option that is pre-populated in a new paste. Other than that, it works as intended. Test Plan: Create a new paste with a file extension that can be auto-detected. Created a new paste and manually selected the language Edited a paste and changed the language. Reviewers: #blessed_reviewers, epriestley Reviewed By: #blessed_reviewers, epriestley Subscribers: Korvin, epriestley, yelirekim Maniphest Tasks: T11532 Differential Revision: https://secure.phabricator.com/D16463
116 lines
3.6 KiB
PHP
116 lines
3.6 KiB
PHP
<?php
|
|
|
|
final class PhabricatorPasteEditEngine
|
|
extends PhabricatorEditEngine {
|
|
|
|
const ENGINECONST = 'paste.paste';
|
|
|
|
public function getEngineName() {
|
|
return pht('Pastes');
|
|
}
|
|
|
|
public function getSummaryHeader() {
|
|
return pht('Configure Paste Forms');
|
|
}
|
|
|
|
public function getSummaryText() {
|
|
return pht('Configure creation and editing forms in Paste.');
|
|
}
|
|
|
|
public function getEngineApplicationClass() {
|
|
return 'PhabricatorPasteApplication';
|
|
}
|
|
|
|
protected function newEditableObject() {
|
|
return PhabricatorPaste::initializeNewPaste($this->getViewer());
|
|
}
|
|
|
|
protected function newObjectQuery() {
|
|
return id(new PhabricatorPasteQuery())
|
|
->needRawContent(true);
|
|
}
|
|
|
|
protected function getObjectCreateTitleText($object) {
|
|
return pht('Create New Paste');
|
|
}
|
|
|
|
protected function getObjectEditTitleText($object) {
|
|
return pht('Edit Paste: %s', $object->getTitle());
|
|
}
|
|
|
|
protected function getObjectEditShortText($object) {
|
|
return $object->getMonogram();
|
|
}
|
|
|
|
protected function getObjectCreateShortText() {
|
|
return pht('Create Paste');
|
|
}
|
|
|
|
protected function getObjectName() {
|
|
return pht('Paste');
|
|
}
|
|
|
|
protected function getCommentViewHeaderText($object) {
|
|
return pht('Eat Paste');
|
|
}
|
|
|
|
protected function getCommentViewButtonText($object) {
|
|
return pht('Nom Nom Nom Nom Nom');
|
|
}
|
|
|
|
protected function getObjectViewURI($object) {
|
|
return '/P'.$object->getID();
|
|
}
|
|
|
|
protected function buildCustomEditFields($object) {
|
|
return array(
|
|
id(new PhabricatorTextEditField())
|
|
->setKey('title')
|
|
->setLabel(pht('Title'))
|
|
->setTransactionType(PhabricatorPasteTitleTransaction::TRANSACTIONTYPE)
|
|
->setDescription(pht('The title of the paste.'))
|
|
->setConduitDescription(pht('Retitle the paste.'))
|
|
->setConduitTypeDescription(pht('New paste title.'))
|
|
->setValue($object->getTitle()),
|
|
id(new PhabricatorDatasourceEditField())
|
|
->setKey('language')
|
|
->setLabel(pht('Language'))
|
|
->setTransactionType(
|
|
PhabricatorPasteLanguageTransaction::TRANSACTIONTYPE)
|
|
->setAliases(array('lang'))
|
|
->setIsCopyable(true)
|
|
->setDatasource(new PasteLanguageSelectDatasource())
|
|
->setDescription(
|
|
pht(
|
|
'Language used for syntax highlighting. By default, inferred '.
|
|
'from the title.'))
|
|
->setConduitDescription(
|
|
pht('Change language used for syntax highlighting.'))
|
|
->setConduitTypeDescription(pht('New highlighting language.'))
|
|
->setSingleValue($object->getLanguage()),
|
|
id(new PhabricatorTextAreaEditField())
|
|
->setKey('text')
|
|
->setLabel(pht('Text'))
|
|
->setTransactionType(
|
|
PhabricatorPasteContentTransaction::TRANSACTIONTYPE)
|
|
->setMonospaced(true)
|
|
->setHeight(AphrontFormTextAreaControl::HEIGHT_VERY_TALL)
|
|
->setDescription(pht('The main body text of the paste.'))
|
|
->setConduitDescription(pht('Change the paste content.'))
|
|
->setConduitTypeDescription(pht('New body content.'))
|
|
->setValue($object->getRawContent()),
|
|
id(new PhabricatorSelectEditField())
|
|
->setKey('status')
|
|
->setLabel(pht('Status'))
|
|
->setTransactionType(
|
|
PhabricatorPasteStatusTransaction::TRANSACTIONTYPE)
|
|
->setIsConduitOnly(true)
|
|
->setOptions(PhabricatorPaste::getStatusNameMap())
|
|
->setDescription(pht('Active or archived status.'))
|
|
->setConduitDescription(pht('Active or archive the paste.'))
|
|
->setConduitTypeDescription(pht('New paste status constant.'))
|
|
->setValue($object->getStatus()),
|
|
);
|
|
}
|
|
|
|
}
|