function context_reaction_addassets_base::options_form in Context Add Assets 6
Same name and namespace in other branches
- 7 plugins/context_reaction_addassets_base.inc \context_reaction_addassets_base::options_form()
Prepare formatted form array showing grouped assets grouped by location and show as checkboxes
1 call to context_reaction_addassets_base::options_form()
- context_reaction_addassets_base::editor_form in plugins/
context_reaction_addassets_base.inc - Editor form.
File
- plugins/
context_reaction_addassets_base.inc, line 43 - The Context reaction plugin to add asset files
Class
- context_reaction_addassets_base
- Expose themes as context reactions.
Code
function options_form($context) {
$values = $this
->fetch_from_context($context);
$options = $this
->_context_addassets_search();
$options = !$options ? array() : $options;
$options_array = array();
foreach ($options as $key => $value) {
$path = $key;
$key = explode(' -- ', $value);
$value = $key[1];
$key = trim($key[0]);
$options_array[$key][$path] = $value;
}
$form['#tree'] = TRUE;
foreach ($options_array as $key => $items) {
$form[$key] = array(
'#type' => 'item',
'#title' => $key,
);
foreach ($items as $path => $file_name) {
$form[$key][$path] = array(
'#title' => $file_name,
'#type' => 'checkbox',
'#return_value' => $path,
'#default_value' => isset($values[$key][$path]) ? $values[$key][$path] : array(),
);
}
}
if (count($form) < 2) {
$link_options['query'] = drupal_get_destination();
$form['help'] = array(
'#type' => 'item',
'#title' => t('No Assets Found'),
'#description' => l('May you need to expand your search?', _context_addassets_admin_url(), $link_options),
);
}
return $form;
}