['name' => __('Other / not set', 'domopage'), 'energy' => false, 'note' => ''],
'ES' => ['name' => 'España', 'energy' => true, 'note' => __('Spain: ads must show the energy rating (Real Decreto 390/2021). Catalonia (AICAT) and Valencia (RAICV) also require the agency register number.', 'domopage')],
'PT' => ['name' => 'Portugal', 'energy' => true, 'note' => __('Portugal: ads must show the energy class from the energy certificate (SCE).', 'domopage')],
'FR' => ['name' => 'France', 'energy' => true, 'note' => __('France: ads must show the DPE energy class and GES emissions class, and the agency fees if paid by the buyer.', 'domopage')],
'IT' => ['name' => 'Italia', 'energy' => true, 'note' => __('Italy: ads must show the APE energy class and the energy performance index.', 'domopage')],
'DE' => ['name' => 'Deutschland', 'energy' => true, 'note' => __('Germany: ads must state the energy certificate type, energy figure, main heating fuel, build year and efficiency class (GEG §87).', 'domopage')],
'NL' => ['name' => 'Nederland', 'energy' => true, 'note' => __('Netherlands: the energy label must be available to buyers and is normally shown in ads.', 'domopage')],
'BE' => ['name' => 'Belgique / België', 'energy' => true, 'note' => __('Belgium: ads must show the EPC score and label (rules differ by region).', 'domopage')],
'GB' => ['name' => 'United Kingdom', 'energy' => true, 'note' => __('United Kingdom: an EPC must be commissioned before marketing and the rating shown on listings.', 'domopage')],
'IE' => ['name' => 'Ireland', 'energy' => true, 'note' => __('Ireland: ads must show the BER rating.', 'domopage')],
];
}
function domo_energy_classes(): array
{
return ['A' => '#00843d', 'B' => '#3aa935', 'C' => '#b4cf1c', 'D' => '#fff200', 'E' => '#fdb913', 'F' => '#f37021', 'G' => '#e21f26'];
}
/** True when the configured country requires an energy rating and the page has none. */
function domo_energy_missing(array $d): bool
{
$country = domo_settings()['country'];
return !empty(domo_countries()[$country]['energy']) && empty($d['energy_rating']);
}
/** The standard A–G scale as an accessible inline SVG, with the property's class marked. */
function domo_energy_label_svg(string $rating, string $lang): string
{
$classes = domo_energy_classes();
$title = domo_t('energy', $lang) . ': ' . ($rating === 'pending' ? domo_t('energy_pending', $lang) : ($rating === 'exempt' ? domo_t('energy_exempt', $lang) : $rating));
$rows = '';
$i = 0;
foreach ($classes as $letter => $color) {
$y = $i * 15;
$w = 46 + $i * 12;
$dark = in_array($letter, ['C', 'D', 'E'], true) ? '#1a1a1a' : '#ffffff';
$rows .= sprintf('%6$s', $y, $w, $color, $y + 10, $dark, $letter);
if ($letter === $rating) {
$rows .= sprintf('%3$s', $y, $y + 10, $letter);
}
$i++;
}
return '';
}