Changeset View
Changeset View
Standalone View
Standalone View
src/applications/phriction/controller/PhrictionMoveController.php
Show All 9 Lines | final class PhrictionMoveController | ||||
public function willProcessRequest(array $data) { | public function willProcessRequest(array $data) { | ||||
$this->id = idx($data, 'id'); | $this->id = idx($data, 'id'); | ||||
} | } | ||||
public function processRequest() { | public function processRequest() { | ||||
$request = $this->getRequest(); | $request = $this->getRequest(); | ||||
$user = $request->getUser(); | $user = $request->getUser(); | ||||
$is_serious = PhabricatorEnv::getEnvConfig('phabricator.serious-business'); | |||||
if ($this->id) { | if ($this->id) { | ||||
$document = id(new PhrictionDocument())->load($this->id); | $document = id(new PhrictionDocument())->load($this->id); | ||||
} else { | } else { | ||||
$slug = PhabricatorSlug::normalize( | $slug = PhabricatorSlug::normalize( | ||||
$request->getStr('slug')); | $request->getStr('slug')); | ||||
if (!$slug) { | if (!$slug) { | ||||
return new Aphront404Response(); | return new Aphront404Response(); | ||||
▲ Show 20 Lines • Show All 82 Lines • ▼ Show 20 Lines | if ($request->isFormPost() && !count($errors)) { | ||||
} | } | ||||
} | } | ||||
if ($errors) { | if ($errors) { | ||||
$error_view = id(new AphrontErrorView()) | $error_view = id(new AphrontErrorView()) | ||||
->setErrors($errors); | ->setErrors($errors); | ||||
} | } | ||||
$descr_caption = $is_serious ? pht('A reason for the move.') : | |||||
pht('You better give a good reason for this.'); | |||||
$form = id(new PHUIFormLayoutView()) | $form = id(new PHUIFormLayoutView()) | ||||
->setUser($user) | ->setUser($user) | ||||
->appendChild( | ->appendChild( | ||||
id(new AphrontFormStaticControl()) | id(new AphrontFormStaticControl()) | ||||
->setLabel(pht('Title')) | ->setLabel(pht('Title')) | ||||
->setValue($content->getTitle())) | ->setValue($content->getTitle())) | ||||
->appendChild( | ->appendChild( | ||||
id(new AphrontFormTextControl()) | id(new AphrontFormTextControl()) | ||||
->setLabel(pht('New URI')) | ->setLabel(pht('New URI')) | ||||
->setValue($target_slug) | ->setValue($target_slug) | ||||
->setError($e_url) | ->setError($e_url) | ||||
->setName('new-slug') | ->setName('new-slug') | ||||
->setCaption(pht('The new location of the document.'))) | ->setCaption(pht('The new location of the document.'))) | ||||
->appendChild( | ->appendChild( | ||||
id(new AphrontFormTextControl()) | id(new AphrontFormTextControl()) | ||||
->setLabel(pht('Edit Notes')) | ->setLabel(pht('Edit Notes')) | ||||
->setValue($content->getDescription()) | ->setValue($content->getDescription()) | ||||
->setError(null) | ->setError(null) | ||||
->setName('description') | ->setName('description')); | ||||
->setCaption($descr_caption)); | |||||
$dialog = id(new AphrontDialogView()) | $dialog = id(new AphrontDialogView()) | ||||
->setUser($user) | ->setUser($user) | ||||
->setTitle(pht('Move Document')) | ->setTitle(pht('Move Document')) | ||||
->appendChild($form) | ->appendChild($form) | ||||
->setSubmitURI($submit_uri) | ->setSubmitURI($submit_uri) | ||||
->addSubmitButton(pht('Move Document')) | ->addSubmitButton(pht('Move Document')) | ||||
->addCancelButton($cancel_uri); | ->addCancelButton($cancel_uri); | ||||
return id(new AphrontDialogResponse())->setDialog($dialog); | return id(new AphrontDialogResponse())->setDialog($dialog); | ||||
} | } | ||||
} | } |