56 lines
2 KiB
PHP
56 lines
2 KiB
PHP
<?php
|
|
/**
|
|
* Station list template (card grid).
|
|
*
|
|
* @package FontdelboscCombustible
|
|
*/
|
|
|
|
declare( strict_types=1 );
|
|
|
|
defined( 'ABSPATH' ) || exit;
|
|
|
|
/**
|
|
* Template data.
|
|
*
|
|
* @var array{stations:array<int,array<mixed>>,fecha:string,stale:bool,radius:int,fuels:array<int>,fields:array<int,string>} $fontdelbosc_data
|
|
*/
|
|
?>
|
|
<div class="fdbc-list">
|
|
<?php if ( array() === $fontdelbosc_data['stations'] ) : ?>
|
|
<p class="fdbc-list__empty">
|
|
<?php
|
|
/* translators: %d: search radius in kilometers. */
|
|
echo esc_html( sprintf( __( 'No stations found within %d km.', 'fontdelbosc-combustible' ), $fontdelbosc_data['radius'] ) );
|
|
?>
|
|
</p>
|
|
<?php else : ?>
|
|
<ul class="fdbc-list__items">
|
|
<?php foreach ( $fontdelbosc_data['stations'] as $fontdelbosc_station ) : ?>
|
|
<li class="fdbc-list__item"><?php echo wp_kses_post( Fontdelbosc_Combustible_Shortcode::view( 'station-card', array( 'station' => $fontdelbosc_station ) ) ); ?></li>
|
|
<?php endforeach; ?>
|
|
</ul>
|
|
<?php endif; ?>
|
|
|
|
<?php if ( '' !== $fontdelbosc_data['fecha'] ) : ?>
|
|
<p class="fdbc-list__updated">
|
|
<?php
|
|
/* translators: %s: data timestamp from the API. */
|
|
echo esc_html( sprintf( __( 'Last update: %s', 'fontdelbosc-combustible' ), $fontdelbosc_data['fecha'] ) );
|
|
?>
|
|
<?php if ( $fontdelbosc_data['stale'] ) : ?>
|
|
<em><?php esc_html_e( 'Showing cached data.', 'fontdelbosc-combustible' ); ?></em>
|
|
<?php endif; ?>
|
|
</p>
|
|
<?php elseif ( array() === $fontdelbosc_data['stations'] ) : ?>
|
|
<p class="fdbc-list__updated"><?php esc_html_e( 'Data unavailable.', 'fontdelbosc-combustible' ); ?></p>
|
|
<?php endif; ?>
|
|
|
|
<details class="fdbc-list__source">
|
|
<summary><?php esc_html_e( 'Source: Ministry of Ecological Transition (MITECO), Spain.', 'fontdelbosc-combustible' ); ?></summary>
|
|
<p>
|
|
<a href="https://datos.gob.es/es/catalogo/e05068001-precio-de-carburantes-en-las-gasolineras-espanolas" rel="nofollow noopener" target="_blank">
|
|
<?php esc_html_e( 'Open data catalog (datos.gob.es)', 'fontdelbosc-combustible' ); ?>
|
|
</a>
|
|
</p>
|
|
</details>
|
|
</div>
|