summaryrefslogtreecommitdiff
blob: 0abbd23c4a3bff6676caf737ba824df03604fd25 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
<?php

namespace SRF;
use SMW, Html;

/**
 * DataTables and SMWAPI.
 *
 * @since 1.9
 * @licence GNU GPL v2 or later
 *
 * @author mwjames
 */
class DataTables extends SMW\ApiResultPrinter {

	/**
	 * Corresponding message name
	 *
	 */
	public function getName() {
		return $this->getContext()->msg( 'srf-printername-datatables' )->text();
	}

	/**
	 * Prepare html output
	 *
	 * @since 1.9
	 *
	 * @param array $data
	 * @return string
	 */
	protected function getHtml( array $data ) {

		// Init
		$this->isHTML = true;
		$id = $this->getId();

		// Add options
		$data['version'] = '0.2.5';

		// Encode data object
		$this->encode( $id, $data );

		// Init RL module
		$this->addResources( 'ext.srf.datatables' );

		// Element includes info, spinner, and container placeholder
		return Html::rawElement( 'div', array(
				'class' => 'srf-datatables' . ( $this->params['class'] ? ' ' . $this->params['class'] : '' ),
				'data-theme' => $this->params['theme'],
			), Html::element( 'div', array(
					'class' => 'top'
					)
				) . $this->loading() .
				Html::element( 'div', array(
					'id' => $id,
					'class' => 'container',
					'style' => 'display:none;'
					)
				)
		);
	}

	/**
	 * @see SMWResultPrinter::getParamDefinitions
	 *
	 * @since 1.8
	 *
	 * @param $definitions array of IParamDefinition
	 *
	 * @return array of IParamDefinition|array
	 */
	public function getParamDefinitions( array $definitions ) {
		$params = parent::getParamDefinitions( $definitions );

		$params['class'] = array(
			'message' => 'srf-paramdesc-class',
			'default' => '',
		);

		$params['theme'] = array(
			'message' => 'srf-paramdesc-theme',
			'default' => 'bootstrap',
			'values' => array ( 'bootstrap' ) // feel free to add more designs
		);

		return $params;
	}
}