GRIS_CITE
in package
Class for citations
With this class different citation and export formats can be built.
PHP version 7
Copyright (c) 2012, Holger Heuser, GESIS Leibniz Institute for the Social Sciences Unter Sachsenhausen 6-8 50667 Cologne, Germany
Tags
Table of Contents
- settings_group = "cite"
- The constant for the settings group
- $classname : object
- The name of the class
- $cache_time : int
- The time to serve data from the cache
- $citations : array<string|int, mixed>
- The array for all citations
- $dbconnection : object
- The database object
- $i18n : object
- The object for translations
- $internal : bool
- The switch between internal and external view (with less information)
- $links : string
- The citation or export style
- $settings : object
- The object for settings
- $style : string
- The citation or export style
- __construct() : mixed
- The class constructor
- add_accesstype() : string
- Adds the access type
- add_citation() : bool
- Adds a new citation to the list
- add_contributiontype() : string
- Adds a conference contribution type
- add_edition() : string
- Adds an edition
- add_eventtype() : string
- Adds an event type
- add_text() : true
- Adds a text (e.g. a headline) to the list
- connect_list() : string
- Connects a list of words with a given connector
- connect_words() : string
- Connects two words with a given connector
- delete_cache() : Returns
- Deletes all cache entries for a ressouce
- export_citation() : string
- Returns a resource in an export format (e.g. endnote or bibtex)
- format_date() : string
- Formats a date (or two dates as a compact date range)
- format_identifiers() : string
- Formats the identifiers of a resource
- get_citation_cache() : mixed
- Undocumented function
- get_citation_list() : string
- Returns the complete list
- renew_cache() : Returns
- Renew all cache entries for a ressouce
- reset_list() : true
- Resets the citation list
- set_citation_cache() : mixed
- Undocumented function
- set_internal() : true
- Sets the internal view switch
- use_either() : string
- Returns word 1 only if word 2 is empty. Otherwise word 2 is returned
- add_internal() : string
- Adds additional information for internal lists
- array_push_nonempty() : null
- Pushes data in an array if it is not empty or not unset
- close() : string
- Closes the content with a given character or word
- em() : string
- Emphasizes the content with a given tag (taken from settings)
- format_year() : string
- Formats the publication year depending on forthcoming value
- generate_initials() : string
- Generates initials from firstnames for apa references
- get_first_person_name() : string
- Returns the last name of the first author
- get_institute() : string
- Returns institute name (optional) & city and country name from institute id
- link() : string
- Creates a hyperlink from a given URL, URN or DOI
- person_list() : string
- Returns a formatted list of persons in the specified (or default) citation style
- remap() : string
- Remaps the content according to a given mapping table
- wrap() : string
- Wraps the content with a given string
Constants
settings_group
The constant for the settings group
public
mixed
settings_group
= "cite"
Properties
$classname
The name of the class
protected
object
$classname
= NULL
Tags
$cache_time
The time to serve data from the cache
private
int
$cache_time
Tags
$citations
The array for all citations
private
array<string|int, mixed>
$citations
Tags
$dbconnection
The database object
private
object
$dbconnection
Tags
$i18n
The object for translations
private
object
$i18n
Tags
$internal
The switch between internal and external view (with less information)
private
bool
$internal
Tags
$links
The citation or export style
private
string
$links
Tags
$settings
The object for settings
private
object
$settings
Tags
$style
The citation or export style
private
string
$style
Tags
Methods
__construct()
The class constructor
public
__construct() : mixed
Initializes the citation class
Return values
mixed —add_accesstype()
Adds the access type
public
add_accesstype(string $accesstype) : string
Parameters
- $accesstype : string
-
The (open) access type
Return values
string —add_citation()
Adds a new citation to the list
public
add_citation(object $resource[, bool $output = false ][, bool $hyperlinks = false ]) : bool
Parameters
- $resource : object
-
The complete resource data
- $output : bool = false
-
Returns the entry (if false entry is only added to the array)
- $hyperlinks : bool = false
-
Add a hyperlink to the citation
Return values
bool —Can also return the last entry itself if $output is set true
add_contributiontype()
Adds a conference contribution type
public
add_contributiontype(string $contributiontype, string $resource_type[, string $english = false ]) : string
Parameters
- $contributiontype : string
-
contributiontype
- $resource_type : string
-
resource_type
- $english : string = false
-
English citation form (for APA-Style) (optional)
Return values
string —add_edition()
Adds an edition
public
add_edition(string $edition_number[, bool $english = false ]) : string
Parameters
- $edition_number : string
-
Edition number
- $english : bool = false
-
English citation form (for APA-Style) (optional)
Return values
string —add_eventtype()
Adds an event type
public
add_eventtype(string $eventtype[, string $english = false ]) : string
Parameters
- $eventtype : string
-
eventtype
- $english : string = false
-
English citation form (for APA-Style) (optional)
Return values
string —add_text()
Adds a text (e.g. a headline) to the list
public
add_text(string $text) : true
Parameters
- $text : string
-
The text
Return values
true —(or false on error)
connect_list()
Connects a list of words with a given connector
public
connect_list(array<string|int, mixed> $list, string $connector) : string
Parameters
- $list : array<string|int, mixed>
-
The list of words
- $connector : string
-
The connector between the words
Return values
string —The connected words
connect_words()
Connects two words with a given connector
public
connect_words(string $word_1, string $word_2, string $connector[, string $parts = 3 ]) : string
Parameters
- $word_1 : string
-
The first word
- $word_2 : string
-
The second word
- $connector : string
-
The connector between the words
- $parts : string = 3
-
The definition of mandatory parts (connect if: 0 always, 1 only if left exists, 2 only if right exists, 3 only if both exist, 4 always add connector)
Return values
string —The connected words
delete_cache()
Deletes all cache entries for a ressouce
public
delete_cache(mixed $resource_id) : Returns
Parameters
- $resource_id : mixed
Return values
Returns —true for success oder false if no resource object found
export_citation()
Returns a resource in an export format (e.g. endnote or bibtex)
public
export_citation(object $resource[, string $export_style = NULL ]) : string
Parameters
- $resource : object
-
The resource object
- $export_style : string = NULL
-
The export style
Return values
string —The complete list
format_date()
Formats a date (or two dates as a compact date range)
public
format_date(string $date[, string $enddate = NULL ][, bool $english = false ]) : string
Parameters
- $date : string
-
The date
- $enddate : string = NULL
-
An enddate (optional)
- $english : bool = false
-
English citation form (for APA-Style) (optional)
Return values
string —The formatted date
format_identifiers()
Formats the identifiers of a resource
public
format_identifiers(string $identifiers) : string
Parameters
- $identifiers : string
-
The identifiers of a resource
Return values
string —The formatted identifier string
get_citation_cache()
Undocumented function
public
get_citation_cache(int $resource_id, mixed $link, bool $internal) : mixed
Parameters
- $resource_id : int
-
The resource ID
- $link : mixed
- $internal : bool
-
Show internal list with more information in scheme (e. g. referred)
Return values
mixed —Returns the citation oder false, if not found
get_citation_list()
Returns the complete list
public
get_citation_list() : string
Return values
string —The complete list
renew_cache()
Renew all cache entries for a ressouce
public
renew_cache(object $resource) : Returns
Parameters
- $resource : object
Return values
Returns —true for success oder false if no resource object found
reset_list()
Resets the citation list
public
reset_list() : true
Return values
true —set_citation_cache()
Undocumented function
public
set_citation_cache(int $resource_id, mixed $link, bool $internal, mixed $citation) : mixed
Parameters
- $resource_id : int
-
The resource ID
- $link : mixed
- $internal : bool
-
Show internal list with more information in scheme (e. g. referred)
- $citation : mixed
Return values
mixed —Returns the citation oder false, if not found
set_internal()
Sets the internal view switch
public
set_internal([bool $value = true ]) : true
Parameters
- $value : bool = true
-
The value of internal view
Return values
true —use_either()
Returns word 1 only if word 2 is empty. Otherwise word 2 is returned
public
use_either(string $word_1, string $word_2) : string
Parameters
- $word_1 : string
-
The first word
- $word_2 : string
-
The second word
Return values
string —The word
add_internal()
Adds additional information for internal lists
private
add_internal(array<string|int, mixed> $fields) : string
Parameters
- $fields : array<string|int, mixed>
-
The additional fields to add if the list is internal
Return values
string —The additional entry
array_push_nonempty()
Pushes data in an array if it is not empty or not unset
private
array_push_nonempty(array<string|int, mixed> &$array, string $value) : null
Parameters
- $array : array<string|int, mixed>
-
The array to push the data (passed by reference)
- $value : string
-
The value to push
Return values
null —close()
Closes the content with a given character or word
private
close(string $content[, string $char = ". " ]) : string
Parameters
- $content : string
-
The content
- $char : string = ". "
-
The character or word (default is ". ")
Return values
string —The closed content
em()
Emphasizes the content with a given tag (taken from settings)
private
em(string $content) : string
Parameters
- $content : string
-
The content
Return values
string —The emphasized words
format_year()
Formats the publication year depending on forthcoming value
private
format_year(string $year, string $forthcoming) : string
Parameters
- $year : string
-
The year of publication
- $forthcoming : string
-
The entry of the forthcoming checkbox
Return values
string —The formatted year
generate_initials()
Generates initials from firstnames for apa references
private
generate_initials(string $firstname) : string
Parameters
- $firstname : string
-
The firstname to generate initials from
Return values
string —The initials from firstname
get_first_person_name()
Returns the last name of the first author
private
get_first_person_name(array<string|int, mixed> $persons) : string
Parameters
- $persons : array<string|int, mixed>
-
An 2 dimensional array with person names
Return values
string —The last name of the first author
get_institute()
Returns institute name (optional) & city and country name from institute id
private
get_institute(int $id[, bool $show_name = true ]) : string
Parameters
- $id : int
-
The ID of the institute
- $show_name : bool = true
-
APA-Style: Display the institute name in front of city and country (default: true)
Return values
string —The Institute and the city
link()
Creates a hyperlink from a given URL, URN or DOI
private
link(string $address[, string $type = "URL" ]) : string
Parameters
- $address : string
-
The address
- $type : string = "URL"
-
The type of the link
Return values
string —The complete hyperlink
person_list()
Returns a formatted list of persons in the specified (or default) citation style
private
person_list(array<string|int, mixed> $persons[, string $style = NULL ][, string $english = false ]) : string
Parameters
- $persons : array<string|int, mixed>
-
An 2 dimensional array with person names
- $style : string = NULL
-
The citation style of the list (optional)
- $english : string = false
-
English citation form (for APA-Style) (optional)
Return values
string —The list of persons
remap()
Remaps the content according to a given mapping table
private
remap(string $content) : string
Parameters
- $content : string
-
The content
Return values
string —The closed content
wrap()
Wraps the content with a given string
private
wrap(string $content, string $wrap) : string
Parameters
- $content : string
-
The content
- $wrap : string
-
The elements to wrap separated by pipe "|"
Return values
string —The emphasized words