// get preferred languages
if (!empty($contact->preferred_language)) {
- $values['preferred_language'] = CRM_Core_PseudoConstant::getValue('CRM_Contact_DAO_Contact', 'preferred_language', $contact->preferred_language);
+ $values['preferred_language'] = CRM_Core_PseudoConstant::getLabel('CRM_Contact_DAO_Contact', 'preferred_language', $contact->preferred_language);
}
// Calculating Year difference
}
elseif ($name === 'preferred_language') {
$params[$index] = $details->$name;
- $values[$index] = CRM_Core_PseudoConstant::getValue('CRM_Contact_DAO_Contact', 'preferred_language', $details->$name);
+ $values[$index] = CRM_Core_PseudoConstant::getLabel('CRM_Contact_DAO_Contact', 'preferred_language', $details->$name);
}
elseif ($name == 'group') {
$groups = CRM_Contact_BAO_GroupContact::getContactGroup($cid, 'Added', NULL, FALSE, TRUE);
foreach ($fields as $field) {
$name = CRM_Utils_Array::value('name', $field);
if ($name && isset($this->$name)) {
- $label = CRM_Core_PseudoConstant::getValue(get_class($this), $name, $this->$name);
+ $label = CRM_Core_PseudoConstant::getLabel(get_class($this), $name, $this->$name);
if ($label !== FALSE) {
// Append 'label' onto the field name
$labelName = $name . '_label';
}
/**
- * Fetch the label (or other value) for a field given its key
+ * Fetch the translated label for a field given its key
*
- * @param String $daoName
+ * @param String $baoName
* @param String $fieldName
* @param String|Int $key
- * @param Array $params will be passed into self::get
+ *
+ * TODO: Accept multivalued input?
*
* @return bool|null|string
* FALSE if the given field has no associated option list
* NULL if the given key has no corresponding option
* String if label is found
*/
- static function getValue($daoName, $fieldName, $key, $params = array()) {
- $values = self::get($daoName, $fieldName, $params, 'get');
+ static function getLabel($baoName, $fieldName, $key) {
+ $values = $baoName::buildOptions($fieldName, 'get');
+ if ($values === FALSE) {
+ return FALSE;
+ }
+ return CRM_Utils_Array::value($key, $values);
+ }
+
+ /**
+ * Fetch the machine name for a field given its key
+ *
+ * @param String $baoName
+ * @param String $fieldName
+ * @param String|Int $key
+ *
+ * @return bool|null|string
+ * FALSE if the given field has no associated option list
+ * NULL if the given key has no corresponding option
+ * String if label is found
+ */
+ static function getName($baoName, $fieldName, $key) {
+ $values = $baoName::buildOptions($fieldName, 'validate');
if ($values === FALSE) {
return FALSE;
}
/**
* Fetch the key for a field option given its name
*
- * @param String $daoName
+ * @param String $baoName
* @param String $fieldName
* @param String|Int $value
- * @param Array $params will be passed into self::get
*
* @return bool|null|string|number
* FALSE if the given field has no associated option list
* NULL if the given key has no corresponding option
* String|Number if key is found
*/
- static function getKey($daoName, $fieldName, $value, $params = array()) {
- $values = self::get($daoName, $fieldName, $params, 'validate');
+ static function getKey($baoName, $fieldName, $value) {
+ $values = $baoName::buildOptions($fieldName, 'validate');
if ($values === FALSE) {
return FALSE;
}
) {
$url = CRM_Utils_System::fixURL($result->$name);
$typeId = substr($name, 0, -4) . "-website_type_id";
- $typeName = CRM_Core_PseudoConstant::getValue('CRM_Core_DAO_Website', 'website_type_id', $result->$typeId);
+ $typeName = CRM_Core_PseudoConstant::getLabel('CRM_Core_DAO_Website', 'website_type_id', $result->$typeId);
if ($typeName) {
$row[] = "<a href=\"$url\">{$result->$name} (${typeName})</a>";
}
}
}
elseif ($name == 'preferred_language') {
- $row[] = CRM_Core_PseudoConstant::getValue('CRM_Contact_DAO_Contact', 'preferred_language', $result->$name);
+ $row[] = CRM_Core_PseudoConstant::getLabel('CRM_Contact_DAO_Contact', 'preferred_language', $result->$name);
}
elseif ($multipleSelectFields &&
array_key_exists($name, $multipleSelectFields)
elseif (strpos($name, '-im')) {
if (!empty($result->$name)) {
$providerId = $name . "-provider_id";
- $providerName = CRM_Core_PseudoConstant::getValue('CRM_Core_DAO_IM', 'provider_id', $result->$providerId);
+ $providerName = CRM_Core_PseudoConstant::getLabel('CRM_Core_DAO_IM', 'provider_id', $result->$providerId);
$row[] = $result->$name . " ({$providerName})";
}
else {
if (array_key_exists('civicrm_grant_grant_type_id', $row)) {
if ($value = $row['civicrm_grant_grant_type_id']) {
- $rows[$rowNum]['civicrm_grant_grant_type_id'] = CRM_Core_PseudoConstant::getValue('CRM_Grant_DAO_Grant', 'grant_type_id', $value);
+ $rows[$rowNum]['civicrm_grant_grant_type_id'] = CRM_Core_PseudoConstant::getLabel('CRM_Grant_DAO_Grant', 'grant_type_id', $value);
}
$entryFound = TRUE;
}
if (array_key_exists('civicrm_grant_status_id', $row)) {
if ($value = $row['civicrm_grant_status_id']) {
- $rows[$rowNum]['civicrm_grant_status_id'] = CRM_Core_PseudoConstant::getValue('CRM_Grant_DAO_Grant', 'status_id', $value);
+ $rows[$rowNum]['civicrm_grant_status_id'] = CRM_Core_PseudoConstant::getLabel('CRM_Grant_DAO_Grant', 'status_id', $value);
}
$entryFound = TRUE;
}
break;
case 'approvalStatus':
- $value = CRM_Core_PseudoConstant::getValue('CRM_Mailing_DAO_Mailing', 'approval_status_id', $mailing->approval_status_id);
+ $value = CRM_Core_PseudoConstant::getLabel('CRM_Mailing_DAO_Mailing', 'approval_status_id', $mailing->approval_status_id);
break;
case 'approvalNote':
foreach ($rows as $rowNum => $row) {
if (array_key_exists('civicrm_grant_grant_type_id', $row)) {
if ($value = $row['civicrm_grant_grant_type_id']) {
- $rows[$rowNum]['civicrm_grant_grant_type_id'] = CRM_Core_PseudoConstant::getValue('CRM_Grant_DAO_Grant', 'grant_type_id', $value);
+ $rows[$rowNum]['civicrm_grant_grant_type_id'] = CRM_Core_PseudoConstant::getLabel('CRM_Grant_DAO_Grant', 'grant_type_id', $value);
}
$entryFound = TRUE;
}
if (array_key_exists('civicrm_grant_status_id', $row)) {
if ($value = $row['civicrm_grant_status_id']) {
- $rows[$rowNum]['civicrm_grant_status_id'] = CRM_Core_PseudoConstant::getValue('CRM_Grant_DAO_Grant', 'status_id', $value);
+ $rows[$rowNum]['civicrm_grant_status_id'] = CRM_Core_PseudoConstant::getLabel('CRM_Grant_DAO_Grant', 'status_id', $value);
}
$entryFound = TRUE;
}