function taxonomy_xml_invoke_import in Taxonomy import/export via XML 6
Same name and namespace in other branches
- 5.2 taxonomy_xml.module \taxonomy_xml_invoke_import()
- 5 taxonomy_xml.module \taxonomy_xml_invoke_import()
- 6.2 taxonomy_xml.module \taxonomy_xml_invoke_import()
- 7 taxonomy_xml.module \taxonomy_xml_invoke_import()
Do the actual importing from the given string, pased on the parameters passed from the form.
Parameters
$text:
$form_values:
$url:
Return value
NULL. Writes success summary to the screen
See also
taxonomy_xml_HOOK_parse()
1 call to taxonomy_xml_invoke_import()
- taxonomy_xml_import_form_submit in ./
taxonomy_xml.module - Imports the actual XML.
File
- ./
taxonomy_xml.module, line 468 - taxonomy_xml.module This module makes it possible to import and export taxonomies as XML documents.
Code
function taxonomy_xml_invoke_import($text, $form_values, $url = NULL) {
$vid = $form_values['vid'];
if ($vid == -1) {
// Requested to create new vocab.
$newname = !empty($form_values['file']) ? basename($form_values['file']->filename) : basename($url);
$vocabulary = _taxonomy_xml_get_vocabulary_placeholder($newname);
$vid = $vocabulary->vid;
variable_set('taxonomy_xml_vid', $vid);
}
// Sitemenu implodes when I try to do bulk updates? Or is it pathauto
// TODO figure this out
// module_disable(array('sitemenu','pathauto'));
// Conditionally include and invoke the appropriate format library
$incfile = dirname(drupal_get_filename('module', 'taxonomy_xml')) . '/' . $form_values['format'] . '.inc';
include_once $incfile;
$format_name = preg_replace('/_format$/', '', $form_values['format']);
$funcname = "taxonomy_xml_{$format_name}_parse";
if (function_exists($funcname)) {
$modified_terms = $funcname($text, $vid, $url);
// Func may have modified vocab or vid during its import. reload (just for these messages).
$vocabulary = taxonomy_vocabulary_load($vid);
if (!empty($modified_terms)) {
$term_list = array();
foreach ($modified_terms as $list_term) {
$term_list[] = l($list_term->name, 'admin/content/taxonomy/edit/term/' . $list_term->tid);
}
drupal_set_message(t('Updated %count term(s)', array(
'%count' => count($modified_terms),
)) . ' <i>' . implode(', ', $term_list) . '.</i> ');
drupal_set_message(t("\n Imported vocabulary %vocab_name.\n You may now need to <a href='!settings_link'>Review the vocabulary settings</a>\n or <a href='!list_link'>List the terms</a>", array(
'%vocab_name' => $vocabulary->name,
'!settings_link' => url('admin/content/taxonomy/edit/vocabulary/' . $vid),
'!list_link' => url('admin/content/taxonomy/' . $vid),
)));
}
else {
drupal_set_message(t("Failed to import any new terms. This may be due to syntax or formattings errors in the import file.", array()), 'error');
}
}
else {
drupal_set_message("Unavailable format. {$funcname} was not found in formatting library {$incfile}.", 'error');
}
}