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');
|
|
|
|
$arcanist_link = phutil_render_tag(
|
|
|
|
'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(
|
|
|
|
'<p class="aphront-form-instructions">The best way to create a '.
|
2011-12-02 01:05:54 +01:00
|
|
|
"Differential diff is by using $arcanist_link, 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 '.
|
|
|
|
'really want.</p>')
|
2011-02-05 21:20:18 +01:00
|
|
|
->appendChild(
|
|
|
|
id(new AphrontFormTextAreaControl())
|
|
|
|
->setLabel('Raw Diff')
|
|
|
|
->setName('diff')
|
|
|
|
->setHeight(AphrontFormTextAreaControl::HEIGHT_VERY_TALL))
|
2011-10-19 04:46:52 +02:00
|
|
|
->appendChild(
|
|
|
|
id(new AphrontFormFileControl())
|
|
|
|
->setLabel('Raw Diff from file')
|
|
|
|
->setName('diff-file'))
|
2011-02-05 21:20:18 +01:00
|
|
|
->appendChild(
|
|
|
|
id(new AphrontFormSubmitControl())
|
|
|
|
->setValue("Create Diff \xC2\xBB"));
|
|
|
|
|
|
|
|
$panel = new AphrontPanelView();
|
|
|
|
$panel->setHeader('Create New Diff');
|
|
|
|
$panel->appendChild($form);
|
|
|
|
$panel->setWidth(AphrontPanelView::WIDTH_FORM);
|
|
|
|
|
|
|
|
return $this->buildStandardPageResponse(
|
|
|
|
$panel,
|
|
|
|
array(
|
|
|
|
'title' => 'Create Diff',
|
|
|
|
));
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|