<?php

# @name: random.php
# @version: 0.1
# @creation_date: 2021-09-24
# @license: The MIT License <https://opensource.org/licenses/MIT>
# @author: Simon Bowie <ad7588@coventry.ac.uk>
# @purpose: Displays a random record from the Solr index

include '../solr.php';
include '../ops_api.php';

$random_record = one_random_record();

?>

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" type="text/css" href="css/style.css">
  <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
  <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-ka7Sk0Gln4gmtz2MlQnikT1wXgYsOg+OMhuP+IlRH9sENBO0LRn5q+8nbTov4+1p" crossorigin="anonymous"></script>
</head>
<body>

  <div class="container-fluid">
  Application ID:

  <?php
  echo $random_record['application_id'];
  ?>

  <br><br>

  EPO publication:

  <a href=<?php echo $random_record['epo_publication_url']; ?>>
    <?php
    echo $random_record['epo_publication_url'];
    ?>
  </a>

  <br><br>

  IPC publication:

  <a href=<?php echo $random_record['ipc_publication_url']; ?>>
    <?php
    echo $random_record['ipc_publication_url'];
    ?>
  </a>

  <br><br>

  Title:

  <?php
  echo $random_record['title'];
  ?>

  <br><br>

  <?php
  if ($random_record['abstract']):
  ?>

  Abstract:

    <?php
    echo $random_record['abstract'];
    ?>

  <br><br>

  <?
  endif;
  ?>

  <?php
    $publication_details = get_publication_details($random_record['doc_ref']);

    if (isset($publication_details['original_title'])):
  ?>

    Original language title:

    <?php
    echo $publication_details['original_title'];
    ?>

    <br><br>

  <?php
    endif;
  ?>

  <?php
    if (isset($publication_details['original_abstract'])):
  ?>

    Original language abstract:

    <?php
    echo $publication_details['original_abstract'];
    ?>

    <br><br>

  <?php
    endif;
  ?>


  <?php
    if (check_for_images($random_record['doc_ref'])):
  ?>

  <iframe src="./ops_image.php?doc_ref=<?php echo $random_record['doc_ref'] ?>" width="100%" height="500px">
  </iframe>

  <br><br>

  <?php
    endif;
  ?>
  </div>
</body>
</html>