mirror of https://github.com/MISP/MISP
chg: [UI] Use IconHelper for flag icons
parent
813a475f4a
commit
8ab97c074b
|
@ -38,7 +38,7 @@
|
|||
} else if($cluster_field['key'] == 'country') {
|
||||
$value = array();
|
||||
foreach ($cluster_field['value'] as $k => $v) {
|
||||
$value[] = '<div class="famfamfam-flag-' . strtolower(h($v)) . '" ></div> ' . h($v);
|
||||
$value[] = $this->Icon->countryFlag($v) . ' ' . h($v);
|
||||
}
|
||||
$dataValue .= nl2br(implode("\n", $value));
|
||||
} else {
|
||||
|
|
|
@ -45,7 +45,7 @@
|
|||
} else if($cluster_field['key'] == 'country') {
|
||||
$value = array();
|
||||
foreach ($cluster_field['value'] as $k => $v) {
|
||||
$value[] = '<span class="famfamfam-flag-' . strtolower(h($v)) . '" ></span> ' . h($v);
|
||||
$value[] = $this->Icon->countryFlag($v) . ' ' . h($v);
|
||||
}
|
||||
$value_contents = nl2br(implode("\n", $value));
|
||||
} else {
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
<?php
|
||||
App::uses('AppHelper', 'View/Helper');
|
||||
|
||||
class IconHelper extends AppHelper {
|
||||
/**
|
||||
* @param string $countryCode ISO 3166-1 alpha-2 two-letter country code
|
||||
* @return string
|
||||
*/
|
||||
public function countryFlag($countryCode)
|
||||
{
|
||||
if (strlen($countryCode) !== 2) {
|
||||
return '';
|
||||
}
|
||||
|
||||
return '<span class="famfamfam-flag-' . strtolower(h($countryCode)) . '" ></span>';
|
||||
/* Unicode version
|
||||
$output = '';
|
||||
foreach (str_split(strtolower($countryCode)) as $letter) {
|
||||
$letterCode = ord($letter);
|
||||
if ($letterCode < 97 || $letterCode > 122) {
|
||||
return ''; // invalid letter
|
||||
}
|
||||
|
||||
// UTF-8 representation
|
||||
$output .= "\xF0\x9F\x87" . chr(0xa6 + ($letterCode - 97));
|
||||
}
|
||||
|
||||
return $output;*/
|
||||
}
|
||||
}
|
|
@ -119,7 +119,7 @@ foreach ($orgs as $org): ?>
|
|||
<td ondblclick="document.location.href ='<?php echo $baseurl . "/organisations/view/" . $org['Organisation']['id'];?>'"><?php echo h($org['Organisation']['description']); ?></td>
|
||||
<td class="short" ondblclick="document.location.href ='<?php echo $baseurl . "/organisations/view/" . $org['Organisation']['id'];?>'"><?php
|
||||
if (isset($org['Organisation']['country_code'])) {
|
||||
echo '<span class="famfamfam-flag-' . strtolower(h($org['Organisation']['country_code'])) . '" ></span> ';
|
||||
echo $this->Icon->countryFlag($org['Organisation']['country_code']) . ' ';
|
||||
}
|
||||
if ($org['Organisation']['nationality'] !== 'Not specified') {
|
||||
echo h($org['Organisation']['nationality']);
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
if (!empty(trim($org['Organisation']['nationality']))) {
|
||||
$html = '';
|
||||
if (isset($org['Organisation']['country_code'])) {
|
||||
$html .= '<span class="famfamfam-flag-' . strtolower(h($org['Organisation']['country_code'])) . '" ></span> ';
|
||||
$html .= $this->Icon->countryFlag($org['Organisation']['country_code']) . ' ';
|
||||
}
|
||||
$html .= trim(h($org['Organisation']['nationality']));
|
||||
$table_data[] = array(
|
||||
|
|
Loading…
Reference in New Issue