Something went wrong. Try again.
@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
Something went wrong. Try again.
3.0 kB · 97 lines
PHP
at commit dfc8f8bc
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798<?php
final class DiffusionRepositoryEditEncodingController extends DiffusionRepositoryEditController {
public function handleRequest(AphrontRequest $request) { $response = $this->loadDiffusionContextForEdit(); if ($response) { return $response; }
$user = $this->getViewer(); $drequest = $this->getDiffusionRequest(); $repository = $drequest->getRepository();
$edit_uri = $this->getRepositoryControllerURI($repository, 'edit/');
$v_encoding = $repository->getDetail('encoding'); $e_encoding = null; $errors = array();
if ($request->isFormPost()) { $v_encoding = $request->getStr('encoding');
if (!$errors) { $xactions = array(); $template = id(new PhabricatorRepositoryTransaction());
$type_encoding = PhabricatorRepositoryTransaction::TYPE_ENCODING;
$xactions[] = id(clone $template) ->setTransactionType($type_encoding) ->setNewValue($v_encoding);
try { id(new PhabricatorRepositoryEditor()) ->setContinueOnNoEffect(true) ->setContentSourceFromRequest($request) ->setActor($user) ->applyTransactions($repository, $xactions);
return id(new AphrontRedirectResponse())->setURI($edit_uri); } catch (Exception $ex) { $errors[] = $ex->getMessage(); } } }
$crumbs = $this->buildApplicationCrumbs(); $crumbs->addTextCrumb(pht('Edit Encoding'));
$title = pht('Edit %s', $repository->getName());
$form = id(new AphrontFormView()) ->setUser($user) ->appendRemarkupInstructions($this->getEncodingInstructions()) ->appendChild( id(new AphrontFormTextControl()) ->setName('encoding') ->setLabel(pht('Text Encoding')) ->setValue($v_encoding) ->setError($e_encoding)) ->appendChild( id(new AphrontFormSubmitControl()) ->setValue(pht('Save Encoding')) ->addCancelButton($edit_uri));
$object_box = id(new PHUIObjectBoxView()) ->setHeaderText($title) ->setForm($form) ->setFormErrors($errors);
return $this->newPage() ->setTitle($title) ->setCrumbs($crumbs) ->appendChild($object_box); }
private function getEncodingInstructions() { return pht(<<<EOTIf source code in this repository uses a character encoding other than UTF-8(for example, `ISO-8859-1`), specify it here.
**Normally, you can leave this field blank.** If your source code is written inASCII or UTF-8, everything will work correctly.
Source files will be translated from the specified encoding to UTF-8 when theyare read from the repository, before they are displayed in Diffusion.
See [[%s | UTF-8 and Character Encoding]] for more information on howPhabricator handles text encodings.EOT , PhabricatorEnv::getDoclink('User Guide: UTF-8 and Character Encoding')); }
}