BIB
Table of Contents
Functions
- getBibData() : array<string|int, mixed>
- Get data from citation sentences and return an array of citation data and an array of resource data ready for producing a bibliography from.
- getItemArray() : array<string|int, mixed>
- Create an array of bibliographic data matching the template fields
- addCreators() : mixed
- Add creators
- findSubsequentFootnoteTemplates() : mixed
- Find examples of ibid, idem, and opCit footnote templates.
- mapTemplate() : array<string|int, mixed>
- Map a template to the raw values and produce a basic bibliographic/footnote entry
- invertFormat() : string
- Invert the format of a title where necessary.
- mapSpecialTemplate() : string
- Map a special template (no partial, creator fields etc.—e.g., runningTimeTemplate) to the raw values and produce a string
- checkMultiplePunctuation() : array<string|int, mixed>
- Make sure we don't have multiple punctuation characters after a field —NOT CURRENTLY USED (see cleanItems())
- addLinks() : string
- Add link items such as URL and DOI
- addLinksFt() : string
- Find any links in footnotes and make active if required
- addDateStage1() : array<string|int, mixed>
- Add date: stage 1
- addDateStage2() : string
- Add date: stage 2
- formatDate() : mixed
- formatDay() : array<string|int, mixed>
- Format the day part of a date
- addRunningTime() : string
- Add and format running time (films, TV etc.)
- formatPages() : array<string|int, mixed>
- Add and format pages
- addOtherItems() : array<string|int, mixed>
- Find other items in various resource arrays for adding to the $items array
- setBookYears() : mixed
- For WIKINDX, if type is book, book_chapter or book article and there exists both 'year1' and 'year2' in $resource (entered as publication year and reprint year respectively), then switch these around as 'year1' is entered in the style template as 'originalPublicationYear' and 'year2' should be 'publicationYear'.
- cleanItems() : array<string|int, mixed>
- Clean up the $item elements, deal with ordinals, and flatten to final string.
- editorSwitch() : bool
- Set any author/editor re-ordering for book and book_article type.
- formatCreators() : mixed
- Format creator name lists (authors, editors, etc.)
- numCreatorManage() : array<string|int, mixed>
- Keep only some elements in array if we've exceeded set thresholds and create an etAl string if necessary.
- rewriteCreatorStrings() : array<string|int, mixed>
- Rewrite creator strings
- addCustom() : mixed
- Add custom fields.
- formatRunningTime() : string
- Format running time for audiovisual bibliography items
- findAmbiguousYears() : array<string|int, mixed>
- Add year fields.
- addEdition() : array<string|int, mixed>
- Add any edition field
- formatEdition() : int|string
- Format edition (might not be numeric)
- getOrdinalExtensionAlignment() : mixed
- checkPartial() : array<string|int, mixed>
- Check that the first field of $template exists in $item and has a value.
- checkFallBackFields() : array<string|int, mixed>
- When using a fallback template, ensure the fields are valid for that resource type
- setCreatorRepeat() : array<string|int, mixed>
- Check against repeat creator options and amend $items if required If this is footnotes, then $newItems is also ordered correctly.
- setCreatorRepeatEndnotes() : array<string|int, mixed>
- Check against repeat creator options and amend $items if required If this is footnotes, then $newItems is also ordered correctly.
- mapTemplateCreatorRepeatString() : mixed
- Basic map template for creator repeat string
Functions
getBibData()
Get data from citation sentences and return an array of citation data and an array of resource data ready for producing a bibliography from.
getBibData(mixed $sentences, array<string|int, mixed> $resIds, array<string|int, mixed> $flags) : array<string|int, mixed>
We only get here if the text from which $sentences is produced has citations (and thus resource data for the bibliography). NB elements of the $sentences array might not themselves have citations/resource data — discard these.
$resIds is an ordered list of resourceIds for in-text bibliographies and endnote-style citations using the same ID number where the style dictates the bibliography order is NOT to be used: in this case, we use the citation array's endnoteId. In other endnote styles, we order $resourceData by the citation array's endnoteId value.
Parameters
- $sentences : mixed
- $resIds : array<string|int, mixed>
- $flags : array<string|int, mixed>
Return values
array<string|int, mixed>getItemArray()
Create an array of bibliographic data matching the template fields
getItemArray(array<string|int, mixed> $localBibType, array<string|int, mixed> $bibStyle, mixed $creatorStyle, array<string|int, mixed> $template, array<string|int, mixed> $customTypes, array<string|int, mixed> $flags, string $styleLocalisation, string $type, array<string|int, mixed> $resourceData, array<string|int, mixed> $citationData, string $puncPattern, string $space) : array<string|int, mixed>
Parameters
- $localBibType : array<string|int, mixed>
- $bibStyle : array<string|int, mixed>
- $creatorStyle : mixed
- $template : array<string|int, mixed>
- $customTypes : array<string|int, mixed>
- $flags : array<string|int, mixed>
- $styleLocalisation : string
- $type : string
- $resourceData : array<string|int, mixed>
- $citationData : array<string|int, mixed>
- $puncPattern : string
- $space : string
Return values
array<string|int, mixed>addCreators()
Add creators
addCreators(array<string|int, mixed> $localBibType, array<string|int, mixed> $template, array<string|int, mixed> $resourceData, array<string|int, mixed> $creatorStyle, string $styleLocalisation, string $type, object &$items, array<string|int, mixed> $flags) : mixed
Parameters
- $localBibType : array<string|int, mixed>
- $template : array<string|int, mixed>
- $resourceData : array<string|int, mixed>
- $creatorStyle : array<string|int, mixed>
- $styleLocalisation : string
- $type : string
- $items : object
- $flags : array<string|int, mixed>
findSubsequentFootnoteTemplates()
Find examples of ibid, idem, and opCit footnote templates.
findSubsequentFootnoteTemplates(array<string|int, mixed> &$footnotes, string $citeType) : mixed
If using endnotes that use the same ID for the same resource, set only to templateEndnote.
Parameters
- $footnotes : array<string|int, mixed>
- $citeType : string
mapTemplate()
Map a template to the raw values and produce a basic bibliographic/footnote entry
mapTemplate(array<string|int, mixed> $localBibType, array<string|int, mixed> $bibStyle, array<string|int, mixed> $styleLocalisation, array<string|int, mixed> $template, string $allPuncPattern, array<string|int, mixed> $item, array<string|int, mixed> $flags) : array<string|int, mixed>
Parameters
- $localBibType : array<string|int, mixed>
- $bibStyle : array<string|int, mixed>
- $styleLocalisation : array<string|int, mixed>
- $template : array<string|int, mixed>
- $allPuncPattern : string
- $item : array<string|int, mixed>
- $flags : array<string|int, mixed>
Return values
array<string|int, mixed>invertFormat()
Invert the format of a title where necessary.
invertFormat(string $title, string $pre, string $post) : string
e.g., if the original title has elements in italics and the title field of the template is enclosed in italics, remove the formatting of those original elements. The same for underline, bold, superscript, and subscript. The formatting comes from tinyMCE so we know what it is for each type.
Parameters
- $title : string
- $pre : string
- $post : string
Return values
stringmapSpecialTemplate()
Map a special template (no partial, creator fields etc.—e.g., runningTimeTemplate) to the raw values and produce a string
mapSpecialTemplate(array<string|int, mixed> $template, array<string|int, mixed> $item) : string
Parameters
- $template : array<string|int, mixed>
- $item : array<string|int, mixed>
Return values
stringcheckMultiplePunctuation()
Make sure we don't have multiple punctuation characters after a field —NOT CURRENTLY USED (see cleanItems())
checkMultiplePunctuation(string $itemString, string $lastItemString, string $puncPattern, string $pre, string $post) : array<string|int, mixed>
Parameters
- $itemString : string
- $lastItemString : string
- $puncPattern : string
- $pre : string
- $post : string
Return values
array<string|int, mixed>addLinks()
Add link items such as URL and DOI
addLinks(string $item, array<string|int, mixed> $flags) : string
Parameters
- $item : string
- $flags : array<string|int, mixed>
Return values
stringaddLinksFt()
Find any links in footnotes and make active if required
addLinksFt(string $item, array<string|int, mixed> $flags) : string
Parameters
- $item : string
- $flags : array<string|int, mixed>
Return values
stringaddDateStage1()
Add date: stage 1
addDateStage1(array<string|int, mixed> $localBibType, array<string|int, mixed> $styleLocalisation, array<string|int, mixed> $bibStyle, array<string|int, mixed> $data, array<string|int, mixed> $items) : array<string|int, mixed>
For 'web_article', $startDay and $startMonth represent the publication date
Parameters
- $localBibType : array<string|int, mixed>
- $styleLocalisation : array<string|int, mixed>
- $bibStyle : array<string|int, mixed>
- $data : array<string|int, mixed>
- $items : array<string|int, mixed>
Return values
array<string|int, mixed>addDateStage2()
Add date: stage 2
addDateStage2(array<string|int, mixed> $localBibType, array<string|int, mixed> $styleLocalisation, array<string|int, mixed> $bibStyle, int $startDay, int $startMonth, int $endDay, int $endMonth) : string
Parameters
- $localBibType : array<string|int, mixed>
- $styleLocalisation : array<string|int, mixed>
- $bibStyle : array<string|int, mixed>
- $startDay : int
- $startMonth : int
- $endDay : int
- $endMonth : int
Return values
stringformatDate()
formatDate(mixed $startDay, mixed $endDay, mixed $startMonth, mixed $endMonth, mixed $monthArray, mixed $bibStyle) : mixed
Parameters
- $startDay : mixed
- $endDay : mixed
- $startMonth : mixed
- $endMonth : mixed
- $monthArray : mixed
- $bibStyle : mixed
formatDay()
Format the day part of a date
formatDay(int $startDay, int $endDay, array<string|int, mixed> $bibStyle, string $styleLocalisation) : array<string|int, mixed>
Parameters
- $startDay : int
- $endDay : int
- $bibStyle : array<string|int, mixed>
- $styleLocalisation : string
Return values
array<string|int, mixed>addRunningTime()
Add and format running time (films, TV etc.)
addRunningTime(array<string|int, mixed> $styleLocalisation, array<string|int, mixed> $bibStyle, array<string|int, mixed> $data) : string
Parameters
- $styleLocalisation : array<string|int, mixed>
- $bibStyle : array<string|int, mixed>
- $data : array<string|int, mixed>
Return values
stringformatPages()
Add and format pages
formatPages(array<string|int, mixed> $data, array<string|int, mixed> $bibStyle, array<string|int, mixed> $items) : array<string|int, mixed>
Parameters
- $data : array<string|int, mixed>
- $bibStyle : array<string|int, mixed>
- $items : array<string|int, mixed>
Return values
array<string|int, mixed>addOtherItems()
Find other items in various resource arrays for adding to the $items array
addOtherItems(object $localBibType, array<string|int, mixed> $resourceData, array<string|int, mixed> $items) : array<string|int, mixed>
Parameters
- $localBibType : object
- $resourceData : array<string|int, mixed>
- $items : array<string|int, mixed>
Return values
array<string|int, mixed>setBookYears()
For WIKINDX, if type is book, book_chapter or book article and there exists both 'year1' and 'year2' in $resource (entered as publication year and reprint year respectively), then switch these around as 'year1' is entered in the style template as 'originalPublicationYear' and 'year2' should be 'publicationYear'.
setBookYears(array<string|int, mixed> &$resource, string $type) : mixed
Parameters
- $resource : array<string|int, mixed>
- $type : string
cleanItems()
Clean up the $item elements, deal with ordinals, and flatten to final string.
cleanItems(string $styleLocalisation, array<string|int, mixed> $itemArray, string $allPuncPattern, string $space, string $ultimate, array<string|int, mixed> $flags) : array<string|int, mixed>
Keep the print statements (commented out for production) as they are useful for debugging. Note that we use '·' to help show spaces either end of the string.
Parameters
- $styleLocalisation : string
- $itemArray : array<string|int, mixed>
- $allPuncPattern : string
- $space : string
- $ultimate : string
- $flags : array<string|int, mixed>
Return values
array<string|int, mixed>editorSwitch()
Set any author/editor re-ordering for book and book_article type.
editorSwitch(array<string|int, mixed> $bibStyle, array<string|int, mixed> &$template, array<string|int, mixed> &$creators, string $type) : bool
If required, we unset the 'authors' element in template, set resourcecreatorRole to 1, and copy the editorSwtich template to the 'authors' element so that the primary creator name formatting settings are used. Seeting resourcecreatorRole to 1, we don't need to unset the 'editors' element in $template.
Parameters
- $bibStyle : array<string|int, mixed>
- $template : array<string|int, mixed>
- $creators : array<string|int, mixed>
- $type : string
Return values
boolformatCreators()
Format creator name lists (authors, editors, etc.)
formatCreators(array<string|int, mixed> $creators, string $nameType, array<string|int, mixed> $localBibType, array<string|int, mixed> $creatorStyle, string $styleLocalisation, array<string|int, mixed> $template, string $type, object &$items, array<string|int, mixed> $flags) : mixed
Parameters
- $creators : array<string|int, mixed>
-
Multi-associative array of creator names e.g. this array might be of the primary authors:
array([0] => array(['surname'] => 'Grimshaw', ['firstname'] => Mark, ['initials'] => 'N', ['prefix'] => ), [1] => array(['surname'] => 'Witt', ['firstname'] => Jan, ['initials'] => , ['prefix'] => 'de'))
- $nameType : string
- $localBibType : array<string|int, mixed>
- $creatorStyle : array<string|int, mixed>
- $styleLocalisation : string
- $template : array<string|int, mixed>
- $type : string
- $items : object
- $flags : array<string|int, mixed>
numCreatorManage()
Keep only some elements in array if we've exceeded set thresholds and create an etAl string if necessary.
numCreatorManage(array<string|int, mixed> $bibStyle, array<string|int, mixed> $cArray, string $localNameType, string $list, string $limit, string $moreThan, bool $italics, string $abbreviation, string $delimitTwo, string $delimitFirstBetween, string $delimitNextBetween, string $delimitLast) : array<string|int, mixed>
Produce the near-final creator string. Check if there are plural creators.
Parameters
- $bibStyle : array<string|int, mixed>
- $cArray : array<string|int, mixed>
- $localNameType : string
- $list : string
- $limit : string
- $moreThan : string
- $italics : bool
- $abbreviation : string
- $delimitTwo : string
- $delimitFirstBetween : string
- $delimitNextBetween : string
- $delimitLast : string
Return values
array<string|int, mixed>rewriteCreatorStrings()
Rewrite creator strings
rewriteCreatorStrings(array<string|int, mixed> $template, string $nameString, string $nameType, bool &$firstInList, bool &$rewriteCreatorBeforeDone) : array<string|int, mixed>
Parameters
- $template : array<string|int, mixed>
- $nameString : string
- $nameType : string
- $firstInList : bool
- $rewriteCreatorBeforeDone : bool
Return values
array<string|int, mixed>addCustom()
Add custom fields.
addCustom(array<string|int, mixed> $customTypes, array<string|int, mixed> $data, string $type, array<string|int, mixed> $items) : mixed
Parameters
- $customTypes : array<string|int, mixed>
- $data : array<string|int, mixed>
- $type : string
- $items : array<string|int, mixed>
formatRunningTime()
Format running time for audiovisual bibliography items
formatRunningTime(array<string|int, mixed> $styleLocalisation, array<string|int, mixed> $bibStyle, int $hours, int $minutes, int $seconds, int $milliseconds) : string
Parameters
- $styleLocalisation : array<string|int, mixed>
- $bibStyle : array<string|int, mixed>
- $hours : int
- $minutes : int
- $seconds : int
- $milliseconds : int
Return values
stringfindAmbiguousYears()
Add year fields.
findAmbiguousYears(array<string|int, mixed> $localBibType, array<string|int, mixed> $resourceData, array<string|int, mixed> $citationData, array<string|int, mixed> $bibStyle, array<string|int, mixed> $template, string $type, array<string|int, mixed> $items) : array<string|int, mixed>
Ambiguous entires are those with the same author(s) and same publication year(s). For in-text styles, we must deal with any ambiguity and place any letter picked up in CITE.php accordingly—ambiguous entires here are ONLY when the entries come from cited text. Append the letter to the main publication year except for certain types. a) For certain types, if the second year field follows immediately on from the first year field in the template, append the letter there. NB. This assumes the template provides some conjunction between the two fields so that the result might be: 2012–2021a or 2012/2021b b) If a) is not the case for these types, append the letter to the 'resourceyearYear1' field in the template as it must match the in-text citation. c) If there is no ambiguity or this is not an in-text style, return the years unchanged.
TODO: The use of 'ambiguousTemplate' in the citation means no letter is provided — perhaps this should be looked at at some later date so that the bibliographic entires are disambiguated . . .
Parameters
- $localBibType : array<string|int, mixed>
- $resourceData : array<string|int, mixed>
- $citationData : array<string|int, mixed>
- $bibStyle : array<string|int, mixed>
- $template : array<string|int, mixed>
- $type : string
- $items : array<string|int, mixed>
Return values
array<string|int, mixed>addEdition()
Add any edition field
addEdition(array<string|int, mixed> $localBibType, array<string|int, mixed> $data, array<string|int, mixed> $bibStyle, string $styleLocalisation, string $type, array<string|int, mixed> $items) : array<string|int, mixed>
Parameters
- $localBibType : array<string|int, mixed>
- $data : array<string|int, mixed>
- $bibStyle : array<string|int, mixed>
- $styleLocalisation : string
- $type : string
- $items : array<string|int, mixed>
Return values
array<string|int, mixed>formatEdition()
Format edition (might not be numeric)
formatEdition(int|string $edition, array<string|int, mixed> $bibStyle, string $styleLocalisation) : int|string
Parameters
- $edition : int|string
- $bibStyle : array<string|int, mixed>
- $styleLocalisation : string
Return values
int|stringgetOrdinalExtensionAlignment()
getOrdinalExtensionAlignment(int|null $alignment) : mixed
Parameters
- $alignment : int|null
checkPartial()
Check that the first field of $template exists in $item and has a value.
checkPartial(array<string|int, mixed> $template, array<string|int, mixed> $item, bool $esDone) : array<string|int, mixed>
If it does not, and $template has a partial template array, rearrange $template
Parameters
- $template : array<string|int, mixed>
- $item : array<string|int, mixed>
- $esDone : bool
Return values
array<string|int, mixed>checkFallBackFields()
When using a fallback template, ensure the fields are valid for that resource type
checkFallBackFields(object $styleMap, array<string|int, mixed> $template, string $fallbacks, string $type) : array<string|int, mixed>
Parameters
- $styleMap : object
- $template : array<string|int, mixed>
- $fallbacks : string
- $type : string
Return values
array<string|int, mixed>setCreatorRepeat()
Check against repeat creator options and amend $items if required If this is footnotes, then $newItems is also ordered correctly.
setCreatorRepeat(object $styleMap, array<string|int, mixed> $bibStyle, array<string|int, mixed> $items, array<string|int, mixed> $bibFootnoteIds, array<string|int, mixed> $footnotes, array<string|int, mixed> $flags) : array<string|int, mixed>
Parameters
- $styleMap : object
- $bibStyle : array<string|int, mixed>
- $items : array<string|int, mixed>
- $bibFootnoteIds : array<string|int, mixed>
- $footnotes : array<string|int, mixed>
- $flags : array<string|int, mixed>
Return values
array<string|int, mixed>setCreatorRepeatEndnotes()
Check against repeat creator options and amend $items if required If this is footnotes, then $newItems is also ordered correctly.
setCreatorRepeatEndnotes(object $styleMap, array<string|int, mixed> $bibStyle, array<string|int, mixed> $items, array<string|int, mixed> $footnotes, array<string|int, mixed> $flags) : array<string|int, mixed>
Parameters
- $styleMap : object
- $bibStyle : array<string|int, mixed>
- $items : array<string|int, mixed>
- $footnotes : array<string|int, mixed>
- $flags : array<string|int, mixed>
Return values
array<string|int, mixed>mapTemplateCreatorRepeatString()
Basic map template for creator repeat string
mapTemplateCreatorRepeatString(array<string|int, mixed> $cTemplate, string $string, string $output, bool $replaceFormatting) : mixed
Parameters
- $cTemplate : array<string|int, mixed>
- $string : string
- $output : string
- $replaceFormatting : bool