You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

69 lines
3.5 KiB

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