You are here

function _taxonomy_xml_get_vocabulary_placeholder in Taxonomy import/export via XML 6.2

Same name and namespace in other branches
  1. 5.2 taxonomy_xml.module \_taxonomy_xml_get_vocabulary_placeholder()
  2. 5 taxonomy_xml.module \_taxonomy_xml_get_vocabulary_placeholder()
  3. 6 taxonomy_xml.module \_taxonomy_xml_get_vocabulary_placeholder()
  4. 7 taxonomy_xml.process.inc \_taxonomy_xml_get_vocabulary_placeholder()

Fetch the named vocab if it exists

Create and return a useful placeholder if not.

Parameters

$name:

$edit An array of additional vocabulary properties as used by: taxonomy_save_vocabulary, eg 'description', 'help', 'required', 'tags'

Return value

The new vocab object.

6 calls to _taxonomy_xml_get_vocabulary_placeholder()
taxonomy_xml_absorb_vocabulary_definitions in ./taxonomy_xml.module
Create Vocabulary definitions.
taxonomy_xml_invoke_import in ./taxonomy_xml.module
Do the actual importing from the given string, pased on the parameters passed from the form.
taxonomy_xml_mesh_parse in ./mesh_format.inc
Reads a XML file and creates the term definitions found in it.
taxonomy_xml_setup_vocabulary_from_data in ./xml_format.inc
The setting is to initialize a vocabulary from the given settings (an array of attributes).
taxonomy_xml_source_features_rebuild in ./taxonomy_xml.features.inc
Create/recreate the items based on the data array.

... See full list

File

./taxonomy_xml.module, line 801
This module makes it possible to import and export taxonomies as XML documents.

Code

function _taxonomy_xml_get_vocabulary_placeholder($name, $edit = array()) {
  if ($vocabulary = taxonomy_xml_get_vocabulary_by_name($name)) {
    return $vocabulary;
  }

  // Create new vocab
  $vocabulary = array(
    'name' => $name,
    'relations' => TRUE,
    'hierarchy' => 2,
  ) + $edit;
  taxonomy_save_vocabulary($vocabulary);

  // Need to retrieve it from DB again - the result isn't given back to us.
  $vid = db_result(db_query("SELECT vid FROM {vocabulary} WHERE LOWER('%s') LIKE LOWER(name)", $vocabulary['name']));
  $vocabulary = taxonomy_vocabulary_load($vid);
  drupal_set_message(t('Created vocabulary %vid %vocabname to put these terms into. You probably want to <a href="!vocablink">go edit it now</a>.', array(
    '%vocabname' => $vocabulary->name,
    '%vid' => $vid,
    '!vocablink' => url('admin/content/taxonomy/edit/vocabulary/' . $vid),
  )));
  return $vocabulary;
}