in web_ui/src/applications/bistro/prefs/BistroPrefs.php [220:299]
public function render() {
require_celerity_resource('bistro-prefs');
$sections = array();
foreach ($this->schemata as $pref_key => $schema) {
// Prepare to render the top line
$is_explicit = isset($this->explicitPrefs[$pref_key]);
$key_tag = phabricator_tag(
'span',
array('class' => ($is_explicit ? 'ex' : 'im').'plicit-pref'),
$pref_key);
$default_value = $this->getDefault($pref_key);
$override_value = idx($this->defaultOverrides, $pref_key);
$value = $this->prefs[$pref_key];
$value_tag = phabricator_tag(
'span',
array(
'class' => ($value !== $default_value ? 'non' : '').'default-value'),
var_export($value, 1));
// Render the top line with the pref's key, value, and type
$pref_value_tags = array(
$key_tag, ' = ', $value_tag,
phabricator_tag(
'span',
array('class' => 'schema-type'),
self::$typeNames[$schema[self::TYPE]]));
if ($override_value !== null && !$is_explicit) {
$pref_value_tags[] = phabricator_tag(
'span',
array('class' => 'hostport-source-override'),
'from hostport source');
}
// Render details with the label, caption, default, units
$details = array();
$label = idx($schema, self::LABEL);
if ($label !== null) {
$details[] = phabricator_tag('p', array('class' => 'schema-label'), $label);
}
$caption = $this->getCaption($pref_key);
if ($caption !== null) {
$details[] =
phabricator_tag('p', array('class' => 'schema-caption'), $caption);
}
$sections[$schema[self::SECTION]][] = phabricator_tag('div', array(), array(
phabricator_tag(
'div', array('style' => 'margin-top: 5px'), $pref_value_tags),
phabricator_tag('div', array('style' => 'margin-left: 5px'), $details)));
}
$section_tags = array();
foreach ($this->sectionNamesInOrder as $sec) {
$section_tags[] = phabricator_tag('div', array(), array(
phabricator_tag('h2', array(), $sec),
phabricator_tag(
'div', array('style' => 'margin-left: 10px'), $sections[$sec])));
}
$listener_id = uniqid('query-prefs-disclosure');
$detail_id = uniqid('query-prefs-details');
Javelin::initBehavior(
'add-detail-toggle-listener',
array(
'detail_html' => $section_tags,
'detail_id' => $detail_id,
'listener_id' => $listener_id));
return id(new AphrontPanelView())
->setHeader(phabricator_tag('a', array('id' => $listener_id), hsprintf(
'<span class="expand">▼</span>'.
'<span class="contract">►</span> Query Prefs')))
->setWidth(AphrontPanelView::WIDTH_FORM)
->addClass('bistro-prefs')
->appendChild(phabricator_tag('div', array('id' => $detail_id), null));
}