|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
use SMW\Query\ResultPrinters\ListResultPrinter\ListResultBuilder; |
|
4
|
|
|
use SMW\Query\ResultPrinters\ResultPrinter; |
|
5
|
|
|
|
|
6
|
|
|
/** |
|
7
|
|
|
* Extends the list result printer (SMW_QP_List.php) with a JavaScript |
|
8
|
|
|
* navigation widget |
|
9
|
|
|
* |
|
10
|
|
|
* @since 1.8 |
|
11
|
|
|
* |
|
12
|
|
|
* @author mwjames |
|
13
|
|
|
* |
|
14
|
|
|
* @ingroup SemanticResultFormats |
|
15
|
|
|
* @file SRF_ListWidget.php |
|
16
|
|
|
*/ |
|
17
|
|
|
class SRFListWidget extends ResultPrinter { |
|
18
|
|
|
|
|
19
|
|
|
/** |
|
20
|
|
|
* Get a human readable label for this printer. |
|
21
|
|
|
* |
|
22
|
|
|
* @return string |
|
23
|
|
|
*/ |
|
24
|
|
|
public function getName() { |
|
25
|
|
|
return wfMessage( 'srf-printername-listwidget' )->text(); |
|
26
|
|
|
} |
|
27
|
|
|
|
|
28
|
|
|
/** |
|
29
|
|
|
* @see SMWResultPrinter::getResultText |
|
30
|
|
|
* |
|
31
|
|
|
* @param SMWQueryResult $res |
|
32
|
|
|
* @param array $params |
|
|
|
|
|
|
33
|
|
|
* @param $outputmode |
|
34
|
|
|
* |
|
35
|
|
|
* @return string |
|
36
|
|
|
*/ |
|
37
|
1 |
|
protected function getResultText( SMWQueryResult $res, $outputmode ) { |
|
38
|
|
|
// Initialize |
|
39
|
1 |
|
static $statNr = 0; |
|
40
|
|
|
//$this->isHTML = true; |
|
41
|
|
|
|
|
42
|
1 |
|
$listType = $this->params[ 'listtype' ] === 'ordered' || $this->params[ 'listtype' ] === 'ol' ? 'ol' : 'ul'; |
|
43
|
|
|
|
|
44
|
1 |
|
$builder = new ListResultBuilder( $res, $this->mLinker ); |
|
45
|
|
|
|
|
46
|
1 |
|
$builder->set( $this->params ); |
|
47
|
1 |
|
$builder->set( [ |
|
|
|
|
|
|
48
|
1 |
|
'format' => $listType, |
|
49
|
1 |
|
'link-first' => $this->mLinkFirst, |
|
50
|
1 |
|
'link-others' => $this->mLinkOthers, |
|
51
|
1 |
|
'show-headers' => $this->mShowHeaders, |
|
52
|
|
|
] ); |
|
53
|
|
|
|
|
54
|
|
|
// Get results from SMWListResultPrinter |
|
55
|
1 |
|
$result = $builder->getResultText(); |
|
56
|
|
|
|
|
57
|
|
|
// Count widgets |
|
58
|
1 |
|
$listwidgetID = 'listwidget-' . ++$statNr; |
|
59
|
|
|
|
|
60
|
|
|
// OL/UL container items |
|
61
|
1 |
|
$result = Html::rawElement( |
|
62
|
1 |
|
'div', |
|
63
|
|
|
[ |
|
64
|
1 |
|
'id' => $listwidgetID, |
|
65
|
1 |
|
'class' => 'listwidget-container', |
|
66
|
1 |
|
'style' => 'display:none; position: relative; margin-bottom:5px; margin-top:5px;' |
|
67
|
|
|
], |
|
68
|
1 |
|
$result |
|
69
|
|
|
); |
|
70
|
|
|
|
|
71
|
|
|
// Placeholder |
|
72
|
1 |
|
$processing = SRFUtils::htmlProcessingElement( $this->isHTML ); |
|
73
|
|
|
|
|
74
|
|
|
// RL module |
|
75
|
1 |
|
$resource = 'ext.srf.listwidget.' . $this->params['widget']; |
|
76
|
1 |
|
SMWOutputs::requireResource( $resource ); |
|
77
|
|
|
|
|
78
|
|
|
// Wrap results |
|
79
|
1 |
|
return Html::rawElement( |
|
80
|
1 |
|
'div', |
|
81
|
|
|
[ |
|
82
|
1 |
|
'class' => 'srf-listwidget ' . htmlspecialchars( $this->params['class'] ), |
|
83
|
1 |
|
'data-listtype' => $listType, |
|
84
|
1 |
|
'data-widget' => $this->params['widget'], |
|
85
|
1 |
|
'data-pageitems' => $this->params['pageitems'], |
|
86
|
|
|
], |
|
87
|
1 |
|
$processing . $result |
|
88
|
|
|
); |
|
89
|
|
|
} |
|
90
|
|
|
|
|
91
|
|
|
/** |
|
92
|
|
|
* @see SMWResultPrinter::getParamDefinitions |
|
93
|
|
|
* |
|
94
|
|
|
* @since 1.8 |
|
95
|
|
|
* |
|
96
|
|
|
* @param $definitions array of IParamDefinition |
|
97
|
|
|
* |
|
98
|
|
|
* @return array of IParamDefinition|array |
|
99
|
|
|
*/ |
|
100
|
1 |
|
public function getParamDefinitions( array $definitions ) { |
|
101
|
1 |
|
$params = parent::getParamDefinitions( $definitions ); |
|
102
|
|
|
|
|
103
|
1 |
|
$params['class'] = [ |
|
104
|
|
|
'name' => 'class', |
|
105
|
|
|
'message' => 'srf-paramdesc-class', |
|
106
|
|
|
'default' => '', |
|
107
|
|
|
]; |
|
108
|
|
|
|
|
109
|
1 |
|
$params['listtype'] = [ |
|
110
|
|
|
'name' => 'listtype', |
|
111
|
|
|
'message' => 'srf-paramdesc-listtype', |
|
112
|
|
|
'values' => [ 'unordered', 'ordered' ], |
|
113
|
|
|
'default' => 'unordered' |
|
114
|
|
|
]; |
|
115
|
|
|
|
|
116
|
1 |
|
$params['widget'] = [ |
|
117
|
|
|
'name' => 'widget', |
|
118
|
|
|
'message' => 'srf-paramdesc-widget', |
|
119
|
|
|
'values' => [ 'alphabet', 'menu', 'pagination' ], |
|
120
|
|
|
'default' => 'alphabet' |
|
121
|
|
|
]; |
|
122
|
|
|
|
|
123
|
1 |
|
$params['pageitems'] = [ |
|
124
|
|
|
'type' => 'integer', |
|
125
|
|
|
'name' => 'pageitems', |
|
126
|
|
|
'message' => 'srf-paramdesc-pageitems', |
|
127
|
|
|
'default' => 5, |
|
128
|
|
|
]; |
|
129
|
|
|
|
|
130
|
1 |
|
return $params; |
|
131
|
|
|
} |
|
132
|
|
|
} |
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.
Consider the following example. The parameter
$italyis not defined by the methodfinale(...).The most likely cause is that the parameter was removed, but the annotation was not.