[ Index ]

PHP Cross Reference of Phabricator

title

Body

[close]

/src/applications/dashboard/controller/ -> PhabricatorDashboardViewController.php (source)

   1  <?php
   2  
   3  final class PhabricatorDashboardViewController
   4    extends PhabricatorDashboardController {
   5  
   6    private $id;
   7  
   8    public function shouldAllowPublic() {
   9      return true;
  10    }
  11  
  12    public function willProcessRequest(array $data) {
  13      $this->id = $data['id'];
  14    }
  15  
  16    public function processRequest() {
  17      $request = $this->getRequest();
  18      $viewer = $request->getUser();
  19  
  20      $dashboard = id(new PhabricatorDashboardQuery())
  21        ->setViewer($viewer)
  22        ->withIDs(array($this->id))
  23        ->needPanels(true)
  24        ->executeOne();
  25      if (!$dashboard) {
  26        return new Aphront404Response();
  27      }
  28  
  29      $title = $dashboard->getName();
  30      $crumbs = $this->buildApplicationCrumbs();
  31      $crumbs->addTextCrumb(pht('Dashboard %d', $dashboard->getID()));
  32  
  33      if ($dashboard->getPanelPHIDs()) {
  34        $rendered_dashboard = id(new PhabricatorDashboardRenderingEngine())
  35          ->setViewer($viewer)
  36          ->setDashboard($dashboard)
  37          ->renderDashboard();
  38      } else {
  39        $rendered_dashboard = $this->buildEmptyView();
  40      }
  41  
  42      return $this->buildApplicationPage(
  43        array(
  44          $crumbs,
  45          $rendered_dashboard,
  46        ),
  47        array(
  48          'title' => $title,
  49        ));
  50    }
  51  
  52    public function buildApplicationCrumbs() {
  53      $crumbs = parent::buildApplicationCrumbs();
  54      $id = $this->id;
  55  
  56      $crumbs->addAction(
  57        id(new PHUIListItemView())
  58          ->setIcon('fa-th')
  59          ->setName(pht('Manage Dashboard'))
  60          ->setHref($this->getApplicationURI("manage/{$id}/")));
  61  
  62      return $crumbs;
  63    }
  64  
  65    public function buildEmptyView() {
  66      $id = $this->id;
  67      $manage_uri = $this->getApplicationURI("manage/{$id}/");
  68  
  69      return id(new AphrontErrorView())
  70        ->setSeverity(AphrontErrorView::SEVERITY_NODATA)
  71        ->appendChild(
  72          pht('This dashboard has no panels '.
  73            'yet. Use %s to add panels.',
  74            phutil_tag(
  75              'a',
  76              array('href' => $manage_uri),
  77              pht('Manage Dashboard'))));
  78    }
  79  
  80  }


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