| 1 |
<?php
|
| 2 |
// $Id: media_settings.inc,v 1.3 2009/07/21 04:05:06 jmstacey Exp $
|
| 3 |
|
| 4 |
/**
|
| 5 |
* @file
|
| 6 |
* This file contains the admin functions for the Media module.
|
| 7 |
*/
|
| 8 |
|
| 9 |
/**
|
| 10 |
* Provide per content type settings.
|
| 11 |
*
|
| 12 |
* @param array &form
|
| 13 |
* A form structured array.
|
| 14 |
* @param string $type_name
|
| 15 |
* A string representing the content type.
|
| 16 |
* @return
|
| 17 |
* Nothing is returned.
|
| 18 |
*/
|
| 19 |
function media_settings_content_type(&$form, $type_name = NULL) {
|
| 20 |
$form['media'] = array(
|
| 21 |
'#type' => 'fieldset',
|
| 22 |
'#title' => t('Media settings'),
|
| 23 |
'#collapsible' => 'true',
|
| 24 |
'#collapsed' => 'true',
|
| 25 |
);
|
| 26 |
|
| 27 |
$type = _media_content_field_types($type_name);
|
| 28 |
|
| 29 |
// Master settings override.
|
| 30 |
$form['media']['media_'. $type_name .'_override'] = array(
|
| 31 |
'#title' => t($type["name"] .' overrides default values'),
|
| 32 |
'#type' => 'checkbox',
|
| 33 |
'#description' => t('Override the default settings for this content type. The options below will only be used if this box is checked.'),
|
| 34 |
'#default_value' => variable_get('media_'. $type_name .'_override', NULL),
|
| 35 |
);
|
| 36 |
$form['media']['media_'. $type_name .'_enabled'] = array(
|
| 37 |
'#title' => t('Enable Media resource browser'),
|
| 38 |
'#type' => 'checkbox',
|
| 39 |
'#description' => t('Enable the Media resource browser for this node type.'),
|
| 40 |
'#default_value' => variable_get('media_'. $type_name .'_enabled', NULL),
|
| 41 |
);
|
| 42 |
|
| 43 |
// Extract the fields for this node type
|
| 44 |
foreach ((array)$type['fields'] as $field_name => $field) {
|
| 45 |
// Create the field identifier
|
| 46 |
$form['media'][$field['field_name']] = array(
|
| 47 |
'#type' => 'fieldset',
|
| 48 |
'#title' => t('Field name: !name', array('!name' => $field['widget']['label'])),
|
| 49 |
'#collapsible' => 'true',
|
| 50 |
);
|
| 51 |
|
| 52 |
// Build a form for each type of module that we have
|
| 53 |
foreach (media_registration_kinds() as $kind) {
|
| 54 |
// Get all the kinds that match this field
|
| 55 |
if ($registrations = media_get_fields($field['type'], $kind)) {
|
| 56 |
$options = array();
|
| 57 |
|
| 58 |
foreach ($registrations as $id => $registration) {
|
| 59 |
$options[$field['field_name'] .'--'. $id] = $registration['name'] .': '. $registration['description'];
|
| 60 |
}
|
| 61 |
|
| 62 |
$form['media'][$field['field_name']]['media_'. $type_name .'_'. $field['field_name'] .'_'. $kind] = array(
|
| 63 |
'#title' => t('Enable !kind options for this field', array('!kind' => $kind)),
|
| 64 |
'#description' => t('Choose which !kind options you would like to have enabled on this field', array('!kind' => $kind)),
|
| 65 |
'#type' => 'checkboxes',
|
| 66 |
'#options' => $options,
|
| 67 |
'#default_value' => variable_get('media_'. $type_name .'_'. $field['field_name'] .'_'. $kind, array()),
|
| 68 |
);
|
| 69 |
}
|
| 70 |
}
|
| 71 |
|
| 72 |
// if we didn't get any additional data, remove this field form
|
| 73 |
// this is ugly but hey, sue me
|
| 74 |
if (count($form['media'][$field['field_name']]) == 3) {
|
| 75 |
unset($form['media'][$field['field_name']]);
|
| 76 |
}
|
| 77 |
}
|
| 78 |
}
|
| 79 |
|
| 80 |
/**
|
| 81 |
* Provide global settings.
|
| 82 |
*
|
| 83 |
* Global settings are currently just defaults for content types.
|
| 84 |
*
|
| 85 |
* @param $form
|
| 86 |
* A form structure.
|
| 87 |
* @return
|
| 88 |
* A form structured array.
|
| 89 |
*/
|
| 90 |
function media_settings_global($form) {
|
| 91 |
$settings_form = array();
|
| 92 |
|
| 93 |
$settings_form['media_global_enabled'] = array(
|
| 94 |
'#title' => t('Media resource browser'),
|
| 95 |
'#type' => 'checkbox',
|
| 96 |
'#description' => t('Enable or Disable the Media resource browser for all types, unless specifically set for a given type.'),
|
| 97 |
'#default_value' => variable_get('media_global_enabled', 1),
|
| 98 |
);
|
| 99 |
|
| 100 |
return system_settings_form($settings_form);
|
| 101 |
}
|