@@ -98,76 +98,6 @@ function parse_csv_data($file)
9898 return $ skills ;
9999}
100100
101- /**
102- * XML-parser: handle start of element.
103- */
104- function element_start ($ parser , $ data )
105- {
106- $ data = api_utf8_decode ($ data );
107- global $ skill ;
108- global $ current_tag ;
109- switch ($ data ) {
110- case 'Skill ' :
111- $ skill = [];
112- break ;
113- default :
114- $ current_tag = $ data ;
115- }
116- }
117-
118- /**
119- * XML-parser: handle end of element.
120- */
121- function element_end ($ parser , $ data )
122- {
123- $ data = api_utf8_decode ($ data );
124- global $ skill ;
125- global $ skills ;
126- global $ current_value ;
127- switch ($ data ) {
128- case 'Skill ' :
129- $ skills [] = $ skill ;
130- break ;
131- default :
132- $ skill [$ data ] = $ current_value ;
133- break ;
134- }
135- }
136-
137- /**
138- * XML-parser: handle character data.
139- */
140- function character_data ($ parser , $ data )
141- {
142- $ data = trim (api_utf8_decode ($ data ));
143- global $ current_value ;
144- $ current_value = $ data ;
145- }
146-
147- /**
148- * Read the XML-file.
149- *
150- * @param string $file Path to the XML-file
151- *
152- * @return array All userinformation read from the file
153- */
154- function parse_xml_data ($ file )
155- {
156- global $ current_tag ;
157- global $ current_value ;
158- global $ skill ;
159- global $ skills ;
160- $ skills = [];
161- $ parser = xml_parser_create ('UTF-8 ' );
162- xml_set_element_handler ($ parser , 'element_start ' , 'element_end ' );
163- xml_set_character_data_handler ($ parser , 'character_data ' );
164- xml_parser_set_option ($ parser , XML_OPTION_CASE_FOLDING , false );
165- xml_parse ($ parser , api_utf8_encode_xml (file_get_contents ($ file )));
166- xml_parser_free ($ parser );
167-
168- return $ skills ;
169- }
170-
171101$ this_section = SECTION_PLATFORM_ADMIN ;
172102api_protect_admin_script (true );
173103
@@ -183,7 +113,7 @@ function parse_xml_data($file)
183113 $ file_type = $ _POST ['file_type ' ];
184114 Security::clear_token ();
185115 $ tok = Security::get_token ();
186- $ allowed_file_mimetype = ['csv ' , ' xml ' ];
116+ $ allowed_file_mimetype = ['csv ' ];
187117 $ error_kind_file = false ;
188118 $ error_message = '' ;
189119
@@ -194,10 +124,6 @@ function parse_xml_data($file)
194124 $ skills = parse_csv_data ($ _FILES ['import_file ' ]['tmp_name ' ]);
195125 $ errors = validate_data ($ skills );
196126 $ error_kind_file = false ;
197- } elseif (strcmp ($ file_type , 'xml ' ) === 0 && $ ext_import_file == $ allowed_file_mimetype [1 ]) {
198- $ skills = parse_xml_data ($ _FILES ['import_file ' ]['tmp_name ' ]);
199- $ errors = validate_data ($ skills );
200- $ error_kind_file = false ;
201127 } else {
202128 $ error_kind_file = true ;
203129 }
@@ -222,8 +148,6 @@ function parse_xml_data($file)
222148
223149 if (strcmp ($ file_type , 'csv ' ) === 0 ) {
224150 save_data ($ skills_to_insert );
225- } elseif (strcmp ($ file_type , 'xml ' ) === 0 ) {
226- save_data ($ skills_to_insert );
227151 } else {
228152 $ error_message = get_lang ('YouMustImportAFileAccordingToSelectedOption ' );
229153 }
@@ -272,7 +196,7 @@ function parse_xml_data($file)
272196 'radio ' ,
273197 'file_type ' ,
274198 '' ,
275- 'CSV (<a href="skill_example.csv" target="_blank"> ' .get_lang ('ExampleCSVFile ' ).'</a>) ' ,
199+ 'CSV (<a href="skill_example.csv" target="_blank" download > ' .get_lang ('ExampleCSVFile ' ).'</a>) ' ,
276200 'csv '
277201);
278202$ form ->addGroup ($ group , '' , get_lang ('FileType ' ));
@@ -283,23 +207,6 @@ function parse_xml_data($file)
283207$ form ->setDefaults ($ defaults );
284208$ form ->display ();
285209
286- $ list = [];
287- $ list_reponse = [];
288- $ result_xml = '' ;
289- $ i = 0 ;
290- $ count_fields = count ($ extra_fields );
291- if ($ count_fields > 0 ) {
292- foreach ($ extra_fields as $ extra ) {
293- $ list [] = $ extra [1 ];
294- $ list_reponse [] = 'xxx ' ;
295- $ spaces = ' ' ;
296- $ result_xml .= $ spaces .'< ' .$ extra [1 ].'>xxx</ ' .$ extra [1 ].'> ' ;
297- if ($ i != $ count_fields - 1 ) {
298- $ result_xml .= '<br/> ' ;
299- }
300- $ i ++;
301- }
302- }
303210?>
304211<p><?php echo get_lang ('CSVMustLookLike ' ).' ( ' .get_lang ('MandatoryFields ' ).') ' ; ?> :</p>
305212
0 commit comments