1
|
<?php
|
2
|
|
3
|
/**
|
4
|
* @file
|
5
|
* Sweaver install file.
|
6
|
*/
|
7
|
|
8
|
/**
|
9
|
* Implements hook_requirements().
|
10
|
*/
|
11
|
function sweaver_requirements($phase) {
|
12
|
$requirements = array();
|
13
|
// Ensure translations don't break at install time.
|
14
|
$t = get_t();
|
15
|
|
16
|
if ($phase == 'runtime' || $phase == 'install') {
|
17
|
$sweaver_directory = 'public://sweaver';
|
18
|
if (!file_prepare_directory($sweaver_directory, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS)) {
|
19
|
if (!is_dir($sweaver_directory)) {
|
20
|
$requirements['sweaver_directory'] = array(
|
21
|
'title' => $t('sweaver directory'),
|
22
|
'value' => $t('%p is not a directory or is not readable by the webserver.', array('%p' => $sweaver_directory)),
|
23
|
'severity' => REQUIREMENT_ERROR,
|
24
|
);
|
25
|
}
|
26
|
elseif (!is_writable($sweaver_directory)) {
|
27
|
$requirements['sweaver_directory'] = array(
|
28
|
'title' => $t('sweaver directory'),
|
29
|
'value' => $t('%p is not writeable by the webserver.', array('%p' => $sweaver_directory)),
|
30
|
'severity' => REQUIREMENT_ERROR,
|
31
|
);
|
32
|
}
|
33
|
else {
|
34
|
$requirements['sweaver_directory'] = array(
|
35
|
'title' => $t('sweaver directory'),
|
36
|
'value' => $t('An unknown error occured.'),
|
37
|
'description' => $t('An unknown error occured trying to verify %p is a directory and is writable.', array('%p' => $sweaver_directory)),
|
38
|
'severity' => REQUIREMENT_ERROR,
|
39
|
);
|
40
|
}
|
41
|
}
|
42
|
else {
|
43
|
$requirements['sweaver_directory'] = array(
|
44
|
'title' => t('sweaver directory'),
|
45
|
'severity' => REQUIREMENT_OK,
|
46
|
'value' => t('Exists'),
|
47
|
);
|
48
|
}
|
49
|
}
|
50
|
|
51
|
return $requirements;
|
52
|
}
|
53
|
|
54
|
function sweaver_update_7100()
|
55
|
{
|
56
|
variable_del('sweaver_plugin_status_sweaver_plugin_customcss');
|
57
|
variable_set('sweaver_plugin_status_sweaver_plugin_advanced', true);
|
58
|
}
|
59
|
|
60
|
function sweaver_update_7101()
|
61
|
{
|
62
|
$editor_form_configuration = array(
|
63
|
'one' => array(
|
64
|
'title' => t('Font'),
|
65
|
'properties' => array(
|
66
|
0 => 'font-family',
|
67
|
1 => 'font-properties-wrapper',
|
68
|
2 => 'vertical-align',
|
69
|
),
|
70
|
),
|
71
|
'two' => array(
|
72
|
'title' => t('Background'),
|
73
|
'properties' => array(
|
74
|
0 => 'background-color',
|
75
|
1 => 'background-image',
|
76
|
2 => 'background-repeat',
|
77
|
3 => 'background-attachment',
|
78
|
4 => 'background-position',
|
79
|
),
|
80
|
),
|
81
|
'three' => array(
|
82
|
'title' => t('Borders & Spacing'),
|
83
|
'properties' => array(
|
84
|
0 => 'position-settings',
|
85
|
1 => 'border-style',
|
86
|
2 => 'border-color',
|
87
|
3 => 'border-collapse',
|
88
|
4 => 'border-spacing',
|
89
|
),
|
90
|
),
|
91
|
'four' => array(
|
92
|
'title' => t('Other'),
|
93
|
'properties' => array(
|
94
|
0 => 'height',
|
95
|
1 => 'width',
|
96
|
),
|
97
|
),
|
98
|
);
|
99
|
variable_set('sweaver_editor_form_configuration', $editor_form_configuration);
|
100
|
}
|
101
|
|
102
|
/**
|
103
|
* Implements hook_install().
|
104
|
*/
|
105
|
function sweaver_install() {
|
106
|
|
107
|
// Alter the module weight to make sure we are the last one.
|
108
|
db_query("UPDATE {system} SET weight = 99 WHERE name = 'sweaver'");
|
109
|
|
110
|
// Set default editor configuration.
|
111
|
$editor_form_configuration = array(
|
112
|
'one' => array(
|
113
|
'title' => t('Font'),
|
114
|
'properties' => array(
|
115
|
0 => 'font-family',
|
116
|
1 => 'font-properties-wrapper',
|
117
|
2 => 'vertical-align',
|
118
|
),
|
119
|
),
|
120
|
'two' => array(
|
121
|
'title' => t('Background'),
|
122
|
'properties' => array(
|
123
|
0 => 'background-color',
|
124
|
1 => 'background-image',
|
125
|
2 => 'background-repeat',
|
126
|
3 => 'background-attachment',
|
127
|
4 => 'background-position',
|
128
|
),
|
129
|
),
|
130
|
'three' => array(
|
131
|
'title' => t('Borders & Spacing'),
|
132
|
'properties' => array(
|
133
|
0 => 'position-settings',
|
134
|
1 => 'border-style',
|
135
|
2 => 'border-color',
|
136
|
3 => 'border-collapse',
|
137
|
4 => 'border-spacing',
|
138
|
),
|
139
|
),
|
140
|
'four' => array(
|
141
|
'title' => t('Other'),
|
142
|
'properties' => array(
|
143
|
0 => 'height',
|
144
|
1 => 'width',
|
145
|
),
|
146
|
),
|
147
|
);
|
148
|
variable_set('sweaver_editor_form_configuration', $editor_form_configuration);
|
149
|
|
150
|
// Selector order.
|
151
|
$sweaver_selector_order = array(
|
152
|
'body' => -100,
|
153
|
'h1' => -99,
|
154
|
'h2' => -98,
|
155
|
'h3' => -97,
|
156
|
'li' => -96,
|
157
|
'link' => -95,
|
158
|
'ol' => -94,
|
159
|
'p' => -93,
|
160
|
'ul' => -92,
|
161
|
'form' => -91,
|
162
|
'label' => -90,
|
163
|
'input' => -89,
|
164
|
'textarea' => -88,
|
165
|
'submit' => -87,
|
166
|
'allids' => -86,
|
167
|
'allclasses' => -85,
|
168
|
'alltags' => -84,
|
169
|
'span' => -83,
|
170
|
'div' => -82,
|
171
|
);
|
172
|
variable_set('sweaver_selector_order', $sweaver_selector_order);
|
173
|
|
174
|
// Weights for plugins.
|
175
|
$plugins_weight = array(
|
176
|
'sweaver_plugin' => -51,
|
177
|
'sweaver_plugin_editor' => -49,
|
178
|
'sweaver_plugin_styles' => -48,
|
179
|
'sweaver_plugin_advanced' => -47,
|
180
|
'sweaver_plugin_palettes' => -46,
|
181
|
'sweaver_plugin_images' => -45,
|
182
|
'sweaver_plugin_themeswitch' => -44,
|
183
|
'sweaver_plugin_themesettings' => -43,
|
184
|
'sweaver_plugin_themeclasses' => -42,
|
185
|
'sweaver_plugin_fontface' => -41,
|
186
|
'sweaver_plugin_kb' => -39,
|
187
|
);
|
188
|
variable_set('sweaver_plugins_weight', $plugins_weight);
|
189
|
|
190
|
// Enable some plugins by default.
|
191
|
variable_set('sweaver_plugin_status_sweaver_plugin', TRUE);
|
192
|
variable_set('sweaver_plugin_status_sweaver_plugin_editor', TRUE);
|
193
|
variable_set('sweaver_plugin_status_sweaver_plugin_styles', TRUE);
|
194
|
variable_set('sweaver_plugin_status_sweaver_plugin_images', TRUE);
|
195
|
|
196
|
// Let images be handled by the images plugin.
|
197
|
variable_set('sweaver_plugin_handle_images', 'sweaver_plugin_images');
|
198
|
}
|
199
|
|
200
|
/**
|
201
|
* Implements hook_uninstall().
|
202
|
*/
|
203
|
function sweaver_uninstall() {
|
204
|
cache_clear_all('sweaver', 'cache');
|
205
|
cache_clear_all('plugins:sweaver:plugins', 'cache');
|
206
|
db_query("DELETE FROM {variable} WHERE name LIKE 'sweaver_%%'")->execute();
|
207
|
}
|
208
|
|
209
|
/**
|
210
|
* Implements hook_schema().
|
211
|
*/
|
212
|
function sweaver_schema() {
|
213
|
|
214
|
// Styles table.
|
215
|
$schema['sweaver_style'] = array(
|
216
|
'description' => t('Storage for the css array'),
|
217
|
'fields' => array(
|
218
|
'style_id' => array(
|
219
|
'description' => 'The primary identifier for a theme style. Linked to style_id from the draft table.',
|
220
|
'type' => 'int',
|
221
|
'unsigned' => TRUE,
|
222
|
'not null' => TRUE,
|
223
|
'default' => 0,
|
224
|
),
|
225
|
'theme' => array(
|
226
|
'description' => 'The theme name',
|
227
|
'type' => 'varchar',
|
228
|
'length' => 64,
|
229
|
'not null' => TRUE,
|
230
|
'default' => ''
|
231
|
),
|
232
|
'style' => array(
|
233
|
'description' => 'The style name',
|
234
|
'type' => 'varchar',
|
235
|
'length' => 64,
|
236
|
'not null' => TRUE,
|
237
|
'default' => ''
|
238
|
),
|
239
|
'css' => array(
|
240
|
'description' => 'The css object',
|
241
|
'type' => 'text',
|
242
|
'size' => 'big'
|
243
|
),
|
244
|
'customcss' => array(
|
245
|
'description' => 'Custom css',
|
246
|
'type' => 'text',
|
247
|
'size' => 'big'
|
248
|
),
|
249
|
'palette' => array(
|
250
|
'description' => 'Palette',
|
251
|
'type' => 'varchar',
|
252
|
'length' => 64,
|
253
|
'not null' => TRUE,
|
254
|
'default' => ''
|
255
|
),
|
256
|
'themesettings' => array(
|
257
|
'description' => 'Theme settings',
|
258
|
'type' => 'text',
|
259
|
'size' => 'big'
|
260
|
),
|
261
|
'active' => array(
|
262
|
'description' => 'Should this style be active?',
|
263
|
'type' => 'int',
|
264
|
'not null' => TRUE,
|
265
|
'default' => 0
|
266
|
),
|
267
|
),
|
268
|
'primary key' => array('style_id'),
|
269
|
);
|
270
|
|
271
|
// Styles draft table
|
272
|
$schema['sweaver_style_draft'] = array(
|
273
|
'description' => t('Storage for the css array'),
|
274
|
'fields' => array(
|
275
|
'style_id' => array(
|
276
|
'description' => 'The primary identifier for a theme style.',
|
277
|
'type' => 'serial',
|
278
|
'unsigned' => TRUE,
|
279
|
'not null' => TRUE
|
280
|
),
|
281
|
'theme' => array(
|
282
|
'description' => 'The theme name',
|
283
|
'type' => 'varchar',
|
284
|
'length' => 64,
|
285
|
'not null' => TRUE,
|
286
|
'default' => ''
|
287
|
),
|
288
|
'style' => array(
|
289
|
'description' => 'The style name',
|
290
|
'type' => 'varchar',
|
291
|
'length' => 64,
|
292
|
'not null' => TRUE,
|
293
|
'default' => ''
|
294
|
),
|
295
|
'css' => array(
|
296
|
'description' => 'The css object',
|
297
|
'type' => 'text',
|
298
|
'size' => 'big'
|
299
|
),
|
300
|
'customcss' => array(
|
301
|
'description' => 'Custom css',
|
302
|
'type' => 'text',
|
303
|
'size' => 'big'
|
304
|
),
|
305
|
'palette' => array(
|
306
|
'description' => 'Palette',
|
307
|
'type' => 'text',
|
308
|
'size' => 'big'
|
309
|
),
|
310
|
'themesettings' => array(
|
311
|
'description' => 'Theme settings',
|
312
|
'type' => 'text',
|
313
|
'size' => 'big'
|
314
|
),
|
315
|
),
|
316
|
'primary key' => array('style_id'),
|
317
|
);
|
318
|
|
319
|
// Images table.
|
320
|
$schema['sweaver_image'] = array(
|
321
|
'description' => t('Table storing images.'),
|
322
|
'fields' => array(
|
323
|
'fid' => array(
|
324
|
'type' => 'int',
|
325
|
'not null' => TRUE,
|
326
|
'description' => 'The image fid.',
|
327
|
'default' => 0,
|
328
|
),
|
329
|
'description' => array(
|
330
|
'type' => 'varchar',
|
331
|
'length' => '40',
|
332
|
'description' => 'A human readable name of the image.',
|
333
|
),
|
334
|
),
|
335
|
);
|
336
|
|
337
|
// Selector table width CTools support.
|
338
|
$schema['sweaver_selector'] = array(
|
339
|
'description' => t('Table storing selector definitions.'),
|
340
|
'export' => array(
|
341
|
'key' => 'name',
|
342
|
'identifier' => 'selector',
|
343
|
'default hook' => 'default_sweaver_selector',
|
344
|
'list callback' => 'sweaver_ctools_selectors_list',
|
345
|
'can disable' => TRUE,
|
346
|
'api' => array(
|
347
|
'owner' => 'sweaver',
|
348
|
'api' => 'sweaver',
|
349
|
'minimum_version' => 1,
|
350
|
'current_version' => 1,
|
351
|
),
|
352
|
),
|
353
|
'fields' => array(
|
354
|
'oid' => array(
|
355
|
'type' => 'serial',
|
356
|
'unsigned' => TRUE,
|
357
|
'not null' => TRUE,
|
358
|
'description' => 'Primary ID field for the table. Not used for anything except internal lookups.',
|
359
|
'no export' => TRUE,
|
360
|
),
|
361
|
'name' => array(
|
362
|
'type' => 'varchar',
|
363
|
'length' => '40',
|
364
|
'description' => 'Unique ID for selectors. Used to identify them programmatically.',
|
365
|
),
|
366
|
'description' => array(
|
367
|
'type' => 'varchar',
|
368
|
'length' => '60',
|
369
|
'description' => 'A human readable name of a selector.',
|
370
|
),
|
371
|
'selector_selector' => array(
|
372
|
'type' => 'varchar',
|
373
|
'length' => '120',
|
374
|
'description' => 'The identifier of the selector',
|
375
|
),
|
376
|
'selector_highlight' => array(
|
377
|
'type' => 'int',
|
378
|
'not null' => TRUE,
|
379
|
'default' => 0,
|
380
|
'size' => 'tiny',
|
381
|
'description' => 'Should this selector be highlighted by default',
|
382
|
),
|
383
|
),
|
384
|
'primary key' => array('oid'),
|
385
|
'unique keys' => array(
|
386
|
'name' => array('name'),
|
387
|
),
|
388
|
);
|
389
|
|
390
|
// Property table width CTools support.
|
391
|
$schema['sweaver_property'] = array(
|
392
|
'description' => t('Table storing property definitions.'),
|
393
|
'export' => array(
|
394
|
'key' => 'name',
|
395
|
'identifier' => 'property',
|
396
|
'default hook' => 'default_sweaver_property',
|
397
|
'list callback' => 'sweaver_ctools_properties_list',
|
398
|
'can disable' => TRUE,
|
399
|
'api' => array(
|
400
|
'owner' => 'sweaver',
|
401
|
'api' => 'sweaver',
|
402
|
'minimum_version' => 1,
|
403
|
'current_version' => 1,
|
404
|
),
|
405
|
),
|
406
|
'fields' => array(
|
407
|
'oid' => array(
|
408
|
'type' => 'serial',
|
409
|
'unsigned' => TRUE,
|
410
|
'not null' => TRUE,
|
411
|
'description' => 'Primary ID field for the table. Not used for anything except internal lookups.',
|
412
|
'no export' => TRUE,
|
413
|
),
|
414
|
'name' => array(
|
415
|
'type' => 'varchar',
|
416
|
'length' => '40',
|
417
|
'description' => 'Unique ID for properties. Used to identify them programmatically.',
|
418
|
),
|
419
|
'description' => array(
|
420
|
'type' => 'varchar',
|
421
|
'length' => '60',
|
422
|
'description' => 'A human readable name of a property.',
|
423
|
),
|
424
|
'property' => array(
|
425
|
'type' => 'varchar',
|
426
|
'length' => '255',
|
427
|
'description' => 'The css property. Seperate multiple values by spaces.',
|
428
|
),
|
429
|
'property_parent' => array(
|
430
|
'type' => 'varchar',
|
431
|
'length' => '40',
|
432
|
'description' => 'The parent of this property.',
|
433
|
),
|
434
|
'property_type' => array(
|
435
|
'type' => 'varchar',
|
436
|
'length' => '20',
|
437
|
'description' => 'Type of the property',
|
438
|
),
|
439
|
'property_prefix' => array(
|
440
|
'type' => 'varchar',
|
441
|
'length' => '20',
|
442
|
'description' => 'Prefix of the property',
|
443
|
),
|
444
|
'property_suffix' => array(
|
445
|
'type' => 'varchar',
|
446
|
'length' => '20',
|
447
|
'description' => 'Suffix of the property',
|
448
|
),
|
449
|
'property_slider_min' => array(
|
450
|
'type' => 'int',
|
451
|
'not null' => TRUE,
|
452
|
'default' => 1,
|
453
|
'description' => 'Minimum value for the slider',
|
454
|
),
|
455
|
'property_slider_max' => array(
|
456
|
'type' => 'int',
|
457
|
'not null' => TRUE,
|
458
|
'default' => 72,
|
459
|
'description' => 'Maximum value for the slider',
|
460
|
),
|
461
|
'property_options' => array(
|
462
|
'description' => 'Options for this property',
|
463
|
'type' => 'text',
|
464
|
'size' => 'big'
|
465
|
),
|
466
|
),
|
467
|
'primary key' => array('oid'),
|
468
|
'unique keys' => array(
|
469
|
'name' => array('name'),
|
470
|
),
|
471
|
);
|
472
|
|
473
|
// Type table width CTools support.
|
474
|
$schema['sweaver_type'] = array(
|
475
|
'description' => t('Table storing type definitions.'),
|
476
|
'export' => array(
|
477
|
'key' => 'name',
|
478
|
'identifier' => 'type',
|
479
|
'default hook' => 'default_sweaver_type',
|
480
|
'list callback' => 'sweaver_ctools_types_list',
|
481
|
'can disable' => TRUE,
|
482
|
'api' => array(
|
483
|
'owner' => 'sweaver',
|
484
|
'api' => 'sweaver',
|
485
|
'minimum_version' => 1,
|
486
|
'current_version' => 1,
|
487
|
),
|
488
|
),
|
489
|
'fields' => array(
|
490
|
'oid' => array(
|
491
|
'type' => 'serial',
|
492
|
'unsigned' => TRUE,
|
493
|
'not null' => TRUE,
|
494
|
'description' => 'Primary ID field for the table. Not used for anything except internal lookups.',
|
495
|
'no export' => TRUE,
|
496
|
),
|
497
|
'name' => array(
|
498
|
'type' => 'varchar',
|
499
|
'length' => '40',
|
500
|
'description' => 'Unique ID for types. Used to identify them programmatically.',
|
501
|
),
|
502
|
'description' => array(
|
503
|
'type' => 'varchar',
|
504
|
'length' => '60',
|
505
|
'description' => 'A human readable name of a type.',
|
506
|
),
|
507
|
'type_options' => array(
|
508
|
'description' => 'Options for this type',
|
509
|
'type' => 'text',
|
510
|
'size' => 'big'
|
511
|
),
|
512
|
),
|
513
|
'primary key' => array('oid'),
|
514
|
'unique keys' => array(
|
515
|
'name' => array('name'),
|
516
|
),
|
517
|
);
|
518
|
|
519
|
return $schema;
|
520
|
}
|