You are here

class revisioning_handler_field_revision_state in Revisioning 6.3

Same name and namespace in other branches
  1. 8 views/revisioning_handler_field_revision_state.inc \revisioning_handler_field_revision_state
  2. 6.4 views/revisioning_handler_field_revision_state.inc \revisioning_handler_field_revision_state
  3. 7 views/revisioning_handler_field_revision_state.inc \revisioning_handler_field_revision_state

@file Handler for the 'Node revision: state' field.

Hierarchy

Expanded class hierarchy of revisioning_handler_field_revision_state

1 string reference to 'revisioning_handler_field_revision_state'
revisioning_views_data_alter in views/revisioning.views.inc
Implementation of hook_views_data_alter().

File

views/revisioning_handler_field_revision_state.inc, line 7
Handler for the 'Node revision: state' field.

View source
class revisioning_handler_field_revision_state extends views_handler_field {
  function construct() {
    parent::construct();

    // Collect additional data required prior to rendering
    $this->additional_fields['nid'] = 'nid';
    $this->additional_fields['vid'] = 'vid';
    $this->additional_fields['published'] = array(
      'table' => 'node',
      'field' => 'status',
    );
    $this->additional_fields['current_vid'] = array(
      'table' => 'node',
      'field' => 'vid',
    );
  }
  function access() {
    return user_access('view revisions');
  }
  function query() {

    // Not calling parent::query() as it will treat 'state' as a real db field.
    $this
      ->ensure_my_table();
    $this
      ->add_additional_fields();
  }

  /**
   * Note that $values contains:
   *   o node_revisions_nid (parent node id)
   *   o node_revisions_vid (revision id)
   *   o node_status (published flag)
   *   o node_vid (current revision id)
   */
  function render($values) {
    $nid = $values->{$this->aliases['nid']};
    $vid = $values->{$this->aliases['vid']};
    $published = $values->{$this->aliases['published']};
    $current_vid = $values->{$this->aliases['current_vid']};
    $is_initial_unpublished_draft = !$published && node_tools_get_number_of_revisions($nid) == 1;
    $is_pending = $vid > $current_vid || $is_initial_unpublished_draft;
    $state_code = $is_pending ? REVISION_PENDING : ($vid == $current_vid ? REVISION_CURRENT : REVISION_ARCHIVED);
    $description = revisioning_revision_states($state_code);
    return $description;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
revisioning_handler_field_revision_state::access function
revisioning_handler_field_revision_state::construct function
revisioning_handler_field_revision_state::query function
revisioning_handler_field_revision_state::render function Note that $values contains: o node_revisions_nid (parent node id) o node_revisions_vid (revision id) o node_status (published flag) o node_vid (current revision id)