Completed
Push — master ( 1d5592...98633c )
by mw
02:13
created

EventCalendar::getName()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

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