Projet

Général

Profil

Paste
Télécharger (1,64 ko) Statistiques
| Branche: | Révision:

root / drupal7 / sites / all / modules / advanced_forum / includes / views / advanced_forum_handler_field_node_topic_pager.inc @ 13c3c9b4

1
<?php
2

    
3
/**
4
 * @file
5
 * Field handler to display the topic pager.
6
 */
7

    
8
// @codingStandardsIgnoreStart
9
class advanced_forum_handler_field_node_topic_pager extends views_handler_field {
10
  /**
11
   * {@inheritdoc}
12
   */
13
  public function construct() {
14
    parent::construct();
15
    $this->additional_fields = array('nid' => 'nid', 'type' => 'type');
16
  }
17

    
18
  /**
19
   * {@inheritdoc}
20
   */
21
  public function option_definition() {
22
    $options = parent::option_definition();
23

    
24
    $options['total_pages_shown'] = array('default' => 6);
25

    
26
    return $options;
27
  }
28

    
29
  /**
30
   * {@inheritdoc}
31
   */
32
  public function options_form(&$form, &$form_state) {
33
    parent::options_form($form, $form_state);
34
    $form['total_pages_shown'] = array(
35
      '#title' => t('Total pages shown'),
36
      '#description' => t('Total number of page numbers to show, including initial numbers and one final. 0 hides pager.'),
37
      '#type' => 'textfield',
38
      '#default_value' => $this->options['total_pages_shown'],
39
    );
40
  }
41

    
42
  /**
43
   * {@inheritdoc}
44
   */
45
  public function query() {
46
    $this->ensure_my_table();
47
    $this->add_additional_fields();
48
    $this->field_alias = $this->table . '_' . $this->field;
49
  }
50

    
51
  /**
52
   * {@inheritdoc}
53
   */
54
  public function render($values) {
55
    // Make a fake topic object with the information that the core one has.
56
    $topic = new stdClass();
57
    $topic->nid = $values->nid;
58
    $topic->type = $values->node_type;
59
    $topic->comment_count = $values->node_comment_statistics_comment_count;
60

    
61
    return theme('advanced_forum_topic_pager', array(
62
      'pagecount' => $this->options['total_pages_shown'],
63
      'topic' => $topic,
64
    ));
65
  }
66
}
67
// @codingStandardsIgnoreEnd