Substantially support character encodings and "Highlight As" in changesets
Summary: Ref T5179. Ref T4045. Ref T832. We can now write non-utf8 hunks into the database, so try to do more reasonable things with them in the UI. Test Plan: (See screenshots...) Reviewers: btrahan Reviewed By: btrahan Subscribers: epriestley Maniphest Tasks: T832, T4045, T5179 Differential Revision: https://secure.phabricator.com/D9294
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
final class PhabricatorSystemSelectEncodingController
|
||||
extends PhabricatorController {
|
||||
|
||||
public function shouldRequireLogin() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public function processRequest() {
|
||||
$request = $this->getRequest();
|
||||
|
||||
if (!function_exists('mb_list_encodings')) {
|
||||
return $this->newDialog()
|
||||
->setTitle(pht('No Encoding Support'))
|
||||
->appendParagraph(
|
||||
pht(
|
||||
'This system does not have the "mbstring" extension installed, '.
|
||||
'so character encodings are not supported. Install "mbstring" to '.
|
||||
'enable support.'))
|
||||
->addCancelButton('/');
|
||||
}
|
||||
|
||||
if ($request->isFormPost()) {
|
||||
$result = array('encoding' => $request->getStr('encoding'));
|
||||
return id(new AphrontAjaxResponse())->setContent($result);
|
||||
}
|
||||
|
||||
$encodings = mb_list_encodings();
|
||||
$encodings = array_fuse($encodings);
|
||||
asort($encodings);
|
||||
unset($encodings['pass']);
|
||||
unset($encodings['auto']);
|
||||
|
||||
$encodings = array(
|
||||
'' => pht('(Use Default)'),
|
||||
) + $encodings;
|
||||
|
||||
$form = id(new AphrontFormView())
|
||||
->setUser($this->getRequest()->getUser())
|
||||
->appendRemarkupInstructions(pht('Choose a text encoding to use.'))
|
||||
->appendChild(
|
||||
id(new AphrontFormSelectControl())
|
||||
->setLabel(pht('Encoding'))
|
||||
->setName('encoding')
|
||||
->setValue($request->getStr('encoding'))
|
||||
->setOptions($encodings));
|
||||
|
||||
return $this->newDialog()
|
||||
->setTitle(pht('Select Character Encoding'))
|
||||
->appendChild($form->buildLayoutView())
|
||||
->addSubmitButton(pht('Choose Encoding'))
|
||||
->addCancelButton('/');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
final class PhabricatorSystemSelectHighlightController
|
||||
extends PhabricatorController {
|
||||
|
||||
public function shouldRequireLogin() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public function processRequest() {
|
||||
$request = $this->getRequest();
|
||||
|
||||
if ($request->isFormPost()) {
|
||||
$result = array('highlight' => $request->getStr('highlight'));
|
||||
return id(new AphrontAjaxResponse())->setContent($result);
|
||||
}
|
||||
|
||||
$languages = array(
|
||||
'' => pht('(Use Default)'),
|
||||
) + PhabricatorEnv::getEnvConfig('pygments.dropdown-choices');
|
||||
|
||||
$form = id(new AphrontFormView())
|
||||
->setUser($this->getRequest()->getUser())
|
||||
->appendRemarkupInstructions(pht('Choose a syntax highlighting to use.'))
|
||||
->appendChild(
|
||||
id(new AphrontFormSelectControl())
|
||||
->setLabel(pht('Highlighting'))
|
||||
->setName('highlight')
|
||||
->setValue($request->getStr('highlight'))
|
||||
->setOptions($languages));
|
||||
|
||||
return $this->newDialog()
|
||||
->setTitle(pht('Select Syntax Highlighting'))
|
||||
->appendChild($form->buildLayoutView())
|
||||
->addSubmitButton(pht('Choose Highlighting'))
|
||||
->addCancelButton('/');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user