Projekt

Allgemein

Profil

GX-Bug #61892 » countries_php_create_country_with_definable_country_translation.patch

Marvin Muxfeld, 27.06.2019 15:43

Unterschiede anzeigen:

src/admin/countries.php (date 1561638667000)
31 31
	switch ($_GET['action']) {
32 32
		case 'insert':
33 33
			$_SESSION['coo_page_token']->is_valid($_POST['page_token']);
34
			$countries_name = xtc_db_prepare_input($_POST['countries_name']);
34
            
35
            $countries_name = xtc_db_prepare_input($_POST['countries_name']);
36
			$country_names = [];
37
            $translation_index = 0;
38
            
39
            //  Input fields are build dynamically with the available languages
40
            while (isset($_POST['countries_translation_' . ++$translation_index])) {
41
            	
42
            	$country_names[$translation_index] = xtc_db_prepare_input($_POST['countries_translation_' . $translation_index]);
43
            }
44
		
35 45
			$countries_iso_code_2 = xtc_db_prepare_input($_POST['countries_iso_code_2']);
36 46
			$countries_iso_code_3 = xtc_db_prepare_input($_POST['countries_iso_code_3']);
37 47
			$address_format_id = xtc_db_prepare_input($_POST['address_format_id']);
38 48

  
39 49
			xtc_db_query("insert into " . TABLE_COUNTRIES . " (countries_name, countries_iso_code_2, countries_iso_code_3, address_format_id) values ('" . xtc_db_input($countries_name) . "', '" . xtc_db_input($countries_iso_code_2) . "', '" . xtc_db_input($countries_iso_code_3) . "', '" . xtc_db_input($address_format_id) . "')");
50
			
51
			$queryBuilder = StaticGXCoreLoader::getDatabaseQueryBuilder();
52
			
53
			foreach ($country_names as $language_id => $phrase_text) {
54
                
55
                $data = [
56
                    'language_id' => $language_id,
57
                    'section_name' => 'countries',
58
                    'phrase_name' => $countries_iso_code_2,
59
                    'phrase_text' => $phrase_text
60
                ];
61
				
62
				$queryBuilder->insert('language_phrases_edited', $data);
63
			}
64
			
40 65
			xtc_redirect(xtc_href_link(FILENAME_COUNTRIES));
41 66
			break;
42 67
		case 'save':
......
307 332

  
308 333
						$contents[] = array('text' => TEXT_INFO_INSERT_INTRO);
309 334
						$contents[] = array('text' => '<span class="options-title">' . TEXT_INFO_COUNTRY_NAME . '</span>' . xtc_draw_input_field('countries_name'));
335
						
336
						foreach ($availableLanguages as $language) {
337
							
338
							$languages_id = $language['languages_id'];
339
                            $languages_code = $language['code'];
340
                            
341
                            $input_title = str_replace(':', '&nbsp;' . strtoupper($languages_code) . ':', TEXT_INFO_COUNTRY_NAME);
342
                            $input_name  = 'countries_translation_' . $languages_id;
343
                            
344
							$contents[] = ['text' => '<span class="options-title">' . $input_title . '</span>' . xtc_draw_input_field($input_name)];
345
						}
346
						
310 347
						$contents[] = array('text' => '<span class="options-title">' . TEXT_INFO_COUNTRY_CODE_2 . '</span>' . xtc_draw_input_field('countries_iso_code_2'));
311 348
						$contents[] = array('text' => '<span class="options-title">' . TEXT_INFO_COUNTRY_CODE_3 . '</span>' . xtc_draw_input_field('countries_iso_code_3'));
312 349
						$contents[] = array('text' => '<span class="options-title">' . TEXT_INFO_ADDRESS_FORMAT . '</span>' . xtc_draw_pull_down_menu('address_format_id', xtc_get_address_formats()));
(2-2/2)