You are here

function seotools_kwresearch_kwresearch_keyword_sync_vocabulary_reset in Drupal SEO Tools 6

File

plugins/seotools.presets.inc, line 590

Code

function seotools_kwresearch_kwresearch_keyword_sync_vocabulary_reset() {

  // First search if the vocabulary has already been created.
  $vocabularies = taxonomy_get_vocabularies();
  if (is_array($vocabularies)) {
    foreach ($vocabularies as $vid => $info) {
      if ($info->name == 'Keywords') {
        $tags = (array) $info;
      }
    }
  }

  // If it doesn't exist yet, create it.
  if (!isset($tags)) {
    $tags = array(
      'name' => 'Keywords',
      'description' => 'generated vocabulary for keyword content',
      'tags' => 1,
      'relations' => 1,
      'module' => 'taxonomy',
      'nodes' => array_combine(array_keys(node_get_types()), array_keys(node_get_types())),
    );
    taxonomy_save_vocabulary($tags);
    drupal_set_message('A keyword vocabulary was generated for you.');
  }

  // Set the variables for the tags vocabulary.
  variable_set('kwresearch_keyword_sync_vocabulary', $tags['vid']);
  $report_vocabs = variable_get('kwresearch_report_vocabulary', array());
  $report_vocabs[$tags['vid']] = $tags['vid'];
  variable_set('kwresearch_report_vocabulary', $report_vocabs);
}