Преглед на файлове

Added new function for ten random images

main
Simon Bowie преди 3 години
родител
ревизия
c3b347bb3f
променени са 3 файла, в които са добавени 66 реда и са изтрити 0 реда
  1. +4
    -0
      site/public/index.html
  2. +44
    -0
      site/public/random_images.php
  3. +18
    -0
      site/solr.php

+ 4
- 0
site/public/index.html Целия файл

@@ -54,6 +54,10 @@
<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>

<div class="row p-3">

+ 44
- 0
site/public/random_images.php Целия файл

@@ -0,0 +1,44 @@
<?php

# @name: random_images.php
# @version: 0.1
# @creation_date: 2021-10-12
# @license: The MIT License <https://opensource.org/licenses/MIT>
# @author: Simon Bowie <ad7588@coventry.ac.uk>
# @purpose: Displays ten random images

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

$random_doc_refs = ten_random_doc_refs();

?>

<!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">
<?php
foreach($random_doc_refs as $doc_ref):
?>

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

<br><br>

<?php
endforeach;
?>

</div>
</body>
</html>

+ 18
- 0
site/solr.php Целия файл

@@ -178,5 +178,23 @@ function ten_random_abstracts (){
return $output;
}

function ten_random_doc_refs (){

$x = 0;
while ($x < 9) {
$random = get_random_record();

foreach($random as $id => $content){
//Set document reference number (used for OPS API)
preg_match('/=D\s(([^\s]*)\s([^\s]*)\s([^\s]*))/', $content, $doc_ref);
$doc_ref = str_replace(' ','',$doc_ref[1]);
if (check_for_images($doc_ref)){
$output[$x] = $doc_ref;
++$x;
}
}
}
return $output;
}

?>

Loading…
Отказ
Запис