Remove product literal strings in "pht()", part 6
[phabricator.git] / src / applications / drydock / controller / DrydockBlueprintEditController.php
blob8f066c708b9b4104e91cbdbe9bff2874541fe44b
1 <?php
3 final class DrydockBlueprintEditController extends DrydockBlueprintController {
5 public function handleRequest(AphrontRequest $request) {
6 $engine = id(new DrydockBlueprintEditEngine())
7 ->setController($this);
9 $id = $request->getURIData('id');
10 if (!$id) {
11 $this->requireApplicationCapability(
12 DrydockCreateBlueprintsCapability::CAPABILITY);
14 $type = $request->getStr('blueprintType');
16 $impl = DrydockBlueprintImplementation::getNamedImplementation($type);
17 if (!$impl || !$impl->isEnabled()) {
18 return $this->buildTypeSelectionResponse();
21 $engine
22 ->addContextParameter('blueprintType', $type)
23 ->setBlueprintImplementation($impl);
26 return $engine->buildResponse();
29 private function buildTypeSelectionResponse() {
30 $request = $this->getRequest();
31 $viewer = $this->getViewer();
33 $implementations =
34 DrydockBlueprintImplementation::getAllBlueprintImplementations();
36 $errors = array();
37 $e_blueprint = null;
39 if ($request->isFormPost()) {
40 $class = $request->getStr('blueprintType');
41 if (!isset($implementations[$class])) {
42 $e_blueprint = pht('Required');
43 $errors[] = pht('You must choose a blueprint type.');
47 $control = id(new AphrontFormRadioButtonControl())
48 ->setName('blueprintType')
49 ->setLabel(pht('Blueprint Type'))
50 ->setError($e_blueprint);
52 foreach ($implementations as $implementation_name => $implementation) {
53 $disabled = !$implementation->isEnabled();
55 $impl_icon = $implementation->getBlueprintIcon();
56 $impl_name = $implementation->getBlueprintName();
58 $impl_icon = id(new PHUIIconView())
59 ->setIcon($impl_icon, 'lightgreytext');
61 $control->addButton(
62 $implementation_name,
63 array($impl_icon, ' ', $impl_name),
64 array(
65 pht('Provides: %s', $implementation->getType()),
66 phutil_tag('br'),
67 phutil_tag('br'),
68 $implementation->getDescription(),
70 $disabled ? 'disabled' : null,
71 $disabled);
74 $title = pht('Create New Blueprint');
75 $crumbs = $this->buildApplicationCrumbs();
76 $crumbs->addTextCrumb(pht('New Blueprint'));
77 $crumbs->setBorder(true);
79 $form = id(new AphrontFormView())
80 ->setUser($viewer)
81 ->appendChild($control)
82 ->appendChild(
83 id(new AphrontFormSubmitControl())
84 ->addCancelButton($this->getApplicationURI('blueprint/'))
85 ->setValue(pht('Continue')));
87 $box = id(new PHUIObjectBoxView())
88 ->setFormErrors($errors)
89 ->setHeaderText($title)
90 ->setBackground(PHUIObjectBoxView::WHITE_CONFIG)
91 ->setForm($form);
93 $view = id(new PHUITwoColumnView())
94 ->setFooter($box);
96 return $this->newPage()
97 ->setTitle($title)
98 ->setCrumbs($crumbs)
99 ->appendChild($view);