1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-15 11:22:40 +01:00
phorge-phorge/src/applications/almanac/controller/AlmanacController.php

63 lines
1.5 KiB
PHP
Raw Normal View History

<?php
abstract class AlmanacController
2014-11-06 00:27:16 +01:00
extends PhabricatorController {
protected function buildAlmanacPropertiesTable(
AlmanacPropertyInterface $object) {
2014-11-06 00:27:16 +01:00
$viewer = $this->getViewer();
$properties = $object->getAlmanacProperties();
2014-11-06 00:27:16 +01:00
$rows = array();
foreach ($properties as $property) {
$value = $property->getFieldValue();
$rows[] = array(
$property->getFieldName(),
PhabricatorConfigJSON::prettyPrintJSON($value),
);
}
$table = id(new AphrontTableView($rows))
->setNoDataString(pht('No properties.'))
->setHeaders(
array(
pht('Name'),
pht('Value'),
))
->setColumnClasses(
array(
null,
'wide',
));
$phid = $object->getPHID();
$add_uri = $this->getApplicationURI("property/edit/?objectPHID={$phid}");
$can_edit = PhabricatorPolicyFilter::hasCapability(
$viewer,
$object,
PhabricatorPolicyCapability::CAN_EDIT);
$add_button = id(new PHUIButtonView())
->setTag('a')
->setHref($add_uri)
->setWorkflow(true)
->setDisabled(!$can_edit)
->setText(pht('Add Property'))
->setIcon(
id(new PHUIIconView())
->setIconFont('fa-plus'));
$header = id(new PHUIHeaderView())
->setHeader(pht('Properties'))
->addActionLink($add_button);
return id(new PHUIObjectBoxView())
->setHeader($header)
->appendChild($table);
}
}