Newer
Older
<?php
Addison Berry
committed
/**
* @file
* Install, update and uninstall functions for the css_injector module.
*
*/
/**
* Implements hook_install().
Addison Berry
committed
*/
function css_injector_install() {
}
Addison Berry
committed
/**
* Implements hook_schema().
Addison Berry
committed
*/
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
function css_injector_schema() {
$schema['css_injector_rule'] = array(
'fields' => array(
'crid' => array(
'description' => 'The primary identifier for the CSS injection rule',
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE),
'title' => array(
'description' => 'The descriptive title of the CSS injection rule',
'type' => 'varchar',
'length' => 255,
'not null' => TRUE),
'rule_type' => array(
'description' => 'The type of rule to use when determining if the CSS should be injected',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0),
'rule_conditions' => array(
'description' => 'The data to evaluate when determining if the CSS should be injected',
'type' => 'text',
'not null' => TRUE),
'media' => array(
'description' => 'The media type of the CSS file (screen, print, etc.)',
'type' => 'varchar',
'length' => 255,
'not null' => TRUE),
'preprocess' => array(
'description' => 'Whether the CSS file should be included by the CSS preprocessor',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0),
),
'primary key' => array('crid'),
);
return $schema;
}
Addison Berry
committed
/**
* Implements hook_uninstall().
Addison Berry
committed
*/
function css_injector_uninstall() {
cache_clear_all('css_injector:*', 'cache', TRUE);
$rules = db_query("SELECT * FROM {css_injector_rule}", array(), array('fetch' => PDO::FETCH_ASSOC))->fetchAllAssoc('crid');
Randy Fay
committed
foreach($rules as $crid => $rule) {
file_unmanaged_delete(_css_injector_rule_uri($crid));
}
db_drop_table('css_injector_rule');
Addison Berry
committed
}
/**
* Implements hook_requirements().
* We'll use this to prevent installation of the module if the file directory
* is not available and writable.
*/
function css_injector_requirements($phase) {
$status = REQUIREMENT_OK;
$dir = 'public://css_injector';
if (!file_prepare_directory($dir, FILE_MODIFY_PERMISSIONS)) {
if (!file_prepare_directory($dir, FILE_CREATE_DIRECTORY)) {
$status = REQUIREMENT_ERROR;
}
}
$requirements = array(
'css_injector' => array(
'title' => t('CSS Injector directory writable'),
'description' => $status == REQUIREMENT_OK ? t('CSS Injector Directory %dir is writable', array('%dir' => $dir)) : t('Directory %dir is not writable', array('%dir' => $dir)),
'severity' => $status,
'value' => t('Not writable'),
),
);
return $requirements;