You are here

function nodewords_form in Nodewords: D6 Meta Tags 6

Return the form used to set the meta tags values.

Parameters

$type: The object to which the meta tags are associated (node, user, taxonomy term, etc...).

$tags: The meta tags array as returned by nodewords_load_tags().

Return value

An array as requested by the form API.

6 calls to nodewords_form()
nodewords_custom_pages_edit in ./nodewords.admin.inc
Edit form for custom pages.
nodewords_form_alter in ./nodewords.module
Implements hook_form_alter().
nodewords_form_taxonomy_form_term_alter in ./nodewords.module
Implements hook_form_FORM_ID_alter().
nodewords_form_taxonomy_form_vocabulary_alter in ./nodewords.module
Implements hook_form_FORM_ID_alter().
nodewords_tags_form in ./nodewords.admin.inc
Front page settings form.

... See full list

File

./nodewords.module, line 761
Implement an API that other modules can use to implement meta tags.

Code

function nodewords_form($type, $tags, $options = array()) {
  $default_options = array(
    'fieldset' => TRUE,
    'fieldset:title' => t('Meta tags'),
    'fieldset:weight' => 20,
  );
  $default_tag_options = array(
    'default' => nodewords_load_tags(),
    'type' => $type,
  );
  $edit_tags = variable_get('nodewords_edit', array());
  $form = array();
  $options += $default_options;
  if (isset($options['tag_options']) && is_array($options['tag_options'])) {
    $tag_options = $options['tag_options'] + $default_tag_options;
  }
  else {
    $tag_options = $default_tag_options;
  }
  $tags_info = nodewords_get_possible_tags();
  foreach ($tags_info as $name => $info) {
    $bool = user_access('administer meta tags') || !empty($edit_tags[$name]);
    if ($bool) {
      $bool = !empty($info['context']['allowed']) && is_array($info['context']['allowed']) && !in_array($type, $info['context']['allowed']) || !empty($info['context']['denied']) && is_array($info['context']['denied']) && in_array($type, $info['context']['denied']);
      if ($bool) {
        continue;
      }
      $bool = user_access('administer meta tags') || !empty($info['permission']) && user_access($info['permission']);
      if ($bool) {
        if (function_exists($function = $info['callback'] . '_form')) {
          $function($form, isset($tags[$name]) ? $tags[$name] : array(), $tag_options);
        }
      }
    }
  }
  if (!empty($form) && $options['fieldset']) {
    $form['#type'] = 'fieldset';
    $form['#title'] = $options['fieldset:title'];
    $form['#tree'] = TRUE;
    $form['#collapsible'] = TRUE;
    $form['#collapsed'] = TRUE;
    $form['#weight'] = $options['fieldset:weight'];
    $form['#group'] = 'additional_settings';
  }
  return $form;
}