[ Index ]

PHP Cross Reference of Drupal 6 (yi-drupal)

title

Body

[close]

/sites/all/modules/data/data_taxonomy/ -> data_taxonomy.admin.inc (source)

   1  <?php
   2  /**
   3   * @file
   4   * Admin UI functionality.
   5   */
   6  
   7  /**
   8   * Form callback for relating a data table to a node.
   9   */
  10  function data_taxonomy_settings_form(&$form_state, $table) {
  11    drupal_set_title(check_plain($table->get('title')));
  12  
  13    $form = $vocabularies = array();
  14    foreach (taxonomy_get_vocabularies() as $v) {
  15      if (strpos($v->module, 'features_') === 0) {
  16        $vocabularies[filter_xss_admin($v->module)] = check_plain($v->name);
  17      }
  18      else {
  19        $vocabularies[$v->vid] = check_plain($v->name);
  20      }
  21    }
  22    $meta = $table->get('meta');
  23    $form['#table'] = $table;
  24    $form['vocabularies'] = array(
  25      '#type' => 'checkboxes',
  26      '#title' => t('Vocabularies'),
  27      '#options' => $vocabularies,
  28      '#default_value' => isset($meta['data_taxonomy']['vocabularies']) ? $meta['data_taxonomy']['vocabularies'] : array(),
  29      '#description' => t('Select the vocabulary to whose terms this data table\'s entries can be related to.'),
  30    );
  31    $schema = $table->get('table_schema');
  32    $fields = drupal_map_assoc(array_keys($schema['fields']));
  33    $form['id'] = array(
  34      '#type' => 'select',
  35      '#title' => t('Identifier'),
  36      '#options' => $fields,
  37      '#default_value' => $meta['data_taxonomy']['id'],
  38      '#description' => t('Select the identifier of the data table that should be related to terms.'),
  39    );
  40    $form['submit'] = array(
  41      '#type' => 'submit',
  42      '#value' => t('Save'),
  43    );
  44    return $form;
  45  }
  46  
  47  /**
  48   * Submit handler for data_node_settings_form().
  49   */
  50  function data_taxonomy_settings_form_submit($form, &$form_state) {
  51    $meta = $form['#table']->get('meta');
  52    $meta['data_taxonomy']['vocabularies'] = array_filter($form_state['values']['vocabularies']);
  53    $meta['data_taxonomy']['id'] = $form_state['values']['id'];
  54    $form['#table']->update(array('meta' => $meta));
  55    drupal_set_message(t('Settings saved.'));
  56  }


Generated: Mon Jul 9 18:01:44 2012 Cross-referenced by PHPXref 0.7