You are here

function nodewords_admin_settings_form in Nodewords: D6 Meta Tags 6.3

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

Menu callback: settings form.

2 string references to 'nodewords_admin_settings_form'
nodewords_admin_menu in nodewords_admin/nodewords_admin.module
Implements hook_menu().
nodewords_basic_robots_settings_form in nodewords_basic/includes/nodewords_basic.nodewords.tags.inc

File

nodewords_admin/nodewords_admin.admin.inc, line 11
Administration interface for Nodewords.

Code

function nodewords_admin_settings_form() {
  $admin_pages = array(
    NODEWORDS_TYPE_ERRORPAGE,
    NODEWORDS_TYPE_PAGE,
    NODEWORDS_TYPE_TERM,
    NODEWORDS_TYPE_VOCABULARY,
  );
  $form = array();
  $enabled_options = array();
  $metatags_options = array(
    'admin' => TRUE,
    'fieldset' => TRUE,
    'last fields' => array(
      'operations' => array(
        'reset_metatags' => array(
          '#type' => 'submit',
          '#value' => t('Reset default meta tag values'),
          '#submit' => array(
            'nodewords_admin_settings_form_reset_metatags',
          ),
        ),
      ),
    ),
    'title' => t('Default meta tags'),
    'weight' => 0,
  );
  $options = array();
  $tags_info = nodewords_get_possible_tags();
  nodewords_load_all_includes('nodewords.tags.inc');
  if (!empty($tags_info)) {
    foreach ($tags_info as $name => $info) {
      $options[$name] = '';
      $bool = !empty($info['context']['allowed']) && is_array($info['context']['allowed']) && count(array_intersect($admin_pages, $info['context']['allowed'])) || !empty($info['context']['denied']) && is_array($info['context']['denied']) && count(array_intersect($admin_pages, $info['context']['denied'])) != count($admin_pages);
      if ($bool || empty($info['context']['allowed'])) {
        $enabled_options[$name] = '';
      }
    }
    $form['enabled'] = array(
      '#type' => 'fieldset',
      '#title' => t('Enabled meta tags'),
      '#description' => t('These settings change the meta tags that will be output, and shown in edit forms.'),
      '#collapsible' => TRUE,
      '#weight' => 0,
      '#group' => 'nodewords',
    );
    $form['enabled']['output'] = array(
      '#type' => 'fieldset',
      '#title' => t('Meta tags to output'),
      '#description' => t('These settings change the meta tags that will be output. Meta tags are used in search indexes only if there are modules implementing the necessary code.'),
      '#collapsible' => TRUE,
      '#theme' => 'nodewords_admin_output_fieldset',
    );
    $form['enabled']['output']['nodewords_head'] = array(
      '#type' => 'checkboxes',
      '#options' => $options,
      '#default_value' => variable_get('nodewords_head', array()),
      '#checkall' => TRUE ? 'nodewords-head-output' : FALSE,
    );
    $form['enabled']['output']['nodewords_search_index'] = array(
      '#type' => 'checkboxes',
      '#options' => $options,
      '#default_value' => variable_get('nodewords_search_index', array()),
      '#checkall' => TRUE ? 'nodewords-search-index-output' : FALSE,
    );
    $form['enabled']['admin'] = array(
      '#type' => 'fieldset',
      '#title' => t('Meta tags enabled on administrative settings pages'),
      '#theme' => 'nodewords_admin_enabled_metatags',
      '#weight' => 0,
    );
    $select_options = array(
      'never' => t('Never'),
      'empty' => t('When the meta tag is empty'),
    );
    $form['enabled']['admin']['nodewords_admin_edit'] = array(
      '#type' => 'checkboxes',
      '#options' => $enabled_options,
      '#default_value' => variable_get('nodewords_admin_edit', array()),
      '#checkall' => TRUE ? 'nodewords-enabled-metatags-admin-edit-form' : FALSE,
    );
    foreach ($tags_info as $name => $info) {
      if (isset($enabled_options[$name])) {
        $form['enabled']['admin']['nodewords_admin_use_default_value_' . $name] = array(
          '#type' => 'select',
          '#default_value' => variable_get('nodewords_admin_use_default_value_' . $name, 'empty'),
          '#options' => $select_options,
          '#multiple' => FALSE,
        );
      }
    }
  }
  else {
    $form['nodewords_head'] = array(
      '#type' => 'value',
      '#value' => variable_get('nodewords_head', array()),
    );
    $form['nodewords_search_index'] = array(
      '#type' => 'value',
      '#value' => variable_get('nodewords_search_index', array()),
    );
    $form['nodewords_admin_edit'] = array(
      '#type' => 'value',
      '#value' => variable_get('nodewords_admin_edit', array()),
    );
  }
  $form['metatags_creation'] = array(
    '#type' => 'fieldset',
    '#title' => t('Meta tags creation options'),
    '#description' => t('These options change the way the meta tags are generated.'),
    '#collapsible' => TRUE,
    '#weight' => 4,
    '#group' => 'nodewords',
  );
  $form['metatags_creation']['nodewords_list_repeat'] = array(
    '#type' => 'checkbox',
    '#title' => t('Repeat meta tags for lists'),
    '#description' => t('Some search engines punish sites that use the same meta tags on different pages. Uncheck this option if you want to suppress the repetition of the same meta tags on pages that use the pager - if unchecked, Drupal will only display the meta tags for the first page and not for subsequent pages. If unsure, select this option.'),
    '#default_value' => variable_get('nodewords_list_repeat', FALSE),
  );
  $form['metatags_creation']['nodewords_enable_tokens'] = array(
    '#type' => 'checkbox',
    '#title' => t('Enable tokens'),
    '#description' => t('This setting allows to use the tokens implemented in <a href="@token">token.module</a> in meta tags content.', array(
      '@token' => 'http://drupal.org/project/token',
    )),
    '#default_value' => variable_get('nodewords_enable_tokens', TRUE),
  );
  if (!module_exists('token')) {
    $form['metatags_creation']['nodewords_enable_tokens']['#description'] .= ' ' . t('The module token.module is not enabled, or installed.');
    if (!variable_get('nodewords_enable_tokens', TRUE)) {
      $form['metatags_creation']['nodewords_enable_tokens']['#disabled'] = TRUE;
    }
  }
  $form['metatags_creation']['nodewords_max_size'] = array(
    '#type' => 'textfield',
    '#title' => t('Maximum meta tags length'),
    '#description' => t('The maximum length to use for the meta tags form fields.'),
    '#default_value' => variable_get('nodewords_max_size', 350),
    '#required' => TRUE,
    '#element_validate' => array(
      'nodewords_admin_max_size_validate',
    ),
    '#size' => 6,
    '#maxlength' => 6,
  );
  $form['metatags_creation']['nodewords_base_url'] = array(
    '#type' => 'textfield',
    '#title' => t('Base URL'),
    '#description' => t('Enter the base URL that will be used for any URL generated by the module.'),
    '#default_value' => variable_get('nodewords_base_url', ''),
    '#element_validate' => array(
      'nodewords_admin_base_url_validate',
    ),
  );
  foreach ($tags_info as $name => $info) {
    $function = $info['callback'] . '_settings_form';
    $options = array(
      'parameters' => !empty($info['callback arguments']) ? $info['callback arguments'] : array(),
    );
    if (function_exists($function)) {
      $function($form, 'nodewords_admin_settings_form', $options);
    }
  }
  $form['buttons']['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Save configuration'),
  );
  $form['buttons']['reset'] = array(
    '#type' => 'submit',
    '#value' => t('Reset to defaults'),
    '#submit' => array(
      'nodewords_admin_settings_form_reset',
    ),
  );
  $form['buttons']['#weight'] = 100;
  $form['#pre_render'][] = 'vertical_tabs_form_pre_render';
  $form['#submit'][] = 'nodewords_admin_settings_form_submit';
  $form['#theme'] = 'nodewords_admin_settings_form';
  return $form;
}