You are here

function imagefield_extended_token_values in ImageField Extended 6.3

Same name and namespace in other branches
  1. 6.4 imagefield_extended.module \imagefield_extended_token_values()

Implements hook_token_values().

File

./imagefield_extended.module, line 473
Insert additional fields into an ImageField data array.

Code

function imagefield_extended_token_values($type, $object = NULL) {
  if ($type == 'field') {
    $tokens = array();
    $fields = _imagefield_extended_fields();
    foreach ($fields['textfields'] as $id => $field) {
      $tokens['imagefield-extended-' . $id . '-raw'] = '';
      $tokens['imagefield-extended-' . $id . '-plain'] = '';
      $tokens['imagefield-extended-' . $id] = '';
      if (isset($object[0]['data'][$id])) {
        $tokens['imagefield-extended-' . $id . '-raw'] = $object[0]['data'][$id]['body'];
        $tokens['imagefield-extended-' . $id . '-plain'] = strip_tags($object[0]['data'][$id]['body']);
        $tokens['imagefield-extended-' . $id] = imagefield_extended_check_text($object[0]['data'][$id]);
      }
    }
    foreach ($fields['checkboxes'] as $id => $field) {
      $key = 'workflow_' . $id;
      $tokens['imagefield-extended-workflow-' . $id . '-yn'] = '';
      $tokens['imagefield-extended-workflow-' . $id . '-on'] = '';
      $tokens['imagefield-extended-workflow-' . $id] = '';
      if (isset($object[0]['data']['workflow_' . $id])) {
        $tokens['imagefield-extended-workflow-' . $id . '-yn'] = $object[0]['data'][$key] ? t('Yes') : t('No');
        $tokens['imagefield-extended-workflow-' . $id . '-on'] = $object[0]['data'][$key] ? t('On') : t('Off');
        $tokens['imagefield-extended-workflow-' . $id] = $object[0]['data'][$key] ? 1 : 0;
      }
    }
    return $tokens;
  }
}