Commit d54c6788 authored by aaronwinborn's avatar aaronwinborn

* Begin to fix content type settings page (aaron).

parent 2d6b6494
......@@ -3,6 +3,7 @@
September 2009
-----------
* Move menu settings to media config (aaron).
* Begin to fix content type settings page (aaron).
July 2009
---------
......
......@@ -537,26 +537,30 @@ function media_create_id($drawer_name) {
* A form structured array is returned.
*/
function _media_content_field_types($type_name) {
if (module_exists('content')) {
// Use CCK if available
$type = content_types($type_name);
}
else {
// Get the specific content type.
$type = (array)node_get_types('type', $type_name);
}
// if (module_exists('content')) {
// // Use CCK if available
// $type = content_types($type_name);
// }
// else {
// // Get the specific content type.
// $type = (array)node_get_types('type', $type_name);
// }
$types = node_type_get_types();
$type = $types[$type_name]; // node_type_get_name($type_name);
// print_r($type);
// print_r(node_type_get_types());
// Recognize the upload/attachment form and create an artificial field.
// This should be the only one we ever have to do this for.
if (module_exists('upload')) {
$type['fields']['attachments'] = array(
'field_name' => 'attachments',
'type' => 'attachments',
'widget' => array(
'label' => $type['extra']['attachments']['label'],
),
);
}
// if (module_exists('upload')) {
// $type['fields']['attachments'] = array(
// 'field_name' => 'attachments',
// 'type' => 'attachments',
// 'widget' => array(
// 'label' => $type['extra']['attachments']['label'],
// ),
// );
// }
return $type;
}
......
......@@ -20,15 +20,15 @@ function media_settings_content_type(&$form, $type_name = NULL) {
$form['media'] = array(
'#type' => 'fieldset',
'#title' => t('Media settings'),
'#collapsible' => 'true',
'#collapsed' => 'true',
'#collapsible' => TRUE,
'#group' => 'additional_settings',
);
$type = _media_content_field_types($type_name);
// Master settings override.
$form['media']['media_'. $type_name .'_override'] = array(
'#title' => t($type["name"] .' overrides default values'),
'#title' => t($type->name .' overrides default values'),
'#type' => 'checkbox',
'#description' => t('Override the default settings for this content type. The options below will only be used if this box is checked.'),
'#default_value' => variable_get('media_'. $type_name .'_override', NULL),
......@@ -39,36 +39,38 @@ function media_settings_content_type(&$form, $type_name = NULL) {
'#description' => t('Enable the Media resource browser for this node type.'),
'#default_value' => variable_get('media_'. $type_name .'_enabled', NULL),
);
// Extract the fields for this node type
foreach ((array)$type['fields'] as $field_name => $field) {
// Create the field identifier
$form['media'][$field['field_name']] = array(
'#type' => 'fieldset',
'#title' => t('Field name: !name', array('!name' => $field['widget']['label'])),
'#collapsible' => 'true',
);
// Build a form for each type of module that we have
foreach (media_registration_kinds() as $kind) {
// Get all the kinds that match this field
if ($registrations = media_get_fields($field['type'], $kind)) {
$options = array();
foreach ($registrations as $id => $registration) {
$options[$field['field_name'] .'--'. $id] = $registration['name'] .': '. $registration['description'];
if (isset($type->fields)) {
foreach ((array)$type->fields as $field_name => $field) {
// Create the field identifier
$form['media'][$field['field_name']] = array(
'#type' => 'fieldset',
'#title' => t('Field name: !name', array('!name' => $field['widget']['label'])),
'#collapsible' => 'true',
);
// Build a form for each type of module that we have
foreach (media_registration_kinds() as $kind) {
// Get all the kinds that match this field
if ($registrations = media_get_fields($field['type'], $kind)) {
$options = array();
foreach ($registrations as $id => $registration) {
$options[$field['field_name'] .'--'. $id] = $registration['name'] .': '. $registration['description'];
}
$form['media'][$field['field_name']]['media_'. $type_name .'_'. $field['field_name'] .'_'. $kind] = array(
'#title' => t('Enable !kind options for this field', array('!kind' => $kind)),
'#description' => t('Choose which !kind options you would like to have enabled on this field', array('!kind' => $kind)),
'#type' => 'checkboxes',
'#options' => $options,
'#default_value' => variable_get('media_'. $type_name .'_'. $field['field_name'] .'_'. $kind, array()),
);
}
$form['media'][$field['field_name']]['media_'. $type_name .'_'. $field['field_name'] .'_'. $kind] = array(
'#title' => t('Enable !kind options for this field', array('!kind' => $kind)),
'#description' => t('Choose which !kind options you would like to have enabled on this field', array('!kind' => $kind)),
'#type' => 'checkboxes',
'#options' => $options,
'#default_value' => variable_get('media_'. $type_name .'_'. $field['field_name'] .'_'. $kind, array()),
);
}
}
// if we didn't get any additional data, remove this field form
// this is ugly but hey, sue me
if (count($form['media'][$field['field_name']]) == 3) {
......@@ -79,7 +81,7 @@ function media_settings_content_type(&$form, $type_name = NULL) {
/**
* Provide global settings.
*
*
* Global settings are currently just defaults for content types.
*
* @param $form
......@@ -89,7 +91,7 @@ function media_settings_content_type(&$form, $type_name = NULL) {
*/
function media_settings_global($form) {
$settings_form = array();
$settings_form['media_global_enabled'] = array(
'#title' => t('Media resource browser'),
'#type' => 'checkbox',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment