korea_democratic_peoples_republic_of_408_2.cif 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <?php
  2. /**
  3. * Implements hook_install() using the name of the country as the base of
  4. * the function name.
  5. */
  6. function korea_democratic_peoples_republic_of_install() {
  7. // Make the entry in the country table.
  8. // VALUES = Country ID, Country Name, 2-digit Code, 3-digit Code, File Version
  9. db_insert('uc_countries')
  10. ->fields(array(
  11. 'country_id' => 408,
  12. 'country_name' => "Korea, Democratic People's Republic of",
  13. 'country_iso_code_2' => 'KP',
  14. 'country_iso_code_3' => 'PRK',
  15. 'version' => 2,
  16. ))
  17. ->execute();
  18. // Make the entries in the zones table.
  19. $zones = array(
  20. array(408, 'KP-01', 'P’yŏngyang'),
  21. array(408, 'KP-13', 'Nasŏn (Najin-Sŏnbong'),
  22. array(408, 'KP-02', 'P’yŏngan-namdo'),
  23. array(408, 'KP-03', 'P’yŏngan-bukto'),
  24. array(408, 'KP-04', 'Chagang-do'),
  25. array(408, 'KP-05', 'Hwanghae-namdo'),
  26. array(408, 'KP-06', 'Hwanghae-bukto'),
  27. array(408, 'KP-07', 'Kangwŏn-do'),
  28. array(408, 'KP-08', 'Hamgyŏng-namdo'),
  29. array(408, 'KP-09', 'Hamgyŏng-bukto'),
  30. array(408, 'KP-10', 'Yanggang-do'),
  31. );
  32. $query = db_insert('uc_zones')->fields(array('zone_country_id', 'zone_code', 'zone_name'));
  33. foreach ($zones as $zone) {
  34. $query->values($zone);
  35. }
  36. $query->execute();
  37. // Set address format
  38. uc_set_address_format(
  39. 408,
  40. "!company\r\n" .
  41. "!first_name !last_name\r\n" .
  42. "!street1\r\n" .
  43. "!street2\r\n" .
  44. "!city, !zone_name !postal_code\r\n" .
  45. "!country_name_if"
  46. );
  47. }
  48. /**
  49. * Implements hook_update() with $version being the only argument.
  50. * Add a new case for each version update, and be sure to always include the
  51. * latest changes in the install function.
  52. */
  53. function korea_democratic_peoples_republic_of_update($version) {
  54. switch ($version) {
  55. case 2:
  56. // Correct ISO-3166-1 country name
  57. db_update('uc_countries')
  58. ->fields(array('country_name' => "Korea, Democratic People's Republic of"))
  59. ->condition('country_id', 408)
  60. ->execute();
  61. break;
  62. }
  63. }