Changeset View
Changeset View
Standalone View
Standalone View
src/applications/phriction/controller/PhrictionNewController.php
Show All 10 Lines | if ($request->isFormPost()) { | ||||
->setViewer($viewer) | ->setViewer($viewer) | ||||
->withSlugs(array($slug)) | ->withSlugs(array($slug)) | ||||
->executeOne(); | ->executeOne(); | ||||
$prompt = $request->getStr('prompt', 'no'); | $prompt = $request->getStr('prompt', 'no'); | ||||
$document_exists = $document && $document->getStatus() == | $document_exists = $document && $document->getStatus() == | ||||
PhrictionDocumentStatus::STATUS_EXISTS; | PhrictionDocumentStatus::STATUS_EXISTS; | ||||
if ($document_exists && $prompt == 'no') { | if ($document_exists && $prompt == 'no') { | ||||
$dialog = new AphrontDialogView(); | return $this->newDialog() | ||||
$dialog->setSubmitURI('/phriction/new/') | ->setSubmitURI('/phriction/new/') | ||||
->setTitle(pht('Edit Existing Document?')) | ->setTitle(pht('Edit Existing Document?')) | ||||
->setUser($viewer) | ->setUser($viewer) | ||||
->appendChild(pht( | ->appendChild(pht( | ||||
'The document %s already exists. Do you want to edit it instead?', | 'The document %s already exists. Do you want to edit it instead?', | ||||
phutil_tag('tt', array(), $slug))) | phutil_tag('tt', array(), $slug))) | ||||
->addHiddenInput('slug', $slug) | ->addHiddenInput('slug', $slug) | ||||
->addHiddenInput('prompt', 'yes') | ->addHiddenInput('prompt', 'yes') | ||||
->addCancelButton('/w/') | ->addCancelButton('/w/') | ||||
->addSubmitButton(pht('Edit Document')); | ->addSubmitButton(pht('Edit Document')); | ||||
return id(new AphrontDialogResponse())->setDialog($dialog); | |||||
} | } | ||||
$uri = '/phriction/edit/?slug='.$slug; | $uri = '/phriction/edit/?slug='.$slug; | ||||
return id(new AphrontRedirectResponse()) | return id(new AphrontRedirectResponse()) | ||||
->setURI($uri); | ->setURI($uri); | ||||
} | } | ||||
if ($slug == '/') { | if ($slug == '/') { | ||||
$slug = ''; | $slug = ''; | ||||
} | } | ||||
$view = id(new PHUIFormLayoutView()) | $view = id(new PHUIFormLayoutView()) | ||||
->appendChild(id(new AphrontFormTextControl()) | ->appendChild(id(new AphrontFormTextControl()) | ||||
->setLabel('/w/') | ->setLabel('/w/') | ||||
->setValue($slug) | ->setValue($slug) | ||||
->setName('slug')); | ->setName('slug')); | ||||
$dialog = id(new AphrontDialogView()) | return $this->newDialog() | ||||
->setUser($viewer) | |||||
->setTitle(pht('New Document')) | ->setTitle(pht('New Document')) | ||||
->setSubmitURI('/phriction/new/') | ->setSubmitURI('/phriction/new/') | ||||
->appendChild(phutil_tag('p', | ->appendChild(phutil_tag('p', | ||||
array(), | array(), | ||||
pht('Create a new document at'))) | pht('Create a new document at'))) | ||||
->appendChild($view) | ->appendChild($view) | ||||
->addSubmitButton(pht('Create')) | ->addSubmitButton(pht('Create')) | ||||
->addCancelButton('/w/'); | ->addCancelButton('/w/'); | ||||
return id(new AphrontDialogResponse())->setDialog($dialog); | |||||
} | } | ||||
} | } |