object = $object; return $this; } public function getObject() { return $this->object; } public function setFields(array $fields) { $this->fields = $fields; return $this; } public function getFields() { return $this->fields; } public function render() { $object = $this->getObject(); $fields = $this->getFields(); $uri = 'https://phorge.example.com/application/edit/'; // Remove fields which do not expose an HTTP parameter type. $types = array(); foreach ($fields as $key => $field) { if (!$field->shouldGenerateTransactionsFromSubmit()) { unset($fields[$key]); continue; } $type = $field->getHTTPParameterType(); if ($type === null) { unset($fields[$key]); continue; } $types[$type->getTypeName()] = $type; } $intro = pht(<<getLabel(), head($field->getAllReadValueFromRequestKeys()), $field->getHTTPParameterType()->getTypeName(), $field->getDescription(), ); } $main_table = id(new AphrontTableView($rows)) ->setHeaders( array( pht('Label'), pht('Key'), pht('Type'), pht('Description'), )) ->setColumnClasses( array( 'pri', null, null, 'wide', )); $aliases_text = pht(<<getAllReadValueFromRequestKeys(), 1); if (!$aliases) { continue; } $rows[] = array( $field->getLabel(), $field->getKey(), implode(', ', $aliases), ); } $alias_table = id(new AphrontTableView($rows)) ->setNoDataString(pht('This object has no fields with aliases.')) ->setHeaders( array( pht('Label'), pht('Key'), pht('Aliases'), )) ->setColumnClasses( array( 'pri', null, 'wide', )); $template_text = pht(<<setIcon('fa-check-circle green'); $no = id(new PHUIIconView())->setIcon('fa-times grey'); $rows = array(); foreach ($fields as $field) { $rows[] = array( $field->getLabel(), $field->getIsCopyable() ? $yes : $no, ); } $template_table = id(new AphrontTableView($rows)) ->setNoDataString( pht('None of the fields on this object support templating.')) ->setHeaders( array( pht('Field'), pht('Will Copy'), )) ->setColumnClasses( array( 'pri', 'wide', )); $select_text = pht(<<getOptions(); $label = $field->getLabel(); foreach ($options as $option_key => $option_value) { if (strlen($option_key)) { $option_display = $option_key; } else { $option_display = phutil_tag('em', array(), pht('')); } $rows[] = array( $label, $option_display, $option_value, ); $label = null; } } $select_table = id(new AphrontTableView($rows)) ->setNoDataString(pht('This object has no select fields.')) ->setHeaders( array( pht('Field'), pht('Value'), pht('Label'), )) ->setColumnClasses( array( 'pri', null, 'wide', )); $types_text = pht(<<setHTTPParameterTypes($types); return array( $this->renderInstructions($intro), $main_table, $this->renderInstructions($aliases_text), $alias_table, $this->renderInstructions($template_text), $template_table, $this->renderInstructions($select_text), $select_table, $this->renderInstructions($types_text), $types_table, ); } protected function renderInstructions($corpus) { $viewer = $this->getUser(); $view = new PHUIRemarkupView($viewer, $corpus); $view->setRemarkupOptions( array( PHUIRemarkupView::OPTION_PRESERVE_LINEBREAKS => false, )); return $view; } }