You are here

function HistoryUserTimestamp::render in Views (for Drupal 7) 8.3

Render the field.

Parameters

$values: The values retrieved from the database.

Overrides Node::render

File

lib/Views/node/Plugin/views/field/HistoryUserTimestamp.php, line 70
Definition of Views\node\Plugin\views\field\HistoryUserTimestamp.

Class

HistoryUserTimestamp
Field handler to display the marker for new content.

Namespace

Views\node\Plugin\views\field

Code

function render($values) {

  // Let's default to 'read' state.
  // This code shadows node_mark, but it reads from the db directly and
  // we already have that info.
  $mark = MARK_READ;
  global $user;
  if ($user->uid) {
    $last_read = $this
      ->get_value($values);
    $changed = $this
      ->get_value($values, 'changed');
    $last_comment = module_exists('comment') && !empty($this->options['comments']) ? $this
      ->get_value($values, 'last_comment') : 0;
    if (!$last_read && $changed > NODE_NEW_LIMIT) {
      $mark = MARK_NEW;
    }
    elseif ($changed > $last_read && $changed > NODE_NEW_LIMIT) {
      $mark = MARK_UPDATED;
    }
    elseif ($last_comment > $last_read && $last_comment > NODE_NEW_LIMIT) {
      $mark = MARK_UPDATED;
    }
    return $this
      ->render_link(theme('mark', array(
      'type' => $mark,
    )), $values);
  }
}