You are here

function jeditable_handler_field_sid::render in jEditable inline content editing 6.2

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

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

File

views/jeditable_handler_field_sid.inc, line 81
Definition of jeditable_handler_field_sid.

Class

jeditable_handler_field_sid
Extends the workflow_views_handler_field_sid class.

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_name = $this->field;
    if ($override_defaults) {
      $inline_editor_class = "jeditable-{$field_name}";
    }
    else {
      $inline_editor_class = "jeditable-select";
      if ($reload_page) {
        $inline_editor_class .= "-reload";
      }
    }
    $no_tags_value = strip_tags($value);
    $id = 'workflow-' . $values->nid . '-' . $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;
}