[ Index ]

PHP Cross Reference of Phabricator

title

Body

[close]

/src/applications/auth/view/ -> PhabricatorAuthSSHKeyTableView.php (source)

   1  <?php
   2  
   3  final class PhabricatorAuthSSHKeyTableView extends AphrontView {
   4  
   5    private $keys;
   6    private $canEdit;
   7    private $noDataString;
   8    private $showTrusted;
   9    private $showID;
  10  
  11    public function setNoDataString($no_data_string) {
  12      $this->noDataString = $no_data_string;
  13      return $this;
  14    }
  15  
  16    public function setCanEdit($can_edit) {
  17      $this->canEdit = $can_edit;
  18      return $this;
  19    }
  20  
  21    public function setShowTrusted($show_trusted) {
  22      $this->showTrusted = $show_trusted;
  23      return $this;
  24    }
  25  
  26    public function setShowID($show_id) {
  27      $this->showID = $show_id;
  28      return $this;
  29    }
  30  
  31    public function setKeys(array $keys) {
  32      assert_instances_of($keys, 'PhabricatorAuthSSHKey');
  33      $this->keys = $keys;
  34      return $this;
  35    }
  36  
  37    public function render() {
  38      $keys = $this->keys;
  39      $viewer = $this->getUser();
  40  
  41      if ($this->canEdit) {
  42        $delete_class = 'small grey button';
  43      } else {
  44        $delete_class = 'small grey button disabled';
  45      }
  46  
  47      $trusted_icon = id(new PHUIIconView())
  48        ->setIconFont('fa-star blue');
  49      $untrusted_icon = id(new PHUIIconView())
  50        ->setIconFont('fa-times grey');
  51  
  52      $rows = array();
  53      foreach ($keys as $key) {
  54        $rows[] = array(
  55          $key->getID(),
  56          javelin_tag(
  57            'a',
  58            array(
  59              'href' => '/auth/sshkey/edit/'.$key->getID().'/',
  60              'sigil' => 'workflow',
  61            ),
  62            $key->getName()),
  63          $key->getIsTrusted() ? $trusted_icon : $untrusted_icon,
  64          $key->getKeyComment(),
  65          $key->getKeyType(),
  66          phabricator_datetime($key->getDateCreated(), $viewer),
  67          javelin_tag(
  68            'a',
  69            array(
  70              'href' => '/auth/sshkey/delete/'.$key->getID().'/',
  71              'class' => $delete_class,
  72              'sigil' => 'workflow',
  73            ),
  74            pht('Delete')),
  75        );
  76      }
  77  
  78      $table = id(new AphrontTableView($rows))
  79        ->setNoDataString($this->noDataString)
  80        ->setHeaders(
  81          array(
  82            pht('ID'),
  83            pht('Name'),
  84            pht('Trusted'),
  85            pht('Comment'),
  86            pht('Type'),
  87            pht('Added'),
  88            null,
  89          ))
  90        ->setColumnVisibility(
  91          array(
  92            $this->showID,
  93            true,
  94            $this->showTrusted,
  95          ))
  96        ->setColumnClasses(
  97          array(
  98            '',
  99            'wide pri',
 100            'center',
 101            '',
 102            '',
 103            'right',
 104            'action',
 105          ));
 106  
 107      return $table;
 108    }
 109  
 110  }


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