libya_434_2.cif 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. <?php
  2. /**
  3. * Implements hook_install() using the name of the country as the base of
  4. * the function name.
  5. */
  6. function libya_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' => 434,
  12. 'country_name' => 'Libya',
  13. 'country_iso_code_2' => 'LY',
  14. 'country_iso_code_3' => 'LBY',
  15. 'version' => 2,
  16. ))
  17. ->execute();
  18. // Make the entries in the zones table.
  19. $zones = array(
  20. array(434, 'LY-BU', 'Al Buţnān'),
  21. array(434, 'LY-JA', 'Al Jabal al Akhḑar'),
  22. array(434, 'LY-JG', 'Al Jabal al Gharbī'),
  23. array(434, 'LY-JI', 'Al Jifārah'),
  24. array(434, 'LY-JU', 'Al Jufrah'),
  25. array(434, 'LY-KF', 'Al Kufrah'),
  26. array(434, 'LY-MJ', 'Al Marj'),
  27. array(434, 'LY-MB', 'Al Marqab'),
  28. array(434, 'LY-WA', 'Al Wāḩāt'),
  29. array(434, 'LY-NQ', 'An Nuqaţ al Khams'),
  30. array(434, 'LY-ZA', 'Az Zāwiyah'),
  31. array(434, 'LY-BA', 'Banghāzī'),
  32. array(434, 'LY-DR', 'Darnah'),
  33. array(434, 'LY-GT', 'Ghāt'),
  34. array(434, 'LY-MI', 'Mişrātah'),
  35. array(434, 'LY-MQ', 'Murzuq'),
  36. array(434, 'LY-NL', 'Nālūt'),
  37. array(434, 'LY-SB', 'Sabhā'),
  38. array(434, 'LY-SR', 'Surt'),
  39. array(434, 'LY-TB', 'Tarābulus'),
  40. array(434, 'LY-WD', 'Wādī al Ḩayāt'),
  41. array(434, 'LY-WS', 'Wādī ash Shāţiʾ'),
  42. );
  43. $query = db_insert('uc_zones')->fields(array('zone_country_id', 'zone_code', 'zone_name'));
  44. foreach ($zones as $zone) {
  45. $query->values($zone);
  46. }
  47. $query->execute();
  48. // Set address format
  49. uc_set_address_format(
  50. 434,
  51. "!company\r\n" .
  52. "!first_name !last_name\r\n" .
  53. "!street1\r\n" .
  54. "!street2\r\n" .
  55. "!city, !zone_name !postal_code\r\n" .
  56. "!country_name_if"
  57. );
  58. }
  59. /**
  60. * Implements hook_update() with $version being the only argument.
  61. * Add a new case for each version update, and be sure to always include the
  62. * latest changes in the install function.
  63. */
  64. function libya_update($version) {
  65. switch ($version) {
  66. case 2:
  67. // Correct ISO-3166-1 country name
  68. db_update('uc_countries')
  69. ->fields(array('country_name' => 'Libya'))
  70. ->condition('country_id', 434)
  71. ->execute();
  72. break;
  73. }
  74. }