2011-02-05 21:20:18 +01:00
|
|
|
<?php
|
|
|
|
|
2012-03-10 00:46:25 +01:00
|
|
|
final class DifferentialDiffCreateController extends DifferentialController {
|
2011-02-05 21:20:18 +01:00
|
|
|
|
|
|
|
public function processRequest() {
|
|
|
|
|
|
|
|
$request = $this->getRequest();
|
|
|
|
|
|
|
|
if ($request->isFormPost()) {
|
2011-10-19 04:46:52 +02:00
|
|
|
$diff = null;
|
2013-01-09 17:14:17 +01:00
|
|
|
|
|
|
|
if ($request->getFileExists('diff-file')) {
|
2011-10-19 04:46:52 +02:00
|
|
|
$diff = PhabricatorFile::readUploadedFileData($_FILES['diff-file']);
|
2013-01-09 17:14:17 +01:00
|
|
|
} else {
|
2011-10-19 04:46:52 +02:00
|
|
|
$diff = $request->getStr('diff');
|
|
|
|
}
|
2011-02-05 21:20:18 +01:00
|
|
|
|
2012-06-20 21:35:04 +02:00
|
|
|
$call = new ConduitCall(
|
|
|
|
'differential.createrawdiff',
|
|
|
|
array(
|
|
|
|
'diff' => $diff,
|
|
|
|
));
|
|
|
|
$call->setUser($request->getUser());
|
|
|
|
$result = $call->execute();
|
2011-02-05 21:20:18 +01:00
|
|
|
|
2012-06-20 21:35:04 +02:00
|
|
|
$path = id(new PhutilURI($result['uri']))->getPath();
|
|
|
|
return id(new AphrontRedirectResponse())->setURI($path);
|
2011-02-05 21:20:18 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
$form = new AphrontFormView();
|
2011-12-02 01:05:54 +01:00
|
|
|
$arcanist_href = PhabricatorEnv::getDoclink(
|
|
|
|
'article/Arcanist_User_Guide.html');
|
2013-01-18 03:57:09 +01:00
|
|
|
$arcanist_link = phutil_tag(
|
2011-12-02 01:05:54 +01:00
|
|
|
'a',
|
|
|
|
array(
|
|
|
|
'href' => $arcanist_href,
|
|
|
|
'target' => '_blank',
|
|
|
|
),
|
|
|
|
'Arcanist');
|
2011-02-05 21:20:18 +01:00
|
|
|
$form
|
|
|
|
->setAction('/differential/diff/create/')
|
2011-10-19 04:46:52 +02:00
|
|
|
->setEncType('multipart/form-data')
|
2011-02-05 21:20:18 +01:00
|
|
|
->setUser($request->getUser())
|
|
|
|
->appendChild(
|
2013-01-24 19:46:47 +01:00
|
|
|
'<p class="aphront-form-instructions">'.pht('The best way to create '.
|
|
|
|
'a Differential diff is by using %s, but you '.
|
2011-02-05 21:20:18 +01:00
|
|
|
'can also just paste a diff (e.g., from <tt>svn diff</tt> or '.
|
2011-10-19 04:46:52 +02:00
|
|
|
'<tt>git diff</tt>) into this box or upload it as a file if you '.
|
2013-01-24 19:46:47 +01:00
|
|
|
'really want.', $arcanist_link).'</p>')
|
2011-02-05 21:20:18 +01:00
|
|
|
->appendChild(
|
|
|
|
id(new AphrontFormTextAreaControl())
|
2013-01-24 19:46:47 +01:00
|
|
|
->setLabel(pht('Raw Diff'))
|
2011-02-05 21:20:18 +01:00
|
|
|
->setName('diff')
|
|
|
|
->setHeight(AphrontFormTextAreaControl::HEIGHT_VERY_TALL))
|
2011-10-19 04:46:52 +02:00
|
|
|
->appendChild(
|
|
|
|
id(new AphrontFormFileControl())
|
2013-01-24 19:46:47 +01:00
|
|
|
->setLabel(pht('Raw Diff from file'))
|
2011-10-19 04:46:52 +02:00
|
|
|
->setName('diff-file'))
|
2011-02-05 21:20:18 +01:00
|
|
|
->appendChild(
|
|
|
|
id(new AphrontFormSubmitControl())
|
2013-01-24 19:46:47 +01:00
|
|
|
->setValue(pht("Create Diff \xC2\xBB")));
|
2011-02-05 21:20:18 +01:00
|
|
|
|
|
|
|
$panel = new AphrontPanelView();
|
2013-01-24 19:46:47 +01:00
|
|
|
$panel->setHeader(pht('Create New Diff'));
|
2011-02-05 21:20:18 +01:00
|
|
|
$panel->appendChild($form);
|
|
|
|
$panel->setWidth(AphrontPanelView::WIDTH_FORM);
|
|
|
|
|
|
|
|
return $this->buildStandardPageResponse(
|
|
|
|
$panel,
|
|
|
|
array(
|
2013-01-24 19:46:47 +01:00
|
|
|
'title' => pht('Create Diff'),
|
2011-02-05 21:20:18 +01:00
|
|
|
));
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|