<?php

# @name: index.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: Home page for the application

include '../solr.php';

$cores = array("active", "expanding", "invisible", "multispecies", "pissing", "secret", "defending", "surviving", "working");

?>

<!DOCTYPE html>
<html lang="en">
<head>
  <title>Performing Patents Otherwise: Archival conversations with 320.000 clothing inventions</title>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <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>
  <link rel="stylesheet" type="text/css" href="css/style.css">
</head>
<body class="d-flex flex-column min-vh-100">

  <main class="flex-shrink-0">
    <div class="container-fluid p-5 my-5 border">
      <div class="row">
        <div class="col text-center">
          <p class="h1">Performing Patents Otherwise</p>
          <p class="h2">Archival conversations with 320,000 clothing inventions</p>
        </div>
      </div>

      <div class="row justify-content-center p-3">
        <div class="col-sm-6 text-center">
          <form action="search.php" method="POST">
            <input type="text" name="search" placeholder="search for a patent record">
            <input type="submit" id="submit" value="search">
          </form>
        </div>
      </div>

      <div class="row p-3">
        <div class="col text-center">
          <a href="./random.php">show a random record</a>
        </div>

        <div class="col text-center">
          <a href="./compare.php">compare two random records</a>
        </div>
      </div>

      <div class="row p-3">
        <div class="col text-center">
          <a href="./titles.php">ten random titles</a>
        </div>

        <div class="col text-center">
          <a href="./abstracts.php">ten random abstracts</a>
        </div>

        <div class="col text-center">
          <a href="./random_images.php">ten random images (takes a long time to load)</a>
        </div>
      </div>

      <?php
        foreach($cores as $core):
      ?>

      <div class="row p-3 m-3 border">
        <div class="col-1 border border-dark text-center verticaltext">
          <span class="text-uppercase"><?php echo $core; ?></span>
        </div>
        <div class="col-11">
          <div class="row p-3">
              <?php
                $random_record = one_random_record($core);
              ?>
              <a href="id_search.php?id=<? echo $random_record['id']; ?>&core=<? echo $core; ?>">
                <?php
                  if(isset($random_record['title'])){
                    echo $random_record['title'];
                  }
                ?>
              </a>
          </div>
          <div class="row p-3">
              <?php
                if(isset($random_record['abstract'])){
                  echo $random_record['abstract'];
                }
              ?>
          </div>
        </div>
      </div>

      <?php
        endforeach;
      ?>

    </div>
  </main>

  <footer class="footer py-3 mt-auto bg-light">
      <div class="container">
          <span class="text-muted">Data from the <a href="https://www.epo.org/">European Patent Office's</a> <a href="https://worldwide.espacenet.com/">Espacenet patent search engine</a> and reconfigured by Goldsmiths, University of London's Archival Conversations project.</span>
      </div>
  </footer>

</body>
</html>