-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathExportSPSSsav.php
84 lines (70 loc) · 2.62 KB
/
ExportSPSSsav.php
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
<?php
class ExportSPSSsav extends \LimeSurvey\PluginManager\PluginBase
{
protected $storage = 'DbStorage';
static protected $description = 'Export survey results to an SPSS sav file';
static protected $name = 'SPSS Export';
public function init()
{
/**
* Here you should handle subscribing to the events your plugin will handle
*/
$this->subscribe('listExportPlugins');
$this->subscribe('listExportOptions');
$this->subscribe('newExport');
}
protected $settings = array(
'spssfileversion' => array(
'type' => 'select',
'label' => 'Export for SPSS',
'options' => array('16' => 'versions 14 and above', '13' => 'version 13 and below (limited string length)'),
'default' => '16',
'submitonchange'=> false
)
);
public function listExportOptions()
{
$event = $this->getEvent();
$type = $event->get('type');
switch ($type) {
case 'spsssav':
$event->set('label', gT("SPSS (.sav)"));
$event->set('onclick', '
document.getElementById("answers-short").checked=true;
document.getElementById("answers-long").disabled=true;
document.getElementById("converty").checked=true;
document.getElementById("convertn").checked=true;
document.getElementById("convertnto").value=0;
document.getElementById("convertyto").value=1;
document.getElementById("headstyle-code").disabled=true;
document.getElementById("headstyle-abbreviated").disabled=true;
document.getElementById("headstyle-full").checked=true;
document.getElementById("headstyle-codetext").disabled=true;
');
break;
default:
break;
}
}
/**
* Registers this export type
*/
public function listExportPlugins()
{
$event = $this->getEvent();
$exports = $event->get('exportplugins');
// Yes we overwrite existing classes if available
$exports['spsssav'] = get_class();
$event->set('exportplugins', $exports);
}
/**
* Returns the required IWriter
*/
public function newExport()
{
$event = $this->getEvent();
$pluginsettings = $this->getPluginSettings(true);
$writer = new SPSSWriter($pluginsettings);
$event->set('writer', $writer);
}
}