Refbase update_2021-01-28_15_58

This commit is contained in:
root
2021-01-28 15:58:21 +01:00
commit 64e7261da6
300 changed files with 164739 additions and 0 deletions

678
cite/styles/cite_AMA.php Normal file
View File

@@ -0,0 +1,678 @@
<?php
// Project: Web Reference Database (refbase) <http://www.refbase.net>
// Copyright: Matthias Steffens <mailto:refbase@extracts.de> and the file's
// original author(s).
//
// This code is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY. Please see the GNU General Public
// License for more details.
//
// File: ./cite/styles/cite_AMA.php
// Repository: $HeadURL$
// Author(s): Matthias Steffens <mailto:refbase@extracts.de> and
// Richard Karnesky <mailto:karnesky@gmail.com>
//
// Created: 25-Feb-08, 20:05
// Modified: $Date: 2012-02-27 20:25:30 +0000 (Mon, 27 Feb 2012) $
// $Author$
// $Revision: 1337 $
// This is a citation style file (which must reside within the 'cite/styles/' sub-directory of your refbase root directory). It contains a
// version of the 'citeRecord()' function that outputs a reference list from selected records according to the citation style used by
// the American Medical Association (AMA)
// based on 'cite_Chicago.php'
// TODO: - abstracts, conference proceedings, patents, reports
// - book/volume/report/etc titles should be formatted in heading caps
// - don't add a dot if the abbreviated journal (or series title) ends with a dot!
// --------------------------------------------------------------------
// --- BEGIN CITATION STYLE ---
function citeRecord($row, $citeStyle, $citeType, $markupPatternsArray, $encodeHTML)
{
$record = ""; // make sure that our buffer variable is empty
// --- BEGIN TYPE = JOURNAL ARTICLE / MAGAZINE ARTICLE / NEWSPAPER ARTICLE --------------------------------------------------------------
if (preg_match("/^(Journal Article|Magazine Article|Newspaper Article)$/", $row['type']))
{
if (!empty($row['author'])) // author
{
// Call the 'reArrangeAuthorContents()' function (defined in 'include.inc.php') in order to re-order contents of the author field. Required Parameters:
// 1. input: contents of the author field
// 2. input: boolean value that specifies whether the author's family name comes first (within one author) in the source string
// ('true' means that the family name is followed by the given name (or initials), 'false' if it's the other way around)
//
// 3. input: pattern describing old delimiter that separates different authors
// 4. output: for all authors except the last author: new delimiter that separates different authors
// 5. output: for the last author: new delimiter that separates the last author from all other authors
//
// 6. input: pattern describing old delimiter that separates author name & initials (within one author)
// 7. output: for the first author: new delimiter that separates author name & initials (within one author)
// 8. output: for all authors except the first author: new delimiter that separates author name & initials (within one author)
// 9. output: new delimiter that separates multiple initials (within one author)
// 10. output: for the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db)
// 11. output: for all authors except the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db)
// 12. output: boolean value that specifies whether an author's full given name(s) shall be shortened to initial(s)
//
// 13. output: if the total number of authors is greater than the given number (integer >= 1), only the number of authors given in (14) will be included in the citation along with the string given in (15); keep empty if all authors shall be returned
// 14. output: number of authors (integer >= 1) that is included in the citation if the total number of authors is greater than the number given in (13); keep empty if not applicable
// 15. output: string that's appended to the number of authors given in (14) if the total number of authors is greater than the number given in (13); the actual number of authors can be printed by including '__NUMBER_OF_AUTHORS__' (without quotes) within the string
//
// 16. output: boolean value that specifies whether the re-ordered string shall be returned with higher ASCII chars HTML encoded
$author = reArrangeAuthorContents($row['author'], // 1.
true, // 2.
"/ *; */", // 3.
", ", // 4.
", ", // 5.
"/ *, */", // 6.
" ", // 7.
" ", // 8.
"", // 9.
false, // 10.
false, // 11.
true, // 12.
"6", // 13.
"3", // 14.
", et al.", // 15.
$encodeHTML // 16.
);
if (!preg_match("/\. *$/", $author))
$record .= $author . ".";
else
$record .= $author;
}
if (!empty($row['title'])) // title
{
if (!empty($row['author']))
$record .= " ";
$record .= $row['title'];
}
// From here on we'll assume that at least either the 'author' or the 'title' field did contain some contents
// if this is not the case, the output string will begin with a space. However, any preceding/trailing whitespace will be removed at the cleanup stage (see below)
if (!preg_match("/[?!.] *$/", $record))
$record .= ".";
if (!empty($row['abbrev_journal'])) // abbreviated journal name
$record .= " " . $markupPatternsArray["italic-prefix"] . $row['abbrev_journal'] . $markupPatternsArray["italic-suffix"];
// if there's no abbreviated journal name, we'll use the full journal name
elseif (!empty($row['publication'])) // publication (= journal) name
$record .= " " . $markupPatternsArray["italic-prefix"] . $row['publication'] . $markupPatternsArray["italic-suffix"];
if (preg_match("/^(Magazine Article|Newspaper Article)$/", $row['type']) AND !preg_match("/^\d+$/", $row['volume'])) // for newspaper articles (and magazine articles if w/o volume number), volume (=month) and issue (=day) information is printed before the year
{
if (!empty($row['volume'])) // volume (=month)
$record .= ". " . $row['volume'];
if (!empty($row['issue'])) // issue (=day)
$record .= " " . $row['issue'];
if (!empty($row['year'])) // year
$record .= ", " . $row['year'];
}
else // journal article (or a magazine article with volume numbers)
{
if (!empty($row['year'])) // year
$record .= ". " . $row['year'];
if (!empty($row['volume']) || !empty($row['issue']))
$record .= ";";
if (!empty($row['volume'])) // volume
$record .= $row['volume'];
if (!empty($row['issue'])) // issue
$record .= "(" . $row['issue'] . ")";
}
if (!empty($row['pages'])) // pages
{
if (!empty($row['year']) || !empty($row['volume']) || !empty($row['issue']) || !empty($row['abbrev_journal']) || !empty($row['publication'])) // only add ": " if either year, volume, issue, abbrev_journal or publication isn't empty
$record .= ":";
$record .= formatPageInfo($row['pages'], $markupPatternsArray["endash"]); // function 'formatPageInfo()' is defined in 'cite.inc.php'
}
if ($row['online_publication'] == "yes") // this record refers to an online article
{
// append an optional string (given in 'online_citation') plus the current date and the DOI (or URL):
$today = date("F j, Y");
if (!empty($row['online_citation'])) // online_citation
{
if (!empty($row['year']) || !empty($row['volume']) || !empty($row['issue']) || !empty($row['abbrev_journal']) || !empty($row['publication'])) // only add ":" or "," if either year, volume, issue, abbrev_journal or publication isn't empty
{
if (empty($row['pages']))
$record .= ":"; // print instead of pages
else
$record .= ","; // append to pages
}
$record .= $row['online_citation'];
}
if (!empty($row['doi'])) // doi
{
if (!empty($row['online_citation']) OR (empty($row['online_citation']) AND (!empty($row['year']) || !empty($row['volume']) || !empty($row['issue']) || !empty($row['abbrev_journal']) || !empty($row['publication'])))) // only add "." if online_citation isn't empty, or else if either year, volume, issue, abbrev_journal or publication isn't empty
$record .= ".";
if ($encodeHTML)
$record .= " " . encodeHTML("http://dx.doi.org/" . $row['doi']) . ". Accessed " . $today;
else
$record .= " " . "http://dx.doi.org/" . $row['doi'] . ". Accessed " . $today;
}
elseif (!empty($row['url'])) // url
{
if (!empty($row['online_citation']) OR (empty($row['online_citation']) AND (!empty($row['year']) || !empty($row['volume']) || !empty($row['issue']) || !empty($row['abbrev_journal']) || !empty($row['publication'])))) // only add "." if online_citation isn't empty, or else if either year, volume, issue, abbrev_journal or publication isn't empty
$record .= ".";
if ($encodeHTML)
$record .= " " . encodeHTML($row['url']) . ". Accessed " . $today;
else
$record .= " " . $row['url'] . ". Accessed " . $today;
}
}
if (!preg_match("/\. *$/", $record))
$record .= ".";
}
// --- BEGIN TYPE = ABSTRACT / BOOK CHAPTER / CONFERENCE ARTICLE ------------------------------------------------------------------------
elseif (preg_match("/^(Abstract|Book Chapter|Conference Article)$/", $row['type']))
{
if (!empty($row['author'])) // author
{
// Call the 'reArrangeAuthorContents()' function (defined in 'include.inc.php') in order to re-order contents of the author field. Required Parameters:
// 1. input: contents of the author field
// 2. input: boolean value that specifies whether the author's family name comes first (within one author) in the source string
// ('true' means that the family name is followed by the given name (or initials), 'false' if it's the other way around)
//
// 3. input: pattern describing old delimiter that separates different authors
// 4. output: for all authors except the last author: new delimiter that separates different authors
// 5. output: for the last author: new delimiter that separates the last author from all other authors
//
// 6. input: pattern describing old delimiter that separates author name & initials (within one author)
// 7. output: for the first author: new delimiter that separates author name & initials (within one author)
// 8. output: for all authors except the first author: new delimiter that separates author name & initials (within one author)
// 9. output: new delimiter that separates multiple initials (within one author)
// 10. output: for the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db)
// 11. output: for all authors except the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db)
// 12. output: boolean value that specifies whether an author's full given name(s) shall be shortened to initial(s)
//
// 13. output: if the total number of authors is greater than the given number (integer >= 1), only the number of authors given in (14) will be included in the citation along with the string given in (15); keep empty if all authors shall be returned
// 14. output: number of authors (integer >= 1) that is included in the citation if the total number of authors is greater than the number given in (13); keep empty if not applicable
// 15. output: string that's appended to the number of authors given in (14) if the total number of authors is greater than the number given in (13); the actual number of authors can be printed by including '__NUMBER_OF_AUTHORS__' (without quotes) within the string
//
// 16. output: boolean value that specifies whether the re-ordered string shall be returned with higher ASCII chars HTML encoded
$author = reArrangeAuthorContents($row['author'], // 1.
true, // 2.
"/ *; */", // 3.
", ", // 4.
", ", // 5.
"/ *, */", // 6.
" ", // 7.
" ", // 8.
"", // 9.
false, // 10.
false, // 11.
true, // 12.
"6", // 13.
"3", // 14.
", et al.", // 15.
$encodeHTML // 16.
);
if (!preg_match("/\. *$/", $author))
$record .= $author . ".";
else
$record .= $author;
}
if (!empty($row['title'])) // title
{
if (!empty($row['author']))
$record .= " ";
$record .= $row['title'];
}
if ($row['type'] == "Abstract") // for abstracts, add "[abstract]" label
$record .= " [abstract]";
// From here on we'll assume that at least either the 'author' or the 'title' field did contain some contents
// if this is not the case, the output string will begin with a space. However, any preceding/trailing whitespace will be removed at the cleanup stage (see below)
if (!empty($row['editor'])) // editor
{
// Call the 'reArrangeAuthorContents()' function (defined in 'include.inc.php') in order to re-order contents of the author field. Required Parameters:
// 1. input: contents of the author field
// 2. input: boolean value that specifies whether the author's family name comes first (within one author) in the source string
// ('true' means that the family name is followed by the given name (or initials), 'false' if it's the other way around)
//
// 3. input: pattern describing old delimiter that separates different authors
// 4. output: for all authors except the last author: new delimiter that separates different authors
// 5. output: for the last author: new delimiter that separates the last author from all other authors
//
// 6. input: pattern describing old delimiter that separates author name & initials (within one author)
// 7. output: for the first author: new delimiter that separates author name & initials (within one author)
// 8. output: for all authors except the first author: new delimiter that separates author name & initials (within one author)
// 9. output: new delimiter that separates multiple initials (within one author)
// 10. output: for the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db)
// 11. output: for all authors except the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db)
// 12. output: boolean value that specifies whether an author's full given name(s) shall be shortened to initial(s)
//
// 13. output: if the total number of authors is greater than the given number (integer >= 1), only the number of authors given in (14) will be included in the citation along with the string given in (15); keep empty if all authors shall be returned
// 14. output: number of authors (integer >= 1) that is included in the citation if the total number of authors is greater than the number given in (13); keep empty if not applicable
// 15. output: string that's appended to the number of authors given in (14) if the total number of authors is greater than the number given in (13); the actual number of authors can be printed by including '__NUMBER_OF_AUTHORS__' (without quotes) within the string
//
// 16. output: boolean value that specifies whether the re-ordered string shall be returned with higher ASCII chars HTML encoded
$editor = reArrangeAuthorContents($row['editor'], // 1.
true, // 2.
"/ *; */", // 3.
", ", // 4.
", ", // 5.
"/ *, */", // 6.
" ", // 7.
" ", // 8.
"", // 9.
false, // 10.
false, // 11.
true, // 12.
"6", // 13.
"3", // 14.
", et al.", // 15.
$encodeHTML // 16.
);
if (!preg_match("/[?!.] *$/", $record))
$record .= ".";
$record .= " In: " . $editor . ", ";
if (preg_match("/^[^;\r\n]+(;[^;\r\n]+)+$/", $row['editor'])) // there are at least two editors (separated by ';')
$record .= "eds";
else // there's only one editor (or the editor field is malformed with multiple editors but missing ';' separator[s])
$record .= "ed";
}
$publication = preg_replace("/[ \r\n]*\(Eds?:[^\)\r\n]*\)/i", "", $row['publication']);
if (!empty($publication)) // publication
{
if (!preg_match("/[?!.] *$/", $record))
$record .= ".";
if (empty($row['editor']))
$record .= " In:";
// TODO: container titles should be formatted in heading caps, however, this doesn't yet work correctly if the publication title contains HTML entities
$record .= " " . $markupPatternsArray["italic-prefix"] . $publication . $markupPatternsArray["italic-suffix"];
// $record .= " " . $markupPatternsArray["italic-prefix"] . changeCase("heading", $publication) . $markupPatternsArray["italic-suffix"]; // function 'changeCase()' is defined in 'include.inc.php'
}
if (!empty($row['volume'])) // volume
{
if (!preg_match("@[?!.][ \"" . $markupPatternsArray["italic-suffix"] . "]*$@", $record))
$record .= ".";
$record .= " Vol. " . $row['volume'];
}
if (!empty($row['edition']) && !preg_match("/^(1|1st|first|one)( ed\.?| edition)?$/i", $row['edition'])) // edition
{
if (!preg_match("@[?!.][ \"" . $markupPatternsArray["italic-suffix"] . "]*$@", $record))
$record .= ".";
if (preg_match("/^\d{1,3}$/", $row['edition'])) // if the edition field contains a number of up to three digits, we assume it's an edition number (such as "2nd ed.")
{
if ($row['edition'] == "2")
$editionSuffix = "nd";
elseif ($row['edition'] == "3")
$editionSuffix = "rd";
else
$editionSuffix = "th";
}
else
$editionSuffix = "";
if (!preg_match("/( ed\.?| edition)$/i", $row['edition']))
$editionSuffix .= " ed.";
$record .= " " . $row['edition'] . $editionSuffix;
}
if (!preg_match("@[?!.][ \"" . $markupPatternsArray["italic-suffix"] . "]*$@", $record))
$record .= ".";
if (!empty($row['place'])) // place
$record .= " " . $row['place'];
if (!empty($row['publisher'])) // publisher
{
if (!empty($row['place']))
$record .= ":";
$record .= " " . $row['publisher'];
}
if (!empty($row['year'])) // year
$record .= "; " . $row['year'];
if (!empty($row['pages'])) // pages
$record .= ":" . formatPageInfo($row['pages'], $markupPatternsArray["endash"]); // function 'formatPageInfo()' is defined in 'cite.inc.php'
if (!empty($row['abbrev_series_title']) OR !empty($row['series_title'])) // if there's either a full or an abbreviated series title
{
if (!preg_match("@[?!.][ \"" . $markupPatternsArray["italic-suffix"] . "]*$@", $record))
$record .= ".";
$record .= " ";
if (!empty($row['abbrev_series_title']))
$record .= $row['abbrev_series_title']; // abbreviated series title
// if there's no abbreviated series title, we'll use the full series title instead:
elseif (!empty($row['series_title']))
$record .= $row['series_title']; // full series title
if (!empty($row['series_volume'])||!empty($row['series_issue']))
$record .= " ";
if (!empty($row['series_volume'])) // series volume
$record .= $row['series_volume'];
if (!empty($row['series_issue'])) // series issue (I'm not really sure if -- for this cite style -- the series issue should be rather omitted here)
$record .= "(" . $row['series_issue'] . ")"; // is it correct to format series issues similar to journal article issues?
}
if (!preg_match("/\. *$/", $record))
$record .= ".";
}
// --- BEGIN TYPE = BOOK WHOLE / CONFERENCE VOLUME / JOURNAL / MANUAL / MANUSCRIPT / MAP / MISCELLANEOUS / PATENT / REPORT / SOFTWARE ---
else // if (preg_match("/Book Whole|Conference Volume|Journal|Manual|Manuscript|Map|Miscellaneous|Patent|Report|Software/", $row['type']))
// note that this also serves as a fallback: unrecognized resource types will be formatted similar to whole books
{
if (!empty($row['author'])) // author
{
$author = preg_replace("/[ \r\n]*\(eds?\)/i", "", $row['author']);
// Call the 'reArrangeAuthorContents()' function (defined in 'include.inc.php') in order to re-order contents of the author field. Required Parameters:
// 1. input: contents of the author field
// 2. input: boolean value that specifies whether the author's family name comes first (within one author) in the source string
// ('true' means that the family name is followed by the given name (or initials), 'false' if it's the other way around)
//
// 3. input: pattern describing old delimiter that separates different authors
// 4. output: for all authors except the last author: new delimiter that separates different authors
// 5. output: for the last author: new delimiter that separates the last author from all other authors
//
// 6. input: pattern describing old delimiter that separates author name & initials (within one author)
// 7. output: for the first author: new delimiter that separates author name & initials (within one author)
// 8. output: for all authors except the first author: new delimiter that separates author name & initials (within one author)
// 9. output: new delimiter that separates multiple initials (within one author)
// 10. output: for the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db)
// 11. output: for all authors except the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db)
// 12. output: boolean value that specifies whether an author's full given name(s) shall be shortened to initial(s)
//
// 13. output: if the total number of authors is greater than the given number (integer >= 1), only the number of authors given in (14) will be included in the citation along with the string given in (15); keep empty if all authors shall be returned
// 14. output: number of authors (integer >= 1) that is included in the citation if the total number of authors is greater than the number given in (13); keep empty if not applicable
// 15. output: string that's appended to the number of authors given in (14) if the total number of authors is greater than the number given in (13); the actual number of authors can be printed by including '__NUMBER_OF_AUTHORS__' (without quotes) within the string
//
// 16. output: boolean value that specifies whether the re-ordered string shall be returned with higher ASCII chars HTML encoded
$author = reArrangeAuthorContents($author, // 1.
true, // 2.
"/ *; */", // 3.
", ", // 4.
", ", // 5.
"/ *, */", // 6.
" ", // 7.
" ", // 8.
"", // 9.
false, // 10.
false, // 11.
true, // 12.
"6", // 13.
"3", // 14.
", et al.", // 15.
$encodeHTML // 16.
);
// if the author is actually the editor of the resource we'll append ', ed' (or ', eds') to the author string:
// [to distinguish editors from authors in the 'author' field, the 'modify.php' script does append ' (ed)' or ' (eds)' if appropriate,
// so we're just checking for these identifier strings here. Alternatively, we could check whether the editor field matches the author field]
if (preg_match("/[ \r\n]*\(ed\)/", $row['author'])) // single editor
$author = $author . ", ed";
elseif (preg_match("/[ \r\n]*\(eds\)/", $row['author'])) // multiple editors
$author = $author . ", eds";
if (!preg_match("/\. *$/", $author))
$record .= $author . ".";
else
$record .= $author;
}
if (!empty($row['title'])) // title
{
if (!empty($row['author']))
$record .= " ";
// TODO: book/volume/report/etc titles should be formatted in heading caps, however, this doesn't yet work correctly if the publication title contains HTML entities
$record .= $markupPatternsArray["italic-prefix"] . $row['title'] . $markupPatternsArray["italic-suffix"];
// $record .= $markupPatternsArray["italic-prefix"] . changeCase("heading", $row['title']) . $markupPatternsArray["italic-suffix"]; // function 'changeCase()' is defined in 'include.inc.php'
}
if ($row['type'] == "Software") // for software, add software label
$record .= " [computer program]";
if (!empty($row['volume']) AND ($row['type'] != "Software")) // volume
{
if (!preg_match("@[?!.][ \"" . $markupPatternsArray["italic-suffix"] . "]*$@", $record))
$record .= ".";
$record .= " Vol. " . $row['volume'];
}
if (!empty($row['edition'])) // edition
{
if (!preg_match("@[?!.][ \"" . $markupPatternsArray["italic-suffix"] . "]*$@", $record))
$record .= ".";
if ($row['type'] == "Software") // software edition (=version)
{
$record .= " Version " . $row['edition'];
}
elseif (!preg_match("/^(1|1st|first|one)( ed\.?| edition)?$/i", $row['edition'])) // edition
{
if (preg_match("/^\d{1,3}$/", $row['edition'])) // if the edition field contains a number of up to three digits, we assume it's an edition number (such as "2nd ed.")
{
if ($row['edition'] == "2")
$editionSuffix = "nd";
elseif ($row['edition'] == "3")
$editionSuffix = "rd";
else
$editionSuffix = "th";
}
else
$editionSuffix = "";
if (!preg_match("/( ed\.?| edition)$/i", $row['edition']))
$editionSuffix .= " ed.";
$record .= " " . $row['edition'] . $editionSuffix;
}
}
if (!empty($row['editor']) && !preg_match("/[ \r\n]*\(eds?\)/", $row['author'])) // editor (if different from author, see note above regarding the check for ' (ed)' or ' (eds)')
{
// Call the 'reArrangeAuthorContents()' function (defined in 'include.inc.php') in order to re-order contents of the author field. Required Parameters:
// 1. input: contents of the author field
// 2. input: boolean value that specifies whether the author's family name comes first (within one author) in the source string
// ('true' means that the family name is followed by the given name (or initials), 'false' if it's the other way around)
//
// 3. input: pattern describing old delimiter that separates different authors
// 4. output: for all authors except the last author: new delimiter that separates different authors
// 5. output: for the last author: new delimiter that separates the last author from all other authors
//
// 6. input: pattern describing old delimiter that separates author name & initials (within one author)
// 7. output: for the first author: new delimiter that separates author name & initials (within one author)
// 8. output: for all authors except the first author: new delimiter that separates author name & initials (within one author)
// 9. output: new delimiter that separates multiple initials (within one author)
// 10. output: for the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db)
// 11. output: for all authors except the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db)
// 12. output: boolean value that specifies whether an author's full given name(s) shall be shortened to initial(s)
//
// 13. output: if the total number of authors is greater than the given number (integer >= 1), only the number of authors given in (14) will be included in the citation along with the string given in (15); keep empty if all authors shall be returned
// 14. output: number of authors (integer >= 1) that is included in the citation if the total number of authors is greater than the number given in (13); keep empty if not applicable
// 15. output: string that's appended to the number of authors given in (14) if the total number of authors is greater than the number given in (13); the actual number of authors can be printed by including '__NUMBER_OF_AUTHORS__' (without quotes) within the string
//
// 16. output: boolean value that specifies whether the re-ordered string shall be returned with higher ASCII chars HTML encoded
$editor = reArrangeAuthorContents($row['editor'], // 1.
true, // 2.
"/ *; */", // 3.
", ", // 4.
", ", // 5.
"/ *, */", // 6.
" ", // 7.
" ", // 8.
"", // 9.
false, // 10.
false, // 11.
true, // 12.
"6", // 13.
"3", // 14.
", et al.", // 15.
$encodeHTML // 16.
);
if (!preg_match("@[?!.][ \"" . $markupPatternsArray["italic-suffix"] . "]*$@", $record))
$record .= ".";
$record .= " " . $editor;
if (preg_match("/^[^;\r\n]+(;[^;\r\n]+)+$/", $row['editor'])) // there are at least two editors (separated by ';')
$record .= ", eds";
else // there's only one editor (or the editor field is malformed with multiple editors but missing ';' separator[s])
$record .= ", ed";
}
if (!empty($row['thesis'])) // thesis
// TODO: do we need to use the term "[dissertation]" instead of "[Ph.D. thesis]", etc? What about other thesis types then?
$record .= " [" . $row['thesis'] . "]";
if (!preg_match("@[?!.][ \"" . $markupPatternsArray["italic-suffix"] . "]*$@", $record))
$record .= ".";
if (!empty($row['place'])) // place
$record .= " " . $row['place'];
if (!empty($row['publisher'])) // publisher
{
if (!empty($row['place']))
$record .= ":";
$record .= " " . $row['publisher'];
}
$record .= ";";
if ($row['type'] == "Software") // for software, volume (=month) and issue (=day) information is printed before the year (similar to newspaper articles)
{
if (!empty($row['volume'])) // volume (=month)
$record .= " " . $row['volume'];
if (!empty($row['issue'])) // issue (=day)
$record .= " " . $row['issue'];
$record .= ",";
}
if (!empty($row['year'])) // year
$record .= " " . $row['year'];
if (!empty($row['abbrev_series_title']) OR !empty($row['series_title'])) // if there's either a full or an abbreviated series title
{
if (!preg_match("@[?!.][ \"" . $markupPatternsArray["italic-suffix"] . "]*$@", $record))
$record .= ".";
$record .= " ";
if (!empty($row['abbrev_series_title']))
$record .= $row['abbrev_series_title']; // abbreviated series title
// if there's no abbreviated series title, we'll use the full series title instead:
elseif (!empty($row['series_title']))
$record .= $row['series_title']; // full series title
if (!empty($row['series_volume'])||!empty($row['series_issue']))
$record .= " ";
if (!empty($row['series_volume'])) // series volume
$record .= $row['series_volume'];
if (!empty($row['series_issue'])) // series issue (I'm not really sure if -- for this cite style -- the series issue should be rather omitted here)
$record .= "(" . $row['series_issue'] . ")"; // is it correct to format series issues similar to journal article issues?
}
if ($row['online_publication'] == "yes" || $row['type'] == "Software") // this record refers to an online article, or a computer program/software
{
// append an optional string (given in 'online_citation') plus the current date and the DOI (or URL):
$today = date("F j, Y");
if (!empty($row['online_citation'])) // online_citation
{
if (!preg_match("/\. *$/", $record))
$record .= ".";
$record .= $row['online_citation'];
}
if (!empty($row['doi'])) // doi
{
if (!preg_match("/\. *$/", $record))
$record .= ".";
if ($encodeHTML)
$record .= " " . encodeHTML("http://dx.doi.org/" . $row['doi']) . ". Accessed " . $today;
else
$record .= " " . "http://dx.doi.org/" . $row['doi'] . ". Accessed " . $today;
}
elseif (!empty($row['url'])) // url
{
if (!preg_match("/\. *$/", $record))
$record .= ".";
if ($encodeHTML)
$record .= " " . encodeHTML($row['url']) . ". Accessed " . $today;
else
$record .= " " . $row['url'] . ". Accessed " . $today;
}
}
if (!preg_match("/\. *$/", $record))
$record .= ".";
}
// --- BEGIN POST-PROCESSING -----------------------------------------------------------------------------------------------------------
// do some further cleanup:
$record = trim($record); // remove any preceding or trailing whitespace
return $record;
}
// --- END CITATION STYLE ---
?>

699
cite/styles/cite_APA.php Normal file
View File

@@ -0,0 +1,699 @@
<?php
// Project: Web Reference Database (refbase) <http://www.refbase.net>
// Copyright: Matthias Steffens <mailto:refbase@extracts.de> and the file's
// original author(s).
//
// This code is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY. Please see the GNU General Public
// License for more details.
//
// File: ./cite/styles/cite_APA.php
// Repository: $HeadURL: file:///svn/p/refbase/code/branches/bleeding-edge/cite/styles/cite_APA.php $
// Author(s): Richard Karnesky <mailto:karnesky@gmail.com> and
// Matthias Steffens <mailto:refbase@extracts.de>
//
// Created: 06-Nov-06, 13:00
// Modified: $Date: 2012-02-27 20:25:30 +0000 (Mon, 27 Feb 2012) $
// $Author: msteffens $
// $Revision: 1337 $
// This is a citation style file (which must reside within the 'cite/styles/' sub-directory of your refbase root directory). It contains a
// version of the 'citeRecord()' function that outputs a reference list from selected records according to the citation style used by
// the APA
// based on 'cite_AnnGlaciol_JGlaciol.php'
// TODO: - magazine articles, conference proceedings, patents & reports?
// --------------------------------------------------------------------
// --- BEGIN CITATION STYLE ---
function citeRecord($row, $citeStyle, $citeType, $markupPatternsArray, $encodeHTML)
{
$record = ""; // make sure that our buffer variable is empty
// --- BEGIN TYPE = JOURNAL ARTICLE / MAGAZINE ARTICLE / NEWSPAPER ARTICLE --------------------------------------------------------------
if (preg_match("/^(Journal Article|Magazine Article|Newspaper Article)$/", $row['type']))
{
if (!empty($row['author'])) // author
{
// Call the 'reArrangeAuthorContents()' function (defined in 'include.inc.php') in order to re-order contents of the author field. Required Parameters:
// 1. input: contents of the author field
// 2. input: boolean value that specifies whether the author's family name comes first (within one author) in the source string
// ('true' means that the family name is followed by the given name (or initials), 'false' if it's the other way around)
//
// 3. input: pattern describing old delimiter that separates different authors
// 4. output: for all authors except the last author: new delimiter that separates different authors
// 5. output: for the last author: new delimiter that separates the last author from all other authors
//
// 6. input: pattern describing old delimiter that separates author name & initials (within one author)
// 7. output: for the first author: new delimiter that separates author name & initials (within one author)
// 8. output: for all authors except the first author: new delimiter that separates author name & initials (within one author)
// 9. output: new delimiter that separates multiple initials (within one author)
// 10. output: for the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db)
// 11. output: for all authors except the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db)
// 12. output: boolean value that specifies whether an author's full given name(s) shall be shortened to initial(s)
//
// 13. output: if the total number of authors is greater than the given number (integer >= 1), only the number of authors given in (14) will be included in the citation along with the string given in (15); keep empty if all authors shall be returned
// 14. output: number of authors (integer >= 1) that is included in the citation if the total number of authors is greater than the number given in (13); keep empty if not applicable
// 15. output: string that's appended to the number of authors given in (14) if the total number of authors is greater than the number given in (13); the actual number of authors can be printed by including '__NUMBER_OF_AUTHORS__' (without quotes) within the string
//
// 16. output: boolean value that specifies whether the re-ordered string shall be returned with higher ASCII chars HTML encoded
$author = reArrangeAuthorContents($row['author'], // 1.
true, // 2.
"/ *; */", // 3.
", ", // 4.
", " . $markupPatternsArray["ampersand"] . " ", // 5.
"/ *, */", // 6.
", ", // 7.
", ", // 8.
". ", // 9.
false, // 10.
false, // 11.
true, // 12.
"6", // 13.
"6", // 14.
", et al.", // 15.
$encodeHTML); // 16.
if (!preg_match("/\. *$/", $author))
$record .= $author . ".";
else
$record .= $author;
}
if (!empty($row['year']) || !empty($row['volume']) || !empty($row['issue']))
{
if (!empty($row['author']))
$record .= " ";
$record .= "(";
if (!empty($row['year'])) // year
$record .= $row['year'];
if ($row['type'] == "Newspaper Article") // for newspaper articles, volume (=month) and issue (=day) information is printed after the year
{
if (!empty($row['year']) && (!empty($row['volume']) || !empty($row['issue'])))
$record .= ",";
if (!empty($row['volume'])) // volume (=month)
$record .= " " . $row['volume'];
if (!empty($row['issue'])) // issue (=day)
$record .= " " . $row['issue'];
}
$record .= ").";
}
if (!empty($row['title'])) // title
{
if (!empty($row['author']) || !empty($row['year']))
$record .= " ";
$record .= $row['title'];
if (!preg_match("/[?!.]$/", $row['title']))
$record .= ".";
}
// From here on we'll assume that at least one of the fields 'author', 'year' or 'title' did contain some contents
// if this is not the case, the output string will begin with a space. However, any preceding/trailing whitespace will be removed at the cleanup stage (see below)
if (!empty($row['abbrev_journal'])) // abbreviated journal name
$record .= " " . $markupPatternsArray["italic-prefix"] . $row['abbrev_journal'] . $markupPatternsArray["italic-suffix"];
// if there's no abbreviated journal name, we'll use the full journal name
elseif (!empty($row['publication'])) // publication (= journal) name
$record .= " " . $markupPatternsArray["italic-prefix"] . $row['publication'] . $markupPatternsArray["italic-suffix"];
if (preg_match("/^(Journal Article|Magazine Article)$/", $row['type'])) // for journal and magazine articles, volume and issue information is printed after the publication name
{
if (!empty($row['abbrev_journal']) || !empty($row['publication']))
$record .= ", ";
if (!empty($row['volume'])) // volume
$record .= $markupPatternsArray["italic-prefix"] . $row['volume'] . $markupPatternsArray["italic-suffix"];
if (!empty($row['issue'])) // issue
$record .= "(" . $row['issue'] . ")";
}
if ($row['online_publication'] == "yes") // this record refers to an online article
{
// instead of any pages info (which normally doesn't exist for online publications) we append
// an optional string (given in 'online_citation') plus the current date and the DOI (or URL):
$today = date("F j, Y");
if (!empty($row['online_citation'])) // online_citation
{
if (!empty($row['volume']) || !empty($row['issue']) || !empty($row['abbrev_journal']) || !empty($row['publication'])) // only add "," if either volume, issue, abbrev_journal or publication isn't empty
$record .= ",";
$record .= " " . $row['online_citation'];
}
if (!empty($row['doi'])) // doi
{
if (!empty($row['online_citation']) OR (empty($row['online_citation']) AND (!empty($row['volume']) || !empty($row['issue']) || !empty($row['abbrev_journal']) || !empty($row['publication'])))) // only add "." if online_citation isn't empty, or else if either volume, issue, abbrev_journal or publication isn't empty
$record .= ".";
if ($encodeHTML)
$record .= " Retrieved " . $today . ", from " . encodeHTML("http://dx.doi.org/" . $row['doi']);
else
$record .= " Retrieved " . $today . ", from http://dx.doi.org/" . $row['doi'];
}
elseif (!empty($row['url'])) // url
{
if (!empty($row['online_citation']) OR (empty($row['online_citation']) AND (!empty($row['volume']) || !empty($row['issue']) || !empty($row['abbrev_journal']) || !empty($row['publication'])))) // only add "." if online_citation isn't empty, or else if either volume, issue, abbrev_journal or publication isn't empty
$record .= ".";
if ($encodeHTML)
$record .= " Retrieved " . $today . ", from " . encodeHTML($row['url']);
else
$record .= " Retrieved " . $today . ", from " . $row['url'];
}
}
else // $row['online_publication'] == "no" -> this record refers to a printed article, so we append any pages info instead:
{
if (!empty($row['pages'])) // pages
{
if (!empty($row['volume']) || !empty($row['issue']) || !empty($row['abbrev_journal']) || !empty($row['publication'])) // only add ", " if either volume, issue, abbrev_journal or publication isn't empty
$record .= ", ";
if ($row['type'] == "Newspaper Article") // for newspaper articles, we prefix page numbers with "p." or "pp."
$record .= formatPageInfo($row['pages'], $markupPatternsArray["endash"], "p. ", "pp. "); // function 'formatPageInfo()' is defined in 'cite.inc.php'
else
$record .= formatPageInfo($row['pages'], $markupPatternsArray["endash"]);
}
}
if (!preg_match("/\. *$/", $record) && !($row['online_publication'] == "yes" && (!empty($row['doi']) || !empty($row['url'])))) // if the string doesn't end with a period or a DOI/URL
$record .= ".";
}
// --- BEGIN TYPE = ABSTRACT / BOOK CHAPTER / CONFERENCE ARTICLE ------------------------------------------------------------------------
elseif (preg_match("/^(Abstract|Book Chapter|Conference Article)$/", $row['type']))
{
if (!empty($row['author'])) // author
{
// Call the 'reArrangeAuthorContents()' function (defined in 'include.inc.php') in order to re-order contents of the author field. Required Parameters:
// 1. input: contents of the author field
// 2. input: boolean value that specifies whether the author's family name comes first (within one author) in the source string
// ('true' means that the family name is followed by the given name (or initials), 'false' if it's the other way around)
//
// 3. input: pattern describing old delimiter that separates different authors
// 4. output: for all authors except the last author: new delimiter that separates different authors
// 5. output: for the last author: new delimiter that separates the last author from all other authors
//
// 6. input: pattern describing old delimiter that separates author name & initials (within one author)
// 7. output: for the first author: new delimiter that separates author name & initials (within one author)
// 8. output: for all authors except the first author: new delimiter that separates author name & initials (within one author)
// 9. output: new delimiter that separates multiple initials (within one author)
// 10. output: for the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db)
// 11. output: for all authors except the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db)
// 12. output: boolean value that specifies whether an author's full given name(s) shall be shortened to initial(s)
//
// 13. output: if the total number of authors is greater than the given number (integer >= 1), only the number of authors given in (14) will be included in the citation along with the string given in (15); keep empty if all authors shall be returned
// 14. output: number of authors (integer >= 1) that is included in the citation if the total number of authors is greater than the number given in (13); keep empty if not applicable
// 15. output: string that's appended to the number of authors given in (14) if the total number of authors is greater than the number given in (13); the actual number of authors can be printed by including '__NUMBER_OF_AUTHORS__' (without quotes) within the string
//
// 16. output: boolean value that specifies whether the re-ordered string shall be returned with higher ASCII chars HTML encoded
$author = reArrangeAuthorContents($row['author'], // 1.
true, // 2.
"/ *; */", // 3.
", ", // 4.
", " . $markupPatternsArray["ampersand"] . " ", // 5.
"/ *, */", // 6.
", ", // 7.
", ", // 8.
". ", // 9.
false, // 10.
false, // 11.
true, // 12.
"6", // 13.
"6", // 14.
", et al.", // 15.
$encodeHTML); // 16.
if (!preg_match("/\. *$/", $author))
$record .= $author . ".";
else
$record .= $author;
}
if (!empty($row['year'])) // year
{
if (!empty($row['author']))
$record .= " ";
$record .= "(" . $row['year'] . ").";
}
if (!empty($row['title'])) // title
{
if (!empty($row['author']) || !empty($row['year']))
$record .= " ";
$record .= $row['title'];
if (!preg_match("/[?!.]$/", $row['title']))
$record .= ".";
}
// From here on we'll assume that at least one of the fields 'author', 'year' or 'title' did contain some contents
// if this is not the case, the output string will begin with a space. However, any preceding/trailing whitespace will be removed at the cleanup stage (see below)
if (!empty($row['editor'])) // editor
{
// Call the 'reArrangeAuthorContents()' function (defined in 'include.inc.php') in order to re-order contents of the author field. Required Parameters:
// 1. input: contents of the author field
// 2. input: boolean value that specifies whether the author's family name comes first (within one author) in the source string
// ('true' means that the family name is followed by the given name (or initials), 'false' if it's the other way around)
//
// 3. input: pattern describing old delimiter that separates different authors
// 4. output: for all authors except the last author: new delimiter that separates different authors
// 5. output: for the last author: new delimiter that separates the last author from all other authors
//
// 6. input: pattern describing old delimiter that separates author name & initials (within one author)
// 7. output: for the first author: new delimiter that separates author name & initials (within one author)
// 8. output: for all authors except the first author: new delimiter that separates author name & initials (within one author)
// 9. output: new delimiter that separates multiple initials (within one author)
// 10. output: for the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db)
// 11. output: for all authors except the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db)
// 12. output: boolean value that specifies whether an author's full given name(s) shall be shortened to initial(s)
//
// 13. output: if the total number of authors is greater than the given number (integer >= 1), only the number of authors given in (14) will be included in the citation along with the string given in (15); keep empty if all authors shall be returned
// 14. output: number of authors (integer >= 1) that is included in the citation if the total number of authors is greater than the number given in (13); keep empty if not applicable
// 15. output: string that's appended to the number of authors given in (14) if the total number of authors is greater than the number given in (13); the actual number of authors can be printed by including '__NUMBER_OF_AUTHORS__' (without quotes) within the string
//
// 16. output: boolean value that specifies whether the re-ordered string shall be returned with higher ASCII chars HTML encoded
$editor = reArrangeAuthorContents($row['editor'], // 1.
true, // 2.
"/ *; */", // 3.
", ", // 4.
", " . $markupPatternsArray["ampersand"] . " ", // 5.
"/ *, */", // 6.
" ", // 7.
" ", // 8.
". ", // 9.
true, // 10.
true, // 11.
true, // 12.
"6", // 13.
"6", // 14.
", et al.", // 15.
$encodeHTML); // 16.
$record .= " In " . $editor . " (";
if (preg_match("/^[^;\r\n]+(;[^;\r\n]+)+$/", $row['editor'])) // there are at least two editors (separated by ';')
$record .= "Eds.";
else // there's only one editor (or the editor field is malformed with multiple editors but missing ';' separator[s])
$record .= "Ed.";
$record .= "),";
}
$publication = preg_replace("/[ \r\n]*\(Eds?:[^\)\r\n]*\)/i", "", $row['publication']);
if (!empty($publication)) // publication
{
if (empty($row['editor']))
$record .= " In";
$record .= " " . $markupPatternsArray["italic-prefix"] . $publication . $markupPatternsArray["italic-suffix"];
}
if (!empty($row['edition']) && !preg_match("/^(1|1st|first|one)( ed\.?| edition)?$/i", $row['edition']) || !empty($row['volume']) || !empty($row['pages']))
{
$record .= " (";
if (!empty($row['edition']) && !preg_match("/^(1|1st|first|one)( ed\.?| edition)?$/i", $row['edition'])) // edition
{
if (preg_match("/^\d{1,3}$/", $row['edition'])) // if the edition field contains a number of up to three digits, we assume it's an edition number (such as "2nd ed.")
{
if ($row['edition'] == "2")
$editionSuffix = "nd";
elseif ($row['edition'] == "3")
$editionSuffix = "rd";
else
$editionSuffix = "th";
}
else
$editionSuffix = "";
if (!empty($row['edition']) && !preg_match("/( ed\.?| edition)$/i", $row['edition']))
$editionSuffix .= " ed.";
$record .= $row['edition'] . $editionSuffix;
}
if (!empty($row['volume'])) // volume
{
if (!empty($row['edition']) && !preg_match("/^(1|1st|first|one)( ed\.?| edition)?$/i", $row['edition']))
$record .= ", ";
$record .= "Vol. " . $row['volume'];
}
if (!empty($row['pages'])) // pages
{
if (!empty($row['edition']) && !preg_match("/^(1|1st|first|one)( ed\.?| edition)?$/i", $row['edition']) || !empty($row['volume']))
$record .= ", ";
$record .= formatPageInfo($row['pages'], $markupPatternsArray["endash"], "p. ", "pp. "); // function 'formatPageInfo()' is defined in 'cite.inc.php'
}
$record .= ")";
}
if (!empty($row['abbrev_series_title']) OR !empty($row['series_title'])) // if there's either a full or an abbreviated series title
{
if (!preg_match("@[?!.][ " . $markupPatternsArray["italic-suffix"] . "]*$@", $record))
$record .= ".";
$record .= " ";
if (!empty($row['abbrev_series_title']))
$record .= $row['abbrev_series_title']; // abbreviated series title
// if there's no abbreviated series title, we'll use the full series title instead:
elseif (!empty($row['series_title']))
$record .= $row['series_title']; // full series title
if (!empty($row['series_volume'])||!empty($row['series_issue']))
$record .= ", ";
if (!empty($row['series_volume'])) // series volume (I'm not really sure if -- for this cite style -- the series volume & issue should be rather omitted here)
$record .= $row['series_volume'];
if (!empty($row['series_issue'])) // series issue (see note for series volume)
$record .= "(" . $row['series_issue'] . ")";
}
$record .= ".";
if (!empty($row['place'])) // place
$record .= " " . $row['place'];
if (!empty($row['publisher'])) // publisher
{
if (!empty($row['place']))
$record .= ":";
$record .= " " . $row['publisher'];
}
if (!preg_match("/\. *$/", $record))
$record .= ".";
}
// --- BEGIN TYPE = BOOK WHOLE / CONFERENCE VOLUME / JOURNAL / MANUAL / MANUSCRIPT / MAP / MISCELLANEOUS / PATENT / REPORT / SOFTWARE ---
else // if (preg_match("/Book Whole|Conference Volume|Journal|Manual|Manuscript|Map|Miscellaneous|Patent|Report|Software/", $row['type']))
// note that this also serves as a fallback: unrecognized resource types will be formatted similar to whole books
{
if (!empty($row['author'])) // author
{
$author = preg_replace("/[ \r\n]*\(eds?\)/i", "", $row['author']);
// Call the 'reArrangeAuthorContents()' function (defined in 'include.inc.php') in order to re-order contents of the author field. Required Parameters:
// 1. input: contents of the author field
// 2. input: boolean value that specifies whether the author's family name comes first (within one author) in the source string
// ('true' means that the family name is followed by the given name (or initials), 'false' if it's the other way around)
//
// 3. input: pattern describing old delimiter that separates different authors
// 4. output: for all authors except the last author: new delimiter that separates different authors
// 5. output: for the last author: new delimiter that separates the last author from all other authors
//
// 6. input: pattern describing old delimiter that separates author name & initials (within one author)
// 7. output: for the first author: new delimiter that separates author name & initials (within one author)
// 8. output: for all authors except the first author: new delimiter that separates author name & initials (within one author)
// 9. output: new delimiter that separates multiple initials (within one author)
// 10. output: for the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db)
// 11. output: for all authors except the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db)
// 12. output: boolean value that specifies whether an author's full given name(s) shall be shortened to initial(s)
//
// 13. output: if the total number of authors is greater than the given number (integer >= 1), only the number of authors given in (14) will be included in the citation along with the string given in (15); keep empty if all authors shall be returned
// 14. output: number of authors (integer >= 1) that is included in the citation if the total number of authors is greater than the number given in (13); keep empty if not applicable
// 15. output: string that's appended to the number of authors given in (14) if the total number of authors is greater than the number given in (13); the actual number of authors can be printed by including '__NUMBER_OF_AUTHORS__' (without quotes) within the string
//
// 16. output: boolean value that specifies whether the re-ordered string shall be returned with higher ASCII chars HTML encoded
$author = reArrangeAuthorContents($author, // 1.
true, // 2.
"/ *; */", // 3.
", ", // 4.
", " . $markupPatternsArray["ampersand"] . " ", // 5.
"/ *, */", // 6.
", ", // 7.
", ", // 8.
". ", // 9.
false, // 10.
false, // 11.
true, // 12.
"6", // 13.
"6", // 14.
", et al.", // 15.
$encodeHTML); // 16.
// if the author is actually the editor of the resource we'll append ', ed' (or ', eds') to the author string:
// [to distinguish editors from authors in the 'author' field, the 'modify.php' script does append ' (ed)' or ' (eds)' if appropriate,
// so we're just checking for these identifier strings here. Alternatively, we could check whether the editor field matches the author field]
if (preg_match("/[ \r\n]*\(ed\)/", $row['author'])) // single editor
$author = $author . " (Ed.).";
elseif (preg_match("/[ \r\n]*\(eds\)/", $row['author'])) // multiple editors
$author = $author . " (Eds.).";
if (!preg_match("/\. *$/", $author))
$record .= $author . ".";
else
$record .= $author;
}
if (!empty($row['year'])) // year
{
if (!empty($row['author']))
$record .= " ";
$record .= "(" . $row['year'] . ").";
}
if (!empty($row['title'])) // title
{
if (!empty($row['author']) || !empty($row['year']))
$record .= " ";
if ($row['type'] == "Software") // except for software, the title is printed in italics
$record .= $row['title'];
else
$record .= $markupPatternsArray["italic-prefix"] . $row['title'] . $markupPatternsArray["italic-suffix"];
}
if (!empty($row['editor']) && !preg_match("/[ \r\n]*\(eds?\)/", $row['author'])) // editor (if different from author, see note above regarding the check for ' (ed)' or ' (eds)')
{
// Call the 'reArrangeAuthorContents()' function (defined in 'include.inc.php') in order to re-order contents of the author field. Required Parameters:
// 1. input: contents of the author field
// 2. input: boolean value that specifies whether the author's family name comes first (within one author) in the source string
// ('true' means that the family name is followed by the given name (or initials), 'false' if it's the other way around)
//
// 3. input: pattern describing old delimiter that separates different authors
// 4. output: for all authors except the last author: new delimiter that separates different authors
// 5. output: for the last author: new delimiter that separates the last author from all other authors
//
// 6. input: pattern describing old delimiter that separates author name & initials (within one author)
// 7. output: for the first author: new delimiter that separates author name & initials (within one author)
// 8. output: for all authors except the first author: new delimiter that separates author name & initials (within one author)
// 9. output: new delimiter that separates multiple initials (within one author)
// 10. output: for the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db)
// 11. output: for all authors except the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db)
// 12. output: boolean value that specifies whether an author's full given name(s) shall be shortened to initial(s)
//
// 13. output: if the total number of authors is greater than the given number (integer >= 1), only the number of authors given in (14) will be included in the citation along with the string given in (15); keep empty if all authors shall be returned
// 14. output: number of authors (integer >= 1) that is included in the citation if the total number of authors is greater than the number given in (13); keep empty if not applicable
// 15. output: string that's appended to the number of authors given in (14) if the total number of authors is greater than the number given in (13); the actual number of authors can be printed by including '__NUMBER_OF_AUTHORS__' (without quotes) within the string
//
// 16. output: boolean value that specifies whether the re-ordered string shall be returned with higher ASCII chars HTML encoded
$editor = reArrangeAuthorContents($row['editor'], // 1.
true, // 2.
"/ *; */", // 3.
", ", // 4.
", " . $markupPatternsArray["ampersand"] . " ", // 5.
"/ *, */", // 6.
" ", // 7.
" ", // 8.
". ", // 9.
true, // 10.
true, // 11.
true, // 12.
"6", // 13.
"6", // 14.
", et al.", // 15.
$encodeHTML); // 16.
if (!empty($row['author']) || !empty($row['year']) || !empty($row['title']))
$record .= " ";
$record .= " (" . $editor . ", ";
if (preg_match("/^[^;\r\n]+(;[^;\r\n]+)+$/", $row['editor'])) // there are at least two editors (separated by ';')
$record .= "Eds.";
else // there's only one editor (or the editor field is malformed with multiple editors but missing ';' separator[s])
$record .= "Ed.";
$record .= ")";
}
if (!empty($row['edition']) || !empty($row['volume']))
{
if (!empty($row['author']) || !empty($row['year']) || !empty($row['title']) || (!empty($row['editor']) && !preg_match("/[ \r\n]*\(eds?\)/", $row['author'])))
$record .= " ";
$record .= "(";
if ($row['type'] == "Software") // software edition (=version)
{
$record .= "Version " . $row['edition'];
}
elseif (!preg_match("/^(1|1st|first|one)( ed\.?| edition)?$/i", $row['edition'])) // regular edition (other than the first)
{
if (preg_match("/^\d{1,3}$/", $row['edition'])) // if the edition field contains a number of up to three digits, we assume it's an edition number (such as "2nd ed.")
{
if ($row['edition'] == "2")
$editionSuffix = "nd";
elseif ($row['edition'] == "3")
$editionSuffix = "rd";
else
$editionSuffix = "th";
}
else
$editionSuffix = "";
if (!empty($row['edition']) && !preg_match("/( ed\.?| edition)$/i", $row['edition']))
$editionSuffix .= " ed.";
$record .= $row['edition'] . $editionSuffix;
}
if (!empty($row['volume'])) // volume
{
if (!empty($row['edition']) && !preg_match("/^(1|1st|first|one)( ed\.?| edition)?$/i", $row['edition']))
$record .= ", ";
$record .= "Vol. " . $row['volume'];
}
$record .= ")";
}
if ($row['type'] == "Software") // for software, add software label
{
$record .= " [Computer software]";
}
else // add series info, thesis info, and publisher & place
{
if ((!empty($row['title']) && !preg_match("/[?!.]$/", $row['title'])) || (!empty($row['editor']) && !preg_match("/[ \r\n]*\(eds?\)/", $row['author'])) || !empty($row['edition']) || !empty($row['volume']))
$record .= ".";
if (!empty($row['abbrev_series_title']) OR !empty($row['series_title'])) // if there's either a full or an abbreviated series title
{
$record .= " ";
if (!empty($row['abbrev_series_title']))
$record .= $row['abbrev_series_title']; // abbreviated series title
// if there's no abbreviated series title, we'll use the full series title instead:
elseif (!empty($row['series_title']))
$record .= $row['series_title']; // full series title
if (!empty($row['series_volume'])||!empty($row['series_issue']))
$record .= ", ";
if (!empty($row['series_volume'])) // series volume (I'm not really sure if -- for this cite style -- the series volume & issue should be rather omitted here)
$record .= $row['series_volume'];
if (!empty($row['series_issue'])) // series issue (see note for series volume)
$record .= "(" . $row['series_issue'] . ")";
$record .= ".";
}
if (!empty($row['thesis'])) // thesis
{
$record .= " " . $row['thesis'];
$record .= ", " . $row['publisher'];
$record .= ", " . $row['place'];
}
else // not a thesis
{
if (!empty($row['place'])) // place
$record .= " " . $row['place'];
if (!empty($row['publisher'])) // publisher
{
if (!empty($row['place']))
$record .= ":";
if ($row['author'] == $row['publisher']) // in APA style, the string "Author" is used instead of the publisher's name when the author and publisher are identical
$record .= " Author";
else
$record .= " " . $row['publisher'];
}
}
}
if ($row['online_publication'] == "yes" || $row['type'] == "Software") // this record refers to an online article, or a computer program/software
{
if (!empty($row['online_citation'])) // online_citation
{
if (!preg_match("/\. *$/", $record))
$record .= ".";
$record .= " " . $row['online_citation'];
}
if (!empty($row['doi']) || !empty($row['url']))
{
if (!preg_match("/\. *$/", $record))
$record .= ".";
if ($row['type'] == "Software")
{
$record .= " Available from ";
}
else
{
$today = date("F j, Y");
$record .= " Retrieved " . $today . ", from ";
}
if (!empty($row['doi'])) // doi
{
if ($encodeHTML)
$record .= encodeHTML("http://dx.doi.org/" . $row['doi']);
else
$record .= "http://dx.doi.org/" . $row['doi'];
}
elseif (!empty($row['url'])) // url
{
if ($encodeHTML)
$record .= encodeHTML($row['url']);
else
$record .= $row['url'];
}
}
}
if (!preg_match("/\. *$/", $record) && !(($row['online_publication'] == "yes" || $row['type'] == "Software") && !empty($row['url']))) // if the string doesn't end with a period or no URL/DOI was given
$record .= ".";
}
// --- BEGIN POST-PROCESSING -----------------------------------------------------------------------------------------------------------
// do some further cleanup:
$record = trim($record); // remove any preceding or trailing whitespace
return $record;
}
// --- END CITATION STYLE ---
?>

View File

@@ -0,0 +1,471 @@
<?php
// Project: Web Reference Database (refbase) <http://www.refbase.net>
// Copyright: Matthias Steffens <mailto:refbase@extracts.de> and the file's
// original author(s).
//
// This code is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY. Please see the GNU General Public
// License for more details.
//
// File: ./cite/styles/cite_AnnGlaciol_JGlaciol.php
// Repository: $HeadURL: file:///svn/p/refbase/code/branches/bleeding-edge/cite/styles/cite_AnnGlaciol_JGlaciol.php $
// Author(s): Matthias Steffens <mailto:refbase@extracts.de>
//
// Created: 07-Sep-05, 14:53
// Modified: $Date: 2012-02-27 20:25:30 +0000 (Mon, 27 Feb 2012) $
// $Author: msteffens $
// $Revision: 1337 $
// This is a citation style file (which must reside within the 'cite/styles/' sub-directory of your refbase root directory). It contains a
// version of the 'citeRecord()' function that outputs a reference list from selected records according to the citation style used by
// the journals "Annals of Glaciology" and "Journal of Glaciology" (International Glaciological Society, www.igsoc.org).
// --------------------------------------------------------------------
// --- BEGIN CITATION STYLE ---
function citeRecord($row, $citeStyle, $citeType, $markupPatternsArray, $encodeHTML)
{
$record = ""; // make sure that our buffer variable is empty
// --- BEGIN TYPE = JOURNAL ARTICLE / MAGAZINE ARTICLE / NEWSPAPER ARTICLE --------------------------------------------------------------
if (preg_match("/^(Journal Article|Magazine Article|Newspaper Article)$/", $row['type']))
{
if (!empty($row['author'])) // author
{
// Call the 'reArrangeAuthorContents()' function (defined in 'include.inc.php') in order to re-order contents of the author field. Required Parameters:
// 1. input: contents of the author field
// 2. input: boolean value that specifies whether the author's family name comes first (within one author) in the source string
// ('true' means that the family name is followed by the given name (or initials), 'false' if it's the other way around)
//
// 3. input: pattern describing old delimiter that separates different authors
// 4. output: for all authors except the last author: new delimiter that separates different authors
// 5. output: for the last author: new delimiter that separates the last author from all other authors
//
// 6. input: pattern describing old delimiter that separates author name & initials (within one author)
// 7. output: for the first author: new delimiter that separates author name & initials (within one author)
// 8. output: for all authors except the first author: new delimiter that separates author name & initials (within one author)
// 9. output: new delimiter that separates multiple initials (within one author)
// 10. output: for the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db)
// 11. output: for all authors except the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db)
// 12. output: boolean value that specifies whether an author's full given name(s) shall be shortened to initial(s)
//
// 13. output: if the total number of authors is greater than the given number (integer >= 1), only the number of authors given in (14) will be included in the citation along with the string given in (15); keep empty if all authors shall be returned
// 14. output: number of authors (integer >= 1) that is included in the citation if the total number of authors is greater than the number given in (13); keep empty if not applicable
// 15. output: string that's appended to the number of authors given in (14) if the total number of authors is greater than the number given in (13); the actual number of authors can be printed by including '__NUMBER_OF_AUTHORS__' (without quotes) within the string
//
// 16. output: boolean value that specifies whether the re-ordered string shall be returned with higher ASCII chars HTML encoded
$author = reArrangeAuthorContents($row['author'], // 1.
true, // 2.
"/ *; */", // 3.
", ", // 4.
" and ", // 5.
"/ *, */", // 6.
", ", // 7.
" ", // 8.
".", // 9.
false, // 10.
true, // 11.
true, // 12.
"6", // 13.
"1", // 14.
" " . $markupPatternsArray["italic-prefix"] . "and __NUMBER_OF_AUTHORS__ others" . $markupPatternsArray["italic-suffix"], // 15.
$encodeHTML); // 16.
if (!preg_match("/\. *$/", $author))
$record .= $author . ".";
else
$record .= $author;
}
if (!empty($row['year'])) // year
{
if (!empty($row['author']))
$record .= " ";
$record .= $row['year'] . ".";
}
if (!empty($row['title'])) // title
{
if (!empty($row['author']) || !empty($row['year']))
$record .= " ";
$record .= $row['title'];
if (!preg_match("/[?!.]$/", $row['title']))
$record .= ".";
}
// From here on we'll assume that at least one of the fields 'author', 'year' or 'title' did contain some contents
// if this is not the case, the output string will begin with a space. However, any preceding/trailing whitespace will be removed at the cleanup stage (see below)
if (!empty($row['abbrev_journal'])) // abbreviated journal name
$record .= " " . $markupPatternsArray["italic-prefix"] . $row['abbrev_journal'] . $markupPatternsArray["italic-suffix"];
// if there's no abbreviated journal name, we'll use the full journal name
elseif (!empty($row['publication'])) // publication (= journal) name
$record .= " " . $markupPatternsArray["italic-prefix"] . $row['publication'] . $markupPatternsArray["italic-suffix"];
if (!empty($row['volume'])) // volume
{
if (!empty($row['abbrev_journal']) || !empty($row['publication']))
$record .= ",";
$record .= " " . $markupPatternsArray["bold-prefix"] . $row['volume'] . $markupPatternsArray["bold-suffix"];
}
if (!empty($row['issue'])) // issue
$record .= "(" . $row['issue'] . ")";
if ($row['online_publication'] == "yes") // this record refers to an online article
{
// instead of any pages info (which normally doesn't exist for online publications) we append
// an optional string (given in 'online_citation') plus the DOI:
if (!empty($row['online_citation'])) // online_citation
{
if (!empty($row['volume']) || !empty($row['issue']) || !empty($row['abbrev_journal']) || !empty($row['publication'])) // only add "," if either volume, issue, abbrev_journal or publication isn't empty
$record .= ",";
$record .= " " . $row['online_citation'];
}
if (!empty($row['doi'])) // doi
{
if (!empty($row['online_citation']) OR (empty($row['online_citation']) AND (!empty($row['volume']) || !empty($row['issue']) || !empty($row['abbrev_journal']) || !empty($row['publication'])))) // only add "," if online_citation isn't empty, or else if either volume, issue, abbrev_journal or publication isn't empty
$record .= ".";
$record .= " (" . $row['doi'] . ".)";
}
}
else // $row['online_publication'] == "no" -> this record refers to a printed article, so we append any pages info instead:
{
if (!empty($row['pages'])) // pages
{
if (!empty($row['volume']) || !empty($row['issue']) || !empty($row['abbrev_journal']) || !empty($row['publication'])) // only add "," if either volume, issue, abbrev_journal or publication isn't empty
$record .= ", ";
$record .= formatPageInfo($row['pages'], $markupPatternsArray["endash"]); // function 'formatPageInfo()' is defined in 'cite.inc.php'
}
}
if (!preg_match("/\.\)? *$/", $record))
$record .= ".";
}
// --- BEGIN TYPE = ABSTRACT / BOOK CHAPTER / CONFERENCE ARTICLE ------------------------------------------------------------------------
elseif (preg_match("/^(Abstract|Book Chapter|Conference Article)$/", $row['type']))
{
if (!empty($row['author'])) // author
{
// Call the 'reArrangeAuthorContents()' function (defined in 'include.inc.php') in order to re-order contents of the author field. Required Parameters:
// 1. input: contents of the author field
// 2. input: boolean value that specifies whether the author's family name comes first (within one author) in the source string
// ('true' means that the family name is followed by the given name (or initials), 'false' if it's the other way around)
//
// 3. input: pattern describing old delimiter that separates different authors
// 4. output: for all authors except the last author: new delimiter that separates different authors
// 5. output: for the last author: new delimiter that separates the last author from all other authors
//
// 6. input: pattern describing old delimiter that separates author name & initials (within one author)
// 7. output: for the first author: new delimiter that separates author name & initials (within one author)
// 8. output: for all authors except the first author: new delimiter that separates author name & initials (within one author)
// 9. output: new delimiter that separates multiple initials (within one author)
// 10. output: for the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db)
// 11. output: for all authors except the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db)
// 12. output: boolean value that specifies whether an author's full given name(s) shall be shortened to initial(s)
//
// 13. output: if the total number of authors is greater than the given number (integer >= 1), only the number of authors given in (14) will be included in the citation along with the string given in (15); keep empty if all authors shall be returned
// 14. output: number of authors (integer >= 1) that is included in the citation if the total number of authors is greater than the number given in (13); keep empty if not applicable
// 15. output: string that's appended to the number of authors given in (14) if the total number of authors is greater than the number given in (13); the actual number of authors can be printed by including '__NUMBER_OF_AUTHORS__' (without quotes) within the string
//
// 16. output: boolean value that specifies whether the re-ordered string shall be returned with higher ASCII chars HTML encoded
$author = reArrangeAuthorContents($row['author'], // 1.
true, // 2.
"/ *; */", // 3.
", ", // 4.
" and ", // 5.
"/ *, */", // 6.
", ", // 7.
" ", // 8.
".", // 9.
false, // 10.
true, // 11.
true, // 12.
"6", // 13.
"1", // 14.
" " . $markupPatternsArray["italic-prefix"] . "and __NUMBER_OF_AUTHORS__ others" . $markupPatternsArray["italic-suffix"], // 15.
$encodeHTML); // 16.
if (!preg_match("/\. *$/", $author))
$record .= $author . ".";
else
$record .= $author;
}
if (!empty($row['year'])) // year
{
if (!empty($row['author']))
$record .= " ";
$record .= $row['year'] . ".";
}
if (!empty($row['title'])) // title
{
if (!empty($row['author']) || !empty($row['year']))
$record .= " ";
$record .= $row['title'];
if (!preg_match("/[?!.]$/", $row['title']))
$record .= ".";
}
// From here on we'll assume that at least one of the fields 'author', 'year' or 'title' did contain some contents
// if this is not the case, the output string will begin with a space. However, any preceding/trailing whitespace will be removed at the cleanup stage (see below)
if (!empty($row['editor'])) // editor
{
// Call the 'reArrangeAuthorContents()' function (defined in 'include.inc.php') in order to re-order contents of the author field. Required Parameters:
// 1. input: contents of the author field
// 2. input: boolean value that specifies whether the author's family name comes first (within one author) in the source string
// ('true' means that the family name is followed by the given name (or initials), 'false' if it's the other way around)
//
// 3. input: pattern describing old delimiter that separates different authors
// 4. output: for all authors except the last author: new delimiter that separates different authors
// 5. output: for the last author: new delimiter that separates the last author from all other authors
//
// 6. input: pattern describing old delimiter that separates author name & initials (within one author)
// 7. output: for the first author: new delimiter that separates author name & initials (within one author)
// 8. output: for all authors except the first author: new delimiter that separates author name & initials (within one author)
// 9. output: new delimiter that separates multiple initials (within one author)
// 10. output: for the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db)
// 11. output: for all authors except the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db)
// 12. output: boolean value that specifies whether an author's full given name(s) shall be shortened to initial(s)
//
// 13. output: if the total number of authors is greater than the given number (integer >= 1), only the number of authors given in (14) will be included in the citation along with the string given in (15); keep empty if all authors shall be returned
// 14. output: number of authors (integer >= 1) that is included in the citation if the total number of authors is greater than the number given in (13); keep empty if not applicable
// 15. output: string that's appended to the number of authors given in (14) if the total number of authors is greater than the number given in (13); the actual number of authors can be printed by including '__NUMBER_OF_AUTHORS__' (without quotes) within the string
//
// 16. output: boolean value that specifies whether the re-ordered string shall be returned with higher ASCII chars HTML encoded
$editor = reArrangeAuthorContents($row['editor'], // 1.
true, // 2.
"/ *; */", // 3.
", ", // 4.
" and ", // 5.
"/ *, */", // 6.
", ", // 7.
" ", // 8.
".", // 9.
false, // 10.
true, // 11.
true, // 12.
"6", // 13.
"1", // 14.
" " . $markupPatternsArray["italic-prefix"] . "and __NUMBER_OF_AUTHORS__ others" . $markupPatternsArray["italic-suffix"], // 15.
$encodeHTML); // 16.
$record .= " " . $markupPatternsArray["italic-prefix"] . "In" . $markupPatternsArray["italic-suffix"] . " " . $editor;
if (preg_match("/^[^;\r\n]+(;[^;\r\n]+)+$/", $row['editor'])) // there are at least two editors (separated by ';')
$record .= ", " . $markupPatternsArray["italic-prefix"] . "eds" . $markupPatternsArray["italic-suffix"] . ".";
else // there's only one editor (or the editor field is malformed with multiple editors but missing ';' separator[s])
$record .= ", " . $markupPatternsArray["italic-prefix"] . "ed" . $markupPatternsArray["italic-suffix"] . ".";
}
$publication = preg_replace("/[ \r\n]*\(Eds?:[^\)\r\n]*\)/i", "", $row['publication']);
if (!empty($publication)) // publication
$record .= " " . $markupPatternsArray["italic-prefix"] . $publication . $markupPatternsArray["italic-suffix"] . ".";
if (!empty($row['place'])) // place
$record .= " " . $row['place'];
if (!empty($row['publisher'])) // publisher
{
if (!empty($row['place']))
$record .= ",";
$record .= " " . $row['publisher'];
}
if (!empty($row['pages'])) // pages
{
if (!empty($row['place']) || !empty($row['publisher']))
$record .= ", ";
$record .= formatPageInfo($row['pages'], $markupPatternsArray["endash"]); // function 'formatPageInfo()' is defined in 'cite.inc.php'
}
if (!preg_match("/\. *$/", $record))
$record .= ".";
if (!empty($row['abbrev_series_title']) OR !empty($row['series_title'])) // if there's either a full or an abbreviated series title
{
$record .= " (";
if (!empty($row['abbrev_series_title']))
$record .= $row['abbrev_series_title']; // abbreviated series title
// if there's no abbreviated series title, we'll use the full series title instead:
elseif (!empty($row['series_title']))
$record .= $row['series_title']; // full series title
if (!empty($row['series_volume'])||!empty($row['series_issue']))
$record .= " ";
if (!empty($row['series_volume'])) // series volume
$record .= $row['series_volume'];
if (!empty($row['series_issue'])) // series issue (I'm not really sure if -- for this cite style -- the series issue should be rather omitted here)
$record .= "(" . $row['series_issue'] . ")";
$record .= ".)";
}
}
// --- BEGIN TYPE = BOOK WHOLE / CONFERENCE VOLUME / JOURNAL / MANUAL / MANUSCRIPT / MAP / MISCELLANEOUS / PATENT / REPORT / SOFTWARE ---
else // if (preg_match("/Book Whole|Conference Volume|Journal|Manual|Manuscript|Map|Miscellaneous|Patent|Report|Software/", $row['type']))
// note that this also serves as a fallback: unrecognized resource types will be formatted similar to whole books
{
if (!empty($row['author'])) // author
{
$author = preg_replace("/[ \r\n]*\(eds?\)/i", "", $row['author']);
// Call the 'reArrangeAuthorContents()' function (defined in 'include.inc.php') in order to re-order contents of the author field. Required Parameters:
// 1. input: contents of the author field
// 2. input: boolean value that specifies whether the author's family name comes first (within one author) in the source string
// ('true' means that the family name is followed by the given name (or initials), 'false' if it's the other way around)
//
// 3. input: pattern describing old delimiter that separates different authors
// 4. output: for all authors except the last author: new delimiter that separates different authors
// 5. output: for the last author: new delimiter that separates the last author from all other authors
//
// 6. input: pattern describing old delimiter that separates author name & initials (within one author)
// 7. output: for the first author: new delimiter that separates author name & initials (within one author)
// 8. output: for all authors except the first author: new delimiter that separates author name & initials (within one author)
// 9. output: new delimiter that separates multiple initials (within one author)
// 10. output: for the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db)
// 11. output: for all authors except the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db)
// 12. output: boolean value that specifies whether an author's full given name(s) shall be shortened to initial(s)
//
// 13. output: if the total number of authors is greater than the given number (integer >= 1), only the number of authors given in (14) will be included in the citation along with the string given in (15); keep empty if all authors shall be returned
// 14. output: number of authors (integer >= 1) that is included in the citation if the total number of authors is greater than the number given in (13); keep empty if not applicable
// 15. output: string that's appended to the number of authors given in (14) if the total number of authors is greater than the number given in (13); the actual number of authors can be printed by including '__NUMBER_OF_AUTHORS__' (without quotes) within the string
//
// 16. output: boolean value that specifies whether the re-ordered string shall be returned with higher ASCII chars HTML encoded
$author = reArrangeAuthorContents($author, // 1.
true, // 2.
"/ *; */", // 3.
", ", // 4.
" and ", // 5.
"/ *, */", // 6.
", ", // 7.
" ", // 8.
".", // 9.
false, // 10.
true, // 11.
true, // 12.
"6", // 13.
"1", // 14.
" " . $markupPatternsArray["italic-prefix"] . "and __NUMBER_OF_AUTHORS__ others" . $markupPatternsArray["italic-suffix"], // 15.
$encodeHTML); // 16.
// if the author is actually the editor of the resource we'll append ', ed' (or ', eds') to the author string:
// [to distinguish editors from authors in the 'author' field, the 'modify.php' script does append ' (ed)' or ' (eds)' if appropriate,
// so we're just checking for these identifier strings here. Alternatively, we could check whether the editor field matches the author field]
if (preg_match("/[ \r\n]*\(ed\)/", $row['author'])) // single editor
$author = $author . ", " . $markupPatternsArray["italic-prefix"] . "ed" . $markupPatternsArray["italic-suffix"];
elseif (preg_match("/[ \r\n]*\(eds\)/", $row['author'])) // multiple editors
$author = $author . ", " . $markupPatternsArray["italic-prefix"] . "eds" . $markupPatternsArray["italic-suffix"];
if (!preg_match("/\. *$/", $author))
$record .= $author . ".";
else
$record .= $author;
}
if (!empty($row['year'])) // year
{
if (!empty($row['author']))
$record .= " ";
$record .= $row['year'] . ".";
}
if (!empty($row['title'])) // title
{
if (!empty($row['author']) || !empty($row['year']))
$record .= " ";
$record .= $markupPatternsArray["italic-prefix"] . $row['title'] . $markupPatternsArray["italic-suffix"];
if (!preg_match("/[?!.]$/", $row['title']))
$record .= ".";
}
if (!empty($row['thesis'])) // thesis
{
$record .= " (" . $row['thesis'];
$record .= ", " . $row['publisher'] . ".)";
}
else // not a thesis
{
if (!empty($row['place'])) // place
$record .= " " . $row['place'];
if (!empty($row['publisher'])) // publisher
{
if (!empty($row['place']))
$record .= ",";
$record .= " " . $row['publisher'];
}
// if (!empty($row['pages'])) // pages
// {
// if (!empty($row['place']) || !empty($row['publisher']))
// $record .= ", ";
//
// $record .= formatPageInfo($row['pages'], $markupPatternsArray["endash"]); // function 'formatPageInfo()' is defined in 'cite.inc.php'
// }
if (!preg_match("/\. *$/", $record))
$record .= ".";
}
if (!empty($row['abbrev_series_title']) OR !empty($row['series_title'])) // if there's either a full or an abbreviated series title
{
$record .= " (";
if (!empty($row['abbrev_series_title']))
$record .= $row['abbrev_series_title']; // abbreviated series title
// if there's no abbreviated series title, we'll use the full series title instead:
elseif (!empty($row['series_title']))
$record .= $row['series_title']; // full series title
if (!empty($row['series_volume'])||!empty($row['series_issue']))
$record .= " ";
if (!empty($row['series_volume'])) // series volume
$record .= $row['series_volume'];
if (!empty($row['series_issue'])) // series issue (I'm not really sure if -- for this cite style -- the series issue should be rather omitted here)
$record .= "(" . $row['series_issue'] . ")";
$record .= ".)";
}
}
// --- BEGIN POST-PROCESSING -----------------------------------------------------------------------------------------------------------
// do some further cleanup:
$record = trim($record); // remove any preceding or trailing whitespace
return $record;
}
// --- END CITATION STYLE ---
?>

View File

@@ -0,0 +1,629 @@
<?php
// Project: Web Reference Database (refbase) <http://www.refbase.net>
// Copyright: Matthias Steffens <mailto:refbase@extracts.de> and the file's
// original author(s).
//
// This code is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY. Please see the GNU General Public
// License for more details.
//
// File: ./cite/styles/cite_Chicago.php
// Repository: $HeadURL$
// Author(s): Matthias Steffens <mailto:refbase@extracts.de> and
// Richard Karnesky <mailto:karnesky@gmail.com>
//
// Created: 25-Feb-08, 20:05
// Modified: $Date: 2012-02-27 20:25:30 +0000 (Mon, 27 Feb 2012) $
// $Author$
// $Revision: 1337 $
// This is a citation style file (which must reside within the 'cite/styles/' sub-directory of your refbase root directory). It contains a
// version of the 'citeRecord()' function that outputs a reference list from selected records according to the citation style documented
// in the "Chicago Manual of Style" (2003), and Kate Turabian's "Manual for Writer's of Term Papers, Theses, and Dissertations" (1996)
// based on 'cite_MLA.php'
// TODO: - newspaper & magazine articles, conference proceedings, manuals, patents, reports, software -> see e.g. examples at <http://www.library.hbs.edu/guides/citationguide.pdf>
// - " and " vs. ", and "?
// --------------------------------------------------------------------
// --- BEGIN CITATION STYLE ---
function citeRecord($row, $citeStyle, $citeType, $markupPatternsArray, $encodeHTML)
{
$record = ""; // make sure that our buffer variable is empty
// --- BEGIN TYPE = JOURNAL ARTICLE / MAGAZINE ARTICLE / NEWSPAPER ARTICLE --------------------------------------------------------------
if (preg_match("/^(Journal Article|Magazine Article|Newspaper Article)$/", $row['type']))
{
if (!empty($row['author'])) // author
{
// Call the 'reArrangeAuthorContents()' function (defined in 'include.inc.php') in order to re-order contents of the author field. Required Parameters:
// 1. input: contents of the author field
// 2. input: boolean value that specifies whether the author's family name comes first (within one author) in the source string
// ('true' means that the family name is followed by the given name (or initials), 'false' if it's the other way around)
//
// 3. input: pattern describing old delimiter that separates different authors
// 4. output: for all authors except the last author: new delimiter that separates different authors
// 5. output: for the last author: new delimiter that separates the last author from all other authors
//
// 6. input: pattern describing old delimiter that separates author name & initials (within one author)
// 7. output: for the first author: new delimiter that separates author name & initials (within one author)
// 8. output: for all authors except the first author: new delimiter that separates author name & initials (within one author)
// 9. output: new delimiter that separates multiple initials (within one author)
// 10. output: for the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db)
// 11. output: for all authors except the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db)
// 12. output: boolean value that specifies whether an author's full given name(s) shall be shortened to initial(s)
//
// 13. output: if the total number of authors is greater than the given number (integer >= 1), only the number of authors given in (14) will be included in the citation along with the string given in (15); keep empty if all authors shall be returned
// 14. output: number of authors (integer >= 1) that is included in the citation if the total number of authors is greater than the number given in (13); keep empty if not applicable
// 15. output: string that's appended to the number of authors given in (14) if the total number of authors is greater than the number given in (13); the actual number of authors can be printed by including '__NUMBER_OF_AUTHORS__' (without quotes) within the string
//
// 16. output: boolean value that specifies whether the re-ordered string shall be returned with higher ASCII chars HTML encoded
$author = reArrangeAuthorContents($row['author'], // 1.
true, // 2.
"/ *; */", // 3.
", ", // 4.
", and ", // 5.
"/ *, */", // 6.
", ", // 7.
" ", // 8.
". ", // 9.
false, // 10.
true, // 11.
false, // 12.
"10", // 13.
"10", // 14.
" et al.", // 15.
$encodeHTML // 16.
);
if (!preg_match("/\. *$/", $author))
$record .= $author . ".";
else
$record .= $author;
}
if (!empty($row['title'])) // title
{
if (!empty($row['author']))
$record .= " ";
$record .= '"' . $row['title'];
if (!preg_match("/[?!.]$/", $row['title']))
$record .= ".";
$record .= '"';
}
// From here on we'll assume that at least either the 'author' or the 'title' field did contain some contents
// if this is not the case, the output string will begin with a space. However, any preceding/trailing whitespace will be removed at the cleanup stage (see below)
if (!empty($row['publication'])) // publication (= journal) name
$record .= " " . $markupPatternsArray["italic-prefix"] . $row['publication'] . $markupPatternsArray["italic-suffix"];
// if there's no full journal name, we'll use the abbreviated journal name
elseif (!empty($row['abbrev_journal'])) // abbreviated journal name
$record .= " " . $markupPatternsArray["italic-prefix"] . $row['abbrev_journal'] . $markupPatternsArray["italic-suffix"];
if (!empty($row['volume'])) // volume
$record .= " " . $row['volume'];
if (!empty($row['issue'])) // issue
$record .= ", no. " . $row['issue'];
if (!empty($row['year'])) // year
$record .= " (" . $row['year'] . ")";
if (!empty($row['pages'])) // pages
{
if (!empty($row['year']) || !empty($row['volume']) || !empty($row['issue']) || !empty($row['abbrev_journal']) || !empty($row['publication'])) // only add ": " if either year, volume, issue, abbrev_journal or publication isn't empty
$record .= ": ";
$record .= formatPageInfo($row['pages'], $markupPatternsArray["endash"]); // function 'formatPageInfo()' is defined in 'cite.inc.php'
}
if ($row['online_publication'] == "yes") // this record refers to an online article
{
// append an optional string (given in 'online_citation') plus the current date and the DOI (or URL):
$today = date("F j, Y");
if (!empty($row['online_citation'])) // online_citation
{
if (!empty($row['year']) || !empty($row['volume']) || !empty($row['issue']) || !empty($row['abbrev_journal']) || !empty($row['publication'])) // only add "," if either year, volume, issue, abbrev_journal or publication isn't empty
{
if (empty($row['pages']))
$record .= ":"; // print instead of pages
else
$record .= ","; // append to pages
}
$record .= " " . $row['online_citation'];
}
if (!empty($row['doi'])) // doi
{
if (!empty($row['online_citation']) OR (empty($row['online_citation']) AND (!empty($row['year']) || !empty($row['volume']) || !empty($row['issue']) || !empty($row['abbrev_journal']) || !empty($row['publication'])))) // only add "." if online_citation isn't empty, or else if either year, volume, issue, abbrev_journal or publication isn't empty
$record .= "."; // NOTE: some Chicago examples (e.g. <http://www.lib.berkeley.edu/instruct/guides/chicago-turabianstyle.pdf>) use a comma here (not sure what's correct)
if ($encodeHTML)
$record .= " " . encodeHTML("http://dx.doi.org/" . $row['doi']) . " (accessed " . $today . ")";
else
$record .= " " . "http://dx.doi.org/" . $row['doi'] . " (accessed " . $today . ")";
}
elseif (!empty($row['url'])) // url
{
if (!empty($row['online_citation']) OR (empty($row['online_citation']) AND (!empty($row['year']) || !empty($row['volume']) || !empty($row['issue']) || !empty($row['abbrev_journal']) || !empty($row['publication'])))) // only add "." if online_citation isn't empty, or else if either year, volume, issue, abbrev_journal or publication isn't empty
$record .= "."; // see note for doi
if ($encodeHTML)
$record .= " " . encodeHTML($row['url']) . " (accessed " . $today . ")";
else
$record .= " " . $row['url'] . " (accessed " . $today . ")";
}
}
if (!preg_match("/\. *$/", $record))
$record .= ".";
}
// --- BEGIN TYPE = ABSTRACT / BOOK CHAPTER / CONFERENCE ARTICLE ------------------------------------------------------------------------
elseif (preg_match("/^(Abstract|Book Chapter|Conference Article)$/", $row['type']))
{
if (!empty($row['author'])) // author
{
// Call the 'reArrangeAuthorContents()' function (defined in 'include.inc.php') in order to re-order contents of the author field. Required Parameters:
// 1. input: contents of the author field
// 2. input: boolean value that specifies whether the author's family name comes first (within one author) in the source string
// ('true' means that the family name is followed by the given name (or initials), 'false' if it's the other way around)
//
// 3. input: pattern describing old delimiter that separates different authors
// 4. output: for all authors except the last author: new delimiter that separates different authors
// 5. output: for the last author: new delimiter that separates the last author from all other authors
//
// 6. input: pattern describing old delimiter that separates author name & initials (within one author)
// 7. output: for the first author: new delimiter that separates author name & initials (within one author)
// 8. output: for all authors except the first author: new delimiter that separates author name & initials (within one author)
// 9. output: new delimiter that separates multiple initials (within one author)
// 10. output: for the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db)
// 11. output: for all authors except the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db)
// 12. output: boolean value that specifies whether an author's full given name(s) shall be shortened to initial(s)
//
// 13. output: if the total number of authors is greater than the given number (integer >= 1), only the number of authors given in (14) will be included in the citation along with the string given in (15); keep empty if all authors shall be returned
// 14. output: number of authors (integer >= 1) that is included in the citation if the total number of authors is greater than the number given in (13); keep empty if not applicable
// 15. output: string that's appended to the number of authors given in (14) if the total number of authors is greater than the number given in (13); the actual number of authors can be printed by including '__NUMBER_OF_AUTHORS__' (without quotes) within the string
//
// 16. output: boolean value that specifies whether the re-ordered string shall be returned with higher ASCII chars HTML encoded
$author = reArrangeAuthorContents($row['author'], // 1.
true, // 2.
"/ *; */", // 3.
", ", // 4.
", and ", // 5.
"/ *, */", // 6.
", ", // 7.
" ", // 8.
". ", // 9.
false, // 10.
true, // 11.
false, // 12.
"10", // 13.
"10", // 14.
" et al.", // 15.
$encodeHTML // 16.
);
if (!preg_match("/\. *$/", $author))
$record .= $author . ".";
else
$record .= $author;
}
if (!empty($row['title'])) // title
{
if (!empty($row['author']))
$record .= " ";
$record .= '"' . $row['title'];
if (!preg_match("/[?!.]$/", $row['title']))
$record .= ".";
$record .= '"';
}
$publication = preg_replace("/[ \r\n]*\(Eds?:[^\)\r\n]*\)/i", "", $row['publication']);
if (!empty($publication)) // publication
$record .= " In " . $markupPatternsArray["italic-prefix"] . $publication . $markupPatternsArray["italic-suffix"];
// From here on we'll assume that at least either the 'author' or the 'title' field did contain some contents
// if this is not the case, the output string will begin with a space. However, any preceding/trailing whitespace will be removed at the cleanup stage (see below)
if (!empty($row['editor'])) // editor
{
// Call the 'reArrangeAuthorContents()' function (defined in 'include.inc.php') in order to re-order contents of the author field. Required Parameters:
// 1. input: contents of the author field
// 2. input: boolean value that specifies whether the author's family name comes first (within one author) in the source string
// ('true' means that the family name is followed by the given name (or initials), 'false' if it's the other way around)
//
// 3. input: pattern describing old delimiter that separates different authors
// 4. output: for all authors except the last author: new delimiter that separates different authors
// 5. output: for the last author: new delimiter that separates the last author from all other authors
//
// 6. input: pattern describing old delimiter that separates author name & initials (within one author)
// 7. output: for the first author: new delimiter that separates author name & initials (within one author)
// 8. output: for all authors except the first author: new delimiter that separates author name & initials (within one author)
// 9. output: new delimiter that separates multiple initials (within one author)
// 10. output: for the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db)
// 11. output: for all authors except the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db)
// 12. output: boolean value that specifies whether an author's full given name(s) shall be shortened to initial(s)
//
// 13. output: if the total number of authors is greater than the given number (integer >= 1), only the number of authors given in (14) will be included in the citation along with the string given in (15); keep empty if all authors shall be returned
// 14. output: number of authors (integer >= 1) that is included in the citation if the total number of authors is greater than the number given in (13); keep empty if not applicable
// 15. output: string that's appended to the number of authors given in (14) if the total number of authors is greater than the number given in (13); the actual number of authors can be printed by including '__NUMBER_OF_AUTHORS__' (without quotes) within the string
//
// 16. output: boolean value that specifies whether the re-ordered string shall be returned with higher ASCII chars HTML encoded
$editor = reArrangeAuthorContents($row['editor'], // 1.
true, // 2.
"/ *; */", // 3.
", ", // 4.
" and ", // 5.
"/ *, */", // 6.
" ", // 7.
" ", // 8.
". ", // 9.
true, // 10.
true, // 11.
false, // 12.
"10", // 13.
"10", // 14.
" et al.", // 15.
$encodeHTML // 16.
);
$record .= ", edited by " . $editor;
}
if (!empty($row['pages'])) // pages
$record .= ", " . formatPageInfo($row['pages'], $markupPatternsArray["endash"]); // function 'formatPageInfo()' is defined in 'cite.inc.php'
if (!empty($row['edition']) && !preg_match("/^(1|1st|first|one)( ed\.?| edition)?$/i", $row['edition'])) // edition
{
if (!preg_match("@[?!.][ \"" . $markupPatternsArray["italic-suffix"] . "]*$@", $record))
$record .= ".";
if (preg_match("/^\d{1,3}$/", $row['edition'])) // if the edition field contains a number of up to three digits, we assume it's an edition number (such as "2nd ed.")
{
if ($row['edition'] == "2")
$editionSuffix = "nd";
elseif ($row['edition'] == "3")
$editionSuffix = "rd";
else
$editionSuffix = "th";
}
else
$editionSuffix = "";
if (!preg_match("/( ed\.?| edition)$/i", $row['edition']))
$editionSuffix .= " ed.";
$record .= " " . $row['edition'] . $editionSuffix;
}
if (!empty($row['volume'])) // volume
{
if (!preg_match("@[?!.][ \"" . $markupPatternsArray["italic-suffix"] . "]*$@", $record))
$record .= ".";
$record .= " Vol. " . $row['volume'];
}
if (!empty($row['abbrev_series_title']) OR !empty($row['series_title'])) // if there's either a full or an abbreviated series title
{
if (!preg_match("@[?!.][ \"" . $markupPatternsArray["italic-suffix"] . "]*$@", $record))
$record .= ".";
$record .= " ";
if (!empty($row['abbrev_series_title']))
$record .= $row['abbrev_series_title']; // abbreviated series title
// if there's no abbreviated series title, we'll use the full series title instead:
elseif (!empty($row['series_title']))
$record .= $row['series_title']; // full series title
if (!empty($row['series_volume'])||!empty($row['series_issue']))
$record .= " ";
if (!empty($row['series_volume'])) // series volume
$record .= $row['series_volume'];
if (!empty($row['series_issue'])) // series issue (I'm not really sure if -- for this cite style -- the series issue should be rather omitted here)
$record .= ", no. " . $row['series_issue']; // is it correct to format series issues similar to journal article issues?
}
if (!preg_match("@[?!.][ \"" . $markupPatternsArray["italic-suffix"] . "]*$@", $record))
$record .= ".";
if (!empty($row['place'])) // place
$record .= " " . $row['place'];
if (!empty($row['publisher'])) // publisher
{
if (!empty($row['place']))
$record .= ":";
$record .= " " . $row['publisher'];
}
if (!empty($row['year'])) // year
$record .= ", " . $row['year'];
if (!preg_match("/\. *$/", $record))
$record .= ".";
}
// --- BEGIN TYPE = BOOK WHOLE / CONFERENCE VOLUME / JOURNAL / MANUAL / MANUSCRIPT / MAP / MISCELLANEOUS / PATENT / REPORT / SOFTWARE ---
else // if (preg_match("/Book Whole|Conference Volume|Journal|Manual|Manuscript|Map|Miscellaneous|Patent|Report|Software/", $row['type']))
// note that this also serves as a fallback: unrecognized resource types will be formatted similar to whole books
{
if (!empty($row['author'])) // author
{
$author = preg_replace("/[ \r\n]*\(eds?\)/i", "", $row['author']);
// Call the 'reArrangeAuthorContents()' function (defined in 'include.inc.php') in order to re-order contents of the author field. Required Parameters:
// 1. input: contents of the author field
// 2. input: boolean value that specifies whether the author's family name comes first (within one author) in the source string
// ('true' means that the family name is followed by the given name (or initials), 'false' if it's the other way around)
//
// 3. input: pattern describing old delimiter that separates different authors
// 4. output: for all authors except the last author: new delimiter that separates different authors
// 5. output: for the last author: new delimiter that separates the last author from all other authors
//
// 6. input: pattern describing old delimiter that separates author name & initials (within one author)
// 7. output: for the first author: new delimiter that separates author name & initials (within one author)
// 8. output: for all authors except the first author: new delimiter that separates author name & initials (within one author)
// 9. output: new delimiter that separates multiple initials (within one author)
// 10. output: for the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db)
// 11. output: for all authors except the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db)
// 12. output: boolean value that specifies whether an author's full given name(s) shall be shortened to initial(s)
//
// 13. output: if the total number of authors is greater than the given number (integer >= 1), only the number of authors given in (14) will be included in the citation along with the string given in (15); keep empty if all authors shall be returned
// 14. output: number of authors (integer >= 1) that is included in the citation if the total number of authors is greater than the number given in (13); keep empty if not applicable
// 15. output: string that's appended to the number of authors given in (14) if the total number of authors is greater than the number given in (13); the actual number of authors can be printed by including '__NUMBER_OF_AUTHORS__' (without quotes) within the string
//
// 16. output: boolean value that specifies whether the re-ordered string shall be returned with higher ASCII chars HTML encoded
$author = reArrangeAuthorContents($author, // 1.
true, // 2.
"/ *; */", // 3.
", ", // 4.
", and ", // 5.
"/ *, */", // 6.
", ", // 7.
" ", // 8.
". ", // 9.
false, // 10.
true, // 11.
false, // 12.
"10", // 13.
"10", // 14.
" et al.", // 15.
$encodeHTML // 16.
);
// if the author is actually the editor of the resource we'll append ', ed' (or ', eds') to the author string:
// [to distinguish editors from authors in the 'author' field, the 'modify.php' script does append ' (ed)' or ' (eds)' if appropriate,
// so we're just checking for these identifier strings here. Alternatively, we could check whether the editor field matches the author field]
if (preg_match("/[ \r\n]*\(ed\)/", $row['author'])) // single editor
$author = $author . ", ed";
elseif (preg_match("/[ \r\n]*\(eds\)/", $row['author'])) // multiple editors
$author = $author . ", eds";
if (!preg_match("/\. *$/", $author))
$record .= $author . ".";
else
$record .= $author;
}
if (!empty($row['title'])) // title
{
if (!empty($row['author']))
$record .= " ";
if (!empty($row['thesis'])) // thesis
{
$record .= '"' . $row['title'];
if (!preg_match("/[?!.]$/", $row['title']))
$record .= ".";
$record .= '"';
}
else // not a thesis
$record .= $markupPatternsArray["italic-prefix"] . $row['title'] . $markupPatternsArray["italic-suffix"];
}
if (!empty($row['editor']) && !preg_match("/[ \r\n]*\(eds?\)/", $row['author'])) // editor (if different from author, see note above regarding the check for ' (ed)' or ' (eds)')
{
// Call the 'reArrangeAuthorContents()' function (defined in 'include.inc.php') in order to re-order contents of the author field. Required Parameters:
// 1. input: contents of the author field
// 2. input: boolean value that specifies whether the author's family name comes first (within one author) in the source string
// ('true' means that the family name is followed by the given name (or initials), 'false' if it's the other way around)
//
// 3. input: pattern describing old delimiter that separates different authors
// 4. output: for all authors except the last author: new delimiter that separates different authors
// 5. output: for the last author: new delimiter that separates the last author from all other authors
//
// 6. input: pattern describing old delimiter that separates author name & initials (within one author)
// 7. output: for the first author: new delimiter that separates author name & initials (within one author)
// 8. output: for all authors except the first author: new delimiter that separates author name & initials (within one author)
// 9. output: new delimiter that separates multiple initials (within one author)
// 10. output: for the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db)
// 11. output: for all authors except the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db)
// 12. output: boolean value that specifies whether an author's full given name(s) shall be shortened to initial(s)
//
// 13. output: if the total number of authors is greater than the given number (integer >= 1), only the number of authors given in (14) will be included in the citation along with the string given in (15); keep empty if all authors shall be returned
// 14. output: number of authors (integer >= 1) that is included in the citation if the total number of authors is greater than the number given in (13); keep empty if not applicable
// 15. output: string that's appended to the number of authors given in (14) if the total number of authors is greater than the number given in (13); the actual number of authors can be printed by including '__NUMBER_OF_AUTHORS__' (without quotes) within the string
//
// 16. output: boolean value that specifies whether the re-ordered string shall be returned with higher ASCII chars HTML encoded
$editor = reArrangeAuthorContents($row['editor'], // 1.
true, // 2.
"/ *; */", // 3.
", ", // 4.
", and ", // 5.
"/ *, */", // 6.
" ", // 7.
" ", // 8.
". ", // 9.
true, // 10.
true, // 11.
false, // 12.
"10", // 13.
"10", // 14.
" et al.", // 15.
$encodeHTML // 16.
);
if (!preg_match("@[?!.][ \"" . $markupPatternsArray["italic-suffix"] . "]*$@", $record))
$record .= ".";
$record .= " Edited by " . $editor;
}
if (!empty($row['edition']) && !preg_match("/^(1|1st|first|one)( ed\.?| edition)?$/i", $row['edition'])) // edition
{
if (!preg_match("@[?!.][ \"" . $markupPatternsArray["italic-suffix"] . "]*$@", $record))
$record .= ".";
if (preg_match("/^\d{1,3}$/", $row['edition'])) // if the edition field contains a number of up to three digits, we assume it's an edition number (such as "2nd ed.")
{
if ($row['edition'] == "2")
$editionSuffix = "nd";
elseif ($row['edition'] == "3")
$editionSuffix = "rd";
else
$editionSuffix = "th";
}
else
$editionSuffix = "";
if (!preg_match("/( ed\.?| edition)$/i", $row['edition']))
$editionSuffix .= " ed.";
$record .= " " . $row['edition'] . $editionSuffix;
}
if (!empty($row['volume'])) // volume
{
if (!preg_match("@[?!.][ \"" . $markupPatternsArray["italic-suffix"] . "]*$@", $record))
$record .= ".";
$record .= " Vol. " . $row['volume'];
}
if (!empty($row['abbrev_series_title']) OR !empty($row['series_title'])) // if there's either a full or an abbreviated series title
{
if (!preg_match("@[?!.][ \"" . $markupPatternsArray["italic-suffix"] . "]*$@", $record))
$record .= ".";
$record .= " ";
if (!empty($row['abbrev_series_title']))
$record .= $row['abbrev_series_title']; // abbreviated series title
// if there's no abbreviated series title, we'll use the full series title instead:
elseif (!empty($row['series_title']))
$record .= $row['series_title']; // full series title
if (!empty($row['series_volume'])||!empty($row['series_issue']))
$record .= " ";
if (!empty($row['series_volume'])) // series volume
$record .= $row['series_volume'];
if (!empty($row['series_issue'])) // series issue (I'm not really sure if -- for this cite style -- the series issue should be rather omitted here)
$record .= ", no. " . $row['series_issue']; // is it correct to format series issues similar to journal article issues?
}
if (!empty($row['thesis'])) // thesis
{
if (!preg_match("@[?!.][ \"" . $markupPatternsArray["italic-suffix"] . "]*$@", $record))
$record .= ".";
$record .= " " . $row['thesis'];
$record .= ", " . $row['publisher'];
}
else // not a thesis
{
if (!preg_match("@[?!.][ \"" . $markupPatternsArray["italic-suffix"] . "]*$@", $record))
$record .= ".";
if (!empty($row['place'])) // place
$record .= " " . $row['place'];
if (!empty($row['publisher'])) // publisher
{
if (!empty($row['place']))
$record .= ":";
$record .= " " . $row['publisher'];
}
}
if (!empty($row['year'])) // year
$record .= ", ".$row['year'];
if ($row['online_publication'] == "yes") // this record refers to an online article
{
// append an optional string (given in 'online_citation') plus the current date and the DOI (or URL):
$today = date("F j, Y");
if (!empty($row['online_citation'])) // online_citation
{
if (!preg_match("/\. *$/", $record))
$record .= ".";
$record .= " " . $row['online_citation'];
}
if (!empty($row['doi'])) // doi
{
if (!preg_match("/\. *$/", $record))
$record .= ".";
if ($encodeHTML)
$record .= " " . encodeHTML("http://dx.doi.org/" . $row['doi']) . " (accessed " . $today . ")";
else
$record .= " " . "http://dx.doi.org/" . $row['doi'] . " (accessed " . $today . ")";
}
elseif (!empty($row['url'])) // url
{
if (!preg_match("/\. *$/", $record))
$record .= ".";
if ($encodeHTML)
$record .= " " . encodeHTML($row['url']) . " (accessed " . $today . ")";
else
$record .= " " . $row['url'] . " (accessed " . $today . ")";
}
}
if (!preg_match("/\. *$/", $record))
$record .= ".";
}
// --- BEGIN POST-PROCESSING -----------------------------------------------------------------------------------------------------------
// do some further cleanup:
$record = trim($record); // remove any preceding or trailing whitespace
return $record;
}
// --- END CITATION STYLE ---
?>

View File

@@ -0,0 +1,438 @@
<?php
// Project: Web Reference Database (refbase) <http://www.refbase.net>
// Copyright: Matthias Steffens <mailto:refbase@extracts.de> and the file's
// original author(s).
//
// This code is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY. Please see the GNU General Public
// License for more details.
//
// File: ./cite/styles/cite_DeepSeaRes.php
// Repository: $HeadURL: file:///svn/p/refbase/code/branches/bleeding-edge/cite/styles/cite_DeepSeaRes.php $
// Author(s): Matthias Steffens <mailto:refbase@extracts.de>
//
// Created: 28-Sep-04, 23:36
// Modified: $Date: 2012-02-27 20:25:30 +0000 (Mon, 27 Feb 2012) $
// $Author: msteffens $
// $Revision: 1337 $
// This is a citation style file (which must reside within the 'cite/styles/' sub-directory of your refbase root directory). It contains a
// version of the 'citeRecord()' function that outputs a reference list from selected records according to the citation style used by
// the journal "Deep Sea Research".
// --------------------------------------------------------------------
// --- BEGIN CITATION STYLE ---
function citeRecord($row, $citeStyle, $citeType, $markupPatternsArray, $encodeHTML)
{
global $alnum, $alpha, $cntrl, $dash, $digit, $graph, $lower, $print, $punct, $space, $upper, $word, $patternModifiers; // defined in 'transtab_unicode_charset.inc.php' and 'transtab_latin1_charset.inc.php'
$record = ""; // make sure that our buffer variable is empty
// --- BEGIN TYPE = JOURNAL ARTICLE / MAGAZINE ARTICLE / NEWSPAPER ARTICLE --------------------------------------------------------------
if (preg_match("/^(Journal Article|Magazine Article|Newspaper Article)$/", $row['type']))
{
if (!empty($row['author'])) // author
{
// Call the 'reArrangeAuthorContents()' function (defined in 'include.inc.php') in order to re-order contents of the author field. Required Parameters:
// 1. input: contents of the author field
// 2. input: boolean value that specifies whether the author's family name comes first (within one author) in the source string
// ('true' means that the family name is followed by the given name (or initials), 'false' if it's the other way around)
//
// 3. input: pattern describing old delimiter that separates different authors
// 4. output: for all authors except the last author: new delimiter that separates different authors
// 5. output: for the last author: new delimiter that separates the last author from all other authors
//
// 6. input: pattern describing old delimiter that separates author name & initials (within one author)
// 7. output: for the first author: new delimiter that separates author name & initials (within one author)
// 8. output: for all authors except the first author: new delimiter that separates author name & initials (within one author)
// 9. output: new delimiter that separates multiple initials (within one author)
// 10. output: for the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db)
// 11. output: for all authors except the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db)
// 12. output: boolean value that specifies whether an author's full given name(s) shall be shortened to initial(s)
//
// 13. output: if the total number of authors is greater than the given number (integer >= 1), only the number of authors given in (14) will be included in the citation along with the string given in (15); keep empty if all authors shall be returned
// 14. output: number of authors (integer >= 1) that is included in the citation if the total number of authors is greater than the number given in (13); keep empty if not applicable
// 15. output: string that's appended to the number of authors given in (14) if the total number of authors is greater than the number given in (13); the actual number of authors can be printed by including '__NUMBER_OF_AUTHORS__' (without quotes) within the string
//
// 16. output: boolean value that specifies whether the re-ordered string shall be returned with higher ASCII chars HTML encoded
$author = reArrangeAuthorContents($row['author'], // 1.
true, // 2.
"/ *; */", // 3.
", ", // 4.
", ", // 5.
"/ *, */", // 6.
", ", // 7.
", ", // 8.
".", // 9.
false, // 10.
false, // 11.
true, // 12.
"", // 13.
"", // 14.
" " . $markupPatternsArray["italic-prefix"] . "and __NUMBER_OF_AUTHORS__ others" . $markupPatternsArray["italic-suffix"], // 15.
$encodeHTML); // 16.
$record .= $author . ", ";
}
if (!empty($row['year'])) // year
$record .= $row['year'] . ". ";
if (!empty($row['title'])) // title
{
$record .= $row['title'];
if (!preg_match("/[?!.]$/", $row['title']))
$record .= ".";
$record .= " ";
}
if (!empty($row['publication'])) // publication
$record .= $row['publication'] . " ";
if (!empty($row['volume'])) // volume
$record .= $row['volume'];
if (!empty($row['issue'])) // issue
$record .= " (" . $row['issue'] . ")";
if ($row['online_publication'] == "yes") // this record refers to an online article
{
// instead of any pages info (which normally doesn't exist for online publications) we append
// an optional string (given in 'online_citation') plus the DOI:
if (!empty($row['online_citation'])) // online_citation
{
if (!empty($row['publication'])||!empty($row['volume'])||!empty($row['issue'])) // only add "," if either publication, volume or issue isn't empty
$record .= ",";
$record .= " " . $row['online_citation'];
}
if (!empty($row['doi'])) // doi
{
if (!empty($row['publication'])||!empty($row['volume'])||!empty($row['issue'])) // only add "," if either publication, volume or issue isn't empty
$record .= ",";
$record .= " doi:" . $row['doi'];
}
}
else // $row['online_publication'] == "no" -> this record refers to a printed article, so we append any pages info instead:
{
if (!empty($row['pages'])) // pages
{
if (!empty($row['volume'])||!empty($row['issue'])) // only add "," if either volume or issue isn't empty
$record .= ", ";
$record .= formatPageInfo($row['pages'], $markupPatternsArray["endash"], "", "", "pp"); // function 'formatPageInfo()' is defined in 'cite.inc.php'
}
}
if (!preg_match("/\. *$/", $record))
$record .= ".";
}
// --- BEGIN TYPE = ABSTRACT / BOOK CHAPTER / CONFERENCE ARTICLE ------------------------------------------------------------------------
elseif (preg_match("/^(Abstract|Book Chapter|Conference Article)$/", $row['type']))
{
if (!empty($row['author'])) // author
{
// Call the 'reArrangeAuthorContents()' function (defined in 'include.inc.php') in order to re-order contents of the author field. Required Parameters:
// 1. input: contents of the author field
// 2. input: boolean value that specifies whether the author's family name comes first (within one author) in the source string
// ('true' means that the family name is followed by the given name (or initials), 'false' if it's the other way around)
//
// 3. input: pattern describing old delimiter that separates different authors
// 4. output: for all authors except the last author: new delimiter that separates different authors
// 5. output: for the last author: new delimiter that separates the last author from all other authors
//
// 6. input: pattern describing old delimiter that separates author name & initials (within one author)
// 7. output: for the first author: new delimiter that separates author name & initials (within one author)
// 8. output: for all authors except the first author: new delimiter that separates author name & initials (within one author)
// 9. output: new delimiter that separates multiple initials (within one author)
// 10. output: for the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db)
// 11. output: for all authors except the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db)
// 12. output: boolean value that specifies whether an author's full given name(s) shall be shortened to initial(s)
//
// 13. output: if the total number of authors is greater than the given number (integer >= 1), only the number of authors given in (14) will be included in the citation along with the string given in (15); keep empty if all authors shall be returned
// 14. output: number of authors (integer >= 1) that is included in the citation if the total number of authors is greater than the number given in (13); keep empty if not applicable
// 15. output: string that's appended to the number of authors given in (14) if the total number of authors is greater than the number given in (13); the actual number of authors can be printed by including '__NUMBER_OF_AUTHORS__' (without quotes) within the string
//
// 16. output: boolean value that specifies whether the re-ordered string shall be returned with higher ASCII chars HTML encoded
$author = reArrangeAuthorContents($row['author'], // 1.
true, // 2.
"/ *; */", // 3.
", ", // 4.
", ", // 5.
"/ *, */", // 6.
", ", // 7.
", ", // 8.
".", // 9.
false, // 10.
false, // 11.
true, // 12.
"", // 13.
"", // 14.
" " . $markupPatternsArray["italic-prefix"] . "and __NUMBER_OF_AUTHORS__ others" . $markupPatternsArray["italic-suffix"], // 15.
$encodeHTML); // 16.
$record .= $author . ", ";
}
if (!empty($row['year'])) // year
$record .= $row['year'] . ". ";
if (!empty($row['title'])) // title
{
$record .= $row['title'];
if (!preg_match("/[?!.]$/", $row['title']))
$record .= ".";
$record .= " ";
}
if (!empty($row['editor'])) // editor
{
// Call the 'reArrangeAuthorContents()' function (defined in 'include.inc.php') in order to re-order contents of the author field. Required Parameters:
// 1. input: contents of the author field
// 2. input: boolean value that specifies whether the author's family name comes first (within one author) in the source string
// ('true' means that the family name is followed by the given name (or initials), 'false' if it's the other way around)
//
// 3. input: pattern describing old delimiter that separates different authors
// 4. output: for all authors except the last author: new delimiter that separates different authors
// 5. output: for the last author: new delimiter that separates the last author from all other authors
//
// 6. input: pattern describing old delimiter that separates author name & initials (within one author)
// 7. output: for the first author: new delimiter that separates author name & initials (within one author)
// 8. output: for all authors except the first author: new delimiter that separates author name & initials (within one author)
// 9. output: new delimiter that separates multiple initials (within one author)
// 10. output: for the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db)
// 11. output: for all authors except the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db)
// 12. output: boolean value that specifies whether an author's full given name(s) shall be shortened to initial(s)
//
// 13. output: if the total number of authors is greater than the given number (integer >= 1), only the number of authors given in (14) will be included in the citation along with the string given in (15); keep empty if all authors shall be returned
// 14. output: number of authors (integer >= 1) that is included in the citation if the total number of authors is greater than the number given in (13); keep empty if not applicable
// 15. output: string that's appended to the number of authors given in (14) if the total number of authors is greater than the number given in (13); the actual number of authors can be printed by including '__NUMBER_OF_AUTHORS__' (without quotes) within the string
//
// 16. output: boolean value that specifies whether the re-ordered string shall be returned with higher ASCII chars HTML encoded
$editor = reArrangeAuthorContents($row['editor'], // 1.
true, // 2.
"/ *; */", // 3.
", ", // 4.
", ", // 5.
"/ *, */", // 6.
", ", // 7.
", ", // 8.
".", // 9.
false, // 10.
false, // 11.
true, // 12.
"", // 13.
"", // 14.
" " . $markupPatternsArray["italic-prefix"] . "and __NUMBER_OF_AUTHORS__ others" . $markupPatternsArray["italic-suffix"], // 15.
$encodeHTML); // 16.
$record .= "In: " . $editor;
if (preg_match("/^[^;\r\n]+(;[^;\r\n]+)+$/", $row['editor'])) // there are at least two editors (separated by ';')
$record .= " (Eds.)";
else // there's only one editor (or the editor field is malformed with multiple editors but missing ';' separator[s])
$record .= " (Ed.)";
}
$publication = preg_replace("/[ \r\n]*\(Eds?:[^\)\r\n]*\)/i", "", $row['publication']);
if (!empty($publication)) // publication
$record .= ", " . $publication . ". ";
else
if (!empty($row['editor']))
$record .= ". ";
if (!empty($row['series_title'])) // if there's a series title, series information will replace the publisher & place information
{
$record .= $row['series_title']; // series title
if (!empty($row['series_volume'])||!empty($row['series_issue']))
$record .= " ";
if (!empty($row['series_volume'])) // series volume
$record .= $row['series_volume'];
if (!empty($row['series_issue'])) // series issue
$record .= "(" . $row['series_issue'] . ")";
if (!empty($row['pages']))
$record .= ", ";
}
else // if there's NO series title available, we'll insert the publisher & place instead:
{
if (!empty($row['publisher'])) // publisher
{
$record .= $row['publisher'];
if (!empty($row['place']))
$record .= ", ";
else
{
if (!preg_match("/,$/", $row['publisher']))
$record .= ",";
$record .= " ";
}
}
if (!empty($row['place'])) // place
{
$record .= $row['place'];
if (!empty($row['pages']))
{
if (!preg_match("/,$/", $row['place']))
$record .= ",";
$record .= " ";
}
}
}
if (!empty($row['pages'])) // pages
$record .= formatPageInfo($row['pages'], $markupPatternsArray["endash"], "p. ", "pp. ", "pp"); // function 'formatPageInfo()' is defined in 'cite.inc.php'
if (!preg_match("/\. *$/", $record))
$record .= ".";
}
// --- BEGIN TYPE = BOOK WHOLE / CONFERENCE VOLUME / JOURNAL / MANUAL / MANUSCRIPT / MAP / MISCELLANEOUS / PATENT / REPORT / SOFTWARE ---
else // if (preg_match("/Book Whole|Conference Volume|Journal|Manual|Manuscript|Map|Miscellaneous|Patent|Report|Software/", $row['type']))
// note that this also serves as a fallback: unrecognized resource types will be formatted similar to whole books
{
if (!empty($row['author'])) // author
{
$author = preg_replace("/[ \r\n]*\(eds?\)/i", "", $row['author']);
// Call the 'reArrangeAuthorContents()' function (defined in 'include.inc.php') in order to re-order contents of the author field. Required Parameters:
// 1. input: contents of the author field
// 2. input: boolean value that specifies whether the author's family name comes first (within one author) in the source string
// ('true' means that the family name is followed by the given name (or initials), 'false' if it's the other way around)
//
// 3. input: pattern describing old delimiter that separates different authors
// 4. output: for all authors except the last author: new delimiter that separates different authors
// 5. output: for the last author: new delimiter that separates the last author from all other authors
//
// 6. input: pattern describing old delimiter that separates author name & initials (within one author)
// 7. output: for the first author: new delimiter that separates author name & initials (within one author)
// 8. output: for all authors except the first author: new delimiter that separates author name & initials (within one author)
// 9. output: new delimiter that separates multiple initials (within one author)
// 10. output: for the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db)
// 11. output: for all authors except the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db)
// 12. output: boolean value that specifies whether an author's full given name(s) shall be shortened to initial(s)
//
// 13. output: if the total number of authors is greater than the given number (integer >= 1), only the number of authors given in (14) will be included in the citation along with the string given in (15); keep empty if all authors shall be returned
// 14. output: number of authors (integer >= 1) that is included in the citation if the total number of authors is greater than the number given in (13); keep empty if not applicable
// 15. output: string that's appended to the number of authors given in (14) if the total number of authors is greater than the number given in (13); the actual number of authors can be printed by including '__NUMBER_OF_AUTHORS__' (without quotes) within the string
//
// 16. output: boolean value that specifies whether the re-ordered string shall be returned with higher ASCII chars HTML encoded
$author = reArrangeAuthorContents($author, // 1.
true, // 2.
"/ *; */", // 3.
", ", // 4.
", ", // 5.
"/ *, */", // 6.
", ", // 7.
", ", // 8.
".", // 9.
false, // 10.
false, // 11.
true, // 12.
"", // 13.
"", // 14.
" " . $markupPatternsArray["italic-prefix"] . "and __NUMBER_OF_AUTHORS__ others" . $markupPatternsArray["italic-suffix"], // 15.
$encodeHTML); // 16.
$record .= $author . ", ";
}
if (!empty($row['year'])) // year
$record .= $row['year'] . ". ";
if (!empty($row['title'])) // title
{
$record .= $row['title'];
if (!preg_match("/[?!.]$/", $row['title']))
$record .= ".";
$record .= " ";
}
if (!empty($row['thesis'])) // thesis
$record .= $row['thesis'] . ". ";
if (!empty($row['publisher'])) // publisher
{
$record .= $row['publisher'];
if (!empty($row['place']))
$record .= ", ";
else
{
if (!preg_match("/[?!.]$/", $row['publisher']))
$record .= ". ";
else
$record .= " ";
}
}
if (!empty($row['place'])) // place
{
$record .= $row['place'];
if (!empty($row['series_title']) || !empty($row['pages']))
{
if (!preg_match("/,$/", $row['place']))
$record .= ",";
$record .= " ";
}
}
if (!empty($row['series_title'])) // series title
{
$record .= $row['series_title'];
if (!empty($row['series_volume'])) // series volume (will get appended only if there's also a series title!)
{
$record .= " ";
$record .= $row['series_volume'];
}
if (!empty($row['pages']))
{
if (!preg_match("/,$/", $row['series_volume']))
$record .= ",";
$record .= " ";
}
}
if (!empty($row['pages'])) // pages
{
// TODO: use function 'formatPageInfo()' when it can recognize & process total number of pages
// $record .= formatPageInfo($row['pages'], $markupPatternsArray["endash"], "p. ", "pp. ", "pp"); // function 'formatPageInfo()' is defined in 'cite.inc.php'
if (preg_match("/\d *[$dash] *\d/$patternModifiers", $row['pages'])) // if the 'pages' field contains a page range (like: "127-132")
// Note that we'll check for page ranges here although for whole books the 'pages' field should NOT contain a page range but the total number of pages! (like: "623 pp")
$pagesDisplay = (preg_replace("@(\d+) *[$dash] *(\d+)@$patternModifiers", "\\1" . $markupPatternsArray["endash"] . "\\2", $row['pages']));
else
$pagesDisplay = $row['pages'];
$record .= $pagesDisplay;
}
if (!preg_match("/\. *$/", $record))
$record .= ".";
}
// --- BEGIN POST-PROCESSING -----------------------------------------------------------------------------------------------------------
// do some further cleanup:
$record = preg_replace("/[ \r\n]*$/i", "", $record); // remove whitespace at end of line
$record = preg_replace("/([0-9]+) *pp\.$/i", "\\1pp.", $record); // remove space between (book whole) page numbers & "pp"
return $record;
}
// --- END CITATION STYLE ---
?>

View File

@@ -0,0 +1,691 @@
<?php
// Project: Web Reference Database (refbase) <http://www.refbase.net>
// Copyright: Matthias Steffens <mailto:refbase@extracts.de> and the file's
// original author(s).
//
// This code is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY. Please see the GNU General Public
// License for more details.
//
// File: ./cite/styles/cite_Harvard_1.php
// Repository: $HeadURL$
// Author(s): Matthias Steffens <mailto:refbase@extracts.de>
//
// Created: 12-Aug-08, 16:00
// Modified: $Date: 2012-02-27 20:25:30 +0000 (Mon, 27 Feb 2012) $
// $Author$
// $Revision: 1337 $
// This is a citation style file (which must reside within the 'cite/styles/' sub-directory of your refbase root directory). It contains a
// version of the 'citeRecord()' function that outputs a reference list from selected records according to the citation style used by
// the Harvard referencing system
// This is a variant of the Harvard author/date style, modeled after this guide:
// <http://libweb.anglia.ac.uk/referencing/harvard.htm>
// based on 'cite_Harvard_3.php'
// TODO: - abstracts, conference proceedings, magazine articles, patents, reports & software?
// - should we shorten ending page numbers if necessary (e.g. "p. 10-8" or "p. 51-5", but "p. 19-26"), or only if numbers are >=3 digits?
// - where to put (and how to format) series info & editors of whole books that also have an author?
// - see also inline comments labeled with TODO (and NOTE)
// --------------------------------------------------------------------
// --- BEGIN CITATION STYLE ---
function citeRecord($row, $citeStyle, $citeType, $markupPatternsArray, $encodeHTML)
{
$record = ""; // make sure that our buffer variable is empty
// --- BEGIN TYPE = JOURNAL ARTICLE / MAGAZINE ARTICLE / NEWSPAPER ARTICLE --------------------------------------------------------------
if (preg_match("/^(Journal Article|Magazine Article|Newspaper Article)$/", $row['type']))
{
if (!empty($row['author'])) // author
{
// Call the 'reArrangeAuthorContents()' function (defined in 'include.inc.php') in order to re-order contents of the author field. Required Parameters:
// 1. input: contents of the author field
// 2. input: boolean value that specifies whether the author's family name comes first (within one author) in the source string
// ('true' means that the family name is followed by the given name (or initials), 'false' if it's the other way around)
//
// 3. input: pattern describing old delimiter that separates different authors
// 4. output: for all authors except the last author: new delimiter that separates different authors
// 5. output: for the last author: new delimiter that separates the last author from all other authors
//
// 6. input: pattern describing old delimiter that separates author name & initials (within one author)
// 7. output: for the first author: new delimiter that separates author name & initials (within one author)
// 8. output: for all authors except the first author: new delimiter that separates author name & initials (within one author)
// 9. output: new delimiter that separates multiple initials (within one author)
// 10. output: for the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db)
// 11. output: for all authors except the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db)
// 12. output: boolean value that specifies whether an author's full given name(s) shall be shortened to initial(s)
//
// 13. output: if the total number of authors is greater than the given number (integer >= 1), only the number of authors given in (14) will be included in the citation along with the string given in (15); keep empty if all authors shall be returned
// 14. output: number of authors (integer >= 1) that is included in the citation if the total number of authors is greater than the number given in (13); keep empty if not applicable
// 15. output: string that's appended to the number of authors given in (14) if the total number of authors is greater than the number given in (13); the actual number of authors can be printed by including '__NUMBER_OF_AUTHORS__' (without quotes) within the string
//
// 16. output: boolean value that specifies whether the re-ordered string shall be returned with higher ASCII chars HTML encoded
$author = reArrangeAuthorContents($row['author'], // 1.
true, // 2.
"/ *; */", // 3.
", ", // 4.
" " . $markupPatternsArray["ampersand"] . " ", // 5.
"/ *, */", // 6.
", ", // 7.
", ", // 8.
".", // 9.
false, // 10.
false, // 11.
true, // 12.
"4", // 13.
"1", // 14.
" et al", // 15.
$encodeHTML); // 16.
$record .= $author;
}
if (!empty($row['year'])) // year
{
if (!empty($row['author']))
$record .= ", ";
if (!empty($row['year']))
$record .= $row['year'];
}
if (!empty($row['title'])) // title
{
if (!empty($row['author']) || !empty($row['year']))
$record .= ". ";
$record .= $row['title'];
$record .= ",";
}
// From here on we'll assume that at least one of the fields 'author', 'year' or 'title' did contain some contents
if (!empty($row['publication'])) // publication (= journal) name
$record .= " " . $markupPatternsArray["italic-prefix"] . $row['publication'] . $markupPatternsArray["italic-suffix"];
// if there's no full journal name, we'll use the abbreviated journal name instead:
elseif (!empty($row['abbrev_journal'])) // abbreviated journal name
$record .= " " . $markupPatternsArray["italic-prefix"] . $row['abbrev_journal'] . $markupPatternsArray["italic-suffix"];
if ((!empty($row['abbrev_journal']) || !empty($row['publication'])) && (!empty($row['volume']) || !empty($row['issue'])))
$record .= ","; // NOTE: for newspaper articles, the above mentioned guide uses a dot instead of a comma ("The Times, 3 Sep. p.4-5.") but this seems incorrect/inconsistent to me
if ($row['online_publication'] == "yes") // this record refers to an online publication
$record .= " [Online]";
if ($row['type'] == "Journal Article")
{
if (!empty($row['volume'])) // volume
$record .= " " . $row['volume'];
if (!empty($row['issue'])) // issue
{
if (!empty($row['volume']))
$record .= " ";
$record .= "(" . $row['issue'] . ")";
}
}
elseif (preg_match("/^(Newspaper Article|Magazine Article)$/", $row['type'])) // for newspaper and magazine articles, volume (=month) and issue (=day) information is printed without prefix
{
if (!empty($row['issue'])) // issue (=day)
$record .= " " . $row['issue'];
if (!empty($row['volume'])) // volume (=month)
$record .= " " . $row['volume'];
}
if (!empty($row['pages'])) // pages
{
if (!empty($row['volume']) || !empty($row['issue']) || !empty($row['abbrev_journal']) || !empty($row['publication'])) // only add ", " if either volume, issue, abbrev_journal or publication isn't empty
$record .= ", ";
$record .= formatPageInfo($row['pages'], $markupPatternsArray["endash"], "p. ", "p. "); // function 'formatPageInfo()' is defined in 'cite.inc.php' (NOTE: from the examples in the above mentioned guide it's unclear whether "p." should be followed by a space or not)
}
if ($row['online_publication'] == "yes") // this record refers to an online article
{
// append an optional string (given in 'online_citation') plus the current date and the DOI (or URL):
if (!empty($row['online_citation'])) // online_citation
{
if (!empty($row['volume']) || !empty($row['issue']) || !empty($row['abbrev_journal']) || !empty($row['publication'])) // only add "," if either volume, issue, abbrev_journal or publication isn't empty
$record .= ",";
$record .= " " . $row['online_citation'];
}
if (!empty($row['doi']) || !empty($row['url'])) // doi OR url
{
if (!empty($row['online_citation']) OR (empty($row['online_citation']) AND (!empty($row['volume']) || !empty($row['issue']) || !empty($row['abbrev_journal']) || !empty($row['publication'])))) // only add "." if online_citation isn't empty, or else if either volume, issue, abbrev_journal or publication isn't empty
$record .= ".";
$today = date("j F Y");
$record .= " Available at: " . $markupPatternsArray["underline-prefix"];
if (!empty($row['doi'])) // doi
$uri = "http://dx.doi.org/" . $row['doi'];
else // url
$uri = $row['url'];
if ($encodeHTML)
$record .= encodeHTML($uri);
else
$record .= $uri;
$record .= $markupPatternsArray["underline-suffix"];
$record .= " [accessed " . $today . "]";
}
}
if (!preg_match("/\. *$/", $record)) // if the string doesn't end with a period
$record .= ".";
}
// --- BEGIN TYPE = ABSTRACT / BOOK CHAPTER / CONFERENCE ARTICLE ------------------------------------------------------------------------
elseif (preg_match("/^(Abstract|Book Chapter|Conference Article)$/", $row['type']))
{
if (!empty($row['author'])) // author
{
// Call the 'reArrangeAuthorContents()' function (defined in 'include.inc.php') in order to re-order contents of the author field. Required Parameters:
// 1. input: contents of the author field
// 2. input: boolean value that specifies whether the author's family name comes first (within one author) in the source string
// ('true' means that the family name is followed by the given name (or initials), 'false' if it's the other way around)
//
// 3. input: pattern describing old delimiter that separates different authors
// 4. output: for all authors except the last author: new delimiter that separates different authors
// 5. output: for the last author: new delimiter that separates the last author from all other authors
//
// 6. input: pattern describing old delimiter that separates author name & initials (within one author)
// 7. output: for the first author: new delimiter that separates author name & initials (within one author)
// 8. output: for all authors except the first author: new delimiter that separates author name & initials (within one author)
// 9. output: new delimiter that separates multiple initials (within one author)
// 10. output: for the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db)
// 11. output: for all authors except the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db)
// 12. output: boolean value that specifies whether an author's full given name(s) shall be shortened to initial(s)
//
// 13. output: if the total number of authors is greater than the given number (integer >= 1), only the number of authors given in (14) will be included in the citation along with the string given in (15); keep empty if all authors shall be returned
// 14. output: number of authors (integer >= 1) that is included in the citation if the total number of authors is greater than the number given in (13); keep empty if not applicable
// 15. output: string that's appended to the number of authors given in (14) if the total number of authors is greater than the number given in (13); the actual number of authors can be printed by including '__NUMBER_OF_AUTHORS__' (without quotes) within the string
//
// 16. output: boolean value that specifies whether the re-ordered string shall be returned with higher ASCII chars HTML encoded
$author = reArrangeAuthorContents($row['author'], // 1.
true, // 2.
"/ *; */", // 3.
", ", // 4.
" " . $markupPatternsArray["ampersand"] . " ", // 5.
"/ *, */", // 6.
", ", // 7.
", ", // 8.
".", // 9.
false, // 10.
false, // 11.
true, // 12.
"4", // 13.
"1", // 14.
" et al", // 15.
$encodeHTML); // 16.
$record .= $author;
}
if (!empty($row['year'])) // year
{
if (!empty($row['author']))
$record .= ", ";
$record .= $row['year'];
}
if (!empty($row['title'])) // title
{
if (!empty($row['author']) || !empty($row['year']))
$record .= ". ";
$record .= $row['title'];
$record .= ".";
}
// From here on we'll assume that at least one of the fields 'author', 'year' or 'title' did contain some contents
// if this is not the case, the output string will begin with a space. However, any preceding/trailing whitespace will be removed at the cleanup stage (see below)
if (!empty($row['editor'])) // editor
{
// Call the 'reArrangeAuthorContents()' function (defined in 'include.inc.php') in order to re-order contents of the author field. Required Parameters:
// 1. input: contents of the author field
// 2. input: boolean value that specifies whether the author's family name comes first (within one author) in the source string
// ('true' means that the family name is followed by the given name (or initials), 'false' if it's the other way around)
//
// 3. input: pattern describing old delimiter that separates different authors
// 4. output: for all authors except the last author: new delimiter that separates different authors
// 5. output: for the last author: new delimiter that separates the last author from all other authors
//
// 6. input: pattern describing old delimiter that separates author name & initials (within one author)
// 7. output: for the first author: new delimiter that separates author name & initials (within one author)
// 8. output: for all authors except the first author: new delimiter that separates author name & initials (within one author)
// 9. output: new delimiter that separates multiple initials (within one author)
// 10. output: for the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db)
// 11. output: for all authors except the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db)
// 12. output: boolean value that specifies whether an author's full given name(s) shall be shortened to initial(s)
//
// 13. output: if the total number of authors is greater than the given number (integer >= 1), only the number of authors given in (14) will be included in the citation along with the string given in (15); keep empty if all authors shall be returned
// 14. output: number of authors (integer >= 1) that is included in the citation if the total number of authors is greater than the number given in (13); keep empty if not applicable
// 15. output: string that's appended to the number of authors given in (14) if the total number of authors is greater than the number given in (13); the actual number of authors can be printed by including '__NUMBER_OF_AUTHORS__' (without quotes) within the string
//
// 16. output: boolean value that specifies whether the re-ordered string shall be returned with higher ASCII chars HTML encoded
$editor = reArrangeAuthorContents($row['editor'], // 1.
true, // 2.
"/ *; */", // 3.
", ", // 4.
" " . $markupPatternsArray["ampersand"] . " ", // 5.
"/ *, */", // 6.
" ", // 7.
" ", // 8.
".", // 9.
true, // 10.
true, // 11.
true, // 12.
"4", // 13.
"1", // 14.
" et al", // 15.
$encodeHTML); // 16.
$record .= " In " . $editor . ", ";
if (preg_match("/^[^;\r\n]+(;[^;\r\n]+)+$/", $row['editor'])) // there are at least two editors (separated by ';')
$record .= "eds.";
else // there's only one editor (or the editor field is malformed with multiple editors but missing ';' separator[s])
$record .= "ed.";
}
$publication = preg_replace("/[ \r\n]*\(Eds?:[^\)\r\n]*\)/i", "", $row['publication']);
if (!empty($publication)) // publication
{
if (empty($row['editor']))
$record .= " In";
$record .= " " . $markupPatternsArray["italic-prefix"] . $publication . $markupPatternsArray["italic-suffix"];
}
if (!empty($row['edition']) && !preg_match("/^(1|1st|first|one)( ed\.?| edition)?$/i", $row['edition']) || !empty($row['volume']))
{
$record .= ". ";
if (!empty($row['edition']) && !preg_match("/^(1|1st|first|one)( ed\.?| edition)?$/i", $row['edition'])) // edition
{
if (preg_match("/^\d{1,3}$/", $row['edition'])) // if the edition field contains a number of up to three digits, we assume it's an edition number (such as "2nd ed.")
{
if ($row['edition'] == "2")
$editionSuffix = "nd";
elseif ($row['edition'] == "3")
$editionSuffix = "rd";
else
$editionSuffix = "th";
}
else
$editionSuffix = "";
if (!empty($row['edition']) && !preg_match("/( ed\.?| edition)$/i", $row['edition']))
$editionSuffix .= " ed.";
$record .= $row['edition'] . $editionSuffix;
}
if (!empty($row['volume'])) // volume
{
if (!empty($row['edition']) && !preg_match("/^(1|1st|first|one)( ed\.?| edition)?$/i", $row['edition']))
$record .= ", ";
$record .= "vol. " . $row['volume']; // TODO: not sure whether this is correct
}
}
if (!empty($row['abbrev_series_title']) OR !empty($row['series_title'])) // if there's either a full or an abbreviated series title
{
$record .= ". ";
if (!empty($row['series_title']))
$record .= $row['series_title']; // full series title
// if there's no full series title, we'll use the abbreviated series title instead:
elseif (!empty($row['abbrev_series_title']))
$record .= $row['abbrev_series_title']; // abbreviated series title
if (!empty($row['series_volume'])||!empty($row['series_issue']))
$record .= ", ";
if (!empty($row['series_volume'])) // series volume (I'm not really sure if -- for this cite style -- the series volume & issue should be rather omitted here)
$record .= "vol. " . $row['series_volume']; // TODO: not sure whether this is correct
if (!empty($row['series_issue'])) // series issue (see note for series volume)
{
if (!empty($row['series_volume']))
$record .= ", ";
$record .= "no. " . $row['series_issue']; // TODO: not sure whether this is correct
}
}
if (!preg_match("/\. *$/", $record))
$record .= ".";
if (!empty($row['place'])) // place
$record .= " " . $row['place'];
if (!empty($row['publisher'])) // publisher
{
if (!empty($row['place']))
$record .= ":";
$record .= " " . $row['publisher'];
}
if (!empty($row['pages'])) // pages
{
if (!empty($row['publisher']) || !empty($row['place']))
$record .= ", ";
$record .= formatPageInfo($row['pages'], $markupPatternsArray["endash"], "p. ", "p. "); // function 'formatPageInfo()' is defined in 'cite.inc.php' (NOTE: from the examples in the above mentioned guide it's unclear whether "p." should be followed by a space or not)
}
if (!preg_match("/\. *$/", $record))
$record .= ".";
}
// --- BEGIN TYPE = BOOK WHOLE / CONFERENCE VOLUME / JOURNAL / MANUAL / MANUSCRIPT / MAP / MISCELLANEOUS / PATENT / REPORT / SOFTWARE ---
else // if (preg_match("/Book Whole|Conference Volume|Journal|Manual|Manuscript|Map|Miscellaneous|Patent|Report|Software/", $row['type']))
// note that this also serves as a fallback: unrecognized resource types will be formatted similar to whole books
{
if (!empty($row['author'])) // author
{
$author = preg_replace("/[ \r\n]*\(eds?\)/i", "", $row['author']);
// Call the 'reArrangeAuthorContents()' function (defined in 'include.inc.php') in order to re-order contents of the author field. Required Parameters:
// 1. input: contents of the author field
// 2. input: boolean value that specifies whether the author's family name comes first (within one author) in the source string
// ('true' means that the family name is followed by the given name (or initials), 'false' if it's the other way around)
//
// 3. input: pattern describing old delimiter that separates different authors
// 4. output: for all authors except the last author: new delimiter that separates different authors
// 5. output: for the last author: new delimiter that separates the last author from all other authors
//
// 6. input: pattern describing old delimiter that separates author name & initials (within one author)
// 7. output: for the first author: new delimiter that separates author name & initials (within one author)
// 8. output: for all authors except the first author: new delimiter that separates author name & initials (within one author)
// 9. output: new delimiter that separates multiple initials (within one author)
// 10. output: for the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db)
// 11. output: for all authors except the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db)
// 12. output: boolean value that specifies whether an author's full given name(s) shall be shortened to initial(s)
//
// 13. output: if the total number of authors is greater than the given number (integer >= 1), only the number of authors given in (14) will be included in the citation along with the string given in (15); keep empty if all authors shall be returned
// 14. output: number of authors (integer >= 1) that is included in the citation if the total number of authors is greater than the number given in (13); keep empty if not applicable
// 15. output: string that's appended to the number of authors given in (14) if the total number of authors is greater than the number given in (13); the actual number of authors can be printed by including '__NUMBER_OF_AUTHORS__' (without quotes) within the string
//
// 16. output: boolean value that specifies whether the re-ordered string shall be returned with higher ASCII chars HTML encoded
$author = reArrangeAuthorContents($author, // 1.
true, // 2.
"/ *; */", // 3.
", ", // 4.
" " . $markupPatternsArray["ampersand"] . " ", // 5.
"/ *, */", // 6.
", ", // 7.
", ", // 8.
".", // 9.
false, // 10.
false, // 11.
true, // 12.
"4", // 13.
"1", // 14.
" et al", // 15.
$encodeHTML); // 16.
// if the author is actually the editor of the resource we'll append ', ed' (or ', eds') to the author string:
// [to distinguish editors from authors in the 'author' field, the 'modify.php' script does append ' (ed)' or ' (eds)' if appropriate,
// so we're just checking for these identifier strings here. Alternatively, we could check whether the editor field matches the author field]
if (preg_match("/[ \r\n]*\(ed\)/", $row['author'])) // single editor
$author = $author . " ed.";
elseif (preg_match("/[ \r\n]*\(eds\)/", $row['author'])) // multiple editors
$author = $author . " eds.";
$record .= $author;
}
if (!empty($row['year'])) // year
{
if (!empty($row['author']))
$record .= ", ";
$record .= $row['year'];
}
if (!empty($row['title'])) // title
{
if (!empty($row['author']) || !empty($row['year']))
$record .= ". ";
$record .= $markupPatternsArray["italic-prefix"] . $row['title'] . $markupPatternsArray["italic-suffix"];
}
if ($row['online_publication'] == "yes") // this record refers to an online publication
$record .= ". [Online]"; // TODO: this may not be entirely correct, since, according to the above mentioned guide, the actual type should be used: e.g. "[e-book]" or "[CD-ROM]"
if (!empty($row['editor']) && !preg_match("/[ \r\n]*\(eds?\)/", $row['author'])) // editor (if different from author, see note above regarding the check for ' (ed)' or ' (eds)')
{
// Call the 'reArrangeAuthorContents()' function (defined in 'include.inc.php') in order to re-order contents of the author field. Required Parameters:
// 1. input: contents of the author field
// 2. input: boolean value that specifies whether the author's family name comes first (within one author) in the source string
// ('true' means that the family name is followed by the given name (or initials), 'false' if it's the other way around)
//
// 3. input: pattern describing old delimiter that separates different authors
// 4. output: for all authors except the last author: new delimiter that separates different authors
// 5. output: for the last author: new delimiter that separates the last author from all other authors
//
// 6. input: pattern describing old delimiter that separates author name & initials (within one author)
// 7. output: for the first author: new delimiter that separates author name & initials (within one author)
// 8. output: for all authors except the first author: new delimiter that separates author name & initials (within one author)
// 9. output: new delimiter that separates multiple initials (within one author)
// 10. output: for the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db)
// 11. output: for all authors except the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db)
// 12. output: boolean value that specifies whether an author's full given name(s) shall be shortened to initial(s)
//
// 13. output: if the total number of authors is greater than the given number (integer >= 1), only the number of authors given in (14) will be included in the citation along with the string given in (15); keep empty if all authors shall be returned
// 14. output: number of authors (integer >= 1) that is included in the citation if the total number of authors is greater than the number given in (13); keep empty if not applicable
// 15. output: string that's appended to the number of authors given in (14) if the total number of authors is greater than the number given in (13); the actual number of authors can be printed by including '__NUMBER_OF_AUTHORS__' (without quotes) within the string
//
// 16. output: boolean value that specifies whether the re-ordered string shall be returned with higher ASCII chars HTML encoded
$editor = reArrangeAuthorContents($row['editor'], // 1.
true, // 2.
"/ *; */", // 3.
", ", // 4.
" " . $markupPatternsArray["ampersand"] . " ", // 5.
"/ *, */", // 6.
" ", // 7.
" ", // 8.
".", // 9.
true, // 10.
true, // 11.
true, // 12.
"4", // 13.
"1", // 14.
" et al", // 15.
$encodeHTML); // 16.
if (!empty($row['author']) || !empty($row['year']) || !empty($row['title']))
$record .= " ";
$record .= " (" . $editor . ", ";
if (preg_match("/^[^;\r\n]+(;[^;\r\n]+)+$/", $row['editor'])) // there are at least two editors (separated by ';')
$record .= "eds.";
else // there's only one editor (or the editor field is malformed with multiple editors but missing ';' separator[s])
$record .= "ed.";
$record .= ")";
}
if (!empty($row['edition']) || !empty($row['volume']))
{
if (!empty($row['author']) || !empty($row['year']) || !empty($row['title']) || (!empty($row['editor']) && !preg_match("/[ \r\n]*\(eds?\)/", $row['author'])))
$record .= ". ";
if ($row['type'] == "Software") // software edition (=version)
{
if (!empty($row['edition']))
{
$record .= "Version " . $row['edition'];
if (!empty($row['volume']) || !empty($row['issue']))
$record .= ", ";
}
if (!empty($row['issue'])) // issue (=day)
$record .= " " . $row['issue'];
if (!empty($row['volume'])) // volume (=month)
$record .= " " . $row['volume'];
}
elseif (!preg_match("/^(1|1st|first|one)( ed\.?| edition)?$/i", $row['edition'])) // regular edition (other than the first)
{
if (preg_match("/^\d{1,3}$/", $row['edition'])) // if the edition field contains a number of up to three digits, we assume it's an edition number (such as "2nd ed.")
{
if ($row['edition'] == "2")
$editionSuffix = "nd";
elseif ($row['edition'] == "3")
$editionSuffix = "rd";
else
$editionSuffix = "th";
}
else
$editionSuffix = "";
if (!empty($row['edition']) && !preg_match("/( ed\.?| edition)$/i", $row['edition']))
$editionSuffix .= " ed.";
$record .= $row['edition'] . $editionSuffix;
if (!empty($row['volume'])) // volume
{
if (!empty($row['edition']) && !preg_match("/^(1|1st|first|one)( ed\.?| edition)?$/i", $row['edition']))
$record .= ", ";
$record .= "vol. " . $row['volume']; // TODO: not sure whether this is correct
}
}
}
if ($row['type'] == "Software") // for software, add software label
{
$record .= ", computer software.";
}
else // add series info
{
if (!preg_match("/\. *$/", $record))
$record .= ".";
if (!empty($row['abbrev_series_title']) OR !empty($row['series_title'])) // if there's either a full or an abbreviated series title
{
$record .= " ";
if (!empty($row['series_title']))
$record .= $row['series_title']; // full series title
// if there's no full series title, we'll use the abbreviated series title instead:
elseif (!empty($row['abbrev_series_title']))
$record .= $row['abbrev_series_title']; // abbreviated series title
if (!empty($row['series_volume'])||!empty($row['series_issue']))
$record .= ", ";
if (!empty($row['series_volume'])) // series volume (I'm not really sure if -- for this cite style -- the series volume & issue should be rather omitted here)
$record .= "vol. " . $row['series_volume']; // TODO: not sure whether this is correct
if (!empty($row['series_issue'])) // series issue (see note for series volume)
{
if (!empty($row['series_volume']))
$record .= ", ";
$record .= "no. " . $row['series_issue']; // TODO: not sure whether this is correct
}
$record .= ".";
}
}
if (!empty($row['thesis'])) // thesis
$record .= " " . $row['thesis'];
if (!empty($row['place']) || !empty($row['publisher']))
{
if (!empty($row['thesis']))
$record .= ".";
if (!empty($row['place'])) // place (NOTE: should we omit the place of publication for theses?)
$record .= " " . $row['place'];
if (!empty($row['publisher'])) // publisher
{
if (!empty($row['place']))
$record .= ":";
$record .= " " . $row['publisher'];
}
}
if ($row['online_publication'] == "yes" || $row['type'] == "Software") // this record refers to an online article, or a computer program/software
{
if (!empty($row['online_citation'])) // online_citation
{
if (!preg_match("/\. *$/", $record))
$record .= ".";
$record .= " " . $row['online_citation'];
}
if (!empty($row['doi']) || !empty($row['url'])) // doi OR url
{
if (!preg_match("/\. *$/", $record))
$record .= ".";
$today = date("j F Y");
$record .= " Available at: " . $markupPatternsArray["underline-prefix"];
if (!empty($row['doi'])) // doi
$uri = "http://dx.doi.org/" . $row['doi'];
else // url
$uri = $row['url'];
if ($encodeHTML)
$record .= encodeHTML($uri);
else
$record .= $uri;
$record .= $markupPatternsArray["underline-suffix"];
$record .= " [accessed " . $today . "]";
}
}
if (!preg_match("/\. *$/", $record)) // if the string doesn't end with a period
$record .= ".";
}
// --- BEGIN POST-PROCESSING -----------------------------------------------------------------------------------------------------------
// do some further cleanup:
$record = trim($record); // remove any preceding or trailing whitespace
return $record;
}
// --- END CITATION STYLE ---
?>

View File

@@ -0,0 +1,657 @@
<?php
// Project: Web Reference Database (refbase) <http://www.refbase.net>
// Copyright: Matthias Steffens <mailto:refbase@extracts.de> and the file's
// original author(s).
//
// This code is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY. Please see the GNU General Public
// License for more details.
//
// File: ./cite/styles/cite_Harvard_2.php
// Repository: $HeadURL$
// Author(s): Matthias Steffens <mailto:refbase@extracts.de>
//
// Created: 12-Aug-08, 20:00
// Modified: $Date: 2012-02-27 20:25:30 +0000 (Mon, 27 Feb 2012) $
// $Author$
// $Revision: 1337 $
// This is a citation style file (which must reside within the 'cite/styles/' sub-directory of your refbase root directory). It contains a
// version of the 'citeRecord()' function that outputs a reference list from selected records according to the citation style used by
// the Harvard referencing system
// This is a variant of the Harvard author/date style, modeled after this guide:
// <http://skillsforlearning.leedsmet.ac.uk/harvard_2004.pdf>
// based on 'cite_Harvard_1.php'
// NOTES: - For conference proceedings, you'll currently need to add the place & date of the conference in the proceedings title field
// (e.g. "Proceedings of the 67th IFLA Council and General Conference, August 16-25, 2001, Boston USA").
// TODO: - abstracts, conference proceedings, magazine articles, patents, reports & software?
// - for references where there are more than four authors, we currently only use the first author followed by " et al"; is this correct?
// - where to put (and how to format) series info & editors of whole books that also have an author?
// - see also inline comments labeled with TODO (and NOTE)
// --------------------------------------------------------------------
// --- BEGIN CITATION STYLE ---
function citeRecord($row, $citeStyle, $citeType, $markupPatternsArray, $encodeHTML)
{
$record = ""; // make sure that our buffer variable is empty
// --- BEGIN TYPE = JOURNAL ARTICLE / MAGAZINE ARTICLE / NEWSPAPER ARTICLE --------------------------------------------------------------
if (preg_match("/^(Journal Article|Magazine Article|Newspaper Article)$/", $row['type']))
{
if (!empty($row['author'])) // author
{
// Call the 'reArrangeAuthorContents()' function (defined in 'include.inc.php') in order to re-order contents of the author field. Required Parameters:
// 1. input: contents of the author field
// 2. input: boolean value that specifies whether the author's family name comes first (within one author) in the source string
// ('true' means that the family name is followed by the given name (or initials), 'false' if it's the other way around)
//
// 3. input: pattern describing old delimiter that separates different authors
// 4. output: for all authors except the last author: new delimiter that separates different authors
// 5. output: for the last author: new delimiter that separates the last author from all other authors
//
// 6. input: pattern describing old delimiter that separates author name & initials (within one author)
// 7. output: for the first author: new delimiter that separates author name & initials (within one author)
// 8. output: for all authors except the first author: new delimiter that separates author name & initials (within one author)
// 9. output: new delimiter that separates multiple initials (within one author)
// 10. output: for the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db)
// 11. output: for all authors except the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db)
// 12. output: boolean value that specifies whether an author's full given name(s) shall be shortened to initial(s)
//
// 13. output: if the total number of authors is greater than the given number (integer >= 1), only the number of authors given in (14) will be included in the citation along with the string given in (15); keep empty if all authors shall be returned
// 14. output: number of authors (integer >= 1) that is included in the citation if the total number of authors is greater than the number given in (13); keep empty if not applicable
// 15. output: string that's appended to the number of authors given in (14) if the total number of authors is greater than the number given in (13); the actual number of authors can be printed by including '__NUMBER_OF_AUTHORS__' (without quotes) within the string
//
// 16. output: boolean value that specifies whether the re-ordered string shall be returned with higher ASCII chars HTML encoded
$author = reArrangeAuthorContents($row['author'], // 1.
true, // 2.
"/ *; */", // 3.
", ", // 4.
" " . $markupPatternsArray["ampersand"] . " ", // 5.
"/ *, */", // 6.
", ", // 7.
", ", // 8.
".", // 9.
false, // 10.
false, // 11.
true, // 12.
"4", // 13.
"1", // 14.
" et al", // 15.
$encodeHTML); // 16.
$record .= $author;
}
if (!empty($row['year'])) // year
$record .= " (" . $row['year'] . ")";
if (!empty($row['title'])) // title
$record .= " " . $row['title'] . ".";
// From here on we'll assume that at least one of the fields 'author', 'year' or 'title' did contain some contents
if (!empty($row['publication'])) // publication (= journal) name
$record .= " " . $markupPatternsArray["italic-prefix"] . $row['publication'] . $markupPatternsArray["italic-suffix"];
// if there's no full journal name, we'll use the abbreviated journal name instead:
elseif (!empty($row['abbrev_journal'])) // abbreviated journal name
$record .= " " . $markupPatternsArray["italic-prefix"] . $row['abbrev_journal'] . $markupPatternsArray["italic-suffix"];
if ($row['online_publication'] == "yes") // this record refers to an online publication
$record .= " [Internet]";
if ((!empty($row['abbrev_journal']) || !empty($row['publication'])) && (!empty($row['volume']) || !empty($row['issue'])))
$record .= ",";
if ($row['type'] == "Journal Article")
{
if (!empty($row['volume'])) // volume
$record .= " " . $row['volume'];
if (!empty($row['issue'])) // issue
{
if (!empty($row['volume']))
$record .= " ";
$record .= "(" . $row['issue'] . ")";
}
}
elseif (preg_match("/^(Newspaper Article|Magazine Article)$/", $row['type'])) // for newspaper and magazine articles, volume (=month) and issue (=day) information is printed without prefix
{
if (!empty($row['issue'])) // issue (=day)
$record .= " " . $row['issue'];
if (!empty($row['volume'])) // volume (=month)
$record .= " " . $row['volume'];
}
if (!empty($row['pages'])) // pages
{
if (!empty($row['volume']) || !empty($row['issue']) || !empty($row['abbrev_journal']) || !empty($row['publication'])) // only add ", " if either volume, issue, abbrev_journal or publication isn't empty
$record .= ", ";
$record .= formatPageInfo($row['pages'], $markupPatternsArray["endash"], "p.", "pp."); // function 'formatPageInfo()' is defined in 'cite.inc.php'
}
if ($row['online_publication'] == "yes") // this record refers to an online article
{
// append an optional string (given in 'online_citation') plus the current date and the DOI (or URL):
if (!empty($row['online_citation'])) // online_citation
{
if (!empty($row['volume']) || !empty($row['issue']) || !empty($row['abbrev_journal']) || !empty($row['publication'])) // only add "," if either volume, issue, abbrev_journal or publication isn't empty
$record .= ",";
$record .= " " . $row['online_citation'];
}
if (!empty($row['doi']) || !empty($row['url'])) // doi OR url
{
if (!empty($row['online_citation']) OR (empty($row['online_citation']) AND (!empty($row['volume']) || !empty($row['issue']) || !empty($row['abbrev_journal']) || !empty($row['publication'])))) // only add "." if online_citation isn't empty, or else if either volume, issue, abbrev_journal or publication isn't empty
$record .= ".";
$today = date("j F Y");
$record .= " Available from: ";
if (!empty($row['doi'])) // doi
$uri = "http://dx.doi.org/" . $row['doi'];
else // url
$uri = $row['url'];
if ($encodeHTML)
$record .= encodeHTML($markupPatternsArray["less-than"] . $uri . $markupPatternsArray["greater-than"]);
else
$record .= $markupPatternsArray["less-than"] . $uri . $markupPatternsArray["greater-than"];
$record .= " [Accessed " . $today . "]";
}
}
if (!preg_match("/\. *$/", $record)) // if the string doesn't end with a period
$record .= ".";
}
// --- BEGIN TYPE = ABSTRACT / BOOK CHAPTER / CONFERENCE ARTICLE ------------------------------------------------------------------------
elseif (preg_match("/^(Abstract|Book Chapter|Conference Article)$/", $row['type']))
{
if (!empty($row['author'])) // author
{
// Call the 'reArrangeAuthorContents()' function (defined in 'include.inc.php') in order to re-order contents of the author field. Required Parameters:
// 1. input: contents of the author field
// 2. input: boolean value that specifies whether the author's family name comes first (within one author) in the source string
// ('true' means that the family name is followed by the given name (or initials), 'false' if it's the other way around)
//
// 3. input: pattern describing old delimiter that separates different authors
// 4. output: for all authors except the last author: new delimiter that separates different authors
// 5. output: for the last author: new delimiter that separates the last author from all other authors
//
// 6. input: pattern describing old delimiter that separates author name & initials (within one author)
// 7. output: for the first author: new delimiter that separates author name & initials (within one author)
// 8. output: for all authors except the first author: new delimiter that separates author name & initials (within one author)
// 9. output: new delimiter that separates multiple initials (within one author)
// 10. output: for the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db)
// 11. output: for all authors except the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db)
// 12. output: boolean value that specifies whether an author's full given name(s) shall be shortened to initial(s)
//
// 13. output: if the total number of authors is greater than the given number (integer >= 1), only the number of authors given in (14) will be included in the citation along with the string given in (15); keep empty if all authors shall be returned
// 14. output: number of authors (integer >= 1) that is included in the citation if the total number of authors is greater than the number given in (13); keep empty if not applicable
// 15. output: string that's appended to the number of authors given in (14) if the total number of authors is greater than the number given in (13); the actual number of authors can be printed by including '__NUMBER_OF_AUTHORS__' (without quotes) within the string
//
// 16. output: boolean value that specifies whether the re-ordered string shall be returned with higher ASCII chars HTML encoded
$author = reArrangeAuthorContents($row['author'], // 1.
true, // 2.
"/ *; */", // 3.
", ", // 4.
" " . $markupPatternsArray["ampersand"] . " ", // 5.
"/ *, */", // 6.
", ", // 7.
", ", // 8.
".", // 9.
false, // 10.
false, // 11.
true, // 12.
"4", // 13.
"1", // 14.
" et al", // 15.
$encodeHTML); // 16.
$record .= $author;
}
if (!empty($row['year'])) // year
$record .= " (" . $row['year'] . ")";
if (!empty($row['title'])) // title
$record .= " " . $row['title'] . ".";
// From here on we'll assume that at least one of the fields 'author', 'year' or 'title' did contain some contents
// if this is not the case, the output string will begin with a space. However, any preceding/trailing whitespace will be removed at the cleanup stage (see below)
if (!empty($row['editor'])) // editor
{
// Call the 'reArrangeAuthorContents()' function (defined in 'include.inc.php') in order to re-order contents of the author field. Required Parameters:
// 1. input: contents of the author field
// 2. input: boolean value that specifies whether the author's family name comes first (within one author) in the source string
// ('true' means that the family name is followed by the given name (or initials), 'false' if it's the other way around)
//
// 3. input: pattern describing old delimiter that separates different authors
// 4. output: for all authors except the last author: new delimiter that separates different authors
// 5. output: for the last author: new delimiter that separates the last author from all other authors
//
// 6. input: pattern describing old delimiter that separates author name & initials (within one author)
// 7. output: for the first author: new delimiter that separates author name & initials (within one author)
// 8. output: for all authors except the first author: new delimiter that separates author name & initials (within one author)
// 9. output: new delimiter that separates multiple initials (within one author)
// 10. output: for the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db)
// 11. output: for all authors except the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db)
// 12. output: boolean value that specifies whether an author's full given name(s) shall be shortened to initial(s)
//
// 13. output: if the total number of authors is greater than the given number (integer >= 1), only the number of authors given in (14) will be included in the citation along with the string given in (15); keep empty if all authors shall be returned
// 14. output: number of authors (integer >= 1) that is included in the citation if the total number of authors is greater than the number given in (13); keep empty if not applicable
// 15. output: string that's appended to the number of authors given in (14) if the total number of authors is greater than the number given in (13); the actual number of authors can be printed by including '__NUMBER_OF_AUTHORS__' (without quotes) within the string
//
// 16. output: boolean value that specifies whether the re-ordered string shall be returned with higher ASCII chars HTML encoded
$editor = reArrangeAuthorContents($row['editor'], // 1.
true, // 2.
"/ *; */", // 3.
", ", // 4.
" " . $markupPatternsArray["ampersand"] . " ", // 5.
"/ *, */", // 6.
", ", // 7.
", ", // 8.
".", // 9.
false, // 10.
false, // 11.
true, // 12.
"4", // 13.
"1", // 14.
" et al", // 15.
$encodeHTML); // 16.
$record .= " In: " . $editor . " ";
if (preg_match("/^[^;\r\n]+(;[^;\r\n]+)+$/", $row['editor'])) // there are at least two editors (separated by ';')
$record .= "eds.";
else // there's only one editor (or the editor field is malformed with multiple editors but missing ';' separator[s])
$record .= "ed.";
}
$publication = preg_replace("/[ \r\n]*\(Eds?:[^\)\r\n]*\)/i", "", $row['publication']);
if (!empty($publication)) // publication
{
if (empty($row['editor']))
$record .= " In:";
$record .= " " . $markupPatternsArray["italic-prefix"] . $publication . $markupPatternsArray["italic-suffix"];
}
if (!empty($row['edition']) && !preg_match("/^(1|1st|first|one)( ed\.?| edition)?$/i", $row['edition']) || !empty($row['volume']))
{
$record .= ". ";
if (!empty($row['edition']) && !preg_match("/^(1|1st|first|one)( ed\.?| edition)?$/i", $row['edition'])) // edition
{
if (preg_match("/^\d{1,3}$/", $row['edition'])) // if the edition field contains a number of up to three digits, we assume it's an edition number (such as "2nd ed.")
{
if ($row['edition'] == "2")
$editionSuffix = "nd";
elseif ($row['edition'] == "3")
$editionSuffix = "rd";
else
$editionSuffix = "th";
}
else
$editionSuffix = "";
if (!empty($row['edition']) && !preg_match("/( ed\.?| edition)$/i", $row['edition']))
$editionSuffix .= " ed.";
$record .= $row['edition'] . $editionSuffix;
}
if (!empty($row['volume'])) // volume
{
if (!empty($row['edition']) && !preg_match("/^(1|1st|first|one)( ed\.?| edition)?$/i", $row['edition']))
$record .= ", ";
$record .= "vol. " . $row['volume']; // TODO: not sure whether this is correct (should this be printed before the edition number?)
}
}
if (!empty($row['abbrev_series_title']) OR !empty($row['series_title'])) // if there's either a full or an abbreviated series title
{
$record .= ". ";
if (!empty($row['series_title']))
$record .= $row['series_title']; // full series title
// if there's no full series title, we'll use the abbreviated series title instead:
elseif (!empty($row['abbrev_series_title']))
$record .= $row['abbrev_series_title']; // abbreviated series title
if (!empty($row['series_volume'])||!empty($row['series_issue']))
$record .= ", ";
if (!empty($row['series_volume'])) // series volume (I'm not really sure if -- for this cite style -- the series volume & issue should be rather omitted here)
$record .= "vol. " . $row['series_volume']; // TODO: not sure whether this is correct
if (!empty($row['series_issue'])) // series issue (see note for series volume)
{
if (!empty($row['series_volume']))
$record .= ", ";
$record .= "no. " . $row['series_issue']; // TODO: not sure whether this is correct
}
}
if (!preg_match("/\. *$/", $record))
$record .= ".";
if (!empty($row['place'])) // place
$record .= " " . $row['place'];
if (!empty($row['publisher'])) // publisher
{
if (!empty($row['place']))
$record .= ",";
$record .= " " . $row['publisher'];
}
if (!empty($row['pages'])) // pages
{
if (!empty($row['publisher']) || !empty($row['place']))
$record .= ", ";
$record .= formatPageInfo($row['pages'], $markupPatternsArray["endash"], "p.", "pp."); // function 'formatPageInfo()' is defined in 'cite.inc.php'
}
if (!preg_match("/\. *$/", $record))
$record .= ".";
}
// --- BEGIN TYPE = BOOK WHOLE / CONFERENCE VOLUME / JOURNAL / MANUAL / MANUSCRIPT / MAP / MISCELLANEOUS / PATENT / REPORT / SOFTWARE ---
else // if (preg_match("/Book Whole|Conference Volume|Journal|Manual|Manuscript|Map|Miscellaneous|Patent|Report|Software/", $row['type']))
// note that this also serves as a fallback: unrecognized resource types will be formatted similar to whole books
{
if (!empty($row['author'])) // author
{
$author = preg_replace("/[ \r\n]*\(eds?\)/i", "", $row['author']);
// Call the 'reArrangeAuthorContents()' function (defined in 'include.inc.php') in order to re-order contents of the author field. Required Parameters:
// 1. input: contents of the author field
// 2. input: boolean value that specifies whether the author's family name comes first (within one author) in the source string
// ('true' means that the family name is followed by the given name (or initials), 'false' if it's the other way around)
//
// 3. input: pattern describing old delimiter that separates different authors
// 4. output: for all authors except the last author: new delimiter that separates different authors
// 5. output: for the last author: new delimiter that separates the last author from all other authors
//
// 6. input: pattern describing old delimiter that separates author name & initials (within one author)
// 7. output: for the first author: new delimiter that separates author name & initials (within one author)
// 8. output: for all authors except the first author: new delimiter that separates author name & initials (within one author)
// 9. output: new delimiter that separates multiple initials (within one author)
// 10. output: for the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db)
// 11. output: for all authors except the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db)
// 12. output: boolean value that specifies whether an author's full given name(s) shall be shortened to initial(s)
//
// 13. output: if the total number of authors is greater than the given number (integer >= 1), only the number of authors given in (14) will be included in the citation along with the string given in (15); keep empty if all authors shall be returned
// 14. output: number of authors (integer >= 1) that is included in the citation if the total number of authors is greater than the number given in (13); keep empty if not applicable
// 15. output: string that's appended to the number of authors given in (14) if the total number of authors is greater than the number given in (13); the actual number of authors can be printed by including '__NUMBER_OF_AUTHORS__' (without quotes) within the string
//
// 16. output: boolean value that specifies whether the re-ordered string shall be returned with higher ASCII chars HTML encoded
$author = reArrangeAuthorContents($author, // 1.
true, // 2.
"/ *; */", // 3.
", ", // 4.
" " . $markupPatternsArray["ampersand"] . " ", // 5.
"/ *, */", // 6.
", ", // 7.
", ", // 8.
".", // 9.
false, // 10.
false, // 11.
true, // 12.
"4", // 13.
"1", // 14.
" et al", // 15.
$encodeHTML); // 16.
// if the author is actually the editor of the resource we'll append ', ed' (or ', eds') to the author string:
// [to distinguish editors from authors in the 'author' field, the 'modify.php' script does append ' (ed)' or ' (eds)' if appropriate,
// so we're just checking for these identifier strings here. Alternatively, we could check whether the editor field matches the author field]
if (preg_match("/[ \r\n]*\(ed\)/", $row['author'])) // single editor
$author = $author . " ed.";
elseif (preg_match("/[ \r\n]*\(eds\)/", $row['author'])) // multiple editors
$author = $author . " eds.";
$record .= $author;
}
if (!empty($row['year'])) // year
$record .= " (" . $row['year'] . ")";
if (!empty($row['title'])) // title
$record .= " " . $markupPatternsArray["italic-prefix"] . $row['title'] . $markupPatternsArray["italic-suffix"];
if ($row['online_publication'] == "yes") // this record refers to an online publication
$record .= " [Internet]";
if (!empty($row['editor']) && !preg_match("/[ \r\n]*\(eds?\)/", $row['author'])) // editor (if different from author, see note above regarding the check for ' (ed)' or ' (eds)')
{
// Call the 'reArrangeAuthorContents()' function (defined in 'include.inc.php') in order to re-order contents of the author field. Required Parameters:
// 1. input: contents of the author field
// 2. input: boolean value that specifies whether the author's family name comes first (within one author) in the source string
// ('true' means that the family name is followed by the given name (or initials), 'false' if it's the other way around)
//
// 3. input: pattern describing old delimiter that separates different authors
// 4. output: for all authors except the last author: new delimiter that separates different authors
// 5. output: for the last author: new delimiter that separates the last author from all other authors
//
// 6. input: pattern describing old delimiter that separates author name & initials (within one author)
// 7. output: for the first author: new delimiter that separates author name & initials (within one author)
// 8. output: for all authors except the first author: new delimiter that separates author name & initials (within one author)
// 9. output: new delimiter that separates multiple initials (within one author)
// 10. output: for the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db)
// 11. output: for all authors except the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db)
// 12. output: boolean value that specifies whether an author's full given name(s) shall be shortened to initial(s)
//
// 13. output: if the total number of authors is greater than the given number (integer >= 1), only the number of authors given in (14) will be included in the citation along with the string given in (15); keep empty if all authors shall be returned
// 14. output: number of authors (integer >= 1) that is included in the citation if the total number of authors is greater than the number given in (13); keep empty if not applicable
// 15. output: string that's appended to the number of authors given in (14) if the total number of authors is greater than the number given in (13); the actual number of authors can be printed by including '__NUMBER_OF_AUTHORS__' (without quotes) within the string
//
// 16. output: boolean value that specifies whether the re-ordered string shall be returned with higher ASCII chars HTML encoded
$editor = reArrangeAuthorContents($row['editor'], // 1.
true, // 2.
"/ *; */", // 3.
", ", // 4.
" " . $markupPatternsArray["ampersand"] . " ", // 5.
"/ *, */", // 6.
", ", // 7.
", ", // 8.
".", // 9.
false, // 10.
false, // 11.
true, // 12.
"4", // 13.
"1", // 14.
" et al", // 15.
$encodeHTML); // 16.
if (!empty($row['author']) || !empty($row['year']) || !empty($row['title']))
$record .= " ";
$record .= " (" . $editor . " ";
if (preg_match("/^[^;\r\n]+(;[^;\r\n]+)+$/", $row['editor'])) // there are at least two editors (separated by ';')
$record .= "eds.";
else // there's only one editor (or the editor field is malformed with multiple editors but missing ';' separator[s])
$record .= "ed.";
$record .= ")";
}
if (!empty($row['edition']) || !empty($row['volume']))
{
if (!empty($row['author']) || !empty($row['year']) || !empty($row['title']) || (!empty($row['editor']) && !preg_match("/[ \r\n]*\(eds?\)/", $row['author'])))
$record .= ". ";
if ($row['type'] == "Software") // software edition (=version)
{
if (!empty($row['edition']))
{
$record .= "Version " . $row['edition'];
if (!empty($row['volume']) || !empty($row['issue']))
$record .= ", ";
}
if (!empty($row['issue'])) // issue (=day)
$record .= " " . $row['issue'];
if (!empty($row['volume'])) // volume (=month)
$record .= " " . $row['volume'];
}
elseif (!preg_match("/^(1|1st|first|one)( ed\.?| edition)?$/i", $row['edition'])) // regular edition (other than the first)
{
if (preg_match("/^\d{1,3}$/", $row['edition'])) // if the edition field contains a number of up to three digits, we assume it's an edition number (such as "2nd ed.")
{
if ($row['edition'] == "2")
$editionSuffix = "nd";
elseif ($row['edition'] == "3")
$editionSuffix = "rd";
else
$editionSuffix = "th";
}
else
$editionSuffix = "";
if (!empty($row['edition']) && !preg_match("/( ed\.?| edition)$/i", $row['edition']))
$editionSuffix .= " ed.";
$record .= $row['edition'] . $editionSuffix;
if (!empty($row['volume'])) // volume
{
if (!empty($row['edition']) && !preg_match("/^(1|1st|first|one)( ed\.?| edition)?$/i", $row['edition']))
$record .= ", ";
$record .= "vol. " . $row['volume']; // TODO: not sure whether this is correct (should this be printed before the edition number?)
}
}
}
if ($row['type'] == "Software") // for software, add software label
{
$record .= ", computer software.";
}
else // add series info
{
if (!preg_match("/\. *$/", $record))
$record .= ".";
if (!empty($row['abbrev_series_title']) OR !empty($row['series_title'])) // if there's either a full or an abbreviated series title
{
$record .= " ";
if (!empty($row['series_title']))
$record .= $row['series_title']; // full series title
// if there's no full series title, we'll use the abbreviated series title instead:
elseif (!empty($row['abbrev_series_title']))
$record .= $row['abbrev_series_title']; // abbreviated series title
if (!empty($row['series_volume'])||!empty($row['series_issue']))
$record .= ", ";
if (!empty($row['series_volume'])) // series volume (I'm not really sure if -- for this cite style -- the series volume & issue should be rather omitted here)
$record .= "vol. " . $row['series_volume']; // TODO: not sure whether this is correct
if (!empty($row['series_issue'])) // series issue (see note for series volume)
{
if (!empty($row['series_volume']))
$record .= ", ";
$record .= "no. " . $row['series_issue']; // TODO: not sure whether this is correct
}
$record .= ".";
}
}
if (!empty($row['thesis'])) // thesis
$record .= " " . $row['thesis'];
if (!empty($row['place']) || !empty($row['publisher']))
{
if (!empty($row['thesis']))
$record .= ",";
if (!empty($row['place'])) // place (NOTE: should we omit the place of publication for theses?)
$record .= " " . $row['place'];
if (!empty($row['publisher'])) // publisher
{
if (!empty($row['place']))
$record .= ",";
$record .= " " . $row['publisher'];
}
}
if ($row['online_publication'] == "yes" || $row['type'] == "Software") // this record refers to an online article, or a computer program/software
{
if (!empty($row['online_citation'])) // online_citation
{
if (!preg_match("/\. *$/", $record))
$record .= ".";
$record .= " " . $row['online_citation'];
}
if (!empty($row['doi']) || !empty($row['url'])) // doi OR url
{
if (!preg_match("/\. *$/", $record))
$record .= ".";
$today = date("j F Y");
$record .= " Available from: ";
if (!empty($row['doi'])) // doi
$uri = "http://dx.doi.org/" . $row['doi'];
else // url
$uri = $row['url'];
if ($encodeHTML)
$record .= encodeHTML($markupPatternsArray["less-than"] . $uri . $markupPatternsArray["greater-than"]);
else
$record .= $markupPatternsArray["less-than"] . $uri . $markupPatternsArray["greater-than"];
$record .= " [Accessed " . $today . "]";
}
}
if (!preg_match("/\. *$/", $record)) // if the string doesn't end with a period
$record .= ".";
}
// --- BEGIN POST-PROCESSING -----------------------------------------------------------------------------------------------------------
// do some further cleanup:
$record = trim($record); // remove any preceding or trailing whitespace
return $record;
}
// --- END CITATION STYLE ---
?>

View File

@@ -0,0 +1,684 @@
<?php
// Project: Web Reference Database (refbase) <http://www.refbase.net>
// Copyright: Matthias Steffens <mailto:refbase@extracts.de> and the file's
// original author(s).
//
// This code is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY. Please see the GNU General Public
// License for more details.
//
// File: ./cite/styles/cite_Harvard_3.php
// Repository: $HeadURL$
// Author(s): Matthias Steffens <mailto:refbase@extracts.de>
//
// Created: 01-Aug-08, 02:00
// Modified: $Date: 2012-02-27 20:25:30 +0000 (Mon, 27 Feb 2012) $
// $Author$
// $Revision: 1337 $
// This is a citation style file (which must reside within the 'cite/styles/' sub-directory of your refbase root directory). It contains a
// version of the 'citeRecord()' function that outputs a reference list from selected records according to the citation style used by
// the Harvard referencing system
// This is a variant of the Harvard author/date style, modeled after these resources:
// <http://library.curtin.edu.au/referencing/harvard.html> (not available anymore?)
// <http://www.usq.edu.au/library/help/ehelp/ref_guides/harvard.htm>
// <http://www.library.uwa.edu.au/education_training_and_support/guides/harvard_citation_style>
// <http://www.lib.unimelb.edu.au/cite/harvard_dis/>
// based on 'cite_APA.php'
// TODO: - patents & reports?
// - should we shorten ending page numbers if necessary (e.g. "pp. 10-8" or "pp. 51-5", but "pp. 19-26"), or only if numbers are >=3 digits?
// - where to put (and how to format) series info & editors of whole books that also have an author?
// --------------------------------------------------------------------
// --- BEGIN CITATION STYLE ---
function citeRecord($row, $citeStyle, $citeType, $markupPatternsArray, $encodeHTML)
{
$record = ""; // make sure that our buffer variable is empty
// --- BEGIN TYPE = JOURNAL ARTICLE / MAGAZINE ARTICLE / NEWSPAPER ARTICLE --------------------------------------------------------------
if (preg_match("/^(Journal Article|Magazine Article|Newspaper Article)$/", $row['type']))
{
if (!empty($row['author'])) // author
{
// Call the 'reArrangeAuthorContents()' function (defined in 'include.inc.php') in order to re-order contents of the author field. Required Parameters:
// 1. input: contents of the author field
// 2. input: boolean value that specifies whether the author's family name comes first (within one author) in the source string
// ('true' means that the family name is followed by the given name (or initials), 'false' if it's the other way around)
//
// 3. input: pattern describing old delimiter that separates different authors
// 4. output: for all authors except the last author: new delimiter that separates different authors
// 5. output: for the last author: new delimiter that separates the last author from all other authors
//
// 6. input: pattern describing old delimiter that separates author name & initials (within one author)
// 7. output: for the first author: new delimiter that separates author name & initials (within one author)
// 8. output: for all authors except the first author: new delimiter that separates author name & initials (within one author)
// 9. output: new delimiter that separates multiple initials (within one author)
// 10. output: for the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db)
// 11. output: for all authors except the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db)
// 12. output: boolean value that specifies whether an author's full given name(s) shall be shortened to initial(s)
//
// 13. output: if the total number of authors is greater than the given number (integer >= 1), only the number of authors given in (14) will be included in the citation along with the string given in (15); keep empty if all authors shall be returned
// 14. output: number of authors (integer >= 1) that is included in the citation if the total number of authors is greater than the number given in (13); keep empty if not applicable
// 15. output: string that's appended to the number of authors given in (14) if the total number of authors is greater than the number given in (13); the actual number of authors can be printed by including '__NUMBER_OF_AUTHORS__' (without quotes) within the string
//
// 16. output: boolean value that specifies whether the re-ordered string shall be returned with higher ASCII chars HTML encoded
$author = reArrangeAuthorContents($row['author'], // 1.
true, // 2.
"/ *; */", // 3.
", ", // 4.
" " . $markupPatternsArray["ampersand"] . " ", // 5.
"/ *, */", // 6.
", ", // 7.
", ", // 8.
"", // 9.
false, // 10.
false, // 11.
true, // 12.
"", // 13.
"", // 14.
" et al", // 15.
$encodeHTML); // 16.
$record .= $author;
}
if (!empty($row['year'])) // year
{
if (!empty($row['author']))
$record .= " ";
if (!empty($row['year']))
$record .= $row['year'];
}
if (!empty($row['title'])) // title
{
if (!empty($row['author']) || !empty($row['year']))
$record .= ", ";
$record .= $markupPatternsArray["single-quote-left"] . $row['title'] . $markupPatternsArray["single-quote-right"];
$record .= ",";
}
// From here on we'll assume that at least one of the fields 'author', 'year' or 'title' did contain some contents
if (!empty($row['publication'])) // publication (= journal) name
$record .= " " . $markupPatternsArray["italic-prefix"] . $row['publication'] . $markupPatternsArray["italic-suffix"];
// if there's no full journal name, we'll use the abbreviated journal name instead:
elseif (!empty($row['abbrev_journal'])) // abbreviated journal name
$record .= " " . $markupPatternsArray["italic-prefix"] . $row['abbrev_journal'] . $markupPatternsArray["italic-suffix"];
if ((!empty($row['abbrev_journal']) || !empty($row['publication'])) && (!empty($row['volume']) || !empty($row['issue'])))
$record .= ",";
if ($row['type'] == "Journal Article") // for journal articles, volume (or issue) information is printed with a "vol." (or "no.") prefix
{
if (!empty($row['volume'])) // volume
$record .= " vol. " . $row['volume'];
if (!empty($row['issue'])) // issue
{
if (!empty($row['volume']))
$record .= ",";
$record .= " no. " . $row['issue'];
}
}
elseif (preg_match("/^(Newspaper Article|Magazine Article)$/", $row['type'])) // for newspaper and magazine articles, volume (=month) and issue (=day) information is printed without prefix
{
if (!empty($row['issue'])) // issue (=day)
$record .= " " . $row['issue'];
if (!empty($row['volume'])) // volume (=month)
$record .= " " . $row['volume'];
}
if (!empty($row['pages'])) // pages
{
if (!empty($row['volume']) || !empty($row['issue']) || !empty($row['abbrev_journal']) || !empty($row['publication'])) // only add ", " if either volume, issue, abbrev_journal or publication isn't empty
$record .= ", ";
$record .= formatPageInfo($row['pages'], $markupPatternsArray["endash"], "p. ", "pp. "); // function 'formatPageInfo()' is defined in 'cite.inc.php'
}
if ($row['online_publication'] == "yes") // this record refers to an online article
{
// append an optional string (given in 'online_citation') plus the current date and the DOI (or URL):
if (!empty($row['online_citation'])) // online_citation
{
if (!empty($row['volume']) || !empty($row['issue']) || !empty($row['abbrev_journal']) || !empty($row['publication'])) // only add "," if either volume, issue, abbrev_journal or publication isn't empty
$record .= ",";
$record .= " " . $row['online_citation'];
}
if (!empty($row['doi']) || !empty($row['url'])) // doi OR url
{
if (!empty($row['online_citation']) OR (empty($row['online_citation']) AND (!empty($row['volume']) || !empty($row['issue']) || !empty($row['abbrev_journal']) || !empty($row['publication'])))) // only add "." if online_citation isn't empty, or else if either volume, issue, abbrev_journal or publication isn't empty
$record .= ".";
$today = date("j F Y");
$record .= " Available from: "; // NOTE: some of the above mentioned resources use ", accessed 26 February 2004, from <http://...>." (or ", viewed on ...") instead
if (!empty($row['doi'])) // doi
$uri = "http://dx.doi.org/" . $row['doi'];
else // url
$uri = $row['url'];
if ($encodeHTML)
$record .= encodeHTML($markupPatternsArray["less-than"] . $uri . $markupPatternsArray["greater-than"]);
else
$record .= $markupPatternsArray["less-than"] . $uri . $markupPatternsArray["greater-than"];
$record .= " [" . $today . "]";
}
}
if (!preg_match("/\. *$/", $record)) // if the string doesn't end with a period
$record .= ".";
}
// --- BEGIN TYPE = ABSTRACT / BOOK CHAPTER / CONFERENCE ARTICLE ------------------------------------------------------------------------
elseif (preg_match("/^(Abstract|Book Chapter|Conference Article)$/", $row['type']))
{
if (!empty($row['author'])) // author
{
// Call the 'reArrangeAuthorContents()' function (defined in 'include.inc.php') in order to re-order contents of the author field. Required Parameters:
// 1. input: contents of the author field
// 2. input: boolean value that specifies whether the author's family name comes first (within one author) in the source string
// ('true' means that the family name is followed by the given name (or initials), 'false' if it's the other way around)
//
// 3. input: pattern describing old delimiter that separates different authors
// 4. output: for all authors except the last author: new delimiter that separates different authors
// 5. output: for the last author: new delimiter that separates the last author from all other authors
//
// 6. input: pattern describing old delimiter that separates author name & initials (within one author)
// 7. output: for the first author: new delimiter that separates author name & initials (within one author)
// 8. output: for all authors except the first author: new delimiter that separates author name & initials (within one author)
// 9. output: new delimiter that separates multiple initials (within one author)
// 10. output: for the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db)
// 11. output: for all authors except the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db)
// 12. output: boolean value that specifies whether an author's full given name(s) shall be shortened to initial(s)
//
// 13. output: if the total number of authors is greater than the given number (integer >= 1), only the number of authors given in (14) will be included in the citation along with the string given in (15); keep empty if all authors shall be returned
// 14. output: number of authors (integer >= 1) that is included in the citation if the total number of authors is greater than the number given in (13); keep empty if not applicable
// 15. output: string that's appended to the number of authors given in (14) if the total number of authors is greater than the number given in (13); the actual number of authors can be printed by including '__NUMBER_OF_AUTHORS__' (without quotes) within the string
//
// 16. output: boolean value that specifies whether the re-ordered string shall be returned with higher ASCII chars HTML encoded
$author = reArrangeAuthorContents($row['author'], // 1.
true, // 2.
"/ *; */", // 3.
", ", // 4.
" " . $markupPatternsArray["ampersand"] . " ", // 5.
"/ *, */", // 6.
", ", // 7.
", ", // 8.
"", // 9.
false, // 10.
false, // 11.
true, // 12.
"", // 13.
"", // 14.
" et al", // 15.
$encodeHTML); // 16.
$record .= $author;
}
if (!empty($row['year'])) // year
{
if (!empty($row['author']))
$record .= " ";
$record .= $row['year'];
}
if (!empty($row['title'])) // title
{
if (!empty($row['author']) || !empty($row['year']))
$record .= ", ";
$record .= $markupPatternsArray["single-quote-left"] . $row['title'] . $markupPatternsArray["single-quote-right"];
$record .= ",";
}
// From here on we'll assume that at least one of the fields 'author', 'year' or 'title' did contain some contents
// if this is not the case, the output string will begin with a space. However, any preceding/trailing whitespace will be removed at the cleanup stage (see below)
if (!empty($row['editor'])) // editor
{
// Call the 'reArrangeAuthorContents()' function (defined in 'include.inc.php') in order to re-order contents of the author field. Required Parameters:
// 1. input: contents of the author field
// 2. input: boolean value that specifies whether the author's family name comes first (within one author) in the source string
// ('true' means that the family name is followed by the given name (or initials), 'false' if it's the other way around)
//
// 3. input: pattern describing old delimiter that separates different authors
// 4. output: for all authors except the last author: new delimiter that separates different authors
// 5. output: for the last author: new delimiter that separates the last author from all other authors
//
// 6. input: pattern describing old delimiter that separates author name & initials (within one author)
// 7. output: for the first author: new delimiter that separates author name & initials (within one author)
// 8. output: for all authors except the first author: new delimiter that separates author name & initials (within one author)
// 9. output: new delimiter that separates multiple initials (within one author)
// 10. output: for the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db)
// 11. output: for all authors except the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db)
// 12. output: boolean value that specifies whether an author's full given name(s) shall be shortened to initial(s)
//
// 13. output: if the total number of authors is greater than the given number (integer >= 1), only the number of authors given in (14) will be included in the citation along with the string given in (15); keep empty if all authors shall be returned
// 14. output: number of authors (integer >= 1) that is included in the citation if the total number of authors is greater than the number given in (13); keep empty if not applicable
// 15. output: string that's appended to the number of authors given in (14) if the total number of authors is greater than the number given in (13); the actual number of authors can be printed by including '__NUMBER_OF_AUTHORS__' (without quotes) within the string
//
// 16. output: boolean value that specifies whether the re-ordered string shall be returned with higher ASCII chars HTML encoded
$editor = reArrangeAuthorContents($row['editor'], // 1.
true, // 2.
"/ *; */", // 3.
", ", // 4.
" " . $markupPatternsArray["ampersand"] . " ", // 5.
"/ *, */", // 6.
" ", // 7.
" ", // 8.
"", // 9.
true, // 10.
true, // 11.
true, // 12.
"", // 13.
"", // 14.
" et al", // 15.
$encodeHTML); // 16.
$record .= " in " . $editor . " (";
if (preg_match("/^[^;\r\n]+(;[^;\r\n]+)+$/", $row['editor'])) // there are at least two editors (separated by ';')
$record .= "eds.";
else // there's only one editor (or the editor field is malformed with multiple editors but missing ';' separator[s])
$record .= "ed.";
$record .= "),";
}
$publication = preg_replace("/[ \r\n]*\(Eds?:[^\)\r\n]*\)/i", "", $row['publication']);
if (!empty($publication)) // publication
{
if (empty($row['editor']))
$record .= " in";
$record .= " " . $markupPatternsArray["italic-prefix"] . $publication . $markupPatternsArray["italic-suffix"];
}
if (!empty($row['edition']) && !preg_match("/^(1|1st|first|one)( ed\.?| edition)?$/i", $row['edition']) || !empty($row['volume']))
{
$record .= ", ";
if (!empty($row['edition']) && !preg_match("/^(1|1st|first|one)( ed\.?| edition)?$/i", $row['edition'])) // edition
{
if (preg_match("/^\d{1,3}$/", $row['edition'])) // if the edition field contains a number of up to three digits, we assume it's an edition number (such as "2nd edn")
{
if ($row['edition'] == "2")
$editionSuffix = "nd";
elseif ($row['edition'] == "3")
$editionSuffix = "rd";
else
$editionSuffix = "th";
}
else
$editionSuffix = "";
if (!empty($row['edition']) && !preg_match("/( ed\.?| edition)$/i", $row['edition']))
$editionSuffix .= " edn";
$record .= $row['edition'] . $editionSuffix;
}
if (!empty($row['volume'])) // volume
{
if (!empty($row['edition']) && !preg_match("/^(1|1st|first|one)( ed\.?| edition)?$/i", $row['edition']))
$record .= ", ";
$record .= "vol. " . $row['volume'];
}
}
if (!empty($row['abbrev_series_title']) OR !empty($row['series_title'])) // if there's either a full or an abbreviated series title
{
$record .= ", ";
if (!empty($row['series_title']))
$record .= $row['series_title']; // full series title
// if there's no full series title, we'll use the abbreviated series title instead:
elseif (!empty($row['abbrev_series_title']))
$record .= $row['abbrev_series_title']; // abbreviated series title
if (!empty($row['series_volume'])||!empty($row['series_issue']))
$record .= ", ";
if (!empty($row['series_volume'])) // series volume (I'm not really sure if -- for this cite style -- the series volume & issue should be rather omitted here)
$record .= "vol. " . $row['series_volume'];
if (!empty($row['series_issue'])) // series issue (see note for series volume)
{
if (!empty($row['series_volume']))
$record .= ", ";
$record .= "no. " . $row['series_issue'];
}
}
$record .= ",";
if (!empty($row['publisher'])) // publisher
$record .= " " . $row['publisher'];
if (!empty($row['place'])) // place
{
if (!empty($row['publisher']))
$record .= ",";
$record .= " " . $row['place'];
}
if (!empty($row['pages'])) // pages
{
if (!empty($row['publisher']) || !empty($row['place']))
$record .= ", ";
$record .= formatPageInfo($row['pages'], $markupPatternsArray["endash"], "p. ", "pp. "); // function 'formatPageInfo()' is defined in 'cite.inc.php'
}
if (!preg_match("/\. *$/", $record))
$record .= ".";
}
// --- BEGIN TYPE = BOOK WHOLE / CONFERENCE VOLUME / JOURNAL / MANUAL / MANUSCRIPT / MAP / MISCELLANEOUS / PATENT / REPORT / SOFTWARE ---
else // if (preg_match("/Book Whole|Conference Volume|Journal|Manual|Manuscript|Map|Miscellaneous|Patent|Report|Software/", $row['type']))
// note that this also serves as a fallback: unrecognized resource types will be formatted similar to whole books
{
if (!empty($row['author'])) // author
{
$author = preg_replace("/[ \r\n]*\(eds?\)/i", "", $row['author']);
// Call the 'reArrangeAuthorContents()' function (defined in 'include.inc.php') in order to re-order contents of the author field. Required Parameters:
// 1. input: contents of the author field
// 2. input: boolean value that specifies whether the author's family name comes first (within one author) in the source string
// ('true' means that the family name is followed by the given name (or initials), 'false' if it's the other way around)
//
// 3. input: pattern describing old delimiter that separates different authors
// 4. output: for all authors except the last author: new delimiter that separates different authors
// 5. output: for the last author: new delimiter that separates the last author from all other authors
//
// 6. input: pattern describing old delimiter that separates author name & initials (within one author)
// 7. output: for the first author: new delimiter that separates author name & initials (within one author)
// 8. output: for all authors except the first author: new delimiter that separates author name & initials (within one author)
// 9. output: new delimiter that separates multiple initials (within one author)
// 10. output: for the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db)
// 11. output: for all authors except the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db)
// 12. output: boolean value that specifies whether an author's full given name(s) shall be shortened to initial(s)
//
// 13. output: if the total number of authors is greater than the given number (integer >= 1), only the number of authors given in (14) will be included in the citation along with the string given in (15); keep empty if all authors shall be returned
// 14. output: number of authors (integer >= 1) that is included in the citation if the total number of authors is greater than the number given in (13); keep empty if not applicable
// 15. output: string that's appended to the number of authors given in (14) if the total number of authors is greater than the number given in (13); the actual number of authors can be printed by including '__NUMBER_OF_AUTHORS__' (without quotes) within the string
//
// 16. output: boolean value that specifies whether the re-ordered string shall be returned with higher ASCII chars HTML encoded
$author = reArrangeAuthorContents($author, // 1.
true, // 2.
"/ *; */", // 3.
", ", // 4.
" " . $markupPatternsArray["ampersand"] . " ", // 5.
"/ *, */", // 6.
", ", // 7.
", ", // 8.
"", // 9.
false, // 10.
false, // 11.
true, // 12.
"", // 13.
"", // 14.
" et al", // 15.
$encodeHTML); // 16.
// if the author is actually the editor of the resource we'll append ', ed' (or ', eds') to the author string:
// [to distinguish editors from authors in the 'author' field, the 'modify.php' script does append ' (ed)' or ' (eds)' if appropriate,
// so we're just checking for these identifier strings here. Alternatively, we could check whether the editor field matches the author field]
if (preg_match("/[ \r\n]*\(ed\)/", $row['author'])) // single editor
$author = $author . " (ed.)";
elseif (preg_match("/[ \r\n]*\(eds\)/", $row['author'])) // multiple editors
$author = $author . " (eds.)";
$record .= $author;
}
if (!empty($row['year'])) // year
{
if (!empty($row['author']))
$record .= " ";
$record .= $row['year'];
}
if (!empty($row['title'])) // title
{
if (!empty($row['author']) || !empty($row['year']))
$record .= ", ";
if (!empty($row['thesis'])) // for theses, the title is printed in roman type and in quotation marks
$record .= $markupPatternsArray["single-quote-left"] . $row['title'] . $markupPatternsArray["single-quote-right"];
else // otherwise, the title is printed in italics
$record .= $markupPatternsArray["italic-prefix"] . $row['title'] . $markupPatternsArray["italic-suffix"];
}
if (!empty($row['editor']) && !preg_match("/[ \r\n]*\(eds?\)/", $row['author'])) // editor (if different from author, see note above regarding the check for ' (ed)' or ' (eds)')
{
// Call the 'reArrangeAuthorContents()' function (defined in 'include.inc.php') in order to re-order contents of the author field. Required Parameters:
// 1. input: contents of the author field
// 2. input: boolean value that specifies whether the author's family name comes first (within one author) in the source string
// ('true' means that the family name is followed by the given name (or initials), 'false' if it's the other way around)
//
// 3. input: pattern describing old delimiter that separates different authors
// 4. output: for all authors except the last author: new delimiter that separates different authors
// 5. output: for the last author: new delimiter that separates the last author from all other authors
//
// 6. input: pattern describing old delimiter that separates author name & initials (within one author)
// 7. output: for the first author: new delimiter that separates author name & initials (within one author)
// 8. output: for all authors except the first author: new delimiter that separates author name & initials (within one author)
// 9. output: new delimiter that separates multiple initials (within one author)
// 10. output: for the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db)
// 11. output: for all authors except the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db)
// 12. output: boolean value that specifies whether an author's full given name(s) shall be shortened to initial(s)
//
// 13. output: if the total number of authors is greater than the given number (integer >= 1), only the number of authors given in (14) will be included in the citation along with the string given in (15); keep empty if all authors shall be returned
// 14. output: number of authors (integer >= 1) that is included in the citation if the total number of authors is greater than the number given in (13); keep empty if not applicable
// 15. output: string that's appended to the number of authors given in (14) if the total number of authors is greater than the number given in (13); the actual number of authors can be printed by including '__NUMBER_OF_AUTHORS__' (without quotes) within the string
//
// 16. output: boolean value that specifies whether the re-ordered string shall be returned with higher ASCII chars HTML encoded
$editor = reArrangeAuthorContents($row['editor'], // 1.
true, // 2.
"/ *; */", // 3.
", ", // 4.
" " . $markupPatternsArray["ampersand"] . " ", // 5.
"/ *, */", // 6.
" ", // 7.
" ", // 8.
"", // 9.
true, // 10.
true, // 11.
true, // 12.
"", // 13.
"", // 14.
" et al", // 15.
$encodeHTML); // 16.
if (!empty($row['author']) || !empty($row['year']) || !empty($row['title']))
$record .= " ";
$record .= " (" . $editor . ", ";
if (preg_match("/^[^;\r\n]+(;[^;\r\n]+)+$/", $row['editor'])) // there are at least two editors (separated by ';')
$record .= "eds.";
else // there's only one editor (or the editor field is malformed with multiple editors but missing ';' separator[s])
$record .= "ed.";
$record .= ")";
}
if (!empty($row['edition']) || !empty($row['volume']))
{
if (!empty($row['author']) || !empty($row['year']) || !empty($row['title']) || (!empty($row['editor']) && !preg_match("/[ \r\n]*\(eds?\)/", $row['author'])))
$record .= ", ";
if ($row['type'] == "Software") // software edition (=version)
{
if (!empty($row['edition']))
{
$record .= "version " . $row['edition'];
if (!empty($row['volume']) || !empty($row['issue']))
$record .= ", ";
}
if (!empty($row['issue'])) // issue (=day)
$record .= " " . $row['issue'];
if (!empty($row['volume'])) // volume (=month)
$record .= " " . $row['volume'];
}
elseif (!preg_match("/^(1|1st|first|one)( ed\.?| edition)?$/i", $row['edition'])) // regular edition (other than the first)
{
if (preg_match("/^\d{1,3}$/", $row['edition'])) // if the edition field contains a number of up to three digits, we assume it's an edition number (such as "2nd edn")
{
if ($row['edition'] == "2")
$editionSuffix = "nd";
elseif ($row['edition'] == "3")
$editionSuffix = "rd";
else
$editionSuffix = "th";
}
else
$editionSuffix = "";
if (!empty($row['edition']) && !preg_match("/( ed\.?| edition)$/i", $row['edition']))
$editionSuffix .= " edn";
$record .= $row['edition'] . $editionSuffix;
if (!empty($row['volume'])) // volume
{
if (!empty($row['edition']) && !preg_match("/^(1|1st|first|one)( ed\.?| edition)?$/i", $row['edition']))
$record .= ", ";
$record .= "vol. " . $row['volume'];
}
}
}
if ($row['type'] == "Software") // for software, add software label
{
$record .= ", computer software";
}
else // add series info
{
if (!empty($row['abbrev_series_title']) OR !empty($row['series_title'])) // if there's either a full or an abbreviated series title
{
if ((!empty($row['title']) && !preg_match("/[?!.]$/", $row['title'])) || (!empty($row['editor']) && !preg_match("/[ \r\n]*\(eds?\)/", $row['author'])) || !empty($row['edition']) || !empty($row['volume']))
$record .= ",";
$record .= " ";
if (!empty($row['series_title']))
$record .= $row['series_title']; // full series title
// if there's no full series title, we'll use the abbreviated series title instead:
elseif (!empty($row['abbrev_series_title']))
$record .= $row['abbrev_series_title']; // abbreviated series title
if (!empty($row['series_volume'])||!empty($row['series_issue']))
$record .= ", ";
if (!empty($row['series_volume'])) // series volume (I'm not really sure if -- for this cite style -- the series volume & issue should be rather omitted here)
$record .= "vol. " . $row['series_volume'];
if (!empty($row['series_issue'])) // series issue (see note for series volume)
{
if (!empty($row['series_volume']))
$record .= ", ";
$record .= "no. " . $row['series_issue'];
}
}
}
if (!empty($row['thesis'])) // thesis
{
$record .= ", " . $row['thesis'];
$record .= ", " . $row['publisher'];
$record .= ", " . $row['place']; // NOTE: should we omit the place of publication for theses?
}
else // not a thesis
{
if (!empty($row['publisher'])) // publisher
$record .= ", " . $row['publisher'];
if (!empty($row['place'])) // place
{
if (!empty($row['publisher']))
$record .= ",";
$record .= " " . $row['place'];
}
}
if ($row['online_publication'] == "yes" || $row['type'] == "Software") // this record refers to an online article, or a computer program/software
{
if (!empty($row['online_citation'])) // online_citation
{
if (!preg_match("/\. *$/", $record))
$record .= ".";
$record .= " " . $row['online_citation'];
}
if (!empty($row['doi']) || !empty($row['url'])) // doi OR url
{
if (!preg_match("/\. *$/", $record))
$record .= ".";
$today = date("j F Y");
$record .= " Available from: "; // NOTE: some of the above mentioned resources use ", accessed 26 February 2004, from <http://...>." (or ", viewed on ...") instead
if (!empty($row['doi'])) // doi
$uri = "http://dx.doi.org/" . $row['doi'];
else // url
$uri = $row['url'];
if ($encodeHTML)
$record .= encodeHTML($markupPatternsArray["less-than"] . $uri . $markupPatternsArray["greater-than"]);
else
$record .= $markupPatternsArray["less-than"] . $uri . $markupPatternsArray["greater-than"];
$record .= " [" . $today . "]";
}
}
if (!preg_match("/\. *$/", $record)) // if the string doesn't end with a period
$record .= ".";
}
// --- BEGIN POST-PROCESSING -----------------------------------------------------------------------------------------------------------
// do some further cleanup:
$record = trim($record); // remove any preceding or trailing whitespace
return $record;
}
// --- END CITATION STYLE ---
?>

660
cite/styles/cite_MLA.php Normal file
View File

@@ -0,0 +1,660 @@
<?php
// Project: Web Reference Database (refbase) <http://www.refbase.net>
// Copyright: Matthias Steffens <mailto:refbase@extracts.de> and the file's
// original author(s).
//
// This code is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY. Please see the GNU General Public
// License for more details.
//
// File: ./cite/styles/cite_MLA.php
// Repository: $HeadURL: file:///svn/p/refbase/code/branches/bleeding-edge/cite/styles/cite_MLA.php $
// Author(s): Richard Karnesky <mailto:karnesky@gmail.com> and
// Matthias Steffens <mailto:refbase@extracts.de>
//
// Created: 13-Nov-06, 15:00
// Modified: $Date: 2012-02-27 20:25:30 +0000 (Mon, 27 Feb 2012) $
// $Author: msteffens $
// $Revision: 1337 $
// This is a citation style file (which must reside within the 'cite/styles/' sub-directory of your refbase root directory). It contains a
// version of the 'citeRecord()' function that outputs a reference list from selected records according to the citation style used by
// the Modern Language Association (MLA)
// based on 'cite_APA.php'
// TODO: - newspaper & magazine articles, conference proceedings, manuals, patents, reports, software, published dissertation
// - use dashes for subsequent entries when citing two or more books by the same author -> see e.g. example at: <http://web.csustan.edu/english/reuben/pal/append/AXI.HTML>
// - don't add a dot if the abbreviated journal (or series title) ends with a dot!
// --------------------------------------------------------------------
// --- BEGIN CITATION STYLE ---
function citeRecord($row, $citeStyle, $citeType, $markupPatternsArray, $encodeHTML)
{
$record = ""; // make sure that our buffer variable is empty
// --- BEGIN TYPE = JOURNAL ARTICLE / MAGAZINE ARTICLE / NEWSPAPER ARTICLE --------------------------------------------------------------
if (preg_match("/^(Journal Article|Magazine Article|Newspaper Article)$/", $row['type']))
{
if (!empty($row['author'])) // author
{
// Call the 'reArrangeAuthorContents()' function (defined in 'include.inc.php') in order to re-order contents of the author field. Required Parameters:
// 1. input: contents of the author field
// 2. input: boolean value that specifies whether the author's family name comes first (within one author) in the source string
// ('true' means that the family name is followed by the given name (or initials), 'false' if it's the other way around)
//
// 3. input: pattern describing old delimiter that separates different authors
// 4. output: for all authors except the last author: new delimiter that separates different authors
// 5. output: for the last author: new delimiter that separates the last author from all other authors
//
// 6. input: pattern describing old delimiter that separates author name & initials (within one author)
// 7. output: for the first author: new delimiter that separates author name & initials (within one author)
// 8. output: for all authors except the first author: new delimiter that separates author name & initials (within one author)
// 9. output: new delimiter that separates multiple initials (within one author)
// 10. output: for the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db)
// 11. output: for all authors except the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db)
// 12. output: boolean value that specifies whether an author's full given name(s) shall be shortened to initial(s)
//
// 13. output: if the total number of authors is greater than the given number (integer >= 1), only the number of authors given in (14) will be included in the citation along with the string given in (15); keep empty if all authors shall be returned
// 14. output: number of authors (integer >= 1) that is included in the citation if the total number of authors is greater than the number given in (13); keep empty if not applicable
// 15. output: string that's appended to the number of authors given in (14) if the total number of authors is greater than the number given in (13); the actual number of authors can be printed by including '__NUMBER_OF_AUTHORS__' (without quotes) within the string
//
// 16. output: boolean value that specifies whether the re-ordered string shall be returned with higher ASCII chars HTML encoded
$author = reArrangeAuthorContents($row['author'], // 1.
true, // 2.
"/ *; */", // 3.
", ", // 4.
", and ", // 5.
"/ *, */", // 6.
", ", // 7.
" ", // 8.
". ", // 9.
false, // 10.
true, // 11.
false, // 12.
"3", // 13.
"1", // 14.
", et al.", // 15.
$encodeHTML); // 16.
if (!preg_match("/\. *$/", $author))
$record .= $author . ".";
else
$record .= $author;
}
if (!empty($row['title'])) // title
{
if (!empty($row['author']))
$record .= " ";
$record .= '"' . $row['title'];
if (!preg_match("/[?!.]$/", $row['title']))
$record .= ".";
$record .= '"';
}
// From here on we'll assume that at least either the 'author' or the 'title' field did contain some contents
// if this is not the case, the output string will begin with a space. However, any preceding/trailing whitespace will be removed at the cleanup stage (see below)
if (!empty($row['abbrev_journal'])) // abbreviated journal name
$record .= " " . $markupPatternsArray["italic-prefix"] . $row['abbrev_journal'] . $markupPatternsArray["italic-suffix"];
// if there's no abbreviated journal name, we'll use the full journal name
elseif (!empty($row['publication'])) // publication (= journal) name
$record .= " " . $markupPatternsArray["italic-prefix"] . $row['publication'] . $markupPatternsArray["italic-suffix"];
if (!empty($row['volume'])) // volume
{
if (!empty($row['abbrev_journal']) || !empty($row['publication']))
$record .= ".";
$record .= " " . $row['volume'];
}
if (!empty($row['issue'])) // issue
$record .= "." . $row['issue'];
if (!empty($row['year'])) // year
{
$record .= " (".$row['year'] . ")";
}
if ($row['online_publication'] == "yes") // this record refers to an online article
{
// instead of any pages info (which normally doesn't exist for online publications) we append
// an optional string (given in 'online_citation') plus the current date and the DOI (or URL):
$today = date("j M. Y");
if (!empty($row['online_citation'])) // online_citation
{
if (!empty($row['volume']) || !empty($row['issue']) || !empty($row['abbrev_journal']) || !empty($row['publication'])) // only add ":" if either volume, issue, abbrev_journal or publication isn't empty
$record .= ":";
$record .= " " . $row['online_citation'];
}
if (!empty($row['doi'])) // doi
{
if (!empty($row['online_citation']) OR (empty($row['online_citation']) AND (!empty($row['volume']) || !empty($row['issue']) || !empty($row['abbrev_journal']) || !empty($row['publication'])))) // only add "." if online_citation isn't empty, or else if either volume, issue, abbrev_journal or publication isn't empty
$record .= ".";
if ($encodeHTML)
$record .= " " . $today . encodeHTML(" <http://dx.doi.org/" . $row['doi'] . ">");
else
$record .= " " . $today . " <http://dx.doi.org/" . $row['doi'] . ">";
}
elseif (!empty($row['url'])) // url
{
if (!empty($row['online_citation']) OR (empty($row['online_citation']) AND (!empty($row['volume']) || !empty($row['issue']) || !empty($row['abbrev_journal']) || !empty($row['publication'])))) // only add "." if online_citation isn't empty, or else if either volume, issue, abbrev_journal or publication isn't empty
$record .= ".";
if ($encodeHTML)
$record .= " " . $today . encodeHTML(" <" . $row['url'] . ">");
else
$record .= " " . $today . " <" . $row['url'] . ">";
}
}
else // $row['online_publication'] == "no" -> this record refers to a printed article, so we append any pages info instead:
{
if (!empty($row['pages'])) // pages
{
if (!empty($row['year']) || !empty($row['volume']) || !empty($row['issue']) || !empty($row['abbrev_journal']) || !empty($row['publication'])) // only add ": " if either volume, issue, abbrev_journal or publication isn't empty
$record .= ": ";
$record .= formatPageInfo($row['pages'], $markupPatternsArray["endash"]); // function 'formatPageInfo()' is defined in 'cite.inc.php'
}
}
if (!preg_match("/\. *$/", $record))
$record .= ".";
}
// --- BEGIN TYPE = ABSTRACT / BOOK CHAPTER / CONFERENCE ARTICLE ------------------------------------------------------------------------
elseif (preg_match("/^(Abstract|Book Chapter|Conference Article)$/", $row['type']))
{
if (!empty($row['author'])) // author
{
// Call the 'reArrangeAuthorContents()' function (defined in 'include.inc.php') in order to re-order contents of the author field. Required Parameters:
// 1. input: contents of the author field
// 2. input: boolean value that specifies whether the author's family name comes first (within one author) in the source string
// ('true' means that the family name is followed by the given name (or initials), 'false' if it's the other way around)
//
// 3. input: pattern describing old delimiter that separates different authors
// 4. output: for all authors except the last author: new delimiter that separates different authors
// 5. output: for the last author: new delimiter that separates the last author from all other authors
//
// 6. input: pattern describing old delimiter that separates author name & initials (within one author)
// 7. output: for the first author: new delimiter that separates author name & initials (within one author)
// 8. output: for all authors except the first author: new delimiter that separates author name & initials (within one author)
// 9. output: new delimiter that separates multiple initials (within one author)
// 10. output: for the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db)
// 11. output: for all authors except the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db)
// 12. output: boolean value that specifies whether an author's full given name(s) shall be shortened to initial(s)
//
// 13. output: if the total number of authors is greater than the given number (integer >= 1), only the number of authors given in (14) will be included in the citation along with the string given in (15); keep empty if all authors shall be returned
// 14. output: number of authors (integer >= 1) that is included in the citation if the total number of authors is greater than the number given in (13); keep empty if not applicable
// 15. output: string that's appended to the number of authors given in (14) if the total number of authors is greater than the number given in (13); the actual number of authors can be printed by including '__NUMBER_OF_AUTHORS__' (without quotes) within the string
//
// 16. output: boolean value that specifies whether the re-ordered string shall be returned with higher ASCII chars HTML encoded
$author = reArrangeAuthorContents($row['author'], // 1.
true, // 2.
"/ *; */", // 3.
", ", // 4.
", and ", // 5.
"/ *, */", // 6.
", ", // 7.
" ", // 8.
". ", // 9.
false, // 10.
true, // 11.
false, // 12.
"3", // 13.
"1", // 14.
", et al.", // 15.
$encodeHTML); // 16.
if (!preg_match("/\. *$/", $author))
$record .= $author . ".";
else
$record .= $author;
}
if (!empty($row['title'])) // title
{
if (!empty($row['author']))
$record .= " ";
$record .= '"' . $row['title'];
if (!preg_match("/[?!.]$/", $row['title']))
$record .= ".";
$record .= '"';
}
$publication = preg_replace("/[ \r\n]*\(Eds?:[^\)\r\n]*\)/i", "", $row['publication']);
if (!empty($publication)) // publication
$record .= " " . $markupPatternsArray["italic-prefix"] . $publication . $markupPatternsArray["italic-suffix"];
// From here on we'll assume that at least either the 'author' or the 'title' field did contain some contents
// if this is not the case, the output string will begin with a space. However, any preceding/trailing whitespace will be removed at the cleanup stage (see below)
if (!empty($row['editor'])) // editor
{
// Call the 'reArrangeAuthorContents()' function (defined in 'include.inc.php') in order to re-order contents of the author field. Required Parameters:
// 1. input: contents of the author field
// 2. input: boolean value that specifies whether the author's family name comes first (within one author) in the source string
// ('true' means that the family name is followed by the given name (or initials), 'false' if it's the other way around)
//
// 3. input: pattern describing old delimiter that separates different authors
// 4. output: for all authors except the last author: new delimiter that separates different authors
// 5. output: for the last author: new delimiter that separates the last author from all other authors
//
// 6. input: pattern describing old delimiter that separates author name & initials (within one author)
// 7. output: for the first author: new delimiter that separates author name & initials (within one author)
// 8. output: for all authors except the first author: new delimiter that separates author name & initials (within one author)
// 9. output: new delimiter that separates multiple initials (within one author)
// 10. output: for the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db)
// 11. output: for all authors except the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db)
// 12. output: boolean value that specifies whether an author's full given name(s) shall be shortened to initial(s)
//
// 13. output: if the total number of authors is greater than the given number (integer >= 1), only the number of authors given in (14) will be included in the citation along with the string given in (15); keep empty if all authors shall be returned
// 14. output: number of authors (integer >= 1) that is included in the citation if the total number of authors is greater than the number given in (13); keep empty if not applicable
// 15. output: string that's appended to the number of authors given in (14) if the total number of authors is greater than the number given in (13); the actual number of authors can be printed by including '__NUMBER_OF_AUTHORS__' (without quotes) within the string
//
// 16. output: boolean value that specifies whether the re-ordered string shall be returned with higher ASCII chars HTML encoded
$editor = reArrangeAuthorContents($row['editor'], // 1.
true, // 2.
"/ *; */", // 3.
", ", // 4.
", and ", // 5.
"/ *, */", // 6.
" ", // 7.
" ", // 8.
". ", // 9.
true, // 10.
true, // 11.
false, // 12.
"3", // 13.
"1", // 14.
", et al.", // 15.
$encodeHTML); // 16.
if (!preg_match("@[?!.][ \"" . $markupPatternsArray["italic-suffix"] . "]*$@", $record))
$record .= ".";
if (preg_match("/^[^;\r\n]+(;[^;\r\n]+)+$/", $row['editor'])) // there are at least two editors (separated by ';')
$record .= " Eds. " . $editor;
else // there's only one editor (or the editor field is malformed with multiple editors but missing ';' separator[s])
$record .= " Ed. " . $editor;
}
if (!empty($row['edition']) && !preg_match("/^(1|1st|first|one)( ed\.?| edition)?$/i", $row['edition'])) // edition
{
if (!preg_match("@[?!.][ \"" . $markupPatternsArray["italic-suffix"] . "]*$@", $record))
$record .= ".";
if (preg_match("/^\d{1,3}$/", $row['edition'])) // if the edition field contains a number of up to three digits, we assume it's an edition number (such as "2nd ed.")
{
if ($row['edition'] == "2")
$editionSuffix = "nd";
elseif ($row['edition'] == "3")
$editionSuffix = "rd";
else
$editionSuffix = "th";
}
else
$editionSuffix = "";
if (preg_match("/^(Rev\.?|Revised)( ed\.?| edition)?$/i", $row['edition']))
$row['edition'] = "Rev.";
elseif (preg_match("/^(Abr\.?|Abridged)( ed\.?| edition)?$/i", $row['edition']))
$row['edition'] = "Abr.";
if (!preg_match("/( ed\.?| edition)$/i", $row['edition']))
$editionSuffix .= " ed.";
$record .= " " . $row['edition'] . $editionSuffix;
}
if (!empty($row['volume'])) // volume
{
if (!preg_match("@[?!.][ \"" . $markupPatternsArray["italic-suffix"] . "]*$@", $record))
$record .= ".";
$record .= " Vol. " . $row['volume'];
}
if (!empty($row['abbrev_series_title']) OR !empty($row['series_title'])) // if there's either a full or an abbreviated series title
{
if (!preg_match("@[?!.][ \"" . $markupPatternsArray["italic-suffix"] . "]*$@", $record))
$record .= ".";
$record .= " ";
if (!empty($row['abbrev_series_title']))
$record .= $row['abbrev_series_title']; // abbreviated series title
// if there's no abbreviated series title, we'll use the full series title instead:
elseif (!empty($row['series_title']))
$record .= $row['series_title']; // full series title
if (!empty($row['series_volume'])||!empty($row['series_issue']))
$record .= ", ";
if (!empty($row['series_volume'])) // series volume
$record .= $row['series_volume'];
if (!empty($row['series_issue'])) // series issue (I'm not really sure if -- for this cite style -- the series issue should be rather omitted here)
$record .= "." . $row['series_issue']; // is it correct to format series issues similar to journal article issues?
}
if (!preg_match("@[?!.][ \"" . $markupPatternsArray["italic-suffix"] . "]*$@", $record))
$record .= ".";
if (!empty($row['place'])) // place
$record .= " " . $row['place'];
if (!empty($row['publisher'])) // publisher
{
if (!empty($row['place']))
$record .= ":";
$record .= " " . $row['publisher'];
}
if (!empty($row['year'])) // year
{
$record .= ", " . $row['year'];
}
if (!empty($row['pages'])) // pages
$record .= ". " . formatPageInfo($row['pages'], $markupPatternsArray["endash"]); // function 'formatPageInfo()' is defined in 'cite.inc.php'
if (!preg_match("/\. *$/", $record))
$record .= ".";
}
// --- BEGIN TYPE = BOOK WHOLE / CONFERENCE VOLUME / JOURNAL / MANUAL / MANUSCRIPT / MAP / MISCELLANEOUS / PATENT / REPORT / SOFTWARE ---
else // if (preg_match("/Book Whole|Conference Volume|Journal|Manual|Manuscript|Map|Miscellaneous|Patent|Report|Software/", $row['type']))
// note that this also serves as a fallback: unrecognized resource types will be formatted similar to whole books
{
if (!empty($row['author'])) // author
{
$author = preg_replace("/[ \r\n]*\(eds?\)/i", "", $row['author']);
// Call the 'reArrangeAuthorContents()' function (defined in 'include.inc.php') in order to re-order contents of the author field. Required Parameters:
// 1. input: contents of the author field
// 2. input: boolean value that specifies whether the author's family name comes first (within one author) in the source string
// ('true' means that the family name is followed by the given name (or initials), 'false' if it's the other way around)
//
// 3. input: pattern describing old delimiter that separates different authors
// 4. output: for all authors except the last author: new delimiter that separates different authors
// 5. output: for the last author: new delimiter that separates the last author from all other authors
//
// 6. input: pattern describing old delimiter that separates author name & initials (within one author)
// 7. output: for the first author: new delimiter that separates author name & initials (within one author)
// 8. output: for all authors except the first author: new delimiter that separates author name & initials (within one author)
// 9. output: new delimiter that separates multiple initials (within one author)
// 10. output: for the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db)
// 11. output: for all authors except the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db)
// 12. output: boolean value that specifies whether an author's full given name(s) shall be shortened to initial(s)
//
// 13. output: if the total number of authors is greater than the given number (integer >= 1), only the number of authors given in (14) will be included in the citation along with the string given in (15); keep empty if all authors shall be returned
// 14. output: number of authors (integer >= 1) that is included in the citation if the total number of authors is greater than the number given in (13); keep empty if not applicable
// 15. output: string that's appended to the number of authors given in (14) if the total number of authors is greater than the number given in (13); the actual number of authors can be printed by including '__NUMBER_OF_AUTHORS__' (without quotes) within the string
//
// 16. output: boolean value that specifies whether the re-ordered string shall be returned with higher ASCII chars HTML encoded
$author = reArrangeAuthorContents($author, // 1.
true, // 2.
"/ *; */", // 3.
", ", // 4.
", and ", // 5.
"/ *, */", // 6.
", ", // 7.
" ", // 8.
". ", // 9.
false, // 10.
true, // 11.
false, // 12.
"3", // 13.
"1", // 14.
", et al.", // 15.
$encodeHTML); // 16.
// if the author is actually the editor of the resource we'll append ', ed' (or ', eds') to the author string:
// [to distinguish editors from authors in the 'author' field, the 'modify.php' script does append ' (ed)' or ' (eds)' if appropriate,
// so we're just checking for these identifier strings here. Alternatively, we could check whether the editor field matches the author field]
if (preg_match("/[ \r\n]*\(ed\)/", $row['author'])) // single editor
$author = $author . ", " . "ed";
elseif (preg_match("/[ \r\n]*\(eds\)/", $row['author'])) // multiple editors
$author = $author . ", " . "eds";
if (!preg_match("/\. *$/", $author))
$record .= $author . ".";
else
$record .= $author;
}
if (!empty($row['title'])) // title
{
if (!empty($row['author']))
$record .= " ";
if (!empty($row['thesis'])) // thesis
{
$record .= '"' . $row['title'];
if (!preg_match("/[?!.]$/", $row['title']))
$record .= ".";
$record .= '"';
}
else // not a thesis
$record .= $markupPatternsArray["italic-prefix"] . $row['title'] . $markupPatternsArray["italic-suffix"];
}
if (!empty($row['editor']) && !preg_match("/[ \r\n]*\(eds?\)/", $row['author'])) // editor (if different from author, see note above regarding the check for ' (ed)' or ' (eds)')
{
// Call the 'reArrangeAuthorContents()' function (defined in 'include.inc.php') in order to re-order contents of the author field. Required Parameters:
// 1. input: contents of the author field
// 2. input: boolean value that specifies whether the author's family name comes first (within one author) in the source string
// ('true' means that the family name is followed by the given name (or initials), 'false' if it's the other way around)
//
// 3. input: pattern describing old delimiter that separates different authors
// 4. output: for all authors except the last author: new delimiter that separates different authors
// 5. output: for the last author: new delimiter that separates the last author from all other authors
//
// 6. input: pattern describing old delimiter that separates author name & initials (within one author)
// 7. output: for the first author: new delimiter that separates author name & initials (within one author)
// 8. output: for all authors except the first author: new delimiter that separates author name & initials (within one author)
// 9. output: new delimiter that separates multiple initials (within one author)
// 10. output: for the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db)
// 11. output: for all authors except the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db)
// 12. output: boolean value that specifies whether an author's full given name(s) shall be shortened to initial(s)
//
// 13. output: if the total number of authors is greater than the given number (integer >= 1), only the number of authors given in (14) will be included in the citation along with the string given in (15); keep empty if all authors shall be returned
// 14. output: number of authors (integer >= 1) that is included in the citation if the total number of authors is greater than the number given in (13); keep empty if not applicable
// 15. output: string that's appended to the number of authors given in (14) if the total number of authors is greater than the number given in (13); the actual number of authors can be printed by including '__NUMBER_OF_AUTHORS__' (without quotes) within the string
//
// 16. output: boolean value that specifies whether the re-ordered string shall be returned with higher ASCII chars HTML encoded
$editor = reArrangeAuthorContents($row['editor'], // 1.
true, // 2.
"/ *; */", // 3.
", ", // 4.
", and ", // 5.
"/ *, */", // 6.
" ", // 7.
" ", // 8.
". ", // 9.
true, // 10.
true, // 11.
false, // 12.
"3", // 13.
"1", // 14.
", et al.", // 15.
$encodeHTML); // 16.
if (!preg_match("@[?!.][ \"" . $markupPatternsArray["italic-suffix"] . "]*$@", $record))
$record .= ".";
if (preg_match("/^[^;\r\n]+(;[^;\r\n]+)+$/", $row['editor'])) // there are at least two editors (separated by ';')
$record .= " Eds. " . $editor;
else // there's only one editor (or the editor field is malformed with multiple editors but missing ';' separator[s])
$record .= " Ed. " . $editor;
}
if (!empty($row['edition']) && !preg_match("/^(1|1st|first|one)( ed\.?| edition)?$/i", $row['edition'])) // edition
{
if (!preg_match("@[?!.][ \"" . $markupPatternsArray["italic-suffix"] . "]*$@", $record))
$record .= ".";
if (preg_match("/^\d{1,3}$/", $row['edition'])) // if the edition field contains a number of up to three digits, we assume it's an edition number (such as "2nd ed.")
{
if ($row['edition'] == "2")
$editionSuffix = "nd";
elseif ($row['edition'] == "3")
$editionSuffix = "rd";
else
$editionSuffix = "th";
}
else
$editionSuffix = "";
if (preg_match("/^(Rev\.?|Revised)( ed\.?| edition)?$/i", $row['edition']))
$row['edition'] = "Rev.";
elseif (preg_match("/^(Abr\.?|Abridged)( ed\.?| edition)?$/i", $row['edition']))
$row['edition'] = "Abr.";
if (!preg_match("/( ed\.?| edition)$/i", $row['edition']))
$editionSuffix .= " ed.";
$record .= " " . $row['edition'] . $editionSuffix;
}
if (!empty($row['volume'])) // volume
{
if (!preg_match("@[?!.][ \"" . $markupPatternsArray["italic-suffix"] . "]*$@", $record))
$record .= ".";
$record .= " Vol. " . $row['volume'];
}
if (!empty($row['abbrev_series_title']) OR !empty($row['series_title'])) // if there's either a full or an abbreviated series title
{
if (!preg_match("@[?!.][ \"" . $markupPatternsArray["italic-suffix"] . "]*$@", $record))
$record .= ".";
$record .= " ";
if (!empty($row['abbrev_series_title']))
$record .= $row['abbrev_series_title']; // abbreviated series title
// if there's no abbreviated series title, we'll use the full series title instead:
elseif (!empty($row['series_title']))
$record .= $row['series_title']; // full series title
if (!empty($row['series_volume'])||!empty($row['series_issue']))
$record .= ", ";
if (!empty($row['series_volume'])) // series volume
$record .= $row['series_volume'];
if (!empty($row['series_issue'])) // series issue (I'm not really sure if -- for this cite style -- the series issue should be rather omitted here)
$record .= "." . $row['series_issue']; // is it correct to format series issues similar to journal article issues?
}
if (!empty($row['thesis'])) // thesis (unpublished dissertation)
{
// TODO: a published dissertation needs to be formatted differently!
// see e.g. example at: <http://web.csustan.edu/english/reuben/pal/append/AXI.HTML>
if (!preg_match("@[?!.][ \"" . $markupPatternsArray["italic-suffix"] . "]*$@", $record))
$record .= ".";
// TODO: I've also seen MLA examples that separate thesis name, name of institution and year by dots. ?:-|
// Also, do we need to use the abbreviation "Diss." instead of "Ph.D. thesis"? What about other thesis types then?
// see e.g. <http://www.english.uiuc.edu/cws/wworkshop/writer_resources/citation_styles/mla/unpublished_diss.htm>
$record .= " " . $row['thesis'];
$record .= ", " . $row['publisher'];
}
else // not a thesis
{
if (!preg_match("@[?!.][ \"" . $markupPatternsArray["italic-suffix"] . "]*$@", $record))
$record .= ".";
if (!empty($row['place'])) // place
$record .= " " . $row['place'];
if (!empty($row['publisher'])) // publisher
{
if (!empty($row['place']))
$record .= ":";
$record .= " " . $row['publisher'];
}
}
if (!empty($row['year'])) // year
$record .= ", ".$row['year'];
if ($row['online_publication'] == "yes") // this record refers to an online article
{
$today = date("j M. Y");
if (!empty($row['online_citation'])) // online_citation
{
if (!preg_match("/\. *$/", $record))
$record .= ".";
$record .= " " . $row['online_citation'];
}
if (!empty($row['doi'])) // doi
{
if (!preg_match("/\. *$/", $record))
$record .= ".";
if ($encodeHTML)
$record .= " " . $today . encodeHTML(" <http://dx.doi.org/" . $row['doi'] . ">");
else
$record .= " " . $today . " <http://dx.doi.org/" . $row['doi'] . ">";
}
elseif (!empty($row['url'])) // url
{
if (!preg_match("/\. *$/", $record))
$record .= ".";
if ($encodeHTML)
$record .= " " . $today . encodeHTML(" <" . $row['url'] . ">");
else
$record .= " " . $today . " <" . $row['url'] . ">";
}
}
if (!preg_match("/\. *$/", $record))
$record .= ".";
}
// --- BEGIN POST-PROCESSING -----------------------------------------------------------------------------------------------------------
// do some further cleanup:
$record = trim($record); // remove any preceding or trailing whitespace
return $record;
}
// --- END CITATION STYLE ---
?>

View File

@@ -0,0 +1,442 @@
<?php
// Project: Web Reference Database (refbase) <http://www.refbase.net>
// Copyright: Matthias Steffens <mailto:refbase@extracts.de> and the file's
// original author(s).
//
// This code is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY. Please see the GNU General Public
// License for more details.
//
// File: ./cite/styles/cite_PolarBiol_MarBiol_MEPS.php
// Repository: $HeadURL: file:///svn/p/refbase/code/branches/bleeding-edge/cite/styles/cite_PolarBiol_MarBiol_MEPS.php $
// Author(s): Matthias Steffens <mailto:refbase@extracts.de>
//
// Created: 28-Sep-04, 22:14
// Modified: $Date: 2012-02-27 20:25:30 +0000 (Mon, 27 Feb 2012) $
// $Author: msteffens $
// $Revision: 1337 $
// This is a citation style file (which must reside within the 'cite/styles/' sub-directory of your refbase root directory). It contains a
// version of the 'citeRecord()' function that outputs a reference list from selected records according to the citation style used by
// the journals "Polar Biology", "Marine Biology" (both Springer-Verlag, springeronline.com) and "MEPS" (Inter-Research, int-res.com).
// --------------------------------------------------------------------
// --- BEGIN CITATION STYLE ---
function citeRecord($row, $citeStyle, $citeType, $markupPatternsArray, $encodeHTML)
{
global $alnum, $alpha, $cntrl, $dash, $digit, $graph, $lower, $print, $punct, $space, $upper, $word, $patternModifiers; // defined in 'transtab_unicode_charset.inc.php' and 'transtab_latin1_charset.inc.php'
$record = ""; // make sure that our buffer variable is empty
// --- BEGIN TYPE = JOURNAL ARTICLE / MAGAZINE ARTICLE / NEWSPAPER ARTICLE --------------------------------------------------------------
if (preg_match("/^(Journal Article|Magazine Article|Newspaper Article)$/", $row['type']))
{
if (!empty($row['author'])) // author
{
// Call the 'reArrangeAuthorContents()' function (defined in 'include.inc.php') in order to re-order contents of the author field. Required Parameters:
// 1. input: contents of the author field
// 2. input: boolean value that specifies whether the author's family name comes first (within one author) in the source string
// ('true' means that the family name is followed by the given name (or initials), 'false' if it's the other way around)
//
// 3. input: pattern describing old delimiter that separates different authors
// 4. output: for all authors except the last author: new delimiter that separates different authors
// 5. output: for the last author: new delimiter that separates the last author from all other authors
//
// 6. input: pattern describing old delimiter that separates author name & initials (within one author)
// 7. output: for the first author: new delimiter that separates author name & initials (within one author)
// 8. output: for all authors except the first author: new delimiter that separates author name & initials (within one author)
// 9. output: new delimiter that separates multiple initials (within one author)
// 10. output: for the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db)
// 11. output: for all authors except the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db)
// 12. output: boolean value that specifies whether an author's full given name(s) shall be shortened to initial(s)
//
// 13. output: if the total number of authors is greater than the given number (integer >= 1), only the number of authors given in (14) will be included in the citation along with the string given in (15); keep empty if all authors shall be returned
// 14. output: number of authors (integer >= 1) that is included in the citation if the total number of authors is greater than the number given in (13); keep empty if not applicable
// 15. output: string that's appended to the number of authors given in (14) if the total number of authors is greater than the number given in (13); the actual number of authors can be printed by including '__NUMBER_OF_AUTHORS__' (without quotes) within the string
//
// 16. output: boolean value that specifies whether the re-ordered string shall be returned with higher ASCII chars HTML encoded
$author = reArrangeAuthorContents($row['author'], // 1.
true, // 2.
"/ *; */", // 3.
", ", // 4.
", ", // 5.
"/ *, */", // 6.
" ", // 7.
" ", // 8.
"", // 9.
false, // 10.
false, // 11.
true, // 12.
"", // 13.
"", // 14.
" " . $markupPatternsArray["italic-prefix"] . "and __NUMBER_OF_AUTHORS__ others" . $markupPatternsArray["italic-suffix"], // 15.
$encodeHTML); // 16.
$record .= $author . " ";
}
if (!empty($row['year'])) // year
$record .= "(" . $row['year'] . ") ";
if (!empty($row['title'])) // title
{
$record .= $row['title'];
if (!preg_match("/[?!.]$/", $row['title']))
$record .= ".";
$record .= " ";
}
if (!empty($row['abbrev_journal'])) // abbreviated journal name
$record .= $row['abbrev_journal'] . " ";
// if there's no abbreviated journal name, we'll use the full journal name
elseif (!empty($row['publication'])) // publication (= journal) name
$record .= $row['publication'] . " ";
if (!empty($row['volume'])) // volume
$record .= $row['volume'];
if (!empty($row['issue'])) // issue
$record .= "(" . $row['issue'] . ")";
if ($row['online_publication'] == "yes") // this record refers to an online article
{
// instead of any pages info (which normally doesn't exist for online publications) we append
// an optional string (given in 'online_citation') plus the DOI:
if (!empty($row['online_citation'])) // online_citation
{
if (!empty($row['volume'])||!empty($row['issue'])) // only add ":" if either volume or issue isn't empty
$record .= ":";
$record .= " " . $row['online_citation'];
}
if (!empty($row['doi'])) // doi
$record .= " doi:" . $row['doi'];
}
else // $row['online_publication'] == "no" -> this record refers to a printed article, so we append any pages info instead:
{
if (!empty($row['pages'])) // pages
{
if (!empty($row['volume'])||!empty($row['issue'])) // only add ":" if either volume or issue isn't empty
$record .= ":";
$record .= formatPageInfo($row['pages'], $markupPatternsArray["endash"], "", "", " pp"); // function 'formatPageInfo()' is defined in 'cite.inc.php'
}
}
}
// --- BEGIN TYPE = ABSTRACT / BOOK CHAPTER / CONFERENCE ARTICLE ------------------------------------------------------------------------
elseif (preg_match("/^(Abstract|Book Chapter|Conference Article)$/", $row['type']))
{
if (!empty($row['author'])) // author
{
// Call the 'reArrangeAuthorContents()' function (defined in 'include.inc.php') in order to re-order contents of the author field. Required Parameters:
// 1. input: contents of the author field
// 2. input: boolean value that specifies whether the author's family name comes first (within one author) in the source string
// ('true' means that the family name is followed by the given name (or initials), 'false' if it's the other way around)
//
// 3. input: pattern describing old delimiter that separates different authors
// 4. output: for all authors except the last author: new delimiter that separates different authors
// 5. output: for the last author: new delimiter that separates the last author from all other authors
//
// 6. input: pattern describing old delimiter that separates author name & initials (within one author)
// 7. output: for the first author: new delimiter that separates author name & initials (within one author)
// 8. output: for all authors except the first author: new delimiter that separates author name & initials (within one author)
// 9. output: new delimiter that separates multiple initials (within one author)
// 10. output: for the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db)
// 11. output: for all authors except the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db)
// 12. output: boolean value that specifies whether an author's full given name(s) shall be shortened to initial(s)
//
// 13. output: if the total number of authors is greater than the given number (integer >= 1), only the number of authors given in (14) will be included in the citation along with the string given in (15); keep empty if all authors shall be returned
// 14. output: number of authors (integer >= 1) that is included in the citation if the total number of authors is greater than the number given in (13); keep empty if not applicable
// 15. output: string that's appended to the number of authors given in (14) if the total number of authors is greater than the number given in (13); the actual number of authors can be printed by including '__NUMBER_OF_AUTHORS__' (without quotes) within the string
//
// 16. output: boolean value that specifies whether the re-ordered string shall be returned with higher ASCII chars HTML encoded
$author = reArrangeAuthorContents($row['author'], // 1.
true, // 2.
"/ *; */", // 3.
", ", // 4.
", ", // 5.
"/ *, */", // 6.
" ", // 7.
" ", // 8.
"", // 9.
false, // 10.
false, // 11.
true, // 12.
"", // 13.
"", // 14.
" " . $markupPatternsArray["italic-prefix"] . "and __NUMBER_OF_AUTHORS__ others" . $markupPatternsArray["italic-suffix"], // 15.
$encodeHTML); // 16.
$record .= $author . " ";
}
if (!empty($row['year'])) // year
$record .= "(" . $row['year'] . ") ";
if (!empty($row['title'])) // title
{
$record .= $row['title'];
if (!preg_match("/[?!.]$/", $row['title']))
$record .= ".";
$record .= " ";
}
if (!empty($row['editor'])) // editor
{
// Call the 'reArrangeAuthorContents()' function (defined in 'include.inc.php') in order to re-order contents of the author field. Required Parameters:
// 1. input: contents of the author field
// 2. input: boolean value that specifies whether the author's family name comes first (within one author) in the source string
// ('true' means that the family name is followed by the given name (or initials), 'false' if it's the other way around)
//
// 3. input: pattern describing old delimiter that separates different authors
// 4. output: for all authors except the last author: new delimiter that separates different authors
// 5. output: for the last author: new delimiter that separates the last author from all other authors
//
// 6. input: pattern describing old delimiter that separates author name & initials (within one author)
// 7. output: for the first author: new delimiter that separates author name & initials (within one author)
// 8. output: for all authors except the first author: new delimiter that separates author name & initials (within one author)
// 9. output: new delimiter that separates multiple initials (within one author)
// 10. output: for the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db)
// 11. output: for all authors except the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db)
// 12. output: boolean value that specifies whether an author's full given name(s) shall be shortened to initial(s)
//
// 13. output: if the total number of authors is greater than the given number (integer >= 1), only the number of authors given in (14) will be included in the citation along with the string given in (15); keep empty if all authors shall be returned
// 14. output: number of authors (integer >= 1) that is included in the citation if the total number of authors is greater than the number given in (13); keep empty if not applicable
// 15. output: string that's appended to the number of authors given in (14) if the total number of authors is greater than the number given in (13); the actual number of authors can be printed by including '__NUMBER_OF_AUTHORS__' (without quotes) within the string
//
// 16. output: boolean value that specifies whether the re-ordered string shall be returned with higher ASCII chars HTML encoded
$editor = reArrangeAuthorContents($row['editor'], // 1.
true, // 2.
"/ *; */", // 3.
", ", // 4.
", ", // 5.
"/ *, */", // 6.
" ", // 7.
" ", // 8.
"", // 9.
false, // 10.
false, // 11.
true, // 12.
"", // 13.
"", // 14.
" " . $markupPatternsArray["italic-prefix"] . "and __NUMBER_OF_AUTHORS__ others" . $markupPatternsArray["italic-suffix"], // 15.
$encodeHTML); // 16.
$record .= "In: " . $editor;
if (preg_match("/^[^;\r\n]+(;[^;\r\n]+)+$/", $row['editor'])) // there are at least two editors (separated by ';')
$record .= " (eds)";
else // there's only one editor (or the editor field is malformed with multiple editors but missing ';' separator[s])
$record .= " (ed)";
}
$publication = preg_replace("/[ \r\n]*\(Eds?:[^\)\r\n]*\)/i", "", $row['publication']);
if (!empty($publication)) // publication
$record .= " " . $publication . ". ";
else
if (!empty($row['editor']))
$record .= ". ";
if (!empty($row['abbrev_series_title']) OR !empty($row['series_title'])) // if there's either a full or an abbreviated series title, series information will replace the publisher & place information
{
if (!empty($row['abbrev_series_title']))
$record .= $row['abbrev_series_title']; // abbreviated series title
// if there's no abbreviated series title, we'll use the full series title instead:
elseif (!empty($row['series_title']))
$record .= $row['series_title']; // full series title
if (!empty($row['series_volume'])||!empty($row['series_issue']))
$record .= " ";
if (!empty($row['series_volume'])) // series volume
$record .= $row['series_volume'];
if (!empty($row['series_issue'])) // series issue
$record .= "(" . $row['series_issue'] . ")";
if (!empty($row['pages']))
$record .= ", ";
}
else // if there's NO series title at all (neither full nor abbreviated), we'll insert the publisher & place instead:
{
if (!empty($row['publisher'])) // publisher
{
$record .= $row['publisher'];
if (!empty($row['place']))
$record .= ", ";
else
{
if (!preg_match("/,$/", $row['publisher']))
$record .= ",";
$record .= " ";
}
}
if (!empty($row['place'])) // place
{
$record .= $row['place'];
if (!empty($row['pages']))
{
if (!preg_match("/,$/", $row['place']))
$record .= ",";
$record .= " ";
}
}
}
if (!empty($row['pages'])) // pages
$record .= formatPageInfo($row['pages'], $markupPatternsArray["endash"], "p ", "pp ", " pp"); // function 'formatPageInfo()' is defined in 'cite.inc.php'
}
// --- BEGIN TYPE = BOOK WHOLE / CONFERENCE VOLUME / JOURNAL / MANUAL / MANUSCRIPT / MAP / MISCELLANEOUS / PATENT / REPORT / SOFTWARE ---
else // if (preg_match("/Book Whole|Conference Volume|Journal|Manual|Manuscript|Map|Miscellaneous|Patent|Report|Software/", $row['type']))
// note that this also serves as a fallback: unrecognized resource types will be formatted similar to whole books
{
if (!empty($row['author'])) // author
{
$author = preg_replace("/[ \r\n]*\(eds?\)/i", "", $row['author']);
// Call the 'reArrangeAuthorContents()' function (defined in 'include.inc.php') in order to re-order contents of the author field. Required Parameters:
// 1. input: contents of the author field
// 2. input: boolean value that specifies whether the author's family name comes first (within one author) in the source string
// ('true' means that the family name is followed by the given name (or initials), 'false' if it's the other way around)
//
// 3. input: pattern describing old delimiter that separates different authors
// 4. output: for all authors except the last author: new delimiter that separates different authors
// 5. output: for the last author: new delimiter that separates the last author from all other authors
//
// 6. input: pattern describing old delimiter that separates author name & initials (within one author)
// 7. output: for the first author: new delimiter that separates author name & initials (within one author)
// 8. output: for all authors except the first author: new delimiter that separates author name & initials (within one author)
// 9. output: new delimiter that separates multiple initials (within one author)
// 10. output: for the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db)
// 11. output: for all authors except the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db)
// 12. output: boolean value that specifies whether an author's full given name(s) shall be shortened to initial(s)
//
// 13. output: if the total number of authors is greater than the given number (integer >= 1), only the number of authors given in (14) will be included in the citation along with the string given in (15); keep empty if all authors shall be returned
// 14. output: number of authors (integer >= 1) that is included in the citation if the total number of authors is greater than the number given in (13); keep empty if not applicable
// 15. output: string that's appended to the number of authors given in (14) if the total number of authors is greater than the number given in (13); the actual number of authors can be printed by including '__NUMBER_OF_AUTHORS__' (without quotes) within the string
//
// 16. output: boolean value that specifies whether the re-ordered string shall be returned with higher ASCII chars HTML encoded
$author = reArrangeAuthorContents($author, // 1.
true, // 2.
"/ *; */", // 3.
", ", // 4.
", ", // 5.
"/ *, */", // 6.
" ", // 7.
" ", // 8.
"", // 9.
false, // 10.
false, // 11.
true, // 12.
"", // 13.
"", // 14.
" " . $markupPatternsArray["italic-prefix"] . "and __NUMBER_OF_AUTHORS__ others" . $markupPatternsArray["italic-suffix"], // 15.
$encodeHTML); // 16.
$record .= $author . " ";
}
if (!empty($row['year'])) // year
$record .= "(" . $row['year'] . ") ";
if (!empty($row['title'])) // title
{
$record .= $row['title'];
if (!preg_match("/[?!.]$/", $row['title']))
$record .= ".";
$record .= " ";
}
if (!empty($row['thesis'])) // thesis
$record .= $row['thesis'] . ". ";
if (!empty($row['publisher'])) // publisher
{
$record .= $row['publisher'];
if (!empty($row['place']))
$record .= ", ";
else
{
if (!preg_match("/,$/", $row['publisher']))
$record .= ",";
$record .= " ";
}
}
if (!empty($row['place'])) // place
{
$record .= $row['place'];
if (!empty($row['abbrev_series_title']) || !empty($row['series_title']) || !empty($row['pages']))
{
if (!preg_match("/,$/", $row['place']))
$record .= ",";
$record .= " ";
}
}
if (!empty($row['abbrev_series_title']) OR !empty($row['series_title'])) // add either abbreviated or full series title
{
if (!empty($row['abbrev_series_title']))
$record .= $row['abbrev_series_title']; // abbreviated series title
// if there's no abbreviated series title, we'll use the full series title instead:
elseif (!empty($row['series_title']))
$record .= $row['series_title']; // full series title
// series volume & series issue will get appended only if there's also either the full or an abbreviated series title(!):
if (!empty($row['series_volume'])||!empty($row['series_issue']))
$record .= " ";
if (!empty($row['series_volume'])) // series volume
$record .= $row['series_volume'];
if (!empty($row['series_issue'])) // series issue
$record .= "(" . $row['series_issue'] . ")";
if (!empty($row['pages']))
{
if (!preg_match("/,$/", $row['series_volume']))
$record .= ",";
$record .= " ";
}
}
if (!empty($row['pages'])) // pages
{
// TODO: use function 'formatPageInfo()' when it can recognize & process total number of pages
// $record .= formatPageInfo($row['pages'], $markupPatternsArray["endash"], "p ", "pp ", " pp"); // function 'formatPageInfo()' is defined in 'cite.inc.php'
if (preg_match("/\d *[$dash] *\d/$patternModifiers", $row['pages'])) // if the 'pages' field contains a page range (like: "127-132")
// Note that we'll check for page ranges here although for whole books the 'pages' field should NOT contain a page range but the total number of pages! (like: "623 pp")
$pagesDisplay = (preg_replace("@(\d+) *[$dash] *(\d+)@$patternModifiers", "\\1" . $markupPatternsArray["endash"] . "\\2", $row['pages']));
else
$pagesDisplay = $row['pages'];
$record .= $pagesDisplay;
}
}
// --- BEGIN POST-PROCESSING -----------------------------------------------------------------------------------------------------------
// do some further cleanup:
$record = preg_replace("/[.,][ \r\n]*$/i", "", $record); // remove '.' or ',' at end of line
if ($citeStyle == "MEPS") // if '$citeStyle' = 'MEPS' ...
$record = preg_replace("/pp ([0-9]+)/i", "p \\1", $record); // ... replace 'pp' with 'p' in front of (book chapter) page numbers
return $record;
}
// --- END CITATION STYLE ---
?>

View File

@@ -0,0 +1,69 @@
<?php
// Project: Web Reference Database (refbase) <http://www.refbase.net>
// Copyright: Matthias Steffens <mailto:refbase@extracts.de> and the file's
// original author(s).
//
// This code is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY. Please see the GNU General Public
// License for more details.
//
// File: ./cite/styles/cite_TextCitation.php
// Repository: $HeadURL: file:///svn/p/refbase/code/branches/bleeding-edge/cite/styles/cite_TextCitation.php $
// Author(s): Matthias Steffens <mailto:refbase@extracts.de>
//
// Created: 28-Sep-04, 23:46
// Modified: $Date: 2012-02-27 20:25:30 +0000 (Mon, 27 Feb 2012) $
// $Author: msteffens $
// $Revision: 1337 $
// This is a citation style file (which must reside within the 'cite/styles/' sub-directory of your refbase root directory). It contains a
// version of the 'citeRecord()' function that outputs a reference list from selected records according to the citation style defined
// by a user's custom text citation format (or by the default format given in '$defaultTextCitationFormat' in 'ini.inc.php').
// --------------------------------------------------------------------
// --- BEGIN CITATION STYLE ---
function citeRecord($row, $citeStyle, $citeType, $markupPatternsArray, $encodeHTML)
{
global $defaultTextCitationFormat; // defined in 'ini.inc.php'
global $userOptionsArray; // '$userOptionsArray' is made globally available by function 'generateCitations()' in 'search.php'
// output records suitable for citation within a text, e.g., like: "Ambrose 1991 {3735}", "Ambrose & Renaud 1995 {3243}" or "Ambrose et al. 2001 {4774}"
if (!empty($userOptionsArray) AND ($userOptionsArray['use_custom_text_citation_format'] == "yes")) // if the user wants to use a custom text citation format
$textCitationFormat = $userOptionsArray['text_citation_format'];
else // use the default text citation format that was specified by the admin in 'ini.inc.php'
$textCitationFormat = $defaultTextCitationFormat;
// this is a stupid hack that maps the names of the '$row' array keys to those used
// by the '$formVars' array (which is required by function 'parsePlaceholderString()')
// (eventually, the '$formVars' array should use the MySQL field names as names for its array keys)
$formVars = buildFormVarsArray($row); // function 'buildFormVarsArray()' is defined in 'include.inc.php'
if (preg_match("/RTF|LaTeX/i", $citeType))
{
$textCitationFormat = preg_replace("/([{}])/i", "\\\\1", $textCitationFormat); // in case of RTF or LaTeX output we need to escape braces in placeholder strings
$fallbackPlaceholderString = "<:authors[2| & | et al.]:>< :year:>< \{:recordIdentifier:\}>";
}
else
$fallbackPlaceholderString = "<:authors[2| & | et al.]:>< :year:>< {:recordIdentifier:}>";
// generate a text citation according to the given naming scheme:
$record = parsePlaceholderString($formVars, $textCitationFormat, $fallbackPlaceholderString); // function 'parsePlaceholderString()' is defined in 'include.inc.php'
// Perform search & replace actions on the text:
$searchReplaceActionsArray["(et +al\.)"] = $markupPatternsArray["italic-prefix"] . "\\1" . $markupPatternsArray["italic-suffix"]; // print 'et al.' in italic
$record = searchReplaceText($searchReplaceActionsArray, $record, false); // function 'searchReplaceText()' is defined in 'include.inc.php'
return $record;
}
// --- END CITATION STYLE ---
?>

View File

@@ -0,0 +1,714 @@
<?php
// Project: Web Reference Database (refbase) <http://www.refbase.net>
// Copyright: Matthias Steffens <mailto:refbase@extracts.de> and the file's
// original author(s).
//
// This code is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY. Please see the GNU General Public
// License for more details.
//
// File: ./cite/styles/cite_Vancouver.php
// Repository: $HeadURL$
// Author(s): Matthias Steffens <mailto:refbase@extracts.de>
//
// Created: 04-Aug-08, 12:00
// Modified: $Date: 2012-02-27 20:25:30 +0000 (Mon, 27 Feb 2012) $
// $Author$
// $Revision: 1337 $
// This is a citation style file (which must reside within the 'cite/styles/' sub-directory of your refbase root directory). It contains a
// version of the 'citeRecord()' function that outputs a reference list from selected records according to the citation style used by
// the Vancouver referencing system (also known as "Uniform Requirements for Manuscripts Submitted to Biomedical Journals")
// This Vancouver style was modeled after these resources:
// <http://www.library.uq.edu.au/training/citation/vancouv.pdf>
// <http://library.curtin.edu.au/research_and_information_skills/referencing/vancouver.pdf>
// <http://www.icmje.org/index.html> citing: <http://www.nlm.nih.gov/citingmedicine/>
// <http://www.nlm.nih.gov/bsd/uniform_requirements.html>
// <http://library.sun.ac.za//eng/help/infolit2002/bibvancouver.htm>
// based on 'cite_AMA.php'
// NOTES: - In the Vancouver style, the reference list is arranged numerically in the order in which references are cited in the text.
// This isn't currently handled by this style (it needs to be implemented in the 'cite/formats/cite_*.php' files).
// - For conference proceedings, you'll currently need to add the place & date of the conference in the proceedings title field
// (e.g. "Proceedings of the 5th Germ Cell Tumour Conference; 2001 Sep 13-15; Leeds, UK").
// TODO: - abstracts, newspaper/magazine articles, patents & reports?
// - arrange references numerically
// - for newspaper articles, only the beginning page number of an article should be included (see: <http://www.ncbi.nlm.nih.gov/books/bv.fcgi?rid=citmed.section.41496#41607>)
// - where to put (and how to format) editors of whole books that also have an author?
// - see also inline comments labeled with TODO (and NOTE)
// --------------------------------------------------------------------
// --- BEGIN CITATION STYLE ---
function citeRecord($row, $citeStyle, $citeType, $markupPatternsArray, $encodeHTML)
{
global $alnum, $alpha, $cntrl, $dash, $digit, $graph, $lower, $print, $punct, $space, $upper, $word, $patternModifiers; // defined in 'transtab_unicode_charset.inc.php' and 'transtab_latin1_charset.inc.php'
static $uspsStateAbbreviations;
// Official USPS state abbreviations:
// see <http://www.usps.com/ncsc/lookups/usps_abbreviations.htm>
$uspsStateAbbreviations = "AL|AK|AS|AZ|AR|CA|CO|CT|DE|DC|FM|FL|GA|GU|HI|ID|IL|IN|IA|KS|KY|LA|ME|MH|MD|MA|MI|MN|MS|MO|MT|"
. "NE|NV|NH|NJ|NM|NY|NC|ND|MP|OH|OK|OR|PW|PA|PR|RI|SC|SD|TN|TX|UT|VT|VI|VA|WA|WV|WI|WY";
$record = ""; // make sure that our buffer variable is empty
// --- BEGIN TYPE = JOURNAL ARTICLE / MAGAZINE ARTICLE / NEWSPAPER ARTICLE --------------------------------------------------------------
if (preg_match("/^(Journal Article|Magazine Article|Newspaper Article)$/", $row['type']))
{
if (!empty($row['author'])) // author
{
// Call the 'reArrangeAuthorContents()' function (defined in 'include.inc.php') in order to re-order contents of the author field. Required Parameters:
// 1. input: contents of the author field
// 2. input: boolean value that specifies whether the author's family name comes first (within one author) in the source string
// ('true' means that the family name is followed by the given name (or initials), 'false' if it's the other way around)
//
// 3. input: pattern describing old delimiter that separates different authors
// 4. output: for all authors except the last author: new delimiter that separates different authors
// 5. output: for the last author: new delimiter that separates the last author from all other authors
//
// 6. input: pattern describing old delimiter that separates author name & initials (within one author)
// 7. output: for the first author: new delimiter that separates author name & initials (within one author)
// 8. output: for all authors except the first author: new delimiter that separates author name & initials (within one author)
// 9. output: new delimiter that separates multiple initials (within one author)
// 10. output: for the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db)
// 11. output: for all authors except the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db)
// 12. output: boolean value that specifies whether an author's full given name(s) shall be shortened to initial(s)
//
// 13. output: if the total number of authors is greater than the given number (integer >= 1), only the number of authors given in (14) will be included in the citation along with the string given in (15); keep empty if all authors shall be returned
// 14. output: number of authors (integer >= 1) that is included in the citation if the total number of authors is greater than the number given in (13); keep empty if not applicable
// 15. output: string that's appended to the number of authors given in (14) if the total number of authors is greater than the number given in (13); the actual number of authors can be printed by including '__NUMBER_OF_AUTHORS__' (without quotes) within the string
//
// 16. output: boolean value that specifies whether the re-ordered string shall be returned with higher ASCII chars HTML encoded
$author = reArrangeAuthorContents($row['author'], // 1.
true, // 2.
"/ *; */", // 3.
", ", // 4.
", ", // 5.
"/ *, */", // 6.
" ", // 7.
" ", // 8.
"", // 9.
false, // 10.
false, // 11.
true, // 12.
"6", // 13.
"6", // 14.
", et al.", // 15.
$encodeHTML // 16.
);
if (!preg_match("/\. *$/", $author))
$record .= $author . ".";
else
$record .= $author;
}
if (!empty($row['title'])) // title
{
if (!empty($row['author']))
$record .= " ";
$record .= $row['title'];
}
// From here on we'll assume that at least either the 'author' or the 'title' field did contain some contents
// if this is not the case, the output string will begin with a space. However, any preceding/trailing whitespace will be removed at the cleanup stage (see below)
if (!preg_match("/[?!.] *$/", $record))
$record .= ".";
if (!empty($row['abbrev_journal'])) // abbreviated journal name
$record .= " " . preg_replace("/\./", "", $row['abbrev_journal']); // no punctuation marks are used in the abbreviated journal name, just spaces (TODO: smarten regex pattern)
// if there's no abbreviated journal name, we'll use the full journal name instead:
elseif (!empty($row['publication'])) // publication (= journal) name
$record .= " " . $row['publication'];
if ($row['online_publication'] == "yes") // this record refers to an online publication
$record .= " [Internet]"; // NOTE: some of the above mentioned resources use "[serial online]", "[serial on the Internet]" or just "[online]" instead
// NOTE: the formatting of year/volume/issue is meant for journal articles (TODO: newspaper/magazine articles)
if (!empty($row['year'])) // year
$record .= ". " . $row['year'];
if ($row['online_publication'] == "yes") // append the current date if this record refers to an online publication
$record .= " [cited " . date("Y M j") . "]";
if (!empty($row['volume']) || !empty($row['issue']))
$record .= ";";
if (!empty($row['volume'])) // volume (=month)
$record .= $row['volume'];
if (!empty($row['issue'])) // issue (=day)
$record .= "(" . $row['issue'] . ")";
if (!empty($row['pages'])) // pages
{
if (!empty($row['year']) || !empty($row['volume']) || !empty($row['issue']) || !empty($row['abbrev_journal']) || !empty($row['publication'])) // only add ": " if either year, volume, issue, abbrev_journal or publication isn't empty
$record .= ":";
$record .= formatPageInfo($row['pages'], $markupPatternsArray["endash"], "", "", "", "", "", "", true); // function 'formatPageInfo()' is defined in 'cite.inc.php'
}
if ($row['online_publication'] == "yes") // this record refers to an online publication
{
// append an optional string (given in 'online_citation') plus the DOI (or URL):
if (!empty($row['online_citation'])) // online_citation
{
if (!empty($row['year']) || !empty($row['volume']) || !empty($row['issue']) || !empty($row['abbrev_journal']) || !empty($row['publication'])) // only add ":" or "," if either year, volume, issue, abbrev_journal or publication isn't empty
{
if (empty($row['pages']))
$record .= ":"; // print instead of pages
else
$record .= ";"; // append to pages (TODO: not sure whether this is correct)
}
$record .= $row['online_citation'];
}
if (!empty($row['doi']) || !empty($row['url'])) // doi OR url
{
if (!empty($row['online_citation']) OR (empty($row['online_citation']) AND (!empty($row['year']) || !empty($row['volume']) || !empty($row['issue']) || !empty($row['abbrev_journal']) || !empty($row['publication'])))) // only add "." if online_citation isn't empty, or else if either year, volume, issue, abbrev_journal or publication isn't empty
$record .= ".";
$record .= " Available from: " . $markupPatternsArray["underline-prefix"]; // NOTE: some of the above mentioned resources use "Available from: URL:http://..." instead
if (!empty($row['doi'])) // doi
$uri = "http://dx.doi.org/" . $row['doi'];
else // url
$uri = $row['url'];
if ($encodeHTML)
$record .= encodeHTML($uri);
else
$record .= $uri;
$record .= $markupPatternsArray["underline-suffix"];
}
}
if (!preg_match("/\. *$/", $record) AND ($row['online_publication'] != "yes"))
$record .= "."; // NOTE: the examples in the above mentioned resources differ wildly w.r.t. whether the closing period should be omitted for online publications
}
// --- BEGIN TYPE = ABSTRACT / BOOK CHAPTER / CONFERENCE ARTICLE ------------------------------------------------------------------------
elseif (preg_match("/^(Abstract|Book Chapter|Conference Article)$/", $row['type']))
{
if (!empty($row['author'])) // author
{
// Call the 'reArrangeAuthorContents()' function (defined in 'include.inc.php') in order to re-order contents of the author field. Required Parameters:
// 1. input: contents of the author field
// 2. input: boolean value that specifies whether the author's family name comes first (within one author) in the source string
// ('true' means that the family name is followed by the given name (or initials), 'false' if it's the other way around)
//
// 3. input: pattern describing old delimiter that separates different authors
// 4. output: for all authors except the last author: new delimiter that separates different authors
// 5. output: for the last author: new delimiter that separates the last author from all other authors
//
// 6. input: pattern describing old delimiter that separates author name & initials (within one author)
// 7. output: for the first author: new delimiter that separates author name & initials (within one author)
// 8. output: for all authors except the first author: new delimiter that separates author name & initials (within one author)
// 9. output: new delimiter that separates multiple initials (within one author)
// 10. output: for the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db)
// 11. output: for all authors except the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db)
// 12. output: boolean value that specifies whether an author's full given name(s) shall be shortened to initial(s)
//
// 13. output: if the total number of authors is greater than the given number (integer >= 1), only the number of authors given in (14) will be included in the citation along with the string given in (15); keep empty if all authors shall be returned
// 14. output: number of authors (integer >= 1) that is included in the citation if the total number of authors is greater than the number given in (13); keep empty if not applicable
// 15. output: string that's appended to the number of authors given in (14) if the total number of authors is greater than the number given in (13); the actual number of authors can be printed by including '__NUMBER_OF_AUTHORS__' (without quotes) within the string
//
// 16. output: boolean value that specifies whether the re-ordered string shall be returned with higher ASCII chars HTML encoded
$author = reArrangeAuthorContents($row['author'], // 1.
true, // 2.
"/ *; */", // 3.
", ", // 4.
", ", // 5.
"/ *, */", // 6.
" ", // 7.
" ", // 8.
"", // 9.
false, // 10.
false, // 11.
true, // 12.
"6", // 13.
"6", // 14.
", et al.", // 15.
$encodeHTML // 16.
);
if (!preg_match("/\. *$/", $author))
$record .= $author . ".";
else
$record .= $author;
}
if (!empty($row['title'])) // title
{
if (!empty($row['author']))
$record .= " ";
$record .= $row['title'];
}
if ($row['type'] == "Abstract") // for abstracts, add "[abstract]" label
$record .= " [abstract]";
// From here on we'll assume that at least either the 'author' or the 'title' field did contain some contents
// if this is not the case, the output string will begin with a space. However, any preceding/trailing whitespace will be removed at the cleanup stage (see below)
if (!empty($row['editor'])) // editor
{
// Call the 'reArrangeAuthorContents()' function (defined in 'include.inc.php') in order to re-order contents of the author field. Required Parameters:
// 1. input: contents of the author field
// 2. input: boolean value that specifies whether the author's family name comes first (within one author) in the source string
// ('true' means that the family name is followed by the given name (or initials), 'false' if it's the other way around)
//
// 3. input: pattern describing old delimiter that separates different authors
// 4. output: for all authors except the last author: new delimiter that separates different authors
// 5. output: for the last author: new delimiter that separates the last author from all other authors
//
// 6. input: pattern describing old delimiter that separates author name & initials (within one author)
// 7. output: for the first author: new delimiter that separates author name & initials (within one author)
// 8. output: for all authors except the first author: new delimiter that separates author name & initials (within one author)
// 9. output: new delimiter that separates multiple initials (within one author)
// 10. output: for the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db)
// 11. output: for all authors except the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db)
// 12. output: boolean value that specifies whether an author's full given name(s) shall be shortened to initial(s)
//
// 13. output: if the total number of authors is greater than the given number (integer >= 1), only the number of authors given in (14) will be included in the citation along with the string given in (15); keep empty if all authors shall be returned
// 14. output: number of authors (integer >= 1) that is included in the citation if the total number of authors is greater than the number given in (13); keep empty if not applicable
// 15. output: string that's appended to the number of authors given in (14) if the total number of authors is greater than the number given in (13); the actual number of authors can be printed by including '__NUMBER_OF_AUTHORS__' (without quotes) within the string
//
// 16. output: boolean value that specifies whether the re-ordered string shall be returned with higher ASCII chars HTML encoded
$editor = reArrangeAuthorContents($row['editor'], // 1.
true, // 2.
"/ *; */", // 3.
", ", // 4.
", ", // 5.
"/ *, */", // 6.
" ", // 7.
" ", // 8.
"", // 9.
false, // 10.
false, // 11.
true, // 12.
"6", // 13.
"6", // 14.
", et al.", // 15.
$encodeHTML // 16.
);
if (!preg_match("/[?!.] *$/", $record))
$record .= ".";
$record .= " In: " . $editor . ", ";
if (preg_match("/^[^;\r\n]+(;[^;\r\n]+)+$/", $row['editor'])) // there are at least two editors (separated by ';')
$record .= "editors";
else // there's only one editor (or the editor field is malformed with multiple editors but missing ';' separator[s])
$record .= "editor";
}
$publication = preg_replace("/[ \r\n]*\(Eds?:[^\)\r\n]*\)/i", "", $row['publication']);
if (!empty($publication)) // publication
{
if (!preg_match("/[?!.] *$/", $record))
$record .= ".";
if (empty($row['editor']))
$record .= " In:";
$record .= " " . $publication;
}
if (!empty($row['volume'])) // volume
{
if (!preg_match("@[?!.][ \"" . $markupPatternsArray["italic-suffix"] . "]*$@", $record))
$record .= ".";
$record .= " Vol " . $row['volume']; // TODO: not sure whether this is correct
}
if (!empty($row['edition']) && !preg_match("/^(1|1st|first|one)( ed\.?| edition)?$/i", $row['edition'])) // edition
{
if (!preg_match("@[?!.][ \"" . $markupPatternsArray["italic-suffix"] . "]*$@", $record))
$record .= ".";
if (preg_match("/^\d{1,3}$/", $row['edition'])) // if the edition field contains a number of up to three digits, we assume it's an edition number (such as "2nd ed.")
{
if ($row['edition'] == "2")
$editionSuffix = "nd";
elseif ($row['edition'] == "3")
$editionSuffix = "rd";
else
$editionSuffix = "th";
}
else
$editionSuffix = "";
if (!preg_match("/( ed\.?| edition)$/i", $row['edition']))
$editionSuffix .= " ed.";
$record .= " " . $row['edition'] . $editionSuffix;
}
if (!preg_match("@[?!.][ \"" . $markupPatternsArray["italic-suffix"] . "]*$@", $record))
$record .= ".";
if (!empty($row['place'])) // place
{
// for places in the USA, format any two-letter postal code for the state (i.e. ensure upper case & wrap in parens, eg. "Boca Raton (FL)"):
if (preg_match("/(.+?)[$punct$space]+($uspsStateAbbreviations)[$punct$space]*$/i$patternModifiers", $row['place']))
$record .= " " . preg_replace("/(.+?)[$punct$space]+($uspsStateAbbreviations)[$punct$space]*$/ie$patternModifiers", "'\\1 ('.strtoupper('\\2').')'", $row['place']);
else
$record .= " " . $row['place'];
}
if (!empty($row['publisher'])) // publisher
{
if (!empty($row['place']))
$record .= ":";
$record .= " " . $row['publisher'];
}
if (!empty($row['year'])) // year
$record .= "; " . $row['year'];
if (!empty($row['pages'])) // pages
$record .= ". " . formatPageInfo($row['pages'], $markupPatternsArray["endash"], "p. ", "p. ", "", "", "", "", true); // function 'formatPageInfo()' is defined in 'cite.inc.php'
if (!empty($row['abbrev_series_title']) OR !empty($row['series_title'])) // if there's either a full or an abbreviated series title
{
if (!preg_match("@[?!.][ \"" . $markupPatternsArray["italic-suffix"] . "]*$@", $record))
$record .= ".";
$record .= " (";
if (!empty($row['abbrev_series_title'])) // abbreviated series title
$record .= preg_replace("/\./", "", $row['abbrev_series_title']); // no punctuation marks are used in the abbreviated series title, just spaces (TODO: smarten regex pattern)
// if there's no abbreviated series title, we'll use the full series title instead:
elseif (!empty($row['series_title'])) // full series title
$record .= $row['series_title'];
if (!empty($row['series_volume'])||!empty($row['series_issue']))
$record .= "; ";
if (!empty($row['series_volume'])) // series volume
$record .= "vol " . $row['series_volume'];
if (!empty($row['series_volume']) && !empty($row['series_issue']))
$record .= "; "; // TODO: not sure whether this is correct
if (!empty($row['series_issue'])) // series issue (I'm not really sure if -- for this cite style -- the series issue should be rather omitted here)
$record .= "no " . $row['series_issue']; // since a series volume should be prefixed with "vol", is it correct to prefix series issues with "no"?
$record .= ")";
}
if (!preg_match("/\. *$/", $record))
$record .= ".";
}
// --- BEGIN TYPE = BOOK WHOLE / CONFERENCE VOLUME / JOURNAL / MANUAL / MANUSCRIPT / MAP / MISCELLANEOUS / PATENT / REPORT / SOFTWARE ---
else // if (preg_match("/Book Whole|Conference Volume|Journal|Manual|Manuscript|Map|Miscellaneous|Patent|Report|Software/", $row['type']))
// note that this also serves as a fallback: unrecognized resource types will be formatted similar to whole books
{
if (!empty($row['author'])) // author
{
$author = preg_replace("/[ \r\n]*\(eds?\)/i", "", $row['author']);
// Call the 'reArrangeAuthorContents()' function (defined in 'include.inc.php') in order to re-order contents of the author field. Required Parameters:
// 1. input: contents of the author field
// 2. input: boolean value that specifies whether the author's family name comes first (within one author) in the source string
// ('true' means that the family name is followed by the given name (or initials), 'false' if it's the other way around)
//
// 3. input: pattern describing old delimiter that separates different authors
// 4. output: for all authors except the last author: new delimiter that separates different authors
// 5. output: for the last author: new delimiter that separates the last author from all other authors
//
// 6. input: pattern describing old delimiter that separates author name & initials (within one author)
// 7. output: for the first author: new delimiter that separates author name & initials (within one author)
// 8. output: for all authors except the first author: new delimiter that separates author name & initials (within one author)
// 9. output: new delimiter that separates multiple initials (within one author)
// 10. output: for the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db)
// 11. output: for all authors except the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db)
// 12. output: boolean value that specifies whether an author's full given name(s) shall be shortened to initial(s)
//
// 13. output: if the total number of authors is greater than the given number (integer >= 1), only the number of authors given in (14) will be included in the citation along with the string given in (15); keep empty if all authors shall be returned
// 14. output: number of authors (integer >= 1) that is included in the citation if the total number of authors is greater than the number given in (13); keep empty if not applicable
// 15. output: string that's appended to the number of authors given in (14) if the total number of authors is greater than the number given in (13); the actual number of authors can be printed by including '__NUMBER_OF_AUTHORS__' (without quotes) within the string
//
// 16. output: boolean value that specifies whether the re-ordered string shall be returned with higher ASCII chars HTML encoded
$author = reArrangeAuthorContents($author, // 1.
true, // 2.
"/ *; */", // 3.
", ", // 4.
", ", // 5.
"/ *, */", // 6.
" ", // 7.
" ", // 8.
"", // 9.
false, // 10.
false, // 11.
true, // 12.
"6", // 13.
"6", // 14.
", et al.", // 15.
$encodeHTML // 16.
);
// if the author is actually the editor of the resource we'll append ', ed' (or ', eds') to the author string:
// [to distinguish editors from authors in the 'author' field, the 'modify.php' script does append ' (ed)' or ' (eds)' if appropriate,
// so we're just checking for these identifier strings here. Alternatively, we could check whether the editor field matches the author field]
if (preg_match("/[ \r\n]*\(ed\)/", $row['author'])) // single editor
$author = $author . ", editor";
elseif (preg_match("/[ \r\n]*\(eds\)/", $row['author'])) // multiple editors
$author = $author . ", editors";
if (!preg_match("/\. *$/", $author))
$record .= $author . ".";
else
$record .= $author;
}
if (!empty($row['title'])) // title
{
if (!empty($row['author']))
$record .= " ";
$record .= $row['title'];
}
if ($row['type'] == "Software") // for software, add software label
$record .= " [computer program]";
if (($row['online_publication'] == "yes") AND empty($row['thesis'])) // this record refers to an online publication (online theses will be handled further down below)
$record .= " [Internet]"; // NOTE: some of the above mentioned resources use "[monograph online]", "[monograph on the Internet]" or just "[online]" instead
if (!empty($row['volume']) AND ($row['type'] != "Software")) // volume
{
if (!preg_match("@[?!.][ \"" . $markupPatternsArray["italic-suffix"] . "]*$@", $record))
$record .= ".";
$record .= " Vol " . $row['volume']; // TODO: not sure whether this is correct
}
if (!empty($row['edition'])) // edition
{
if (!preg_match("@[?!.][ \"" . $markupPatternsArray["italic-suffix"] . "]*$@", $record))
$record .= ".";
if ($row['type'] == "Software") // software edition (=version)
{
$record .= " Version " . $row['edition'];
}
elseif (!preg_match("/^(1|1st|first|one)( ed\.?| edition)?$/i", $row['edition'])) // edition
{
if (preg_match("/^\d{1,3}$/", $row['edition'])) // if the edition field contains a number of up to three digits, we assume it's an edition number (such as "2nd ed.")
{
if ($row['edition'] == "2")
$editionSuffix = "nd";
elseif ($row['edition'] == "3")
$editionSuffix = "rd";
else
$editionSuffix = "th";
}
else
$editionSuffix = "";
if (!preg_match("/( ed\.?| edition)$/i", $row['edition']))
$editionSuffix .= " ed.";
$record .= " " . $row['edition'] . $editionSuffix;
}
}
if (!empty($row['editor']) && !preg_match("/[ \r\n]*\(eds?\)/", $row['author'])) // editor (if different from author, see note above regarding the check for ' (ed)' or ' (eds)')
{
// Call the 'reArrangeAuthorContents()' function (defined in 'include.inc.php') in order to re-order contents of the author field. Required Parameters:
// 1. input: contents of the author field
// 2. input: boolean value that specifies whether the author's family name comes first (within one author) in the source string
// ('true' means that the family name is followed by the given name (or initials), 'false' if it's the other way around)
//
// 3. input: pattern describing old delimiter that separates different authors
// 4. output: for all authors except the last author: new delimiter that separates different authors
// 5. output: for the last author: new delimiter that separates the last author from all other authors
//
// 6. input: pattern describing old delimiter that separates author name & initials (within one author)
// 7. output: for the first author: new delimiter that separates author name & initials (within one author)
// 8. output: for all authors except the first author: new delimiter that separates author name & initials (within one author)
// 9. output: new delimiter that separates multiple initials (within one author)
// 10. output: for the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db)
// 11. output: for all authors except the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db)
// 12. output: boolean value that specifies whether an author's full given name(s) shall be shortened to initial(s)
//
// 13. output: if the total number of authors is greater than the given number (integer >= 1), only the number of authors given in (14) will be included in the citation along with the string given in (15); keep empty if all authors shall be returned
// 14. output: number of authors (integer >= 1) that is included in the citation if the total number of authors is greater than the number given in (13); keep empty if not applicable
// 15. output: string that's appended to the number of authors given in (14) if the total number of authors is greater than the number given in (13); the actual number of authors can be printed by including '__NUMBER_OF_AUTHORS__' (without quotes) within the string
//
// 16. output: boolean value that specifies whether the re-ordered string shall be returned with higher ASCII chars HTML encoded
$editor = reArrangeAuthorContents($row['editor'], // 1.
true, // 2.
"/ *; */", // 3.
", ", // 4.
", ", // 5.
"/ *, */", // 6.
" ", // 7.
" ", // 8.
"", // 9.
false, // 10.
false, // 11.
true, // 12.
"6", // 13.
"6", // 14.
", et al.", // 15.
$encodeHTML // 16.
);
if (!preg_match("@[?!.][ \"" . $markupPatternsArray["italic-suffix"] . "]*$@", $record))
$record .= ".";
$record .= " " . $editor;
if (preg_match("/^[^;\r\n]+(;[^;\r\n]+)+$/", $row['editor'])) // there are at least two editors (separated by ';')
$record .= ", editors";
else // there's only one editor (or the editor field is malformed with multiple editors but missing ';' separator[s])
$record .= ", editor";
}
if (!empty($row['thesis'])) // thesis
{
// TODO: do we need to use the term "[dissertation]" instead of "[Ph.D. thesis]", etc? What about other thesis types then?
$record .= " [" . $row['thesis'];
if ($row['online_publication'] == "yes") // this record refers to an online thesis
$record .= " on the Internet]";
else
$record .= "]";
}
if (!preg_match("@[?!.][ \"" . $markupPatternsArray["italic-suffix"] . "]*$@", $record))
$record .= ".";
if (!empty($row['place'])) // place
{
// for places in the USA, format any two-letter postal code for the state (i.e. ensure upper case & wrap in parentheses, eg. "Boca Raton (FL)"):
if (preg_match("/(.+?)[$punct$space]+($uspsStateAbbreviations)[$punct$space]*$/i$patternModifiers", $row['place']))
$record .= " " . preg_replace("/(.+?)[$punct$space]+($uspsStateAbbreviations)[$punct$space]*$/ie$patternModifiers", "'\\1 ('.strtoupper('\\2').')'", $row['place']);
else
$record .= " " . $row['place'];
}
if (!empty($row['publisher'])) // publisher
{
if (!empty($row['place']))
$record .= ":";
$record .= " " . $row['publisher'];
}
$record .= ";";
if (!empty($row['year'])) // year
$record .= " " . $row['year'];
if ($row['type'] == "Software") // for software, volume (=month) and issue (=day) information is printed after the year (TODO: not sure whether this is correct)
{
if (!empty($row['volume'])) // volume (=month)
$record .= " " . $row['volume'];
if (!empty($row['issue'])) // issue (=day)
$record .= " " . $row['issue'];
}
if ($row['online_publication'] == "yes") // append the current date if this record refers to an online publication
$record .= " [cited " . date("Y M j") . "]";
if (!empty($row['abbrev_series_title']) OR !empty($row['series_title'])) // if there's either a full or an abbreviated series title
{
if (!preg_match("@[?!.][ \"" . $markupPatternsArray["italic-suffix"] . "]*$@", $record))
$record .= ".";
$record .= " (";
if (!empty($row['abbrev_series_title'])) // abbreviated series title
$record .= preg_replace("/\./", "", $row['abbrev_series_title']); // no punctuation marks are used in the abbreviated series title, just spaces (TODO: smarten regex pattern)
// if there's no abbreviated series title, we'll use the full series title instead:
elseif (!empty($row['series_title'])) // full series title
$record .= $row['series_title'];
if (!empty($row['series_volume'])||!empty($row['series_issue']))
$record .= "; ";
if (!empty($row['series_volume'])) // series volume
$record .= "vol " . $row['series_volume'];
if (!empty($row['series_volume']) && !empty($row['series_issue']))
$record .= "; "; // TODO: not sure whether this is correct
if (!empty($row['series_issue'])) // series issue (I'm not really sure if -- for this cite style -- the series issue should be rather omitted here)
$record .= "no " . $row['series_issue']; // since a series volume should be prefixed with "vol", is it correct to prefix series issues with "no"?
$record .= ")";
}
if ($row['online_publication'] == "yes" || $row['type'] == "Software") // this record refers to an online publication, or a computer program/software
{
// append an optional string (given in 'online_citation') plus the DOI (or URL):
if (!empty($row['online_citation'])) // online_citation
{
if (!preg_match("/\. *$/", $record))
$record .= ".";
$record .= $row['online_citation'];
}
if (!empty($row['doi']) || !empty($row['url'])) // doi OR url
{
if (!preg_match("/\. *$/", $record))
$record .= ".";
$record .= " Available from: " . $markupPatternsArray["underline-prefix"]; // NOTE: some of the above mentioned resources use "Available from: URL:http://..." instead
if (!empty($row['doi'])) // doi
$uri = "http://dx.doi.org/" . $row['doi'];
else // url
$uri = $row['url'];
if ($encodeHTML)
$record .= encodeHTML($uri);
else
$record .= $uri;
$record .= $markupPatternsArray["underline-suffix"];
}
}
if (!preg_match("/\. *$/", $record) AND ($row['online_publication'] != "yes") AND ($row['type'] != "Software"))
$record .= "."; // NOTE: the examples in the above mentioned resources differ wildly w.r.t. whether the closing period should be omitted for online publications
}
// --- BEGIN POST-PROCESSING -----------------------------------------------------------------------------------------------------------
// do some further cleanup:
$record = trim($record); // remove any preceding or trailing whitespace
return $record;
}
// --- END CITATION STYLE ---
?>