You are here

function kwresearch_admin_settings in Keyword Research 7

Same name and namespace in other branches
  1. 6 kwresearch.admin.inc \kwresearch_admin_settings()

Displays the form for the standard settings tab.

Return value

array A structured array for use with Forms API.

1 string reference to 'kwresearch_admin_settings'
kwresearch_menu in ./kwresearch.module
Implements hook_menu()

File

./kwresearch.admin.inc, line 14
Admin include file.

Code

function kwresearch_admin_settings($form, &$form_state) {
  $sources = module_invoke_all('kwresearch_sources');
  if (is_array($sources) && count($sources) > 1) {
    foreach ($sources as $aid => $source) {
      $s[] = $source['title'];
    }
    $form['sources'] = array(
      '#type' => 'item',
      '#title' => t('Enabled keyword statistics sources'),
      '#markup' => theme('item_list', array(
        'items' => $s,
      )),
      '#description' => t('Sources provide data for keyword stats reports.'),
    );
  }
  else {
    $form['sources'] = array(
      '#type' => 'item',
      '#title' => t('Sources'),
      '#markup' => t('No keyword statistics sources have been enabled. To access keyword popularity data enable a data source such as the Keyword Research Google (Keyword Research sub-module), !scribe, !wordstream or !wordtracker modules.', array(
        '!scribe' => l('Scribe SEO', 'http://drupal.org/project/scribeseo'),
        '!wordstream' => l('WordStream', 'http://drupal.org/project/wordstream'),
        '!wordtracker' => l('Wordtracker', 'http://drupal.org/project/wordtracker'),
      )),
    );
    $sources = array();
  }
  $form['kwresearch_stats_report_options'] = array(
    '#type' => 'fieldset',
    '#title' => t('Stats report options'),
    '#collapsible' => TRUE,
    '#collapsed' => FALSE,
  );
  require_once DRUPAL_ROOT . '/' . drupal_get_path('module', 'kwresearch') . "/includes/stats_report.inc";
  $options = kwresearch_get_report_data_options();
  $def_values = kwresearch_get_report_data_options_defaults();

  //dsm(variable_get('kwresearch_popularity_report_columns', $def_values));
  $form['kwresearch_stats_report_options']['kwresearch_stats_report_data_options'] = array(
    '#type' => 'checkboxes',
    '#title' => t('Report data'),
    '#options' => $options,
    '#default_value' => variable_get('kwresearch_stats_report_data_options', $def_values),
  );
  $options = kwresearch_get_report_links_options();
  $def_values = kwresearch_get_report_links_options_defaults();
  $form['kwresearch_stats_report_options']['kwresearch_stats_report_links_options'] = array(
    '#type' => 'checkboxes',
    '#title' => t('Report links'),
    '#options' => $options,
    '#default_value' => variable_get('kwresearch_stats_report_links_options', $def_values),
  );
  $form['kwresearch_stats_report_options']['kwresearch_stats_report_item_limit'] = array(
    '#type' => 'textfield',
    '#title' => t('Item limit'),
    '#size' => 5,
    '#default_value' => variable_get('kwresearch_stats_report_item_limit', KWARESEARCH_STATS_REPORT_ITEM_LIMIT_DEFAULT),
    '#description' => t('The maximum number of items to show in the report'),
  );
  $form['kwresearch_site_report_options'] = array(
    '#type' => 'fieldset',
    '#title' => t('Site report options'),
    '#collapsible' => TRUE,
    '#collapsed' => FALSE,
  );
  require_once DRUPAL_ROOT . '/' . drupal_get_path('module', 'kwresearch') . "/includes/site_report.inc";
  $options = kwresearch_get_report_data_options('site');
  $def_values = kwresearch_get_site_report_data_options_defaults();

  //dsm(variable_get('kwresearch_popularity_report_columns', $def_values));
  $form['kwresearch_site_report_options']['kwresearch_site_report_data_options'] = array(
    '#type' => 'checkboxes',
    '#title' => t('Report data'),
    '#options' => $options,
    '#default_value' => variable_get('kwresearch_site_report_data_options', $def_values),
  );
  $form['vocab'] = array(
    '#type' => 'fieldset',
    '#title' => t('Taxonomy settings'),
    '#description' => t('Use the below drop downs to select any vocabularies for tagging nodes with keywords. The Keyword Reserach stores tags in its own tables with meta data and suport for non-nodes. If you want to sync this data with a vocabulary, use the "sync" selection. If you want to store terms in vocabulary independent of Keyword Research\'s data, use the "tag" selection.'),
  );
  $vocabs = taxonomy_get_vocabularies();
  $options = array(
    0 => t('None'),
  );
  $options2 = array();
  if (is_array($vocabs) && count($vocabs) > 0) {
    foreach ($vocabs as $vid => $v) {
      $options[$v->machine_name] = $v->name;
      $options2[$v->machine_name] = $v->name;
    }
    $form['vocab']['kwresearch_keyword_sync_vocabulary'] = array(
      '#type' => 'select',
      '#title' => t('Page keyword sync vocabulary'),
      '#options' => $options,
      '#default_value' => variable_get('kwresearch_keyword_sync_vocabulary', 0),
      '#description' => t('Select a vocabulary to sync with Keyword Research\'s internal page keywords.'),
    );
    $form['vocab']['kwresearch_keyword_tag_vocabulary'] = array(
      '#type' => 'select',
      '#title' => t('Page keyword tag vocabulary'),
      '#options' => $options,
      '#default_value' => variable_get('kwresearch_keyword_tag_vocabulary', 0),
      '#description' => t('Select a vocabulary for storing keywords independed of Keyword Research\'s page keywords.'),
    );
    $form['vocab']['kwresearch_report_vocabulary'] = array(
      '#type' => 'checkboxes',
      '#title' => t('Report vocabulary'),
      '#options' => $options2,
      '#default_value' => variable_get('kwresearch_report_vocabulary', array()),
      '#description' => t('Select any vocabulary you would like to attach the keyword reports.'),
    );
  }
  else {
    $form['vocab']['no'] = array(
      '#type' => 'item',
      '#title' => t('No vocabularies exist'),
      '#description' => t('To sync keyword research you need to !create_a_vocabulary first.', array(
        '!create_a_vocabulary' => l(t('create a vocabulary'), 'admin/structure/taxonomy/add/vocabulary'),
      )),
    );
  }
  return system_settings_form($form);
}