1
|
<?php
|
2
|
|
3
|
/**
|
4
|
* @file
|
5
|
* Field handler to display the topic pager.
|
6
|
*/
|
7
|
|
8
|
class advanced_forum_handler_field_node_topic_pager extends views_handler_field{
|
9
|
function construct() {
|
10
|
parent::construct();
|
11
|
$this->additional_fields = array('nid' => 'nid', 'type' => 'type');
|
12
|
}
|
13
|
|
14
|
function option_definition() {
|
15
|
$options = parent::option_definition();
|
16
|
|
17
|
$options['total_pages_shown'] = array('default' => 6);
|
18
|
|
19
|
return $options;
|
20
|
}
|
21
|
|
22
|
function options_form(&$form, &$form_state) {
|
23
|
parent::options_form($form, $form_state);
|
24
|
$form['total_pages_shown'] = array(
|
25
|
'#title' => t('Total pages shown'),
|
26
|
'#description' => t('Total number of page numbers to show, including initial numbers and one final. 0 hides pager.'),
|
27
|
'#type' => 'textfield',
|
28
|
'#default_value' => $this->options['total_pages_shown'],
|
29
|
);
|
30
|
}
|
31
|
|
32
|
function query() {
|
33
|
$this->ensure_my_table();
|
34
|
$this->add_additional_fields();
|
35
|
$this->field_alias = $this->table . '_' . $this->field;
|
36
|
}
|
37
|
|
38
|
function render($values) {
|
39
|
// Make a fake topic object with the information that the core one has.
|
40
|
$topic = new stdClass();
|
41
|
$topic->nid = $values->nid;
|
42
|
$topic->type = $values->node_type;
|
43
|
$topic->comment_count = $values->node_comment_statistics_comment_count;
|
44
|
|
45
|
return theme('advanced_forum_topic_pager', array(
|
46
|
'pagecount' => $this->options['total_pages_shown'],
|
47
|
'topic' => $topic
|
48
|
));
|
49
|
}
|
50
|
}
|