You are here

function _rules_admin_get_label in Rules 6

Gets the label for the info of the given element by apply label callbacks. Note that this is also used for argument infos.

Parameters

$cfirst: If TRUE, capitalize the first letter, if FALSE lower case the first letter.

$element: The element having or containing this label. Pass by referenec to allow callbacks to alter some info, used by rules_core_node_label_callback().

Return value

An array of changed properties of the given info

2 calls to _rules_admin_get_label()
rules_admin_new_variables_form_submit in rules_admin/rules_admin.rule_forms.inc
rules_admin_save_element_label in rules_admin/rules_admin.rule_forms.inc
Saves the element label.

File

rules_admin/rules_admin.inc, line 233

Code

function _rules_admin_get_label(&$form_state, $info, &$element, $value, $cfirst = NULL) {
  $info_changes = array();
  if (drupal_strtolower($info['label']) != drupal_strtolower($value)) {

    //label has been customized
    $info_changes['label'] = $value;
    $info_changes['label callback'] = FALSE;
  }
  else {
    if (isset($info['label callback']) && $info['label callback'] && function_exists($info['label callback'])) {
      $argument_labels = rules_admin_get_argument_labels($form_state['proxy'], $element);
      $info_changes['label'] = $info['label callback']($element['#settings'], $argument_labels, $element);

      // Labels are treated as user input, so we decode any entites.
      $info_changes['label'] = decode_entities($info_changes['label']);
      if (isset($cfirst)) {
        $function = $cfirst ? 'drupal_strtoupper' : 'drupal_strtolower';
        $info_changes['label'] = $function(drupal_substr($info_changes['label'], 0, 1)) . drupal_substr($info_changes['label'], 1);
      }
    }
  }
  return $info_changes;
}