Refbase update_2021-01-28_15_58
This commit is contained in:
176
cite/formats/cite_ascii.php
Normal file
176
cite/formats/cite_ascii.php
Normal file
@@ -0,0 +1,176 @@
|
||||
<?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/formats/cite_ascii.php
|
||||
// Repository: $HeadURL: file:///svn/p/refbase/code/branches/bleeding-edge/cite/formats/cite_ascii.php $
|
||||
// Author(s): Matthias Steffens <mailto:refbase@extracts.de>
|
||||
//
|
||||
// Created: 10-Jun-06, 02:54
|
||||
// Modified: $Date: 2017-04-13 02:00:18 +0000 (Thu, 13 Apr 2017) $
|
||||
// $Author: karnesky $
|
||||
// $Revision: 1416 $
|
||||
|
||||
// This is a citation format file (which must reside within the 'cite/formats/' sub-directory of your refbase root directory). It contains a
|
||||
// version of the 'citeRecords()' function that outputs a reference list from selected records in plain text format. Plain text output is
|
||||
// mainly meant for command line interfaces such as the refbase command line client (<http://cli.refbase.net/>).
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
// --- BEGIN CITATION FORMAT ---
|
||||
|
||||
function citeRecords($result, $rowsFound, $query, $queryURL, $showQuery, $showLinks, $rowOffset, $showRows, $previousOffset, $nextOffset, $wrapResults, $citeStyle, $citeOrder, $citeType, $orderBy, $headerMsg, $userID, $viewType)
|
||||
{
|
||||
global $officialDatabaseName; // these variables are defined in 'ini.inc.php'
|
||||
global $databaseBaseURL;
|
||||
global $contentTypeCharset;
|
||||
|
||||
global $client;
|
||||
|
||||
// The array '$transtab_refbase_ascii' contains search & replace patterns for conversion from refbase markup to plain text
|
||||
global $transtab_refbase_ascii; // defined in 'transtab_refbase_ascii.inc.php'
|
||||
|
||||
$plainTextData = ""; // make sure that our buffer variable is empty
|
||||
|
||||
// Header:
|
||||
if (!empty($headerMsg))
|
||||
{
|
||||
// Decode any HTML entities:
|
||||
// (these may occur in the header message e.g. if the user's preferred display language is not English but German or French, etc)
|
||||
$headerMsg = decodeHTML($contentTypeCharset, $headerMsg); // function 'decodeHTML()' is defined in 'include.inc.php', and '$contentTypeCharset' is defined in 'ini.inc.php'
|
||||
|
||||
// Convert refbase markup in the header message into plain text:
|
||||
$headerMsg = searchReplaceText($transtab_refbase_ascii, $headerMsg, true); // function 'searchReplaceText()' is defined in 'include.inc.php'
|
||||
|
||||
$plainTextData .= "$headerMsg\n\n"; // prefix any passed header message
|
||||
}
|
||||
|
||||
// Initialize array variables:
|
||||
$yearsArray = array();
|
||||
$typeTitlesArray = array();
|
||||
|
||||
// Define inline text markup to be used by the 'citeRecord()' function:
|
||||
$markupPatternsArray = array("bold-prefix" => "", // for plain text output, we'll omit any font-shape markup
|
||||
"bold-suffix" => "",
|
||||
"italic-prefix" => "",
|
||||
"italic-suffix" => "",
|
||||
"underline-prefix" => "",
|
||||
"underline-suffix" => "",
|
||||
"endash" => "-",
|
||||
"emdash" => "-",
|
||||
"ampersand" => "&",
|
||||
"double-quote" => '"',
|
||||
"double-quote-left" => '"',
|
||||
"double-quote-right" => '"',
|
||||
"single-quote" => "'",
|
||||
"single-quote-left" => "'",
|
||||
"single-quote-right" => "'",
|
||||
"less-than" => "<",
|
||||
"greater-than" => ">",
|
||||
"newline" => "\n"
|
||||
);
|
||||
|
||||
// Defines search & replace 'actions' that will be applied upon TEXT output to all those refbase fields that are listed
|
||||
// in the corresponding 'fields' element:
|
||||
$plainTextSearchReplaceActionsArray = array(
|
||||
array('fields' => array("title", "publication", "abbrev_journal", "address", "keywords", "abstract", "orig_title", "series_title", "abbrev_series_title", "notes"),
|
||||
'actions' => $transtab_refbase_ascii
|
||||
)
|
||||
);
|
||||
|
||||
// For CLI queries, we'll allow paging thru the result set, i.e. we honour the values of the CLI options '-S|--start' ('$rowOffset')
|
||||
// and '-R|--rows' ('$showRows') ('$rowOffset' and '$showRows' are re-assigned in function 'seekInMySQLResultsToOffset()' in 'include.inc.php')
|
||||
if (preg_match("/^cli/i", $client)) // if the query originated from a command line client such as the "refbase" CLI client ("cli-refbase-1.0")
|
||||
$showMaxRows = $showRows; // show only rows up to the value given in '$showRows'
|
||||
else
|
||||
$showMaxRows = $rowsFound; // otherwise show all rows
|
||||
|
||||
|
||||
// LOOP OVER EACH RECORD:
|
||||
// Fetch one page of results (or less if on the last page)
|
||||
// (i.e., upto the limit specified in $showMaxRows) fetch a row into the $row array and ...
|
||||
for ($rowCounter=0; (($rowCounter < $showMaxRows) && ($row = @ mysqli_fetch_array($result))); $rowCounter++)
|
||||
{
|
||||
foreach ($row as $rowFieldName => $rowFieldValue)
|
||||
// Apply search & replace 'actions' to all fields that are listed in the 'fields' element of the arrays contained in '$plainTextSearchReplaceActionsArray':
|
||||
foreach ($plainTextSearchReplaceActionsArray as $fieldActionsArray)
|
||||
if (in_array($rowFieldName, $fieldActionsArray['fields']))
|
||||
$row[$rowFieldName] = searchReplaceText($fieldActionsArray['actions'], $row[$rowFieldName], true); // function 'searchReplaceText()' is defined in 'include.inc.php'
|
||||
|
||||
|
||||
// Order attributes according to the chosen output style & record type:
|
||||
$record = citeRecord($row, $citeStyle, $citeType, $markupPatternsArray, false); // function 'citeRecord()' is defined in the citation style file given in '$citeStyleFile' (which, in turn, must reside in the 'cite' directory of the refbase root directory), see function 'generateCitations()'
|
||||
|
||||
|
||||
// Print out the current record:
|
||||
if (!empty($record)) // unless the record buffer is empty...
|
||||
{
|
||||
// Print any section heading(s):
|
||||
if (preg_match("/year|type/i", $citeOrder))
|
||||
{
|
||||
list($yearsArray, $typeTitlesArray, $sectionHeading) = generateSectionHeading($yearsArray, $typeTitlesArray, $row, $citeOrder, "", "", "", "\n\n", "", "\n\n"); // function 'generateSectionHeading()' is defined in 'cite.inc.php'
|
||||
|
||||
$plainTextData .= $sectionHeading;
|
||||
}
|
||||
|
||||
// Write plain TEXT paragraph:
|
||||
if (preg_match("/^cli/i", $client)) // when outputting results to a command line client, we'll prefix the record with it's serial number (and it's user-specific cite key, if available)
|
||||
{
|
||||
// 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 'generateCiteKey()')
|
||||
// (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'
|
||||
|
||||
// Generate or extract the cite key for this record:
|
||||
// NOTE: currently, the following placeholders are not available for citation output:
|
||||
// <:keywords:>, <:issn:>, <:area:>, <:notes:>, <:userKeys:>
|
||||
// if the cite key specification uses one of these placeholders, it will get ignored
|
||||
$citeKey = generateCiteKey($formVars); // function 'generateCiteKey()' is defined in 'include.inc.php'
|
||||
|
||||
$plainTextData .= "[" . $row['serial'] . "] ";
|
||||
|
||||
if (!empty($citeKey))
|
||||
// Use the custom cite key that's been build according to the user's individual export options:
|
||||
$plainTextData .= "{" . $citeKey . "} ";
|
||||
}
|
||||
|
||||
$plainTextData .= $record . "\n\n"; // create paragraph with encoded record text
|
||||
}
|
||||
}
|
||||
|
||||
if (preg_match("/^cli/i", $client)) // when outputting results to a command line client, we'll append some info about the number of rows displayed/found, the database name/URL and optionally display the SQL query
|
||||
{
|
||||
// Calculate the maximum result number on each page:
|
||||
if (($rowOffset + $showRows) < $rowsFound)
|
||||
$showMaxRow = ($rowOffset + $showRows); // maximum result number on each page
|
||||
else
|
||||
$showMaxRow = $rowsFound; // for the last results page, correct the maximum result number if necessary
|
||||
|
||||
if ($rowsFound == 1)
|
||||
$footerInfoPart = " record found";
|
||||
else
|
||||
$footerInfoPart = " records found";
|
||||
|
||||
$rowsFoundInfo = ($rowOffset + 1) . "-" . $showMaxRow . " of " . $rowsFound . $footerInfoPart; // prints e.g. "1-5 of 23 records found"
|
||||
|
||||
$rowsFoundDelimiter = preg_replace("/./i", "-", $rowsFoundInfo); // generate a line of hyphens which has the same length as the string in '$rowsFoundInfo' (e.g. "-----------------------")
|
||||
|
||||
$plainTextData .= $rowsFoundDelimiter . "\n" . $rowsFoundInfo . "\n\n"; // append info about rows displayed/found
|
||||
|
||||
$plainTextData .= $officialDatabaseName . "\n" . $databaseBaseURL . "\n\n"; // append database name and URL (comment this line if you don't like that)
|
||||
|
||||
if ($showQuery == "1") // display SQL query:
|
||||
$plainTextData .= "Query: " . $query . "\n\n";
|
||||
}
|
||||
|
||||
|
||||
return $plainTextData;
|
||||
}
|
||||
|
||||
// --- END CITATION FORMAT ---
|
||||
?>
|
||||
496
cite/formats/cite_html.php
Normal file
496
cite/formats/cite_html.php
Normal file
@@ -0,0 +1,496 @@
|
||||
<?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/formats/cite_html.php
|
||||
// Repository: $HeadURL: file:///svn/p/refbase/code/branches/bleeding-edge/cite/formats/cite_html.php $
|
||||
// Author(s): Matthias Steffens <mailto:refbase@extracts.de>
|
||||
//
|
||||
// Created: 10-Jun-06, 02:30
|
||||
// Modified: $Date: 2017-04-13 02:00:18 +0000 (Thu, 13 Apr 2017) $
|
||||
// $Author: karnesky $
|
||||
// $Revision: 1416 $
|
||||
|
||||
// This is a citation format file (which must reside within the 'cite/formats/' sub-directory of your refbase root directory). It contains a
|
||||
// version of the 'citeRecords()' function that outputs a reference list from selected records in HTML format.
|
||||
//
|
||||
// TODO: - use divs + CSS styling (instead of a table-based layout) for _all_ output (not only for 'viewType=Mobile')
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
// --- BEGIN CITATION FORMAT ---
|
||||
|
||||
function citeRecords($result, $rowsFound, $query, $queryURL, $showQuery, $showLinks, $rowOffset, $showRows, $previousOffset, $nextOffset, $wrapResults, $citeStyle, $citeOrder, $citeType, $orderBy, $headerMsg, $userID, $viewType)
|
||||
{
|
||||
global $databaseBaseURL; // these variables are defined in 'ini.inc.php'
|
||||
global $useVisualEffects;
|
||||
global $defaultDropDownFieldsEveryone;
|
||||
global $defaultDropDownFieldsLogin;
|
||||
global $defaultCiteStyle;
|
||||
global $additionalFieldsCitationView;
|
||||
global $displayResultsHeaderDefault;
|
||||
global $displayResultsFooterDefault;
|
||||
global $showLinkTypesInCitationView;
|
||||
global $showFieldItemLinks;
|
||||
global $maximumBrowseLinks;
|
||||
|
||||
global $loc; // '$loc' is made globally available in 'core.php'
|
||||
|
||||
global $client;
|
||||
global $displayType;
|
||||
|
||||
$htmlData = ""; // make sure that our buffer variables are empty
|
||||
$recordData = "";
|
||||
|
||||
// First, initialize some variables that we'll need later on
|
||||
// Calculate the number of all visible columns (which is needed as colspan value inside some TD tags)
|
||||
if ($showLinks == "1" && preg_match("/^(type|type-year|year)$/i", $citeOrder)) // in citation layout, we simply set it to a fixed value (either '1' or '2', depending on the values of '$showLinks' and '$citeOrder')
|
||||
$NoColumns = 2; // first column: literature citation, second column: 'display details' link
|
||||
else
|
||||
$NoColumns = 1;
|
||||
|
||||
if (empty($displayType))
|
||||
$displayType = $_SESSION['userDefaultView']; // get the default view for the current user
|
||||
|
||||
// If the results footer is displayed, we increase the colspan value by 1 to account for the checkbox column:
|
||||
if ((!preg_match("/^(Print|Mobile)$/i", $viewType)) AND (!preg_match("/^cli/i", $client)) AND ($wrapResults != "0") AND (!isset($displayResultsFooterDefault[$displayType]) OR (isset($displayResultsFooterDefault[$displayType]) AND ($displayResultsFooterDefault[$displayType] != "hidden"))))
|
||||
$NoColumns++;
|
||||
|
||||
// Initialize array variables:
|
||||
$yearsArray = array();
|
||||
$typeTitlesArray = array();
|
||||
|
||||
// Define inline text markup to be used by the 'citeRecord()' function:
|
||||
$markupPatternsArray = array("bold-prefix" => "<b>",
|
||||
"bold-suffix" => "</b>",
|
||||
"italic-prefix" => "<i>",
|
||||
"italic-suffix" => "</i>",
|
||||
"underline-prefix" => "<u>",
|
||||
"underline-suffix" => "</u>",
|
||||
"endash" => "–",
|
||||
"emdash" => "—",
|
||||
"ampersand" => "&",
|
||||
"double-quote" => '"',
|
||||
"double-quote-left" => "“",
|
||||
"double-quote-right" => "”",
|
||||
"single-quote" => "'",
|
||||
"single-quote-left" => "‘",
|
||||
"single-quote-right" => "’",
|
||||
"less-than" => "<",
|
||||
"greater-than" => ">",
|
||||
"newline" => "\n<br>\n"
|
||||
);
|
||||
|
||||
// Defines field-specific search & replace 'actions' that will be applied to the actual citation
|
||||
// for all those refbase fields that are listed in the corresponding 'fields' element:
|
||||
// (These search and replace actions will be performed *in addition* to those specified globally
|
||||
// in '$searchReplaceActionsArray' (defined in 'ini.inc.php'). Same rules apply as for
|
||||
// '$searchReplaceActionsArray'.)
|
||||
$fieldSpecificSearchReplaceActionsArray = array(
|
||||
array(
|
||||
'fields' => array("abstract"),
|
||||
'actions' => array("/[\r\n]+/" => "\n<br>\n") // for the 'abstract' field, transform runs of newline ('\n') or return ('\r') characters into a single <br> tag
|
||||
)
|
||||
);
|
||||
|
||||
// In addition, for the "more info" section, we also substitute contents of the below 'fields'
|
||||
// with localized field values from variable '$loc'. Since the locales in '$loc' are already
|
||||
// HTML encoded, we have to exclude these fields from any further HTML encoding (done below).
|
||||
$fieldSpecificSearchReplaceActionsArray2 = $fieldSpecificSearchReplaceActionsArray;
|
||||
$fieldSpecificSearchReplaceActionsArray2[] = array(
|
||||
'fields' => array("thesis", "approved", "marked", "copy", "selected"),
|
||||
'actions' => array("/(.+)/e" => "\$loc['\\1']") // use localized field values (e.g., in case of german we display 'ja' instead of 'yes', etc)
|
||||
);
|
||||
|
||||
static $encodingExceptionsArray = array("thesis", "approved", "marked", "copy", "selected");
|
||||
|
||||
|
||||
// LOOP OVER EACH RECORD:
|
||||
// Fetch one page of results (or less if on the last page)
|
||||
// (i.e., upto the limit specified in $showRows) fetch a row into the $row array and ...
|
||||
for ($rowCounter=0; (($rowCounter < $showRows) && ($row = @ mysqli_fetch_array($result))); $rowCounter++)
|
||||
{
|
||||
$encodedRowData = $row; // we keep '$row' in its original (unencoded) form since unencoded data will be required by function 'linkifyFieldItems()' below
|
||||
|
||||
// NOTES: - Currently, HTML encoding and search & replace actions are applied separately
|
||||
// for the citation and the "more info" section underneath the citation. The
|
||||
// actions in this 'foreach' block concern the actual citation
|
||||
// - It might be better to pass the unencoded '$row' data to function 'citeRecord()'
|
||||
// which would then make calls to function 'encodeField()' individually for each
|
||||
// field (similar to as it is done it 'modsxml.inc.php')
|
||||
foreach ($encodedRowData as $rowFieldName => $rowFieldValue)
|
||||
{
|
||||
// NOTES: - We HTML encode non-ASCII chars for all but the author & editor fields. The author & editor
|
||||
// fields are excluded here since these fields must be passed *without* HTML entities to the
|
||||
// 'reArrangeAuthorContents()' function (which will then handle the HTML encoding by itself)
|
||||
// - Function 'encodeField()' will also apply any field-specific search & replace actions
|
||||
$encodedRowData[$rowFieldName] = encodeField($rowFieldName, $rowFieldValue, $fieldSpecificSearchReplaceActionsArray, array("author", "editor")); // function 'encodeField()' is defined in 'include.inc.php'
|
||||
}
|
||||
|
||||
|
||||
// Order attributes according to the chosen output style & record type:
|
||||
$record = citeRecord($encodedRowData, $citeStyle, $citeType, $markupPatternsArray, true); // function 'citeRecord()' is defined in the citation style file given in '$citeStyleFile' (which, in turn, must reside in the 'cite' directory of the refbase root directory), see function 'generateCitations()'
|
||||
|
||||
|
||||
// Print out the current record:
|
||||
if (!empty($record)) // unless the record buffer is empty...
|
||||
{
|
||||
// Print any section heading(s):
|
||||
if (preg_match("/year|type/i", $citeOrder))
|
||||
{
|
||||
if (preg_match("/^Mobile$/i", $viewType))
|
||||
{
|
||||
$headingPrefix = "\n<div class=\"sect\">";
|
||||
|
||||
$headingSuffix = "</div>";
|
||||
}
|
||||
else
|
||||
{
|
||||
$headingPrefix = "\n<tr>"
|
||||
. "\n\t<td valign=\"top\" colspan=\"$NoColumns\">";
|
||||
|
||||
$headingSuffix = "</td>"
|
||||
. "\n</tr>";
|
||||
}
|
||||
|
||||
list($yearsArray, $typeTitlesArray, $sectionHeading) = generateSectionHeading($yearsArray, $typeTitlesArray, $row, $citeOrder, $headingPrefix, $headingSuffix, "<h4>", "</h4>", "<h5>", "</h5>"); // function 'generateSectionHeading()' is defined in 'cite.inc.php'
|
||||
|
||||
$recordData .= $sectionHeading;
|
||||
}
|
||||
|
||||
// Print out the record:
|
||||
if (is_integer($rowCounter / 2)) // if we currently are at an even number of rows
|
||||
$rowClass = "even";
|
||||
else
|
||||
$rowClass = "odd";
|
||||
|
||||
if (preg_match("/^(cli|inc)/i", $client) OR ($wrapResults == "0")) // we use absolute links for CLI clients, for include mechanisms, or when returning only a partial document structure
|
||||
$baseURL = $databaseBaseURL;
|
||||
else
|
||||
$baseURL = "";
|
||||
|
||||
$recordPermaLink = $databaseBaseURL . "show.php?record=" . $row["serial"]; // generate a permanent link for the current record
|
||||
|
||||
if (preg_match("/^Mobile$/i", $viewType))
|
||||
{
|
||||
$recordData .= "\n<div class=\"" . $rowClass . "\">"
|
||||
. "\n\t<div class=\"citation\">" . $record . "</div>";
|
||||
}
|
||||
else
|
||||
{
|
||||
$recordData .= "\n<tr class=\"" . $rowClass . "\">";
|
||||
|
||||
// Print a column with a checkbox:
|
||||
// Note: we omit the results footer in print/mobile view ('viewType=Print' or 'viewType=Mobile'), for CLI clients, and when outputting only a partial document structure ('wrapResults=0')!
|
||||
if ((!preg_match("/^Print$/i", $viewType)) AND (!preg_match("/^cli/i", $client)) AND ($wrapResults != "0") AND (!isset($displayResultsFooterDefault[$displayType]) OR (isset($displayResultsFooterDefault[$displayType]) AND ($displayResultsFooterDefault[$displayType] != "hidden"))))
|
||||
{
|
||||
$recordData .= "\n\t<td align=\"center\" valign=\"top\" width=\"10\">";
|
||||
|
||||
// - Print a checkbox form element:
|
||||
if (!isset($displayResultsFooterDefault[$displayType]) OR (isset($displayResultsFooterDefault[$displayType]) AND ($displayResultsFooterDefault[$displayType] != "hidden")))
|
||||
$recordData .= "\n\t\t<input type=\"checkbox\" onclick=\"updateAllRecs();\" name=\"marked[]\" value=\"" . $row["serial"] . "\" title=\"" . $loc["selectRecord"] . "\">";
|
||||
|
||||
if (!empty($row["orig_record"]))
|
||||
{
|
||||
if (!isset($displayResultsFooterDefault[$displayType]) OR (isset($displayResultsFooterDefault[$displayType]) AND ($displayResultsFooterDefault[$displayType] != "hidden")))
|
||||
$recordData .= "\n\t\t<br>";
|
||||
|
||||
if ($row["orig_record"] < 0)
|
||||
$recordData .= "\n\t\t<img src=\"" . $baseURL . "img/ok.gif\" alt=\"(" . $loc["original"] . ")\" title=\"" . $loc["originalRecord"] . "\" width=\"14\" height=\"16\" hspace=\"0\" border=\"0\">";
|
||||
else // $row["orig_record"] > 0
|
||||
$recordData .= "\n\t\t<img src=\"" . $baseURL . "img/caution.gif\" alt=\"(" . $loc["duplicate"] . ")\" title=\"" . $loc["duplicateRecord"] . "\" width=\"5\" height=\"16\" hspace=\"0\" border=\"0\">";
|
||||
}
|
||||
|
||||
// - Add <abbr> block which works as a microformat that allows applications to identify objects on web pages; see <http://unapi.info/specs/> for more info
|
||||
$recordData .= "\n\t\t<div class=\"unapi\"><abbr class=\"unapi-id\" title=\"" . $recordPermaLink . "\"></abbr></div>";
|
||||
|
||||
$recordData .= "\n\t</td>";
|
||||
}
|
||||
|
||||
// Print record data as a citation:
|
||||
$recordData .= "\n\t<td id=\"ref" . $row["serial"] . "\" class=\"citation\" valign=\"top\">"
|
||||
. "\n\t\t" . $record;
|
||||
|
||||
// Display a triangle widget to show more info (keywords, abstract, etc) under each citation:
|
||||
if (!empty($additionalFieldsCitationView))
|
||||
{
|
||||
// Map MySQL field names to localized column names:
|
||||
$fieldNamesArray = mapFieldNames(); // function 'mapFieldNames()' is defined in 'include.inc.php'
|
||||
|
||||
if ($useVisualEffects == "yes")
|
||||
$toggleVisibilityFunction = "toggleVisibilitySlide";
|
||||
else
|
||||
$toggleVisibilityFunction = "toggleVisibility";
|
||||
|
||||
$recordData .= "\n\t\t<div class=\"showhide\">"
|
||||
. "\n\t\t\t<a href=\"javascript:" . $toggleVisibilityFunction . "('moreinfo" . $row["serial"] . "','toggleimg" . $row["serial"] . "','toggletxt" . $row["serial"] . "','more%20info')\" title=\"" . $loc["LinkTitle_ToggleVisibility"] . "\">"
|
||||
. "<img id=\"toggleimg" . $row["serial"] . "\" class=\"toggleimg\" src=\"" . $baseURL . "img/closed.gif\" alt=\"" . $loc["LinkTitle_ToggleVisibility"] . "\" width=\"9\" height=\"9\" hspace=\"0\" border=\"0\">"
|
||||
. "</a>"
|
||||
. "\n\t\t</div>"
|
||||
. "\n\t\t<div id=\"moreinfo" . $row["serial"] . "\" class=\"moreinfo\" style=\"display: none;\">";
|
||||
|
||||
// Print additional fields:
|
||||
foreach ($additionalFieldsCitationView as $field)
|
||||
{
|
||||
if (isset($row[$field]) AND !empty($row[$field]))
|
||||
{
|
||||
$recordData .= "\n\t\t\t<div class=\"" . $field . "\"><strong>" . $fieldNamesArray[$field] . ":</strong> ";
|
||||
|
||||
// Make field items into clickable search links:
|
||||
if (in_array($displayType, $showFieldItemLinks))
|
||||
// Note: Function 'linkifyFieldItems()' will also call function 'encodeField()' to HTML
|
||||
// encode non-ASCII chars and to apply any field-specific search & replace actions
|
||||
$recordData .= linkifyFieldItems($field, $row[$field], $userID, $fieldSpecificSearchReplaceActionsArray2, $encodingExceptionsArray, "/\s*[;]+\s*/", "; ", $showQuery, $showLinks, $showRows, $citeStyle, $citeOrder, $wrapResults, $displayType, $viewType); // function 'linkifyFieldItems()' is defined in 'include.inc.php'
|
||||
else // don't hotlink field items
|
||||
$recordData .= encodeField($field, $row[$field], $fieldSpecificSearchReplaceActionsArray2, $encodingExceptionsArray); // function 'encodeField()' is defined in 'include.inc.php'
|
||||
|
||||
$recordData .= "</div>";
|
||||
}
|
||||
}
|
||||
|
||||
// Print a row with links for the current record:
|
||||
$recordData .= "\n\t\t\t<div class=\"reflinks\">";
|
||||
|
||||
// - Print the record's permanent URL:
|
||||
if (preg_match("/^inc/i", $client)) // we open links in a new browser window if refbase data are included somewhere else:
|
||||
$target = " target=\"_blank\"";
|
||||
else
|
||||
$target = "";
|
||||
|
||||
$recordData .= "\n\t\t\t\t<div class=\"permalink\"><a href=\"" . $recordPermaLink . "\"" . $target . " title=\"" . $loc["LinkTitle_Permalink"] . "\">";
|
||||
|
||||
if (preg_match("/^Print$/i", $viewType)) // for print view, we use the URL as link title
|
||||
$recordData .= $recordPermaLink;
|
||||
else
|
||||
$recordData .= $loc["PermalinkShort"];
|
||||
|
||||
$recordData .= "</a></div>";
|
||||
|
||||
// - Print additional links to cite/export the current record:
|
||||
// Note: we omit the additional links in print view ('viewType=Print')
|
||||
if (!preg_match("/^Print$/i", $viewType))
|
||||
{
|
||||
// -- Print cite links:
|
||||
if (isset($_SESSION['user_permissions']) AND preg_match("/allow_cite/", $_SESSION['user_permissions']) AND isset($_SESSION['user_cite_formats']))
|
||||
{
|
||||
$userCiteFormatsArray = preg_split("/ *; */", $_SESSION['user_cite_formats'], -1, PREG_SPLIT_NO_EMPTY); // get a list of the user's cite formats (the 'PREG_SPLIT_NO_EMPTY' flag causes only non-empty pieces to be returned)
|
||||
|
||||
$recordData .= "\n\t\t\t\t<div class=\"citelinks\">"
|
||||
. " | " . $loc["SaveCitation"] . ":";
|
||||
|
||||
foreach ($userCiteFormatsArray as $citeFormat)
|
||||
if (!preg_match("/^html$/i", $citeFormat)) // for now, we exclude the "HTML" cite format (as it's not any different to the regular Citation view HTML output)
|
||||
$recordData .= "\n\t\t\t\t\t <a href=\"" . $baseURL . generateURL("show.php", $citeFormat, array("record" => $row['serial']), true, "", "", $citeStyle, $citeOrder) . "\" title=\"" . $loc["LinkTitle_SaveCitationFormat_Prefix"] . $citeFormat . $loc["LinkTitle_SaveCitationFormat_Suffix"] . "\">" . $citeFormat . "</a>";
|
||||
|
||||
$recordData .= "\n\t\t\t\t</div>";
|
||||
}
|
||||
|
||||
// -- Print export links:
|
||||
if (isset($_SESSION['user_permissions']) AND preg_match("/allow_export|allow_batch_export/", $_SESSION['user_permissions']) AND isset($_SESSION['user_export_formats']))
|
||||
{
|
||||
$userExportFormatsArray = preg_split("/ *; */", $_SESSION['user_export_formats'], -1, PREG_SPLIT_NO_EMPTY); // get a list of the user's export formats
|
||||
|
||||
$recordData .= "\n\t\t\t\t<div class=\"exportlinks\">"
|
||||
. " | " . $loc["ExportRecord"] . ":";
|
||||
|
||||
foreach ($userExportFormatsArray as $exportFormat)
|
||||
$recordData .= "\n\t\t\t\t\t <a href=\"" . $baseURL . generateURL("show.php", $exportFormat, array("record" => $row['serial'], "exportType" => "file"), true, "", "", $citeStyle) . "\" title=\"" . $loc["LinkTitle_ExportRecordFormat_Prefix"] . $exportFormat . $loc["LinkTitle_ExportRecordFormat_Suffix"] . "\">" . $exportFormat . "</a>";
|
||||
|
||||
$recordData .= "\n\t\t\t\t</div>";
|
||||
}
|
||||
}
|
||||
|
||||
$recordData .= "\n\t\t\t</div>"
|
||||
. "\n\t\t</div>";
|
||||
}
|
||||
|
||||
$recordData .= "\n\t</td>";
|
||||
}
|
||||
|
||||
// Display the regular links column:
|
||||
if ($showLinks == "1")
|
||||
{
|
||||
if (preg_match("/^Mobile$/i", $viewType))
|
||||
$recordData .= "\n\t<div class=\"links\">";
|
||||
else
|
||||
$recordData .= "\n\t<td class=\"links\" valign=\"top\" width=\"42\">";
|
||||
|
||||
// Print out available links:
|
||||
// for Citation view, we'll use the '$showLinkTypesInCitationView' array that's defined in 'ini.inc.php'
|
||||
// to specify which links shall be displayed (if available and if 'showLinks == 1')
|
||||
// (for links of type DOI/URL/ISBN/XREF, only one link will be printed; order of preference: DOI, URL, ISBN, XREF)
|
||||
$recordData .= printLinks($showLinkTypesInCitationView, $row, $showQuery, $showLinks, $wrapResults, $userID, $viewType, $orderBy); // function 'printLinks()' is defined in 'search.php'
|
||||
|
||||
if (preg_match("/^Mobile$/i", $viewType))
|
||||
$recordData .= "\n\t</div>";
|
||||
else
|
||||
$recordData .= "\n\t</td>";
|
||||
}
|
||||
|
||||
if (preg_match("/^Mobile$/i", $viewType))
|
||||
$recordData .= "\n</div>";
|
||||
else
|
||||
$recordData .= "\n</tr>";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// OUTPUT RESULTS:
|
||||
|
||||
// Note: we omit the results header, browse links & query form for CLI clients, and when outputting only a partial document structure ('wrapResults=0')
|
||||
if (!preg_match("/^cli/i", $client) AND ($wrapResults != "0"))
|
||||
{
|
||||
// Note: we also omit the results header in print/mobile view ('viewType=Print' or 'viewType=Mobile')
|
||||
if ((!preg_match("/^(Print|Mobile)$/i", $viewType)) AND (!isset($displayResultsHeaderDefault[$displayType]) OR (isset($displayResultsHeaderDefault[$displayType]) AND ($displayResultsHeaderDefault[$displayType] != "hidden"))))
|
||||
{
|
||||
// Extract the first field from the 'WHERE' clause:
|
||||
if (preg_match("/ WHERE [ ()]*(\w+)/i", $query))
|
||||
$selectedField = preg_replace("/.+ WHERE [ ()]*(\w+).*/i", "\\1", $query);
|
||||
else
|
||||
$selectedField = "author"; // in the 'Search within Results" form, we'll select the 'author' field by default
|
||||
|
||||
// Map MySQL field names to localized column names:
|
||||
$fieldNamesArray = mapFieldNames(true);
|
||||
$localizedDropDownFieldsArray = array();
|
||||
|
||||
if (isset($_SESSION['loginEmail']) AND !empty($defaultDropDownFieldsLogin)) // if a user is logged in -AND- there were any additional fields specified...
|
||||
$dropDownFieldsArray = array_merge($defaultDropDownFieldsEveryone, $defaultDropDownFieldsLogin); // ...add these additional fields to the list of fields visible in the dropdown menus of the results header
|
||||
else
|
||||
$dropDownFieldsArray = $defaultDropDownFieldsEveryone;
|
||||
|
||||
foreach ($dropDownFieldsArray as $field)
|
||||
{
|
||||
if (isset($fieldNamesArray[$field]))
|
||||
$localizedDropDownFieldsArray[$field] = $fieldNamesArray[$field];
|
||||
else // no localized field name exists, so we use the original field name
|
||||
$localizedDropDownFieldsArray[$field] = $field;
|
||||
}
|
||||
|
||||
// Get all citation styles for the current user:
|
||||
if (!isset($_SESSION['user_styles']))
|
||||
$citationStylesArray = array($defaultCiteStyle);
|
||||
else
|
||||
{
|
||||
$citationStylesArray = array();
|
||||
|
||||
$citationStylesTempArray = preg_split("/ *; */", $_SESSION['user_styles']); // get the user's list of citation styles
|
||||
|
||||
foreach ($citationStylesTempArray as $citationStyle)
|
||||
$citationStylesArray[$citationStyle] = $citationStyle;
|
||||
}
|
||||
|
||||
// 2) Build forms containing options to show the user's groups, refine the search results or change the displayed columns:
|
||||
// TODO for 2b+2c: should we allow users to choose via the web interface which columns are included in the popup menus?
|
||||
|
||||
// 2a) Build a FORM with a popup containing the user's groups:
|
||||
$formElementsGroup = buildGroupSearchElements("search.php", $queryURL, $query, $showQuery, $showLinks, $showRows, $citeStyle, $citeOrder, $displayType); // function 'buildGroupSearchElements()' is defined in 'include.inc.php'
|
||||
|
||||
// 2b) Build a FORM containing options to refine the search results:
|
||||
// Call the 'buildRefineSearchElements()' function (defined in 'include.inc.php') which does the actual work:
|
||||
$formElementsRefine = buildRefineSearchElements("search.php", $queryURL, $showQuery, $showLinks, $showRows, $citeStyle, $citeOrder, $localizedDropDownFieldsArray, $selectedField, $displayType);
|
||||
|
||||
// 2c) Build a FORM containing display options (change citation style & sort order, or change the number of records displayed per page):
|
||||
// Call the 'buildDisplayOptionsElements()' function (defined in 'include.inc.php') which does the actual work:
|
||||
$formElementsDisplayOptions = buildDisplayOptionsElements("search.php", $queryURL, $showQuery, $showLinks, $rowOffset, $showRows, $citeStyle, $citeOrder, $citationStylesArray, $citeStyle, 2, $displayType, $headerMsg);
|
||||
|
||||
$htmlData .= displayResultsHeader("search.php", $formElementsGroup, $formElementsRefine, $formElementsDisplayOptions, $displayType); // function 'displayResultsHeader()' is defined in 'results_header.inc.php'
|
||||
|
||||
// and insert a divider line (which separates the results header from the browse links & results data below):
|
||||
$htmlData .= "\n<hr class=\"resultsheader\" align=\"center\" width=\"93%\">";
|
||||
}
|
||||
|
||||
// Build a TABLE with links for "previous" & "next" browsing, as well as links to intermediate pages
|
||||
// call the 'buildBrowseLinks()' function (defined in 'include.inc.php'):
|
||||
$BrowseLinks = buildBrowseLinks("search.php", $query, $NoColumns, $rowsFound, $showQuery, $showLinks, $showRows, $rowOffset, $previousOffset, $nextOffset, $wrapResults, $maximumBrowseLinks, "sqlSearch", "Cite", $citeStyle, $citeOrder, $orderBy, $headerMsg, $viewType);
|
||||
$htmlData .= $BrowseLinks;
|
||||
|
||||
if (preg_match("/^Mobile$/i", $viewType))
|
||||
{
|
||||
// Extract the original OpenSearch/CQL query that was saved by 'opensearch.php' as a session variable:
|
||||
if (isset($_SESSION['cqlQuery']))
|
||||
$cqlQuery = $_SESSION['cqlQuery'];
|
||||
else
|
||||
$cqlQuery = "";
|
||||
|
||||
// Include an OpenSearch-style (CQL) query form:
|
||||
$htmlData .= "\n<div id=\"queryform\">"
|
||||
. "\n\t<form action=\"opensearch.php\" method=\"GET\" name=\"openSearch\">"
|
||||
. "\n\t\t<input type=\"hidden\" name=\"formType\" value=\"openSearch\">"
|
||||
. "\n\t\t<input type=\"hidden\" name=\"submit\" value=\"" . $loc["ButtonTitle_Search"] . "\">"
|
||||
. "\n\t\t<input type=\"hidden\" name=\"viewType\" value=\"" . $viewType . "\">"
|
||||
. "\n\t\t<input type=\"hidden\" name=\"startRecord\" value=\"1\">"
|
||||
. "\n\t\t<input type=\"hidden\" name=\"maximumRecords\" value=\"" . $showRows . "\">"
|
||||
. "\n\t\t<input type=\"hidden\" name=\"recordSchema\" value=\"html\">"
|
||||
. "\n\t\t<input type=\"text\" name=\"query\" value=\"" . $cqlQuery . "\" size=\"25\" title=\"" . $loc["DescriptionEnterSearchString"] . "\">"
|
||||
. "\n\t\t<input type=\"submit\" name=\"submit\" value=\"" . $loc["ButtonTitle_Search"] . "\" title=\"" . $loc["DescriptionSearchDB"] . "\">"
|
||||
. "\n\t</form>"
|
||||
. "\n</div>";
|
||||
}
|
||||
elseif ((!preg_match("/^Print$/i", $viewType)) AND (!isset($displayResultsFooterDefault[$displayType]) OR (isset($displayResultsFooterDefault[$displayType]) AND ($displayResultsFooterDefault[$displayType] != "hidden"))))
|
||||
{
|
||||
// Include the 'queryResults' form:
|
||||
$htmlData .= "\n<form action=\"search.php\" method=\"GET\" name=\"queryResults\">"
|
||||
. "\n<input type=\"hidden\" name=\"formType\" value=\"queryResults\">"
|
||||
. "\n<input type=\"hidden\" name=\"submit\" value=\"Cite\">" // provide a default value for the 'submit' form tag (then, if any form element is selected, hitting <enter> will act as if the user clicked the 'Cite' button)
|
||||
. "\n<input type=\"hidden\" name=\"originalDisplayType\" value=\"" . $displayType . "\">" // embed the original value of the '$displayType' variable
|
||||
. "\n<input type=\"hidden\" name=\"orderBy\" value=\"" . rawurlencode($orderBy) . "\">" // embed the current ORDER BY parameter so that it can be re-applied when displaying details
|
||||
. "\n<input type=\"hidden\" name=\"showQuery\" value=\"" . $showQuery . "\">" // embed the current value of '$showQuery' so that it's available on 'display details' (batch display) & 'cite'
|
||||
. "\n<input type=\"hidden\" name=\"showLinks\" value=\"" . $showLinks . "\">" // embed the current value of '$showLinks' so that it's available on 'display details' (batch display) & 'cite'
|
||||
. "\n<input type=\"hidden\" name=\"showRows\" value=\"" . $showRows . "\">" // embed the current value of '$showRows' so that it's available on 'display details' (batch display) & 'cite'
|
||||
. "\n<input type=\"hidden\" name=\"rowOffset\" value=\"" . $rowOffset . "\">" // embed the current value of '$rowOffset' so that it can be re-applied after the user pressed either of the 'Add' or 'Remove' buttons within the 'queryResults' form
|
||||
// Note: the inclusion of '$rowOffset' here is only meant to support reloading of the same results page again after a user clicked the 'Add' or 'Remove' buttons
|
||||
// However, '$rowOffset' MUST NOT be set if the user clicked the 'Display' or 'Cite' button! Therefore we'll trap for this case at the top of the script.
|
||||
. "\n<input type=\"hidden\" name=\"sqlQuery\" value=\"" . $queryURL . "\">"; // embed the current sqlQuery so that it can be re-applied after the user pressed either of the 'Add' or 'Remove' buttons within the 'queryResults' form
|
||||
}
|
||||
}
|
||||
|
||||
// Output query results:
|
||||
if (preg_match("/^Mobile$/i", $viewType))
|
||||
{
|
||||
$htmlData .= "\n<div id=\"citations\" class=\"results\">"
|
||||
. $recordData
|
||||
. "\n</div>";
|
||||
}
|
||||
else
|
||||
{
|
||||
$htmlData .= "\n<table id=\"citations\" class=\"results\" align=\"center\" border=\"0\" cellpadding=\"7\" cellspacing=\"0\" width=\"95%\" summary=\"This table holds the database results for your query\">"
|
||||
. $recordData
|
||||
. "\n</table>";
|
||||
}
|
||||
|
||||
// Append the footer:
|
||||
// Note: we omit the results footer & browse links in print/mobile view ('viewType=Print' or 'viewType=Mobile'), for CLI clients, and when outputting only a partial document structure ('wrapResults=0')!
|
||||
if ((!preg_match("/^(Print|Mobile)$/i", $viewType)) AND (!preg_match("/^cli/i", $client)) AND ($wrapResults != "0"))
|
||||
{
|
||||
// Again, insert the (already constructed) BROWSE LINKS
|
||||
// (i.e., a TABLE with links for "previous" & "next" browsing, as well as links to intermediate pages)
|
||||
$htmlData .= $BrowseLinks;
|
||||
|
||||
// Build a results footer with form elements to cite, group or export all/selected records:
|
||||
if (!isset($displayResultsFooterDefault[$displayType]) OR (isset($displayResultsFooterDefault[$displayType]) AND ($displayResultsFooterDefault[$displayType] != "hidden")))
|
||||
{
|
||||
if (isset($_SESSION['user_permissions']) AND ((isset($_SESSION['loginEmail']) AND preg_match("/allow_cite|allow_user_groups|allow_export|allow_batch_export/", $_SESSION['user_permissions'])) OR (!isset($_SESSION['loginEmail']) AND preg_match("/allow_cite/", $_SESSION['user_permissions'])))) // if the 'user_permissions' session variable does contain any of the following: 'allow_cite' -AND- if logged in, aditionally: 'allow_user_groups', 'allow_export', 'allow_batch_export'...
|
||||
// ...Insert a divider line (which separates the results data from the forms in the footer):
|
||||
$htmlData .= "\n<hr class=\"resultsfooter\" align=\"center\">";
|
||||
|
||||
// Call the 'buildResultsFooter()' function (which does the actual work):
|
||||
$htmlData .= buildResultsFooter($showRows, $citeStyle, $citeOrder, $displayType, $headerMsg);
|
||||
}
|
||||
}
|
||||
|
||||
if ((!preg_match("/^(Print|Mobile)$/i", $viewType)) AND (!preg_match("/^cli/i", $client)) AND ($wrapResults != "0") AND (!isset($displayResultsFooterDefault[$displayType]) OR (isset($displayResultsFooterDefault[$displayType]) AND ($displayResultsFooterDefault[$displayType] != "hidden"))))
|
||||
{
|
||||
// Finish the form:
|
||||
$htmlData .= "\n</form>";
|
||||
}
|
||||
|
||||
return $htmlData;
|
||||
}
|
||||
|
||||
// --- END CITATION FORMAT ---
|
||||
?>
|
||||
199
cite/formats/cite_latex.php
Normal file
199
cite/formats/cite_latex.php
Normal file
@@ -0,0 +1,199 @@
|
||||
<?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/formats/cite_latex.php
|
||||
// Repository: $HeadURL: file:///svn/p/refbase/code/branches/bleeding-edge/cite/formats/cite_latex.php $
|
||||
// Author(s): Matthias Steffens <mailto:refbase@extracts.de>
|
||||
//
|
||||
// Created: 10-Jun-06, 02:32
|
||||
// Modified: $Date: 2017-04-13 02:00:18 +0000 (Thu, 13 Apr 2017) $
|
||||
// $Author: karnesky $
|
||||
// $Revision: 1416 $
|
||||
|
||||
// This is a citation format file (which must reside within the 'cite/formats/' sub-directory of your refbase root directory). It contains a
|
||||
// version of the 'citeRecords()' function that outputs a reference list from selected records in LaTeX format.
|
||||
//
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
// --- BEGIN CITATION FORMAT ---
|
||||
|
||||
function citeRecords($result, $rowsFound, $query, $queryURL, $showQuery, $showLinks, $rowOffset, $showRows, $previousOffset, $nextOffset, $wrapResults, $citeStyle, $citeOrder, $citeType, $orderBy, $headerMsg, $userID, $viewType)
|
||||
{
|
||||
global $contentTypeCharset; // defined in 'ini.inc.php'
|
||||
|
||||
global $client;
|
||||
|
||||
// The array '$transtab_refbase_latex' contains search & replace patterns for conversion from refbase markup to LaTeX markup & entities.
|
||||
// Converts refbase fontshape markup (italic, bold) into LaTeX commands of the 'textcomp' package, super- and subscript as well as greek
|
||||
// symbols get converted into the respective commands in math mode. You may need to adopt the LaTeX markup to suit your individual needs.
|
||||
global $transtab_refbase_latex; // defined in 'transtab_refbase_latex.inc.php'
|
||||
|
||||
// The arrays '$transtab_latin1_latex' and '$transtab_unicode_latex' provide translation tables for best-effort conversion of higher ASCII
|
||||
// characters from ISO-8859-1 (or Unicode, respectively) to LaTeX entities.
|
||||
global $transtab_latin1_latex; // defined in 'transtab_latin1_latex.inc.php'
|
||||
global $transtab_unicode_latex; // defined in 'transtab_unicode_latex.inc.php'
|
||||
|
||||
// Initialize array variables:
|
||||
$yearsArray = array();
|
||||
$typeTitlesArray = array();
|
||||
|
||||
// Define inline text markup to be used by the 'citeRecord()' function:
|
||||
$markupPatternsArray = array("bold-prefix" => "\\textbf{",
|
||||
"bold-suffix" => "}",
|
||||
"italic-prefix" => "\\textit{",
|
||||
"italic-suffix" => "}",
|
||||
"underline-prefix" => "\\ul{", // the '\ul' command requires '\usepackage{soul}'
|
||||
"underline-suffix" => "}",
|
||||
"endash" => "--", // or use '{\\textendash}'
|
||||
"emdash" => "---", // or use '{\\textemdash}'
|
||||
"ampersand" => "&", // conversion of ampersands is done below, after the citation has been generated
|
||||
"double-quote" => '"',
|
||||
"double-quote-left" => "{\\textquotedblleft}",
|
||||
"double-quote-right" => "{\\textquotedblright}",
|
||||
"single-quote" => "'", // same as for ampersands
|
||||
"single-quote-left" => "{\\textquoteleft}",
|
||||
"single-quote-right" => "{\\textquoteright}",
|
||||
"less-than" => "<",
|
||||
"greater-than" => ">",
|
||||
"newline" => "\n\n"
|
||||
);
|
||||
|
||||
// Defines search & replace 'actions' that will be applied upon LaTeX output to all those refbase fields that are listed
|
||||
// in the corresponding 'fields' element:
|
||||
$latexSearchReplaceActionsArray = array(
|
||||
array('fields' => array("title", "publication", "abbrev_journal", "address", "keywords", "abstract", "orig_title", "series_title", "abbrev_series_title", "notes"),
|
||||
'actions' => $transtab_refbase_latex
|
||||
)
|
||||
);
|
||||
|
||||
// For CLI queries, we'll allow paging thru the result set, i.e. we honour the values of the CLI options '-S|--start' ('$rowOffset')
|
||||
// and '-R|--rows' ('$showRows') ('$rowOffset' and '$showRows' are re-assigned in function 'seekInMySQLResultsToOffset()' in 'include.inc.php')
|
||||
if (preg_match("/^cli/i", $client)) // if the query originated from a command line client such as the "refbase" CLI client ("cli-refbase-1.0")
|
||||
$showMaxRows = $showRows; // show only rows up to the value given in '$showRows'
|
||||
else
|
||||
$showMaxRows = $rowsFound; // otherwise show all rows
|
||||
|
||||
|
||||
// Setup the basic LaTeX document structure:
|
||||
$latexData = "%&LaTeX\n"
|
||||
. "\\documentclass{article}\n\n";
|
||||
|
||||
// NOTE: the "Vancouver" & "Harvard 1" citation styles make use of the '\ul' command which requires '\usepackage{soul}'
|
||||
// TODO: figure out a better logic when to include the '\usepackage{soul}' statement (or should we simply always include it?)
|
||||
if (preg_match("/^(Vancouver|Harvard 1)$/i", $citeStyle))
|
||||
$latexData .= "\\usepackage{soul}\n";
|
||||
|
||||
if ($contentTypeCharset == "UTF-8")
|
||||
$latexData .= "\\usepackage[utf8]{inputenc}\n";
|
||||
else
|
||||
$latexData .= "\\usepackage[latin1]{inputenc}\n";
|
||||
|
||||
$latexData .= "\\usepackage[T1]{fontenc}\n"
|
||||
. "\\usepackage{textcomp}\n\n";
|
||||
|
||||
$latexData .= "\\begin{document}\n\n";
|
||||
|
||||
// Header:
|
||||
if (!empty($headerMsg))
|
||||
{
|
||||
// Remove any colon (":") from end of header message:
|
||||
$headerMsg = trimTextPattern($headerMsg, ":", false, true); // function 'trimTextPattern()' is defined in 'include.inc.php'
|
||||
|
||||
// Decode any HTML entities:
|
||||
// (these may occur in the header message e.g. if the user's preferred display language is not English but German or French, etc)
|
||||
$headerMsg = decodeHTML($contentTypeCharset, $headerMsg); // function 'decodeHTML()' is defined in 'include.inc.php', and '$contentTypeCharset' is defined in 'ini.inc.php'
|
||||
|
||||
// Convert refbase markup in the header message into appropriate LaTeX markup & entities:
|
||||
$headerMsg = searchReplaceText($transtab_refbase_latex, $headerMsg, true); // function 'searchReplaceText()' is defined in 'include.inc.php'
|
||||
|
||||
// Attempt to convert higher ASCII chars (i.e., characters with an ASCII value of >= 128) in the header message to their corresponding LaTeX entities:
|
||||
if ($contentTypeCharset == "UTF-8")
|
||||
$headerMsg = searchReplaceText($transtab_unicode_latex, $headerMsg, false);
|
||||
else
|
||||
$headerMsg = searchReplaceText($transtab_latin1_latex, $headerMsg, false);
|
||||
|
||||
$latexData .= "\\title{" . $headerMsg . "}\n\n"
|
||||
. "\\maketitle\n\n";
|
||||
}
|
||||
|
||||
if (!preg_match("/type|year/i", $citeOrder))
|
||||
$latexData .= "\\begin{thebibliography}{" . $showMaxRows . "}\n\n";
|
||||
|
||||
|
||||
// LOOP OVER EACH RECORD:
|
||||
// Fetch one page of results (or less if on the last page)
|
||||
// (i.e., upto the limit specified in $showMaxRows) fetch a row into the $row array and ...
|
||||
for ($rowCounter=0; (($rowCounter < $showMaxRows) && ($row = @ mysqli_fetch_array($result))); $rowCounter++)
|
||||
{
|
||||
foreach ($row as $rowFieldName => $rowFieldValue)
|
||||
// Apply search & replace 'actions' to all fields that are listed in the 'fields' element of the arrays contained in '$latexSearchReplaceActionsArray':
|
||||
foreach ($latexSearchReplaceActionsArray as $fieldActionsArray)
|
||||
if (in_array($rowFieldName, $fieldActionsArray['fields']))
|
||||
$row[$rowFieldName] = searchReplaceText($fieldActionsArray['actions'], $row[$rowFieldName], true); // function 'searchReplaceText()' is defined in 'include.inc.php'
|
||||
|
||||
|
||||
// Order attributes according to the chosen output style & record type:
|
||||
$record = citeRecord($row, $citeStyle, $citeType, $markupPatternsArray, false); // function 'citeRecord()' is defined in the citation style file given in '$citeStyleFile' (which, in turn, must reside in the 'cite' directory of the refbase root directory), see function 'generateCitations()'
|
||||
|
||||
|
||||
// Print out the current record:
|
||||
if (!empty($record)) // unless the record buffer is empty...
|
||||
{
|
||||
// Print any section heading(s):
|
||||
if (preg_match("/year|type/i", $citeOrder))
|
||||
{
|
||||
list($yearsArray, $typeTitlesArray, $sectionHeading) = generateSectionHeading($yearsArray, $typeTitlesArray, $row, $citeOrder, "", "", "\\section*{", "}\n\n", "\\subsection*{", "}\n\n"); // function 'generateSectionHeading()' is defined in 'cite.inc.php'
|
||||
|
||||
$latexData .= $sectionHeading;
|
||||
}
|
||||
|
||||
// Attempt to convert higher ASCII chars (i.e., characters with an ASCII value of >= 128) to their corresponding LaTeX entities:
|
||||
if ($contentTypeCharset == "UTF-8")
|
||||
$recordEncoded = searchReplaceText($transtab_unicode_latex, $record, false); // function 'searchReplaceText()' is defined in 'include.inc.php'
|
||||
else
|
||||
$recordEncoded = searchReplaceText($transtab_latin1_latex, $record, false);
|
||||
|
||||
// Write LaTeX paragraph:
|
||||
if (!preg_match("/type|year/i", $citeOrder))
|
||||
{
|
||||
// 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 'generateCiteKey()')
|
||||
// (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'
|
||||
|
||||
// Generate or extract the cite key for this record:
|
||||
// NOTE: currently, the following placeholders are not available for citation output:
|
||||
// <:keywords:>, <:issn:>, <:area:>, <:notes:>, <:userKeys:>
|
||||
// if the cite key specification uses one of these placeholders, it will get ignored
|
||||
$citeKey = generateCiteKey($formVars); // function 'generateCiteKey()' is defined in 'include.inc.php'
|
||||
|
||||
if (!empty($citeKey))
|
||||
// Use the custom cite key that's been build according to the user's individual export options:
|
||||
$latexData .= "\\bibitem{" . $citeKey . "} ";
|
||||
else
|
||||
// The '\bibitem' command requires a cite key, which is why we'll include the record's serial number
|
||||
// even when the user's export options specify 'export_cite_keys=no' or 'autogenerate_cite_keys=no':
|
||||
$latexData .= "\\bibitem{" . $row['serial'] . "} ";
|
||||
}
|
||||
|
||||
$latexData .= $recordEncoded . "\n\n"; // create paragraph with encoded record text
|
||||
}
|
||||
}
|
||||
|
||||
if (!preg_match("/type|year/i", $citeOrder))
|
||||
$latexData .= "\\end{thebibliography}\n\n";
|
||||
|
||||
$latexData .= "\\end{document}\n\n";
|
||||
|
||||
return $latexData;
|
||||
}
|
||||
|
||||
// --- END CITATION FORMAT ---
|
||||
?>
|
||||
281
cite/formats/cite_latex_bbl.php
Normal file
281
cite/formats/cite_latex_bbl.php
Normal file
@@ -0,0 +1,281 @@
|
||||
<?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/formats/cite_latex_bbl.php
|
||||
// Repository: $HeadURL$
|
||||
// Author(s): Matthias Steffens <mailto:refbase@extracts.de>
|
||||
//
|
||||
// Created: 20-Jul-07, 19:42
|
||||
// Modified: $Date: 2017-04-13 02:00:18 +0000 (Thu, 13 Apr 2017) $
|
||||
// $Author$
|
||||
// $Revision: 1416 $
|
||||
|
||||
// This is a citation format file (which must reside within the 'cite/formats/' sub-directory of your refbase root directory). It contains a version of
|
||||
// the 'citeRecords()' function that outputs a reference list from selected records in LateX .bbl format, to be used with LaTeX/BibTeX. The .bbl file
|
||||
// generated by refbase can be used as a replacement of the BibTeX-generated .bbl file. Make sure to use "citeOrder=author" when generating the .bbl file.
|
||||
|
||||
// NOTE: In its current incarnation, this script outputs a .bbl variant that is intended to be used with the natbib package.
|
||||
// You may want to adopt the style-specific settings below if necessary. The natbib package is available at:
|
||||
// <http://www.ctan.org/tex-archive/macros/latex/contrib/natbib/>
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
// --- BEGIN CITATION FORMAT ---
|
||||
|
||||
function citeRecords($result, $rowsFound, $query, $queryURL, $showQuery, $showLinks, $rowOffset, $showRows, $previousOffset, $nextOffset, $wrapResults, $citeStyle, $citeOrder, $citeType, $orderBy, $headerMsg, $userID, $viewType)
|
||||
{
|
||||
global $contentTypeCharset; // defined in 'ini.inc.php'
|
||||
|
||||
global $client;
|
||||
|
||||
// The array '$transtab_refbase_latex' contains search & replace patterns for conversion from refbase markup to LaTeX markup & entities.
|
||||
// Converts refbase fontshape markup (italic, bold) into LaTeX commands of the 'textcomp' package, super- and subscript as well as greek
|
||||
// symbols get converted into the respective commands in math mode. You may need to adopt the LaTeX markup to suit your individual needs.
|
||||
global $transtab_refbase_latex; // defined in 'transtab_refbase_latex.inc.php'
|
||||
|
||||
// The arrays '$transtab_latin1_latex' and '$transtab_unicode_latex' provide translation tables for best-effort conversion of higher ASCII
|
||||
// characters from ISO-8859-1 (or Unicode, respectively) to LaTeX entities.
|
||||
global $transtab_latin1_latex; // defined in 'transtab_latin1_latex.inc.php'
|
||||
global $transtab_unicode_latex; // defined in 'transtab_unicode_latex.inc.php'
|
||||
|
||||
|
||||
// --- Begin style-specific settings ----------------------------------
|
||||
|
||||
// NOTE: the given settings are meant to be used with the natbib package;
|
||||
// you'll have to adopt these settings if you'd like to generate a
|
||||
// .bbl file for another style/package
|
||||
|
||||
// 1) Define header with .bst style-specific declarations:
|
||||
// NOTE: since this header is normally inserted by BibTeX from the used .bst style, I'm not sure if there's a variant of this header that's
|
||||
// universally accepted by natbib. So, if necessary adopt it to your needs.
|
||||
// -- by default, we use this header (as inserted by a .bst style that was generated from 'merlin.mbs' via the docstrip utility):
|
||||
$bblHeader = "\\providecommand{\\natexlab}[1]{#1}" . "\n"
|
||||
. "\\providecommand{\\url}[1]{\\texttt{#1}}" . "\n"
|
||||
. "\\providecommand{\\urlprefix}{URL }" . "\n"
|
||||
. "\\providecommand{\\eprint}[2][]{\\url{#2}}" . "\n\n";
|
||||
|
||||
// -- here's another header example (as inserted by 'elsart-harv.bst'):
|
||||
// $bblHeader = "\\expandafter\\ifx\\csname natexlab\\endcsname\\relax\\def\\natexlab#1{#1}\\fi" . "\n"
|
||||
// . "\\expandafter\\ifx\\csname url\\endcsname\\relax" . "\n"
|
||||
// . " \\def\\url#1{\\texttt{#1}}\\fi" . "\n"
|
||||
// . "\\expandafter\\ifx\\csname urlprefix\\endcsname\\relax\\def\\urlprefix{URL }\\fi" . "\n\n";
|
||||
|
||||
// 2) Define name of \bibitem command:
|
||||
$bibItemCommand = "\\bibitem"; // use "\\harvarditem" for the Harvard family of styles
|
||||
|
||||
// 3) Define variables and placeholder strings which together will form the \bibitem option string:
|
||||
|
||||
// -- variables:
|
||||
$betweenShortAuthorsDelim = " & "; // used to connect individual author names in the short author list
|
||||
$betweenFullAuthorsDelim = ", "; // used to connect multiple authors in the full author list
|
||||
$betweenLastAuthorsDelim = " & "; // used to connect the second-to-last author with the last author in the full author list
|
||||
$etalIdentifierString = " et~al."; // appended to the first author's last name if the record's number of authors exceeds the number given in '$maxAuthorCountInShortAuthorList'
|
||||
$maxAuthorCountInShortAuthorList = 2; // maximum number of authors to be used in the short author list
|
||||
|
||||
// -- placeholder strings:
|
||||
// (please see the refbase online documentation for more info about placeholders and their syntax: <http://placeholders.refbase.net/>)
|
||||
$year = "<:year[4]:>"; // year format, e.g. "1990"
|
||||
$shortAuthorList = "<:authors[" . $maxAuthorCountInShortAuthorList . "|" . $betweenShortAuthorsDelim . "|" . $etalIdentifierString . "]:>"; // format of the short author list which is used as text citation, e.g. "Jones", "Jones and Baker" or "Jones et al."
|
||||
$fullAuthorList = "<:authors[0|_#_<>_~_|]:>"; // format of the full author list, e.g. "Jones, Baker, and Williams"
|
||||
// NOTE: in the above placeholder string, we use the string "_#_<>_~_" as author delimiter which allows us to uniquely identify that delimiter again below, and replace it with the contents of either '$betweenFullAuthorsDelim' or '$betweenLastAuthorsDelim' (depending on its position)
|
||||
|
||||
// 4) Define \bibitem option format:
|
||||
|
||||
// -- extended natbib 5.3 style:
|
||||
$bibItemOptionShort = "[{" . $shortAuthorList . "}(" . $year . ")" . "]"; // e.g.: \bibitem[{Jones et al.}(1990)]{key}...
|
||||
$bibItemOptionFull = "[{" . $shortAuthorList . "}(" . $year . "){" . $fullAuthorList . "}]"; // e.g.: \bibitem[{Jones et al.}(1990){Jones, Baker, and Williams}]{key}...
|
||||
// NOTE: since the author lists may contain parentheses, we need to enclose them in curly brackets to work around a natbib limitation
|
||||
|
||||
// -- native natbib style:
|
||||
// $bibItemOptionShort = "[" . $shortAuthorList . "(" . $year . ")" . "]"; // e.g.: \bibitem[Jones et al.(1990)]{key}...
|
||||
// $bibItemOptionFull = "";
|
||||
|
||||
// -- apalike style:
|
||||
// $bibItemOptionShort = "[" . $shortAuthorList . ", " . $year . "]"; // e.g.: \bibitem[Jones et al., 1990]{key}...
|
||||
// $bibItemOptionFull = "";
|
||||
|
||||
// -- newapa or chicago styles:
|
||||
// $bibItemOptionShort = "[\\protect\\citeauthoryear{" . $fullAuthorList . "}{" . $shortAuthorList . "}{" . $year . "}" . "]"; // this assumes that it's not allowed to omit the full author list, though I dunno)
|
||||
// $bibItemOptionFull = "[\\protect\\citeauthoryear{" . $fullAuthorList . "}{" . $shortAuthorList . "}{" . $year . "}" . "]"; // e.g.: \bibitem[\protect\citeauthoryear{Jones, Baker, and Williams}{Jones et al.}{1990}]{key}...
|
||||
|
||||
// -- named style:
|
||||
// $bibItemOptionShort = "[\\protect\\citeauthoryear{" . $shortAuthorList . "}{" . $year . "}" . "]"; // e.g.: \bibitem[\protect\citeauthoryear{Jones et al.}{1990}]{key}...
|
||||
// $bibItemOptionFull = "";
|
||||
|
||||
// -- astron style:
|
||||
// $bibItemOptionShort = "[\\protect\\astroncite{" . $shortAuthorList . "}{" . $year . "}" . "]"; // e.g.: \bibitem[\protect\astroncite{Jones et al.}{1990}]{key}...
|
||||
// $bibItemOptionFull = "";
|
||||
|
||||
// -- authordate style:
|
||||
// $bibItemOptionShort = "[\\protect\\citename{" . $shortAuthorList . ", }" . $year . "]"; // e.g.: \bibitem[\protect\citename{Jones et al., }1990]{key}...
|
||||
// $bibItemOptionFull = "";
|
||||
|
||||
// -- harvard style:
|
||||
// $bibItemOptionShort = "[" . $shortAuthorList . "]{" . $fullAuthorList . "}{" . $year . "}"; // this assumes that it's not allowed to omit the full author list, though I dunno)
|
||||
// $bibItemOptionFull = "[" . $shortAuthorList . "]{" . $fullAuthorList . "}{" . $year . "}"; // e.g.: \harvarditem[Jones et al.]{Jones, Baker, and Williams}{1990}{key}...
|
||||
|
||||
// 5) Define deduplication prefix and suffix strings:
|
||||
// Identical text citation strings get uniquified by appending letters to the year, e.g. duplicate occurrences
|
||||
// of "Jones et al. 1990" should become "Jones et al. 1990a" and "Jones et al. 1990b" in the final output.
|
||||
// These prefix/suffix strings will be inserted before/after the deduplication letter:
|
||||
$dedupPrefix = "{\\natexlab{"; // these prefix/suffix strings are required by natbib; if any custom command (such as '\natexlab') is used, make sure that the command is also defined above in variable '$bblHeader'
|
||||
$dedupSuffix = "}}";
|
||||
|
||||
// --- End style-specific settings ------------------------------------
|
||||
|
||||
|
||||
// Initialize array variables:
|
||||
$yearsArray = array();
|
||||
$typeTitlesArray = array();
|
||||
$bibItemsArray = array();
|
||||
|
||||
// Define inline text markup to be used by the 'citeRecord()' function:
|
||||
$markupPatternsArray = array("bold-prefix" => "\\textbf{",
|
||||
"bold-suffix" => "}",
|
||||
"italic-prefix" => "\\textit{",
|
||||
"italic-suffix" => "}",
|
||||
"underline-prefix" => "\\ul{", // the '\ul' command requires '\usepackage{soul}'
|
||||
"underline-suffix" => "}",
|
||||
"endash" => "--", // or use '{\\textendash}'
|
||||
"emdash" => "---", // or use '{\\textemdash}'
|
||||
"ampersand" => "&", // conversion of ampersands is done below, after the citation has been generated
|
||||
"double-quote" => '"',
|
||||
"double-quote-left" => "{\\textquotedblleft}",
|
||||
"double-quote-right" => "{\\textquotedblright}",
|
||||
"single-quote" => "'", // same as for ampersands
|
||||
"single-quote-left" => "{\\textquoteleft}",
|
||||
"single-quote-right" => "{\\textquoteright}",
|
||||
"less-than" => "<",
|
||||
"greater-than" => ">",
|
||||
"newline" => "\n\n"
|
||||
);
|
||||
|
||||
// Defines search & replace 'actions' that will be applied upon LaTeX output to all those refbase fields that are listed
|
||||
// in the corresponding 'fields' element:
|
||||
$latexSearchReplaceActionsArray = array(
|
||||
array('fields' => array("title", "publication", "abbrev_journal", "address", "keywords", "abstract", "orig_title", "series_title", "abbrev_series_title", "notes"),
|
||||
'actions' => $transtab_refbase_latex
|
||||
)
|
||||
);
|
||||
|
||||
// For CLI queries, we'll allow paging thru the result set, i.e. we honour the values of the CLI options '-S|--start' ('$rowOffset')
|
||||
// and '-R|--rows' ('$showRows') ('$rowOffset' and '$showRows' are re-assigned in function 'seekInMySQLResultsToOffset()' in 'include.inc.php')
|
||||
if (preg_match("/^cli/i", $client)) // if the query originated from a command line client such as the "refbase" CLI client ("cli-refbase-1.0")
|
||||
$showMaxRows = $showRows; // show only rows up to the value given in '$showRows'
|
||||
else
|
||||
$showMaxRows = $rowsFound; // otherwise show all rows
|
||||
|
||||
|
||||
// Setup the basic .bbl document structure:
|
||||
$latexData = "\\begin{thebibliography}{" . $showMaxRows . "}\n\n";
|
||||
|
||||
// Add header with .bst style-specific declarations:
|
||||
$latexData .= $bblHeader;
|
||||
|
||||
|
||||
// LOOP OVER EACH RECORD:
|
||||
// Fetch one page of results (or less if on the last page)
|
||||
// (i.e., upto the limit specified in $showMaxRows) fetch a row into the $row array and ...
|
||||
for ($rowCounter=0; (($rowCounter < $showMaxRows) && ($row = @ mysqli_fetch_array($result))); $rowCounter++)
|
||||
{
|
||||
foreach ($row as $rowFieldName => $rowFieldValue)
|
||||
// Apply search & replace 'actions' to all fields that are listed in the 'fields' element of the arrays contained in '$latexSearchReplaceActionsArray':
|
||||
foreach ($latexSearchReplaceActionsArray as $fieldActionsArray)
|
||||
if (in_array($rowFieldName, $fieldActionsArray['fields']))
|
||||
$row[$rowFieldName] = searchReplaceText($fieldActionsArray['actions'], $row[$rowFieldName], true); // function 'searchReplaceText()' is defined in 'include.inc.php'
|
||||
|
||||
|
||||
// Order attributes according to the chosen output style & record type:
|
||||
$record = citeRecord($row, $citeStyle, $citeType, $markupPatternsArray, false); // function 'citeRecord()' is defined in the citation style file given in '$citeStyleFile' (which, in turn, must reside in the 'cite' directory of the refbase root directory), see function 'generateCitations()'
|
||||
|
||||
|
||||
// Print out the current record:
|
||||
if (!empty($record)) // unless the record buffer is empty...
|
||||
{
|
||||
// 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 'generateCiteKey()')
|
||||
// (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'
|
||||
|
||||
// Generate or extract the cite key for this record:
|
||||
// NOTE: currently, the following placeholders are not available for citation output:
|
||||
// <:keywords:>, <:issn:>, <:area:>, <:notes:>, <:userKeys:>
|
||||
// if the cite key specification uses one of these placeholders, it will get ignored
|
||||
$citeKey = generateCiteKey($formVars); // function 'generateCiteKey()' is defined in 'include.inc.php'
|
||||
|
||||
// The '\bibitem' command requires a cite key, which is why we'll include the record's serial number
|
||||
// even when the user's export options specify 'export_cite_keys=no' or 'autogenerate_cite_keys=no':
|
||||
// NOTE: maybe we should always generate a cite key here, even if 'export_cite_keys=no' or 'autogenerate_cite_keys=no'??
|
||||
if (empty($citeKey))
|
||||
$citeKey = $row['serial'];
|
||||
|
||||
// Generate the \bibitem option string that's used to build the proper text citation:
|
||||
$bibItemOptionShortString = parsePlaceholderString($formVars, $bibItemOptionShort, "<:authors[2| and | et~al.]:><(:year:)>"); // function 'parsePlaceholderString()' is defined in 'include.inc.php'
|
||||
|
||||
if (!empty($bibItemOptionFull) AND preg_match("/^[^;]+(;[^;]+){" . $maxAuthorCountInShortAuthorList . "}/", $row['author'])) // if the 'author' field does contain more authors as specified in '$maxAuthorCountInShortAuthorList'
|
||||
{
|
||||
// include full author list:
|
||||
$bibItemOptionString = parsePlaceholderString($formVars, $bibItemOptionFull, "<:authors[2| and | et~al.]:><(:year:)><:authors[0|, |]:>");
|
||||
$bibItemOptionString = preg_replace("/_#_<>_~_(?!.*?_#_<>_~_)/", $betweenLastAuthorsDelim, $bibItemOptionString); // replace last occurrence of "_#_<>_~_"
|
||||
$bibItemOptionString = preg_replace("/_#_<>_~_/", $betweenFullAuthorsDelim, $bibItemOptionString); // replace all other occurrences of "_#_<>_~_"
|
||||
}
|
||||
else // only include short author list:
|
||||
$bibItemOptionString = $bibItemOptionShortString;
|
||||
|
||||
// In case of duplicate text citation strings, append a letter to the year in the \bibitem option string as well as in the formatted reference:
|
||||
// NOTE: - this is not fool proof and currently only works if there are no more than 26 duplicate text citations (letters a-z)
|
||||
// - the below replace actions get triggered on the first four-digit number that happens to be identical to the record's year, but depending on the reference format, this may not be the actual year of the reference but some other number!
|
||||
for ($i=0; isset($bibItemsArray[$bibItemOptionShortString]); $i++)
|
||||
{
|
||||
// Update the existing \bibitem entry (that has an identical text citation string) and append an "a" to it's year items:
|
||||
if ($i == 0)
|
||||
{
|
||||
$dedupPrefixQuoted = preg_quote($dedupPrefix, "/"); // escape meta characters (including '/' that is used as delimiter for the PCRE replace functions below and which gets passed as second argument)
|
||||
$dedupSuffixQuoted = preg_quote($dedupSuffix, "/");
|
||||
|
||||
$oldBibItemOptionShortString = preg_replace("/^\[(.+)\]$/", "\\1", $bibItemOptionShortString); // remove square brackets from short \bibitem option string (which is required for the subsequent 'str_replace()' action to work with short and full option strings)
|
||||
$newBibItemOptionShortString = preg_replace("/(" . $row['year'] . ")(" . $dedupPrefixQuoted . "[a-z]*" . $dedupSuffixQuoted . ")*/", "\\1" . $dedupPrefix . "a" . $dedupSuffix, $oldBibItemOptionShortString, 1);
|
||||
$bibItemsArray[$bibItemOptionShortString] = str_replace($oldBibItemOptionShortString, $newBibItemOptionShortString, $bibItemsArray[$bibItemOptionShortString]);
|
||||
$bibItemsArray[$bibItemOptionShortString] = preg_replace("/(" . $row['year'] . ")(" . $dedupPrefixQuoted . "[a-z]*" . $dedupSuffixQuoted . ")*(?!.*?" . $row['year'] . ")/", "\\1" . $dedupPrefix . "a" . $dedupSuffix, $bibItemsArray[$bibItemOptionShortString], 1); // note that this will fail if the formatted reference contains a number after the year that is identical to the year!
|
||||
}
|
||||
|
||||
// Append a letter to the year items of the current \bibitem entry:
|
||||
$bibItemOptionShortString = preg_replace("/(" . $row['year'] . ")(" . $dedupPrefixQuoted . "[a-z]*" . $dedupSuffixQuoted . ")*/e", "'\\1$dedupPrefix'.chr(98 + $i).'$dedupSuffix'", $bibItemOptionShortString, 1); // the 'e' modifier allows to execute PHP code within the replacement pattern
|
||||
$bibItemOptionString = preg_replace("/(" . $row['year'] . ")(" . $dedupPrefixQuoted . "[a-z]*" . $dedupSuffixQuoted . ")*/e", "'\\1$dedupPrefix'.chr(98 + $i).'$dedupSuffix'", $bibItemOptionString, 1);
|
||||
$record = preg_replace("/(" . $row['year'] . ")(" . $dedupPrefixQuoted . "[a-z]*" . $dedupSuffixQuoted . ")*/e", "'\\1$dedupPrefix'.chr(98 + $i).'$dedupSuffix'", $record, 1);
|
||||
}
|
||||
|
||||
|
||||
// Attempt to convert higher ASCII chars (i.e., characters with an ASCII value of >= 128) to their corresponding LaTeX entities:
|
||||
if ($contentTypeCharset == "UTF-8")
|
||||
$recordEncoded = searchReplaceText($transtab_unicode_latex, $record, false); // function 'searchReplaceText()' is defined in 'include.inc.php'
|
||||
else
|
||||
$recordEncoded = searchReplaceText($transtab_latin1_latex, $record, false);
|
||||
|
||||
// We have to make sure that the \bibitem option string also contains proper LaTeX entities:
|
||||
if ($contentTypeCharset == "UTF-8")
|
||||
$bibItemOptionStringEncoded = searchReplaceText($transtab_unicode_latex, $bibItemOptionString, false);
|
||||
else
|
||||
$bibItemOptionStringEncoded = searchReplaceText($transtab_latin1_latex, $bibItemOptionString, false);
|
||||
|
||||
|
||||
// Copy the current \bibitem entry to the array of generated \bibitem entries:
|
||||
$bibItemsArray[$bibItemOptionShortString] = $bibItemCommand . $bibItemOptionStringEncoded . "{" . $citeKey . "} " . $recordEncoded;
|
||||
}
|
||||
}
|
||||
|
||||
$latexData .= implode("\n\n", $bibItemsArray) . "\n\n";
|
||||
|
||||
$latexData .= "\\end{thebibliography}\n\n";
|
||||
|
||||
return $latexData;
|
||||
}
|
||||
|
||||
// --- END CITATION FORMAT ---
|
||||
?>
|
||||
147
cite/formats/cite_markdown.php
Normal file
147
cite/formats/cite_markdown.php
Normal file
@@ -0,0 +1,147 @@
|
||||
<?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/formats/cite_markdown.php
|
||||
// Repository: $HeadURL: file:///svn/p/refbase/code/branches/bleeding-edge/cite/formats/cite_markdown.php $
|
||||
// Author(s): Matthias Steffens <mailto:refbase@extracts.de>
|
||||
//
|
||||
// Created: 10-Jun-06, 02:58
|
||||
// Modified: $Date: 2017-04-13 02:00:18 +0000 (Thu, 13 Apr 2017) $
|
||||
// $Author: karnesky $
|
||||
// $Revision: 1416 $
|
||||
|
||||
// This is a citation format file (which must reside within the 'cite/formats/' sub-directory of your refbase root directory). It contains a
|
||||
// version of the 'citeRecords()' function that outputs a reference list from selected records in Markdown format. Markdown is a plain text
|
||||
// formatting syntax as well as a software tool that converts the plain text formatting back to HTML (<http://daringfireball.net/projects/markdown/>)
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
// --- BEGIN CITATION FORMAT ---
|
||||
|
||||
function citeRecords($result, $rowsFound, $query, $queryURL, $showQuery, $showLinks, $rowOffset, $showRows, $previousOffset, $nextOffset, $wrapResults, $citeStyle, $citeOrder, $citeType, $orderBy, $headerMsg, $userID, $viewType)
|
||||
{
|
||||
global $contentTypeCharset; // defined in 'ini.inc.php'
|
||||
|
||||
global $client;
|
||||
|
||||
// The array '$transtab_refbase_markdown' contains search & replace patterns for conversion from refbase markup to Markdown markup & entities
|
||||
global $transtab_refbase_markdown; // defined in 'transtab_refbase_markdown.inc.php'
|
||||
|
||||
$markdownData = ""; // make sure that our buffer variable is empty
|
||||
|
||||
// Header:
|
||||
if (!empty($headerMsg))
|
||||
{
|
||||
// Decode any HTML entities:
|
||||
// (these may occur in the header message e.g. if the user's preferred display language is not English but German or French, etc)
|
||||
$headerMsg = decodeHTML($contentTypeCharset, $headerMsg); // function 'decodeHTML()' is defined in 'include.inc.php', and '$contentTypeCharset' is defined in 'ini.inc.php'
|
||||
|
||||
// Convert refbase markup in the header message into appropriate Markdown markup & entities:
|
||||
$headerMsg = searchReplaceText($transtab_refbase_markdown, $headerMsg, true); // function 'searchReplaceText()' is defined in 'include.inc.php'
|
||||
|
||||
$markdownData .= "# $headerMsg #\n\n";
|
||||
}
|
||||
|
||||
// Initialize array variables:
|
||||
$yearsArray = array();
|
||||
$typeTitlesArray = array();
|
||||
|
||||
// Define inline text markup to be used by the 'citeRecord()' function:
|
||||
$markupPatternsArray = array("bold-prefix" => "**",
|
||||
"bold-suffix" => "**",
|
||||
"italic-prefix" => "_",
|
||||
"italic-suffix" => "_",
|
||||
"underline-prefix" => "<u>",
|
||||
"underline-suffix" => "</u>",
|
||||
"endash" => "–",
|
||||
"emdash" => "—",
|
||||
"ampersand" => "&",
|
||||
"double-quote" => '"',
|
||||
"double-quote-left" => "“",
|
||||
"double-quote-right" => "”",
|
||||
"single-quote" => "'",
|
||||
"single-quote-left" => "‘",
|
||||
"single-quote-right" => "’",
|
||||
"less-than" => "<",
|
||||
"greater-than" => ">",
|
||||
"newline" => " \n"
|
||||
);
|
||||
|
||||
// Defines search & replace 'actions' that will be applied upon Markdown output to all those refbase fields that are listed
|
||||
// in the corresponding 'fields' element:
|
||||
$markdownSearchReplaceActionsArray = array(
|
||||
array('fields' => array("title", "publication", "abbrev_journal", "address", "keywords", "abstract", "orig_title", "series_title", "abbrev_series_title", "notes"),
|
||||
'actions' => $transtab_refbase_markdown
|
||||
)
|
||||
);
|
||||
|
||||
// For CLI queries, we'll allow paging thru the result set, i.e. we honour the values of the CLI options '-S|--start' ('$rowOffset')
|
||||
// and '-R|--rows' ('$showRows') ('$rowOffset' and '$showRows' are re-assigned in function 'seekInMySQLResultsToOffset()' in 'include.inc.php')
|
||||
if (preg_match("/^cli/i", $client)) // if the query originated from a command line client such as the "refbase" CLI client ("cli-refbase-1.0")
|
||||
$showMaxRows = $showRows; // show only rows up to the value given in '$showRows'
|
||||
else
|
||||
$showMaxRows = $rowsFound; // otherwise show all rows
|
||||
|
||||
|
||||
// LOOP OVER EACH RECORD:
|
||||
// Fetch one page of results (or less if on the last page)
|
||||
// (i.e., upto the limit specified in $showMaxRows) fetch a row into the $row array and ...
|
||||
for ($rowCounter=0; (($rowCounter < $showMaxRows) && ($row = @ mysqli_fetch_array($result))); $rowCounter++)
|
||||
{
|
||||
foreach ($row as $rowFieldName => $rowFieldValue)
|
||||
// Apply search & replace 'actions' to all fields that are listed in the 'fields' element of the arrays contained in '$markdownSearchReplaceActionsArray':
|
||||
foreach ($markdownSearchReplaceActionsArray as $fieldActionsArray)
|
||||
if (in_array($rowFieldName, $fieldActionsArray['fields']))
|
||||
$row[$rowFieldName] = searchReplaceText($fieldActionsArray['actions'], $row[$rowFieldName], true); // function 'searchReplaceText()' is defined in 'include.inc.php'
|
||||
|
||||
|
||||
// Order attributes according to the chosen output style & record type:
|
||||
$record = citeRecord($row, $citeStyle, $citeType, $markupPatternsArray, false); // function 'citeRecord()' is defined in the citation style file given in '$citeStyleFile' (which, in turn, must reside in the 'cite' directory of the refbase root directory), see function 'generateCitations()'
|
||||
|
||||
|
||||
// Print out the current record:
|
||||
if (!empty($record)) // unless the record buffer is empty...
|
||||
{
|
||||
// Print any section heading(s):
|
||||
if (preg_match("/year|type/i", $citeOrder))
|
||||
{
|
||||
$headingPrefix = "";
|
||||
$headingSuffix = "";
|
||||
|
||||
if (!empty($headerMsg)) // if there's a custom header message available, we decrease the heading level of sections & subsections by one (since the header message has level 1)
|
||||
{
|
||||
$sectionMarkupPrefix = "## ";
|
||||
$sectionMarkupSuffix = " ##\n\n";
|
||||
$subSectionMarkupPrefix = "### ";
|
||||
$subSectionMarkupSuffix = " ###\n\n";
|
||||
}
|
||||
else // no custom header message given
|
||||
{
|
||||
$sectionMarkupPrefix = "# ";
|
||||
$sectionMarkupSuffix = " #\n\n";
|
||||
$subSectionMarkupPrefix = "## ";
|
||||
$subSectionMarkupSuffix = " ##\n\n";
|
||||
}
|
||||
|
||||
list($yearsArray, $typeTitlesArray, $sectionHeading) = generateSectionHeading($yearsArray, $typeTitlesArray, $row, $citeOrder, $headingPrefix, $headingSuffix, $sectionMarkupPrefix, $sectionMarkupSuffix, $subSectionMarkupPrefix, $subSectionMarkupSuffix); // function 'generateSectionHeading()' is defined in 'cite.inc.php'
|
||||
|
||||
$markdownData .= $sectionHeading;
|
||||
}
|
||||
|
||||
// Write plain TEXT paragraph:
|
||||
$markdownData .= $record . "\n\n"; // create paragraph with encoded record text
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return $markdownData;
|
||||
}
|
||||
|
||||
// --- END CITATION FORMAT ---
|
||||
?>
|
||||
260
cite/formats/cite_pdf.php
Normal file
260
cite/formats/cite_pdf.php
Normal file
@@ -0,0 +1,260 @@
|
||||
<?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/formats/cite_pdf.php
|
||||
// Repository: $HeadURL: file:///svn/p/refbase/code/branches/bleeding-edge/cite/formats/cite_pdf.php $
|
||||
// Author(s): Matthias Steffens <mailto:refbase@extracts.de>
|
||||
//
|
||||
// Created: 10-Jun-06, 02:04
|
||||
// Modified: $Date: 2017-04-13 02:00:18 +0000 (Thu, 13 Apr 2017) $
|
||||
// $Author: karnesky $
|
||||
// $Revision: 1416 $
|
||||
|
||||
// This is a citation format file (which must reside within the 'cite/formats/' sub-directory of your refbase root directory). It contains a
|
||||
// version of the 'citeRecords()' function that outputs a reference list from selected records in PDF format.
|
||||
// PDF format specification is available at <http://partners.adobe.com/public/developer/pdf/index_reference.html>, more info at <http://en.wikipedia.org/wiki/PDF>
|
||||
|
||||
// LIMITATIONS: - export of cited references to PDF does currently only work with a latin1 database but not with UTF-8 (since I don't know how to write Unicode characters to PDF)
|
||||
// - there's currently no conversion of en-/emdashes or markup for greek letters and super-/subscript (reasons are that I don't know how to print chars by code number)
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
|
||||
// Include the pdf-php package
|
||||
require_once 'includes/classes/org/pdf-php/class.ezpdf.php';
|
||||
|
||||
|
||||
// --- BEGIN CITATION FORMAT ---
|
||||
|
||||
// Requires the "PHP Pdf creation (pdf-php)" Package (by Wayne Munro, R&OS Ltd), which is available
|
||||
// under a public domain licence: <http://www.ros.co.nz/pdf>
|
||||
|
||||
function citeRecords($result, $rowsFound, $query, $queryURL, $showQuery, $showLinks, $rowOffset, $showRows, $previousOffset, $nextOffset, $wrapResults, $citeStyle, $citeOrder, $citeType, $orderBy, $headerMsg, $userID, $viewType)
|
||||
{
|
||||
global $officialDatabaseName; // these variables are defined in 'ini.inc.php'
|
||||
global $databaseBaseURL;
|
||||
global $contentTypeCharset;
|
||||
global $pdfPageSize;
|
||||
|
||||
global $client;
|
||||
|
||||
// The array '$transtab_refbase_pdf' contains search & replace patterns for conversion from refbase markup to PDf markup & entities
|
||||
global $transtab_refbase_pdf; // defined in 'transtab_refbase_pdf.inc.php'
|
||||
|
||||
// Initialize array variables:
|
||||
$yearsArray = array();
|
||||
$typeTitlesArray = array();
|
||||
|
||||
// Define inline text markup to be used by the 'citeRecord()' function:
|
||||
$markupPatternsArray = array("bold-prefix" => "<b>", // html-style fontshape markup is recognized and converted by the pdf-php package
|
||||
"bold-suffix" => "</b>",
|
||||
"italic-prefix" => "<i>",
|
||||
"italic-suffix" => "</i>",
|
||||
"underline-prefix" => "<u>",
|
||||
"underline-suffix" => "</u>",
|
||||
"endash" => "<EFBFBD>", // see notes for "*-quote-*" below; we could also use "<22>" here
|
||||
"emdash" => "<EFBFBD>", // an emdash might also be faked with two endashes ("<22><>")
|
||||
"ampersand" => "&",
|
||||
"double-quote" => '"',
|
||||
"double-quote-left" => "<EFBFBD>", // AFAIK, the ISO-8859-1 (latin1) character set does not have any curly quotes,
|
||||
"double-quote-right" => "<EFBFBD>", // see e.g. <http://www.ramsch.org/martin/uni/fmi-hp/iso8859-1.html>; but ...
|
||||
"single-quote" => "'",
|
||||
"single-quote-left" => "<EFBFBD>", // ... since the pdf-php package let's you replace an (unused) character for any other PostScript char (see below), we use
|
||||
"single-quote-right" => "<EFBFBD>", // the '$diff' array below to replace e.g. "<22>" with a single left curly quote and "<22>" with a single right curly quote, etc
|
||||
"less-than" => "<",
|
||||
"greater-than" => ">",
|
||||
"newline" => "\n"
|
||||
);
|
||||
|
||||
// Defines search & replace 'actions' that will be applied upon PDF output to all those refbase fields that are listed
|
||||
// in the corresponding 'fields' element:
|
||||
$pdfSearchReplaceActionsArray = array(
|
||||
array('fields' => array("title", "publication", "abbrev_journal", "address", "keywords", "abstract", "orig_title", "series_title", "abbrev_series_title", "notes"),
|
||||
'actions' => $transtab_refbase_pdf
|
||||
)
|
||||
);
|
||||
|
||||
// For CLI queries, we'll allow paging thru the result set, i.e. we honour the values of the CLI options '-S|--start' ('$rowOffset')
|
||||
// and '-R|--rows' ('$showRows') ('$rowOffset' and '$showRows' are re-assigned in function 'seekInMySQLResultsToOffset()' in 'include.inc.php')
|
||||
if (preg_match("/^cli/i", $client)) // if the query originated from a command line client such as the "refbase" CLI client ("cli-refbase-1.0")
|
||||
$showMaxRows = $showRows; // show only rows up to the value given in '$showRows'
|
||||
else
|
||||
$showMaxRows = $rowsFound; // otherwise show all rows
|
||||
|
||||
|
||||
// Setup the basic PDF document structure (PDF functions defined in 'class.ezpdf.php'):
|
||||
$pdf = new Cezpdf($pdfPageSize, 'portrait'); // initialize PDF object
|
||||
|
||||
if (!empty($headerMsg)) // adjust upper page margin if a custom header message was given
|
||||
$pageMarginTop = "70";
|
||||
else
|
||||
$pageMarginTop = "50";
|
||||
|
||||
$pdf -> ezSetMargins($pageMarginTop, 70, 50, 50); // set document margins (top, bottom, left, right)
|
||||
|
||||
// Set fonts:
|
||||
$headingFont = 'includes/classes/org/pdf-php/fonts/Helvetica.afm';
|
||||
$textBodyFont = 'includes/classes/org/pdf-php/fonts/Times-Roman.afm';
|
||||
|
||||
// Re-map character numbers from the 0->255 range to a named character, i.e. replace an (unused) character for any other PostScript char;
|
||||
// see the PDF reference for a list of supported PostScript/PDF character names: <http://www.adobe.com/devnet/pdf/pdf_reference.html>;
|
||||
// for the decimal code numbers of the ISO-8859-1 character set, see e.g.: <http://www.ramsch.org/martin/uni/fmi-hp/iso8859-1.html>
|
||||
$diff = array(
|
||||
166 => 'endash', // "<22>"
|
||||
169 => 'emdash', // "<22>"
|
||||
170 => 'quotedblleft', // "<22>"
|
||||
172 => 'quotedblright', // "<22>"
|
||||
174 => 'quoteleft', // "<22>"
|
||||
182 => 'quoteright' // "<22>"
|
||||
);
|
||||
|
||||
// Select a font:
|
||||
$pdf->selectFont($textBodyFont, array('encoding' => 'WinAnsiEncoding', 'differences' => $diff));
|
||||
|
||||
$pdf->openHere('Fit');
|
||||
|
||||
// Put a footer (and optionally a header) on all the pages:
|
||||
$all = $pdf->openObject(); // start an independent object; all further writes to a page will actually go into this object, until a 'closeObject()' call is made
|
||||
$pdf->saveState();
|
||||
|
||||
$pdf->setStrokeColor(0, 0, 0, 1); // set line color
|
||||
$pdf->setLineStyle(0.5); // set line width
|
||||
|
||||
// - print header line and header message at the specified x/y position:
|
||||
if (!empty($headerMsg)) // if a custom header message was given
|
||||
{
|
||||
// Remove any colon (":") from end of header message:
|
||||
$headerMsg = trimTextPattern($headerMsg, ":", false, true); // function 'trimTextPattern()' is defined in 'include.inc.php'
|
||||
|
||||
// Decode any HTML entities:
|
||||
// (these may occur in the header message e.g. if the user's preferred display language is not English but German or French, etc)
|
||||
$headerMsg = decodeHTML($contentTypeCharset, $headerMsg); // function 'decodeHTML()' is defined in 'include.inc.php', and '$contentTypeCharset' is defined in 'ini.inc.php'
|
||||
|
||||
// Convert refbase markup in the header message into appropriate PDF markup & entities:
|
||||
$headerMsg = searchReplaceText($transtab_refbase_pdf, $headerMsg, true); // function 'searchReplaceText()' is defined in 'include.inc.php'
|
||||
|
||||
if ($pdfPageSize == 'a4') // page dimensions 'a4': 595.28 x 841.89 pt.
|
||||
{
|
||||
$pdf->line(20, 800, 575, 800);
|
||||
$pdf->addText(50, 805, 10, $headerMsg);
|
||||
}
|
||||
elseif ($pdfPageSize == 'letter') // page dimensions 'letter': 612 x 792 pt.
|
||||
{
|
||||
$pdf->line(20, 750, 592, 750);
|
||||
$pdf->addText(50, 755, 10, $headerMsg);
|
||||
}
|
||||
}
|
||||
|
||||
// - print footer line and footer text at the specified x/y position:
|
||||
if ($pdfPageSize == 'a4')
|
||||
{
|
||||
$pdf->line(20, 40, 575, 40);
|
||||
$pdf->addText(50, 28, 10, $officialDatabaseName . ' <20> ' . $databaseBaseURL); // w.r.t. the endash, see notes at '$markupPatternsArray' and '$diff' above
|
||||
}
|
||||
elseif ($pdfPageSize == 'letter')
|
||||
{
|
||||
$pdf->line(20, 40, 592, 40);
|
||||
$pdf->addText(50, 28, 10, $officialDatabaseName . ' <20> ' . $databaseBaseURL);
|
||||
}
|
||||
|
||||
$pdf->restoreState();
|
||||
$pdf->closeObject(); // close the currently open object; further writes will now go to the current page
|
||||
$pdf->addObject($all, 'all'); // note that object can be told to appear on just odd or even pages by changing 'all' to 'odd' or 'even'
|
||||
|
||||
// Start printing page numbers:
|
||||
if ($pdfPageSize == 'a4')
|
||||
{
|
||||
$pdf->ezStartPageNumbers(550, 28, 10, '', '', 1);
|
||||
}
|
||||
elseif ($pdfPageSize == 'letter')
|
||||
{
|
||||
$pdf->ezStartPageNumbers(567, 28, 10, '', '', 1);
|
||||
}
|
||||
|
||||
|
||||
// LOOP OVER EACH RECORD:
|
||||
// Fetch one page of results (or less if on the last page)
|
||||
// (i.e., upto the limit specified in $showMaxRows) fetch a row into the $row array and ...
|
||||
for ($rowCounter=0; (($rowCounter < $showMaxRows) && ($row = @ mysqli_fetch_array($result))); $rowCounter++)
|
||||
{
|
||||
foreach ($row as $rowFieldName => $rowFieldValue)
|
||||
// Apply search & replace 'actions' to all fields that are listed in the 'fields' element of the arrays contained in '$pdfSearchReplaceActionsArray':
|
||||
foreach ($pdfSearchReplaceActionsArray as $fieldActionsArray)
|
||||
if (in_array($rowFieldName, $fieldActionsArray['fields']))
|
||||
$row[$rowFieldName] = searchReplaceText($fieldActionsArray['actions'], $row[$rowFieldName], true); // function 'searchReplaceText()' is defined in 'include.inc.php'
|
||||
|
||||
|
||||
// Order attributes according to the chosen output style & record type:
|
||||
$record = citeRecord($row, $citeStyle, $citeType, $markupPatternsArray, false); // function 'citeRecord()' is defined in the citation style file given in '$citeStyleFile' (which, in turn, must reside in the 'cite' directory of the refbase root directory), see function 'generateCitations()'
|
||||
|
||||
|
||||
// Print out the current record:
|
||||
if (!empty($record)) // unless the record buffer is empty...
|
||||
{
|
||||
// Print any section heading(s):
|
||||
if (preg_match("/year|type/i", $citeOrder))
|
||||
{
|
||||
$headingPrefix = "";
|
||||
$headingSuffix = "";
|
||||
$sectionMarkupPrefix = "<b>";
|
||||
$sectionMarkupSuffix = "</b>\n";
|
||||
$subSectionMarkupPrefix = "";
|
||||
$subSectionMarkupSuffix = "\n";
|
||||
|
||||
if ($citeOrder == "type-year")
|
||||
$sectionMarkupSuffix .= "\n";
|
||||
|
||||
list($yearsArray, $typeTitlesArray, $sectionHeading) = generateSectionHeading($yearsArray, $typeTitlesArray, $row, $citeOrder, $headingPrefix, $headingSuffix, $sectionMarkupPrefix, $sectionMarkupSuffix, $subSectionMarkupPrefix, $subSectionMarkupSuffix); // function 'generateSectionHeading()' is defined in 'cite.inc.php'
|
||||
|
||||
if (!empty($sectionHeading))
|
||||
{
|
||||
$pdf->selectFont($headingFont, array('encoding' => 'WinAnsiEncoding', 'differences' => $diff)); // use Helvetica
|
||||
$pdf->ezText($sectionHeading, '14', array('justification' => 'left')); // create heading using a font size of 14pt
|
||||
}
|
||||
}
|
||||
|
||||
// If character encoding is not UTF-8 already, convert record text to UTF-8:
|
||||
// if ($contentTypeCharset != "UTF-8")
|
||||
// $record = convertToCharacterEncoding("UTF-8", "IGNORE", $record); // function 'convertToCharacterEncoding()' is defined in 'include.inc.php'
|
||||
|
||||
// NOTE: Export of cited references to PDF does currently only work with a latin1 database but not with UTF-8 (since I don't know how to write Unicode characters to PDF).
|
||||
// As a workaround, we could convert UTF-8 characters to latin1 if possible (and omit any other higher ASCII chars)
|
||||
// TODO: While this workaround indeed fixes display issues with higher ASCII chars that have equivalents in the latin1 charset, this will currently swallow higher ASCII
|
||||
// hyphens/dashes such as endashes (which display correctly without this workaround).
|
||||
// if ($contentTypeCharset == "UTF-8")
|
||||
// $record = convertToCharacterEncoding("ISO-8859-1", "TRANSLIT", $record, "UTF-8"); // function 'convertToCharacterEncoding()' is defined in 'include.inc.php'
|
||||
|
||||
// Set paragraph text options:
|
||||
$textOptions = array(
|
||||
'justification' => 'full'
|
||||
// 'aleft' => '50',
|
||||
// 'aright' => '545'
|
||||
);
|
||||
// possible array options:
|
||||
// 'left'=> number, gap to leave from the left margin
|
||||
// 'right'=> number, gap to leave from the right margin
|
||||
// 'aleft'=> number, absolute left position (overrides 'left')
|
||||
// 'aright'=> number, absolute right position (overrides 'right')
|
||||
// 'justification' => 'left','right','center','centre','full'
|
||||
//
|
||||
// only set one of the next two items (leading overrides spacing)
|
||||
// 'leading' => number, defines the total height taken by the line, independent of the font height.
|
||||
// 'spacing' => a real number, though usually set to one of 1, 1.5, 2 (line spacing as used in word processing)
|
||||
|
||||
// Write PDF paragraph:
|
||||
$pdf->selectFont($textBodyFont, array('encoding' => 'WinAnsiEncoding')); // use Times-Roman
|
||||
$pdf->ezText($record . "\n", '12', $textOptions); // create text block with record text using "Times Roman" and a font size of 12pt
|
||||
}
|
||||
}
|
||||
|
||||
return $pdf->ezStream();
|
||||
}
|
||||
|
||||
// --- END CITATION FORMAT ---
|
||||
?>
|
||||
170
cite/formats/cite_rtf.php
Normal file
170
cite/formats/cite_rtf.php
Normal file
@@ -0,0 +1,170 @@
|
||||
<?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/formats/cite_rtf.php
|
||||
// Repository: $HeadURL: file:///svn/p/refbase/code/branches/bleeding-edge/cite/formats/cite_rtf.php $
|
||||
// Author(s): Matthias Steffens <mailto:refbase@extracts.de>
|
||||
//
|
||||
// Created: 10-Jun-06, 02:04
|
||||
// Modified: $Date: 2017-04-13 02:00:18 +0000 (Thu, 13 Apr 2017) $
|
||||
// $Author: karnesky $
|
||||
// $Revision: 1416 $
|
||||
|
||||
// This is a citation format file (which must reside within the 'cite/formats/' sub-directory of your refbase root directory). It contains a
|
||||
// version of the 'citeRecords()' function that outputs a reference list from selected records in RTF format.
|
||||
// RTF 1.0 format specification is available at <http://latex2rtf.sourceforge.net/RTF-Spec-1.0.txt>, more info at <http://en.wikipedia.org/wiki/RTF>
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
|
||||
// Include the MINIMALRTF Package
|
||||
require_once 'includes/classes/org/bibliophile/MINIMALRTF.php';
|
||||
|
||||
|
||||
// --- BEGIN CITATION FORMAT ---
|
||||
|
||||
// Requires the MINIMALRTF Package (by Mark Grimshaw), which is available
|
||||
// under the GPL from: <http://bibliophile.sourceforge.net>
|
||||
|
||||
function citeRecords($result, $rowsFound, $query, $queryURL, $showQuery, $showLinks, $rowOffset, $showRows, $previousOffset, $nextOffset, $wrapResults, $citeStyle, $citeOrder, $citeType, $orderBy, $headerMsg, $userID, $viewType)
|
||||
{
|
||||
global $contentTypeCharset; // defined in 'ini.inc.php'
|
||||
|
||||
global $client;
|
||||
|
||||
// The array '$transtab_refbase_rtf' contains search & replace patterns for conversion from refbase markup to RTF markup & entities
|
||||
global $transtab_refbase_rtf; // defined in 'transtab_refbase_rtf.inc.php'
|
||||
|
||||
// Initialize array variables:
|
||||
$yearsArray = array();
|
||||
$typeTitlesArray = array();
|
||||
|
||||
// Define inline text markup to be used by the 'citeRecord()' function:
|
||||
$markupPatternsArray = array("bold-prefix" => "{\\b ",
|
||||
"bold-suffix" => "}",
|
||||
"italic-prefix" => "{\\i ",
|
||||
"italic-suffix" => "}",
|
||||
"underline-prefix" => "{\\ul ",
|
||||
"underline-suffix" => "}",
|
||||
"endash" => "\\endash ", // or use "\\uc0\\u8211 " or "\\u8211\\'2D" (the first two seem to work more reliably than the third one)
|
||||
"emdash" => "\\emdash ", // or use "\\uc0\\u8212 " or "\\u8212\\'2D"
|
||||
"ampersand" => "&",
|
||||
"double-quote" => '"',
|
||||
"double-quote-left" => "\\ldblquote ", // or use "\\uc0\\u8220 " or "\\u8220\\'22"
|
||||
"double-quote-right" => "\\rdblquote ", // or use "\\uc0\\u8221 " or "\\u8221\\'22"
|
||||
"single-quote" => "'",
|
||||
"single-quote-left" => "\\lquote ", // or use "\\uc0\\u8216 " or "\\u8216\\'27"
|
||||
"single-quote-right" => "\\rquote ", // or use "\\uc0\\u8217 " or "\\u8217\\'27"
|
||||
"less-than" => "<",
|
||||
"greater-than" => ">",
|
||||
"newline" => "\n{\\f1\\fs24 \par}\n"
|
||||
);
|
||||
|
||||
// Defines search & replace 'actions' that will be applied upon RTF output to all those refbase fields that are listed
|
||||
// in the corresponding 'fields' element:
|
||||
$rtfSearchReplaceActionsArray = array(
|
||||
array(
|
||||
'fields' => array("title", "publication", "abbrev_journal", "address", "keywords", "abstract", "orig_title", "series_title", "abbrev_series_title", "notes"),
|
||||
'actions' => $transtab_refbase_rtf
|
||||
)
|
||||
);
|
||||
|
||||
// For CLI queries, we'll allow paging thru the result set, i.e. we honour the values of the CLI options '-S|--start' ('$rowOffset')
|
||||
// and '-R|--rows' ('$showRows') ('$rowOffset' and '$showRows' are re-assigned in function 'seekInMySQLResultsToOffset()' in 'include.inc.php')
|
||||
if (preg_match("/^cli/i", $client)) // if the query originated from a command line client such as the "refbase" CLI client ("cli-refbase-1.0")
|
||||
$showMaxRows = $showRows; // show only rows up to the value given in '$showRows'
|
||||
else
|
||||
$showMaxRows = $rowsFound; // otherwise show all rows
|
||||
|
||||
|
||||
// Setup the basic RTF document structure (RTF functions defined in 'MINIMALRTF.php'):
|
||||
$rtf = new MINIMALRTF(); // initialize RTF object
|
||||
$rtfData = $rtf->openRtf(); // create RTF opening tag
|
||||
|
||||
$rtf->createFontBlock(0, "Arial"); // create & set RTF font blocks
|
||||
$rtf->createFontBlock(1, "Times New Roman");
|
||||
$rtfData .= $rtf->setFontBlock();
|
||||
|
||||
// Header:
|
||||
if (!empty($headerMsg))
|
||||
{
|
||||
// Remove any colon (":") from end of header message:
|
||||
$headerMsg = trimTextPattern($headerMsg, ":", false, true); // function 'trimTextPattern()' is defined in 'include.inc.php'
|
||||
|
||||
// Decode any HTML entities:
|
||||
// (these may occur in the header message e.g. if the user's preferred display language is not English but German or French, etc)
|
||||
$headerMsg = decodeHTML($contentTypeCharset, $headerMsg); // function 'decodeHTML()' is defined in 'include.inc.php', and '$contentTypeCharset' is defined in 'ini.inc.php'
|
||||
|
||||
// Convert refbase markup in the header message into appropriate RTF markup & entities:
|
||||
$headerMsg = searchReplaceText($transtab_refbase_rtf, $headerMsg, true); // function 'searchReplaceText()' is defined in 'include.inc.php'
|
||||
|
||||
$rtfData .= "{\header\pard\qc $headerMsg\par}\n";
|
||||
}
|
||||
|
||||
$rtfData .= $rtf->justify("full", 0.5, 0, -0.5); // by default, we'll justify text and set a hanging indent (left indent: 0.5, right indent: 0, first-line indent: -0.5)
|
||||
|
||||
|
||||
// LOOP OVER EACH RECORD:
|
||||
// Fetch one page of results (or less if on the last page)
|
||||
// (i.e., upto the limit specified in $showMaxRows) fetch a row into the $row array and ...
|
||||
for ($rowCounter=0; (($rowCounter < $showMaxRows) && ($row = @ mysqli_fetch_array($result))); $rowCounter++)
|
||||
{
|
||||
foreach ($row as $rowFieldName => $rowFieldValue)
|
||||
// Apply search & replace 'actions' to all fields that are listed in the 'fields' element of the arrays contained in '$rtfSearchReplaceActionsArray':
|
||||
foreach ($rtfSearchReplaceActionsArray as $fieldActionsArray)
|
||||
if (in_array($rowFieldName, $fieldActionsArray['fields']))
|
||||
$row[$rowFieldName] = searchReplaceText($fieldActionsArray['actions'], $row[$rowFieldName], true); // function 'searchReplaceText()' is defined in 'include.inc.php'
|
||||
|
||||
|
||||
// Order attributes according to the chosen output style & record type:
|
||||
$record = citeRecord($row, $citeStyle, $citeType, $markupPatternsArray, false); // function 'citeRecord()' is defined in the citation style file given in '$citeStyleFile' (which, in turn, must reside in the 'cite' directory of the refbase root directory), see function 'generateCitations()'
|
||||
|
||||
|
||||
// Print out the current record:
|
||||
if (!empty($record)) // unless the record buffer is empty...
|
||||
{
|
||||
// Print any section heading(s):
|
||||
if (preg_match("/year|type/i", $citeOrder))
|
||||
{
|
||||
$headingPrefix = $rtf->justify("left", 0, 0, 0) // left-align the current heading without any indents
|
||||
. $rtf->paragraph(0, 12); // create empty paragraph in front of heading using "Arial" (font block 0) and a font size of 12pt
|
||||
|
||||
$headingSuffix = $rtf->justify("full", 0.5, 0, -0.5); // justify any following text and set a hanging indent (left indent: 0.5, right indent: 0, first-line indent: -0.5)
|
||||
|
||||
if ($citeOrder == "type") // for 'citeOrder=type' we'll always print an empty paragraph after the heading
|
||||
$headingSuffix .= $rtf->paragraph(0, 12); // create empty paragraph using "Arial" (font block 0) and a font size of 12pt
|
||||
|
||||
list($yearsArray, $typeTitlesArray, $sectionHeading) = generateSectionHeading($yearsArray, $typeTitlesArray, $row, $citeOrder, $headingPrefix, $headingSuffix, "{\\f0\\fs28 {\b ", "}\par}\n", "{\\f0\\fs24 {\b ", "}\par}\n"); // function 'generateSectionHeading()' is defined in 'cite.inc.php'
|
||||
|
||||
// Note that we pass raw RTF commands to the above function instead of using the 'textBlock()' function from 'MINIMALRTF.php'. This is due to a current limitation of the 'generateSectionHeading()' function.
|
||||
// For 'citeOrder=year', the appropriate call to the 'textBlock()' function would look like this:
|
||||
// $rtfData .= $rtf->textBlock(0, 14, $rtf->bold($row['year'])); // create major heading with the current year using "Arial" (font block 0) and a font size of 14pt, printed in bold
|
||||
|
||||
$rtfData .= $sectionHeading;
|
||||
}
|
||||
|
||||
// If character encoding is not UTF-8 already, convert record text to UTF-8:
|
||||
if ($contentTypeCharset != "UTF-8")
|
||||
$record = convertToCharacterEncoding("UTF-8", "IGNORE", $record); // function 'convertToCharacterEncoding()' is defined in 'include.inc.php'
|
||||
|
||||
// Encode characters with an ASCII value of >= 128 in RTF 1.16 unicode format:
|
||||
$recordUnicodeCharEncoded = $rtf->utf8_2_unicode($record); // converts UTF-8 chars to unicode character codes
|
||||
|
||||
// Write RTF paragraph:
|
||||
$rtfData .= $rtf->textBlock(1, 12, $recordUnicodeCharEncoded); // create text block with encoded record text using "Times New Roman" (font block 1) and a font size of 12pt
|
||||
}
|
||||
}
|
||||
|
||||
$rtfData .= $rtf->closeRtf(); // create RTF closing tag
|
||||
|
||||
return $rtfData;
|
||||
}
|
||||
|
||||
// --- END CITATION FORMAT ---
|
||||
?>
|
||||
678
cite/styles/cite_AMA.php
Normal file
678
cite/styles/cite_AMA.php
Normal 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
699
cite/styles/cite_APA.php
Normal 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 ---
|
||||
?>
|
||||
471
cite/styles/cite_AnnGlaciol_JGlaciol.php
Normal file
471
cite/styles/cite_AnnGlaciol_JGlaciol.php
Normal 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 ---
|
||||
?>
|
||||
629
cite/styles/cite_Chicago.php
Normal file
629
cite/styles/cite_Chicago.php
Normal 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 ---
|
||||
?>
|
||||
438
cite/styles/cite_DeepSeaRes.php
Normal file
438
cite/styles/cite_DeepSeaRes.php
Normal 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 ---
|
||||
?>
|
||||
691
cite/styles/cite_Harvard_1.php
Normal file
691
cite/styles/cite_Harvard_1.php
Normal 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 ---
|
||||
?>
|
||||
657
cite/styles/cite_Harvard_2.php
Normal file
657
cite/styles/cite_Harvard_2.php
Normal 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 ---
|
||||
?>
|
||||
684
cite/styles/cite_Harvard_3.php
Normal file
684
cite/styles/cite_Harvard_3.php
Normal 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
660
cite/styles/cite_MLA.php
Normal 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 ---
|
||||
?>
|
||||
442
cite/styles/cite_PolarBiol_MarBiol_MEPS.php
Normal file
442
cite/styles/cite_PolarBiol_MarBiol_MEPS.php
Normal 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 ---
|
||||
?>
|
||||
69
cite/styles/cite_TextCitation.php
Normal file
69
cite/styles/cite_TextCitation.php
Normal 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 ---
|
||||
?>
|
||||
714
cite/styles/cite_Vancouver.php
Normal file
714
cite/styles/cite_Vancouver.php
Normal 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 ---
|
||||
?>
|
||||
Reference in New Issue
Block a user