Remove product literal strings in "pht()", part 6
[phabricator.git] / src / applications / meta / controller / PhabricatorApplicationEmailCommandsController.php
blob43ed2e957ed8eb8fd06f7fa7385d028c30e3f997
1 <?php
3 final class PhabricatorApplicationEmailCommandsController
4 extends PhabricatorApplicationsController {
6 public function shouldAllowPublic() {
7 return true;
10 public function handleRequest(AphrontRequest $request) {
11 $viewer = $this->getViewer();
12 $application = $request->getURIData('application');
14 $selected = id(new PhabricatorApplicationQuery())
15 ->setViewer($viewer)
16 ->withClasses(array($application))
17 ->executeOne();
18 if (!$selected) {
19 return new Aphront404Response();
22 $specs = $selected->getMailCommandObjects();
23 $type = $request->getURIData('type');
24 if (empty($specs[$type])) {
25 return new Aphront404Response();
28 $spec = $specs[$type];
29 $commands = MetaMTAEmailTransactionCommand::getAllCommandsForObject(
30 $spec['object']);
32 $commands = msort($commands, 'getCommand');
34 $content = array();
36 $content[] = '= '.pht('Mail Commands Overview');
37 $content[] = pht(
38 'After configuring Phabricator to process inbound mail, you can '.
39 'interact with objects (like tasks and revisions) over email. For '.
40 'information on configuring Phabricator, see '.
41 '**[[ %s | Configuring Inbound Email ]]**.'.
42 "\n\n".
43 'In most cases, you can reply to email you receive from Phabricator '.
44 'to leave comments. You can also use **mail commands** to take a '.
45 'greater range of actions (like claiming a task or requesting changes '.
46 'to a revision) without needing to log in to the web UI.'.
47 "\n\n".
48 'Mail commands are keywords which start with an exclamation point, '.
49 'like `!claim`. Some commands may take parameters, like '.
50 "`!assign alincoln`.\n\n".
51 'To use mail commands, write one command per line at the beginning '.
52 'or end of your mail message. For example, you could write this in a '.
53 'reply to task email to claim the task:'.
54 "\n\n```\n!claim\n\nI'll take care of this.\n```\n\n\n".
55 "When Phabricator receives your mail, it will process any commands ".
56 "first, then post the remaining message body as a comment. You can ".
57 "execute multiple commands at once:".
58 "\n\n```\n!assign alincoln\n!close\n\nI just talked to @alincoln, ".
59 "and he showed me that he fixed this.\n```\n",
60 PhabricatorEnv::getDoclink('Configuring Inbound Email'));
62 $content[] = '= '.$spec['header'];
63 $content[] = $spec['summary'];
65 $content[] = '= '.pht('Quick Reference');
66 $content[] = pht(
67 'This table summarizes the available mail commands. For details on a '.
68 'specific command, see the command section below.');
69 $table = array();
70 $table[] = '| '.pht('Command').' | '.pht('Summary').' |';
71 $table[] = '|---|---|';
72 foreach ($commands as $command) {
73 $summary = $command->getCommandSummary();
74 $table[] = '| '.$command->getCommandSyntax().' | '.$summary;
76 $table = implode("\n", $table);
77 $content[] = $table;
79 foreach ($commands as $command) {
80 $content[] = '== !'.$command->getCommand().' ==';
81 $content[] = $command->getCommandSummary();
83 $aliases = $command->getCommandAliases();
84 if ($aliases) {
85 foreach ($aliases as $key => $alias) {
86 $aliases[$key] = '!'.$alias;
88 $aliases = implode(', ', $aliases);
89 } else {
90 $aliases = '//None//';
93 $syntax = $command->getCommandSyntax();
95 $table = array();
96 $table[] = '| '.pht('Property').' | '.pht('Value');
97 $table[] = '|---|---|';
98 $table[] = '| **'.pht('Syntax').'** | '.$syntax;
99 $table[] = '| **'.pht('Aliases').'** | '.$aliases;
100 $table[] = '| **'.pht('Class').'** | `'.get_class($command).'`';
101 $table = implode("\n", $table);
103 $content[] = $table;
105 $description = $command->getCommandDescription();
106 if ($description) {
107 $content[] = $description;
111 $content = implode("\n\n", $content);
113 $title = $spec['name'];
115 $crumbs = $this->buildApplicationCrumbs();
116 $this->addApplicationCrumb($crumbs, $selected);
117 $crumbs->addTextCrumb($title);
118 $crumbs->setBorder(true);
120 $content_box = new PHUIRemarkupView($viewer, $content);
122 $info_view = null;
123 if (!PhabricatorEnv::getEnvConfig('metamta.reply-handler-domain')) {
124 $error = pht(
125 "Phabricator is not currently configured to accept inbound mail. ".
126 "You won't be able to interact with objects over email until ".
127 "inbound mail is set up.");
128 $info_view = id(new PHUIInfoView())
129 ->setErrors(array($error));
132 $header = id(new PHUIHeaderView())
133 ->setHeader($title);
135 $document = id(new PHUIDocumentView())
136 ->setHeader($header)
137 ->appendChild($info_view)
138 ->appendChild($content_box);
140 return $this->newPage()
141 ->setTitle($title)
142 ->setCrumbs($crumbs)
143 ->appendChild($document);