You are here

function fb_opengraph_form_alter in Drupal for Facebook 7.4

File

./fb_opengraph.module, line 239
Open Graph Helpers

Code

function fb_opengraph_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_opengraph'] = array(
      '#type' => 'fieldset',
      '#title' => t('Open Graph'),
      '#collapsible' => TRUE,
      '#collapsed' => TRUE,
    );
    $form['fb_opengraph']['fb_opengraph_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_opengraph_is_metadata_' . $vid, FALSE),
    );

    // @TODO add selector for application specific types.
    $form['#submit'][] = 'fb_opengraph_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_opengraph'] = array(
      '#type' => 'fieldset',
      '#group' => 'additional_settings',
      '#attributes' => array(
        'class' => array(
          'fb-node-type-settings-form',
        ),
      ),
      '#title' => t('Facebook Open Graph'),
      '#collapsible' => TRUE,
      '#collapsed' => TRUE,
    );
    $form['fb_opengraph'][FB_OPENGRAPH_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_opengraph_type_example.', array(
        '!url' => 'http://developers.facebook.com/docs/beta/opengraph/objects/builtin/',
        '%fb_opengraph_type_example' => 'article',
      )),
      '#default_value' => variable_get(FB_OPENGRAPH_VAR_OBJECT_TYPE . '_' . $type, ''),
    );
    $options = array(
      0 => t('<not a custom type>'),
    );
    foreach (fb_admin_all_apps() as $app) {
      $options[$app['fba']] = $app['title'];
    }
    $form['fb_opengraph'][FB_OPENGRAPH_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_OPENGRAPH_VAR_OBJECT_TYPE_APP . '_' . $type, 0),
    );
  }
}