Changeset View
Changeset View
Standalone View
Standalone View
src/applications/phragment/controller/PhragmentBrowseController.php
<?php | <?php | ||||
final class PhragmentBrowseController extends PhragmentController { | final class PhragmentBrowseController extends PhragmentController { | ||||
private $dblob; | private $dblob; | ||||
public function shouldAllowPublic() { | |||||
return true; | |||||
} | |||||
public function willProcessRequest(array $data) { | public function willProcessRequest(array $data) { | ||||
$this->dblob = idx($data, "dblob", ""); | $this->dblob = idx($data, "dblob", ""); | ||||
} | } | ||||
public function processRequest() { | public function processRequest() { | ||||
$request = $this->getRequest(); | $request = $this->getRequest(); | ||||
$viewer = $request->getUser(); | $viewer = $request->getUser(); | ||||
$parents = $this->loadParentFragments($this->dblob); | $parents = $this->loadParentFragments($this->dblob); | ||||
if ($parents === null) { | if ($parents === null) { | ||||
return new Aphront404Response(); | return new Aphront404Response(); | ||||
} | } | ||||
$current = nonempty(last($parents), null); | $current = nonempty(last($parents), null); | ||||
$path = ''; | $path = ''; | ||||
if ($current !== null) { | if ($current !== null) { | ||||
$path = $current->getPath(); | $path = $current->getPath(); | ||||
} | } | ||||
$crumbs = $this->buildApplicationCrumbsWithPath($parents); | $crumbs = $this->buildApplicationCrumbsWithPath($parents); | ||||
if ($this->hasApplicationCapability( | |||||
PhragmentCapabilityCanCreate::CAPABILITY)) { | |||||
$crumbs->addAction( | $crumbs->addAction( | ||||
id(new PHUIListItemView()) | id(new PHUIListItemView()) | ||||
->setName(pht('Create Fragment')) | ->setName(pht('Create Fragment')) | ||||
->setHref($this->getApplicationURI('/create/'.$path)) | ->setHref($this->getApplicationURI('/create/'.$path)) | ||||
->setIcon('create')); | ->setIcon('create')); | ||||
} | |||||
$current_box = $this->createCurrentFragmentView($current, false); | $current_box = $this->createCurrentFragmentView($current, false); | ||||
$list = id(new PHUIObjectItemListView()) | $list = id(new PHUIObjectItemListView()) | ||||
->setUser($viewer); | ->setUser($viewer); | ||||
$fragments = null; | $fragments = null; | ||||
if ($current === null) { | if ($current === null) { | ||||
Show All 34 Lines | foreach ($fragments as $fragment) { | ||||
$item->addAttribute('Directory'); | $item->addAttribute('Directory'); | ||||
} | } | ||||
$list->addItem($item); | $list->addItem($item); | ||||
} | } | ||||
return $this->buildApplicationPage( | return $this->buildApplicationPage( | ||||
array( | array( | ||||
$crumbs, | $crumbs, | ||||
$this->renderConfigurationWarningIfRequired(), | |||||
$current_box, | $current_box, | ||||
$list), | $list), | ||||
array( | array( | ||||
'title' => pht('Browse Fragments'), | 'title' => pht('Browse Fragments'), | ||||
'device' => true)); | 'device' => true)); | ||||
} | } | ||||
} | } |