You are here

function glossify_form_alter in Glossify 6.3

Same name and namespace in other branches
  1. 6 glossify.module \glossify_form_alter()

Implementation of hook_form_alter().

File

./glossify.module, line 125

Code

function glossify_form_alter(&$form, $form_state, $form_id) {
  if (isset($form['type']) && isset($form['#node']) && $form['type']['#value'] . '_node_form' == $form_id) {
    $configurations = variable_get('glossify_configurations', array());
    $use_internal = FALSE;
    foreach ($configurations as $configuration) {
      if ($configuration['methods']['use_internal'] && in_array($form['type']['#value'], $configuration['to'])) {
        $use_internal = TRUE;
      }
    }
    if ($use_internal) {
      $node = $form['#node'];
      $form['glossify'] = array(
        '#type' => 'fieldset',
        '#title' => t('Glossify'),
        '#collapsible' => TRUE,
        '#collapsed' => isset($node->glossify_keywords) && !empty($node->glossify_keywords) || isset($node->glossify_override) && !empty($node->glossify_override) ? FALSE : TRUE,
        '#weight' => 0,
      );
      $form['glossify']['glossify_keywords'] = array(
        '#type' => 'textfield',
        '#title' => t('Glossify Keywords'),
        '#default_value' => isset($node->glossify_keywords) ? $node->glossify_keywords : '',
        '#description' => t('You can add more than one keyword by seperating them with commas.'),
        '#weight' => 0,
      );
      $form['glossify']['glossify_override'] = array(
        '#type' => 'textfield',
        '#title' => t('Glossify Override'),
        '#default_value' => isset($node->glossify_override) ? $node->glossify_override : '',
        '#weight' => 1,
      );
    }
  }
}