1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-14 19:02:41 +01:00
phorge-phorge/src/applications/differential/controller/diffview/DifferentialDiffViewController.php

90 lines
2.6 KiB
PHP
Raw Normal View History

2011-01-24 22:18:41 +01:00
<?php
/*
* Copyright 2011 Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
class DifferentialDiffViewController extends DifferentialController {
private $id;
public function willProcessRequest(array $data) {
$this->id = $data['id'];
}
public function processRequest() {
2011-01-31 03:52:29 +01:00
$request = $this->getRequest();
2011-01-24 22:18:41 +01:00
$diff = id(new DifferentialDiff())->load($this->id);
if (!$diff) {
return new Aphront404Response();
}
2011-01-26 00:19:06 +01:00
$action_panel = new AphrontPanelView();
$action_panel->setHeader('Preview Diff');
$action_panel->setWidth(AphrontPanelView::WIDTH_WIDE);
$action_panel->appendChild(
'<p class="aphront-panel-instructions">Review the diff for correctness. '.
'When you are satisfied, either <strong>create a new revision</strong> '.
'or <strong>update an existing revision</strong>.');
$action_form = new AphrontFormView();
$action_form
2011-01-31 03:52:29 +01:00
->setUser($request->getUser())
2011-01-26 00:19:06 +01:00
->setAction('/differential/revision/edit/')
2011-01-26 02:17:19 +01:00
->addHiddenInput('diffID', $diff->getID())
->addHiddenInput('viaDiffView', 1)
2011-01-26 00:19:06 +01:00
->appendChild(
id(new AphrontFormSelectControl())
->setLabel('Attach To')
->setName('revisionID')
->setValue('')
->setOptions(array(
'' => "Create a new Revision...",
)))
->appendChild(
id(new AphrontFormSubmitControl())
->setValue('Continue'));
$action_panel->appendChild($action_form);
2011-01-24 22:18:41 +01:00
$changesets = $diff->loadChangesets();
$changesets = msort($changesets, 'getSortKey');
$table_of_contents = id(new DifferentialDiffTableOfContentsView())
->setChangesets($changesets);
2011-01-25 20:57:47 +01:00
$details = id(new DifferentialChangesetListView())
2011-01-24 22:18:41 +01:00
->setChangesets($changesets);
return $this->buildStandardPageResponse(
2011-01-26 00:19:06 +01:00
'<div class="differential-primary-pane">'.
implode(
"\n",
array(
$action_panel->render(),
$table_of_contents->render(),
$details->render(),
)).
'</div>',
2011-01-24 22:18:41 +01:00
array(
'title' => 'Diff View',
));
}
}