Skip to content

Commit 119de23

Browse files
committed
new: [UI] Use flag icons from Twemoji
1 parent 8ab97c0 commit 119de23

File tree

263 files changed

+698
-9
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

263 files changed

+698
-9
lines changed

app/View/GalaxyElements/ajax/index.ctp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
<td class="short"><?= h($item['GalaxyElement']['key']); ?></td>
2828
<td class="short"><?php if ($item['GalaxyElement']['key'] === 'refs') {
2929
echo '<a href="' . h($item['GalaxyElement']['value']) . '" rel="noreferrer noopener">' . h($item['GalaxyElement']['value']) . '</a>';
30+
} else if ($item['GalaxyElement']['key'] === 'country') {
31+
echo $this->Icon->countryFlag($item['GalaxyElement']['value']) . ' ' . h($item['GalaxyElement']['value']);
3032
} else {
3133
echo h($item['GalaxyElement']['value']);
3234
}

app/View/Helper/IconHelper.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,30 @@
11
<?php
22
App::uses('AppHelper', 'View/Helper');
33

4-
class IconHelper extends AppHelper {
4+
class IconHelper extends AppHelper
5+
{
56
/**
67
* @param string $countryCode ISO 3166-1 alpha-2 two-letter country code
8+
* @param string $countryName Full country name for title
79
* @return string
810
*/
9-
public function countryFlag($countryCode)
11+
public function countryFlag($countryCode, $countryName = null)
1012
{
1113
if (strlen($countryCode) !== 2) {
1214
return '';
1315
}
1416

15-
return '<span class="famfamfam-flag-' . strtolower(h($countryCode)) . '" ></span>';
16-
/* Unicode version
17-
$output = '';
17+
$output = [];
1818
foreach (str_split(strtolower($countryCode)) as $letter) {
1919
$letterCode = ord($letter);
2020
if ($letterCode < 97 || $letterCode > 122) {
2121
return ''; // invalid letter
2222
}
23-
24-
// UTF-8 representation
25-
$output .= "\xF0\x9F\x87" . chr(0xa6 + ($letterCode - 97));
23+
$output[] = "1f1" . dechex(0xe6 + ($letterCode - 97));
2624
}
2725

28-
return $output;*/
26+
$baseurl = $this->_View->viewVars['baseurl'];
27+
$title = __('Flag of %s', strtoupper($countryName ? h($countryName) : $countryCode));
28+
return '<img src="' . $baseurl . '/img/flags/' . implode('-', $output) . '.svg" title="' . $title .'" alt="' . $title . '" aria-label="' . $title . '" style="height: 18px" />';
2929
}
3030
}

app/webroot/img/flags/1f1e6-1f1e8.svg

Lines changed: 1 addition & 0 deletions
Loading
Lines changed: 1 addition & 0 deletions
Loading
Lines changed: 1 addition & 0 deletions
Loading

app/webroot/img/flags/1f1e6-1f1eb.svg

Lines changed: 1 addition & 0 deletions
Loading
Lines changed: 1 addition & 0 deletions
Loading
Lines changed: 1 addition & 0 deletions
Loading

0 commit comments

Comments
 (0)