You are here

function inline_conditions_field_load in Inline Conditions 7

Implements hook_field_load().

Prepare items array in order to be usable with inline_condition field widget.

File

./inline_conditions.field.inc, line 49
Field module functionality for the Inline Conditions module.

Code

function inline_conditions_field_load($entity_type, $entities, $field, $instances, $langcode, &$items, $age) {

  // Loop on every entities given.
  foreach ($entities as $id => $entity) {

    // Ensures that field is inline_conditions type.
    if ($field['type'] == 'inline_conditions') {
      foreach ($items[$id] as $delta => $item) {

        // Ensure condition_settings is unserialised.
        if (is_string($item['condition_settings'])) {

          // Unserialize the field settings.
          $item['condition_settings'] = unserialize($item['condition_settings']);

          // Look up for the value of the logic operators.
          if (isset($item['condition_settings']['condition_negate'])) {
            $item['condition_negate'] = $item['condition_settings']['condition_negate'];
            unset($item['condition_settings']['condition_negate']);
          }
          if (isset($item['condition_settings']['condition_logic_operator'])) {
            $item['condition_logic_operator'] = $item['condition_settings']['condition_logic_operator'];
            unset($item['condition_settings']['condition_logic_operator']);
          }

          // Replace item value.
          $items[$id][$delta] = $item;
        }
      }
    }
  }
}