Page MenuHomec4science

PhabricatorProjectWikiView.php
No OneTemporary

File Metadata

Created
Sat, Nov 23, 13:48

PhabricatorProjectWikiView.php

<?php
final class PhabricatorProjectWikiView
extends PhabricatorProjectController {
public function handleRequest(AphrontRequest $request) {
$viewer = $request->getViewer();
$id = $request->getURIData('id');
$project = id(new PhabricatorProjectQuery())
->setViewer($viewer)
->withIDs(array($id))
->needImages(true)
->executeOne();
if (!$project) {
return new Aphront404Response();
}
$this->setProject($project);
$title = pht('Wiki pages');
$curtain = $this->buildCurtainView($project);
$query = id(new PhrictionDocumentQuery())
->setViewer($viewer)
->needContent(true)
->withStatuses(array(PhrictionDocumentStatus::STATUS_EXISTS))
->withSlugPrefix(PhabricatorProjectWikiCreate::getAllSlugs($project))
->setOrder(PhrictionDocumentQuery::ORDER_HIERARCHY)
->execute();
$wiki_list = new PHUIObjectItemListView();
foreach($query as $w){
$wiki_list->addItem(
id(new PHUIObjectItemView())
->setHeader($w->getContent()->getTitle())
->addAttribute($w->getSlug())
->setHref($w->getSlugURI($w->getSlug())));
}
$nav = $this->getProfileMenu();
$nav->selectFilter(PhabricatorProjectWikiProfileMenuItem::MENUITEM_WIKI);
$crumbs = $this->buildApplicationCrumbs();
$crumbs->addCrumb(
id(new PHUICrumbView())
->setHref("/project/view/${id}")
->setName($project->getName())
);
$crumbs->addTextCrumb(pht('Wiki'));
$crumbs->setBorder(true);
$header = id(new PHUIHeaderView())
->setHeader($title)
->setHeaderIcon('fa-book');
$view = id(new PHUITwoColumnView())
->setHeader($header)
->setCurtain($curtain)
->setMainColumn(array(
$wiki_list,
));
return $this->newPage()
->setNavigation($nav)
->setCrumbs($crumbs)
->setTitle(array($project->getName(), $title))
->appendChild($view);
}
private function buildCurtainView(PhabricatorProject $project) {
$viewer = $this->getViewer();
$id = $project->getID();
$curtain = $this->newCurtainView($project);
$can_edit = PhabricatorPolicyFilter::hasCapability(
$viewer,
$project,
PhabricatorPolicyCapability::CAN_EDIT);
if($can_edit) {
$curtain->addAction(
id(new PhabricatorActionView())
->setName('Create wiki page')
->setIcon('fa-plus')
->setHref("/project/wiki/create/{$id}/")
->setWorkflow(true));
}
return $curtain;
}
protected function buildApplicationCrumbs() {
$view = new PHUICrumbsView();
$view->addCrumb(
id(new PHUICrumbView())
->setHref('/project/')
->setName(pht('Projects'))
->setIcon('fa-briefcase')
);
return $view;
}
}

Event Timeline