1 node.block.inc | NodeBlock::form(&$form, &$form_state) |
Builds the block's settings configuration form.
Overrides Block::form
File
- core/
modules/ node/ node.block.inc, line 120 - A class that displays a particular node in a block.
Class
- NodeBlock
- @file A class that displays a particular node in a block.
Code
function form(&$form, &$form_state) {
parent::form($form, $form_state);
$form['title_display']['title_display']['#options'][LAYOUT_TITLE_DEFAULT] = t('Use content title');
$form['title_display']['title_display']['#weight'] = -50;
$settings = $this->settings;
$form['link_node_title'] = array(
'#type' => 'checkbox',
'#default_value' => !empty($settings['link_node_title']),
'#title' => t('Link block title to full-page display of embedded content.'),
'#states' => array(
'invisible' => array(
':input[name="title_display"]' => array('value' => LAYOUT_TITLE_NONE),
),
),
);
$form['leave_node_title'] = array(
'#type' => 'checkbox',
'#default_value' => !empty($settings['leave_node_title']),
'#title' => t('Show the content title inside of the block.'),
'#states' => array(
'invisible' => array(
':input[name="title_display"]' => array('value' => LAYOUT_TITLE_DEFAULT),
),
),
);
$nid_default = '';
if (!empty($settings['nid'])) {
$title = db_query("SELECT title FROM {node} WHERE nid = :nid", array(':nid' => $settings['nid']))->fetchField();
$nid_default = $title . ' [' . $settings['nid'] . ']';
}
$form['nid'] = array(
'#title' => t('Content title or ID'),
'#type' => 'textfield',
'#maxlength' => 512,
'#default_value' => $nid_default,
'#autocomplete_path' => 'node/autocomplete',
);
$entity = entity_get_info('node');
$view_mode_options = array();
foreach ($entity['view modes'] as $mode => $option) {
$view_mode_options[$mode] = $option['label'];
}
// Remove view-modes that do not make sense for block display.
unset($view_mode_options['rss']);
unset($view_mode_options['search_index']);
unset($view_mode_options['search_result']);
$form['view_mode'] = array(
'#title' => t('Display mode'),
'#type' => 'select',
'#options' => $view_mode_options,
'#default_value' => isset($settings['view_mode']) ? $settings['view_mode'] : 'full',
);
$form['display_submitted'] = array(
'#type' => 'checkbox',
'#default_value' => !empty($settings['display_submitted']),
'#title' => t('Show author and date information'),
);
$form['links'] = array(
'#type' => 'checkbox',
'#default_value' => !empty($settings['links']),
'#title' => t('Include the links "add comment", "read more" etc.'),
);
if (module_exists('translation')) {
$form['translate'] = array(
'#type' => 'checkbox',
'#default_value' => !empty($settings['translate']),
'#title' => t('Load translated version of the content if available'),
);
}
}