function scald_admin_contexts_form in Scald: Media Management made easy 7
Same name and namespace in other branches
- 6 scald.admin.inc \scald_admin_contexts_form()
Form for admin settings for Scald Contexts.
1 string reference to 'scald_admin_contexts_form'
- scald_admin_contexts in includes/
scald.admin.inc - The Scald Admin page for Scald Contexts.
File
- includes/
scald.admin.inc, line 442
Code
function scald_admin_contexts_form($form, $form_state, $type) {
$form = array();
$contexts = scald_contexts();
$transcoders = scald_transcoders();
$players = scald_players();
$transcoder_options = array();
$player_options = array();
foreach ($transcoders as $tname => $transcoder) {
$transcoder_options[$tname] = $transcoder['title'];
}
foreach ($players as $player_name => $player) {
if (array_intersect($player['type'], array(
'*',
$type->type,
))) {
$player_options[$player_name] = $player['name'];
}
}
foreach ($contexts as $name => $context) {
// Only list visible contexts.
if (!empty($context['hidden'])) {
continue;
}
$default = !empty($contexts[$name]['type_format'][$type->type]['transcoder']) ? $contexts[$name]['type_format'][$type->type]['transcoder'] : NULL;
$form[$name] = array(
'#type' => 'fieldset',
'#title' => check_plain($context['title']),
'#description' => check_plain($context['description']) . '<br />' . t('Provided by <code>@module.module</code>.', array(
'@module' => $context['provider'],
)),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
$form[$name][$name . '_parse'] = array(
'#type' => 'checkbox',
'#title' => t('Make parseable.'),
'#default_value' => (bool) $context['parseable'],
'#disabled' => TRUE,
);
$form[$name][$name . '_trans'] = array(
'#type' => 'select',
'#title' => t('Transcoder'),
'#options' => $transcoder_options,
'#default_value' => $default,
);
$form[$name][$name . '_playe'] = array(
'#type' => 'select',
'#title' => t('Player'),
'#options' => $player_options,
'#default_value' => isset($context['player'][$type->type]) ? $context['player'][$type->type]['*'] : 'default',
'#ajax' => array(
'callback' => 'scald_admin_contexts_player_ajax',
'wrapper' => $name . '-player-settings',
),
);
$current_player = isset($form_state['values'][$name . '_playe']) ? $form_state['values'][$name . '_playe'] : $form[$name][$name . '_playe']['#default_value'];
$form[$name][$name . '_player_settings'] = array(
'#markup' => empty($players[$current_player]['settings']) ? '' : t('Configure the player <a href="@url">settings</a>.', array(
'@url' => url('admin/structure/scald/' . $type->type . '/player/' . $name . '/' . $current_player),
)),
'#prefix' => '<div id="' . $name . '-player-settings">',
'#suffix' => '</div>',
);
$context_config = scald_context_config_load($name);
$form[$name][$name . '_dimensions'] = array(
'#type' => 'fieldset',
'#title' => t('Dimensions'),
'#description' => t('Context width and height are used to hint the Scald rendering process to fit into the specified dimensions. While transcoder is about what to be displayed, the dimensions are about how large an atom is displayed. The unit could be omitted: "200px", "80%" or simply "150" etc.'),
);
$form[$name][$name . '_dimensions'][$name . '_width'] = array(
'#type' => 'textfield',
'#title' => t('Width'),
'#size' => 20,
'#default_value' => isset($context_config->data['width']) ? $context_config->data['width'] : '',
);
$form[$name][$name . '_dimensions'][$name . '_height'] = array(
'#type' => 'textfield',
'#title' => t('Height'),
'#size' => 20,
'#default_value' => isset($context_config->data['height']) ? $context_config->data['height'] : '',
);
}
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Save'),
);
return $form;
}