protected function renderResultList(array $countdowns, PhabricatorSavedQuery $query, array $handles)
 {
     assert_instances_of($countdowns, 'PhabricatorCountdown');
     $viewer = $this->requireViewer();
     $list = new PHUIObjectItemListView();
     $list->setUser($viewer);
     foreach ($countdowns as $countdown) {
         $id = $countdown->getID();
         $ended = false;
         $epoch = $countdown->getEpoch();
         if ($epoch <= PhabricatorTime::getNow()) {
             $ended = true;
         }
         $item = id(new PHUIObjectItemView())->setUser($viewer)->setObject($countdown)->setObjectName("C{$id}")->setHeader($countdown->getTitle())->setHref($this->getApplicationURI("{$id}/"))->addByline(pht('Created by %s', $handles[$countdown->getAuthorPHID()]->renderLink()));
         if ($ended) {
             $item->addAttribute(pht('Launched on %s', phabricator_datetime($epoch, $viewer)));
             $item->setDisabled(true);
         } else {
             $time_left = $epoch - PhabricatorTime::getNow();
             $num = round($time_left / (60 * 60 * 24));
             $noun = pht('Days');
             if ($num < 1) {
                 $num = round($time_left / (60 * 60), 1);
                 $noun = pht('Hours');
             }
             $item->setCountdown($num, $noun);
             $item->addAttribute(phabricator_datetime($epoch, $viewer));
         }
         $list->addItem($item);
     }
     $result = new PhabricatorApplicationSearchResultView();
     $result->setObjectList($list);
     $result->setNoDataString(pht('No countdowns found.'));
     return $result;
 }
 protected function renderResultList(array $panels, PhabricatorSavedQuery $query, array $handles)
 {
     $viewer = $this->requireViewer();
     $list = new PHUIObjectItemListView();
     $list->setUser($viewer);
     foreach ($panels as $panel) {
         $item = id(new PHUIObjectItemView())->setObjectName($panel->getMonogram())->setHeader($panel->getName())->setHref('/' . $panel->getMonogram())->setObject($panel);
         $impl = $panel->getImplementation();
         if ($impl) {
             $type_text = $impl->getPanelTypeName();
             $type_icon = 'none';
         } else {
             $type_text = nonempty($panel->getPanelType(), pht('Unknown Type'));
             $type_icon = 'fa-question';
         }
         $item->addIcon($type_icon, $type_text);
         if ($panel->getIsArchived()) {
             $item->setDisabled(true);
         }
         $list->addItem($item);
     }
     $result = new PhabricatorApplicationSearchResultView();
     $result->setObjectList($list);
     $result->setNoDataString(pht('No panels found.'));
     return $result;
 }
 protected function renderResultList(array $documents, PhabricatorSavedQuery $query, array $handles)
 {
     assert_instances_of($documents, 'PhrictionDocument');
     $viewer = $this->requireViewer();
     $list = new PHUIObjectItemListView();
     $list->setUser($viewer);
     foreach ($documents as $document) {
         $content = $document->getContent();
         $slug = $document->getSlug();
         $author_phid = $content->getAuthorPHID();
         $slug_uri = PhrictionDocument::getSlugURI($slug);
         $byline = pht('Edited by %s', $handles[$author_phid]->renderLink());
         $updated = phabricator_datetime($content->getDateCreated(), $viewer);
         $item = id(new PHUIObjectItemView())->setHeader($content->getTitle())->setHref($slug_uri)->addByline($byline)->addIcon('none', $updated);
         $item->addAttribute($slug_uri);
         switch ($document->getStatus()) {
             case PhrictionDocumentStatus::STATUS_DELETED:
                 $item->setDisabled(true);
                 $item->addIcon('delete', pht('Deleted'));
                 break;
             case PhrictionDocumentStatus::STATUS_MOVED:
                 $item->setDisabled(true);
                 $item->addIcon('arrow-right', pht('Moved Away'));
                 break;
         }
         $list->addItem($item);
     }
     $result = new PhabricatorApplicationSearchResultView();
     $result->setObjectList($list);
     $result->setNoDataString(pht('No documents found.'));
     return $result;
 }
 protected function renderResultList(array $dashboards, PhabricatorSavedQuery $query, array $handles)
 {
     $dashboards = mpull($dashboards, null, 'getPHID');
     $viewer = $this->requireViewer();
     if ($dashboards) {
         $installs = id(new PhabricatorDashboardInstall())->loadAllWhere('objectPHID IN (%Ls) AND dashboardPHID IN (%Ls)', array(PhabricatorHomeApplication::DASHBOARD_DEFAULT, $viewer->getPHID()), array_keys($dashboards));
         $installs = mpull($installs, null, 'getDashboardPHID');
     } else {
         $installs = array();
     }
     $list = new PHUIObjectItemListView();
     $list->setUser($viewer);
     $list->initBehavior('phabricator-tooltips', array());
     $list->requireResource('aphront-tooltip-css');
     foreach ($dashboards as $dashboard_phid => $dashboard) {
         $id = $dashboard->getID();
         $item = id(new PHUIObjectItemView())->setObjectName(pht('Dashboard %d', $id))->setHeader($dashboard->getName())->setHref($this->getApplicationURI("view/{$id}/"))->setObject($dashboard);
         if (isset($installs[$dashboard_phid])) {
             $install = $installs[$dashboard_phid];
             if ($install->getObjectPHID() == $viewer->getPHID()) {
                 $attrs = array('tip' => pht('This dashboard is installed to your personal homepage.'));
                 $item->addIcon('fa-user', pht('Installed'), $attrs);
             } else {
                 $attrs = array('tip' => pht('This dashboard is the default homepage for all users.'));
                 $item->addIcon('fa-globe', pht('Installed'), $attrs);
             }
         }
         $list->addItem($item);
     }
     $result = new PhabricatorApplicationSearchResultView();
     $result->setObjectList($list);
     $result->setNoDataString(pht('No dashboards found.'));
     return $result;
 }
 protected function renderResultList(array $blogs, PhabricatorSavedQuery $query, array $handles)
 {
     assert_instances_of($blogs, 'PhameBlog');
     $viewer = $this->requireViewer();
     $list = new PHUIObjectItemListView();
     $list->setUser($viewer);
     foreach ($blogs as $blog) {
         $id = $blog->getID();
         if ($blog->getDomain()) {
             $domain = $blog->getDomain();
         } else {
             $domain = pht('Local Blog');
         }
         $item = id(new PHUIObjectItemView())->setUser($viewer)->setObject($blog)->setHeader($blog->getName())->setImageURI($blog->getProfileImageURI())->setDisabled($blog->isArchived())->setHref($this->getApplicationURI("/blog/view/{$id}/"))->addAttribute($domain);
         if (!$blog->isArchived()) {
             $button = id(new PHUIButtonView())->setTag('a')->setText('New Post')->setHref($this->getApplicationURI('/post/edit/?blog=' . $id));
             $item->setLaunchButton($button);
         }
         $list->addItem($item);
     }
     $result = new PhabricatorApplicationSearchResultView();
     $result->setObjectList($list);
     $result->setNoDataString(pht('No blogs found.'));
     return $result;
 }
 protected function renderResultList(array $pastes, PhabricatorSavedQuery $query, array $handles)
 {
     assert_instances_of($pastes, 'PhabricatorPaste');
     $viewer = $this->requireViewer();
     $lang_map = PhabricatorEnv::getEnvConfig('pygments.dropdown-choices');
     $list = new PHUIObjectItemListView();
     $list->setUser($viewer);
     foreach ($pastes as $paste) {
         $created = phabricator_date($paste->getDateCreated(), $viewer);
         $author = $handles[$paste->getAuthorPHID()]->renderLink();
         $snippet_type = $paste->getSnippet()->getType();
         $lines = phutil_split_lines($paste->getSnippet()->getContent());
         $preview = id(new PhabricatorSourceCodeView())->setLines($lines)->setTruncatedFirstBytes($snippet_type == PhabricatorPasteSnippet::FIRST_BYTES)->setTruncatedFirstLines($snippet_type == PhabricatorPasteSnippet::FIRST_LINES)->setURI(new PhutilURI($paste->getURI()));
         $source_code = phutil_tag('div', array('class' => 'phabricator-source-code-summary'), $preview);
         $created = phabricator_datetime($paste->getDateCreated(), $viewer);
         $line_count = count($lines);
         $line_count = pht('%s Line(s)', new PhutilNumber($line_count));
         $title = nonempty($paste->getTitle(), pht('(An Untitled Masterwork)'));
         $item = id(new PHUIObjectItemView())->setObjectName('P' . $paste->getID())->setHeader($title)->setHref('/P' . $paste->getID())->setObject($paste)->addByline(pht('Author: %s', $author))->addIcon('none', $created)->addIcon('none', $line_count)->appendChild($source_code);
         if ($paste->isArchived()) {
             $item->setDisabled(true);
         }
         $lang_name = $paste->getLanguage();
         if ($lang_name) {
             $lang_name = idx($lang_map, $lang_name, $lang_name);
             $item->addIcon('none', $lang_name);
         }
         $list->addItem($item);
     }
     $result = new PhabricatorApplicationSearchResultView();
     $result->setObjectList($list);
     $result->setNoDataString(pht('No pastes found.'));
     return $result;
 }
 protected function renderResultList(array $posts, PhabricatorSavedQuery $query, array $handles)
 {
     assert_instances_of($posts, 'PhamePost');
     $viewer = $this->requireViewer();
     $list = new PHUIObjectItemListView();
     $list->setUser($viewer);
     foreach ($posts as $post) {
         $id = $post->getID();
         $blog = $post->getBlog();
         $blog_name = $viewer->renderHandle($post->getBlogPHID())->render();
         $blog_name = pht('Blog: %s', $blog_name);
         $item = id(new PHUIObjectItemView())->setUser($viewer)->setObject($post)->setObjectName($post->getMonogram())->setHeader($post->getTitle())->setStatusIcon('fa-star')->setHref($post->getViewURI())->addAttribute($blog_name);
         if ($post->isDraft()) {
             $item->setStatusIcon('fa-star-o grey');
             $item->setDisabled(true);
             $item->addIcon('fa-star-o', pht('Draft Post'));
         } else {
             if ($post->isArchived()) {
                 $item->setStatusIcon('fa-ban grey');
                 $item->setDisabled(true);
                 $item->addIcon('fa-ban', pht('Archived Post'));
             } else {
                 $date = $post->getDatePublished();
                 $item->setEpoch($date);
             }
         }
         $item->addAction(id(new PHUIListItemView())->setIcon('fa-pencil')->setHref($post->getEditURI()));
         $list->addItem($item);
     }
     $result = new PhabricatorApplicationSearchResultView();
     $result->setObjectList($list);
     $result->setNoDataString(pht('No blogs posts found.'));
     return $result;
 }
 private function renderBlogList(array $blogs, PhabricatorUser $user, $nodata)
 {
     $view = new PHUIObjectItemListView();
     $view->setNoDataString($nodata);
     $view->setUser($user);
     foreach ($blogs as $blog) {
         $item = id(new PHUIObjectItemView())->setHeader($blog->getName())->setHref($this->getApplicationURI('blog/view/' . $blog->getID() . '/'))->setObject($blog);
         $view->addItem($item);
     }
     return $view;
 }
 protected function renderResultList(array $merchants, PhabricatorSavedQuery $query, array $handles)
 {
     assert_instances_of($merchants, 'PhortuneMerchant');
     $viewer = $this->requireViewer();
     $list = new PHUIObjectItemListView();
     $list->setUser($viewer);
     foreach ($merchants as $merchant) {
         $item = id(new PHUIObjectItemView())->setObjectName(pht('Merchant %d', $merchant->getID()))->setHeader($merchant->getName())->setHref('/phortune/merchant/' . $merchant->getID() . '/')->setObject($merchant);
         $list->addItem($item);
     }
     return $list;
 }
 protected function renderResultList(array $queues, PhabricatorSavedQuery $query, array $handles)
 {
     assert_instances_of($queues, 'NuanceQueue');
     $viewer = $this->requireViewer();
     $list = new PHUIObjectItemListView();
     $list->setUser($viewer);
     foreach ($queues as $queue) {
         $item = id(new PHUIObjectItemView())->setObjectName(pht('Queue %d', $queue->getID()))->setHeader($queue->getName())->setHref($queue->getURI());
         $list->addItem($item);
     }
     return $list;
 }
 private function renderBlogList(array $blogs, PhabricatorUser $viewer, $nodata)
 {
     $view = new PHUIObjectItemListView();
     $view->setNoDataString($nodata);
     $view->setUser($viewer);
     foreach ($blogs as $blog) {
         $id = $blog->getID();
         $item = id(new PHUIObjectItemView())->setUser($viewer)->setObject($blog)->setHeader($blog->getName())->setStatusIcon('fa-star')->setHref($this->getApplicationURI("/blog/view/{$id}/"))->addAttribute($blog->getSkin())->addAttribute($blog->getDomain());
         $view->addItem($item);
     }
     return $view;
 }
 protected function renderResultList(array $networks, PhabricatorSavedQuery $query, array $handles)
 {
     assert_instances_of($networks, 'AlmanacNetwork');
     $viewer = $this->requireViewer();
     $list = new PHUIObjectItemListView();
     $list->setUser($viewer);
     foreach ($networks as $network) {
         $id = $network->getID();
         $item = id(new PHUIObjectItemView())->setObjectName(pht('Network %d', $id))->setHeader($network->getName())->setHref($this->getApplicationURI("network/{$id}/"))->setObject($network);
         $list->addItem($item);
     }
     return $list;
 }
 protected function renderResultList(array $dashboards, PhabricatorSavedQuery $query, array $handles)
 {
     $dashboards = mpull($dashboards, null, 'getPHID');
     $viewer = $this->requireViewer();
     if ($dashboards) {
         $installs = id(new PhabricatorDashboardInstall())->loadAllWhere('objectPHID IN (%Ls) AND dashboardPHID IN (%Ls)', array(PhabricatorHomeApplication::DASHBOARD_DEFAULT, $viewer->getPHID()), array_keys($dashboards));
         $installs = mpull($installs, null, 'getDashboardPHID');
     } else {
         $installs = array();
     }
     $proj_phids = array();
     foreach ($dashboards as $dashboard) {
         foreach ($dashboard->getProjectPHIDs() as $project_phid) {
             $proj_phids[] = $project_phid;
         }
     }
     $proj_handles = id(new PhabricatorHandleQuery())->setViewer($viewer)->withPHIDs($proj_phids)->execute();
     $list = new PHUIObjectItemListView();
     $list->setUser($viewer);
     $list->initBehavior('phabricator-tooltips', array());
     $list->requireResource('aphront-tooltip-css');
     foreach ($dashboards as $dashboard_phid => $dashboard) {
         $id = $dashboard->getID();
         $item = id(new PHUIObjectItemView())->setObjectName(pht('Dashboard %d', $id))->setHeader($dashboard->getName())->setHref($this->getApplicationURI("view/{$id}/"))->setObject($dashboard);
         if (isset($installs[$dashboard_phid])) {
             $install = $installs[$dashboard_phid];
             if ($install->getObjectPHID() == $viewer->getPHID()) {
                 $attrs = array('tip' => pht('This dashboard is installed to your personal homepage.'));
                 $item->addIcon('fa-user', pht('Installed'), $attrs);
             } else {
                 $attrs = array('tip' => pht('This dashboard is the default homepage for all users.'));
                 $item->addIcon('fa-globe', pht('Installed'), $attrs);
             }
         }
         $project_handles = array_select_keys($proj_handles, $dashboard->getProjectPHIDs());
         $item->addAttribute(id(new PHUIHandleTagListView())->setLimit(4)->setNoDataString(pht('No Projects'))->setSlim(true)->setHandles($project_handles));
         if ($dashboard->isClosed()) {
             $item->setDisabled(true);
         }
         $can_edit = PhabricatorPolicyFilter::hasCapability($viewer, $dashboard, PhabricatorPolicyCapability::CAN_EDIT);
         $href_view = $this->getApplicationURI("manage/{$id}/");
         $item->addAction(id(new PHUIListItemView())->setName(pht('Manage'))->setIcon('fa-th')->setHref($href_view));
         $href_edit = $this->getApplicationURI("edit/{$id}/");
         $item->addAction(id(new PHUIListItemView())->setName(pht('Edit'))->setIcon('fa-pencil')->setHref($href_edit)->setDisabled(!$can_edit));
         $list->addItem($item);
     }
     $result = new PhabricatorApplicationSearchResultView();
     $result->setObjectList($list);
     $result->setNoDataString(pht('No dashboards found.'));
     return $result;
 }
 protected function renderResultList(array $merchants, PhabricatorSavedQuery $query, array $handles)
 {
     assert_instances_of($merchants, 'PhortuneMerchant');
     $viewer = $this->requireViewer();
     $list = new PHUIObjectItemListView();
     $list->setUser($viewer);
     foreach ($merchants as $merchant) {
         $item = id(new PHUIObjectItemView())->setSubhead(pht('Merchant %d', $merchant->getID()))->setHeader($merchant->getName())->setHref('/phortune/merchant/' . $merchant->getID() . '/')->setObject($merchant)->setImageIcon('fa-bank');
         $list->addItem($item);
     }
     $result = new PhabricatorApplicationSearchResultView();
     $result->setObjectList($list);
     $result->setNoDataString(pht('No merchants found.'));
     return $result;
 }
 protected function renderResultList(array $services, PhabricatorSavedQuery $query, array $handles)
 {
     assert_instances_of($services, 'AlmanacService');
     $viewer = $this->requireViewer();
     $list = new PHUIObjectItemListView();
     $list->setUser($viewer);
     foreach ($services as $service) {
         $item = id(new PHUIObjectItemView())->setObjectName(pht('Service %d', $service->getID()))->setHeader($service->getName())->setHref($service->getURI())->setObject($service)->addIcon($service->getServiceImplementation()->getServiceTypeIcon(), $service->getServiceImplementation()->getServiceTypeShortName());
         $list->addItem($item);
     }
     $result = new PhabricatorApplicationSearchResultView();
     $result->setObjectList($list);
     $result->setNoDataString(pht('No Almanac Services found.'));
     return $result;
 }
 protected function renderResultList(array $namespaces, PhabricatorSavedQuery $query, array $handles)
 {
     assert_instances_of($namespaces, 'AlmanacNamespace');
     $viewer = $this->requireViewer();
     $list = new PHUIObjectItemListView();
     $list->setUser($viewer);
     foreach ($namespaces as $namespace) {
         $id = $namespace->getID();
         $item = id(new PHUIObjectItemView())->setObjectName(pht('Namespace %d', $id))->setHeader($namespace->getName())->setHref($this->getApplicationURI("namespace/{$id}/"))->setObject($namespace);
         $list->addItem($item);
     }
     $result = new PhabricatorApplicationSearchResultView();
     $result->setObjectList($list);
     $result->setNoDataString(pht('No Almanac namespaces found.'));
     return $result;
 }
 protected function renderResultList(array $blogs, PhabricatorSavedQuery $query, array $handles)
 {
     assert_instances_of($blogs, 'PhameBlog');
     $viewer = $this->requireViewer();
     $list = new PHUIObjectItemListView();
     $list->setUser($viewer);
     foreach ($blogs as $blog) {
         $id = $blog->getID();
         $item = id(new PHUIObjectItemView())->setUser($viewer)->setObject($blog)->setHeader($blog->getName())->setStatusIcon('fa-star')->setHref($this->getApplicationURI("/blog/view/{$id}/"))->addAttribute($blog->getSkin())->addAttribute($blog->getDomain());
         $list->addItem($item);
     }
     $result = new PhabricatorApplicationSearchResultView();
     $result->setObjectList($list);
     $result->setNoDataString(pht('No blogs found.'));
     return $result;
 }
 protected function renderResultList(array $items, PhabricatorSavedQuery $query, array $handles)
 {
     assert_instances_of($items, 'NuanceItem');
     $viewer = $this->requireViewer();
     $list = new PHUIObjectItemListView();
     $list->setUser($viewer);
     foreach ($items as $item) {
         $impl = $item->getImplementation();
         $view = id(new PHUIObjectItemView())->setObjectName(pht('Item %d', $item->getID()))->setHeader($item->getDisplayName())->setHref($item->getURI());
         $view->addIcon($impl->getItemTypeDisplayIcon(), $impl->getItemTypeDisplayName());
         $list->addItem($view);
     }
     $result = new PhabricatorApplicationSearchResultView();
     $result->setObjectList($list);
     $result->setNoDataString(pht('No items found.'));
     return $result;
 }
 protected function renderResultList(array $keys, PhabricatorSavedQuery $query, array $handles)
 {
     assert_instances_of($keys, 'PhabricatorAuthSSHKey');
     $viewer = $this->requireViewer();
     $list = new PHUIObjectItemListView();
     $list->setUser($viewer);
     foreach ($keys as $key) {
         $item = id(new PHUIObjectItemView())->setObjectName(pht('SSH Key %d', $key->getID()))->setHeader($key->getName())->setHref($key->getURI());
         if (!$key->getIsActive()) {
             $item->setDisabled(true);
         }
         $list->addItem($item);
     }
     $result = new PhabricatorApplicationSearchResultView();
     $result->setObjectList($list);
     $result->setNoDataString(pht('No matching SSH keys.'));
     return $result;
 }
 protected function renderResultList(array $spaces, PhabricatorSavedQuery $query, array $handles)
 {
     assert_instances_of($spaces, 'PhabricatorSpacesNamespace');
     $viewer = $this->requireViewer();
     $list = new PHUIObjectItemListView();
     $list->setUser($viewer);
     foreach ($spaces as $space) {
         $item = id(new PHUIObjectItemView())->setObjectName($space->getMonogram())->setHeader($space->getNamespaceName())->setHref('/' . $space->getMonogram());
         if ($space->getIsDefaultNamespace()) {
             $item->addIcon('fa-certificate', pht('Default Space'));
         }
         if ($space->getIsArchived()) {
             $item->setDisabled(true);
         }
         $list->addItem($item);
     }
     return $list;
 }
 protected function renderResultList(array $devices, PhabricatorSavedQuery $query, array $handles)
 {
     assert_instances_of($devices, 'AlmanacDevice');
     $viewer = $this->requireViewer();
     $list = new PHUIObjectItemListView();
     $list->setUser($viewer);
     foreach ($devices as $device) {
         $item = id(new PHUIObjectItemView())->setObjectName(pht('Device %d', $device->getID()))->setHeader($device->getName())->setHref($device->getURI())->setObject($device);
         if ($device->isClusterDevice()) {
             $item->addIcon('fa-sitemap', pht('Cluster Device'));
         }
         $list->addItem($item);
     }
     $result = new PhabricatorApplicationSearchResultView();
     $result->setObjectList($list);
     $result->setNoDataString(pht('No Almanac Devices found.'));
     return $result;
 }
 protected function renderResultList(array $services, PhabricatorSavedQuery $query, array $handles)
 {
     assert_instances_of($services, 'AlmanacService');
     $viewer = $this->requireViewer();
     $list = new PHUIObjectItemListView();
     $list->setUser($viewer);
     foreach ($services as $service) {
         $item = id(new PHUIObjectItemView())->setObjectName(pht('Service %d', $service->getID()))->setHeader($service->getName())->setHref($service->getURI())->setObject($service)->addIcon($service->getServiceType()->getServiceTypeIcon(), $service->getServiceType()->getServiceTypeShortName());
         if ($service->getIsLocked() || $service->getServiceType()->isClusterServiceType()) {
             if ($service->getIsLocked()) {
                 $item->addIcon('fa-lock', pht('Locked'));
             } else {
                 $item->addIcon('fa-unlock-alt red', pht('Unlocked'));
             }
         }
         $list->addItem($item);
     }
     return $list;
 }
 protected function renderResultList(array $countdowns, PhabricatorSavedQuery $query, array $handles)
 {
     assert_instances_of($countdowns, 'PhabricatorCountdown');
     $viewer = $this->requireViewer();
     $list = new PHUIObjectItemListView();
     $list->setUser($viewer);
     foreach ($countdowns as $countdown) {
         $id = $countdown->getID();
         $item = id(new PHUIObjectItemView())->setObjectName("C{$id}")->setHeader($countdown->getTitle())->setHref($this->getApplicationURI("{$id}/"))->addByline(pht('Created by %s', $handles[$countdown->getAuthorPHID()]->renderLink()));
         $epoch = $countdown->getEpoch();
         if ($epoch >= time()) {
             $item->addIcon('none', pht('Ends %s', phabricator_datetime($epoch, $viewer)));
         } else {
             $item->addIcon('delete', pht('Ended %s', phabricator_datetime($epoch, $viewer)));
             $item->setDisabled(true);
         }
         $list->addItem($item);
     }
     return $list;
 }
 protected function renderResultList(array $credentials, PhabricatorSavedQuery $query, array $handles)
 {
     assert_instances_of($credentials, 'PassphraseCredential');
     $viewer = $this->requireViewer();
     $list = new PHUIObjectItemListView();
     $list->setUser($viewer);
     foreach ($credentials as $credential) {
         $item = id(new PHUIObjectItemView())->setObjectName('K' . $credential->getID())->setHeader($credential->getName())->setHref('/K' . $credential->getID())->setObject($credential);
         $item->addAttribute(pht('Login: %s', $credential->getUsername()));
         if ($credential->getIsDestroyed()) {
             $item->addIcon('fa-ban', pht('Destroyed'));
             $item->setDisabled(true);
         }
         $type = PassphraseCredentialType::getTypeByConstant($credential->getCredentialType());
         if ($type) {
             $item->addIcon('fa-wrench', $type->getCredentialTypeName());
         }
         $list->addItem($item);
     }
     return $list;
 }
 private function processEditRequest()
 {
     $parent = $this->getDelegatingController();
     $request = $this->getRequest();
     $user = $request->getUser();
     $engine = $this->getSearchEngine();
     $nav = $this->getNavigation();
     if (!$nav) {
         $nav = $this->buildNavigation();
     }
     $named_queries = $engine->loadAllNamedQueries();
     $list_id = celerity_generate_unique_node_id();
     $list = new PHUIObjectItemListView();
     $list->setUser($user);
     $list->setID($list_id);
     Javelin::initBehavior('search-reorder-queries', array('listID' => $list_id, 'orderURI' => '/search/order/' . get_class($engine) . '/'));
     foreach ($named_queries as $named_query) {
         $class = get_class($engine);
         $key = $named_query->getQueryKey();
         $item = id(new PHUIObjectItemView())->setHeader($named_query->getQueryName())->setHref($engine->getQueryResultsPageURI($key));
         if ($named_query->getIsBuiltin() && $named_query->getIsDisabled()) {
             $icon = 'fa-plus';
         } else {
             $icon = 'fa-times';
         }
         $item->addAction(id(new PHUIListItemView())->setIcon($icon)->setHref('/search/delete/' . $key . '/' . $class . '/')->setWorkflow(true));
         if ($named_query->getIsBuiltin()) {
             if ($named_query->getIsDisabled()) {
                 $item->addIcon('fa-times lightgreytext', pht('Disabled'));
                 $item->setDisabled(true);
             } else {
                 $item->addIcon('fa-lock lightgreytext', pht('Builtin'));
             }
         } else {
             $item->addAction(id(new PHUIListItemView())->setIcon('fa-pencil')->setHref('/search/edit/' . $key . '/'));
         }
         $item->setGrippable(true);
         $item->addSigil('named-query');
         $item->setMetadata(array('queryKey' => $named_query->getQueryKey()));
         $list->addItem($item);
     }
     $list->setNoDataString(pht('No saved queries.'));
     $crumbs = $parent->buildApplicationCrumbs()->addTextCrumb(pht('Saved Queries'), $engine->getQueryManagementURI());
     $nav->selectFilter('query/edit');
     $box = id(new PHUIObjectBoxView())->setHeaderText(pht('Saved Queries'))->setObjectList($list);
     return $this->newPage()->setApplicationMenu($this->buildApplicationMenu())->setTitle(pht('Saved Queries'))->setCrumbs($crumbs)->setNavigation($nav)->appendChild($box);
 }
 protected function renderResultList(array $projects, PhabricatorSavedQuery $query, array $handles)
 {
     assert_instances_of($projects, 'PhabricatorProject');
     $viewer = $this->requireViewer();
     $handles = $viewer->loadHandles(mpull($projects, 'getPHID'));
     $list = new PHUIObjectItemListView();
     $list->setUser($viewer);
     $can_edit_projects = id(new PhabricatorPolicyFilter())->setViewer($viewer)->requireCapabilities(array(PhabricatorPolicyCapability::CAN_EDIT))->apply($projects);
     foreach ($projects as $key => $project) {
         $id = $project->getID();
         $tag_list = id(new PHUIHandleTagListView())->setSlim(true)->setHandles(array($handles[$project->getPHID()]));
         $item = id(new PHUIObjectItemView())->setHeader($project->getName())->setHref($this->getApplicationURI("view/{$id}/"))->setImageURI($project->getProfileImageURI())->addAttribute($tag_list);
         if ($project->getStatus() == PhabricatorProjectStatus::STATUS_ARCHIVED) {
             $item->addIcon('delete-grey', pht('Archived'));
             $item->setDisabled(true);
         }
         $list->addItem($item);
     }
     $result = new PhabricatorApplicationSearchResultView();
     $result->setObjectList($list);
     $result->setNoDataString(pht('No projects found.'));
     return $result;
 }
 protected function renderResultList(array $documents, PhabricatorSavedQuery $query, array $handles)
 {
     assert_instances_of($documents, 'LegalpadDocument');
     $viewer = $this->requireViewer();
     $list = new PHUIObjectItemListView();
     $list->setUser($viewer);
     foreach ($documents as $document) {
         $last_updated = phabricator_date($document->getDateModified(), $viewer);
         $title = $document->getTitle();
         $item = id(new PHUIObjectItemView())->setObjectName($document->getMonogram())->setHeader($title)->setHref('/' . $document->getMonogram())->setObject($document);
         $no_signatures = LegalpadDocument::SIGNATURE_TYPE_NONE;
         if ($document->getSignatureType() == $no_signatures) {
             $item->addIcon('none', pht('Not Signable'));
         } else {
             $type_name = $document->getSignatureTypeName();
             $type_icon = $document->getSignatureTypeIcon();
             $item->addIcon($type_icon, $type_name);
             if ($viewer->getPHID()) {
                 $signature = $document->getUserSignature($viewer->getPHID());
             } else {
                 $signature = null;
             }
             if ($signature) {
                 $item->addAttribute(array(id(new PHUIIconView())->setIconFont('fa-check-square-o', 'green'), ' ', pht('Signed on %s', phabricator_date($signature->getDateCreated(), $viewer))));
             } else {
                 $item->addAttribute(array(id(new PHUIIconView())->setIconFont('fa-square-o', 'grey'), ' ', pht('Not Signed')));
             }
         }
         $item->addIcon('fa-pencil grey', pht('Version %d (%s)', $document->getVersions(), $last_updated));
         $list->addItem($item);
     }
     $result = new PhabricatorApplicationSearchResultView();
     $result->setObjectList($list);
     $result->setNoDataString(pht('No documents found.'));
     return $result;
 }
 protected function renderResultList(array $projects, PhabricatorSavedQuery $query, array $handles)
 {
     assert_instances_of($projects, 'PhabricatorProject');
     $viewer = $this->requireViewer();
     $list = new PHUIObjectItemListView();
     $list->setUser($viewer);
     foreach ($projects as $project) {
         $id = $project->getID();
         $workboards_uri = $this->getApplicationURI("board/{$id}/");
         $members_uri = $this->getApplicationURI("members/{$id}/");
         $workboards_url = phutil_tag('a', array('href' => $workboards_uri), pht('Workboards'));
         $members_url = phutil_tag('a', array('href' => $members_uri), pht('Members'));
         $tag_list = id(new PHUIHandleTagListView())->setSlim(true)->setHandles(array($handles[$project->getPHID()]));
         $item = id(new PHUIObjectItemView())->setHeader($project->getName())->setHref($this->getApplicationURI("view/{$id}/"))->setImageURI($project->getProfileImageURI())->addAttribute($tag_list)->addAttribute($workboards_url)->addAttribute($members_url);
         if ($project->getStatus() == PhabricatorProjectStatus::STATUS_ARCHIVED) {
             $item->addIcon('delete-grey', pht('Archived'));
             $item->setDisabled(true);
         }
         $list->addItem($item);
     }
     return $list;
 }
 protected function renderResultList(array $conpherences, PhabricatorSavedQuery $query, array $handles)
 {
     assert_instances_of($conpherences, 'ConpherenceThread');
     $viewer = $this->requireViewer();
     $policy_objects = ConpherenceThread::loadViewPolicyObjects($viewer, $conpherences);
     $engines = array();
     $fulltext = $query->getParameter('fulltext');
     if (strlen($fulltext) && $conpherences) {
         $context = $this->loadContextMessages($conpherences, $fulltext);
         $author_phids = array();
         foreach ($context as $phid => $messages) {
             $conpherence = $conpherences[$phid];
             $engine = id(new PhabricatorMarkupEngine())->setViewer($viewer)->setContextObject($conpherence);
             foreach ($messages as $group) {
                 foreach ($group as $message) {
                     $xaction = $message['xaction'];
                     if ($xaction) {
                         $author_phids[] = $xaction->getAuthorPHID();
                         $engine->addObject($xaction->getComment(), PhabricatorApplicationTransactionComment::MARKUP_FIELD_COMMENT);
                     }
                 }
             }
             $engine->process();
             $engines[$phid] = $engine;
         }
         $handles = $viewer->loadHandles($author_phids);
         $handles = iterator_to_array($handles);
     } else {
         $context = array();
     }
     $content = array();
     $list = new PHUIObjectItemListView();
     $list->setUser($viewer);
     foreach ($conpherences as $conpherence_phid => $conpherence) {
         $created = phabricator_date($conpherence->getDateCreated(), $viewer);
         $title = $conpherence->getDisplayTitle($viewer);
         $monogram = $conpherence->getMonogram();
         $icon_name = $conpherence->getPolicyIconName($policy_objects);
         $icon = id(new PHUIIconView())->setIcon($icon_name);
         if (!strlen($fulltext)) {
             $item = id(new PHUIObjectItemView())->setObjectName($conpherence->getMonogram())->setHeader($title)->setHref('/' . $conpherence->getMonogram())->setObject($conpherence)->setImageURI($conpherence->getProfileImageURI())->addIcon('none', $created)->addIcon('none', pht('Messages: %d', $conpherence->getMessageCount()))->addAttribute(array($icon, ' ', pht('Last updated %s', phabricator_datetime($conpherence->getDateModified(), $viewer))));
             $list->addItem($item);
         } else {
             $messages = idx($context, $conpherence_phid);
             $box = array();
             $list = null;
             if ($messages) {
                 foreach ($messages as $group) {
                     $rows = array();
                     foreach ($group as $message) {
                         $xaction = $message['xaction'];
                         if (!$xaction) {
                             continue;
                         }
                         $view = id(new ConpherenceTransactionView())->setUser($viewer)->setHandles($handles)->setMarkupEngine($engines[$conpherence_phid])->setConpherenceThread($conpherence)->setConpherenceTransaction($xaction)->setSearchResult(true)->addClass('conpherence-fulltext-result');
                         if ($message['match']) {
                             $view->addClass('conpherence-fulltext-match');
                         }
                         $rows[] = $view;
                     }
                     $box[] = id(new PHUIBoxView())->appendChild($rows)->addClass('conpherence-fulltext-results');
                 }
             }
             $header = id(new PHUIHeaderView())->setHeader($title)->setHeaderIcon($icon_name)->setHref('/' . $monogram);
             $content[] = id(new PHUIObjectBoxView())->setHeader($header)->appendChild($box);
         }
     }
     if ($list) {
         $content = $list;
     } else {
         $content = id(new PHUIBoxView())->addClass('conpherence-search-room-results')->appendChild($content);
     }
     $result = new PhabricatorApplicationSearchResultView();
     $result->setContent($content);
     $result->setNoDataString(pht('No results found.'));
     return $result;
 }