protected function renderResultList(array $notifications, PhabricatorSavedQuery $query, array $handles)
 {
     assert_instances_of($notifications, 'PhabricatorFeedStory');
     $viewer = $this->requireViewer();
     $image = id(new PHUIIconView())->setIconFont('fa-eye-slash');
     $button = id(new PHUIButtonView())->setTag('a')->addSigil('workflow')->setColor(PHUIButtonView::SIMPLE)->setIcon($image)->setText(pht('Mark All Read'));
     switch ($query->getQueryKey()) {
         case 'unread':
             $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;
     }
     $clear_uri = id(new PhutilURI('/notification/clear/'));
     if ($notifications) {
         $builder = id(new PhabricatorNotificationBuilder($notifications))->setUser($viewer);
         $view = $builder->buildView();
         $clear_uri->setQueryParam('chronoKey', head($notifications)->getChronologicalKey());
     } else {
         $view = phutil_tag_div('phabricator-notification no-notifications', $no_data);
         $button->setDisabled(true);
     }
     $button->setHref((string) $clear_uri);
     $view = id(new PHUIBoxView())->addPadding(PHUI::PADDING_MEDIUM)->addClass('phabricator-notification-list')->appendChild($view);
     $result = new PhabricatorApplicationSearchResultView();
     $result->addAction($button);
     $result->setContent($view);
     return $result;
 }
 protected function renderResultList(array $all_applications, PhabricatorSavedQuery $query, array $handle)
 {
     assert_instances_of($all_applications, 'PhabricatorApplication');
     $all_applications = msort($all_applications, 'getName');
     if ($query->getQueryKey() == 'launcher') {
         $groups = mgroup($all_applications, 'getApplicationGroup');
     } else {
         $groups = array($all_applications);
     }
     $group_names = PhabricatorApplication::getApplicationGroups();
     $groups = array_select_keys($groups, array_keys($group_names)) + $groups;
     $results = array();
     foreach ($groups as $group => $applications) {
         if (count($groups) > 1) {
             $results[] = phutil_tag('h1', array('class' => 'launcher-header'), idx($group_names, $group, $group));
         }
         $list = new PHUIObjectItemListView();
         $list->addClass('phui-object-item-launcher-list');
         foreach ($applications as $application) {
             $icon = $application->getIconName();
             if (!$icon) {
                 $icon = 'application';
             }
             // TODO: This sheet doesn't work the same way other sheets do so it
             // ends up with the wrong classes if we try to use PHUIIconView. This
             // is probably all changing in the redesign anyway.
             $icon_view = javelin_tag('span', array('class' => 'phui-icon-view ' . 'sprite-apps-large apps-' . $icon . '-dark-large', 'aural' => false), '');
             $description = phutil_tag('div', array('style' => 'white-space: nowrap; ' . 'overflow: hidden; ' . 'text-overflow: ellipsis;'), $application->getShortDescription());
             $item = id(new PHUIObjectItemView())->setHeader($application->getName())->setImageIcon($icon_view)->addAttribute($description)->addAction(id(new PHUIListItemView())->setName(pht('Help/Options'))->setIcon('fa-cog')->setHref('/applications/view/' . get_class($application) . '/'));
             if ($application->getBaseURI()) {
                 $item->setHref($application->getBaseURI());
             }
             if (!$application->isInstalled()) {
                 $item->addIcon('fa-times', pht('Uninstalled'));
             }
             if ($application->isBeta()) {
                 $item->addIcon('fa-star-half-o grey', pht('Beta'));
             }
             if (!$application->isFirstParty()) {
                 $item->addIcon('fa-puzzle-piece', pht('Extension'));
             }
             $list->addItem($item);
         }
         $results[] = $list;
     }
     return $results;
 }
 protected function renderResultList(array $revisions, PhabricatorSavedQuery $query, array $handles)
 {
     assert_instances_of($revisions, 'DifferentialRevision');
     $viewer = $this->requireViewer();
     $template = id(new DifferentialRevisionListView())->setUser($viewer)->setNoBox($this->isPanelContext());
     $views = array();
     if ($query->getQueryKey() == 'active') {
         $split = DifferentialRevisionQuery::splitResponsible($revisions, $query->getParameter('responsiblePHIDs'));
         list($blocking, $active, $waiting) = $split;
         $views[] = id(clone $template)->setHeader(pht('Blocking Others'))->setNoDataString(pht('No revisions are blocked on your action.'))->setHighlightAge(true)->setRevisions($blocking)->setHandles(array());
         $views[] = id(clone $template)->setHeader(pht('Action Required'))->setNoDataString(pht('No revisions require your action.'))->setHighlightAge(true)->setRevisions($active)->setHandles(array());
         $views[] = id(clone $template)->setHeader(pht('Waiting on Others'))->setNoDataString(pht('You have no revisions waiting on others.'))->setRevisions($waiting)->setHandles(array());
     } else {
         $views[] = id(clone $template)->setRevisions($revisions)->setHandles(array());
     }
     $phids = array_mergev(mpull($views, 'getRequiredHandlePHIDs'));
     if ($phids) {
         $handles = id(new PhabricatorHandleQuery())->setViewer($viewer)->withPHIDs($phids)->execute();
     } else {
         $handles = array();
     }
     foreach ($views as $view) {
         $view->setHandles($handles);
     }
     if (count($views) == 1) {
         // Reduce this to a PHUIObjectItemListView so we can get the free
         // support from ApplicationSearch.
         return head($views)->render();
     } else {
         return $views;
     }
 }
 private function renderBatchEditor(PhabricatorSavedQuery $saved_query)
 {
     $user = $this->getUser();
     if (!$this->canBatchEdit) {
         return null;
     }
     if (!$user->isLoggedIn()) {
         // Don't show the batch editor or excel export for logged-out users.
         // Technically we //could// let them export, but ehh.
         return null;
     }
     Javelin::initBehavior('maniphest-batch-selector', array('selectAll' => 'batch-select-all', 'selectNone' => 'batch-select-none', 'submit' => 'batch-select-submit', 'status' => 'batch-select-status-cell', 'idContainer' => 'batch-select-id-container', 'formID' => 'batch-select-form'));
     $select_all = javelin_tag('a', array('href' => '#', 'mustcapture' => true, 'class' => 'grey button', 'id' => 'batch-select-all'), pht('Select All'));
     $select_none = javelin_tag('a', array('href' => '#', 'mustcapture' => true, 'class' => 'grey button', 'id' => 'batch-select-none'), pht('Clear Selection'));
     $submit = phutil_tag('button', array('id' => 'batch-select-submit', 'disabled' => 'disabled', 'class' => 'disabled'), pht("Batch Edit Selected »"));
     $export = javelin_tag('a', array('href' => '/maniphest/export/' . $saved_query->getQueryKey() . '/', 'class' => 'grey button'), pht('Export to Excel'));
     $hidden = phutil_tag('div', array('id' => 'batch-select-id-container'), '');
     $editor = hsprintf('<table class="maniphest-batch-editor-layout">' . '<tr>' . '<td>%s%s</td>' . '<td>%s</td>' . '<td id="batch-select-status-cell">%s</td>' . '<td class="batch-select-submit-cell">%s%s</td>' . '</tr>' . '</table>', $select_all, $select_none, $export, '', $submit, $hidden);
     $editor = phabricator_form($user, array('method' => 'POST', 'action' => '/maniphest/batch/', 'id' => 'batch-select-form'), $editor);
     $box = id(new PHUIObjectBoxView())->setHeaderText(pht('Batch Task Editor'))->appendChild($editor);
     $content = phutil_tag_div('maniphest-batch-editor', $box);
     return $content;
 }
 protected function renderResultList(array $users, PhabricatorSavedQuery $query, array $handles)
 {
     assert_instances_of($users, 'PhabricatorUser');
     $request = $this->getRequest();
     $viewer = $this->requireViewer();
     $list = new PHUIObjectItemListView();
     $is_approval = $query->getQueryKey() == 'approval';
     foreach ($users as $user) {
         $primary_email = $user->loadPrimaryEmail();
         if ($primary_email && $primary_email->getIsVerified()) {
             $email = pht('Verified');
         } else {
             $email = pht('Unverified');
         }
         $item = new PHUIObjectItemView();
         $item->setHeader($user->getFullName())->setHref('/p/' . $user->getUsername() . '/')->addAttribute(phabricator_datetime($user->getDateCreated(), $viewer))->addAttribute($email)->setImageURI($user->getProfileImageURI());
         if ($is_approval && $primary_email) {
             $item->addAttribute($primary_email->getAddress());
         }
         if ($user->getIsDisabled()) {
             $item->addIcon('fa-ban', pht('Disabled'));
         }
         if (!$is_approval) {
             if (!$user->getIsApproved()) {
                 $item->addIcon('fa-clock-o', pht('Needs Approval'));
             }
         }
         if ($user->getIsAdmin()) {
             $item->addIcon('fa-star', pht('Admin'));
         }
         if ($user->getIsSystemAgent()) {
             $item->addIcon('fa-desktop', pht('Bot/Script'));
         }
         if ($viewer->getIsAdmin()) {
             $user_id = $user->getID();
             if ($is_approval) {
                 $item->addAction(id(new PHUIListItemView())->setIcon('fa-ban')->setName(pht('Disable'))->setWorkflow(true)->setHref($this->getApplicationURI('disapprove/' . $user_id . '/')));
                 $item->addAction(id(new PHUIListItemView())->setIcon('fa-thumbs-o-up')->setName(pht('Approve'))->setWorkflow(true)->setHref($this->getApplicationURI('approve/' . $user_id . '/')));
             }
         }
         $list->addItem($item);
     }
     return $list;
 }
 public function newUseResultsActions(PhabricatorSavedQuery $saved)
 {
     $viewer = $this->requireViewer();
     $can_export = $viewer->isLoggedIn();
     return array(id(new PhabricatorActionView())->setIcon('fa-download')->setName(pht('Export Query as .ics'))->setDisabled(!$can_export)->setHref('/calendar/export/edit/?queryKey=' . $saved->getQueryKey()));
 }
 protected function renderResultList(array $all_applications, PhabricatorSavedQuery $query, array $handle)
 {
     assert_instances_of($all_applications, 'PhabricatorApplication');
     $all_applications = msort($all_applications, 'getName');
     if ($query->getQueryKey() == 'launcher') {
         $groups = mgroup($all_applications, 'getApplicationGroup');
     } else {
         $groups = array($all_applications);
     }
     $group_names = PhabricatorApplication::getApplicationGroups();
     $groups = array_select_keys($groups, array_keys($group_names)) + $groups;
     $results = array();
     foreach ($groups as $group => $applications) {
         if (count($groups) > 1) {
             $results[] = phutil_tag('h1', array('class' => 'phui-object-item-list-header'), idx($group_names, $group, $group));
         }
         $list = new PHUIObjectItemListView();
         foreach ($applications as $application) {
             $icon = $application->getFontIcon();
             if (!$icon) {
                 $icon = 'application';
             }
             // TODO: This sheet doesn't work the same way other sheets do so it
             // ends up with the wrong classes if we try to use PHUIIconView. This
             // is probably all changing in the redesign anyway.
             $icon_view = javelin_tag('span', array('class' => 'phui-icon-view phui-font-fa ' . $icon, 'aural' => false), '');
             $description = $application->getShortDescription();
             $configure = id(new PHUIButtonView())->setTag('a')->setHref('/applications/view/' . get_class($application) . '/')->setText(pht('Configure'))->setColor(PHUIButtonView::GREY);
             $name = $application->getName();
             if ($application->isPrototype()) {
                 $name = $name . ' ' . pht('(Prototype)');
             }
             $item = id(new PHUIObjectItemView())->setHeader($name)->setImageIcon($icon_view)->setSubhead($description)->setLaunchButton($configure);
             if ($application->getBaseURI() && $application->isInstalled()) {
                 $item->setHref($application->getBaseURI());
             }
             if (!$application->isInstalled()) {
                 $item->addAttribute(pht('Uninstalled'));
                 $item->setDisabled(true);
             }
             if (!$application->isFirstParty()) {
                 $item->addAttribute(pht('Extension'));
             }
             $list->addItem($item);
         }
         $results[] = $list;
     }
     $result = new PhabricatorApplicationSearchResultView();
     $result->setContent($results);
     return $result;
 }
 protected function renderResultList(array $all_applications, PhabricatorSavedQuery $query, array $handle)
 {
     assert_instances_of($all_applications, 'PhabricatorApplication');
     $all_applications = msort($all_applications, 'getName');
     if ($query->getQueryKey() == 'launcher') {
         $groups = mgroup($all_applications, 'getApplicationGroup');
     } else {
         $groups = array($all_applications);
     }
     $group_names = PhabricatorApplication::getApplicationGroups();
     $groups = array_select_keys($groups, array_keys($group_names)) + $groups;
     $results = array();
     foreach ($groups as $group => $applications) {
         if (count($groups) > 1) {
             $results[] = phutil_tag('h1', array('class' => 'phui-object-item-list-header'), idx($group_names, $group, $group));
         }
         $list = new PHUIObjectItemListView();
         foreach ($applications as $application) {
             $icon = $application->getIcon();
             if (!$icon) {
                 $icon = 'application';
             }
             $description = $application->getShortDescription();
             $configure = id(new PHUIButtonView())->setTag('a')->setHref('/applications/view/' . get_class($application) . '/')->setText(pht('Configure'))->setColor(PHUIButtonView::GREY);
             $name = $application->getName();
             if ($application->isPrototype()) {
                 $name = $name . ' ' . pht('(Prototype)');
             }
             $item = id(new PHUIObjectItemView())->setHeader($name)->setImageIcon($icon)->setSubhead($description)->setLaunchButton($configure);
             if ($application->getBaseURI() && $application->isInstalled()) {
                 $item->setHref($application->getBaseURI());
             }
             if (!$application->isInstalled()) {
                 $item->addAttribute(pht('Uninstalled'));
                 $item->setDisabled(true);
             }
             if (!$application->isFirstParty()) {
                 $item->addAttribute(pht('Extension'));
             }
             $list->addItem($item);
         }
         $results[] = $list;
     }
     $result = new PhabricatorApplicationSearchResultView();
     $result->setContent($results);
     return $result;
 }