123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245 |
- <?php
- define('TAXONOMY_CSV_FORMAT_STRUCTURE', 'structure');
- define('TAXONOMY_CSV_FORMAT_FLAT', 'flat');
- define('TAXONOMY_CSV_FORMAT_TREE', 'tree');
- define('TAXONOMY_CSV_FORMAT_POLYHIERARCHY', 'polyhierarchy');
- define('TAXONOMY_CSV_FORMAT_FIELDS', 'fields');
- define('TAXONOMY_CSV_FORMAT_TRANSLATE', 'translate');
- define('TAXONOMY_CSV_EXISTING_UPDATE', 'update');
- define('TAXONOMY_CSV_EXISTING_IGNORE', 'ignore');
- define('TAXONOMY_CSV_EXISTING_IGNORE_PREVIOUS', 'ignore_previous');
- define('TAXONOMY_CSV_PROCESS_ERROR', 300);
- define('TAXONOMY_CSV_PROCESS_WARNING', 400);
- define('TAXONOMY_CSV_PROCESS_NOTICE', 500);
- define('TAXONOMY_CSV_PROCESS_INFO', 600);
- define('TAXONOMY_CSV_PROCESS_DEBUG', 700);
- define('TAXONOMY_CSV_ERROR', 0);
- define('TAXONOMY_CSV_NEW_UPDATED', 4);
- define('TAXONOMY_CSV_UNCHANGED', 5);
- function _taxonomy_csv_values($list) {
- switch ($list) {
- case 'import_format':
- return array(
- TAXONOMY_CSV_FORMAT_STRUCTURE => t('Structure'),
- TAXONOMY_CSV_FORMAT_FIELDS => t('Fields'),
- TAXONOMY_CSV_FORMAT_TRANSLATE => t('Translation'),
- );
- case 'export_format':
- return array(
- TAXONOMY_CSV_FORMAT_FLAT => t('Term names'),
- TAXONOMY_CSV_FORMAT_TREE => t('Hierarchical tree structure'),
- TAXONOMY_CSV_FORMAT_FIELDS => t('Fields'),
- TAXONOMY_CSV_FORMAT_TRANSLATE => t('Translation'),
- );
- case 'import_default_ui':
- return array(
- 'import_format' => TAXONOMY_CSV_FORMAT_STRUCTURE,
- 'structure_type' => TAXONOMY_CSV_FORMAT_FLAT,
- 'import_fields_format' => 'name',
- 'translate_by' => 'name',
- 'translate_languages' => '',
- 'keep_order' => FALSE,
- 'source_choice' => 'text',
- 'import_delimiter' => 'comma',
- 'import_delimiter_soft_tab_width' => '2',
- 'import_delimiter_custom' => '',
- 'import_enclosure' => 'none',
- 'import_enclosure_custom' => '',
- 'filter_format' => 'plain_text',
- 'filter_format_custom' => 'none',
- 'import_language' => 'und',
- 'check_line' => TRUE,
- 'check_utf8' => TRUE,
- 'locale_custom' => '',
- 'vocabulary_target' => 'autocreate',
- 'vocabulary_id' => 'choose_vocabulary',
- 'i18n_mode' => 0,
- 'language' => 'und',
- 'import_fields_custom' => '',
- 'delete_terms' => FALSE,
- 'check_hierarchy' => TRUE,
- 'set_hierarchy' => 2,
- 'update_or_ignore' => TAXONOMY_CSV_EXISTING_UPDATE,
-
- 'result_stats' => 'result_stats',
- 'result_terms' => 'result_terms',
- 'result_level' => 'notices',
- 'result_type' => 'by_message',
- );
- case 'import_default_api':
- return array(
- 'import_format' => TAXONOMY_CSV_FORMAT_FLAT,
- 'fields_format' => array(0 => 'name'),
- 'translate_by' => 'name',
- 'translate_languages' => '',
- 'keep_order' => FALSE,
- 'delimiter' => ',',
- 'enclosure' => '',
- 'filter_format' => 'plain_text',
- 'filter_format_custom' => 'none',
-
- 'language' => 'und',
- 'check_line' => FALSE,
- 'check_utf8' => FALSE,
- 'locale_custom' => '',
- 'vocabulary_target' => 'autocreate',
- 'vocabulary_id' => 'choose_vocabulary',
- 'i18n_mode' => 0,
- 'vocabulary_language' => 'und',
- 'fields_custom' => array(),
- 'delete_terms' => FALSE,
- 'check_hierarchy' => TRUE,
- 'set_hierarchy' => 2,
- 'update_or_ignore' => TAXONOMY_CSV_EXISTING_UPDATE,
-
- 'check_options' => FALSE,
- 'result_display' => FALSE,
- 'result_stats' => FALSE,
- 'result_terms' => FALSE,
- 'result_level' => 'first',
- 'result_type' => 'by_message',
- );
- case 'export_default_ui':
- return array(
- 'export_format' => TAXONOMY_CSV_FORMAT_FLAT,
- 'export_fields_format' => 'name',
- 'export_vocabulary_id' => 0,
- 'export_delimiter' => 'comma',
- 'export_delimiter_custom' => '',
- 'export_enclosure' => 'quotation',
- 'export_enclosure_custom' => '',
- 'export_line_ending' => 'Unix',
-
- 'def_links_terms_ids' => 'name_if_needed',
- 'def_links_vocabularies_ids' => 'none',
-
- 'export_order' => 'name',
- 'result_duplicates' => TRUE,
- );
- case 'export_default_api':
- return array(
- 'export_format' => TAXONOMY_CSV_FORMAT_FLAT,
- 'fields_format' => array(0 => 'name'),
- 'vocabulary_id' => 0,
- 'delimiter' => ',',
- 'enclosure' => '"',
- 'line_ending' => 'Unix',
- 'order' => 'name',
-
- 'def_links_terms_ids' => 'name_if_needed',
- 'def_links_vocabularies_ids' => 'none',
-
- 'result_duplicates' => FALSE,
- 'check_options' => FALSE,
- 'result_display' => FALSE,
- );
- }
- }
- function _taxonomy_csv_worst_message($messages) {
- return count($messages) ?
- min($messages) :
- 799;
- }
- function _taxonomy_csv_escape_line_break($string) {
- return str_replace(
- array("\r", "\n"),
- array('\r', '\n'),
- $string);
- }
- function _taxonomy_csv_set_line_break($string) {
- return str_replace(
- array('\r', '\n'),
- array("\r", "\n"),
- $string);
- }
|