function mediafront_preset_form in MediaFront 7.2
Same name and namespace in other branches
- 6.2 includes/mediafront.preset.inc \mediafront_preset_form()
- 6 includes/mediafront.preset.inc \mediafront_preset_form()
- 7 includes/mediafront.preset.inc \mediafront_preset_form()
1 string reference to 'mediafront_preset_form'
- mediafront_preset_menu in includes/
mediafront.preset.inc - Implement the menu system for the preset.
File
- includes/
mediafront.preset.inc, line 127
Code
function mediafront_preset_form($form, &$form_state, $preset) {
$form['preview'] = array(
'#type' => 'fieldset',
'#title' => t('Player Preview'),
'#attributes' => array(
'id' => 'mediafront_admin_preview',
),
'#weight' => -10,
);
// Set up the parameters for the player.
$preset = (array) $preset;
$params = array(
'admin' => true,
'player' => $preset['player'],
'preset' => $preset['name'],
);
$params = !empty($preset['settings']) ? array_merge($preset['settings'], $params) : $params;
$form['preview']['player'] = array(
'#type' => 'item',
'#markup' => mediafront_get_player($params),
);
// Get all of the settings for this player.
$preset['settings'] = mediafront_get_settings($preset['player'], $params);
// Store the preset in the form.
$form['#preset'] = $preset;
$form['settings'] = array(
'#type' => 'fieldset',
'#title' => t('Preset Settings'),
'#attributes' => array(
'id' => 'mediafront_admin_settings',
),
'#weight' => -9,
'#collapsible' => false,
'#collapsed' => false,
);
$form['settings']['preset'] = array(
'#type' => 'fieldset',
'#title' => t('Preset Information'),
'#weight' => -9,
'#collapsible' => true,
'#collapsed' => true,
);
if (isset($preset['pid'])) {
$form['settings']['preset']['pid'] = array(
'#type' => 'value',
'#value' => $preset['pid'],
);
}
$form['settings']['preset']['name'] = array(
'#type' => 'value',
'#value' => $preset['name'],
);
$form['settings']['preset']['description'] = array(
'#type' => 'textfield',
'#title' => t('Description'),
'#description' => t('Add a brief description to your preset name.'),
'#default_value' => $preset['description'],
'#weight' => -9,
);
$form['settings']['preset']['player'] = array(
'#type' => 'value',
'#value' => $preset['player'],
);
$form['settings']['player_settings_wrapper'] = array(
'#type' => 'fieldset',
'#title' => t('Player Settings'),
'#weight' => -8,
'#collapsible' => true,
'#collapsed' => true,
);
$form['settings']['player_settings_wrapper']['player_settings'] = array(
'#type' => 'vertical_tabs',
'#tree' => TRUE,
);
// Get the player settings.
$player_settings =& $form['settings']['player_settings_wrapper']['player_settings'];
// Now add the player settings form to this fieldset.
$player_settings = array_merge(mediafront_player_settings_form($preset), $player_settings);
// Add the player to player settings.
$form['settings']['connect'] = array(
'#type' => 'fieldset',
'#title' => t('Player to Player'),
'#collapsible' => true,
'#collapsed' => true,
);
$result = mediafront_preset_get_presets();
$presets = array(
0 => '-- None --',
);
foreach ($result as $pid => $otherPreset) {
if ($otherPreset['name'] != $preset['name']) {
$presets[$otherPreset['name']] = $otherPreset['name'];
}
}
if (isset($preset['connect']) && $preset['connect']) {
$form['settings']['connect']['iscontroller'] = array(
'#type' => 'select',
'#multiple' => TRUE,
'#title' => t('Make this preset the Control Bar for'),
'#description' => t('Select which preset you would like to control using this preset.'),
'#default_value' => !empty($preset['connect']['iscontroller']) ? $preset['connect']['iscontroller'] : 0,
'#options' => $presets,
);
$form['settings']['connect']['isplaylist'] = array(
'#type' => 'select',
'#multiple' => TRUE,
'#title' => t('Make this preset the Playlist for'),
'#description' => t('Select which preset you would like to play this playlist.'),
'#default_value' => !empty($preset['connect']['isplaylist']) ? $preset['connect']['isplaylist'] : 0,
'#options' => $presets,
);
}
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Save Preset'),
'#weight' => 30,
);
$form['delete'] = array(
'#type' => 'submit',
'#value' => t('Delete'),
'#weight' => 40,
'#submit' => array(
'mediafront_preset_delete_submit',
),
);
// Add the form submit handler.
$form['#submit'][] = 'mediafront_preset_submit';
$form['#validate'][] = 'mediafront_preset_validate';
return $form;
}