3 final class PhabricatorMacroMemeDialogController
4 extends PhabricatorMacroController
{
6 public function handleRequest(AphrontRequest
$request) {
7 $viewer = $request->getViewer();
9 $phid = head($request->getArr('macro'));
10 $above = $request->getStr('above');
11 $below = $request->getStr('below');
15 if ($request->isDialogFormPost()) {
17 $e_macro = pht('Required');
18 $errors[] = pht('Macro name is required.');
20 $macro = id(new PhabricatorMacroQuery())
22 ->withPHIDs(array($phid))
25 $e_macro = pht('Invalid');
26 $errors[] = pht('No such macro.');
31 $options = new PhutilSimpleOptions();
33 'src' => $macro->getName(),
37 $string = $options->unparse($data, $escape = '}');
40 'text' => "{meme, {$string}}",
42 return id(new AphrontAjaxResponse())->setContent($result);
46 $view = id(new AphrontFormView())
49 id(new AphrontFormTokenizerControl())
50 ->setLabel(pht('Macro'))
53 ->setDatasource(new PhabricatorMacroDatasource())
56 id(new AphrontFormTextControl())
57 ->setLabel(pht('Above'))
61 id(new AphrontFormTextControl())
62 ->setLabel(pht('Below'))
66 $dialog = id(new AphrontDialogView())
68 ->setTitle(pht('Create Meme'))
70 ->addCancelButton('/')
71 ->addSubmitButton(pht('Llama Diorama'));
73 return id(new AphrontDialogResponse())->setDialog($dialog);