Page MenuHomec4science

PhabricatorProjectWikiCreate.php
No OneTemporary

File Metadata

Created
Fri, Dec 27, 02:30

PhabricatorProjectWikiCreate.php

<?php
final class PhabricatorProjectWikiCreate
extends PhabricatorController {
public function shouldAllowPublic() {
return false;
}
public function handleRequest(AphrontRequest $request) {
$viewer = $request->getViewer();
$id = (int)$request->getURIData('id');
$project = id(new PhabricatorProjectQuery())
->withIDs(array($id))
->setViewer($viewer)
->needSlugs(true)
->executeOne();
if(!$project) {
return $this->newDialog()
->setTitle(pht('Error'))
->setErrors(array('Project doesn\'t exit'))
->addCancelButton('/project/');
}
$project_slug = $project->getPrimarySlug();
if ($request->isFormPost()) {
$slug = PhabricatorSlug::normalize($request->getStr('slug'));
return id(new AphrontRedirectResponse())
->setURI('/phriction/edit/?slug='. $project_slug . '/' . $slug);
}
$wiki_document = id(new PhrictionDocumentQuery())
->setViewer($viewer)
->withStatus(PhrictionDocumentQuery::STATUS_NONSTUB)
->withSlugPrefix($project_slug . '/')
->execute();
if(!$wiki_document){
$view = id(new PHUIFormLayoutView())
->appendChild(phutil_tag(
'p',
array(),
pht('/w/' . $project_slug . '/')));
} else {
$view = id(new PHUIFormLayoutView())
->appendChild(id(new AphrontFormTextControl())
->setLabel('/w/' . $project_slug . '/')
->setValue('')
->setName('slug'));
}
return $this->newDialog()
->setTitle(pht('New Document'))
->setSubmitURI('/project/wiki/create/' . $id . '/')
->appendChild(phutil_tag('p',
array(),
pht('Create a new document at')))
->appendChild($view)
->addSubmitButton(pht('Create'))
->addCancelButton('/project/view/' . $id);
}
protected function buildApplicationCrumbs() {
$crumbs = parent::buildApplicationCrumbs();
id(new AlmanacServiceEditEngine())
->setViewer($this->getViewer())
->addActionToCrumbs($crumbs);
return $crumbs;
}
}

Event Timeline