function scald_admin_contexts_form_submit in Scald: Media Management made easy 7
Same name and namespace in other branches
- 6 scald.admin.inc \scald_admin_contexts_form_submit()
Submit handler for Scald Contexts admin settings form.
Updated values are written directly back to the database and then the Scald Configuration Object is rebuilt from the db.
File
- includes/
scald.admin.inc, line 547
Code
function scald_admin_contexts_form_submit($form, &$form_state) {
drupal_set_message(t('Context transcoders settings saved'));
$typename = $form_state['build_info']['args'][0]->type;
$players = scald_players();
$contexts = scald_contexts();
foreach ($form_state['values'] as $key => $value) {
$context = _scald_parse_machine_name($key);
$setting = substr($key, strlen($context) + 1);
if (!isset($contexts[$context])) {
continue;
}
switch ($setting) {
// Handle transcoders submission.
case 'trans':
$transcoder = $value;
$context_config = scald_context_config_load($context);
$context_config->transcoder[$typename]['*'] = $transcoder;
scald_context_config_save($context_config);
break;
// Handler players submission.
case 'playe':
$context_config = scald_context_config_load($context);
$context_config->player[$typename]['*'] = $value;
// Load and save default settings for the player.
if (empty($context_config->player[$typename]['settings']) && isset($players[$value]['settings'])) {
$context_config->player[$typename]['settings'] = $players[$value]['settings'];
}
scald_context_config_save($context_config);
break;
case 'width':
$context_config = scald_context_config_load($context);
$context_config->data['width'] = $form_state['values'][$context . '_width'];
$context_config->data['height'] = $form_state['values'][$context . '_height'];
scald_context_config_save($context_config);
break;
}
}
// The transcoders associated to the contexts might have change. In this case,
// all the output that we keep in the cache is invalid, which means that we'll
// need to regenerate it.
cache_clear_all('*', 'cache_scald', TRUE);
}