$name = trim(strip_tags(\MartinLindhe\MediawikiClient\Client::stripMediawikiLinks($cols[3]))); $name = stripTrailingMediawikiTag($name); $pos = strpos($name, '/'); if ($pos !== false) { $name = substr($name, 0, $pos); } $pos = strpos($name, '|'); if ($pos !== false) { $name = substr($name, $pos + 1); } $o->name = trim($name); // HACK $cols[4] = str_replace('[[Caribbean Netherlands]] (BQ - Bonaire, Sint Eustatius and Saba)', 'Caribbean Netherlands', $cols[4]); $countries = []; foreach (explode(', ', $cols[4]) as $c) { $c = \MartinLindhe\MediawikiClient\Client::stripMediawikiLinks($c); $c = trim(getRightSideOfMediawikiTag($c)); if (!$c) { continue; } $code = countryCodeFromName($c, $allCountries); if (!$code) { err("WARNING: didn't find country code to " . $c); } else { $countries[] = $code; } } $o->countries = $countries; $list[] = $o; } if (!isAlpha3InList('BTC', $list)) {
if (!$rows[$i]) { continue; } $cols = explode('||', $rows[$i]); if (count($cols) == 1) { $name = $rows[$i]; $i++; $rows[$i] = cleanText($rows[$i]); $cols = explode('||', $rows[$i]); } $o = new \MartinLindhe\Data\Countries\Country(); $o->alpha2 = getRightSideOfMediawikiTag($cols[0]); $o->alpha3 = getRightSideOfMediawikiTag($cols[1]); $o->number = getRightSideOfMediawikiTag($cols[2]); $name = cleanText($name); $name = getRightSideOfMediawikiTag(\MartinLindhe\MediawikiClient\Client::stripMediawikiLinks($name)); $pos = mb_strpos($name, '/'); if ($pos !== false) { $name = mb_substr($name, 0, $pos); } $pos = mb_strpos($name, '|'); if ($pos !== false) { $name = mb_substr($name, $pos + 1); } $o->name = trim(translateName($name)); $list[] = $o; } // aug 2015: Kosovo has a temporary "XK" code since 2010 $o = new \MartinLindhe\Data\Countries\Country(); $o->alpha2 = 'XK'; $o->alpha3 = 'XKO';