function _vkxp_process_node_settings_form in VK CrossPoster 6.3
Same name and namespace in other branches
- 7.2 vkxp.forms.inc \_vkxp_process_node_settings_form()
Add vkxp settings to node settings form.
Parameters
$form: Node settings form.
1 call to _vkxp_process_node_settings_form()
- vkxp_form_node_type_form_alter in ./
vkxp.module - Implements hook_form_FORM_ID_alter(). Add module settings to the node settings form.
File
- ./
vkxp.forms.inc, line 14 - vkxp.forms.inc Contains node form alters.
Code
function _vkxp_process_node_settings_form(&$form) {
// Do not process node form if it do not contain node type.
if (empty($form['#node_type']->type)) {
return;
}
$node_type = $form['#node_type']->type;
$form['vkxp'] = array(
'#type' => 'fieldset',
'#title' => t('VKontakte CrossPoster settings'),
);
// Enable setting.
$form['vkxp']['vkxp_node_enabled'] = array(
'#type' => 'checkbox',
'#title' => t('Enable VKontakte CrossPoster'),
'#default_value' => variable_get('vkxp_node_enabled_' . $node_type, ''),
'#description' => t('Enable or disable crosspost for this node type.'),
);
// Enable default setting.
$form['vkxp']['vkxp_node_enabled_default'] = array(
'#type' => 'checkbox',
'#title' => t('Checkbox "Post this node to VK" are checked by default'),
'#default_value' => variable_get('vkxp_node_enabled_default_' . $node_type, ''),
'#description' => t('Check this if you want checkbox "Post this node to VK" in node forms was checked by default.'),
);
$info = _content_type_info();
// Get information about node fields.
// $fields_info = field_info_instances('node', $node_type);
// Collect all text and image fields.
$text_fields = array(
'title' => t('Title'),
'body' => t('Body'),
);
$image_fields = array(
0 => t('- None -'),
);
foreach ($info['content types'][$node_type]['fields'] as $field_name => $field_instance) {
if ($field_instance['module'] == 'text') {
$text_fields[$field_name] = $field_instance['widget']['label'] . ' (' . $field_name . ')';
}
elseif ($field_instance['widget']['module'] == 'imagefield') {
$image_fields[$field_name] = $field_instance['widget']['label'] . ' (' . $field_name . ')';
}
}
// Message.
$form['vkxp']['vkxp_body'] = array(
'#type' => 'fieldset',
'#title' => t('Message'),
);
// Message field.
$form['vkxp']['vkxp_body']['vkxp_node_message_field'] = array(
'#type' => 'select',
'#title' => t('Message source'),
'#description' => t('Select field from which to take the text to crosspost.'),
'#options' => $text_fields,
'#default_value' => variable_get('vkxp_node_message_field_' . $node_type, 'title'),
);
// Message length.
$form['vkxp']['vkxp_body']['vkxp_node_message_length'] = array(
'#type' => 'textfield',
'#title' => t('Cut message'),
'#field_prefix' => t('Cut message if it has more than'),
'#field_suffix' => t('symbols'),
'#size' => 4,
'#default_value' => variable_get('vkxp_node_message_length_' . $node_type, 255),
'#description' => t('Leave this field empty to not cut a message.'),
'#attributes' => array(
'style' => 'width:auto;',
),
);
// Image.
$form['vkxp']['vkxp_image'] = array(
'#type' => 'fieldset',
'#title' => t('Image'),
);
// Image source.
$form['vkxp']['vkxp_image']['vkxp_node_image_field'] = array(
'#type' => 'select',
'#title' => t('Image source'),
'#description' => t('Select field from which to take the image to crosspost.'),
'#options' => $image_fields,
'#default_value' => variable_get('vkxp_node_image_field_' . $node_type, 0),
);
// Image limit.
$form['vkxp']['vkxp_image']['vkxp_node_image_limit'] = array(
'#type' => 'select',
'#title' => t('Images limit'),
'#description' => t('Select maximum amount of images to crosspost.'),
'#options' => drupal_map_assoc(range(0, 10)),
'#default_value' => variable_get('vkxp_node_image_limit_' . $node_type, 0),
);
}