1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace SRF\Filtered\View; |
4
|
|
|
|
5
|
|
|
/** |
6
|
|
|
* File holding the SRF_Filtered_View class |
7
|
|
|
* |
8
|
|
|
* @author Stephan Gambke |
9
|
|
|
* @file |
10
|
|
|
* @ingroup SemanticResultFormats |
11
|
|
|
*/ |
12
|
|
|
use SRF\Filtered\Filtered; |
13
|
|
|
use SRF\Filtered\ResultItem; |
14
|
|
|
|
15
|
|
|
/** |
16
|
|
|
* The SRF_Filtered_View class. |
17
|
|
|
* |
18
|
|
|
* @ingroup SemanticResultFormats |
19
|
|
|
*/ |
20
|
|
|
abstract class View { |
21
|
|
|
|
22
|
|
|
private $mParameters; |
23
|
|
|
private $mQueryPrinter; |
24
|
|
|
private $mResults; |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* Constructor for the view. |
28
|
|
|
* |
29
|
|
|
* @param ResultItem[] $results |
30
|
|
|
* @param string[] $params array of parameter values given as key-value-pairs |
31
|
|
|
* @param Filtered $queryPrinter |
32
|
|
|
*/ |
33
|
|
|
public function __construct( array &$results, array &$params, Filtered &$queryPrinter ) { |
34
|
|
|
$this->mResults = $results; |
35
|
|
|
$this->mParameters = $params; |
36
|
|
|
$this->mQueryPrinter = $queryPrinter; |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* @return ResultItem[] |
41
|
|
|
*/ |
42
|
|
|
public function &getQueryResults() { return $this->mResults; } |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* @return string[] |
46
|
|
|
*/ |
47
|
|
|
public function &getActualParameters() { return $this->mParameters; } |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* @return Filtered |
51
|
|
|
*/ |
52
|
|
|
public function &getQueryPrinter() { return $this->mQueryPrinter; } |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* Returns the name (string) or names (array of strings) of the resource |
56
|
|
|
* modules to load. |
57
|
|
|
* |
58
|
|
|
* @return string|string[]|null |
59
|
|
|
*/ |
60
|
|
|
public function getResourceModules() { |
61
|
|
|
return null; |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
/** |
65
|
|
|
* A function to describe the allowed parameters of a query for this view. |
66
|
|
|
* |
67
|
|
|
* @return array of Parameter |
68
|
|
|
*/ |
69
|
|
|
public static function getParameters() { |
70
|
|
|
return []; |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
/** |
74
|
|
|
* Returns the HTML text that is to be included for this view. |
75
|
|
|
* |
76
|
|
|
* This text will appear on the page in a div that has the view's id set as |
77
|
|
|
* class. |
78
|
|
|
* |
79
|
|
|
* @return string |
80
|
|
|
*/ |
81
|
|
|
public function getResultText() { |
82
|
|
|
return ''; |
83
|
|
|
} |
84
|
|
|
|
85
|
|
|
/** |
86
|
|
|
* @param ResultItem $row |
87
|
|
|
* @return null |
88
|
|
|
*/ |
89
|
|
|
public function getJsDataForRow( ResultItem $row ) { |
90
|
|
|
return null; |
91
|
|
|
} |
92
|
|
|
|
93
|
|
|
/** |
94
|
|
|
* Returns an array of config data for this view to be stored in the JS |
95
|
|
|
* @return array |
96
|
|
|
*/ |
97
|
|
|
public function getJsConfig() { |
98
|
|
|
return []; |
99
|
|
|
} |
100
|
|
|
|
101
|
|
|
/** |
102
|
|
|
* Check if the view is ready to run, e.g. all required environment |
103
|
|
|
* variables are set. |
104
|
|
|
* |
105
|
|
|
* @return string | null |
106
|
|
|
*/ |
107
|
|
|
public function getInitError() { |
108
|
|
|
return null; |
109
|
|
|
} |
110
|
|
|
} |
111
|
|
|
|