[ Index ]

PHP Cross Reference of Drupal 6 (yi-drupal)

title

Body

[close]

/sites/all/modules/data/data_node/ -> data_node.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_node_settings_form(&$form_state, $table) {
  11    drupal_set_title(check_plain($table->get('title')));
  12  
  13    $form = array();
  14    $content_types = array('' => t('None'));
  15    $content_types += node_get_types('names');
  16    $meta = $table->get('meta');
  17    $form['#table'] = $table;
  18    $form['content_type'] = array(
  19      '#type' => 'select',
  20      '#title' => t('Content type'),
  21      '#options' => $content_types,
  22      '#default_value' => $meta['data_node']['content_type'],
  23      '#description' => t('Select the content type this data table can be related to.'),
  24    );
  25    $schema = $table->get('table_schema');
  26    $fields = drupal_map_assoc(array_keys($schema['fields']));
  27    $form['id'] = array(
  28      '#type' => 'select',
  29      '#title' => t('Identifier'),
  30      '#options' => $fields,
  31      '#default_value' => $meta['data_node']['id'],
  32      '#description' => t('Select the identifier of the data table that should be related to a node.'),
  33    );
  34    $form['submit'] = array(
  35      '#type' => 'submit',
  36      '#value' => t('Save'),
  37    );
  38    return $form;
  39  }
  40  
  41  /**
  42   * Submit handler for data_node_settings_form().
  43   */
  44  function data_node_settings_form_submit($form, &$form_state) {
  45    $meta = $form['#table']->get('meta');
  46    $meta['data_node']['content_type'] = $form_state['values']['content_type'];
  47    $meta['data_node']['id'] = $form_state['values']['id'];
  48    $form['#table']->update(array('meta' => $meta));
  49    drupal_set_message(t('Settings saved.'));
  50  }


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