Projet

Général

Profil

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

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

1
<?php
2

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

    
8
// @codingStandardsIgnoreStart
9
class advanced_forum_handler_field_node_topic_icon 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
    $options['hot_topic_threshold'] = array('default' => 15);
24
    return $options;
25
  }
26

    
27
  /**
28
   * {@inheritdoc}
29
   */
30
  public function options_form(&$form, &$form_state) {
31
    parent::options_form($form, $form_state);
32
    $form['hot_topic_threshold'] = array(
33
      '#title' => t('Hot topic threshold'),
34
      '#description' => t('The number of posts a topic must have to be considered "hot".'),
35
      '#type' => 'textfield',
36
      '#default_value' => $this->options['hot_topic_threshold'],
37
    );
38
  }
39

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

    
49
  /**
50
   * {@inheritdoc}
51
   */
52
  public function render($values) {
53
    $new_posts = advanced_forum_reply_num_new($values->nid);
54
    return theme('forum_icon', array(
55
        'new_posts' => $new_posts,
56
        'num_posts' => empty($values->node_comment_statistics_comment_count) ? 1 : $values->node_comment_statistics_comment_count + 1,
57
        'comment_mode' => $values->node_comment,
58
        'sticky' => $values->node_sticky,
59
        'node_type' => $values->node_type,
60
    ));
61
  }
62
}
63
// @codingStandardsIgnoreEnd