瀏覽代碼

more error-handling and fixing some PHP errors

main
Simon Bowie 2 年之前
父節點
當前提交
930b709141
共有 2 個檔案被更改,包括 22 行新增7 行删除
  1. +14
    -6
      site/ops_api.php
  2. +8
    -1
      site/public/random.php

+ 14
- 6
site/ops_api.php 查看文件

@@ -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 查看文件

@@ -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…
取消
儲存