[ Index ] |
PHP Cross Reference of Phabricator |
[Summary view] [Print] [Text view]
1 <?php 2 3 final class PhabricatorMacroMemeDialogController 4 extends PhabricatorMacroController { 5 6 public function processRequest() { 7 $request = $this->getRequest(); 8 $user = $request->getUser(); 9 10 $phid = head($request->getArr('macro')); 11 $above = $request->getStr('above'); 12 $below = $request->getStr('below'); 13 14 $e_macro = true; 15 $errors = array(); 16 if ($request->isDialogFormPost()) { 17 if (!$phid) { 18 $e_macro = pht('Required'); 19 $errors[] = pht('Macro name is required.'); 20 } else { 21 $macro = id(new PhabricatorMacroQuery()) 22 ->setViewer($user) 23 ->withPHIDs(array($phid)) 24 ->executeOne(); 25 if (!$macro) { 26 $e_macro = pht('Invalid'); 27 $errors[] = pht('No such macro.'); 28 } 29 } 30 31 if (!$errors) { 32 $options = new PhutilSimpleOptions(); 33 $data = array( 34 'src' => $macro->getName(), 35 'above' => $above, 36 'below' => $below, 37 ); 38 $string = $options->unparse($data, $escape = '}'); 39 40 $result = array( 41 'text' => "{meme, {$string}}", 42 ); 43 return id(new AphrontAjaxResponse())->setContent($result); 44 } 45 } 46 47 $view = id(new PHUIFormLayoutView()) 48 ->appendChild( 49 id(new AphrontFormTokenizerControl()) 50 ->setLabel(pht('Macro')) 51 ->setName('macro') 52 ->setLimit(1) 53 ->setDatasource(new PhabricatorMacroDatasource()) 54 ->setError($e_macro)) 55 ->appendChild( 56 id(new AphrontFormTextControl()) 57 ->setLabel(pht('Above')) 58 ->setName('above') 59 ->setValue($above)) 60 ->appendChild( 61 id(new AphrontFormTextControl()) 62 ->setLabel(pht('Below')) 63 ->setName('below') 64 ->setValue($below)); 65 66 $dialog = id(new AphrontDialogView()) 67 ->setUser($user) 68 ->setTitle(pht('Create Meme')) 69 ->appendChild($view) 70 ->addCancelButton('/') 71 ->addSubmitButton(pht('rofllolo!!~')); 72 73 return id(new AphrontDialogResponse())->setDialog($dialog); 74 } 75 76 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Sun Nov 30 09:20:46 2014 | Cross-referenced by PHPXref 0.7.1 |