$type)));
// Get the available embedding themes
$themes = embed_get_info();
// Remap from an array keyed on theme to one keyed on type
$themes = embed_remap_info($themes);
// Filter to get only those themes for the specified type
$themes = $themes[$type];
// TODO : Need a function to sort these by title so it looks pretty
// Cross reference system.admin.inc | system_themes_form()
// Define the default theme setting
$info = array(
'title' => t('Embed'),
'description' => t('This is the default handler of the embed module and it is available for all objects.
It will embed the object using regular HTML. However, not all browers implement the
<object>
tag correctly it may not work in all cases, and the
results are likely to be inconsistent between different browsers.'),
'multiple values' => EMBED_HANDLE_CORE,
'resource' => '',
'resource available' => '',
'operations' => '',
);
// Put the default setting at the start of the array so it always comes first
$form[] = array(
'info' => array(
'#type' => 'value',
'#value' => $info,
),
);
// Put an entry in the options array ready for the radio buttons
$options[] = '';
// Build array of options ready for the selector
foreach ($themes AS $theme => $info) {
// Add defaults that might not be declared in hook_embed_info()
$info += array(
'description' => '',
'resource' => '',
'resource available' => '',
'download' => '',
'private' => FALSE,
'multiple values' => EMBED_HANDLE_CORE,
'operations' => '',
);
// Only list this theme if it isn't private
if (!$info['private']) {
// Pick an appropriate message about the status of any resources that are needed
$info['resource available'] = t('N/A');
// Check if a resource is needed
if ($info['resource']) {
// Assume the resource is available until it is discovered to be otherwise
$info['resource available'] = t('Available');
// Check if the resource is present and change status message accordingly
if (!file_exists($info['resource'])) {
$info['resource available'] = t('Missing');
}
}
// Put the array of information in to the form ready to be rendered
$form[$theme]['info'] = array(
'#type' => 'value',
'#value' => $info,
);
// Add an option for this theme
$options[$theme] = '';
}
}
// Put the option buttons on the form
$form["embed_$type"] = array(
'#type' => 'radios',
'#options' => $options,
'#default_value' => variable_get("embed_$type", 0),
);
// We need to store the type for the theme to use
$form['embed_type'] = array(
'#type' => 'hidden',
'#value' => $type,
);
// Add custom form handler so it triggers first
$form['#submit'][] = 'embed_admin_settings_submit';
// Add standard buttons and system settings submit handler
$form = system_settings_form($form);
// Over-ride the standard theme with the custom one needed to render the table
$form['#theme'] = 'embed_admin_settings';
// Return the form
return $form;
}
/**
* Theme callback for the embed_admin_settings form.
*
* @param $form
* An associative array containing the structure of the form.
*
* @see embed_admin_settings()
*/
function theme_embed_admin_settings($form) {
// Add swf API admin css to enable the error class in the table
drupal_add_css(drupal_get_path('module', 'embed') . '/embed.admin.css', 'module', 'all', FALSE);
// Get the type
$type = $form['embed_type']['#value'];
// Iterate over child elements of the form
foreach (element_children($form) as $key) {
// Only show elements that describe themes and are not configured as private
if (!isset($form[$key]['info']['#value']['title']) || !empty($form[$key]['info']['#value']['private'])) {
continue;
}
// Fetch info
$info = $form[$key]['info']['#value'];
// Build an appropriate shared file message and set a status icon
$resource = '';
$status_icon = 'misc/watchdog-ok.png';
$class = '';
if ($info['resource'] && ($info['resource available'] == t('Missing'))) {
$resource .= '