function taxonomy_csv_formats_get in Taxonomy CSV import/export 6.4
Same name and namespace in other branches
- 6.5 taxonomy_csv.api.inc \taxonomy_csv_formats_get()
- 6.2 taxonomy_csv.api.inc \taxonomy_csv_formats_get()
- 6.3 taxonomy_csv.api.inc \taxonomy_csv_formats_get()
Fetch available external formats.
Scan the sub directory "formats" of the module for *.format.inc files. An included file should contain appropriate functions to get infos, to create a vocabulary, to import a line and to export a term.
Return value
Array of available formats indexed by format name.
4 calls to taxonomy_csv_formats_get()
- taxonomy_csv_format_check_vocabulary in ./
taxonomy_csv.api.inc - Helper to check if a vocabulary has specific fields.
- taxonomy_csv_format_get in ./
taxonomy_csv.api.inc - Helper to get a format.
- taxonomy_csv_form_import in import/
taxonomy_csv.import.admin.inc - Generates the taxonomy CSV import form.
- _taxonomy_csv_values in ./
taxonomy_csv.api.inc - Helper to remember some items and to describe features.
File
- ./
taxonomy_csv.api.inc, line 295 - Manage variables and features of module.
Code
function taxonomy_csv_formats_get() {
static $formats = array();
if (!$formats) {
$module_dir = drupal_get_path('module', 'taxonomy_csv');
$files = file_scan_directory("{$module_dir}/formats", '\\.format.inc$');
$formats = array();
foreach ($files as $filepath => $file) {
// Use this format only if it works.
$format_name = preg_replace('/.format.inc$/', '', $file->basename);
$funcname = "taxonomy_csv_format_{$format_name}";
if (taxonomy_csv_format_check($format_name, $funcname)) {
$format = $funcname();
if (!isset($format['needed_module']) || $format['needed_module'] == '' || module_exists($format['needed_module'])) {
$formats[$format_name] = $format;
}
}
}
}
return $formats;
}