[ Index ]

PHP Cross Reference of Phabricator

title

Body

[close]

/src/applications/countdown/controller/ -> PhabricatorCountdownViewController.php (source)

   1  <?php
   2  
   3  final class PhabricatorCountdownViewController
   4    extends PhabricatorCountdownController {
   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  
  18      $request = $this->getRequest();
  19      $user = $request->getUser();
  20  
  21      $countdown = id(new PhabricatorCountdownQuery())
  22        ->setViewer($user)
  23        ->withIDs(array($this->id))
  24        ->executeOne();
  25      if (!$countdown) {
  26        return new Aphront404Response();
  27      }
  28  
  29      $countdown_view = id(new PhabricatorCountdownView())
  30        ->setUser($user)
  31        ->setCountdown($countdown)
  32        ->setHeadless(true);
  33  
  34      $id = $countdown->getID();
  35      $title = $countdown->getTitle();
  36  
  37      $crumbs = $this
  38        ->buildApplicationCrumbs()
  39        ->addTextCrumb("C{$id}");
  40  
  41      $header = id(new PHUIHeaderView())
  42        ->setHeader($title)
  43        ->setUser($user)
  44        ->setPolicyObject($countdown);
  45  
  46      $actions = $this->buildActionListView($countdown);
  47      $properties = $this->buildPropertyListView($countdown, $actions);
  48  
  49      $object_box = id(new PHUIObjectBoxView())
  50        ->setHeader($header)
  51        ->addPropertyList($properties);
  52  
  53      $content = array(
  54        $crumbs,
  55        $object_box,
  56        $countdown_view,
  57      );
  58  
  59      return $this->buildApplicationPage(
  60        $content,
  61        array(
  62          'title' => $title,
  63        ));
  64    }
  65  
  66    private function buildActionListView(PhabricatorCountdown $countdown) {
  67      $request = $this->getRequest();
  68      $viewer = $request->getUser();
  69  
  70      $id = $countdown->getID();
  71  
  72      $view = id(new PhabricatorActionListView())
  73        ->setUser($viewer);
  74  
  75      $can_edit = PhabricatorPolicyFilter::hasCapability(
  76        $viewer,
  77        $countdown,
  78        PhabricatorPolicyCapability::CAN_EDIT);
  79  
  80      $view->addAction(
  81        id(new PhabricatorActionView())
  82          ->setIcon('fa-pencil')
  83          ->setName(pht('Edit Countdown'))
  84          ->setHref($this->getApplicationURI("edit/{$id}/"))
  85          ->setDisabled(!$can_edit)
  86          ->setWorkflow(!$can_edit));
  87  
  88      $view->addAction(
  89        id(new PhabricatorActionView())
  90          ->setIcon('fa-times')
  91          ->setName(pht('Delete Countdown'))
  92          ->setHref($this->getApplicationURI("delete/{$id}/"))
  93          ->setDisabled(!$can_edit)
  94          ->setWorkflow(true));
  95  
  96      return $view;
  97    }
  98  
  99    private function buildPropertyListView(
 100      PhabricatorCountdown $countdown,
 101      PhabricatorActionListView $actions) {
 102  
 103      $request = $this->getRequest();
 104      $viewer = $request->getUser();
 105  
 106      $this->loadHandles(array($countdown->getAuthorPHID()));
 107  
 108      $view = id(new PHUIPropertyListView())
 109        ->setUser($viewer)
 110        ->setActionList($actions);
 111  
 112      $view->addProperty(
 113        pht('Author'),
 114        $this->getHandle($countdown->getAuthorPHID())->renderLink());
 115  
 116      return $view;
 117    }
 118  
 119  }


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