2012-08-15 19:45:06 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
final class PhabricatorPropertyListView extends AphrontView {
|
|
|
|
|
2012-10-15 23:50:53 +02:00
|
|
|
private $properties = array();
|
2012-08-15 19:45:06 +02:00
|
|
|
|
|
|
|
public function addProperty($key, $value) {
|
|
|
|
$this->properties[$key] = $value;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2012-10-15 23:50:53 +02:00
|
|
|
public function addTextContent($content) {
|
|
|
|
return $this->appendChild(
|
|
|
|
phutil_render_tag(
|
|
|
|
'div',
|
|
|
|
array(
|
|
|
|
'class' => 'phabricator-property-list-text-content',
|
|
|
|
),
|
|
|
|
$content));
|
|
|
|
}
|
|
|
|
|
2012-08-15 19:45:06 +02:00
|
|
|
public function render() {
|
|
|
|
require_celerity_resource('phabricator-property-list-view-css');
|
|
|
|
|
|
|
|
$items = array();
|
|
|
|
foreach ($this->properties as $key => $value) {
|
|
|
|
$items[] = phutil_render_tag(
|
|
|
|
'dt',
|
|
|
|
array(
|
|
|
|
'class' => 'phabricator-property-key',
|
|
|
|
),
|
|
|
|
phutil_escape_html($key));
|
|
|
|
$items[] = phutil_render_tag(
|
|
|
|
'dd',
|
|
|
|
array(
|
|
|
|
'class' => 'phabricator-property-value',
|
|
|
|
),
|
|
|
|
$this->renderSingleView($value));
|
|
|
|
}
|
|
|
|
|
|
|
|
$list = phutil_render_tag(
|
|
|
|
'dl',
|
|
|
|
array(
|
|
|
|
),
|
|
|
|
$this->renderSingleView($items));
|
|
|
|
|
2012-10-15 23:50:53 +02:00
|
|
|
$content = $this->renderChildren();
|
|
|
|
if (strlen($content)) {
|
|
|
|
$content = phutil_render_tag(
|
|
|
|
'div',
|
|
|
|
array(
|
|
|
|
'class' => 'phabricator-property-list-content',
|
|
|
|
),
|
|
|
|
$content);
|
|
|
|
}
|
|
|
|
|
2012-08-15 19:45:06 +02:00
|
|
|
return phutil_render_tag(
|
|
|
|
'div',
|
|
|
|
array(
|
|
|
|
'class' => 'phabricator-property-list-view',
|
|
|
|
),
|
2012-08-24 22:19:47 +02:00
|
|
|
$list.
|
|
|
|
// NOTE: We need this (which is basically a "clear: both;" div) to make
|
|
|
|
// sure the property list is taller than the action list for objects with
|
|
|
|
// few properties but many actions. Otherwise, the action list may
|
|
|
|
// obscure the document content.
|
2012-10-15 23:50:53 +02:00
|
|
|
'<div class="phabriator-property-list-view-end"></div>').
|
|
|
|
$content;
|
2012-08-15 19:45:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|