-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsingle-issues.php
197 lines (184 loc) · 11.5 KB
/
single-issues.php
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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
<?php get_header(); ?>
<?php
the_post();
?>
<div id="issue-wrapper">
<div class="col-md-9">
<div id="issue-title"><?php the_title(); ?></div>
<div id="issue-header">
<?php if (has_post_thumbnail()) { ?>
<div id="issue-image"><?php the_post_thumbnail('medium'); ?></div>
<?php } ?>
<div id="issue-excerpt">
<?php the_content(); ?>
</div>
</div>
<div id="issue-articles">
<?php
if (get_post_type() == 'issues' && !is_archive() && get_the_ID() == 4) {
$postArray = array();
$postId = get_post_meta(get_the_ID(), 'articles', true);
foreach ($postId as $id) {
$t_post = get_post($id);
if ($t_post) {
$postArray[] = $t_post;
}
}
?>
<?php
foreach ($postArray as $t_post) {
if ($t_post->post_status != "trash" and $t_post->post_status != "inherit") {
?>
<div class="row" id="online-<?php echo $t_post->ID; ?>">
<div class="col-md-8 col-sm-8 article-section-title-author">
<div class="row">
<div class="col-md-12">
<a class="issue-section-article-title"
href="<?php echo get_permalink($t_post->ID); ?>">
<?php $new_post = get_post_meta($t_post->ID, 'show_new_button', true);
if ($new_post == 1) { ?>
<img src="<?php echo get_template_directory_uri(); ?>/images/tag-new-icon.jpg"
alt="tag-new-icon.jpg">
<?php } ?>
<?php echo $t_post->post_title; ?>
</a>
</div>
</div>
<div class="row">
<div class="col-md-12 issue-article-author">
<?php
$authors = get_post_meta($t_post->ID, 'authors', true);
$authors_array = array();
if (is_array($authors)) {
foreach ($authors as $author) $authors_array[] = $author['first_name'] . ' ' . $author['middle_name'] . ' ' . $author['last_name'];
echo implode(', ', $authors_array);
}
?>
</div>
</div>
<!-- Peer Review
<div class="row">
<div class="col-md-12 onlineFirst">
<?php
$peers = get_post_meta($t_post->ID, 'peers', true);
$peers_array = array();
//print_r($authors);
if (is_array($peers)) {
foreach ($peers as $peer) $peers_array[] = $peer['first_name'] . ' ' . $peer['middle_name'] . ' ' . $author['last_name'];
echo implode(', ', $peers_array);
}
?>
</div>
</div> -->
<!-- End Peer Review -->
<div class="row">
<div class="col-md-12">
<?php $uri = $_SERVER['REQUEST_URI'];
if (strpos($uri, 'online-first') !== false) { ?>
<p class="issue-article-date"><?php
$publish_date = get_post_meta($t_post->ID, 'article_pub_date', true);
echo date("F j, Y", strtotime($publish_date));
?></p>
<?php } else {
} ?>
</div>
</div>
</div>
<div class="col-md-4 col-sm-4 article-galley-file">
<a class="tocPages-pg"><?php echo get_post_meta($t_post->ID, 'page_range', true); ?></a>
<?php
$pdfUrl = add_query_arg('galley', 'pdf', get_permalink($t_post->ID));
$pdf_file = get_post_meta($t_post->ID, 'pdf_file', true);
$htmlUrl = add_query_arg('galley', 'html', get_permalink($t_post->ID));
?>
<a class="tocGalleyFile" href="<?php echo get_permalink($t_post->ID); ?>">View</a>
<?php if (get_post_meta($t_post->ID, 'pdf_file', true)) { ?>
<a class="tocGalleyFile" href="<?php echo $pdf_file; ?>">Download PDF</a>
<?php } ?>
</div>
</div>
<?php
}
}
}
// Code for current issue
if (get_post_type() == 'issues' && !is_archive() && get_the_ID() != 4) {
$category_array = array();
$articles_id = get_post_meta(get_the_ID(), 'articles', true);
foreach ($articles_id as $id) {
$t_post = get_post($id);
$category = get_the_category($t_post->ID);
if ($category) {
if (!isset($category_array[$category[0]->cat_name]))
$category_array[$category[0]->cat_name] = array();
$category_array[$category[0]->cat_name][] = $t_post;
}
}
foreach ($category_array as $category_name => $t_post_array) {
?>
<h4 class="tocSectionTitle"><?php echo $category_name; ?></h4>
<?php
foreach ($t_post_array as $t_post) {
if ($t_post->post_status != "trash") {
?>
<div class="row issue-article-row">
<div class="col-md-8 col-sm-8 article-section-title-author">
<div class="row">
<div class="col-md-12">
<a class="issue-section-article-title"
href="<?php echo get_permalink($t_post->ID); ?>">
<?php $new_post = get_post_meta($t_post->ID, 'show_new_button', true);
if ($new_post == 1) {
?>
<img src="<?php echo get_template_directory_uri(); ?>/images/tag-new-icon.jpg"
alt="tag-new-icon.jpg">
<?php } ?>
<?php echo $t_post->post_title; ?></a>
</div>
</div>
<div class="row">
<div class="col-md-12 issue-article-author">
<?php
$authors = get_post_meta($t_post->ID, 'authors', true);
$authors_array = array();
//print_r($authors);
if (is_array($authors)) {
foreach ($authors as $author) $authors_array[] = $author['first_name'] . ' ' . $author['middle_name'] . ' ' . $author['last_name'];
echo implode(', ', $authors_array);
}
?>
</div>
</div>
<div class="row">
<div class="col-md-12">
<p class="issue-article-date"><?php
$publish_date = get_post_meta($t_post->ID, 'article_pub_date', true);
echo date("F j, Y", strtotime($publish_date));
?>
</p>
</div>
</div>
</div>
<div class="col-md-4 col-sm-4 article-galley-file">
<a class="tocPages-pg"><?php echo get_post_meta($t_post->ID, 'page_range', true); ?></a>
<?php
$pdfUrl = add_query_arg('galley', 'pdf', get_permalink($t_post->ID));
$pdf_file = get_post_meta($t_post->ID, 'pdf_file', true);
$htmlUrl = add_query_arg('galley', 'html', get_permalink($t_post->ID));
?>
<a class="tocGalleyFile" href="<?php echo get_permalink($t_post->ID); ?>">View</a>
<?php if (get_post_meta($t_post->ID, 'pdf_file', true)) { ?>
<a class="tocGalleyFile" href="<?php echo $pdf_file; ?>">Download PDF</a>
<?php } ?>
<?php } ?>
</div>
</div>
<?php
}
}
}
?>
</div>
</div>
</div>
<?php get_footer(); ?>