mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-10 00:42:41 +01:00
Create a basic meme dialog
Summary: Simple dialog for creating memes. We can add more features (typeahead, selection thumbs, preview) later. Test Plan: {F29815} Reviewers: DeedyDas, chad Reviewed By: chad CC: aran Maniphest Tasks: T2353 Differential Revision: https://secure.phabricator.com/D4557
This commit is contained in:
parent
dce6d2e9d5
commit
4f3fafd2e9
3 changed files with 69 additions and 0 deletions
|
@ -929,6 +929,7 @@ phutil_register_library_map(array(
|
||||||
'PhabricatorMacroEditor' => 'applications/macro/editor/PhabricatorMacroEditor.php',
|
'PhabricatorMacroEditor' => 'applications/macro/editor/PhabricatorMacroEditor.php',
|
||||||
'PhabricatorMacroListController' => 'applications/macro/controller/PhabricatorMacroListController.php',
|
'PhabricatorMacroListController' => 'applications/macro/controller/PhabricatorMacroListController.php',
|
||||||
'PhabricatorMacroMemeController' => 'applications/macro/controller/PhabricatorMacroMemeController.php',
|
'PhabricatorMacroMemeController' => 'applications/macro/controller/PhabricatorMacroMemeController.php',
|
||||||
|
'PhabricatorMacroMemeDialogController' => 'applications/macro/controller/PhabricatorMacroMemeDialogController.php',
|
||||||
'PhabricatorMacroReplyHandler' => 'applications/macro/mail/PhabricatorMacroReplyHandler.php',
|
'PhabricatorMacroReplyHandler' => 'applications/macro/mail/PhabricatorMacroReplyHandler.php',
|
||||||
'PhabricatorMacroTransaction' => 'applications/macro/storage/PhabricatorMacroTransaction.php',
|
'PhabricatorMacroTransaction' => 'applications/macro/storage/PhabricatorMacroTransaction.php',
|
||||||
'PhabricatorMacroTransactionComment' => 'applications/macro/storage/PhabricatorMacroTransactionComment.php',
|
'PhabricatorMacroTransactionComment' => 'applications/macro/storage/PhabricatorMacroTransactionComment.php',
|
||||||
|
@ -2317,6 +2318,7 @@ phutil_register_library_map(array(
|
||||||
'PhabricatorMacroEditor' => 'PhabricatorApplicationTransactionEditor',
|
'PhabricatorMacroEditor' => 'PhabricatorApplicationTransactionEditor',
|
||||||
'PhabricatorMacroListController' => 'PhabricatorMacroController',
|
'PhabricatorMacroListController' => 'PhabricatorMacroController',
|
||||||
'PhabricatorMacroMemeController' => 'PhabricatorMacroController',
|
'PhabricatorMacroMemeController' => 'PhabricatorMacroController',
|
||||||
|
'PhabricatorMacroMemeDialogController' => 'PhabricatorMacroController',
|
||||||
'PhabricatorMacroReplyHandler' => 'PhabricatorMailReplyHandler',
|
'PhabricatorMacroReplyHandler' => 'PhabricatorMailReplyHandler',
|
||||||
'PhabricatorMacroTransaction' => 'PhabricatorApplicationTransaction',
|
'PhabricatorMacroTransaction' => 'PhabricatorApplicationTransaction',
|
||||||
'PhabricatorMacroTransactionComment' => 'PhabricatorApplicationTransactionComment',
|
'PhabricatorMacroTransactionComment' => 'PhabricatorApplicationTransactionComment',
|
||||||
|
|
|
@ -32,6 +32,7 @@ final class PhabricatorApplicationMacro extends PhabricatorApplication {
|
||||||
'edit/(?P<id>[1-9]\d*)/' => 'PhabricatorMacroEditController',
|
'edit/(?P<id>[1-9]\d*)/' => 'PhabricatorMacroEditController',
|
||||||
'disable/(?P<id>[1-9]\d*)/' => 'PhabricatorMacroDisableController',
|
'disable/(?P<id>[1-9]\d*)/' => 'PhabricatorMacroDisableController',
|
||||||
'meme/' => 'PhabricatorMacroMemeController',
|
'meme/' => 'PhabricatorMacroMemeController',
|
||||||
|
'meme/create/' => 'PhabricatorMacroMemeDialogController',
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,66 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
final class PhabricatorMacroMemeDialogController
|
||||||
|
extends PhabricatorMacroController {
|
||||||
|
|
||||||
|
public function processRequest() {
|
||||||
|
$request = $this->getRequest();
|
||||||
|
$user = $request->getUser();
|
||||||
|
|
||||||
|
$name = $request->getStr('macro');
|
||||||
|
$above = $request->getStr('above');
|
||||||
|
$below = $request->getStr('below');
|
||||||
|
|
||||||
|
$e_macro = true;
|
||||||
|
$errors = array();
|
||||||
|
if ($request->isDialogFormPost()) {
|
||||||
|
if (!$name) {
|
||||||
|
$e_macro = pht('Required');
|
||||||
|
$errors[] = pht('Macro name is required.');
|
||||||
|
} else {
|
||||||
|
$macro = id(new PhabricatorFileImageMacro())->loadOneWhere(
|
||||||
|
'name = %s',
|
||||||
|
$name);
|
||||||
|
if (!$macro) {
|
||||||
|
$e_macro = pht('Invalid');
|
||||||
|
$errors[] = pht('No such macro.');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$errors) {
|
||||||
|
$result = array(
|
||||||
|
'text' => "{meme, src={$name}, above={$above}, below={$below}}",
|
||||||
|
);
|
||||||
|
return id(new AphrontAjaxResponse())->setContent($result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$view = id(new AphrontFormLayoutView())
|
||||||
|
->appendChild(
|
||||||
|
id(new AphrontFormTextControl())
|
||||||
|
->setLabel(pht('Macro'))
|
||||||
|
->setName('macro')
|
||||||
|
->setValue($name)
|
||||||
|
->setError($e_macro))
|
||||||
|
->appendChild(
|
||||||
|
id(new AphrontFormTextControl())
|
||||||
|
->setLabel(pht('Above'))
|
||||||
|
->setName('above')
|
||||||
|
->setValue($above))
|
||||||
|
->appendChild(
|
||||||
|
id(new AphrontFormTextControl())
|
||||||
|
->setLabel(pht('Below'))
|
||||||
|
->setName('below')
|
||||||
|
->setValue($below));
|
||||||
|
|
||||||
|
$dialog = id(new AphrontDialogView())
|
||||||
|
->setUser($user)
|
||||||
|
->setTitle(pht('Create Meme'))
|
||||||
|
->appendChild($view)
|
||||||
|
->addCancelButton('/')
|
||||||
|
->addSubmitButton(pht('rofllolo!!~'));
|
||||||
|
|
||||||
|
return id(new AphrontDialogResponse())->setDialog($dialog);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in a new issue