-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathyui.install
57 lines (53 loc) · 1.83 KB
/
yui.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
<?php
/**
* @file
* The install hooks for this module.
*/
/**
* Implements hook_requirements().
*/
function yui_requirements($phase) {
// module_load_include() isn't avaliable during the 'install' $phase.
require_once dirname(__FILE__) . '/includes/utilities.inc';
$t = get_t();
$requirements = array(
'yui' => array('title' => $t('Yahoo YUI Library')),
);
if ($version = yui_get_version()) {
$requirements['yui']['severity'] = REQUIREMENT_OK;
$requirements['yui']['value'] = $version;
}
else {
$requirements['yui']['severity'] = REQUIREMENT_ERROR;
$requirements['yui']['value'] = $t('Not found');
$requirements['yui']['description'] = $t('The <a href="@yui">Yahoo YUI Library</a> plugin is missing. <a href="@download">Download</a> and extract it into the <code>@directory</code> directory. Rename the extracted folder to <code>@library-folder</code>.', array(
'@yui' => 'http://yuilibrary.com/',
'@download' => 'http://yui.zenfs.com/releases/yui3/yui_3.5.1.zip',
'@directory' => 'sites/all/libraries',
'@library-folder' => 'yui')
);
}
return $requirements;
}
/**
* Implements hook_install().
*/
function yui_install() {
// Set the module's weight high so that it runs after other modules.
db_query("UPDATE {system} SET weight = 99 WHERE name = 'yui' and type = 'module'");
$path = variable_get('file_' . file_default_scheme() . '_path', conf_path() . '/files') . '/yui';
file_prepare_directory($path, FILE_CREATE_DIRECTORY);
}
/**
* Implements hook_uninstall().
*/
function yui_uninstall() {
$path = variable_get('file_' . file_default_scheme() . '_path', conf_path() . '/files') . '/yui';
if (file_prepare_directory($path)) {
$files = file_scan_directory($path, '/.*/');
foreach ($files as $file) {
drupal_unlink($file->filename);
}
rmdir($path);
}
}