Path: blob/master/src/applications/almanac/view/AlmanacInterfaceTableView.php
12256 views
<?php12final class AlmanacInterfaceTableView extends AphrontView {34private $interfaces;5private $canEdit;67public function setInterfaces(array $interfaces) {8$this->interfaces = $interfaces;9return $this;10}1112public function getInterfaces() {13return $this->interfaces;14}1516public function setCanEdit($can_edit) {17$this->canEdit = $can_edit;18return $this;19}2021public function getCanEdit() {22return $this->canEdit;23}2425public function render() {26$interfaces = $this->getInterfaces();27$viewer = $this->getUser();2829$can_edit = $this->getCanEdit();3031if ($can_edit) {32$button_class = 'small button button-grey';33} else {34$button_class = 'small button button-grey disabled';35}3637$handles = $viewer->loadHandles(mpull($interfaces, 'getNetworkPHID'));3839$rows = array();40foreach ($interfaces as $interface) {41$rows[] = array(42$interface->getID(),43$handles->renderHandle($interface->getNetworkPHID()),44$interface->getAddress(),45$interface->getPort(),46javelin_tag(47'a',48array(49'class' => $button_class,50'href' => '/almanac/interface/edit/'.$interface->getID().'/',51'sigil' => ($can_edit ? null : 'workflow'),52),53pht('Edit')),54javelin_tag(55'a',56array(57'class' => $button_class,58'href' => '/almanac/interface/delete/'.$interface->getID().'/',59'sigil' => 'workflow',60),61pht('Delete')),62);63}6465$table = id(new AphrontTableView($rows))66->setHeaders(67array(68pht('ID'),69pht('Network'),70pht('Address'),71pht('Port'),72null,73null,74))75->setColumnClasses(76array(77'',78'wide',79'',80'',81'action',82'action',83));8485return $table;86}8788}899091