Completed
Push — master ( 9b2ed5...981814 )
by Jeroen De
76:07
created

formats/widget/SRF_ListWidget.php (1 issue)

Labels
Severity

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
3
use SMW\ListResultPrinter;
4
5
/**
6
 * Extends the list result printer (SMW_QP_List.php) with a JavaScript
7
 * navigation widget
8
 *
9
 * @since 1.8
10
 *
11
 * @author mwjames
12
 *
13
 * @ingroup SemanticResultFormats
14
 * @file SRF_ListWidget.php
15
 */
16
class SRFListWidget extends ListResultPrinter {
17
18
	/**
19
	 * Get a human readable label for this printer.
20
	 *
21
	 * @return string
22
	 */
23
	public function getName() {
24
		return wfMessage( 'srf-printername-listwidget' )->text();
25
	}
26
27
	/**
28
	 * @see SMWResultPrinter::getResultText
29
	 *
30
	 * @param SMWQueryResult $res
31
	 * @param array $params
0 ignored issues
show
There is no parameter named $params. Was it maybe removed?

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 $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
32
	 * @param $outputmode
33
	 *
34
	 * @return string
35
	 */
36
	protected function getResultText( SMWQueryResult $res, $outputmode ) {
37
		// Initialize
38
		static $statNr = 0;
39
		//$this->isHTML = true;
40
41
		// Set output type for the parent
42
		$this->mFormat = $this->params['listtype'] == 'ordered' || $this->params['listtype'] == 'ol' ? 'ol' : 'ul';
43
44
		// Get results from SMWListResultPrinter
45
		$result = parent::getResultText( $res, $outputmode );
46
47
		// Count widgets
48
		$listwidgetID = 'listwidget-' . ++$statNr;
49
50
		// OL/UL container items
51
		$result = Html::rawElement(
52
			'div',
53
			[
54
				'id' => $listwidgetID,
55
				'class' => 'listwidget-container',
56
				'style' => 'display:none; position: relative; margin-bottom:5px; margin-top:5px;'
57
			],
58
			$result
59
		);
60
61
		// Placeholder
62
		$processing = SRFUtils::htmlProcessingElement( $this->isHTML );
63
64
		// RL module
65
		$resource = 'ext.srf.listwidget.' . $this->params['widget'];
66
		SMWOutputs::requireResource( $resource );
67
68
		// Wrap results
69
		return Html::rawElement(
70
			'div',
71
			[
72
				'class' => 'srf-listwidget ' . htmlspecialchars( $this->params['class'] ),
73
				'data-listtype' => $this->mFormat,
74
				'data-widget' => $this->params['widget'],
75
				'data-pageitems' => $this->params['pageitems'],
76
			],
77
			$processing . $result
78
		);
79
	}
80
81
	/**
82
	 * @see SMWResultPrinter::getParamDefinitions
83
	 *
84
	 * @since 1.8
85
	 *
86
	 * @param $definitions array of IParamDefinition
87
	 *
88
	 * @return array of IParamDefinition|array
89
	 */
90
	public function getParamDefinitions( array $definitions ) {
91
		$params = parent::getParamDefinitions( $definitions );
92
93
		$params['class'] = [
94
			'name' => 'class',
95
			'message' => 'srf-paramdesc-class',
96
			'default' => '',
97
		];
98
99
		$params['listtype'] = [
100
			'name' => 'listtype',
101
			'message' => 'srf-paramdesc-listtype',
102
			'values' => [ 'unordered', 'ordered' ],
103
			'default' => 'unordered'
104
		];
105
106
		$params['widget'] = [
107
			'name' => 'widget',
108
			'message' => 'srf-paramdesc-widget',
109
			'values' => [ 'alphabet', 'menu', 'pagination' ],
110
			'default' => 'alphabet'
111
		];
112
113
		$params['pageitems'] = [
114
			'type' => 'integer',
115
			'name' => 'pageitems',
116
			'message' => 'srf-paramdesc-pageitems',
117
			'default' => 5,
118
		];
119
120
		return $params;
121
	}
122
}