1 |
85ad3d82
|
Assos Assos
|
<?php
|
2 |
|
|
|
3 |
|
|
/**
|
4 |
|
|
* @file
|
5 |
|
|
* Field handler to display the topic pager.
|
6 |
|
|
*/
|
7 |
|
|
|
8 |
13c3c9b4
|
Assos Assos
|
// @codingStandardsIgnoreStart
|
9 |
|
|
class advanced_forum_handler_field_node_topic_pager extends views_handler_field {
|
10 |
|
|
/**
|
11 |
|
|
* {@inheritdoc}
|
12 |
|
|
*/
|
13 |
|
|
public function construct() {
|
14 |
85ad3d82
|
Assos Assos
|
parent::construct();
|
15 |
|
|
$this->additional_fields = array('nid' => 'nid', 'type' => 'type');
|
16 |
|
|
}
|
17 |
|
|
|
18 |
13c3c9b4
|
Assos Assos
|
/**
|
19 |
|
|
* {@inheritdoc}
|
20 |
|
|
*/
|
21 |
|
|
public function option_definition() {
|
22 |
85ad3d82
|
Assos Assos
|
$options = parent::option_definition();
|
23 |
|
|
|
24 |
|
|
$options['total_pages_shown'] = array('default' => 6);
|
25 |
|
|
|
26 |
|
|
return $options;
|
27 |
|
|
}
|
28 |
|
|
|
29 |
13c3c9b4
|
Assos Assos
|
/**
|
30 |
|
|
* {@inheritdoc}
|
31 |
|
|
*/
|
32 |
|
|
public function options_form(&$form, &$form_state) {
|
33 |
85ad3d82
|
Assos Assos
|
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 |
13c3c9b4
|
Assos Assos
|
/**
|
43 |
|
|
* {@inheritdoc}
|
44 |
|
|
*/
|
45 |
|
|
public function query() {
|
46 |
85ad3d82
|
Assos Assos
|
$this->ensure_my_table();
|
47 |
|
|
$this->add_additional_fields();
|
48 |
|
|
$this->field_alias = $this->table . '_' . $this->field;
|
49 |
|
|
}
|
50 |
|
|
|
51 |
13c3c9b4
|
Assos Assos
|
/**
|
52 |
|
|
* {@inheritdoc}
|
53 |
|
|
*/
|
54 |
|
|
public function render($values) {
|
55 |
85ad3d82
|
Assos Assos
|
// 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 |
13c3c9b4
|
Assos Assos
|
'pagecount' => $this->options['total_pages_shown'],
|
63 |
|
|
'topic' => $topic,
|
64 |
85ad3d82
|
Assos Assos
|
));
|
65 |
|
|
}
|
66 |
|
|
}
|
67 |
13c3c9b4
|
Assos Assos
|
// @codingStandardsIgnoreEnd |