Conjunto cd814d6 en sipes
- Fecha y hora:
- 01/08/2018 15:05:01 (hace 6 años)
- Branches:
- stable
- Children:
- 49ac6ee
- Parents:
- 7218404
- Fichero:
-
- 1 editado
Leyenda
- No modificado
- Añadido
- Eliminado
-
0.3-modules/ente_planificador_importar/ente_planificador_importar.module
r34e3034 rcd814d6 124 124 } 125 125 if (user_access('import term')) { 126 $links['term '] = array(126 $links['term1'] = array( 127 127 'data' => l(t('Importar terminos'), 'ente_planificador_importar/terminos'), 128 128 'class' => 'ente-planificador-importar-term', 129 129 ); 130 $links['term '] = array(130 $links['term2'] = array( 131 131 'data' => l(t('Importar Campos de terminos'), 'ente_planificador_importar/terminos/fields'), 132 132 'class' => 'ente-planificador-importar-term-fields', … … 721 721 ); 722 722 $options = array(); 723 for($i = 0;$i < 1 1; $i++) {723 for($i = 0;$i < 15; $i++) { 724 724 if (!$i) { 725 725 $options[$i] = t('N/A'); … … 729 729 } 730 730 } 731 $form['nombre'] = array( 732 '#type' => 'select', 733 '#title' => t('Nombre'), 734 '#options' => $options, 735 '#description' => t("La fila donde se encuentra el nombre del termino."), 736 '#required' => TRUE, 737 ); 731 for ($i=0; $i<=6; $i++) { 732 $form['fieldset_' . $i] = array( 733 '#type' => 'fieldset', 734 '#title' => t('Grupo ') . $i, 735 ); 736 $form['fieldset_' . $i]['search_parent_' . $i] = array( 737 '#type' => 'select', 738 '#title' => t('Parent ') . $i, 739 '#options' => $options, 740 '#description' => t("La fila donde se encuentra el parent ") . $i, 741 '#required' => TRUE, 742 ); 743 $form['fieldset_' . $i]['nombre_' . $i] = array( 744 '#type' => 'select', 745 '#title' => t('Nombre ') . $i, 746 '#options' => $options, 747 '#description' => t("La fila donde se encuentra el nombre del termino ") . $i, 748 '#required' => TRUE, 749 ); 750 $form['fieldset_' . $i]['description_' . $i] = array( 751 '#type' => 'select', 752 '#title' => t('Description ') . $i, 753 '#options' => $options, 754 '#description' => t("La fila donde se encuentra el description del termino ") . $i, 755 '#required' => TRUE, 756 ); 757 } 758 /* 738 759 $ids = array( 739 760 'code' => t('Código'), … … 745 766 '#options' => $options, 746 767 ); 747 } 768 }*/ 748 769 $form['encabezado'] = array( 749 770 '#title' => 'Primera columna como encabezado', … … 766 787 $validators = array('file_validate_extensions' => array('csv')); 767 788 // Check for a new uploaded file. 768 $file = file_save_upload('file_import_entes', $validators); 789 $file = file_save_upload('file_import_entes'); 790 769 791 if (isset($file)) { 770 792 // File upload was attempted. … … 785 807 ); 786 808 while (($data = fgetcsv($file)) !== FALSE) { 787 $term = array( 788 'vid' => $form_state['values']['vid'], // Voacabulary ID 789 'name' => check_plain($data[$form_state['values']['nombre'] - 1]), // Term Name 790 'fields' => array( 791 'unidad_codigo1' => array( 792 'value' => check_plain($data[$form_state['values']['code'] - 1]), 793 ), 794 ), 795 ); 796 if (!($form_state['values']['encabezado'] && $i == 1)) { 797 $batch['operations'][] = array('_batch_ente_planificador_importar_term', array($term)); 809 for ($j=0; $j<=6; $j++) { 810 if ($form_state['values']['nombre_' . $j] && $data[$form_state['values']['nombre_' . $j] - 1]) { 811 $term = array( 812 'vid' => $form_state['values']['vid'], // Voacabulary ID 813 'name' => check_plain($data[$form_state['values']['nombre_' . $j] - 1]), // Term Name 814 'description' => check_plain($data[$form_state['values']['description_' . $j] - 1]), // Term description 815 'search_parent' => FALSE, 816 /*'fields' => array( 817 'unidad_codigo1' => array( 818 'value' => check_plain($data[$form_state['values']['code'] - 1]), 819 ), 820 ),*/ 821 ); 822 if ($form_state['values']['search_parent_' . $j] && $data[$form_state['values']['search_parent_' . $j] - 1]) { 823 $term['search_parent'] = check_plain($data[$form_state['values']['search_parent_' . $j] - 1]); 824 } 825 if (!($form_state['values']['encabezado'] && $i == 1)) { 826 $batch['operations'][] = array('_batch_ente_planificador_importar_term', array($term)); 827 } 828 } 798 829 } 799 830 $i++; … … 866 897 */ 867 898 function _batch_ente_planificador_importar_term($term, &$context) { 868 taxonomy_save_term($term); 899 //not create if exist 900 $db_result = db_query(db_rewrite_sql("SELECT t.tid, t.name FROM {term_data} t WHERE LOWER(t.name) = LOWER('%s') AND vid = %d", 't', 'tid'), $term['name'], $term['vid']); 901 $row = db_fetch_array($db_result); 902 if (!taxonomy_get_term($row['tid'])) { 903 $term['parent'] = array(); 904 $term['search_parent']; 905 if ($term['search_parent']) { 906 $db_result = db_query(db_rewrite_sql("SELECT t.tid, t.name FROM {term_data} t WHERE LOWER(t.name) = LOWER('%s') AND vid = %d", 't', 'tid'), trim($term['search_parent']), $term['vid']); 907 $result = array(); 908 $row = db_fetch_array($db_result); 909 if (!empty($row)) { 910 $parent = taxonomy_get_term($row['tid']); 911 if ($parent) { 912 $term['parent'][] = $parent->tid; 913 } 914 } 915 } 916 taxonomy_save_term($term); 917 } 918 869 919 $context['message'] = t('Now processing ente: %submission', array('%submission' => $term->name)); 870 920 $context['results'][] = 'term importado: ' . $term->name . '</pre>';
Nota: Vea TracChangeset
para ayuda en el uso del visor de conjuntos de cambios.