Tripal
Loading...
Searching...
No Matches
Public Member Functions | Protected Attributes | List of all members
Drupal\tripal\Services\TripalCitationManager Class Reference

Public Member Functions

 __construct (TripalTokenParser $token_parser)
 
 generateCitation (string $format, array $values)
 
 getDefaultCitationTemplate (string $pub_type)
 

Protected Attributes

 $token_parser = NULL
 

Detailed Description

Generates citations for publications.

The citation manager class is used to generate citations for publications of various types. The primary function is generateCitation(), and input consists of two parts, a citation template containing various tokens in a particular order with appropriate punctuation, and an associative array of key => value pairs that will be used to replace the tokens in the template.

This class can also provide default templates for several types of publications. See getDefaultCitationTemplate() for the types of publications supported.

Constructor & Destructor Documentation

◆ __construct()

Drupal\tripal\Services\TripalCitationManager::__construct ( TripalTokenParser  $token_parser)

TripalCitationManager constructor.

Parameters

Drupal\tripal\Services\TripalTokenParser The token parser service.

Member Function Documentation

◆ generateCitation()

Drupal\tripal\Services\TripalCitationManager::generateCitation ( string  $format,
array  $values 
)

Generate citation

Parameters
string$formatA token string defining fields used to generate the citation. Tokens are text enclosed in square brackets, e.g. "[Title]" Tokens may be "doubled" inside another set of square brackets to indicate a prefix or suffix that is only added if the token has a value. For example, a journal may not have issue numbers. Thus, for "[ [Volume]][([Issue])][:[Pages].]", if there is no issue number, then the parentheses will not be included.
array$valuesAn associative array defining the publication properties used to replace the tokens. The keys are the case-sensitive name of the token and the value is the value of that property.
Returns
string The citation which is the result of the $format string with all tokens replaced by the value provided in $values.

◆ getDefaultCitationTemplate()

Drupal\tripal\Services\TripalCitationManager::getDefaultCitationTemplate ( string  $pub_type)

Provides a default format string based on publication type.

To use, call this method with the publication type and then pass in the result as the format string for generateCitation().

Parameters
string$pub_typeThe publication type. This is the name, not the term accession. Supported types include:
  • Journal Article
  • Review
  • Research Support, Non-U.S. Gov't
  • Letter
  • Conference Proceedings
  • Book
  • Book Chapter
Returns
string The citation format for this publication type or the default format if the type is not supported. Includes tokens for use with generateCitation().

Member Data Documentation

◆ $token_parser

Drupal tripal Services TripalTokenParser Drupal\tripal\Services\TripalCitationManager::$token_parser = NULL
protected

The Tripal Token Parser service.


The documentation for this class was generated from the following file: