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.

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