function taxonomy_csv_import in Taxonomy CSV import/export 7.5
Same name and namespace in other branches
- 5 taxonomy_csv.module \taxonomy_csv_import()
- 6.5 import/taxonomy_csv.import.api.inc \taxonomy_csv_import()
- 6.2 import/taxonomy_csv.import.api.inc \taxonomy_csv_import()
- 6.3 import/taxonomy_csv.import.api.inc \taxonomy_csv_import()
- 6.4 import/taxonomy_csv.import.api.inc \taxonomy_csv_import()
- 7.4 import/taxonomy_csv.import.api.inc \taxonomy_csv_import()
Process the import of an input.
If not used in a form, don't forget to use batch_process().
Parameters
$options: An associative array of options:
- file : object file if file is already uploaded
- text : csv text to import
- url : url to distant or local csv file
- path : path to local csv file
- import_format : see _taxonomy_csv_values (default: 'flat')
- fields_format : array. list of machinename fields (default: 0 => 'name')
- translate_by : string. name (default) or tid
- translate_languages: array. List of languages for i18n (default: empty)
- keep_order : boolean. keep order of imported terms or not (default)
- delimiter : 1 character csv delimiter (default: ',')
- enclosure : 0 or 1 character csv enclosure (default: none or '"')
- filter_format : string. description field format (default: 'plain_text')
- filter_format_custom: string. custom fields format (default: 'none')
- language : string. terms' default language (default: neutral 'und')
- check_line : boolean. check or not (default) format of lines
- check_utf8 : boolean. check or not (default) utf8 format
- locale_custom : string. specific locale of imported file
- vocabulary_target: 'autocreate' (default), 'duplicate' or 'existing'
- vocabulary_id : vid or machine_name of the vocabulary to import into
- i18n_mode : integer. internationalization mode of autocreated vocabulary (default: 0 (I18N_MODE_NONE))
- vocabulary_language: string. language code of autocreated vocabulary (default: 'und' (undefined))
- fields_custom : array. custom fields to add or create (default: array())
- delete_terms : delete all terms before import (default: FALSE)
- check_hierarchy: boolean. check (default) or not vocabulary hierarchy
- set_hierarchy : if hierarchy isn't checked, set it (0, 1 or 2 (default))
- update_or_ignore : depends on import_format: update (default) or ignore
- check_options : boolean. check or not (default) this array of options
- result_display : boolean. display or not (default)
- result_stats : boolean. display or not (default) stats
- result_terms : boolean. display or not (default) list of imported terms
- result_level : log: 'first' (default), 'warnings', 'notices' or 'infos'
- result_type : display log 'by_message' (default) or 'by_line'
Only one option is required: file or text or url or path. Other options have default values. Warning: default values are little different with UI.
Return value
Array of errors or nothing (need to execute batch process; result is logged in watchdog).
1 call to taxonomy_csv_import()
- drush_taxonomy_csv_import in ./
taxonomy_csv.drush.inc - Process the import of an input.
File
- import/
taxonomy_csv.import.api.inc, line 65 - Validate import options and manage import process.
Code
function taxonomy_csv_import($options) {
// Complete $options with default values if needed.
// Default api and UI options are different.
$options += _taxonomy_csv_values('import_default_api');
// Preload text or file in order to check access to temporary folder.
$messages = _taxonomy_csv_import_input_preload($options);
if (count($messages)) {
return $messages;
}
// Process import.
return taxonomy_csv_vocabulary_import($options);
}