-
Notifications
You must be signed in to change notification settings - Fork 10
/
islandora_chem_sp.install
116 lines (105 loc) · 5.34 KB
/
islandora_chem_sp.install
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
<?php
/**
* @file
*
* Installs the required associations/forms.
*/
define('ISLANDORA_CHEM_SP_MODS_FORM_NAME', 'Islandora Chem MODS Form');
define('ISLANDORA_CHEM_SP_MADS_FORM_NAME', 'Islandora Chem MADS Form');
/**
* Implementation of hook_install.
*/
function islandora_chem_sp_install() {
module_load_include('inc', 'islandora_chem_sp', 'islandora_chem_sp_schema');
drupal_install_schema('islandora_chem_sp');
module_load_include('inc', 'xml_form_builder', 'XMLFormDatabase');
if (!XMLFormDatabase::Exists(ISLANDORA_CHEM_SP_MODS_FORM_NAME)) {
$module_path = drupal_get_path('module', 'islandora_chem_sp');
$definition = new DOMDocument();
$definition->load($module_path . '/xml/mods_chem.xml');
XMLFormDatabase::Create(ISLANDORA_CHEM_SP_MODS_FORM_NAME, $definition);
}
if (!XMLFormDatabase::Exists(ISLANDORA_CHEM_SP_MADS_FORM_NAME)) {
$module_path = drupal_get_path('module', 'islandora_chem_sp');
$definition = new DOMDocument();
$definition->load($module_path . '/xml/mads_chem.xml');
XMLFormDatabase::Create(ISLANDORA_CHEM_SP_MADS_FORM_NAME, $definition);
}
// Associates the form with the content model
$result = db_result(db_query('Select content_model from {islandora_content_model_forms} where content_model = "%s" and form_name = "%s"', 'quantumchem:sp_chem_CM', 'Islandora Chem MODS Form'));
if (!$result) {
$object = new stdClass();
$object->content_model = 'islandora:sp_chem_CM';
$object->form_name = 'Islandora Chem MODS Form';
$object->dsid = 'MODS';
$object->title_field = "['titleInfo']['title']";
$object->transform = 'mods_to_dc.xsl';
$result = drupal_write_record('islandora_content_model_forms', $object);
}
$result = db_result(db_query('Select content_model from {islandora_content_model_forms} where content_model = "%s" and form_name = "%s"', 'quantumchem:sp_chem_researcher_CM', 'Islandora Chem MADS Form'));
if (!$result) {
$object = new stdClass();
$object->content_model = 'islandora:sp_chem_researcher_CM';
$object->form_name = 'Islandora Chem MADS Form';
$object->dsid = 'MADS';
$object->title_field = "['titleInfo']['title']";
$object->transform = 'mods_to_dc.xsl';
$result = drupal_write_record('islandora_content_model_forms', $object);
}
}
function islandora_chem_sp_requirements($phase) {
global $base_url;
$requirements = array();
$requirements['fedora-cdw']['title'] = t("ChemDoodleWeb installed");
$module_path = drupal_get_path('module', 'islandora_chem_sp');
$result = file_exists($module_path . '/js/ChemDoodleWeb/install/ChemDoodleWeb.js');
if (!$result) {
$requirements['fedora-cdw']['value'] = t('ChemDoodleWeb is not installed');
$requirements['fedora-cdw']['description'] = t('Islandora will not be able to show 3D structures. Click <a href="http://web.chemdoodle.com/">here</a> for installation instructions');
$requirements['fedora-cdw']['severity'] = REQUIREMENT_WARNING;
}
else {
$requirements['fedora-cdw']['value'] = t("Installed");
$requirements['fedora-cdw']['severity'] = REQUIREMENT_OK;
}
$requirements['fedora-obabel']['title'] = t("Open Babel installed");
$result = exec('obabel');
if (!$result) {
$requirements['fedora-obabel']['value'] = t('Open Babel is not in the path');
$requirements['fedora-obabel']['description'] = t('Islandora will not be able to convert chemistry files. Click <a href="http://openbabel.org">here</a> for installation instructions');
$requirements['fedora-obabel']['severity'] = REQUIREMENT_WARNING;
}
else {
$requirements['fedora-obabel']['value'] = t("Installed");
$requirements['fedora-obabel']['severity'] = REQUIREMENT_OK;
}
$requirements['fedora-checkmol']['title'] = t("Checkmol installed");
$result = exec('checkmol');
if (!$result) {
$requirements['fedora-checkmol']['value'] = t('Checkmol is not in the path');
$requirements['fedora-checkmol']['description'] = t('Islandora will not be able to analyse chemistry files. Click <a href="http://merian.pch.univie.ac.at/~nhaider/cheminf/cmmm.html">here</a> for installation instructions');
$requirements['fedora-checkmol']['severity'] = REQUIREMENT_WARNING;
}
else {
$requirements['fedora-checkmol']['value'] = t("Installed");
$requirements['fedora-checkmol']['severity'] = REQUIREMENT_OK;
}
return $requirements;
}
/**
* Implementation of hook_uninstall.
*/
function islandora_chem_sp_uninstall() {
module_load_include('inc', 'xml_form_builder', 'XMLFormDatabase');
if (XMLFormDatabase::Exists(ISLANDORA_CHEM_SP_MODS_FORM_NAME)) {
XMLFormDatabase::Delete(ISLANDORA_CHEM_SP_MODS_FORM_NAME);
}
$result = db_result(db_query('Select content_model from {islandora_content_model_forms} where content_model = "%s" and form_name = "%s"', 'islandora:sp_chem_CM', 'Islandora Chem MODS Form'));
if ($result) {
db_query('DELETE FROM {islandora_content_model_forms} WHERE content_model = "%s" and form_name = "%s"', 'islandora:sp_chem_CM', 'Islandora Chem MODS Form');
}
$result = db_result(db_query('Select content_model from {islandora_content_model_forms} where content_model = "%s" and form_name = "%s"', 'islandora:sp_chem_researcher_CM', 'Islandora Chem MADS Form'));
if ($result) {
db_query('DELETE FROM {islandora_content_model_forms} WHERE content_model = "%s" and form_name = "%s"', 'islandora:sp_chem_researcher_CM', 'Islandora Chem MADS Form');
}
}