Browse Source

fixed issue with random titles and abstracts not returning 10 items

main
Simon Bowie 2 years ago
parent
commit
7a4bedb650
1 changed files with 8 additions and 3 deletions
  1. +8
    -3
      site/solr.php

+ 8
- 3
site/solr.php View File



function ten_random_titles ($core){ function ten_random_titles ($core){


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


foreach($random as $id => $content){ foreach($random as $id => $content){
// Search for the title in the content element and display it // Search for the title in the content element and display it
if (preg_match('/Title.*\n(.*)\n/', $content, $title)){ if (preg_match('/Title.*\n(.*)\n/', $content, $title)){
$output[$x] = array($id=>$title[1]); $output[$x] = array($id=>$title[1]);
++$x;
} }
} }
} }


function ten_random_abstracts ($core){ function ten_random_abstracts ($core){


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


foreach($random as $id => $content){ foreach($random as $id => $content){
// Search for the abstract in the content element and display it // Search for the abstract in the content element and display it
if (preg_match('/Abstract.*\n(.*)\n/', $content, $abstract)){ if (preg_match('/Abstract.*\n(.*)\n/', $content, $abstract)){
$output[$x] = array($id=>$abstract[1]); $output[$x] = array($id=>$abstract[1]);
++$x;
} }
elseif (preg_match('/\(.\) \\n\\n(.*)\\n/', $content, $abstract)) { elseif (preg_match('/\(.\) \\n\\n(.*)\\n/', $content, $abstract)) {
$output[$x] = array($id=>$abstract[1]); $output[$x] = array($id=>$abstract[1]);
++$x;
} }
} }
} }
function ten_random_doc_refs ($core){ function ten_random_doc_refs ($core){


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


foreach($random as $id => $content){ foreach($random as $id => $content){

Loading…
Cancel
Save