You are here

function nodewords_custom_pages_edit in Nodewords: D6 Meta Tags 6

Same name and namespace in other branches
  1. 6.2 nodewords_custom_pages/nodewords_custom_pages.admin.inc \nodewords_custom_pages_edit()

Edit form for custom pages.

1 string reference to 'nodewords_custom_pages_edit'
nodewords_menu in ./nodewords.module
Implements hook_menu().

File

./nodewords.admin.inc, line 112
Administration interface for nodewords.module.

Code

function nodewords_custom_pages_edit($form_state, $page = NULL) {
  $form = array();
  if (!isset($page)) {
    $page = (object) array(
      'name' => t('Custom page'),
      'path' => '',
      'weight' => 0,
      'enabled' => 1,
      'tags' => array(),
    );
  }
  else {
    $form['pid'] = array(
      '#type' => 'value',
      '#value' => $page->pid,
    );
  }
  $nodewords_form = nodewords_form(NODEWORDS_TYPE_PAGE, $page->tags, array(
    'fieldset' => FALSE,
  ));
  if (empty($nodewords_form)) {
    $form['warning'] = array(
      '#value' => t('You have not yet enabled any <a href="@url">meta tags for edit forms</a>.', array(
        '@url' => url('admin/content/nodewords'),
      )),
      '#prefix' => '<div class="messages warning">',
      '#suffix' => '</div>',
    );
    return $form;
  }
  else {
    $form['name'] = array(
      '#type' => 'textfield',
      '#title' => t('Name'),
      '#description' => t("A name to better identify the page in the list of custom pages. The name must contains at least one alpha-numeric character."),
      '#default_value' => $page->name,
      '#size' => 60,
      '#maxlength' => 128,
      '#required' => TRUE,
    );
    $form['path'] = array(
      '#type' => 'textarea',
      '#title' => t('Path'),
      '#description' => t("Enter the Drupal paths associated with the page. The character <q>*</q> is a wildcard. Example paths are <em>blog</em> for the blog page and <em>blog/*</em> for every personal blog. The list must contain at least one path."),
      '#default_value' => $page->path,
      '#size' => 60,
      '#wysiwyg' => FALSE,
      '#required' => TRUE,
    );
    $form['weight'] = array(
      '#type' => 'weight',
      '#title' => t('Weight'),
      '#description' => t('Pages with lower weight will be considered first. Only the first matching page will be used.'),
      '#delta' => 10,
      '#default_value' => $page->weight,
    );
    $form['enabled'] = array(
      '#type' => 'radios',
      '#options' => array(
        t('Disabled'),
        t('Enabled'),
      ),
      '#default_value' => $page->enabled,
    );
    $form['nodewords'] = $nodewords_form;
    $form['nodewords']['#tree'] = TRUE;
    $form['submit'] = array(
      '#type' => 'submit',
      '#value' => t('Save'),
      '#weight' => 40,
    );
  }
  return $form;
}