Browse Source

more error-handling and fixing some PHP errors

main
Simon Bowie 2 years ago
parent
commit
930b709141
2 changed files with 22 additions and 7 deletions
  1. +14
    -6
      site/ops_api.php
  2. +8
    -1
      site/public/random.php

+ 14
- 6
site/ops_api.php View File

@@ -62,22 +62,30 @@ function get_publication_details($document_reference) {
$json = json_decode($response);

// For each invention title, check if it's in the original language
foreach ($json->{'ops:world-patent-data'}->{'exchange-documents'}->{'exchange-document'}->{'bibliographic-data'}->{'invention-title'} as $invention_title){
if (isset($json->{'ops:world-patent-data'}->{'exchange-documents'}->{'exchange-document'}->{'bibliographic-data'}->{'invention-title'})){

if ((isset($invention_title->{'@lang'})) && ($invention_title->{'@lang'} === 'ol')){
foreach ($json->{'ops:world-patent-data'}->{'exchange-documents'}->{'exchange-document'}->{'bibliographic-data'}->{'invention-title'} as $invention_title){

$output['original_title'] = $invention_title->{'$'};
if ((isset($invention_title->{'@lang'})) && ($invention_title->{'@lang'} === 'ol')){

$output['original_title'] = $invention_title->{'$'};

}

}

}

// For each abstract, check if it's in the original language
foreach ($json->{'ops:world-patent-data'}->{'exchange-documents'}->{'exchange-document'}->{'abstract'} as $abstract){
if (isset($json->{'ops:world-patent-data'}->{'exchange-documents'}->{'exchange-document'}->{'abstract'})){

foreach ($json->{'ops:world-patent-data'}->{'exchange-documents'}->{'exchange-document'}->{'abstract'} as $abstract){

if ((isset($abstract->{'@lang'})) && ($abstract->{'@lang'} === 'ol')){

if ((isset($abstract->{'@lang'})) && ($abstract->{'@lang'} === 'ol')){
$output['original_abstract'] = $abstract->p->{'$'};

$output['original_abstract'] = $abstract->p->{'$'};
}

}


+ 8
- 1
site/public/random.php View File

@@ -58,6 +58,10 @@ $publication_details = get_publication_details($random_record['doc_ref']);

<br><br>

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

Title:

<?php
@@ -67,7 +71,10 @@ $publication_details = get_publication_details($random_record['doc_ref']);
<br><br>

<?php
endif;
?>

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

@@ -84,7 +91,7 @@ $publication_details = get_publication_details($random_record['doc_ref']);
?>

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

Abstract:

Loading…
Cancel
Save