[ Index ] |
PHP Cross Reference of Phabricator |
[Summary view] [Print] [Text view]
1 <?php 2 3 final class PholioMockSearchEngine extends PhabricatorApplicationSearchEngine { 4 5 public function getResultTypeDescription() { 6 return pht('Pholio Mocks'); 7 } 8 9 public function getApplicationClassName() { 10 return 'PhabricatorPholioApplication'; 11 } 12 13 public function buildSavedQueryFromRequest(AphrontRequest $request) { 14 $saved = new PhabricatorSavedQuery(); 15 $saved->setParameter( 16 'authorPHIDs', 17 $this->readUsersFromRequest($request, 'authors')); 18 $saved->setParameter( 19 'statuses', 20 $request->getStrList('status')); 21 22 return $saved; 23 } 24 25 public function buildQueryFromSavedQuery(PhabricatorSavedQuery $saved) { 26 $query = id(new PholioMockQuery()) 27 ->needCoverFiles(true) 28 ->needImages(true) 29 ->needTokenCounts(true) 30 ->withAuthorPHIDs($saved->getParameter('authorPHIDs', array())) 31 ->withStatuses($saved->getParameter('statuses', array())); 32 33 return $query; 34 } 35 36 public function buildSearchForm( 37 AphrontFormView $form, 38 PhabricatorSavedQuery $saved_query) { 39 40 $phids = $saved_query->getParameter('authorPHIDs', array()); 41 $author_handles = id(new PhabricatorHandleQuery()) 42 ->setViewer($this->requireViewer()) 43 ->withPHIDs($phids) 44 ->execute(); 45 46 $statuses = array( 47 '' => pht('Any Status'), 48 'closed' => pht('Closed'), 49 'open' => pht('Open'), 50 ); 51 52 $status = $saved_query->getParameter('statuses', array()); 53 $status = head($status); 54 55 $form 56 ->appendChild( 57 id(new AphrontFormTokenizerControl()) 58 ->setDatasource(new PhabricatorPeopleDatasource()) 59 ->setName('authors') 60 ->setLabel(pht('Authors')) 61 ->setValue($author_handles)) 62 ->appendChild( 63 id(new AphrontFormSelectControl()) 64 ->setLabel(pht('Status')) 65 ->setName('status') 66 ->setOptions($statuses) 67 ->setValue($status)); 68 } 69 70 protected function getURI($path) { 71 return '/pholio/'.$path; 72 } 73 74 public function getBuiltinQueryNames() { 75 $names = array( 76 'open' => pht('Open Mocks'), 77 'all' => pht('All Mocks'), 78 ); 79 80 if ($this->requireViewer()->isLoggedIn()) { 81 $names['authored'] = pht('Authored'); 82 } 83 84 return $names; 85 } 86 87 public function buildSavedQueryFromBuiltin($query_key) { 88 $query = $this->newSavedQuery(); 89 $query->setQueryKey($query_key); 90 91 switch ($query_key) { 92 case 'open': 93 return $query->setParameter( 94 'statuses', 95 array('open')); 96 case 'all': 97 return $query; 98 case 'authored': 99 return $query->setParameter( 100 'authorPHIDs', 101 array($this->requireViewer()->getPHID())); 102 } 103 104 return parent::buildSavedQueryFromBuiltin($query_key); 105 } 106 107 protected function getRequiredHandlePHIDsForResultList( 108 array $mocks, 109 PhabricatorSavedQuery $query) { 110 return mpull($mocks, 'getAuthorPHID'); 111 } 112 113 protected function renderResultList( 114 array $mocks, 115 PhabricatorSavedQuery $query, 116 array $handles) { 117 assert_instances_of($mocks, 'PholioMock'); 118 119 $viewer = $this->requireViewer(); 120 121 $board = new PHUIPinboardView(); 122 foreach ($mocks as $mock) { 123 124 $header = 'M'.$mock->getID().' '.$mock->getName(); 125 $item = id(new PHUIPinboardItemView()) 126 ->setHeader($header) 127 ->setURI('/M'.$mock->getID()) 128 ->setImageURI($mock->getCoverFile()->getThumb280x210URI()) 129 ->setImageSize(280, 210) 130 ->setDisabled($mock->isClosed()) 131 ->addIconCount('fa-picture-o', count($mock->getImages())) 132 ->addIconCount('fa-trophy', $mock->getTokenCount()); 133 134 if ($mock->getAuthorPHID()) { 135 $author_handle = $handles[$mock->getAuthorPHID()]; 136 $datetime = phabricator_date($mock->getDateCreated(), $viewer); 137 $item->appendChild( 138 pht('By %s on %s', $author_handle->renderLink(), $datetime)); 139 } 140 141 $board->addItem($item); 142 } 143 144 return $board; 145 } 146 147 }
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 |