|
| 1 | +<?php |
| 2 | +/** |
| 3 | +* Macro helpers |
| 4 | +* |
| 5 | +*/ |
| 6 | + |
| 7 | +/** |
| 8 | +* Country macro |
| 9 | +* Generates the dropdown menu of countries for the profile form |
| 10 | +*/ |
| 11 | +Form::macro('countries', function ($name = "country", $selected = null, $class = null) { |
| 12 | + |
| 13 | + $countries = array( |
| 14 | + ''=>"Select a Country", |
| 15 | + 'ac'=>'Ascension Island', |
| 16 | + 'ad'=>'Andorra', |
| 17 | + 'ae'=>'United Arab Emirates', |
| 18 | + 'af'=>'Afghanistan', |
| 19 | + 'ag'=>'Antigua And Barbuda', |
| 20 | + 'ai'=>'Anguilla', |
| 21 | + 'al'=>'Albania', |
| 22 | + 'am'=>'Armenia', |
| 23 | + 'an'=>'Netherlands Antilles', |
| 24 | + 'ao'=>'Angola', |
| 25 | + 'aq'=>'Antarctica', |
| 26 | + 'ar'=>'Argentina', |
| 27 | + 'as'=>'American Samoa', |
| 28 | + 'at'=>'Austria', |
| 29 | + 'au'=>'Australia', |
| 30 | + 'aw'=>'Aruba', |
| 31 | + 'ax'=>'Ã…land', |
| 32 | + 'az'=>'Azerbaijan', |
| 33 | + 'ba'=>'Bosnia And Herzegovina', |
| 34 | + 'bb'=>'Barbados', |
| 35 | + 'be'=>'Belgium', |
| 36 | + 'bd'=>'Bangladesh', |
| 37 | + 'bf'=>'Burkina Faso', |
| 38 | + 'bg'=>'Bulgaria', |
| 39 | + 'bh'=>'Bahrain', |
| 40 | + 'bi'=>'Burundi', |
| 41 | + 'bj'=>'Benin', |
| 42 | + 'bm'=>'Bermuda', |
| 43 | + 'bn'=>'Brunei Darussalam', |
| 44 | + 'bo'=>'Bolivia', |
| 45 | + 'br'=>'Brazil', |
| 46 | + 'bs'=>'Bahamas', |
| 47 | + 'bt'=>'Bhutan', |
| 48 | + 'bv'=>'Bouvet Island', |
| 49 | + 'bw'=>'Botswana', |
| 50 | + 'by'=>'Belarus', |
| 51 | + 'bz'=>'Belize', |
| 52 | + 'ca'=>'Canada', |
| 53 | + 'cc'=>'Cocos (Keeling) Islands', |
| 54 | + 'cd'=>'Congo (Democratic Republic)', |
| 55 | + 'cf'=>'Central African Republic', |
| 56 | + 'cg'=>'Congo (Republic)', |
| 57 | + 'ch'=>'Switzerland', |
| 58 | + 'ci'=>'Cote D’Ivoire', |
| 59 | + 'ck'=>'Cook Islands', |
| 60 | + 'cl'=>'Chile', |
| 61 | + 'cm'=>'Cameroon', |
| 62 | + 'cn'=>'People’s Republic of China', |
| 63 | + 'co'=>'Colombia', |
| 64 | + 'cr'=>'Costa Rica', |
| 65 | + 'cu'=>'Cuba', |
| 66 | + 'cv'=>'Cape Verde', |
| 67 | + 'cx'=>'Christmas Island', |
| 68 | + 'cy'=>'Cyprus', |
| 69 | + 'cz'=>'Czech Republic', |
| 70 | + 'de'=>'Germany', |
| 71 | + 'dj'=>'Djibouti', |
| 72 | + 'dk'=>'Denmark', |
| 73 | + 'dm'=>'Dominica', |
| 74 | + 'do'=>'Dominican Republic', |
| 75 | + 'dz'=>'Algeria', |
| 76 | + 'ec'=>'Ecuador', |
| 77 | + 'ee'=>'Estonia', |
| 78 | + 'eg'=>'Egypt', |
| 79 | + 'er'=>'Eritrea', |
| 80 | + 'es'=>'Spain', |
| 81 | + 'et'=>'Ethiopia', |
| 82 | + 'eU'=>'European Union', |
| 83 | + 'fi'=>'Finland', |
| 84 | + 'fj'=>'Fiji', |
| 85 | + 'fk'=>'Falkland Islands (Malvinas)', |
| 86 | + 'fm'=>'Micronesia, Federated States Of', |
| 87 | + 'fo'=>'Faroe Islands', |
| 88 | + 'fr'=>'France', |
| 89 | + 'ga'=>'Gabon', |
| 90 | + 'gb'=>'United Kingdom', |
| 91 | + 'gd'=>'Grenada', |
| 92 | + 'ge'=>'Georgia', |
| 93 | + 'gf'=>'French Guiana', |
| 94 | + 'gg'=>'Guernsey', |
| 95 | + 'gh'=>'Ghana', |
| 96 | + 'gi'=>'Gibraltar', |
| 97 | + 'gl'=>'Greenland', |
| 98 | + 'gm'=>'Gambia', |
| 99 | + 'gn'=>'Guinea', |
| 100 | + 'gp'=>'Guadeloupe', |
| 101 | + 'gq'=>'Equatorial Guinea', |
| 102 | + 'gr'=>'Greece', |
| 103 | + 'gs'=>'South Georgia And The South Sandwich Islands', |
| 104 | + 'gt'=>'Guatemala', |
| 105 | + 'gu'=>'Guam', |
| 106 | + 'gw'=>'Guinea-Bissau', |
| 107 | + 'gy'=>'Guyana', |
| 108 | + 'hk'=>'Hong Kong', |
| 109 | + 'hm'=>'Heard And Mc Donald Islands', |
| 110 | + 'hn'=>'Honduras', |
| 111 | + 'hr'=>'Croatia (local name: Hrvatska)', |
| 112 | + 'ht'=>'Haiti', |
| 113 | + 'hu'=>'Hungary', |
| 114 | + 'id'=>'Indonesia', |
| 115 | + 'ie'=>'Ireland', |
| 116 | + 'il'=>'Israel', |
| 117 | + 'im'=>'Isle of Man', |
| 118 | + 'in'=>'India', |
| 119 | + 'io'=>'British Indian Ocean Territory', |
| 120 | + 'iq'=>'Iraq', |
| 121 | + 'ir'=>'Iran (Islamic Republic Of)', |
| 122 | + 'is'=>'Iceland', |
| 123 | + 'it'=>'Italy', |
| 124 | + 'je'=>'Jersey', |
| 125 | + 'jm'=>'Jamaica', |
| 126 | + 'jo'=>'Jordan', |
| 127 | + 'jp'=>'Japan', |
| 128 | + 'ke'=>'Kenya', |
| 129 | + 'kg'=>'Kyrgyzstan', |
| 130 | + 'kh'=>'Cambodia', |
| 131 | + 'ki'=>'Kiribati', |
| 132 | + 'km'=>'Comoros', |
| 133 | + 'kn'=>'Saint Kitts And Nevis', |
| 134 | + 'kr'=>'Korea, Republic Of', |
| 135 | + 'kw'=>'Kuwait', |
| 136 | + 'ky'=>'Cayman Islands', |
| 137 | + 'kz'=>'Kazakhstan', |
| 138 | + 'la'=>'Lao People’s Democratic Republic', |
| 139 | + 'lb'=>'Lebanon', |
| 140 | + 'lc'=>'Saint Lucia', |
| 141 | + 'li'=>'Liechtenstein', |
| 142 | + 'lk'=>'Sri Lanka', |
| 143 | + 'lr'=>'Liberia', |
| 144 | + 'ls'=>'Lesotho', |
| 145 | + 'lt'=>'Lithuania', |
| 146 | + 'lu'=>'Luxembourg', |
| 147 | + 'lv'=>'Latvia', |
| 148 | + 'ly'=>'Libyan Arab Jamahiriya', |
| 149 | + 'ma'=>'Morocco', |
| 150 | + 'mc'=>'Monaco', |
| 151 | + 'md'=>'Moldova, Republic Of', |
| 152 | + 'me'=>'Montenegro', |
| 153 | + 'mg'=>'Madagascar', |
| 154 | + 'mh'=>'Marshall Islands', |
| 155 | + 'mk'=>'Macedonia, The Former Yugoslav Republic Of', |
| 156 | + 'ml'=>'Mali', |
| 157 | + 'mm'=>'Myanmar', |
| 158 | + 'mn'=>'Mongolia', |
| 159 | + 'mo'=>'Macau', |
| 160 | + 'mp'=>'Northern Mariana Islands', |
| 161 | + 'mq'=>'Martinique', |
| 162 | + 'mr'=>'Mauritania', |
| 163 | + 'ms'=>'Montserrat', |
| 164 | + 'mt'=>'Malta', |
| 165 | + 'mu'=>'Mauritius', |
| 166 | + 'mv'=>'Maldives', |
| 167 | + 'mw'=>'Malawi', |
| 168 | + 'mx'=>'Mexico', |
| 169 | + 'my'=>'Malaysia', |
| 170 | + 'mz'=>'Mozambique', |
| 171 | + 'na'=>'Namibia', |
| 172 | + 'nc'=>'New Caledonia', |
| 173 | + 'ne'=>'Niger', |
| 174 | + 'nf'=>'Norfolk Island', |
| 175 | + 'ng'=>'Nigeria', |
| 176 | + 'ni'=>'Nicaragua', |
| 177 | + 'nl'=>'Netherlands', |
| 178 | + 'no'=>'Norway', |
| 179 | + 'np'=>'Nepal', |
| 180 | + 'nr'=>'Nauru', |
| 181 | + 'nu'=>'Niue', |
| 182 | + 'nz'=>'New Zealand', |
| 183 | + 'om'=>'Oman', |
| 184 | + 'pa'=>'Panama', |
| 185 | + 'pe'=>'Peru', |
| 186 | + 'pf'=>'French Polynesia', |
| 187 | + 'pg'=>'Papua New Guinea', |
| 188 | + 'ph'=>'Philippines, Republic of the', |
| 189 | + 'pk'=>'Pakistan', |
| 190 | + 'pl'=>'Poland', |
| 191 | + 'pm'=>'St. Pierre And Miquelon', |
| 192 | + 'pn'=>'Pitcairn', |
| 193 | + 'pr'=>'Puerto Rico', |
| 194 | + 'ps'=>'Palestine', |
| 195 | + 'pt'=>'Portugal', |
| 196 | + 'pw'=>'Palau', |
| 197 | + 'py'=>'Paraguay', |
| 198 | + 'qa'=>'Qatar', |
| 199 | + 're'=>'Reunion', |
| 200 | + 'ro'=>'Romania', |
| 201 | + 'rs'=>'Serbia', |
| 202 | + 'ru'=>'Russian Federation', |
| 203 | + 'rw'=>'Rwanda', |
| 204 | + 'sa'=>'Saudi Arabia', |
| 205 | + 'uk'=>'Scotland', |
| 206 | + 'sb'=>'Solomon Islands', |
| 207 | + 'sc'=>'Seychelles', |
| 208 | + 'sd'=>'Sudan', |
| 209 | + 'se'=>'Sweden', |
| 210 | + 'sg'=>'Singapore', |
| 211 | + 'sh'=>'St. Helena', |
| 212 | + 'si'=>'Slovenia', |
| 213 | + 'sj'=>'Svalbard And Jan Mayen Islands', |
| 214 | + 'sk'=>'Slovakia (Slovak Republic)', |
| 215 | + 'sl'=>'Sierra Leone', |
| 216 | + 'sm'=>'San Marino', |
| 217 | + 'sn'=>'Senegal', |
| 218 | + 'so'=>'Somalia', |
| 219 | + 'sr'=>'Suriname', |
| 220 | + 'st'=>'Sao Tome And Principe', |
| 221 | + 'su'=>'Soviet Union', |
| 222 | + 'sv'=>'El Salvador', |
| 223 | + 'sy'=>'Syrian Arab Republic', |
| 224 | + 'sz'=>'Swaziland', |
| 225 | + 'tc'=>'Turks And Caicos Islands', |
| 226 | + 'td'=>'Chad', |
| 227 | + 'tf'=>'French Southern Territories', |
| 228 | + 'tg'=>'Togo', |
| 229 | + 'th'=>'Thailand', |
| 230 | + 'tj'=>'Tajikistan', |
| 231 | + 'tk'=>'Tokelau', |
| 232 | + 'ti'=>'East Timor (new code)', |
| 233 | + 'tm'=>'Turkmenistan', |
| 234 | + 'tn'=>'Tunisia', |
| 235 | + 'to'=>'Tonga', |
| 236 | + 'tp'=>'East Timor (old code)', |
| 237 | + 'tr'=>'Turkey', |
| 238 | + 'tt'=>'Trinidad And Tobago', |
| 239 | + 'tv'=>'Tuvalu', |
| 240 | + 'tw'=>'Taiwan', |
| 241 | + 'tz'=>'Tanzania, United Republic Of', |
| 242 | + 'ua'=>'Ukraine', |
| 243 | + 'ug'=>'Uganda', |
| 244 | + 'uk'=>'United Kingdom', |
| 245 | + 'um'=>'United States Minor Outlying Islands', |
| 246 | + 'us'=>'United States', |
| 247 | + 'uy'=>'Uruguay', |
| 248 | + 'uz'=>'Uzbekistan', |
| 249 | + 'va'=>'Vatican City State (Holy See)', |
| 250 | + 'vc'=>'Saint Vincent And The Grenadines', |
| 251 | + 've'=>'Venezuela', |
| 252 | + 'vg'=>'Virgin Islands (British)', |
| 253 | + 'vi'=>'Virgin Islands (U.S.)', |
| 254 | + 'vn'=>'Viet Nam', |
| 255 | + 'vu'=>'Vanuatu', |
| 256 | + 'wf'=>'Wallis And Futuna Islands', |
| 257 | + 'ws'=>'Samoa', |
| 258 | + 'ye'=>'Yemen', |
| 259 | + 'yt'=>'Mayotte', |
| 260 | + 'za'=>'South Africa', |
| 261 | + 'zm'=>'Zambia', |
| 262 | + 'zw'=>'Zimbabwe' |
| 263 | + ); |
| 264 | + |
| 265 | + $select = '<select name="'.$name.'" class="'.$class.'" style="min-width:350px">'; |
| 266 | + |
| 267 | + foreach ($countries as $abbr => $country) { |
| 268 | + $select .= '<option value="'.$abbr.'"'.($selected == $abbr ? ' selected="selected"' : '').'>'.$country.'</option> '; |
| 269 | + } |
| 270 | + |
| 271 | + $select .= '</select>'; |
| 272 | + |
| 273 | + return $select; |
| 274 | + |
| 275 | +}); |
0 commit comments