You are here

function jeditable_handler_field_content::render in jEditable inline content editing 6

Same name and namespace in other branches
  1. 6.2 views/jeditable_handler_field_content.inc \jeditable_handler_field_content::render()

Render the field. The inline editor tags are placed innermost.

File

views/jeditable_handler_field_content.inc, line 125

Class

jeditable_handler_field_content
Override for content_handler_field_multiple

Code

function render($values) {
  $value = parent::render($values);
  $is_enabled = $this->options['jeditable']['enabled'];
  $reload_page = $this->options['jeditable']['reload_page'];
  $hide_if_empty = $this->options['jeditable']['hide_if_empty'];
  $disable_if_not_empty = $this->options['jeditable']['disable_if_not_empty'];
  $override_defaults = $this->options['jeditable']['override_defaults'];
  if (empty($value) && $hide_if_empty) {
    return $value;
  }
  if (!empty($value) && $disable_if_not_empty) {
    return $value;
  }
  if ($is_enabled) {
    $field = $this->content_field;
    $field_name = $field['field_name'];
    if ($override_defaults) {
      $inline_editor_class = "jeditable-{$field_name}";
    }
    else {
      $inline_editor_class = $this->inline_editor_class;
      if ($reload_page) {
        $inline_editor_class .= "-reload";
      }
    }
    $nid_field_alias = $this->aliases['nid'];
    $no_tags_value = strip_tags($value);
    $id = 'cck-' . $values->{$nid_field_alias} . '-' . $field_name;
    $inline_editor = '<span id="' . $id . '" class="' . $inline_editor_class . '">' . $no_tags_value . '</span>';
    if (!empty($value)) {
      if (strcmp($value, $no_tags_value) == 0) {
        $value = str_replace($no_tags_value, $inline_editor, $value);
      }
      else {
        $value = str_replace('>' . $no_tags_value . '<', '>' . $inline_editor . '<', $value);
      }
    }
    else {
      $value = $inline_editor;
    }
  }
  return $value;
}