2012-11-09 15:08:37 -08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @group phriction
|
|
|
|
*/
|
|
|
|
final class PhrictionNewController extends PhrictionController {
|
|
|
|
|
|
|
|
public function processRequest() {
|
|
|
|
|
|
|
|
$request = $this->getRequest();
|
|
|
|
$user = $request->getUser();
|
2013-03-07 08:12:00 -08:00
|
|
|
$slug = PhabricatorSlug::normalize($request->getStr('slug'));
|
2012-11-09 15:08:37 -08:00
|
|
|
|
|
|
|
if ($request->isFormPost()) {
|
|
|
|
$uri = '/phriction/edit/?slug='.$slug;
|
|
|
|
return id(new AphrontRedirectResponse())
|
|
|
|
->setURI($uri);
|
|
|
|
}
|
|
|
|
|
2013-03-07 08:12:00 -08:00
|
|
|
if ($slug == '/') {
|
|
|
|
$slug = '';
|
|
|
|
}
|
|
|
|
|
2012-11-09 15:08:37 -08:00
|
|
|
$view = id(new AphrontFormLayoutView())
|
|
|
|
->appendChild(id(new AphrontFormTextControl())
|
|
|
|
->setLabel('/w/')
|
2013-03-07 08:12:00 -08:00
|
|
|
->setValue($slug)
|
2012-11-09 15:08:37 -08:00
|
|
|
->setName('slug'));
|
|
|
|
|
|
|
|
$dialog = id(new AphrontDialogView())
|
|
|
|
->setUser($user)
|
|
|
|
->setTitle(pht('New Document'))
|
2013-03-07 08:12:00 -08:00
|
|
|
->setSubmitURI('/phriction/new/')
|
2013-01-17 19:15:06 -08:00
|
|
|
->appendChild(phutil_tag('p',
|
2012-11-09 15:08:37 -08:00
|
|
|
array(),
|
2013-03-07 08:12:00 -08:00
|
|
|
pht('Create a new document at')))
|
2012-11-09 15:08:37 -08:00
|
|
|
->appendChild($view)
|
|
|
|
->addSubmitButton(pht('Create'))
|
2013-01-11 11:58:31 -08:00
|
|
|
->addCancelButton('/w/');
|
2012-11-09 15:08:37 -08:00
|
|
|
|
|
|
|
return id(new AphrontDialogResponse())->setDialog($dialog);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|