You are here

function nodewords_edit in Nodewords: D6 Meta Tags 6.2

Edit the basics of a meta tag.

Parameters

$tag: Object. The meta tag to edit. If NULL a new meta tag will be created.

1 call to nodewords_edit()
nodewords_add in ./nodewords.admin.inc
Create a new meta tag.
5 string references to 'nodewords_edit'
nodewords_admin_install in nodewords_admin/nodewords_admin.install
Implements hook_install().
nodewords_ui_install in nodewords_ui/nodewords_ui.install
Implements hook_install().
nodewords_ui_update_6102 in nodewords_ui/nodewords_ui.install
Implements hook_update_N().
nodewords_update_6100 in ./nodewords.install
Implements hook_update_N().
nodewords_update_6104 in ./nodewords.install
Implements hook_update_N().

File

./nodewords.admin.inc, line 58
Administration forms.

Code

function nodewords_edit(&$form_state, $tag = NULL) {
  $form = array();
  if (isset($tag->tagid)) {
    drupal_set_title(t('Edit %tag_name meta tag', array(
      '%tag_name' => $tag->name,
    )));
    $form['tagid'] = array(
      '#type' => 'value',
      '#value' => $tag->tagid,
    );
  }
  else {
    drupal_set_title(t('Create new meta tag'));
  }
  $form['name'] = array(
    '#type' => 'textfield',
    '#title' => t('Name'),
    '#required' => TRUE,
    '#description' => t('The name of the meta tag.'),
    '#default_value' => $tag->name,
  );
  $form['description'] = array(
    '#type' => 'textfield',
    '#title' => t('Description'),
    '#description' => t('Short description for administrators.'),
    '#default_value' => $tag->description,
  );
  $types = _nodewords_types();
  $titles = array();
  $descriptions = array();
  foreach ($types as $key => $value) {
    $titles[$key] = $value['title'];
    if (isset($value['description'])) {
      $descriptions[$value['title']] = $value['description'];
    }
  }
  $description = t('<p>Select one of the available meta tag types.</p>');
  if (count($descriptions)) {
    $description .= theme('nodewords_descriptions', $descriptions);
  }
  $form['type'] = array(
    '#type' => 'radios',
    '#title' => t('Type'),
    '#description' => $description,
    '#default_value' => $tag->type,
    '#options' => $titles,
    '#required' => TRUE,
  );
  $form['options'] = array(
    '#type' => 'fieldset',
    '#title' => t('Content construction'),
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
    '#tree' => TRUE,
  );
  $form['options']['use-all'] = array(
    '#type' => 'checkbox',
    '#title' => t('Use all inheritted values'),
    '#description' => t('The normal way of handling different context defaults is that the more specific context default overrides the broader one. For some meta tags (such as <code>keywords</code>) it is more useful to use all defaults from all broader contexts. Checking this option will use the user-inputted value and all context default values as values for this meta tag. If unsure, unselect this option.'),
    '#default_value' => isset($tag->options['use-all']) ? $tag->options['use-all'] : FALSE,
  );
  $form['options']['allow-empty'] = array(
    '#type' => 'checkbox',
    '#title' => t('Allow empty value'),
    '#description' => t('If a meta tag value is empty, normally there is no use of outputting the meta tag. Check this option if you want to output an empty-valued meta tag.'),
    '#default_value' => isset($tag->options['allow-empty']) ? $tag->options['allow-empty'] : FALSE,
  );
  $form['options']['unique-list'] = array(
    '#type' => 'checkbox',
    '#title' => t('Suppress duplicate values'),
    '#description' => t('Normally there is no use of outputting the same value of a meta tag multiple times. For meta tags as <code>keywords</code> or <code>DC.Subject</code> this is even discouraged as it may lower your SEO ranking. Checking this option will remove duplicate values for this meta tag. If unsure, select this option.'),
    '#default_value' => isset($tag->options['unique-list']) ? $tag->options['unique-list'] : TRUE,
  );
  $form['options']['combine-values'] = array(
    '#type' => 'checkbox',
    '#title' => t('Combine multiple values'),
    '#description' => t('If a meta tag has multiple values, either by checking the option above or when the widget supports multiple values, one meta tag is outputted for each value. For some meta tags (such as <code>keywords</code>) it is more usefull to combine all those values into one single value. Checking this option will combine all inputted or automatic values into a single one separated by the separator below. If unsure, unselect this option.'),
    '#default_value' => isset($tag->options['combine-values']) ? $tag->options['combine-values'] : FALSE,
  );
  $form['options']['separator'] = array(
    '#type' => 'textfield',
    '#title' => t('Separator'),
    '#description' => t('For the <em>Combine multiple values</em> option above we need a separator. If unsure, input <em>, (comma)</em>.'),
    '#size' => 6,
    '#default_value' => isset($tag->options['separator']) ? $tag->options['separator'] : ',',
  );
  $form['buttons'] = array(
    '#weight' => 50,
    'save' => array(
      '#type' => 'submit',
      '#value' => isset($tag->tagid) ? t('Save meta tag') : t('Create new meta tag'),
      '#submit' => array(
        'nodewords_edit_submit_save',
      ),
      '#weight' => 0,
    ),
  );
  if (isset($tag->tagid)) {
    $form['buttons']['delete'] = array(
      '#type' => 'submit',
      '#value' => t('Delete meta tag'),
      '#submit' => array(
        'nodewords_edit_submit_delete',
      ),
      '#weight' => 5,
    );
  }
  return $form;
}