You are here

function jeditable_handler_field_date::render in jEditable inline content editing 6.2

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

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

Overrides date_handler_field_multiple::render

File

views/jeditable_handler_field_date.inc, line 109
Definition of jeditable_handler_field_date class.

Class

jeditable_handler_field_date
Extends the date_handler_field_multiple 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 = $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 . ' edit-datetime">' . $no_tags_value . '</span>';
    if (!empty($value)) {

      // If tags were stripped, then we need to be sure that we are replacing
      // the text and not some part of a tag.
      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;
}