You are here

function fb_graph_form_alter in Drupal for Facebook 6.3

Same name and namespace in other branches
  1. 7.3 fb_graph.module \fb_graph_form_alter()

File

./fb_graph.module, line 220
Open Graph Helpers

Code

function fb_graph_form_alter(&$form, &$form_state, $form_id) {
  if ($form_id == 'taxonomy_form_vocabulary') {
    $vid = 0;
    if (isset($form['vid'])) {
      $vid = $form['vid']['#value'];
    }
    $form['fb_graph'] = array(
      '#type' => 'fieldset',
      '#title' => t('Open Graph'),
      '#collapsible' => TRUE,
      '#collapsed' => TRUE,
    );
    $form['fb_graph']['fb_graph_is_metadata'] = array(
      '#title' => t('Treat tags as metadata'),
      '#description' => t('Render terms as HTML header metadata.  The name of the vocabulary becomes the property, and terms become the content.  For example a vocabulary named "og:type" would have terms "article", "blog", etc...', array(
        '!url' => 'http://developers.facebook.com/docs/beta/opengraph/objects/builtin/',
      )),
      '#type' => 'checkbox',
      '#default_value' => variable_get('fb_graph_is_metadata_' . $vid, FALSE),
    );

    // @TODO add selector for application specific types.
    $form['#submit'][] = 'fb_graph_taxonomy_form_vocabulary_submit';

    // Weights on taxonomy form are screwed up.
    if (!isset($form['submit']['#weight'])) {
      $form['submit']['#weight'] = 98;
      $form['delete']['#weight'] = 99;
    }
  }
  if ($form_id == 'node_type_form') {
    $type = $form['#node_type']->type;

    // Allow administrator to configure which Object types this content type represents.
    include drupal_get_path('module', 'fb') . '/fb.admin.inc';
    $form['fb_graph'] = array(
      '#type' => 'fieldset',
      '#title' => t('Open Graph'),
      '#collapsible' => TRUE,
      '#collapsed' => TRUE,
    );
    $form['fb_graph'][FB_GRAPH_VAR_OBJECT_TYPE] = array(
      '#type' => 'textfield',
      '#title' => t('Object Type'),
      '#description' => t('Which <a href=!url target=_blank>object type</a> does this content type represent? For example, %fb_graph_type_example.', array(
        '!url' => 'http://developers.facebook.com/docs/beta/opengraph/objects/builtin/',
        '%fb_graph_type_example' => 'article',
      )),
      '#default_value' => variable_get(FB_GRAPH_VAR_OBJECT_TYPE . '_' . $type, ''),
    );
    $options = array(
      0 => t('<not a custom type>'),
    ) + fb_admin_get_app_options();
    $form['fb_graph'][FB_GRAPH_VAR_OBJECT_TYPE_APP] = array(
      '#type' => 'select',
      '#title' => t('Custom Object Type'),
      '#description' => t('If the object type is custom, as opposed to <a href=!url target=_blank>built in</a>, which application is it associated with?', array(
        '!url' => 'http://developers.facebook.com/docs/beta/opengraph/objects/builtin/',
      )),
      '#options' => $options,
      '#default_value' => variable_get(FB_GRAPH_VAR_OBJECT_TYPE_APP . '_' . $type, 0),
    );
  }
}