-
Notifications
You must be signed in to change notification settings - Fork 6
/
patterns.install
179 lines (166 loc) · 4.84 KB
/
patterns.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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
<?php
/**
* @file
* Installation file for Patterns.
*/
module_load_include('inc', 'patterns', 'includes/variables');
module_load_include('inc', 'patterns', 'includes/config');
module_load_include('inc', 'patterns', 'includes/path');
module_load_include('inc', 'patterns', 'includes/io');
/**
* Implements hook_install().
*/
function patterns_install() {
}
/**
* Implements hook_uninstall().
*/
function patterns_uninstall() {
$del = db_delete('variable')
->condition('name', 'patterns_%', 'LIKE')
->execute();
}
/**
* Implements hook_schema().
*/
function patterns_schema() {
$schema['patterns'] = array(
'description' => 'Stores patterns information.',
'fields' => array(
'pid' => array(
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
'description' => 'Primary Key: Unique pattern ID.',
),
'name' => array(
'type' => 'varchar',
'length' => 55,
'default' => '',
'description' => 'Machine readable name of this pattern.',
),
'format' => array(
'type' => 'varchar',
'length' => 10,
'default' => '',
'description' => 'Format of the patterns (XML, YAML, etc.).',
),
/*
* STATUSES:
*
* 0: installed, not enabled
* 1: installed, enabled
*
* -1: invalid
* -5: removed
*/
'status' => array(
'type' => 'int',
'size' => 'tiny',
'not null' => TRUE,
'default' => 0,
'description' => 'Boolean indicating whether the pattern has been executed (enabled).',
),
'public' => array(
'type' => 'int',
'size' => 'tiny',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
'description' => 'Boolean indicating whether the pattern is published (available for sharing via patterns server).',
),
'file' => array(
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
'description' => 'Path of the pattern file relative to Drupal root.',
),
'updated' => array(
'type' => 'varchar',
'length' => 10,
'not null' => TRUE,
'default' => '0',
'description' => 'The Unix timestamp indicating when the pattern file was last time updated (modified).',
),
'enabled' => array(
'type' => 'varchar',
'length' => 10,
'not null' => TRUE,
'default' => '0',
'description' => 'The Unix timestamp indicating when the pattern was last time executed.',
),
'title' => array(
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
'description' => 'Title of the pattern.',
),
'description' => array(
'type' => 'text',
'not null' => TRUE,
'description' => 'Description of the pattern.',
),
'pattern' => array(
'type' => 'text',
'size' => 'medium',
'not null' => TRUE,
'description' => 'A serialized array containing pattern code.',
)
),
'primary key' => array('pid'),
'unique keys' => array('name' => array('name'))
);
return $schema;
}
/**
* Add format field to {patterns} table.
*/
function patterns_update_7026() {
$spec = array(
'type' => 'varchar',
'length' => 10,
'default' => '',
'description' => 'Format of the patterns (XML, YAML, etc.).',
);
db_add_field('patterns', 'format', $spec);
}
/**
* Implements hook_requirements().
*
* @param string $phase The phase in which hook_requirements is run (install|runtime).
*/
function patterns_requirements($phase) {
$requirements = array();
// Checking if patterns directory is writable
// Must be done at installation and runtime
if (!_patterns_io_is_patterns_dir_ready()) {
$requirements['pdir'] = array(
'title' => t('Patterns files dir writable'),
'description' => t("Patterns folder doesn't exist or is not writable: !path", array('!path' => patterns_path_get_files_dir())),
'severity' => REQUIREMENT_WARNING,
'value' => t('Not writable'),
);
}
else {
$requirements['pdir'] = array(
'title' => t('Patterns files dir'),
'severity' => REQUIREMENT_OK,
'value' => t('Writable'),
);
}
switch ($phase) {
case 'runtime':
if (!ini_get('allow_url_fopen')) {
$requirements['allow_url_fopen'] = array(
'title' => t('Patterns import files from remote URL'),
'description' => t('To import patterns directly from remote URL \'allow_url_fopen\' must be enabled in your PHP configuration.'),
'severity' => REQUIREMENT_WARNING,
'value' => t('Disabled'),
);
}
break;
}
return $requirements;
}