|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace SRF; |
|
4
|
|
|
|
|
5
|
|
|
use SMW\ResultPrinter; |
|
6
|
|
|
use SMWQueryResult as QueryResult; |
|
7
|
|
|
use Html; |
|
8
|
|
|
|
|
9
|
|
|
/** |
|
10
|
|
|
* An event calendar printer using the FullCalendar JavaScript library |
|
11
|
|
|
* and SMWAPI. |
|
12
|
|
|
* |
|
13
|
|
|
* @since 1.9 |
|
14
|
|
|
* |
|
15
|
|
|
* @file |
|
16
|
|
|
* @ingroup QueryPrinter |
|
17
|
|
|
* |
|
18
|
|
|
* @licence GNU GPL v2+ |
|
19
|
|
|
* @author mwjames |
|
20
|
|
|
*/ |
|
21
|
|
|
|
|
22
|
|
|
/** |
|
23
|
|
|
* Query printer supporting a JavaScript Event calendar using the |
|
24
|
|
|
* Semantic MediaWiki Api |
|
25
|
|
|
* |
|
26
|
|
|
* @ingroup QueryPrinter |
|
27
|
|
|
*/ |
|
28
|
|
|
class EventCalendar extends ResultPrinter { |
|
29
|
|
|
|
|
30
|
|
|
/** |
|
31
|
|
|
* @see ResultPrinter::getName |
|
32
|
|
|
* |
|
33
|
|
|
* {@inheritDoc} |
|
34
|
|
|
*/ |
|
35
|
|
|
public function getName() { |
|
36
|
|
|
return $this->msg( 'srf-printername-eventcalendar' )->text(); |
|
37
|
|
|
} |
|
38
|
|
|
|
|
39
|
|
|
/** |
|
40
|
|
|
* @see ResultPrinter::getParamDefinitions |
|
41
|
|
|
* |
|
42
|
|
|
* @since 1.8 |
|
43
|
|
|
* |
|
44
|
|
|
* {@inheritDoc} |
|
45
|
|
|
*/ |
|
46
|
|
|
public function getParamDefinitions( array $definitions ) { |
|
47
|
|
|
$params = parent::getParamDefinitions( $definitions ); |
|
48
|
|
|
|
|
49
|
|
|
$params['defaultview'] = [ |
|
50
|
|
|
'message' => 'srf-paramdesc-calendardefaultview', |
|
51
|
|
|
'default' => 'month', |
|
52
|
|
|
'values' => [ 'month', 'basicweek', 'basicday', 'agendaweek', 'agendaday' ] |
|
53
|
|
|
]; |
|
54
|
|
|
|
|
55
|
|
|
$params['firstday'] = [ |
|
56
|
|
|
'message' => 'srf-paramdesc-calendarfirstday', |
|
57
|
|
|
'default' => 'Sunday', |
|
58
|
|
|
'values' => [ "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" ] |
|
59
|
|
|
]; |
|
60
|
|
|
|
|
61
|
|
|
$params['start'] = [ |
|
62
|
|
|
'message' => 'srf-paramdesc-calendarstart', |
|
63
|
|
|
'default' => 'current', |
|
64
|
|
|
'values' => [ 'current', 'earliest', 'latest' ] |
|
65
|
|
|
]; |
|
66
|
|
|
|
|
67
|
|
|
$params['legend'] = [ |
|
68
|
|
|
'message' => 'srf-paramdesc-calendarlegend', |
|
69
|
|
|
'default' => 'none', |
|
70
|
|
|
'values' => [ 'none', 'top', 'bottom', 'tooltip', 'pane' ] |
|
71
|
|
|
]; |
|
72
|
|
|
|
|
73
|
|
|
$params['dayview'] = [ |
|
74
|
|
|
'type' => 'boolean', |
|
75
|
|
|
'message' => 'srf-paramdesc-dayview', |
|
76
|
|
|
'default' => false |
|
77
|
|
|
]; |
|
78
|
|
|
|
|
79
|
|
|
$params['class'] = [ |
|
80
|
|
|
'message' => 'srf-paramdesc-class', |
|
81
|
|
|
'default' => '', |
|
82
|
|
|
]; |
|
83
|
|
|
|
|
84
|
|
|
$params['theme'] = [ |
|
85
|
|
|
'message' => 'srf-paramdesc-theme', |
|
86
|
|
|
'default' => 'basic', |
|
87
|
|
|
'values' => [ 'basic', 'vector' ] |
|
88
|
|
|
]; |
|
89
|
|
|
|
|
90
|
|
|
$params['clicktarget'] = [ |
|
91
|
|
|
'message' => 'srf-paramdesc-clicktarget', |
|
92
|
|
|
'default' => 'none' |
|
93
|
|
|
]; |
|
94
|
|
|
|
|
95
|
|
|
return $params; |
|
96
|
|
|
} |
|
97
|
|
|
|
|
98
|
|
|
/** |
|
99
|
|
|
* @see ResultPrinter::getResultText |
|
100
|
|
|
* |
|
101
|
|
|
* {@inheritDoc} |
|
102
|
|
|
*/ |
|
103
|
|
|
protected function getResultText( QueryResult $res, $outputmode ) { |
|
104
|
|
|
|
|
105
|
|
|
$resourceFormatter = new ResourceFormatter(); |
|
106
|
|
|
$data = $resourceFormatter->getData( $res, $outputmode, $this->params ); |
|
107
|
|
|
|
|
108
|
|
|
$this->isHTML = true; |
|
109
|
|
|
$id = $resourceFormatter->session(); |
|
110
|
|
|
|
|
111
|
|
|
// Add options |
|
112
|
|
|
$data['version'] = '0.8.0'; |
|
113
|
|
|
|
|
114
|
|
|
// Encode data object |
|
115
|
|
|
$resourceFormatter->encode( $id, $data ); |
|
116
|
|
|
|
|
117
|
|
|
// Init RL module |
|
118
|
|
|
$resourceFormatter->registerResources( [ 'ext.srf.eventcalendar' ] ); |
|
119
|
|
|
|
|
120
|
|
|
// Element includes info, spinner, and container placeholder |
|
121
|
|
|
return Html::rawElement( |
|
122
|
|
|
'div', |
|
123
|
|
|
[ |
|
124
|
|
|
'class' => 'srf-eventcalendar', |
|
125
|
|
|
'data-external-class' => ( $this->params['class'] ? $this->params['class'] : '' ) |
|
126
|
|
|
], |
|
127
|
|
|
Html::element( |
|
128
|
|
|
'div', |
|
129
|
|
|
[ |
|
130
|
|
|
'class' => 'srf-top' |
|
131
|
|
|
], |
|
132
|
|
|
'' |
|
133
|
|
|
) . $resourceFormatter->placeholder() . Html::element( |
|
134
|
|
|
'div', |
|
135
|
|
|
[ |
|
136
|
|
|
'id' => $id, |
|
137
|
|
|
'class' => 'srf-container', |
|
138
|
|
|
'style' => 'display:none;' |
|
139
|
|
|
] |
|
140
|
|
|
) |
|
141
|
|
|
); |
|
142
|
|
|
} |
|
143
|
|
|
|
|
144
|
|
|
} |
|
145
|
|
|
|