Changeset View
Changeset View
Standalone View
Standalone View
src/applications/phriction/controller/PhrictionNewController.php
Show All 27 Lines | if ($request->isFormPost()) { | ||||
'The document %s already exists. Do you want to edit it instead?', | 'The document %s already exists. Do you want to edit it instead?', | ||||
hsprintf('<tt>%s</tt>', $slug))) | hsprintf('<tt>%s</tt>', $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); | return id(new AphrontDialogResponse())->setDialog($dialog); | ||||
} elseif (substr($slug, 0, 9) == 'projects/') { | } else if (PhrictionDocument::isProjectSlug($slug)) { | ||||
$project = id(new PhabricatorProjectQuery()) | |||||
->setViewer($user) | |||||
->withPhrictionSlugs(array( | |||||
PhrictionDocument::getProjectSlugIdentifier($slug))) | |||||
->executeOne(); | |||||
if (!$project) { | |||||
$dialog = new AphrontDialogView(); | $dialog = new AphrontDialogView(); | ||||
$dialog->setSubmitURI('/w/') | $dialog->setSubmitURI('/w/') | ||||
->setTitle(pht('Oops!')) | ->setTitle(pht('Oops!')) | ||||
->setUser($user) | ->setUser($user) | ||||
->appendChild(pht( | ->appendChild(pht( | ||||
'You cannot create wiki pages under "projects/", | 'You cannot create wiki pages under "projects/", | ||||
because they are reserved as project pages. | because they are reserved as project pages. | ||||
Create a new project with this name first.')) | Create a new project with this name first.')) | ||||
->addCancelButton('/w/', 'Okay'); | ->addCancelButton('/w/', 'Okay'); | ||||
return id(new AphrontDialogResponse())->setDialog($dialog); | return id(new AphrontDialogResponse())->setDialog($dialog); | ||||
} | |||||
} | |||||
} else { | |||||
$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/') | ||||
Show All 18 Lines |