You are here

class views_plugin_row_heartbeat_view in Heartbeat 6.3

Same name and namespace in other branches
  1. 7 views/views_plugin_row_heartbeat_view.inc \views_plugin_row_heartbeat_view

Plugin which performs a heartbeat_view on the resulting object.

Most of the code on this object is in the theme function.

Hierarchy

Expanded class hierarchy of views_plugin_row_heartbeat_view

1 string reference to 'views_plugin_row_heartbeat_view'
heartbeat_views_plugins in views/heartbeat_views.views.inc
Implementation of hook_views_plugins

File

views/plugins/views_plugin_row_heartbeat_view.inc, line 12
Contains the heartbeat row style plugin.

View source
class views_plugin_row_heartbeat_view extends views_plugin_row {
  function init(&$view, &$display, $options = NULL) {

    // call init of base class
    parent::init($view, $display, $options);
    if ($view->query === null || !method_exists($view->query, 'add_field')) {

      //drupal_set_message('Something went wrong while fetching heartbeat messages.', 'error');
      return;
    }
    $table1 = 'heartbeat_activity';
    $table2 = 'heartbeat_messages';
    $join_by = 'message_id';

    // Clear the fields first

    //$view->query->clear_fields();

    // Build the fields for heartbeat_activity
    $fields = _heartbeat_get_fields($table1);
    foreach ($fields as $field => $alias) {
      $view->query
        ->add_field($table1, $field, $alias);
    }

    // Build the fields for heartbeat_messages
    $join = new views_join();
    $join
      ->construct($table2, $table1, $join_by, $join_by);
    $view->query
      ->add_relationship($table2, $join, $table1);

    //$view->query->add_table($table2);
    $fields = _heartbeat_get_fields($table2);
    foreach ($fields as $field => $alias) {
      $view->query
        ->add_field($table2, $field, $alias);
    }
  }
  function uses_fields() {
    $has_fields = !empty($this->definition['uses fields']);
    return $has_fields;
  }
  function option_definition() {
    $options = parent::option_definition();
    $options['messages'] = array(
      'default' => TRUE,
    );
    return $options;
  }
  function options_form(&$form, &$form_state) {
    $form['messages'] = array(
      '#type' => 'checkbox',
      '#title' => t('Display messages'),
      '#default_value' => $this->options['messages'],
    );
  }

  /**
   * Override the behavior of the render() function.
   */
  function render($row) {
    return theme($this
      ->theme_functions(), $this->view, $this->options, $row);
  }

}

Members