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.

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