function twitter_form_alter in Twitter 6.2
Implementation of hook_form_alter().
File
- ./
twitter.module, line 66
Code
function twitter_form_alter(&$form, $form_state, $form_id) {
// Alter any node forms.
if (isset($form['#node']) && $form['#node']->type . '_node_form' == $form_id) {
// If we haven't enabled Twitter posting on this node type, nothing to do
// here.
$type = $form['#node']->type;
$allowed_types = variable_get('twitter_types', array(
'story' => 'story',
'blog' => 'blog',
));
if (empty($allowed_types[$type])) {
return;
}
module_load_include('inc', 'twitter');
$twitter_form = twitter_form();
if (!$twitter_form) {
return;
}
$form['twitter'] = array(
'#type' => 'fieldset',
'#title' => t('Post to twitter.com'),
'#collapsible' => TRUE,
'#collapsed' => FALSE,
'#tree' => TRUE,
);
$form['twitter']['post'] = array(
'#type' => 'checkbox',
'#title' => t('Announce this post on Twitter'),
'#default_value' => empty($form['nid']['#value']),
'#id' => 'twitter-toggle',
);
$form['twitter'] += $twitter_form;
$form['twitter']['status']['#default_value'] = variable_get('twitter_default_format', 'New post: [title] [shorturl]');
$form['twitter']['status']['#description'] = t('The given text will be posted to twitter.com. You can use [url], [url-alias], [shorturl], [title] and [author-name] (as well as other tokens supplied by Token module) as placeholders.');
}
}