-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbib-single.php
More file actions
111 lines (97 loc) · 3.44 KB
/
bib-single.php
File metadata and controls
111 lines (97 loc) · 3.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
<?php
/*
Template Name: Bibliography Entry
Template Post Type: bib
*/
get_header(); ?>
<div class="wrap">
<div id="primary" class="content-area">
<main id="main" class="site-main" role="main">
<?php
/* Start the Loop */
while ( have_posts() ) :
the_post();
?>
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<?php
if ( is_sticky() && is_home() ) :
echo twentyseventeen_get_svg( array( 'icon' => 'thumb-tack' ) );
endif;
?>
<header class="entry-header">
<?php
the_title( '<h1 class="entry-title">', '</h1>' );
?>
</header><!-- .entry-header -->
<div class="entry-content">
<?php
//the_meta();
include 'bib-fields.php';
//print_r(get_post_meta($post->ID));
foreach($frontendfields as $fieldtitle => $fieldid) {
switch ($fieldid) {
case "url":
if (!empty(get_field('url'))){
if (strpos(get_field('url'), 'http') !== false) {
$val = "<a href='".$post->url."'>".$post->url."</a>";
} else {
$val = "<a href='http://doi.org/".$post->url."'>".$post->url."</a>";
}
} else {
$val = "";
}
break;
// case "type":
// //make reference type pretty (JOUR -> Journal)
// $val = $referencetypes[$post->type];
// break;
case "keywords":
case "authors":
case "editors":
case "series-authors":
$val = implode("</br>",$post->$fieldid);
break;
case "urls":
$val = implode("</br>", array_map(
function ($url) { return "<a href='".$url."'>$url</a>"; },
$post->urls)
);
break;
default:
$val = $post->$fieldid;
}
//do not display empty fields OR arrays that only contain another empty array
if (!empty($val) && !empty($val[0])) {
echo "<p><h4>" . $fieldtitle . "</h4>" . $val . "</p>";
}
}
//Generate .RIS download
require( plugin_dir_path( __FILE__ ) . 'lib/RefLib-master/reflib.php');
$newlib = new RefLib();
$newlib->SetContentsFile('.ris');
$newlib->refs[0]["title"] = $post->title;
foreach ($frontendfields as $title => $key) {
if ($post->$key) {
$newlib->refs[0][$key] = $post->$key;
}
}
$tofile = $newlib->GetContents(); // Output file to the browser
$tofile = str_replace("\\n", '', $tofile);
?>
<form action="http://wp-test.cpc.unc.edu/tonybird/wp-content/plugins/cpc-bibliography/download.php" method="post">
<input type="hidden" name="filename" value="<?php echo $post->id.".ris"; ?>">
<input type="hidden" name="tofile" value="<?php echo $tofile; ?>">
<input type="submit" name="submit" id="submit" value="Download as .RIS" />
</form>
</div><!-- .entry-content -->
</article><!-- #post-## -->
<?php
endwhile; // End of the loop.
?>
</main><!-- #main -->
</div><!-- #primary -->
<?php get_sidebar(); ?>
</div><!-- .wrap -->
<?php
get_footer();
?>