/lib/contents/cite.inc.php

https://gitlab.com/mucill/majalengka · PHP · 88 lines · 45 code · 7 blank · 36 comment · 9 complexity · e191c60b6c3a04e52edbf3ef615ee8ff MD5 · raw file

  1. <?php
  2. /**
  3. *
  4. * Citation page
  5. * Copyright (C) 2015 Arie Nugraha (dicarve@yahoo.com)
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; either version 2 of the License, or
  10. * (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, write to the Free Software
  19. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  20. *
  21. */
  22. // be sure that this file not accessed directly
  23. if (!defined('INDEX_AUTH')) {
  24. die("can not access this file directly");
  25. } elseif (INDEX_AUTH != 1) {
  26. die("can not access this file directly");
  27. }
  28. $cite_style = 'apa';
  29. $biblio_id = 0;
  30. if (isset($_GET['id'])) {
  31. $biblio_id = (integer)$_GET['id'];
  32. }
  33. /*
  34. if (isset($_GET['style'])) {
  35. $cite_style = strtolower(trim($_GET['style']));
  36. }
  37. $cite_style_template = SB.'template'.DS.'citation'.DS.$cite_style.'_style_template.php';
  38. if (!file_exists($cite_style_template)) {
  39. exit(__('Sorry, no cite template available.'));
  40. }
  41. */
  42. require SIMBIO.'simbio_FILE/simbio_directory.inc.php';
  43. $dir = new simbio_directory(SB.'template'.DS.$sysconf['template']['theme'].DS.'citation');
  44. $style_files = $dir->getFileList();
  45. // create Biblio
  46. $biblio = new Biblio($dbs, $biblio_id);
  47. $biblio_detail = $biblio->detail();
  48. // var_dump($biblio_detail);
  49. extract($biblio_detail);
  50. // Pre-proccess author
  51. $authors_string = '';
  52. $author_list = array();
  53. $last_author = '';
  54. $a = 0;
  55. foreach ($authors as $auth) {
  56. // invert first author name if it is not inverted
  57. if ($a == 0 && stripos($auth['author_name'], ',', 2) === false) {
  58. $last_name = strrpos($auth['author_name'], ' ') + 1;
  59. $name = substr($auth['author_name'], $last_name);
  60. die($name);
  61. $author_list[] = $name;
  62. } else {
  63. $author_list[] = $auth['author_name'];
  64. }
  65. $last_author = $auth['author_name'];
  66. $a++;
  67. }
  68. $authors_string = implode(', ', $author_list);
  69. foreach ($style_files as $file) {
  70. if (false === stripos($file, '_style_template.php')) {
  71. continue;
  72. } else {
  73. include_once SB.'template'.DS.$sysconf['template']['theme'].DS.'citation'.DS.$file;
  74. }
  75. }
  76. // main content
  77. $main_content = ob_get_clean();
  78. // page title
  79. echo $main_content;
  80. echo '<p class="spacer">&nbsp;</p>';
  81. exit();