You are here

function biblio_admin_keyword_edit_form in Bibliography Module 6

Same name and namespace in other branches
  1. 6.2 includes/biblio.admin.inc \biblio_admin_keyword_edit_form()
  2. 7 includes/biblio.admin.inc \biblio_admin_keyword_edit_form()
  3. 7.2 includes/biblio.admin.inc \biblio_admin_keyword_edit_form()
1 string reference to 'biblio_admin_keyword_edit_form'
biblio_menu in ./biblio.module
Implementation of hook_menu().

File

./biblio.admin.inc, line 1952

Code

function biblio_admin_keyword_edit_form($form_state, $keyword_id) {
  $base = variable_get('biblio_base', 'biblio');
  $keyword = db_fetch_object(db_query('SELECT * FROM {biblio_keyword_data} bkd WHERE bkd.kid = %d ', $keyword_id));
  $base = variable_get('biblio_base', 'biblio');
  $path = strpos($_GET['q'], 'settings') ? 'admin/settings/biblio/keywords' : $base . '/keywords';
  $form['#redirect'] = $path;
  $form['kid'] = array(
    '#type' => 'value',
    '#value' => $keyword_id,
  );
  $form['word'] = array(
    '#type' => 'textfield',
    '#title' => t('Keyword'),
    '#default_value' => $keyword->word,
    '#size' => 100,
    '#weight' => -10,
    '#required' => TRUE,
    '#maxlength' => 255,
  );
  $keywords = db_query("SELECT * FROM {biblio_keyword_data} kd WHERE word LIKE '%%%s%%' AND kid!=%d", drupal_substr($keyword->word, 1, 5), $keyword_id);
  unset($options);
  $base = variable_get('biblio_base', 'biblio');
  while ($kw = db_fetch_object($keywords)) {
    $options[$kw->kid] = l($kw->word, $base . '/keywords/' . $kw->kid . '/edit/');
  }
  if ($options) {
    $form['merge'] = array(
      '#type' => 'fieldset',
      '#title' => t('Keyword Merge'),
      '#description' => t('Select other keywords which will be merged with the one above.  You should only do this if you are sure the other keywords represent the same keyword as the one being edited.'),
      '#weight' => 5,
      '#collapsible' => TRUE,
      '#collapsed' => TRUE,
    );
    $form['merge']['merge_keywords'] = array(
      '#type' => 'checkboxes',
      '#title' => t('Similar keywords'),
      '#options' => $options,
      '#weight' => 12,
      '#required' => FALSE,
      '#multiple' => TRUE,
      '#size' => min(count($options), 6),
    );
  }
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Save'),
  );
  $form['delete'] = array(
    '#value' => l(t('Delete'), $base . '/keyword/' . $keyword_id . '/delete'),
  );
  return $form;
}