You are here

ContentLockViewsHandlerFieldLocked.inc in Content locking (anti-concurrent editing) 7.3

Same filename and directory in other branches
  1. 7.2 views/ContentLockViewsHandlerFieldLocked.inc

Handler to identify if node is locked or not.

File

views/ContentLockViewsHandlerFieldLocked.inc
View source
<?php

/**
 * @file
 * Handler to identify if node is locked or not.
 */

/**
 * Class ContentLockViewsHandlerFieldLocked.
 */
class ContentLockViewsHandlerFieldLocked extends views_handler_field_boolean {

  /**
   * Init.
   */
  public function construct() {
    parent::construct();
    $this->additional_fields['timestamp'] = 'timestamp';
  }

  /**
   * Query.
   */
  public function query() {
    $this
      ->ensure_my_table();
    $this
      ->add_additional_fields();
  }

  /**
   * Render.
   */
  public function render($values) {
    $value = $values->content_lock_timestamp ? TRUE : FALSE;
    if (!empty($this->options['not'])) {
      $value = !$value;
    }
    switch ($this->options['type']) {
      case 'true-false':
        return $value ? t('True') : t('False');
      case 'on-off':
        return $value ? t('On') : t('Off');
      case 'custom':
        return $value ? $this->options['type_custom_true'] : $this->options['type_custom_false'];
      case 'yes-no':
      default:
        return $value ? t('Yes') : t('No');
    }
  }

}

Classes

Namesort descending Description
ContentLockViewsHandlerFieldLocked Class ContentLockViewsHandlerFieldLocked.