forked from ctsit/redcap_entity
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExternalModule.php
More file actions
72 lines (62 loc) · 1.8 KB
/
ExternalModule.php
File metadata and controls
72 lines (62 loc) · 1.8 KB
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
<?php
/**
* @file
* Provides ExternalModule class for REDCap Entity module.
*/
namespace REDCapEntity\ExternalModule;
require_once 'classes/EntityDB.php';
require_once 'classes/EntityFactory.php';
require_once 'classes/Page.php';
require_once 'classes/EntityFormTrait.php';
require_once 'classes/EntityForm.php';
require_once 'classes/EntityDeleteForm.php';
require_once 'classes/EntityList.php';
require_once 'classes/StatusMessageQueue.php';
use ExternalModules\AbstractExternalModule;
use ExternalModules\ExternalModules;
/**
* ExternalModule class for REDCap Entity module.
*/
class ExternalModule extends AbstractExternalModule {
/**
* @inheritdoc.
*/
function redcap_every_page_before_render($project_id = null) {
define('REDCAP_ENTITY_PREFIX', $this->PREFIX);
}
/**
* @inheritdoc
*/
function redcap_every_page_top($project_id) {
if (strpos(PAGE, 'ExternalModules/manager/control_center.php') === false) {
return;
}
$this->includeJs('manager/js/global_config.js');
$this->setJsSettings(['modulePrefix' => $this->PREFIX]);
}
/**
* @inheritdoc
*/
function redcap_module_system_enable($version) {
// Making sure the module is enabled on all projects.
$this->setSystemSetting(ExternalModules::KEY_ENABLED, true);
}
/**
* Includes a local JS file.
*
* @param string $path
* The relative path to the js file.
*/
function includeJs($path) {
echo '<script src="' . $this->getUrl($path) . '"></script>';
}
/**
* Sets JS settings.
*
* @param mixed $settings
* The setting settings.
*/
protected function setJsSettings($settings) {
echo '<script>redcapEntity = ' . json_encode($settings) . ';</script>';
}
}