function javascript_libraries_edit_form_submit in JavaScript Libraries Manager 7
Form submit for javascript_libraries_edit_form().
File
- ./
javascript_libraries.admin.inc, line 515 - Administrative management forms for JavaScript libraries.
Code
function javascript_libraries_edit_form_submit($form, &$form_state) {
switch ($form_state['values']['library_type']) {
case 'external':
if (empty($form['#library']['id'])) {
// New URL
$form['#library']['id'] = 'ext-' . db_next_id();
}
$custom = variable_get('javascript_libraries_custom_libraries', array());
if (strlen($form_state['values']['name']) == 0) {
$parts = explode('/', $form_state['values']['external_url']);
$form_state['values']['name'] = '... /' . end($parts);
}
$custom[$form['#library']['id']] = array(
'id' => $form['#library']['id'],
'type' => 'external',
'scope' => $form_state['values']['scope'],
'name' => $form_state['values']['name'],
'weight' => $form['#library']['weight'],
'uri' => $form_state['values']['external_url'],
'cache' => $form_state['values']['cache_external'],
);
variable_set('javascript_libraries_custom_libraries', $custom);
break;
case 'file':
_javascript_libraries_file_submit($form, $form_state);
// Change query-strings on css/js files to enforce reload for all users.
javascript_libraries_js_cache_clear();
break;
}
drupal_set_message('Your library has been added. Please configure the region and weight.');
$form_state['redirect'] = 'admin/config/system/javascript-libraries/custom';
}