-
Notifications
You must be signed in to change notification settings - Fork 0
/
visualscience_docgraph.install
49 lines (44 loc) · 1.42 KB
/
visualscience_docgraph.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
<?php
function visualscience_docgraph_install() {
$public_uri = FALSE;
if ($wrapper = file_stream_wrapper_get_instance_by_uri('public://')) {
$public_uri = $wrapper->realpath();
}
if ($public_uri === FALSE) {
drupal_set_message(st('Error at Document Graph installation. Public URI creation failed.'), 'error');
return;
}
$main_path = '/visualscience_docgraph/';
variable_set('visualscience_docgraph_main_path', $main_path);
if (!is_dir($public_uri . $main_path)) {
drupal_mkdir($public_uri . $main_path, 0777);
}
_visualscience_docgraph_generate_author($public_uri . $main_path);
_visualscience_docgraph_generate_reference($public_uri . $main_path);
}
function visualscience_docgraph_uninstall() {
$path = variable_get('visualscience_docgraph_main_path');
$public_uri = FALSE;
if ($wrapper = file_stream_wrapper_get_instance_by_uri('public://')) {
$public_uri = $wrapper->realpath();
}
if ($public_uri === FALSE) {
drupal_set_message(t('Error at Document Graphs uninstallation. Public URI is FALSE.'), 'error');
return;
}
_visualscience_docgraph_rrmdir($public_uri . $path);
}
function _visualscience_docgraph_rrmdir($dir) {
if (strpos($dir, "/") !== strlen($dir) - 1) {
$dir .= "/";
}
foreach (glob($dir . '*') as $file) {
if (is_dir($file)) {
_visualscience_docgraph_rrmdir($file);
}
else {
drupal_unlink($file);
}
}
drupal_rmdir($dir);
}