foreach ($returnProperties as $key => $value) {
if (($key != 'location' || !is_array($value)) && !$processor->isRelationshipTypeKey($key)) {
$outputColumns[$key] = $value;
- $processor->addOutputSpecification($key, $processor->getHeaderForRow($key));
+ $processor->addOutputSpecification($key);
self::sqlColumnDefn($processor, $sqlColumns, $key);
}
elseif ($processor->isRelationshipTypeKey($key)) {
if (isset($queryFields[$relationField]['title'])) {
if (!$processor->isHouseholdMergeRelationshipTypeKey($field)) {
// Do not add to header row if we are only generating for merge reasons.
- $processor->addOutputSpecification($relationField, $processor->getHeaderForRow($relationField), $key);
+ $processor->addOutputSpecification($relationField, $key);
}
self::sqlColumnDefn($processor, $sqlColumns, $field . '-' . $relationField);
}
$hdr .= "-" . CRM_Core_PseudoConstant::getLabel('CRM_Core_BAO_IM', 'provider_id', $type[1]);
}
}
- $processor->addOutputSpecification($field, $hdr, $key);
+ $processor->addOutputSpecification($field, $key, $ltype, CRM_Utils_Array::value(1, $type));
self::sqlColumnDefn($processor, $sqlColumns, $field . '-' . $hdr);
}
}
$metadata[$daoFieldName]['pseudoconstant']['var'] = 'imProviders';
}
self::sqlColumnDefn($processor, $sqlColumns, $outputFieldName);
- $processor->addOutputSpecification($outputFieldName, $processor->getHeaderForRow($outputFieldName));
+ $processor->addOutputSpecification($outputFieldName, NULL, $locationType, CRM_Utils_Array::value(1, $type));
self::sqlColumnDefn($processor, $sqlColumns, $outputFieldName);
if ($actualDBFieldName == 'country' || $actualDBFieldName == 'world_region') {
$metadata[$daoFieldName] = array('context' => 'country');
/**
* Add a row to the specification for how to output data.
+ *
* @param string $key
- * @param string $label
* @param string $relationshipType
+ * @param string $locationType
+ * @param int $entityTypeID phone_type_id or provider_id for phone or im fields.
*/
- public function addOutputSpecification($key, $label, $relationshipType = NULL) {
- $labelPrefix = '';
+ public function addOutputSpecification($key, $relationshipType = NULL, $locationType = NULL, $entityTypeID = NULL) {
+ $label = $this->getHeaderForRow($key);
+ $labelPrefix = $fieldPrefix = [];
if ($relationshipType) {
- $labelPrefix = $this->getRelationshipTypes()[$relationshipType] . '-';
+ $labelPrefix[] = $this->getRelationshipTypes()[$relationshipType];
+ $fieldPrefix[] = $relationshipType;
+ }
+ if ($locationType) {
+ $labelPrefix[] = $fieldPrefix[] = $locationType;
+ }
+ if ($entityTypeID) {
+ if ($key === 'phone') {
+ $labelPrefix[] = $fieldPrefix[] = CRM_Core_PseudoConstant::getLabel('CRM_Core_BAO_Phone', 'phone_type_id', $entityTypeID);
+ }
+ if ($key === 'im') {
+ $labelPrefix[] = $fieldPrefix[] = CRM_Core_PseudoConstant::getLabel('CRM_Core_BAO_IM', 'provider_id', $entityTypeID);
+ }
}
- $this->outputSpecification[$key]['header'] = $labelPrefix . $label;
+ $index = ($fieldPrefix ? (implode('-', $fieldPrefix) . '-') : '') . $key;
+ $this->outputSpecification[$index]['header'] = ($labelPrefix ? (implode('-', $labelPrefix) . '-') : '') . $label;
+
}
/**