function _disclaimer_content_selection in Disclaimer 7
Build content selection part of settings form.
Return value
array An array of forms.
1 call to _disclaimer_content_selection()
- disclaimer_admin_settings in ./
disclaimer.admin.inc - Admin settings form for Disclaimer.
File
- ./
disclaimer.admin.inc, line 266 - Admin page callbacks for the Disclaimer module.
Code
function _disclaimer_content_selection($zone = 'content') {
$options = array();
$default = '';
// Get all view modes.
$entity_info = entity_get_info('node');
foreach ($entity_info['view modes'] as $key => $view_mode) {
$options[$key] = $view_mode['label'];
}
if ($zone == 'footer') {
$wrap = 'content_footer';
$key = 'disclaimer_footer_';
$title = t('Footer');
}
else {
$wrap = 'content';
$key = 'disclaimer_main_';
$title = t('Content');
}
// Build form.
$form[$wrap] = array(
'#type' => 'fieldset',
'#collapsible' => TRUE,
'#collapsed' => FALSE,
'#title' => $title,
);
$form[$wrap][$key . 'source'] = array(
'#type' => 'select',
'#title' => t('Content source'),
'#options' => array(
0 => t('Custom text'),
1 => t('Existing node'),
),
'#default_value' => variable_get($key . 'source', 0),
'#description' => t('You can select the source of this content, custom text or existing node.'),
);
// Get default node title.
if (variable_get($key . 'node', NULL)) {
$node = node_load(variable_get($key . 'node'));
if (isset($node->nid)) {
$default = $node->title . ' [' . $node->nid . ']';
}
}
$form[$wrap][$key . 'node'] = array(
'#type' => 'textfield',
'#description' => t('Type a title to search a node to use for this content.'),
'#title' => t('Node'),
'#maxlength' => 60,
'#autocomplete_path' => 'node/autocomplete',
'#default_value' => $default,
'#states' => array(
'visible' => array(
':input[name="' . $key . 'source"]' => array(
'value' => '1',
),
),
),
);
$form[$wrap][$key . 'node_view'] = array(
'#type' => 'select',
'#title' => t('View mode'),
'#description' => t('Choose node view mode to use for this node.'),
'#options' => $options,
'#default_value' => variable_get($key . 'node_view', 'full'),
'#states' => array(
'visible' => array(
':input[name="' . $key . 'source"]' => array(
'value' => '1',
),
),
),
);
$form[$wrap][$key . 'node_view_links'] = array(
'#type' => 'checkbox',
'#title' => t('Show links'),
'#default_value' => variable_get($key . 'node_view_links'),
'#states' => array(
'visible' => array(
':input[name="' . $key . 'source"]' => array(
'value' => '1',
),
),
),
);
$form[$wrap]['container'] = array(
'#type' => 'container',
'#states' => array(
'visible' => array(
':input[name="' . $key . 'source"]' => array(
'value' => '0',
),
),
),
);
$content = variable_get($key . 'content', array(
'value' => '',
));
$form[$wrap]['container'][$key . 'content'] = array(
'#type' => 'text_format',
'#default_value' => $content['value'],
'#format' => isset($content['format']) ? $content['format'] : NULL,
);
return $form;
}