public function processRequest()
 {
     $request = $this->getRequest();
     $user = $request->getUser();
     $nav = new AphrontSideNavFilterView();
     $nav->setBaseURI(new PhutilURI('/notification/'));
     $nav->addFilter('all', 'All Notifications');
     $nav->addFilter('unread', 'Unread Notifications');
     $filter = $nav->selectFilter($this->filter, 'all');
     $pager = new AphrontPagerView();
     $pager->setURI($request->getRequestURI(), 'offset');
     $pager->setOffset($request->getInt('offset'));
     $query = new PhabricatorNotificationQuery();
     $query->setUserPHID($user->getPHID());
     switch ($filter) {
         case 'unread':
             $query->withUnread(true);
             $header = pht('Unread Notifications');
             $no_data = pht('You have no unread notifications.');
             break;
         default:
             $header = pht('Notifications');
             $no_data = pht('You have no notifications.');
             break;
     }
     $notifications = $query->executeWithOffsetPager($pager);
     if ($notifications) {
         $builder = new PhabricatorNotificationBuilder($notifications);
         $view = $builder->buildView();
     } else {
         $view = '<div class="phabricator-notification no-notifications">' . $no_data . '</div>';
     }
     $view = array('<div class="phabricator-notification-list">', $view, '</div>');
     $panel = new AphrontPanelView();
     $panel->setHeader($header);
     $panel->setWidth(AphrontPanelView::WIDTH_FORM);
     $panel->addButton(javelin_render_tag('a', array('href' => '/notification/clear/', 'class' => 'button', 'sigil' => 'workflow'), 'Mark All Read'));
     $panel->appendChild($view);
     $panel->appendChild($pager);
     $nav->appendChild($panel);
     return $this->buildStandardPageResponse($nav, array('title' => 'Notifications'));
 }
 public function processRequest()
 {
     $request = $this->getRequest();
     $user = $request->getUser();
     $query = new PhabricatorNotificationQuery();
     $query->setUserPHID($user->getPHID());
     $query->setLimit(15);
     $stories = $query->execute();
     if ($stories) {
         $builder = new PhabricatorNotificationBuilder($stories);
         $notifications_view = $builder->buildView();
         $content = $notifications_view->render();
     } else {
         $content = '<div class="phabricator-notification no-notifications">' . 'You have no notifications.' . '</div>';
     }
     $content .= '<div class="phabricator-notification view-all-notifications">' . phutil_render_tag('a', array('href' => '/notification/'), 'View All Notifications') . '</div>';
     $unread_count = id(new PhabricatorFeedStoryNotification())->countUnread($user);
     $json = array('content' => $content, 'number' => $unread_count);
     return id(new AphrontAjaxResponse())->setContent($json);
 }