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.

684 lines
36 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_Harvard_3.php
  11. // Repository: $HeadURL$
  12. // Author(s): Matthias Steffens <mailto:refbase@extracts.de>
  13. //
  14. // Created: 01-Aug-08, 02:00
  15. // Modified: $Date: 2012-02-27 20:25:30 +0000 (Mon, 27 Feb 2012) $
  16. // $Author$
  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 used by
  20. // the Harvard referencing system
  21. // This is a variant of the Harvard author/date style, modeled after these resources:
  22. // <http://library.curtin.edu.au/referencing/harvard.html> (not available anymore?)
  23. // <http://www.usq.edu.au/library/help/ehelp/ref_guides/harvard.htm>
  24. // <http://www.library.uwa.edu.au/education_training_and_support/guides/harvard_citation_style>
  25. // <http://www.lib.unimelb.edu.au/cite/harvard_dis/>
  26. // based on 'cite_APA.php'
  27. // TODO: - patents & reports?
  28. // - 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?
  29. // - where to put (and how to format) series info & editors of whole books that also have an author?
  30. // --------------------------------------------------------------------
  31. // --- BEGIN CITATION STYLE ---
  32. function citeRecord($row, $citeStyle, $citeType, $markupPatternsArray, $encodeHTML)
  33. {
  34. $record = ""; // make sure that our buffer variable is empty
  35. // --- BEGIN TYPE = JOURNAL ARTICLE / MAGAZINE ARTICLE / NEWSPAPER ARTICLE --------------------------------------------------------------
  36. if (preg_match("/^(Journal Article|Magazine Article|Newspaper Article)$/", $row['type']))
  37. {
  38. if (!empty($row['author'])) // author
  39. {
  40. // Call the 'reArrangeAuthorContents()' function (defined in 'include.inc.php') in order to re-order contents of the author field. Required Parameters:
  41. // 1. input: contents of the author field
  42. // 2. input: boolean value that specifies whether the author's family name comes first (within one author) in the source string
  43. // ('true' means that the family name is followed by the given name (or initials), 'false' if it's the other way around)
  44. //
  45. // 3. input: pattern describing old delimiter that separates different authors
  46. // 4. output: for all authors except the last author: new delimiter that separates different authors
  47. // 5. output: for the last author: new delimiter that separates the last author from all other authors
  48. //
  49. // 6. input: pattern describing old delimiter that separates author name & initials (within one author)
  50. // 7. output: for the first author: new delimiter that separates author name & initials (within one author)
  51. // 8. output: for all authors except the first author: new delimiter that separates author name & initials (within one author)
  52. // 9. output: new delimiter that separates multiple initials (within one author)
  53. // 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)
  54. // 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)
  55. // 12. output: boolean value that specifies whether an author's full given name(s) shall be shortened to initial(s)
  56. //
  57. // 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
  58. // 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
  59. // 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
  60. //
  61. // 16. output: boolean value that specifies whether the re-ordered string shall be returned with higher ASCII chars HTML encoded
  62. $author = reArrangeAuthorContents($row['author'], // 1.
  63. true, // 2.
  64. "/ *; */", // 3.
  65. ", ", // 4.
  66. " " . $markupPatternsArray["ampersand"] . " ", // 5.
  67. "/ *, */", // 6.
  68. ", ", // 7.
  69. ", ", // 8.
  70. "", // 9.
  71. false, // 10.
  72. false, // 11.
  73. true, // 12.
  74. "", // 13.
  75. "", // 14.
  76. " et al", // 15.
  77. $encodeHTML); // 16.
  78. $record .= $author;
  79. }
  80. if (!empty($row['year'])) // year
  81. {
  82. if (!empty($row['author']))
  83. $record .= " ";
  84. if (!empty($row['year']))
  85. $record .= $row['year'];
  86. }
  87. if (!empty($row['title'])) // title
  88. {
  89. if (!empty($row['author']) || !empty($row['year']))
  90. $record .= ", ";
  91. $record .= $markupPatternsArray["single-quote-left"] . $row['title'] . $markupPatternsArray["single-quote-right"];
  92. $record .= ",";
  93. }
  94. // From here on we'll assume that at least one of the fields 'author', 'year' or 'title' did contain some contents
  95. if (!empty($row['publication'])) // publication (= journal) name
  96. $record .= " " . $markupPatternsArray["italic-prefix"] . $row['publication'] . $markupPatternsArray["italic-suffix"];
  97. // if there's no full journal name, we'll use the abbreviated journal name instead:
  98. elseif (!empty($row['abbrev_journal'])) // abbreviated journal name
  99. $record .= " " . $markupPatternsArray["italic-prefix"] . $row['abbrev_journal'] . $markupPatternsArray["italic-suffix"];
  100. if ((!empty($row['abbrev_journal']) || !empty($row['publication'])) && (!empty($row['volume']) || !empty($row['issue'])))
  101. $record .= ",";
  102. if ($row['type'] == "Journal Article") // for journal articles, volume (or issue) information is printed with a "vol." (or "no.") prefix
  103. {
  104. if (!empty($row['volume'])) // volume
  105. $record .= " vol. " . $row['volume'];
  106. if (!empty($row['issue'])) // issue
  107. {
  108. if (!empty($row['volume']))
  109. $record .= ",";
  110. $record .= " no. " . $row['issue'];
  111. }
  112. }
  113. elseif (preg_match("/^(Newspaper Article|Magazine Article)$/", $row['type'])) // for newspaper and magazine articles, volume (=month) and issue (=day) information is printed without prefix
  114. {
  115. if (!empty($row['issue'])) // issue (=day)
  116. $record .= " " . $row['issue'];
  117. if (!empty($row['volume'])) // volume (=month)
  118. $record .= " " . $row['volume'];
  119. }
  120. if (!empty($row['pages'])) // pages
  121. {
  122. 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
  123. $record .= ", ";
  124. $record .= formatPageInfo($row['pages'], $markupPatternsArray["endash"], "p. ", "pp. "); // function 'formatPageInfo()' is defined in 'cite.inc.php'
  125. }
  126. if ($row['online_publication'] == "yes") // this record refers to an online article
  127. {
  128. // append an optional string (given in 'online_citation') plus the current date and the DOI (or URL):
  129. if (!empty($row['online_citation'])) // online_citation
  130. {
  131. 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
  132. $record .= ",";
  133. $record .= " " . $row['online_citation'];
  134. }
  135. if (!empty($row['doi']) || !empty($row['url'])) // doi OR url
  136. {
  137. 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
  138. $record .= ".";
  139. $today = date("j F Y");
  140. $record .= " Available from: "; // NOTE: some of the above mentioned resources use ", accessed 26 February 2004, from <http://...>." (or ", viewed on ...") instead
  141. if (!empty($row['doi'])) // doi
  142. $uri = "http://dx.doi.org/" . $row['doi'];
  143. else // url
  144. $uri = $row['url'];
  145. if ($encodeHTML)
  146. $record .= encodeHTML($markupPatternsArray["less-than"] . $uri . $markupPatternsArray["greater-than"]);
  147. else
  148. $record .= $markupPatternsArray["less-than"] . $uri . $markupPatternsArray["greater-than"];
  149. $record .= " [" . $today . "]";
  150. }
  151. }
  152. if (!preg_match("/\. *$/", $record)) // if the string doesn't end with a period
  153. $record .= ".";
  154. }
  155. // --- BEGIN TYPE = ABSTRACT / BOOK CHAPTER / CONFERENCE ARTICLE ------------------------------------------------------------------------
  156. elseif (preg_match("/^(Abstract|Book Chapter|Conference Article)$/", $row['type']))
  157. {
  158. if (!empty($row['author'])) // author
  159. {
  160. // Call the 'reArrangeAuthorContents()' function (defined in 'include.inc.php') in order to re-order contents of the author field. Required Parameters:
  161. // 1. input: contents of the author field
  162. // 2. input: boolean value that specifies whether the author's family name comes first (within one author) in the source string
  163. // ('true' means that the family name is followed by the given name (or initials), 'false' if it's the other way around)
  164. //
  165. // 3. input: pattern describing old delimiter that separates different authors
  166. // 4. output: for all authors except the last author: new delimiter that separates different authors
  167. // 5. output: for the last author: new delimiter that separates the last author from all other authors
  168. //
  169. // 6. input: pattern describing old delimiter that separates author name & initials (within one author)
  170. // 7. output: for the first author: new delimiter that separates author name & initials (within one author)
  171. // 8. output: for all authors except the first author: new delimiter that separates author name & initials (within one author)
  172. // 9. output: new delimiter that separates multiple initials (within one author)
  173. // 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)
  174. // 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)
  175. // 12. output: boolean value that specifies whether an author's full given name(s) shall be shortened to initial(s)
  176. //
  177. // 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
  178. // 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
  179. // 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
  180. //
  181. // 16. output: boolean value that specifies whether the re-ordered string shall be returned with higher ASCII chars HTML encoded
  182. $author = reArrangeAuthorContents($row['author'], // 1.
  183. true, // 2.
  184. "/ *; */", // 3.
  185. ", ", // 4.
  186. " " . $markupPatternsArray["ampersand"] . " ", // 5.
  187. "/ *, */", // 6.
  188. ", ", // 7.
  189. ", ", // 8.
  190. "", // 9.
  191. false, // 10.
  192. false, // 11.
  193. true, // 12.
  194. "", // 13.
  195. "", // 14.
  196. " et al", // 15.
  197. $encodeHTML); // 16.
  198. $record .= $author;
  199. }
  200. if (!empty($row['year'])) // year
  201. {
  202. if (!empty($row['author']))
  203. $record .= " ";
  204. $record .= $row['year'];
  205. }
  206. if (!empty($row['title'])) // title
  207. {
  208. if (!empty($row['author']) || !empty($row['year']))
  209. $record .= ", ";
  210. $record .= $markupPatternsArray["single-quote-left"] . $row['title'] . $markupPatternsArray["single-quote-right"];
  211. $record .= ",";
  212. }
  213. // From here on we'll assume that at least one of the fields 'author', 'year' or 'title' did contain some contents
  214. // 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)
  215. if (!empty($row['editor'])) // editor
  216. {
  217. // Call the 'reArrangeAuthorContents()' function (defined in 'include.inc.php') in order to re-order contents of the author field. Required Parameters:
  218. // 1. input: contents of the author field
  219. // 2. input: boolean value that specifies whether the author's family name comes first (within one author) in the source string
  220. // ('true' means that the family name is followed by the given name (or initials), 'false' if it's the other way around)
  221. //
  222. // 3. input: pattern describing old delimiter that separates different authors
  223. // 4. output: for all authors except the last author: new delimiter that separates different authors
  224. // 5. output: for the last author: new delimiter that separates the last author from all other authors
  225. //
  226. // 6. input: pattern describing old delimiter that separates author name & initials (within one author)
  227. // 7. output: for the first author: new delimiter that separates author name & initials (within one author)
  228. // 8. output: for all authors except the first author: new delimiter that separates author name & initials (within one author)
  229. // 9. output: new delimiter that separates multiple initials (within one author)
  230. // 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)
  231. // 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)
  232. // 12. output: boolean value that specifies whether an author's full given name(s) shall be shortened to initial(s)
  233. //
  234. // 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
  235. // 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
  236. // 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
  237. //
  238. // 16. output: boolean value that specifies whether the re-ordered string shall be returned with higher ASCII chars HTML encoded
  239. $editor = reArrangeAuthorContents($row['editor'], // 1.
  240. true, // 2.
  241. "/ *; */", // 3.
  242. ", ", // 4.
  243. " " . $markupPatternsArray["ampersand"] . " ", // 5.
  244. "/ *, */", // 6.
  245. " ", // 7.
  246. " ", // 8.
  247. "", // 9.
  248. true, // 10.
  249. true, // 11.
  250. true, // 12.
  251. "", // 13.
  252. "", // 14.
  253. " et al", // 15.
  254. $encodeHTML); // 16.
  255. $record .= " in " . $editor . " (";
  256. if (preg_match("/^[^;\r\n]+(;[^;\r\n]+)+$/", $row['editor'])) // there are at least two editors (separated by ';')
  257. $record .= "eds.";
  258. else // there's only one editor (or the editor field is malformed with multiple editors but missing ';' separator[s])
  259. $record .= "ed.";
  260. $record .= "),";
  261. }
  262. $publication = preg_replace("/[ \r\n]*\(Eds?:[^\)\r\n]*\)/i", "", $row['publication']);
  263. if (!empty($publication)) // publication
  264. {
  265. if (empty($row['editor']))
  266. $record .= " in";
  267. $record .= " " . $markupPatternsArray["italic-prefix"] . $publication . $markupPatternsArray["italic-suffix"];
  268. }
  269. if (!empty($row['edition']) && !preg_match("/^(1|1st|first|one)( ed\.?| edition)?$/i", $row['edition']) || !empty($row['volume']))
  270. {
  271. $record .= ", ";
  272. if (!empty($row['edition']) && !preg_match("/^(1|1st|first|one)( ed\.?| edition)?$/i", $row['edition'])) // edition
  273. {
  274. 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")
  275. {
  276. if ($row['edition'] == "2")
  277. $editionSuffix = "nd";
  278. elseif ($row['edition'] == "3")
  279. $editionSuffix = "rd";
  280. else
  281. $editionSuffix = "th";
  282. }
  283. else
  284. $editionSuffix = "";
  285. if (!empty($row['edition']) && !preg_match("/( ed\.?| edition)$/i", $row['edition']))
  286. $editionSuffix .= " edn";
  287. $record .= $row['edition'] . $editionSuffix;
  288. }
  289. if (!empty($row['volume'])) // volume
  290. {
  291. if (!empty($row['edition']) && !preg_match("/^(1|1st|first|one)( ed\.?| edition)?$/i", $row['edition']))
  292. $record .= ", ";
  293. $record .= "vol. " . $row['volume'];
  294. }
  295. }
  296. if (!empty($row['abbrev_series_title']) OR !empty($row['series_title'])) // if there's either a full or an abbreviated series title
  297. {
  298. $record .= ", ";
  299. if (!empty($row['series_title']))
  300. $record .= $row['series_title']; // full series title
  301. // if there's no full series title, we'll use the abbreviated series title instead:
  302. elseif (!empty($row['abbrev_series_title']))
  303. $record .= $row['abbrev_series_title']; // abbreviated series title
  304. if (!empty($row['series_volume'])||!empty($row['series_issue']))
  305. $record .= ", ";
  306. 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)
  307. $record .= "vol. " . $row['series_volume'];
  308. if (!empty($row['series_issue'])) // series issue (see note for series volume)
  309. {
  310. if (!empty($row['series_volume']))
  311. $record .= ", ";
  312. $record .= "no. " . $row['series_issue'];
  313. }
  314. }
  315. $record .= ",";
  316. if (!empty($row['publisher'])) // publisher
  317. $record .= " " . $row['publisher'];
  318. if (!empty($row['place'])) // place
  319. {
  320. if (!empty($row['publisher']))
  321. $record .= ",";
  322. $record .= " " . $row['place'];
  323. }
  324. if (!empty($row['pages'])) // pages
  325. {
  326. if (!empty($row['publisher']) || !empty($row['place']))
  327. $record .= ", ";
  328. $record .= formatPageInfo($row['pages'], $markupPatternsArray["endash"], "p. ", "pp. "); // function 'formatPageInfo()' is defined in 'cite.inc.php'
  329. }
  330. if (!preg_match("/\. *$/", $record))
  331. $record .= ".";
  332. }
  333. // --- BEGIN TYPE = BOOK WHOLE / CONFERENCE VOLUME / JOURNAL / MANUAL / MANUSCRIPT / MAP / MISCELLANEOUS / PATENT / REPORT / SOFTWARE ---
  334. else // if (preg_match("/Book Whole|Conference Volume|Journal|Manual|Manuscript|Map|Miscellaneous|Patent|Report|Software/", $row['type']))
  335. // note that this also serves as a fallback: unrecognized resource types will be formatted similar to whole books
  336. {
  337. if (!empty($row['author'])) // author
  338. {
  339. $author = preg_replace("/[ \r\n]*\(eds?\)/i", "", $row['author']);
  340. // Call the 'reArrangeAuthorContents()' function (defined in 'include.inc.php') in order to re-order contents of the author field. Required Parameters:
  341. // 1. input: contents of the author field
  342. // 2. input: boolean value that specifies whether the author's family name comes first (within one author) in the source string
  343. // ('true' means that the family name is followed by the given name (or initials), 'false' if it's the other way around)
  344. //
  345. // 3. input: pattern describing old delimiter that separates different authors
  346. // 4. output: for all authors except the last author: new delimiter that separates different authors
  347. // 5. output: for the last author: new delimiter that separates the last author from all other authors
  348. //
  349. // 6. input: pattern describing old delimiter that separates author name & initials (within one author)
  350. // 7. output: for the first author: new delimiter that separates author name & initials (within one author)
  351. // 8. output: for all authors except the first author: new delimiter that separates author name & initials (within one author)
  352. // 9. output: new delimiter that separates multiple initials (within one author)
  353. // 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)
  354. // 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)
  355. // 12. output: boolean value that specifies whether an author's full given name(s) shall be shortened to initial(s)
  356. //
  357. // 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
  358. // 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
  359. // 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
  360. //
  361. // 16. output: boolean value that specifies whether the re-ordered string shall be returned with higher ASCII chars HTML encoded
  362. $author = reArrangeAuthorContents($author, // 1.
  363. true, // 2.
  364. "/ *; */", // 3.
  365. ", ", // 4.
  366. " " . $markupPatternsArray["ampersand"] . " ", // 5.
  367. "/ *, */", // 6.
  368. ", ", // 7.
  369. ", ", // 8.
  370. "", // 9.
  371. false, // 10.
  372. false, // 11.
  373. true, // 12.
  374. "", // 13.
  375. "", // 14.
  376. " et al", // 15.
  377. $encodeHTML); // 16.
  378. // if the author is actually the editor of the resource we'll append ', ed' (or ', eds') to the author string:
  379. // [to distinguish editors from authors in the 'author' field, the 'modify.php' script does append ' (ed)' or ' (eds)' if appropriate,
  380. // so we're just checking for these identifier strings here. Alternatively, we could check whether the editor field matches the author field]
  381. if (preg_match("/[ \r\n]*\(ed\)/", $row['author'])) // single editor
  382. $author = $author . " (ed.)";
  383. elseif (preg_match("/[ \r\n]*\(eds\)/", $row['author'])) // multiple editors
  384. $author = $author . " (eds.)";
  385. $record .= $author;
  386. }
  387. if (!empty($row['year'])) // year
  388. {
  389. if (!empty($row['author']))
  390. $record .= " ";
  391. $record .= $row['year'];
  392. }
  393. if (!empty($row['title'])) // title
  394. {
  395. if (!empty($row['author']) || !empty($row['year']))
  396. $record .= ", ";
  397. if (!empty($row['thesis'])) // for theses, the title is printed in roman type and in quotation marks
  398. $record .= $markupPatternsArray["single-quote-left"] . $row['title'] . $markupPatternsArray["single-quote-right"];
  399. else // otherwise, the title is printed in italics
  400. $record .= $markupPatternsArray["italic-prefix"] . $row['title'] . $markupPatternsArray["italic-suffix"];
  401. }
  402. 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)')
  403. {
  404. // Call the 'reArrangeAuthorContents()' function (defined in 'include.inc.php') in order to re-order contents of the author field. Required Parameters:
  405. // 1. input: contents of the author field
  406. // 2. input: boolean value that specifies whether the author's family name comes first (within one author) in the source string
  407. // ('true' means that the family name is followed by the given name (or initials), 'false' if it's the other way around)
  408. //
  409. // 3. input: pattern describing old delimiter that separates different authors
  410. // 4. output: for all authors except the last author: new delimiter that separates different authors
  411. // 5. output: for the last author: new delimiter that separates the last author from all other authors
  412. //
  413. // 6. input: pattern describing old delimiter that separates author name & initials (within one author)
  414. // 7. output: for the first author: new delimiter that separates author name & initials (within one author)
  415. // 8. output: for all authors except the first author: new delimiter that separates author name & initials (within one author)
  416. // 9. output: new delimiter that separates multiple initials (within one author)
  417. // 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)
  418. // 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)
  419. // 12. output: boolean value that specifies whether an author's full given name(s) shall be shortened to initial(s)
  420. //
  421. // 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
  422. // 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
  423. // 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
  424. //
  425. // 16. output: boolean value that specifies whether the re-ordered string shall be returned with higher ASCII chars HTML encoded
  426. $editor = reArrangeAuthorContents($row['editor'], // 1.
  427. true, // 2.
  428. "/ *; */", // 3.
  429. ", ", // 4.
  430. " " . $markupPatternsArray["ampersand"] . " ", // 5.
  431. "/ *, */", // 6.
  432. " ", // 7.
  433. " ", // 8.
  434. "", // 9.
  435. true, // 10.
  436. true, // 11.
  437. true, // 12.
  438. "", // 13.
  439. "", // 14.
  440. " et al", // 15.
  441. $encodeHTML); // 16.
  442. if (!empty($row['author']) || !empty($row['year']) || !empty($row['title']))
  443. $record .= " ";
  444. $record .= " (" . $editor . ", ";
  445. if (preg_match("/^[^;\r\n]+(;[^;\r\n]+)+$/", $row['editor'])) // there are at least two editors (separated by ';')
  446. $record .= "eds.";
  447. else // there's only one editor (or the editor field is malformed with multiple editors but missing ';' separator[s])
  448. $record .= "ed.";
  449. $record .= ")";
  450. }
  451. if (!empty($row['edition']) || !empty($row['volume']))
  452. {
  453. if (!empty($row['author']) || !empty($row['year']) || !empty($row['title']) || (!empty($row['editor']) && !preg_match("/[ \r\n]*\(eds?\)/", $row['author'])))
  454. $record .= ", ";
  455. if ($row['type'] == "Software") // software edition (=version)
  456. {
  457. if (!empty($row['edition']))
  458. {
  459. $record .= "version " . $row['edition'];
  460. if (!empty($row['volume']) || !empty($row['issue']))
  461. $record .= ", ";
  462. }
  463. if (!empty($row['issue'])) // issue (=day)
  464. $record .= " " . $row['issue'];
  465. if (!empty($row['volume'])) // volume (=month)
  466. $record .= " " . $row['volume'];
  467. }
  468. elseif (!preg_match("/^(1|1st|first|one)( ed\.?| edition)?$/i", $row['edition'])) // regular edition (other than the first)
  469. {
  470. 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")
  471. {
  472. if ($row['edition'] == "2")
  473. $editionSuffix = "nd";
  474. elseif ($row['edition'] == "3")
  475. $editionSuffix = "rd";
  476. else
  477. $editionSuffix = "th";
  478. }
  479. else
  480. $editionSuffix = "";
  481. if (!empty($row['edition']) && !preg_match("/( ed\.?| edition)$/i", $row['edition']))
  482. $editionSuffix .= " edn";
  483. $record .= $row['edition'] . $editionSuffix;
  484. if (!empty($row['volume'])) // volume
  485. {
  486. if (!empty($row['edition']) && !preg_match("/^(1|1st|first|one)( ed\.?| edition)?$/i", $row['edition']))
  487. $record .= ", ";
  488. $record .= "vol. " . $row['volume'];
  489. }
  490. }
  491. }
  492. if ($row['type'] == "Software") // for software, add software label
  493. {
  494. $record .= ", computer software";
  495. }
  496. else // add series info
  497. {
  498. if (!empty($row['abbrev_series_title']) OR !empty($row['series_title'])) // if there's either a full or an abbreviated series title
  499. {
  500. if ((!empty($row['title']) && !preg_match("/[?!.]$/", $row['title'])) || (!empty($row['editor']) && !preg_match("/[ \r\n]*\(eds?\)/", $row['author'])) || !empty($row['edition']) || !empty($row['volume']))
  501. $record .= ",";
  502. $record .= " ";
  503. if (!empty($row['series_title']))
  504. $record .= $row['series_title']; // full series title
  505. // if there's no full series title, we'll use the abbreviated series title instead:
  506. elseif (!empty($row['abbrev_series_title']))
  507. $record .= $row['abbrev_series_title']; // abbreviated series title
  508. if (!empty($row['series_volume'])||!empty($row['series_issue']))
  509. $record .= ", ";
  510. 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)
  511. $record .= "vol. " . $row['series_volume'];
  512. if (!empty($row['series_issue'])) // series issue (see note for series volume)
  513. {
  514. if (!empty($row['series_volume']))
  515. $record .= ", ";
  516. $record .= "no. " . $row['series_issue'];
  517. }
  518. }
  519. }
  520. if (!empty($row['thesis'])) // thesis
  521. {
  522. $record .= ", " . $row['thesis'];
  523. $record .= ", " . $row['publisher'];
  524. $record .= ", " . $row['place']; // NOTE: should we omit the place of publication for theses?
  525. }
  526. else // not a thesis
  527. {
  528. if (!empty($row['publisher'])) // publisher
  529. $record .= ", " . $row['publisher'];
  530. if (!empty($row['place'])) // place
  531. {
  532. if (!empty($row['publisher']))
  533. $record .= ",";
  534. $record .= " " . $row['place'];
  535. }
  536. }
  537. if ($row['online_publication'] == "yes" || $row['type'] == "Software") // this record refers to an online article, or a computer program/software
  538. {
  539. if (!empty($row['online_citation'])) // online_citation
  540. {
  541. if (!preg_match("/\. *$/", $record))
  542. $record .= ".";
  543. $record .= " " . $row['online_citation'];
  544. }
  545. if (!empty($row['doi']) || !empty($row['url'])) // doi OR url
  546. {
  547. if (!preg_match("/\. *$/", $record))
  548. $record .= ".";
  549. $today = date("j F Y");
  550. $record .= " Available from: "; // NOTE: some of the above mentioned resources use ", accessed 26 February 2004, from <http://...>." (or ", viewed on ...") instead
  551. if (!empty($row['doi'])) // doi
  552. $uri = "http://dx.doi.org/" . $row['doi'];
  553. else // url
  554. $uri = $row['url'];
  555. if ($encodeHTML)
  556. $record .= encodeHTML($markupPatternsArray["less-than"] . $uri . $markupPatternsArray["greater-than"]);
  557. else
  558. $record .= $markupPatternsArray["less-than"] . $uri . $markupPatternsArray["greater-than"];
  559. $record .= " [" . $today . "]";
  560. }
  561. }
  562. if (!preg_match("/\. *$/", $record)) // if the string doesn't end with a period
  563. $record .= ".";
  564. }
  565. // --- BEGIN POST-PROCESSING -----------------------------------------------------------------------------------------------------------
  566. // do some further cleanup:
  567. $record = trim($record); // remove any preceding or trailing whitespace
  568. return $record;
  569. }
  570. // --- END CITATION STYLE ---
  571. ?>