function smiley_form_alter in Smiley 6
Implementation of hook_form_alter().
File
- ./
smiley.module, line 67
Code
function smiley_form_alter(&$form, $form_state, $form_id) {
if ($form_id != 'comment_form' && !isset($form['#node'])) {
return;
}
if ($form_id == 'comment_form') {
$node_type = db_result(db_query('SELECT type FROM {node} WHERE nid=%d', $form['nid']['#value']));
}
else {
if (!empty($form['type']['#value'])) {
$node_type = $form['type']['#value'];
}
}
if (in_array($node_type, variable_get('smiley_node_types_content', array()), TRUE)) {
if (user_access('use smiley select box') && (isset($form['type']) && $form['type']['#value'] . '_node_form' == $form_id && variable_get('smiley_enable_for_nodes', 0) && isset($form['body_field']) || 'comment_form' == $form_id && variable_get('smiley_enable_for_comments', 0))) {
$output = '';
if (array_key_exists('body_field', $form)) {
$key = 'body_field';
}
elseif (array_key_exists('comment_filter', $form)) {
$key = 'comment_filter';
}
else {
$key = 'smiley_wrapper';
}
$collapsed = variable_get('smiley_select_box_expanded', TRUE) ? FALSE : TRUE;
$form[$key]['smiley'] = array(
'#type' => 'fieldset',
'#title' => t('Smileys'),
'#collapsible' => TRUE,
'#collapsed' => $collapsed,
'#weight' => 0,
'#prefix' => '<div class="smiley-box">',
'#suffix' => '</div>',
);
$form[$key]['smiley']['smiley_box'] = array(
'#type' => 'markup',
'#value' => theme('smiley_select_table', TRUE),
);
_smiley_add_files();
}
}
return $form;
}