Syndetics
extends AbstractSyndetics
in package
Syndetics review content loader.
Tags
Table of Contents
- $sourceList : array<string|int, mixed>
- List of syndetic review sources
- $timeout : int
- HTTP timeout for API calls (in seconds)
- $usePlus : bool
- Use Syndetics plus?
- $useSSL : bool
- Use SSL URLs?
- __construct() : mixed
- Constructor
- loadByIsbn() : array<string|int, mixed>
- This method is responsible for connecting to Syndetics and abstracting reviews from multiple providers.
- debug() : void
- Log a debug message.
- getHttpClient() : Client
- Get an HTTP client
- getIsbn10() : string
- Attempt to get an ISBN-10; revert to ISBN-13 only when ISBN-10 representation is impossible.
- getIsbnUrl() : string
- Get the Syndetics URL for making a request.
- log() : void
- Send a message to the logger.
- logError() : void
- Log an error message.
- logWarning() : void
- Log a warning message.
- xmlToDOMDocument() : DOMDocument|bool
- Turn an XML response into a DOMDocument object.
Properties
$sourceList
List of syndetic review sources
protected
array<string|int, mixed>
$sourceList
= [
'CHREVIEW' => ['title' => 'Choice Review', 'file' => 'CHREVIEW.XML', 'div' => '<div id="syn_chreview"></div>'],
'NYREVIEW' => ['title' => 'New York Times Review', 'file' => 'NYREVIEW.XML', 'div' => '<div id="syn_nyreview"></div>'],
'BLREVIEW' => ['title' => 'Booklist Review', 'file' => 'BLREVIEW.XML', 'div' => '<div id="syn_blreview"></div>'],
'PWREVIEW' => ['title' => "Publisher's Weekly Review", 'file' => 'PWREVIEW.XML', 'div' => '<div id="syn_pwreview"></div>'],
'LJREVIEW' => ['title' => 'Library Journal Review', 'file' => 'LJREVIEW.XML', 'div' => '<div id="syn_ljreview"></div>'],
'SLJREVIEW' => ['title' => 'School Library Journal Review', 'file' => 'SLJREVIEW.XML', 'div' => '<div id="syn_sljreview"></div>'],
'HBREVIEW' => ['title' => 'Horn Book Review', 'file' => 'HBREVIEW.XML', 'div' => '<div id="syn_hbreview"></div>'],
'KIRKREVIEW' => ['title' => 'Kirkus Book Review', 'file' => 'KIRKREVIEW.XML', 'div' => '<div id="syn_kireview"></div>'],
'CRITICASREVIEW' => ['title' => 'Criticas Review', 'file' => 'CRITICASREVIEW.XML', 'div' => '<div id="syn_criticasreview"></div>'],
// These last two entries are probably typos -- retained for legacy
// compatibility just in case they're actually used for something!
'KIREVIEW' => ['title' => 'Kirkus Book Review', 'file' => 'KIREVIEW.XML'],
'CRITICASEREVIEW' => ['title' => 'Criti Case Review', 'file' => 'CRITICASEREVIEW.XML'],
]
$timeout
HTTP timeout for API calls (in seconds)
protected
int
$timeout
$usePlus
Use Syndetics plus?
protected
bool
$usePlus
$useSSL
Use SSL URLs?
protected
bool
$useSSL
Methods
__construct()
Constructor
public
__construct([bool $useSSL = false ][, bool $usePlus = false ][, int $timeout = 10 ]) : mixed
Parameters
- $useSSL : bool = false
-
Use SSL URLs?
- $usePlus : bool = false
-
Use Syndetics Plus?
- $timeout : int = 10
-
HTTP timeout for API calls (in seconds)
Return values
mixed —loadByIsbn()
This method is responsible for connecting to Syndetics and abstracting reviews from multiple providers.
public
loadByIsbn(string $key, ISBN $isbnObj) : array<string|int, mixed>
It first queries the master url for the ISBN entry seeking a review URL. If a review URL is found, the script will then use HTTP request to retrieve the script. The script will then parse the review according to US MARC (I believe). It will provide a link to the URL master HTML page for more information. Configuration: Sources are processed in order - refer to $sourceList above. If your library prefers one reviewer over another change the order. If your library does not like a reviewer, remove it. If there are more syndetics reviewers add another entry.
Parameters
- $key : string
-
API key (unused here)
- $isbnObj : ISBN
-
ISBN object
Tags
Return values
array<string|int, mixed> —Returns array with review data.
debug()
Log a debug message.
protected
debug(string $msg[, array<string|int, mixed> $context = [] ][, bool $prependClass = true ]) : void
Parameters
- $msg : string
-
Log message
- $context : array<string|int, mixed> = []
-
Log context
- $prependClass : bool = true
-
Prepend class name to message?
Return values
void —getHttpClient()
Get an HTTP client
protected
getHttpClient([string $url = null ]) : Client
Parameters
- $url : string = null
-
URL for client to use
Tags
Return values
Client —getIsbn10()
Attempt to get an ISBN-10; revert to ISBN-13 only when ISBN-10 representation is impossible.
protected
getIsbn10(ISBN $isbnObj) : string
Parameters
- $isbnObj : ISBN
-
ISBN object to convert
Return values
string —getIsbnUrl()
Get the Syndetics URL for making a request.
protected
getIsbnUrl(string $isbn, string $id[, string $file = 'index.xml' ][, string $type = 'rw12,h7' ]) : string
Parameters
- $isbn : string
-
ISBN to load
- $id : string
-
Client ID
- $file : string = 'index.xml'
-
File to request
- $type : string = 'rw12,h7'
-
Type parameter
Return values
string —log()
Send a message to the logger.
protected
log(string $level, string $message[, array<string|int, mixed> $context = [] ][, bool $prependClass = false ]) : void
Parameters
- $level : string
-
Log level
- $message : string
-
Log message
- $context : array<string|int, mixed> = []
-
Log context
- $prependClass : bool = false
-
Prepend class name to message?
Return values
void —logError()
Log an error message.
protected
logError(string $msg[, array<string|int, mixed> $context = [] ][, bool $prependClass = true ]) : void
Parameters
- $msg : string
-
Log message
- $context : array<string|int, mixed> = []
-
Log context
- $prependClass : bool = true
-
Prepend class name to message?
Return values
void —logWarning()
Log a warning message.
protected
logWarning(string $msg[, array<string|int, mixed> $context = [] ][, bool $prependClass = true ]) : void
Parameters
- $msg : string
-
Log message
- $context : array<string|int, mixed> = []
-
Log context
- $prependClass : bool = true
-
Prepend class name to message?
Return values
void —xmlToDOMDocument()
Turn an XML response into a DOMDocument object.
protected
xmlToDOMDocument(string $xml) : DOMDocument|bool
Parameters
- $xml : string
-
XML to load.
Return values
DOMDocument|bool —Document on success, false on failure.