You are here

function editablefields_cck_render in Editable Fields 6.3

1 call to editablefields_cck_render()
theme_editablefields_formatter in plugins/editables/cck.inc
Default theme implementation for editablefields_modal. RESPONDER

File

plugins/editables/cck.inc, line 161

Code

function editablefields_cck_render($field, $items, $node, $responder) {
  require_once drupal_get_path('module', 'content') . '/includes/views/content.views.inc';
  $formatter_name = $field['display_settings'][$responder]['format'];

  // Other module's formatters might be doing something just as exotic
  // as we are but we can only allow tags that won't mess with our button.
  // We use filter_xss just for its html stripping magic.
  // Some formatters need to behave differently depending on the build_mode
  // (for instance: preview), so we provide one.
  $node->build_mode = NODE_BUILD_NORMAL;
  foreach ($items as $delta => $item) {
    $items[$delta]['#delta'] = $delta;
  }

  // Render items.
  $allowed_tags = array(
    'img',
    'div',
    'span',
    'em',
    'strong',
    'cite',
    'ul',
    'ol',
    'li',
    'dl',
    'dt',
    'dd',
  );
  if ($items && ($formatter = _content_get_formatter($formatter_name, $field['type']))) {
    $rendered = array();
    if (content_handle('formatter', 'multiple values', $formatter) == CONTENT_HANDLE_CORE) {

      // Single-value formatter.
      foreach ($items as $item) {
        $rendered[] = filter_xss(content_format($field, $item, $formatter_name, $node), $allowed_tags);
      }
    }
    else {

      // Multiple values formatter.
      $rendered[] = filter_xss(content_format($field, $items, $formatter_name, $node), $allowed_tags);
    }
    if (count($rendered) > 1) {

      // TODO: could we use generic field display ?
      $output = theme('content_view_multiple_field', $rendered, $field, $items);
    }
    elseif ($rendered) {
      $output = $rendered[0];
    }
  }
  if ($output) {
    return $output;
  }
  else {

    // TODO: "Not set" is not necessarily true.  For instance, CCK returns
    // an empty string for files that are not "listed".
    return t('Not set');
  }
}