VuFind API Documentation

AuthorInfo
in package
implements RecommendInterface, TranslatorAwareInterface Uses TranslatorAwareTrait

AuthorInfo Recommendations Module

This class gathers information from the Wikipedia API and publishes the results to a module at the top of an author's results page

Tags
category

VuFind

author

Chris Hallberg challber@villanova.edu

license

http://opensource.org/licenses/gpl-2.0.php GNU General Public License

link

Wiki

view

AuthorInfoFacets.phtml

Interfaces, Classes, Traits and Enums

RecommendInterface
Search Recommendations Interface
TranslatorAwareInterface
Lightweight translator aware marker interface (used as an alternative to \Laminas\I18n\Translator\TranslatorAwareInterface, which requires an excessive number of methods to be implemented).

Table of Contents

$client  : Client
HTTP client
$resultsManager  : PluginManager
Results plugin manager
$searchObject  : Results
Saved search results
$sources  : string
Sources of author data that may be used (comma-delimited string; currently only 'wikipedia' is supported).
$translator  : TranslatorInterface
Translator
$useViaf  : bool
Should we use VIAF for authorized names?
$wikipedia  : Wikipedia
Wikipedia client
__construct()  : mixed
Constructor
getAuthorInfo()  : array<string|int, mixed>
Returns info from Wikipedia to the view
getTranslator()  : TranslatorInterface
Get translator object.
getTranslatorLocale()  : string
Get the locale from the translator.
init()  : void
Called before the Search Results object performs its main search (specifically, in response to \VuFind\Search\SearchRunner::EVENT_CONFIGURED).
process()  : void
Called after the Search Results object has performed its main search. This may be used to extract necessary information from the Search Results object or to perform completely unrelated processing.
setConfig()  : void
Store the configuration of the recommendation module.
setTranslator()  : TranslatorAwareInterface
Set a translator
translate()  : string
Translate a string (or string-castable object)
translateWithPrefix()  : string
Translate a string (or string-castable object) using a prefix, or without the prefix if a prefixed translation is not found.
extractTextDomain()  : array<string|int, mixed>
Given a translation string with or without a text domain, return an array with the raw string and the text domain separated.
getAuthor()  : string
Takes the search term and extracts a normal name from it
getDebugTranslation()  : string
Build a debug-mode translation
getWikipediaNameFromViaf()  : string|bool
Translate an LCCN to a Wikipedia name through the VIAF web service. Returns false if no value can be found.
normalizeName()  : string
Normalize an author name using internal logic.
normalizeNameWithViaf()  : string
Normalize an author name using VIAF.
sanitizeTranslationKey()  : string
Make sure there are not any illegal characters in the translation key that might prevent successful lookup in language files.
translateString()  : string
Get translation for a string

Properties

$sources

Sources of author data that may be used (comma-delimited string; currently only 'wikipedia' is supported).

protected string $sources

$useViaf

Should we use VIAF for authorized names?

protected bool $useViaf = false

Methods

__construct()

Constructor

public __construct(PluginManager $results, Client $client[, string $sources = 'wikipedia' ]) : mixed
Parameters
$results : PluginManager

Results plugin manager

$client : Client

HTTP client

$sources : string = 'wikipedia'

Source identifiers (currently, only 'wikipedia' is supported)

Return values
mixed

getAuthorInfo()

Returns info from Wikipedia to the view

public getAuthorInfo() : array<string|int, mixed>
Tags
reference

_parseWikipedia : Home.php (VuFind 1)

refauthor

Rushikesh Katikar rushikesh.katikar@gmail.com

Return values
array<string|int, mixed>

info = { 'description' : string : extracted/formatted Wikipedia text 'image' : string : url of the Wikipedia page's image 'altimge' : string : alt text for the image 'name' : string : title of Wikipedia article 'wiki_lang' : string : truncated from the lang. settings }

getTranslator()

Get translator object.

public getTranslator() : TranslatorInterface
Return values
TranslatorInterface

getTranslatorLocale()

Get the locale from the translator.

public getTranslatorLocale([string $default = 'en' ]) : string
Parameters
$default : string = 'en'

Default to use if translator absent.

Return values
string

init()

Called before the Search Results object performs its main search (specifically, in response to \VuFind\Search\SearchRunner::EVENT_CONFIGURED).

public init(Params $params, Parameters $request) : void

This method is responsible for setting search parameters needed by the recommendation module and for reading any existing search parameters that may be needed.

Parameters
$params : Params

Search parameter object

$request : Parameters

Parameter object representing user request.

Return values
void

process()

Called after the Search Results object has performed its main search. This may be used to extract necessary information from the Search Results object or to perform completely unrelated processing.

public process(Results $results) : void
Parameters
$results : Results

Search results object

Return values
void

setConfig()

Store the configuration of the recommendation module.

public setConfig(string $settings) : void
Parameters
$settings : string

Settings from searches.ini.

Return values
void

translate()

Translate a string (or string-castable object)

public translate(string|object|array<string|int, mixed> $target[, array<string|int, mixed> $tokens = [] ][, string $default = null ][, bool $useIcuFormatter = false ][, array<string|int, string> $fallbackDomains = [] ]) : string
Parameters
$target : string|object|array<string|int, mixed>

String to translate or an array of text domain and string to translate

$tokens : array<string|int, mixed> = []

Tokens to inject into the translated string

$default : string = null

Default value to use if no translation is found (null for no default).

$useIcuFormatter : bool = false

Should we use an ICU message formatter instead of the default behavior?

$fallbackDomains : array<string|int, string> = []

Text domains to check if no match is found in the domain specified in $target

Return values
string

translateWithPrefix()

Translate a string (or string-castable object) using a prefix, or without the prefix if a prefixed translation is not found.

public translateWithPrefix(string $prefix, string|object|array<string|int, mixed> $target[, array<string|int, mixed> $tokens = [] ][, string $default = null ][, bool $useIcuFormatter = false ][, array<string|int, string> $fallbackDomains = [] ]) : string
Parameters
$prefix : string

Translation key prefix

$target : string|object|array<string|int, mixed>

String to translate or an array of text domain and string to translate

$tokens : array<string|int, mixed> = []

Tokens to inject into the translated string

$default : string = null

Default value to use if no translation is found (null for no default).

$useIcuFormatter : bool = false

Should we use an ICU message formatter instead of the default behavior?

$fallbackDomains : array<string|int, string> = []

Text domains to check if no match is found in the domain specified in $target

Return values
string

extractTextDomain()

Given a translation string with or without a text domain, return an array with the raw string and the text domain separated.

protected extractTextDomain(string|object|array<string|int, mixed> $target) : array<string|int, mixed>
Parameters
$target : string|object|array<string|int, mixed>

String to translate or an array of text domain and string to translate

Return values
array<string|int, mixed>

getAuthor()

Takes the search term and extracts a normal name from it

protected getAuthor() : string
Return values
string

getDebugTranslation()

Build a debug-mode translation

protected getDebugTranslation(string $domain, string $str, array<string|int, mixed> $tokens) : string
Parameters
$domain : string

Text domain

$str : string

String to translate

$tokens : array<string|int, mixed>

Tokens to inject into the translated string

Return values
string

getWikipediaNameFromViaf()

Translate an LCCN to a Wikipedia name through the VIAF web service. Returns false if no value can be found.

protected getWikipediaNameFromViaf(string $lccn) : string|bool
Parameters
$lccn : string

LCCN

Return values
string|bool

normalizeName()

Normalize an author name using internal logic.

protected normalizeName(string $author) : string
Parameters
$author : string

Author name

Return values
string

normalizeNameWithViaf()

Normalize an author name using VIAF.

protected normalizeNameWithViaf(string $author) : string
Parameters
$author : string

Author name

Return values
string

sanitizeTranslationKey()

Make sure there are not any illegal characters in the translation key that might prevent successful lookup in language files.

protected sanitizeTranslationKey(string $key) : string
Parameters
$key : string

Key to sanitize

Return values
string

Sanitized key

translateString()

Get translation for a string

protected translateString(string $rawStr[, array<string|int, mixed> $tokens = [] ][, string $default = null ][, string $domain = 'default' ][, bool $useIcuFormatter = false ]) : string
Parameters
$rawStr : string

String to translate

$tokens : array<string|int, mixed> = []

Tokens to inject into the translated string

$default : string = null

Default value to use if no translation is found (null for no default).

$domain : string = 'default'

Text domain (omit for default)

$useIcuFormatter : bool = false

Should we use an ICU message formatter instead of the default behavior?

Return values
string

Search results