<?php

/**
 * Implements hook_station_info_accordion_alter().
 */
function toc_sr_station_info_accordion_alter(&$accordion, $entity) {
  $accordion['items'] = [
    [
      'pid' => 'station_info_accordion',
      'aiid' => 'ticket_buying_collection',
      'label' => '<i class="far fa-ticket"></i> Ticket buying and collection',
      'content' => _toc_sr_nre_station_accordion_content_ticket_buying_collection($entity),
    ],
    [
      'pid' => 'station_info_accordion',
      'aiid' => 'help_support',
      'label' => '<i class="far fa-life-ring"></i> Help and support',
      'content' => _toc_sr_nre_station_accordion_content_help_support($entity),
    ],
    [
      'pid' => 'station_info_accordion',
      'aiid' => 'accessibility_support',
      'label' => '<i class="far fa-wheelchair"></i> Accessibility and support',
      'content' => _toc_sr_nre_station_accordion_content_accessibility_support($entity),
    ],
    [
      'pid' => 'station_info_accordion',
      'aiid' => 'toilets_baby_changing',
      'label' => '<i class="far fa-toilet"></i> Toilets and baby changing',
      'content' => _toc_sr_nre_station_accordion_content_toilets_baby_changing($entity),
    ],
    [
      'pid' => 'station_info_accordion',
      'aiid' => 'lounges_waiting_rooms',
      'label' => '<i class="far fa-newspaper"></i> Lounges and waiting rooms',
      'content' => _toc_sr_nre_station_accordion_content_lounges_waiting_rooms($entity),
    ],
    [
      'pid' => 'station_info_accordion',
      'aiid' => 'car_parking',
      'label' => '<i class="far fa-car"></i> Car parking',
      'content' => _toc_sr_nre_station_accordion_content_car_parking($entity),
    ],
    [
      'pid' => 'station_info_accordion',
      'aiid' => 'shopping',
      'label' => '<i class="far fa-coffee"></i> Shopping, food, drink and cash',
      'content' => _toc_sr_nre_station_accordion_content_shopping($entity),
    ],
    [
      'pid' => 'station_info_accordion',
      'aiid' => 'wifi_phones',
      'label' => '<i class="far fa-wifi"></i> Wi-fi, telephones and post',
      'content' => _toc_sr_nre_station_accordion_content_wifi_phones($entity),
    ],
    [
      'pid' => 'station_info_accordion',
      'aiid' => 'cycling',
      'label' => '<i class="far fa-bicycle"></i> Cycling',
      'content' => _toc_sr_nre_station_accordion_content_cycling($entity),
    ],
  ];
}

function _toc_sr_add_accordion_item(&$items, $entity, $content_func, $icon, $title) {
  $content = call_user_func($content_func, $entity);
  if ($content) {
    $items[] = [
      'pid' => 'station_info_accordion2',
      'aiid' => str_replace(' ', '_', strtolower($title)),
      'label' => '<i class="far fa-'. $icon .'"></i> '. $title,
      'content' => $content,
    ];
  }
}

function toc_sr_station_info_accordion2_alter(&$accordion, $entity) {
  $items = [];

  _toc_sr_add_accordion_item(
    $items,
    $entity,
    '_toc_sr_nre_station_accordion_content_rail_replacement',
    'bus',
    'Rail replacement service'
  );
  _toc_sr_add_accordion_item(
    $items,
    $entity,
    '_toc_sr_nre_station_accordion_content_taxi',
    'taxi',
    'Taxi'
  );
  _toc_sr_add_accordion_item(
    $items,
    $entity,
    '_toc_sr_nre_station_accordion_content_bus',
    'bus',
    'Bus'
  );
  _toc_sr_add_accordion_item(
    $items,
    $entity,
    '_toc_sr_nre_station_accordion_content_underground',
    'train',
    'Underground'
  );
  _toc_sr_add_accordion_item(
    $items,
    $entity,
    '_toc_sr_nre_station_accordion_content_airport',
    'plane',
    'Airport'
  );
  _toc_sr_add_accordion_item(
    $items,
    $entity,
    '_toc_sr_nre_station_accordion_content_port',
    'ship',
    'Port'
  );
  _toc_sr_add_accordion_item(
    $items,
    $entity,
    '_toc_sr_nre_station_accordion_content_car_hire',
    'car',
    'Car hire'
  );
  _toc_sr_add_accordion_item(
    $items,
    $entity,
    '_toc_sr_nre_station_accordion_content_bicycle_hire',
    'bicycle',
    'Bicycle hire'
  );

  $accordion['items'] = $items;

}
