[ Index ] |
PHP Cross Reference of Phabricator |
[Summary view] [Print] [Text view]
1 <?php 2 3 final class PhragmentBrowseController extends PhragmentController { 4 5 private $dblob; 6 7 public function shouldAllowPublic() { 8 return true; 9 } 10 11 public function willProcessRequest(array $data) { 12 $this->dblob = idx($data, 'dblob', ''); 13 } 14 15 public function processRequest() { 16 $request = $this->getRequest(); 17 $viewer = $request->getUser(); 18 19 $parents = $this->loadParentFragments($this->dblob); 20 if ($parents === null) { 21 return new Aphront404Response(); 22 } 23 $current = nonempty(last($parents), null); 24 25 $path = ''; 26 if ($current !== null) { 27 $path = $current->getPath(); 28 } 29 30 $crumbs = $this->buildApplicationCrumbsWithPath($parents); 31 if ($this->hasApplicationCapability( 32 PhragmentCanCreateCapability::CAPABILITY)) { 33 $crumbs->addAction( 34 id(new PHUIListItemView()) 35 ->setName(pht('Create Fragment')) 36 ->setHref($this->getApplicationURI('/create/'.$path)) 37 ->setIcon('fa-plus-square')); 38 } 39 40 $current_box = $this->createCurrentFragmentView($current, false); 41 42 $list = id(new PHUIObjectItemListView()) 43 ->setUser($viewer); 44 45 $fragments = null; 46 if ($current === null) { 47 // Find all root fragments. 48 $fragments = id(new PhragmentFragmentQuery()) 49 ->setViewer($this->getRequest()->getUser()) 50 ->needLatestVersion(true) 51 ->withDepths(array(1)) 52 ->execute(); 53 } else { 54 // Find all child fragments. 55 $fragments = id(new PhragmentFragmentQuery()) 56 ->setViewer($this->getRequest()->getUser()) 57 ->needLatestVersion(true) 58 ->withLeadingPath($current->getPath().'/') 59 ->withDepths(array($current->getDepth() + 1)) 60 ->execute(); 61 } 62 63 foreach ($fragments as $fragment) { 64 $item = id(new PHUIObjectItemView()); 65 $item->setHeader($fragment->getName()); 66 $item->setHref($fragment->getURI()); 67 if (!$fragment->isDirectory()) { 68 $item->addAttribute(pht( 69 'Last Updated %s', 70 phabricator_datetime( 71 $fragment->getLatestVersion()->getDateCreated(), 72 $viewer))); 73 $item->addAttribute(pht( 74 'Latest Version %s', 75 $fragment->getLatestVersion()->getSequence())); 76 if ($fragment->isDeleted()) { 77 $item->setDisabled(true); 78 $item->addAttribute(pht('Deleted')); 79 } 80 } else { 81 $item->addAttribute('Directory'); 82 } 83 $list->addItem($item); 84 } 85 86 return $this->buildApplicationPage( 87 array( 88 $crumbs, 89 $this->renderConfigurationWarningIfRequired(), 90 $current_box, 91 $list, 92 ), 93 array( 94 'title' => pht('Browse Fragments'), 95 )); 96 } 97 98 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Sun Nov 30 09:20:46 2014 | Cross-referenced by PHPXref 0.7.1 |