[ Index ] |
PHP Cross Reference of Phabricator |
[Summary view] [Print] [Text view]
1 <?php 2 3 final class PhabricatorNotificationSearchEngine 4 extends PhabricatorApplicationSearchEngine { 5 6 public function getResultTypeDescription() { 7 return pht('Notifications'); 8 } 9 10 public function getApplicationClassName() { 11 return 'PhabricatorNotificationsApplication'; 12 } 13 14 public function buildSavedQueryFromRequest(AphrontRequest $request) { 15 $saved = new PhabricatorSavedQuery(); 16 17 $saved->setParameter( 18 'unread', 19 $this->readBoolFromRequest($request, 'unread')); 20 21 return $saved; 22 } 23 24 public function buildQueryFromSavedQuery(PhabricatorSavedQuery $saved) { 25 $query = id(new PhabricatorNotificationQuery()) 26 ->withUserPHIDs(array($this->requireViewer()->getPHID())); 27 28 if ($saved->getParameter('unread')) { 29 $query->withUnread(true); 30 } 31 32 return $query; 33 } 34 35 public function buildSearchForm( 36 AphrontFormView $form, 37 PhabricatorSavedQuery $saved) { 38 39 $unread = $saved->getParameter('unread'); 40 41 $form->appendChild( 42 id(new AphrontFormCheckboxControl()) 43 ->setLabel(pht('Unread')) 44 ->addCheckbox( 45 'unread', 46 1, 47 pht('Show only unread notifications.'), 48 $unread)); 49 } 50 51 protected function getURI($path) { 52 return '/notification/'.$path; 53 } 54 55 public function getBuiltinQueryNames() { 56 57 $names = array( 58 'all' => pht('All Notifications'), 59 'unread' => pht('Unread Notifications'), 60 ); 61 62 return $names; 63 } 64 65 public function buildSavedQueryFromBuiltin($query_key) { 66 $query = $this->newSavedQuery(); 67 $query->setQueryKey($query_key); 68 69 switch ($query_key) { 70 case 'all': 71 return $query; 72 case 'unread': 73 return $query->setParameter('unread', true); 74 } 75 76 return parent::buildSavedQueryFromBuiltin($query_key); 77 } 78 79 protected function renderResultList( 80 array $notifications, 81 PhabricatorSavedQuery $query, 82 array $handles) { 83 assert_instances_of($notifications, 'PhabricatorFeedStory'); 84 85 $viewer = $this->requireViewer(); 86 87 $image = id(new PHUIIconView()) 88 ->setIconFont('fa-eye-slash'); 89 90 $button = id(new PHUIButtonView()) 91 ->setTag('a') 92 ->addSigil('workflow') 93 ->setColor(PHUIButtonView::SIMPLE) 94 ->setIcon($image) 95 ->setText(pht('Mark All Read')); 96 97 switch ($query->getQueryKey()) { 98 case 'unread': 99 $header = pht('Unread Notifications'); 100 $no_data = pht('You have no unread notifications.'); 101 break; 102 default: 103 $header = pht('Notifications'); 104 $no_data = pht('You have no notifications.'); 105 break; 106 } 107 108 $clear_uri = id(new PhutilURI('/notification/clear/')); 109 if ($notifications) { 110 $builder = id(new PhabricatorNotificationBuilder($notifications)) 111 ->setUser($viewer); 112 113 $view = $builder->buildView(); 114 $clear_uri->setQueryParam( 115 'chronoKey', 116 head($notifications)->getChronologicalKey()); 117 } else { 118 $view = phutil_tag_div( 119 'phabricator-notification no-notifications', 120 $no_data); 121 $button->setDisabled(true); 122 } 123 $button->setHref((string)$clear_uri); 124 125 $view = id(new PHUIBoxView()) 126 ->addPadding(PHUI::PADDING_MEDIUM) 127 ->addClass('phabricator-notification-list') 128 ->appendChild($view); 129 130 $notif_header = id(new PHUIHeaderView()) 131 ->setHeader($header) 132 ->addActionLink($button); 133 134 return id(new PHUIObjectBoxView()) 135 ->setHeader($notif_header) 136 ->appendChild($view); 137 } 138 139 public function shouldUseOffsetPaging() { 140 return true; 141 } 142 143 }
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 |