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.
1.8 kB · 70 lines
PHP
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071<?php
final class PhabricatorSystemSelectViewAsController extends PhabricatorController {
public function shouldRequireLogin() { return false; }
public function handleRequest(AphrontRequest $request) { $viewer = $this->getViewer(); $v_engine = $request->getStr('engine');
if ($request->isFormPost()) { $result = array('engine' => $v_engine); return id(new AphrontAjaxResponse())->setContent($result); }
$engines = PhabricatorDocumentEngine::getAllEngines();
$options = $request->getStrList('options'); $options = array_fuse($options);
// TODO: This controller is a bit rough because it isn't really using the // file ref to figure out which engines should work. See also T13513. // Callers can pass a list of "options" to control which options are // presented, at least.
$ref = new PhabricatorDocumentRef();
$map = array(); foreach ($engines as $engine) { $key = $engine->getDocumentEngineKey();
if ($options && !isset($options[$key])) { continue; }
$label = $engine->getViewAsLabel($ref);
if (!strlen($label)) { continue; }
$map[$key] = $label; }
asort($map);
$map = array( '' => pht('(Use Default)'), ) + $map;
$form = id(new AphrontFormView()) ->setViewer($viewer) ->appendRemarkupInstructions(pht('Choose a document engine to use.')) ->appendChild( id(new AphrontFormSelectControl()) ->setLabel(pht('View As')) ->setName('engine') ->setValue($v_engine) ->setOptions($map));
return $this->newDialog() ->setTitle(pht('Select Document Engine')) ->appendForm($form) ->addSubmitButton(pht('Choose Engine')) ->addCancelButton('/'); }}