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.

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