function libraries_cdn_ui_browser_submit in Libraries CDN API 7
File
- modules/
libraries_cdn_ui/ libraries_cdn_ui.admin.inc, line 280
Code
function libraries_cdn_ui_browser_submit($form, &$form_state) {
switch ($form_state['stage']) {
case 'step4':
$form_state['multistep_values'][$form_state['stage']] = $form_state['values'];
$form_state['complete'] = TRUE;
break;
default:
$form_state['multistep_values'][$form_state['stage']] = $form_state['values'];
$form_state['new_stage'] = libraries_cdn_ui_browser_next_stage($form, $form_state);
break;
}
if (isset($form_state['complete'])) {
$files = array_filter($form_state['values']['files'][$form_state['values']['version']]['files']);
// Build the operations array for the batch.
$operations = array();
foreach ($files as $id) {
$operations[] = array(
'_libraries_cdn_ui_download_files',
array(
$id,
),
);
}
$operations[] = array(
'_libraries_cdn_ui_build_variable',
array(
$files,
),
);
$batch = array(
'title' => t('Libraries CDN API: Downloading files'),
'operations' => $operations,
'init_message' => t('Initializing...'),
'progress_message' => t('Operation @current out of @total.'),
'error_message' => t('Found some error.'),
'file' => drupal_get_path('module', 'libraries_cdn_ui') . '/libraries_cdn_ui.admin.inc',
);
// Start the batch if there are files to download.
if (!empty($files)) {
batch_set($batch);
drupal_flush_all_caches();
}
return;
}
if ($form_state['triggering_element']['#value'] == 'Back') {
$form_state['new_stage'] = libraries_cdn_ui_browser_previous_stage($form, $form_state);
}
if (isset($form_state['multistep_values']['form_build_id'])) {
$form_state['values']['form_build_id'] = $form_state['multistep_values']['form_build_id'];
}
$form_state['multistep_values']['form_build_id'] = $form_state['values']['form_build_id'];
$form_state['stage'] = $form_state['new_stage'];
$form_state['rebuild'] = TRUE;
}