return self::formatDisplayValue($value, self::$displayInfoCache[$fieldId], $contactId);
}
- /**
- * Legacy display value formatter.
- *
- * @deprecated
- *
- * @param string $value
- * @param array $option
- * @param string $html_type
- * @param string $data_type
- * @param int $contactID
- * @param int $fieldID
- *
- * @return array|mixed|null|string
- */
- public static function getDisplayValueCommon(
- $value,
- $option,
- $html_type,
- $data_type,
- $contactID = NULL,
- $fieldID = NULL
- ) {
-
- if ($fieldID &&
- (($html_type == 'Radio' && $data_type != 'Boolean') ||
- ($html_type == 'Autocomplete-Select' && $data_type != 'ContactReference') ||
- $html_type == 'Select' ||
- $html_type == 'CheckBox' ||
- $html_type == 'AdvMulti-Select' ||
- $html_type == 'Multi-Select'
- )
- ) {
- CRM_Utils_Hook::customFieldOptions($fieldID, $option);
- }
-
- if ($data_type == 'Boolean') {
- $option = CRM_Core_SelectValues::boolean();
- }
-
- if ($data_type == 'Country') {
- $option = CRM_Core_PseudoConstant::country(FALSE, FALSE);
- }
-
- if ($data_type == 'StateProvince') {
- $option = CRM_Core_PseudoConstant::stateProvince(FALSE, FALSE);
- }
-
- $field = array(
- 'id' => $fieldID,
- 'html_type' => $html_type,
- 'data_type' => $data_type,
- 'options' => $option,
- );
-
- return self::formatDisplayValue($value, $field, $contactID);
- }
-
-
/**
* Lower-level logic for rendering a custom field value
*
return $options;
}
- /**
- * Returns the option label for a custom field with a specific value. Handles all
- * custom field data and html types
- *
- * @param int $fieldId
- * the custom field ID.
- * @pram $value string the value (typically from the DB) of this custom field
- * @param $value
- * @param string $htmlType
- * the html type of the field (optional).
- * @param string $dataType
- * the data type of the field (optional).
- *
- * @return string
- * the label to display for this custom field
- */
- public static function getOptionLabel($fieldId, $value, $htmlType = NULL, $dataType = NULL) {
- if (!$fieldId) {
- return NULL;
- }
-
- if (!$htmlType || !$dataType) {
- $sql = "
-SELECT html_type, data_type
-FROM civicrm_custom_field
-WHERE id = %1
-";
- $params = array(1 => array($fieldId, 'Integer'));
- $dao = CRM_Core_DAO::executeQuery($sql, $params);
- if ($dao->fetch()) {
- $htmlType = $dao->html_type;
- $dataType = $dao->data_type;
- }
- else {
- CRM_Core_Error::fatal();
- }
- }
-
- $options = NULL;
- switch ($htmlType) {
- case 'CheckBox':
- case 'Multi-Select':
- case 'AdvMulti-Select':
- case 'Select':
- case 'Radio':
- case 'Autocomplete-Select':
- if (!in_array($dataType, array(
- 'Boolean',
- 'ContactReference',
- ))
- ) {
- $options = self::valuesByID($fieldId);
- }
- }
-
- return CRM_Core_BAO_CustomField::getDisplayValueCommon($value,
- $options,
- $htmlType,
- $dataType
- );
- }
-
/**
* Delete Option.
*
/**
* Replace all the org-level tokens in $str
*
+ * @fixme: This function appears to be broken, as it depends on
+ * nonexistant method: CRM_Core_BAO_CustomValue::getContactValues()
+ * Marking as deprecated until this is fixed
+ * @deprecated
+ *
* @param string $str
* The string with tokens to be replaced.
* @param object $org
}
foreach ($cv as $cvFieldID => $value) {
if ($cvFieldID == $cfID) {
- $value = CRM_Core_BAO_CustomOption::getOptionLabel($cfID, $value);
+ $value = CRM_Core_BAO_CustomField::displayValue($value, $cfID);
break;
}
}