-
Notifications
You must be signed in to change notification settings - Fork 74
/
wetkit.profile
340 lines (287 loc) · 10.7 KB
/
wetkit.profile
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
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
<?php
/**
* @file
* Bootstrap profile for installation of Drupal WxT.
*/
/**
* Implements hook_install_tasks().
*/
function wetkit_install_tasks(&$install_state) {
// Increase maximum function nesting level to prevent install errors.
$max_nesting_level = ini_get('xdebug.max_nesting_level');
if ($max_nesting_level > 0 && $max_nesting_level <= '200') {
ini_set('xdebug.max_nesting_level', 200);
}
// Hide some messages from various modules that are just too chatty.
drupal_get_messages('status');
drupal_get_messages('warning');
$tasks = array();
// Add the WetKit theme selection to the installation process.
require_once drupal_get_path('module', 'wetkit_theme') . '/wetkit_theme.profile.inc';
$tasks = $tasks + wetkit_theme_profile_theme_selection_install_task($install_state);
// Set up a task to include secondary language (fr).
$tasks['wetkit_batch_processing'] = array(
'display_name' => st('Import French Language'),
'type' => 'batch',
);
$tasks['wetkit_import_content'] = array(
'display_name' => st('Import Required Content'),
'type' => 'batch',
'display' => TRUE,
);
if (isset($install_state['parameters']['demo_content'])) {
$tasks['wetkit_import_demo_content'] = array(
'display_name' => st('Import Demo Content'),
'type' => 'batch',
'display' => $install_state['parameters']['demo_content'] == 1,
'run' => $install_state['parameters']['demo_content'] == 1 ? INSTALL_TASK_RUN_IF_NOT_COMPLETED : INSTALL_TASK_SKIP,
);
}
return $tasks;
}
/**
* Implements hook_install_tasks_alter().
*/
function wetkit_install_tasks_alter(&$tasks, $install_state) {
$tasks['install_select_profile']['display'] = FALSE;
$tasks['install_select_locale']['display'] = FALSE;
// Hide some messages from various modules that are just too chatty.
drupal_get_messages('status');
drupal_get_messages('warning');
// The "Welcome" screen needs to come after the first two steps
// (profile and language selection), despite the fact that they are disabled.
$new_task['wetkit_install_welcome'] = array(
'display' => TRUE,
'display_name' => st('Welcome'),
'type' => 'form',
'run' => isset($install_state['parameters']['welcome']) ? INSTALL_TASK_SKIP : INSTALL_TASK_RUN_IF_REACHED,
);
$old_tasks = $tasks;
$tasks = array_slice($old_tasks, 0, 2) + $new_task + array_slice($old_tasks, 2);
_wetkit_set_theme('wetkit_shiny');
// If using French Locale as default remove associated Install Task.
unset($tasks['install_import_locales']);
unset($tasks['install_import_locales_remaining']);
// Magically go one level deeper in solving years of dependency problems.
require_once drupal_get_path('module', 'wetkit_core') . '/wetkit_core.profile.inc';
$tasks['install_load_profile']['function'] = 'wetkit_core_install_load_profile';
}
/**
* Force-set a theme at any point during the execution of the request.
*
* Drupal doesn't give us the option to set the theme during the installation
* process and forces enable the maintenance theme too early in the request
* for us to modify it in a clean way.
*/
function _wetkit_set_theme($target_theme) {
if ($GLOBALS['theme'] != $target_theme) {
unset($GLOBALS['theme']);
drupal_static_reset();
$GLOBALS['conf']['maintenance_theme'] = $target_theme;
_drupal_maintenance_theme();
}
}
/**
* Task callback: shows the welcome screen.
*/
function wetkit_install_welcome($form, &$form_state, &$install_state) {
drupal_set_title(st('Welcome'));
$message = st('Thank you for choosing the Web Experience Toolkit Drupal Distribution!') . '<br />';
$message .= '<p>' . st('This distribution installs Drupal with
preconfigured features that will help you meet Enterprise Standards.') . '</p>';
$message .= '<p>' . st('Please note that this is a community-supported work in progress,
so be sure to join us over on ' . l(t('github.com/wet-boew/wet-boew-drupal'), 'http://github.com/wet-boew/wet-boew-drupal') .
' and help us improve this product.') . '</p>';
$form = array();
$form['welcome_message'] = array(
'#markup' => $message,
);
$form['actions'] = array(
'#type' => 'actions',
);
$form['actions']['submit'] = array(
'#type' => 'submit',
'#value' => st("Let's Get Started!"),
'#weight' => 10,
);
return $form;
}
/**
* Task callback: Welcome screen submit.
*/
function wetkit_install_welcome_submit($form, &$form_state) {
global $install_state;
$install_state['parameters']['welcome'] = 'done';
}
/**
* Implements hook_form_FORM_ID_alter().
*/
function wetkit_form_install_configure_form_alter(&$form, $form_state) {
// Hide some messages from various modules that are just too chatty.
drupal_get_messages('status');
drupal_get_messages('warning');
// Set reasonable defaults for site configuration form.
$form['site_information']['site_name']['#default_value'] = 'Web Experience Toolkit';
$form['admin_account']['account']['name']['#default_value'] = 'admin';
$form['server_settings']['site_default_country']['#default_value'] = 'CA';
$form['server_settings']['date_default_timezone']['#default_value'] = 'America/New_York';
// Define a default email address if we can guess a valid one.
if (valid_email_address('admin@' . $_SERVER['HTTP_HOST'])) {
$form['site_information']['site_mail']['#default_value'] = 'admin@' . $_SERVER['HTTP_HOST'];
$form['admin_account']['account']['mail']['#default_value'] = 'admin@' . $_SERVER['HTTP_HOST'];
}
$form['wetkit_settings'] = array(
'#type' => 'fieldset',
'#title' => st('WXT Settings'),
);
$form['wetkit_settings']['demo_content'] = array(
'#title' => st('Import Demo Content'),
'#description' => st('Whether demo content should imported.'),
'#type' => 'checkbox',
'#default_value' => drupal_is_cli() ? FALSE : TRUE,
);
array_push($form['#submit'], 'wetkit_import_demo_content_form_submit');
}
/**
* Batch Processing for French Language import.
*/
function wetkit_batch_processing(&$install_state) {
// Import the additonal language po file and translate the interface.
// Require once is only added here because too early in the bootstrap.
require_once 'includes/locale.inc';
require_once 'includes/form.inc';
// Batch up the process + import existing po files.
$batch = locale_batch_by_language('fr');
return $batch;
}
/**
* Task callback: return a batch API array with the products to be imported.
*/
function wetkit_import_content() {
// Run Mega Menu migration.
$operations[] = array('_wetkit_import', array(
'WetKitMigrateMegaMenu',
t('Importing content.'),
));
// Page Manager Fix.
$operations[] = array('_wetkit_panels_fix', array(
t('Fix Page Manager dependency chain issue.'),
));
// Permissions Fix.
$operations[] = array('_wetkit_permissions_fix', array(
t('Fix Permissions for Administrator Role.'),
));
$batch = array(
'title' => t('Importing content'),
'operations' => $operations,
'file' => drupal_get_path('profile', 'wetkit') . '/wetkit.install_callbacks.inc',
);
return $batch;
}
/**
* Form submit callback: Demo content form submit callback.
*/
function wetkit_import_demo_content_form_submit($form, &$form_state) {
global $install_state;
$install_state['parameters']['demo_content'] = $form_state['values']['demo_content'];
}
/**
* Task callback: return a batch API array with the products to be imported.
*/
function wetkit_import_demo_content() {
// Fixes problems when the CSV files used for importing have been created
// on a Mac, by forcing PHP to detect the appropriate line endings.
ini_set("auto_detect_line_endings", TRUE);
// Run Beans migration.
$operations[] = array('_wetkit_import', array(
'WetKitMigrateTaxonomy',
t('Importing taxonomy.'),
));
// Run Beans migration.
$operations[] = array('_wetkit_import', array(
'WetKitMigrateBean',
t('Importing Bean content.'),
));
// Run Beans migration.
$operations[] = array('_wetkit_import', array(
'WetKitMigrateBeanSlideOut',
t('Importing Bean Slideout.'),
));
// Run Beans migration.
$operations[] = array('_wetkit_import', array(
'WetKitMigrateBeanSlideShow',
t('Importing Beans Slideshow.'),
));
// Run Files migration.
$operations[] = array('_wetkit_import', array(
'WetKitMigrateFileBeanSlideShow',
t('Importing File Bean Slideshow.'),
));
// Run Files migration.
$operations[] = array('_wetkit_import', array(
'WetKitMigrateFldCollectionSlides',
t('Importing Field Collection Slides.'),
));
// Run Default Content Media migration.
$operations[] = array('_wetkit_import', array(
'WetKitMigrateDefaultContentMedia',
t('Importing Default Content Media.'),
));
// Run Default Content migration.
$operations[] = array('_wetkit_import', array(
'WetKitMigrateDefaultContent',
t('Importing Default Content.'),
));
// Run Site Menu migration.
$operations[] = array('_wetkit_import', array(
'WetKitMigrateSiteMenu',
t('Importing Site Menu.'),
));
// Run Site Menu Links migration.
$operations[] = array('_wetkit_import', array(
'WetKitMigrateSiteMenuLinks',
t('Importing Site Menu Links.'),
));
// Run Mega Menu Links migration.
$operations[] = array('_wetkit_import', array(
'WetKitMigrateMegaMenuLinks',
t('Importing Mega Menu Links.'),
));
// Enable WetKit Demo.
$operations[] = array('module_enable', array(
array('wetkit_demo'),
t('Enabling WetKit Demo module.'),
));
$batch = array(
'title' => t('Importing demo content'),
'operations' => $operations,
'file' => drupal_get_path('profile', 'wetkit') . '/wetkit.install_callbacks.inc',
);
return $batch;
}
/**
* Implements hook_form_FORM_ID_alter().
*/
function wetkit_form_apps_profile_apps_select_form_alter(&$form, $form_state) {
// Hide some messages from various modules.
drupal_get_messages('status');
drupal_get_messages('warning');
// For some things there are no need.
$form['apps_message']['#access'] = FALSE;
$form['apps_fieldset']['apps']['#title'] = NULL;
// Improve style of apps selection form.
if (isset($form['apps_fieldset'])) {
$manifest = apps_manifest(apps_servers('wetkit'));
foreach ($manifest['apps'] as $name => $app) {
if ($name != '#theme') {
$form['apps_fieldset']['apps']['#options'][$name] = '<strong>' . $app['name'] . '</strong><p><div class="admin-options"><div class="form-item">' . theme('image', array(
'path' => $app['logo']['path'],
'height' => '32', 'width' => '32',
)) . '</div>' . $app['description'] . '</div></p>';
}
}
}
// Remove the demo content selection option since this is handled through the
// WetKit demo module.
$form['default_content_fieldset']['#access'] = FALSE;
}