[ Index ]

PHP Cross Reference of Phabricator

title

Body

[close]

/src/applications/dashboard/query/ -> PhabricatorDashboardSearchEngine.php (source)

   1  <?php
   2  
   3  final class PhabricatorDashboardSearchEngine
   4    extends PhabricatorApplicationSearchEngine {
   5  
   6    public function getResultTypeDescription() {
   7      return pht('Dashboards');
   8    }
   9  
  10    public function getApplicationClassName() {
  11      return 'PhabricatorDashboardApplication';
  12    }
  13  
  14    public function buildSavedQueryFromRequest(AphrontRequest $request) {
  15      return new PhabricatorSavedQuery();
  16    }
  17  
  18    public function buildQueryFromSavedQuery(PhabricatorSavedQuery $saved) {
  19      return new PhabricatorDashboardQuery();
  20    }
  21  
  22    public function buildSearchForm(
  23      AphrontFormView $form,
  24      PhabricatorSavedQuery $saved_query) {
  25      return;
  26    }
  27  
  28    protected function getURI($path) {
  29      return '/dashboard/'.$path;
  30    }
  31  
  32    public function getBuiltinQueryNames() {
  33      return array(
  34        'all' => pht('All Dashboards'),
  35      );
  36    }
  37  
  38    public function buildSavedQueryFromBuiltin($query_key) {
  39  
  40      $query = $this->newSavedQuery();
  41      $query->setQueryKey($query_key);
  42  
  43      switch ($query_key) {
  44        case 'all':
  45          return $query;
  46      }
  47  
  48      return parent::buildSavedQueryFromBuiltin($query_key);
  49    }
  50  
  51    protected function renderResultList(
  52      array $dashboards,
  53      PhabricatorSavedQuery $query,
  54      array $handles) {
  55  
  56      $dashboards = mpull($dashboards, null, 'getPHID');
  57      $viewer = $this->requireViewer();
  58  
  59      if ($dashboards) {
  60        $installs = id(new PhabricatorDashboardInstall())
  61          ->loadAllWhere(
  62            'objectPHID IN (%Ls) AND dashboardPHID IN (%Ls)',
  63            array(
  64              PhabricatorHomeApplication::DASHBOARD_DEFAULT,
  65              $viewer->getPHID(),
  66            ),
  67            array_keys($dashboards));
  68        $installs = mpull($installs, null, 'getDashboardPHID');
  69      } else {
  70        $installs = array();
  71      }
  72  
  73      $list = new PHUIObjectItemListView();
  74      $list->setUser($viewer);
  75      $list->initBehavior('phabricator-tooltips', array());
  76      $list->requireResource('aphront-tooltip-css');
  77  
  78      foreach ($dashboards as $dashboard_phid => $dashboard) {
  79        $id = $dashboard->getID();
  80  
  81        $item = id(new PHUIObjectItemView())
  82          ->setObjectName(pht('Dashboard %d', $id))
  83          ->setHeader($dashboard->getName())
  84          ->setHref($this->getApplicationURI("view/{$id}/"))
  85          ->setObject($dashboard);
  86  
  87        if (isset($installs[$dashboard_phid])) {
  88          $install = $installs[$dashboard_phid];
  89          if ($install->getObjectPHID() == $viewer->getPHID()) {
  90            $attrs = array(
  91              'tip' => pht(
  92                'This dashboard is installed to your personal homepage.'),
  93            );
  94            $item->addIcon('fa-user', pht('Installed'), $attrs);
  95          } else {
  96            $attrs = array(
  97              'tip' => pht(
  98                'This dashboard is the default homepage for all users.'),
  99            );
 100            $item->addIcon('fa-globe', pht('Installed'), $attrs);
 101          }
 102        }
 103  
 104        $list->addItem($item);
 105      }
 106  
 107      return $list;
 108    }
 109  
 110  }


Generated: Sun Nov 30 09:20:46 2014 Cross-referenced by PHPXref 0.7.1