Path: blob/master/src/applications/macro/controller/PhabricatorMacroMemeDialogController.php
12241 views
<?php12final class PhabricatorMacroMemeDialogController3extends PhabricatorMacroController {45public function handleRequest(AphrontRequest $request) {6$viewer = $request->getViewer();78$phid = head($request->getArr('macro'));9$above = $request->getStr('above');10$below = $request->getStr('below');1112$e_macro = true;13$errors = array();14if ($request->isDialogFormPost()) {15if (!$phid) {16$e_macro = pht('Required');17$errors[] = pht('Macro name is required.');18} else {19$macro = id(new PhabricatorMacroQuery())20->setViewer($viewer)21->withPHIDs(array($phid))22->executeOne();23if (!$macro) {24$e_macro = pht('Invalid');25$errors[] = pht('No such macro.');26}27}2829if (!$errors) {30$options = new PhutilSimpleOptions();31$data = array(32'src' => $macro->getName(),33'above' => $above,34'below' => $below,35);36$string = $options->unparse($data, $escape = '}');3738$result = array(39'text' => "{meme, {$string}}",40);41return id(new AphrontAjaxResponse())->setContent($result);42}43}4445$view = id(new AphrontFormView())46->setUser($viewer)47->appendControl(48id(new AphrontFormTokenizerControl())49->setLabel(pht('Macro'))50->setName('macro')51->setLimit(1)52->setDatasource(new PhabricatorMacroDatasource())53->setError($e_macro))54->appendChild(55id(new AphrontFormTextControl())56->setLabel(pht('Above'))57->setName('above')58->setValue($above))59->appendChild(60id(new AphrontFormTextControl())61->setLabel(pht('Below'))62->setName('below')63->setValue($below));6465$dialog = id(new AphrontDialogView())66->setUser($viewer)67->setTitle(pht('Create Meme'))68->appendForm($view)69->addCancelButton('/')70->addSubmitButton(pht('Llama Diorama'));7172return id(new AphrontDialogResponse())->setDialog($dialog);73}7475}767778