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.

471 lines
27 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_AnnGlaciol_JGlaciol.php
  11. // Repository: $HeadURL: file:///svn/p/refbase/code/branches/bleeding-edge/cite/styles/cite_AnnGlaciol_JGlaciol.php $
  12. // Author(s): Matthias Steffens <mailto:refbase@extracts.de>
  13. //
  14. // Created: 07-Sep-05, 14:53
  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 used by
  20. // the journals "Annals of Glaciology" and "Journal of Glaciology" (International Glaciological Society, www.igsoc.org).
  21. // --------------------------------------------------------------------
  22. // --- BEGIN CITATION STYLE ---
  23. function citeRecord($row, $citeStyle, $citeType, $markupPatternsArray, $encodeHTML)
  24. {
  25. $record = ""; // make sure that our buffer variable is empty
  26. // --- BEGIN TYPE = JOURNAL ARTICLE / MAGAZINE ARTICLE / NEWSPAPER ARTICLE --------------------------------------------------------------
  27. if (preg_match("/^(Journal Article|Magazine Article|Newspaper Article)$/", $row['type']))
  28. {
  29. if (!empty($row['author'])) // author
  30. {
  31. // Call the 'reArrangeAuthorContents()' function (defined in 'include.inc.php') in order to re-order contents of the author field. Required Parameters:
  32. // 1. input: contents of the author field
  33. // 2. input: boolean value that specifies whether the author's family name comes first (within one author) in the source string
  34. // ('true' means that the family name is followed by the given name (or initials), 'false' if it's the other way around)
  35. //
  36. // 3. input: pattern describing old delimiter that separates different authors
  37. // 4. output: for all authors except the last author: new delimiter that separates different authors
  38. // 5. output: for the last author: new delimiter that separates the last author from all other authors
  39. //
  40. // 6. input: pattern describing old delimiter that separates author name & initials (within one author)
  41. // 7. output: for the first author: new delimiter that separates author name & initials (within one author)
  42. // 8. output: for all authors except the first author: new delimiter that separates author name & initials (within one author)
  43. // 9. output: new delimiter that separates multiple initials (within one author)
  44. // 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)
  45. // 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)
  46. // 12. output: boolean value that specifies whether an author's full given name(s) shall be shortened to initial(s)
  47. //
  48. // 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
  49. // 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
  50. // 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
  51. //
  52. // 16. output: boolean value that specifies whether the re-ordered string shall be returned with higher ASCII chars HTML encoded
  53. $author = reArrangeAuthorContents($row['author'], // 1.
  54. true, // 2.
  55. "/ *; */", // 3.
  56. ", ", // 4.
  57. " and ", // 5.
  58. "/ *, */", // 6.
  59. ", ", // 7.
  60. " ", // 8.
  61. ".", // 9.
  62. false, // 10.
  63. true, // 11.
  64. true, // 12.
  65. "6", // 13.
  66. "1", // 14.
  67. " " . $markupPatternsArray["italic-prefix"] . "and __NUMBER_OF_AUTHORS__ others" . $markupPatternsArray["italic-suffix"], // 15.
  68. $encodeHTML); // 16.
  69. if (!preg_match("/\. *$/", $author))
  70. $record .= $author . ".";
  71. else
  72. $record .= $author;
  73. }
  74. if (!empty($row['year'])) // year
  75. {
  76. if (!empty($row['author']))
  77. $record .= " ";
  78. $record .= $row['year'] . ".";
  79. }
  80. if (!empty($row['title'])) // title
  81. {
  82. if (!empty($row['author']) || !empty($row['year']))
  83. $record .= " ";
  84. $record .= $row['title'];
  85. if (!preg_match("/[?!.]$/", $row['title']))
  86. $record .= ".";
  87. }
  88. // From here on we'll assume that at least one of the fields 'author', 'year' or 'title' 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['abbrev_journal'])) // abbreviated journal name
  91. $record .= " " . $markupPatternsArray["italic-prefix"] . $row['abbrev_journal'] . $markupPatternsArray["italic-suffix"];
  92. // if there's no abbreviated journal name, we'll use the full journal name
  93. elseif (!empty($row['publication'])) // publication (= journal) name
  94. $record .= " " . $markupPatternsArray["italic-prefix"] . $row['publication'] . $markupPatternsArray["italic-suffix"];
  95. if (!empty($row['volume'])) // volume
  96. {
  97. if (!empty($row['abbrev_journal']) || !empty($row['publication']))
  98. $record .= ",";
  99. $record .= " " . $markupPatternsArray["bold-prefix"] . $row['volume'] . $markupPatternsArray["bold-suffix"];
  100. }
  101. if (!empty($row['issue'])) // issue
  102. $record .= "(" . $row['issue'] . ")";
  103. if ($row['online_publication'] == "yes") // this record refers to an online article
  104. {
  105. // instead of any pages info (which normally doesn't exist for online publications) we append
  106. // an optional string (given in 'online_citation') plus the DOI:
  107. if (!empty($row['online_citation'])) // online_citation
  108. {
  109. 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
  110. $record .= ",";
  111. $record .= " " . $row['online_citation'];
  112. }
  113. if (!empty($row['doi'])) // doi
  114. {
  115. 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
  116. $record .= ".";
  117. $record .= " (" . $row['doi'] . ".)";
  118. }
  119. }
  120. else // $row['online_publication'] == "no" -> this record refers to a printed article, so we append any pages info instead:
  121. {
  122. if (!empty($row['pages'])) // pages
  123. {
  124. 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
  125. $record .= ", ";
  126. $record .= formatPageInfo($row['pages'], $markupPatternsArray["endash"]); // function 'formatPageInfo()' is defined in 'cite.inc.php'
  127. }
  128. }
  129. if (!preg_match("/\.\)? *$/", $record))
  130. $record .= ".";
  131. }
  132. // --- BEGIN TYPE = ABSTRACT / BOOK CHAPTER / CONFERENCE ARTICLE ------------------------------------------------------------------------
  133. elseif (preg_match("/^(Abstract|Book Chapter|Conference Article)$/", $row['type']))
  134. {
  135. if (!empty($row['author'])) // author
  136. {
  137. // Call the 'reArrangeAuthorContents()' function (defined in 'include.inc.php') in order to re-order contents of the author field. Required Parameters:
  138. // 1. input: contents of the author field
  139. // 2. input: boolean value that specifies whether the author's family name comes first (within one author) in the source string
  140. // ('true' means that the family name is followed by the given name (or initials), 'false' if it's the other way around)
  141. //
  142. // 3. input: pattern describing old delimiter that separates different authors
  143. // 4. output: for all authors except the last author: new delimiter that separates different authors
  144. // 5. output: for the last author: new delimiter that separates the last author from all other authors
  145. //
  146. // 6. input: pattern describing old delimiter that separates author name & initials (within one author)
  147. // 7. output: for the first author: new delimiter that separates author name & initials (within one author)
  148. // 8. output: for all authors except the first author: new delimiter that separates author name & initials (within one author)
  149. // 9. output: new delimiter that separates multiple initials (within one author)
  150. // 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)
  151. // 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)
  152. // 12. output: boolean value that specifies whether an author's full given name(s) shall be shortened to initial(s)
  153. //
  154. // 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
  155. // 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
  156. // 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
  157. //
  158. // 16. output: boolean value that specifies whether the re-ordered string shall be returned with higher ASCII chars HTML encoded
  159. $author = reArrangeAuthorContents($row['author'], // 1.
  160. true, // 2.
  161. "/ *; */", // 3.
  162. ", ", // 4.
  163. " and ", // 5.
  164. "/ *, */", // 6.
  165. ", ", // 7.
  166. " ", // 8.
  167. ".", // 9.
  168. false, // 10.
  169. true, // 11.
  170. true, // 12.
  171. "6", // 13.
  172. "1", // 14.
  173. " " . $markupPatternsArray["italic-prefix"] . "and __NUMBER_OF_AUTHORS__ others" . $markupPatternsArray["italic-suffix"], // 15.
  174. $encodeHTML); // 16.
  175. if (!preg_match("/\. *$/", $author))
  176. $record .= $author . ".";
  177. else
  178. $record .= $author;
  179. }
  180. if (!empty($row['year'])) // year
  181. {
  182. if (!empty($row['author']))
  183. $record .= " ";
  184. $record .= $row['year'] . ".";
  185. }
  186. if (!empty($row['title'])) // title
  187. {
  188. if (!empty($row['author']) || !empty($row['year']))
  189. $record .= " ";
  190. $record .= $row['title'];
  191. if (!preg_match("/[?!.]$/", $row['title']))
  192. $record .= ".";
  193. }
  194. // From here on we'll assume that at least one of the fields 'author', 'year' or 'title' did contain some contents
  195. // 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)
  196. if (!empty($row['editor'])) // editor
  197. {
  198. // Call the 'reArrangeAuthorContents()' function (defined in 'include.inc.php') in order to re-order contents of the author field. Required Parameters:
  199. // 1. input: contents of the author field
  200. // 2. input: boolean value that specifies whether the author's family name comes first (within one author) in the source string
  201. // ('true' means that the family name is followed by the given name (or initials), 'false' if it's the other way around)
  202. //
  203. // 3. input: pattern describing old delimiter that separates different authors
  204. // 4. output: for all authors except the last author: new delimiter that separates different authors
  205. // 5. output: for the last author: new delimiter that separates the last author from all other authors
  206. //
  207. // 6. input: pattern describing old delimiter that separates author name & initials (within one author)
  208. // 7. output: for the first author: new delimiter that separates author name & initials (within one author)
  209. // 8. output: for all authors except the first author: new delimiter that separates author name & initials (within one author)
  210. // 9. output: new delimiter that separates multiple initials (within one author)
  211. // 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)
  212. // 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)
  213. // 12. output: boolean value that specifies whether an author's full given name(s) shall be shortened to initial(s)
  214. //
  215. // 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
  216. // 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
  217. // 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
  218. //
  219. // 16. output: boolean value that specifies whether the re-ordered string shall be returned with higher ASCII chars HTML encoded
  220. $editor = reArrangeAuthorContents($row['editor'], // 1.
  221. true, // 2.
  222. "/ *; */", // 3.
  223. ", ", // 4.
  224. " and ", // 5.
  225. "/ *, */", // 6.
  226. ", ", // 7.
  227. " ", // 8.
  228. ".", // 9.
  229. false, // 10.
  230. true, // 11.
  231. true, // 12.
  232. "6", // 13.
  233. "1", // 14.
  234. " " . $markupPatternsArray["italic-prefix"] . "and __NUMBER_OF_AUTHORS__ others" . $markupPatternsArray["italic-suffix"], // 15.
  235. $encodeHTML); // 16.
  236. $record .= " " . $markupPatternsArray["italic-prefix"] . "In" . $markupPatternsArray["italic-suffix"] . " " . $editor;
  237. if (preg_match("/^[^;\r\n]+(;[^;\r\n]+)+$/", $row['editor'])) // there are at least two editors (separated by ';')
  238. $record .= ", " . $markupPatternsArray["italic-prefix"] . "eds" . $markupPatternsArray["italic-suffix"] . ".";
  239. else // there's only one editor (or the editor field is malformed with multiple editors but missing ';' separator[s])
  240. $record .= ", " . $markupPatternsArray["italic-prefix"] . "ed" . $markupPatternsArray["italic-suffix"] . ".";
  241. }
  242. $publication = preg_replace("/[ \r\n]*\(Eds?:[^\)\r\n]*\)/i", "", $row['publication']);
  243. if (!empty($publication)) // publication
  244. $record .= " " . $markupPatternsArray["italic-prefix"] . $publication . $markupPatternsArray["italic-suffix"] . ".";
  245. if (!empty($row['place'])) // place
  246. $record .= " " . $row['place'];
  247. if (!empty($row['publisher'])) // publisher
  248. {
  249. if (!empty($row['place']))
  250. $record .= ",";
  251. $record .= " " . $row['publisher'];
  252. }
  253. if (!empty($row['pages'])) // pages
  254. {
  255. if (!empty($row['place']) || !empty($row['publisher']))
  256. $record .= ", ";
  257. $record .= formatPageInfo($row['pages'], $markupPatternsArray["endash"]); // function 'formatPageInfo()' is defined in 'cite.inc.php'
  258. }
  259. if (!preg_match("/\. *$/", $record))
  260. $record .= ".";
  261. if (!empty($row['abbrev_series_title']) OR !empty($row['series_title'])) // if there's either a full or an abbreviated series title
  262. {
  263. $record .= " (";
  264. if (!empty($row['abbrev_series_title']))
  265. $record .= $row['abbrev_series_title']; // abbreviated series title
  266. // if there's no abbreviated series title, we'll use the full series title instead:
  267. elseif (!empty($row['series_title']))
  268. $record .= $row['series_title']; // full series title
  269. if (!empty($row['series_volume'])||!empty($row['series_issue']))
  270. $record .= " ";
  271. if (!empty($row['series_volume'])) // series volume
  272. $record .= $row['series_volume'];
  273. 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)
  274. $record .= "(" . $row['series_issue'] . ")";
  275. $record .= ".)";
  276. }
  277. }
  278. // --- BEGIN TYPE = BOOK WHOLE / CONFERENCE VOLUME / JOURNAL / MANUAL / MANUSCRIPT / MAP / MISCELLANEOUS / PATENT / REPORT / SOFTWARE ---
  279. else // if (preg_match("/Book Whole|Conference Volume|Journal|Manual|Manuscript|Map|Miscellaneous|Patent|Report|Software/", $row['type']))
  280. // note that this also serves as a fallback: unrecognized resource types will be formatted similar to whole books
  281. {
  282. if (!empty($row['author'])) // author
  283. {
  284. $author = preg_replace("/[ \r\n]*\(eds?\)/i", "", $row['author']);
  285. // Call the 'reArrangeAuthorContents()' function (defined in 'include.inc.php') in order to re-order contents of the author field. Required Parameters:
  286. // 1. input: contents of the author field
  287. // 2. input: boolean value that specifies whether the author's family name comes first (within one author) in the source string
  288. // ('true' means that the family name is followed by the given name (or initials), 'false' if it's the other way around)
  289. //
  290. // 3. input: pattern describing old delimiter that separates different authors
  291. // 4. output: for all authors except the last author: new delimiter that separates different authors
  292. // 5. output: for the last author: new delimiter that separates the last author from all other authors
  293. //
  294. // 6. input: pattern describing old delimiter that separates author name & initials (within one author)
  295. // 7. output: for the first author: new delimiter that separates author name & initials (within one author)
  296. // 8. output: for all authors except the first author: new delimiter that separates author name & initials (within one author)
  297. // 9. output: new delimiter that separates multiple initials (within one author)
  298. // 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)
  299. // 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)
  300. // 12. output: boolean value that specifies whether an author's full given name(s) shall be shortened to initial(s)
  301. //
  302. // 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
  303. // 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
  304. // 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
  305. //
  306. // 16. output: boolean value that specifies whether the re-ordered string shall be returned with higher ASCII chars HTML encoded
  307. $author = reArrangeAuthorContents($author, // 1.
  308. true, // 2.
  309. "/ *; */", // 3.
  310. ", ", // 4.
  311. " and ", // 5.
  312. "/ *, */", // 6.
  313. ", ", // 7.
  314. " ", // 8.
  315. ".", // 9.
  316. false, // 10.
  317. true, // 11.
  318. true, // 12.
  319. "6", // 13.
  320. "1", // 14.
  321. " " . $markupPatternsArray["italic-prefix"] . "and __NUMBER_OF_AUTHORS__ others" . $markupPatternsArray["italic-suffix"], // 15.
  322. $encodeHTML); // 16.
  323. // if the author is actually the editor of the resource we'll append ', ed' (or ', eds') to the author string:
  324. // [to distinguish editors from authors in the 'author' field, the 'modify.php' script does append ' (ed)' or ' (eds)' if appropriate,
  325. // so we're just checking for these identifier strings here. Alternatively, we could check whether the editor field matches the author field]
  326. if (preg_match("/[ \r\n]*\(ed\)/", $row['author'])) // single editor
  327. $author = $author . ", " . $markupPatternsArray["italic-prefix"] . "ed" . $markupPatternsArray["italic-suffix"];
  328. elseif (preg_match("/[ \r\n]*\(eds\)/", $row['author'])) // multiple editors
  329. $author = $author . ", " . $markupPatternsArray["italic-prefix"] . "eds" . $markupPatternsArray["italic-suffix"];
  330. if (!preg_match("/\. *$/", $author))
  331. $record .= $author . ".";
  332. else
  333. $record .= $author;
  334. }
  335. if (!empty($row['year'])) // year
  336. {
  337. if (!empty($row['author']))
  338. $record .= " ";
  339. $record .= $row['year'] . ".";
  340. }
  341. if (!empty($row['title'])) // title
  342. {
  343. if (!empty($row['author']) || !empty($row['year']))
  344. $record .= " ";
  345. $record .= $markupPatternsArray["italic-prefix"] . $row['title'] . $markupPatternsArray["italic-suffix"];
  346. if (!preg_match("/[?!.]$/", $row['title']))
  347. $record .= ".";
  348. }
  349. if (!empty($row['thesis'])) // thesis
  350. {
  351. $record .= " (" . $row['thesis'];
  352. $record .= ", " . $row['publisher'] . ".)";
  353. }
  354. else // not a thesis
  355. {
  356. if (!empty($row['place'])) // place
  357. $record .= " " . $row['place'];
  358. if (!empty($row['publisher'])) // publisher
  359. {
  360. if (!empty($row['place']))
  361. $record .= ",";
  362. $record .= " " . $row['publisher'];
  363. }
  364. // if (!empty($row['pages'])) // pages
  365. // {
  366. // if (!empty($row['place']) || !empty($row['publisher']))
  367. // $record .= ", ";
  368. //
  369. // $record .= formatPageInfo($row['pages'], $markupPatternsArray["endash"]); // function 'formatPageInfo()' is defined in 'cite.inc.php'
  370. // }
  371. if (!preg_match("/\. *$/", $record))
  372. $record .= ".";
  373. }
  374. if (!empty($row['abbrev_series_title']) OR !empty($row['series_title'])) // if there's either a full or an abbreviated series title
  375. {
  376. $record .= " (";
  377. if (!empty($row['abbrev_series_title']))
  378. $record .= $row['abbrev_series_title']; // abbreviated series title
  379. // if there's no abbreviated series title, we'll use the full series title instead:
  380. elseif (!empty($row['series_title']))
  381. $record .= $row['series_title']; // full series title
  382. if (!empty($row['series_volume'])||!empty($row['series_issue']))
  383. $record .= " ";
  384. if (!empty($row['series_volume'])) // series volume
  385. $record .= $row['series_volume'];
  386. 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)
  387. $record .= "(" . $row['series_issue'] . ")";
  388. $record .= ".)";
  389. }
  390. }
  391. // --- BEGIN POST-PROCESSING -----------------------------------------------------------------------------------------------------------
  392. // do some further cleanup:
  393. $record = trim($record); // remove any preceding or trailing whitespace
  394. return $record;
  395. }
  396. // --- END CITATION STYLE ---
  397. ?>