/
ProjectDetail.cfm
291 lines (277 loc) · 8.75 KB
/
ProjectDetail.cfm
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
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
<cfinclude template = "includes/_header.cfm">
<cfoutput>
<cfif listfindnocase(request.rdurl,"project","/") and isdefined("project_id") and isnumeric(project_id)>
<!-- where we want to be; don't need to do anything --->
<cfelseif not listfindnocase(request.rdurl,"project","/") and isdefined("project_id") >
<!--- just redirect to a bookmarkable URL--->
<cfheader statuscode="301" statustext="Moved permanently">
<cfheader name="Location" value="/project/#project_id#">
<cfelseif isdefined("niceProjName")>
<cfquery name="redir" datasource="user_login" username="#session.dbuser#" password="#decrypt(session.epw,session.sessionKey)#">
select project_id from project where niceURL(project_name)='#niceProjName#'
</cfquery>
<cfif redir.recordcount is 1>
<!--- old format; keep this usable, but redirect to new --->
<p>
Redirecting to <a href="/project/#redir.project_id#">/project/#redir.project_id#</a>
</p>
<cfheader statuscode="301" statustext="Moved permanently">
<cfheader name="Location" value="/project/#redir.project_id#">
<cfabort>
<cfelse>
<div class="error">
Project not found.
<br>Try <a href="/SpecimenUsage.cfm">searching</a>
</div>
<cfthrow message="Project not found.">
<cfabort>
</cfif>
<cfelse>
<div class="error">
invalid call
<br>Try <a href="/SpecimenUsage.cfm">searching</a>
</div>
<cfthrow message="invalid project call">
<cfabort>
</cfif>
<style>
.proj_title {font-size:2em;font-weight:900;text-align:center;}
.proj_sponsor {font-size:1.5em;font-weight:800;text-align:center;}
.proj_agent {font-weight:800;text-align:center;}
.cdiv {text-align:center;}
</style>
<script type='text/javascript' language="javascript" src='https://cdn.rawgit.com/showdownjs/showdown/1.5.0/dist/showdown.min.js'></script>
<script type="text/javascript" language="javascript">
function load(name){
var el=document.getElementById(name);
var ptl="/includes/project/" + name + ".cfm?project_id=#project_id#";
jQuery.get(ptl, function(data){
jQuery(el).html(data);
if (name=='pubs'){
fetchMediaMeta();
}
})
}
jQuery(document).ready(function(){
// this doesn't work in includes for some reason so here it is...
$('body').on('click', '.modalink', function(e) {
e.preventDefault();
var d=$(this).attr("data-doi");
showPubInfo(d);
});
var elemsToLoad='pubs,specUsed,specCont,projCont,projUseCont,projTaxa';
var elemAry = elemsToLoad.split(",");
for(var i=0; i<elemAry.length; i++){
load(elemAry[i]);
}
var am='/form/inclMedia.cfm?q=#project_id#&typ=project&tgt=projMedia';
jQuery.get(am, function(data){
jQuery('##projMedia').html(data);
})
// convert project description, which is stored as markdown, to html
// grab the markdown text
var mdtext = $("##ht_desc_orig").html();
// users can disable this by using <nomd> tags
if (mdtext.trim().substring(0,6) != '<nomd>'){
// convert to markdown
var converter = new showdown.Converter();
// people are used to github, so....
showdown.setFlavor('github');
converter.setOption('strikethrough', 'true');
converter.setOption('simplifiedAutoLink', 'true');
// make some HTML
var htmlc = converter.makeHtml(mdtext);
// add the HTML to the appropriate div
$("##ht_desc").html(htmlc);
// hide the original
$("##ht_desc_orig").hide();
}
});
</script>
<cfquery name="proj" datasource="user_login" username="#session.dbuser#" password="#decrypt(session.epw,session.sessionKey)#">
SELECT
project.project_id,
project_name,
project_description,
start_date,
end_date,
preferred_agent_name.agent_name,
agent_position,
project_agent_role,
project_agent_remarks,
funded_usd,
award_number
FROM
project,
project_agent,
preferred_agent_name
WHERE
project.project_id = project_agent.project_id (+) AND
project_agent.agent_id = preferred_agent_name.agent_id (+) and
project.project_id = #project_id#
</cfquery>
<cfquery name="p" dbtype="query">
select
project_id,
project_name,
project_description,
start_date,
end_date,
funded_usd
from
proj
group by
project_id,
project_name,
project_description,
start_date,
end_date,
funded_usd
</cfquery>
<cfquery name="a" dbtype="query">
select
agent_name,
project_agent_role,
project_agent_remarks,
award_number
from
proj
group by
agent_name,
project_agent_role,
project_agent_remarks,
award_number
order by
agent_position
</cfquery>
<!----
<cfquery name="s" dbtype="query">
select
agent_name,
project_agent_remarks
from
proj
where
project_agent_role='Sponsor'
group by
agent_name,
project_agent_remarks
</cfquery>
---->
<span class="annotateSpace">
<cfif len(session.username) gt 0>
<cfquery name="existingAnnotations" datasource="user_login" username="#session.dbuser#" password="#decrypt(session.epw,session.sessionKey)#">
select count(*) cnt from annotations
where project_id = #project_id#
</cfquery>
<a href="javascript: openAnnotation('project_id=#project_id#')">
[ Comment or report bad data ]
<cfif #existingAnnotations.cnt# gt 0>
<br>(#existingAnnotations.cnt# existing)
</cfif>
</a>
<cfelse>
<a href="/login.cfm">Login or Create Account</a>
</cfif>
</span>
<cfset noHTML=replacenocase(p.project_name,'<i>','','all')>
<cfset noHTML=replacenocase(noHTML,'</i>','','all')>
<cfset title = "Project Detail: #noHTML#">
<div class="proj_title">#p.project_name#</div>
<!----
<cfloop query="s">
<div class="proj_sponsor">
Sponsored by #agent_name# <cfif len(project_agent_remarks) gt 0>: #project_agent_remarks#</cfif>
</div>
</cfloop>
---->
<cfloop query="a">
<div class="proj_agent">
<a target="_blank" href="/agent.cfm?agent_name=#agent_name#">#agent_name#</a>:
#project_agent_role#<cfif len(project_agent_remarks) gt 0> (#project_agent_remarks#)</cfif>
<cfif len(award_number) gt 0>
<div style="margin-left:2em;font-size:smaller;">
Award Number <a target="_blank" class="external" href="https://search.crossref.org/?q=#award_number#">#award_number#</a>
</div>
</cfif>
</div>
</cfloop>
<div class="cdiv">
#dateformat(p.start_date,"yyyy-mm-dd")# - #dateformat(p.end_date,"yyyy-mm-dd")#
</div>
<cfif isdefined("session.roles") and listfindnocase(session.roles,"manage_publications")>
<p><a href="/Project.cfm?Action=editProject&project_id=#p.project_id#">Edit Project</a></p>
</cfif>
<h2>Description</h2>
<div id="ht_desc"></div>
<div id="ht_desc_orig">#p.project_description#</div>
<cfquery name="supported_research_value" datasource="user_login" username="#session.dbuser#" password="#decrypt(session.epw,session.sessionKey)#">
SELECT
sum(funded_usd) supported_research_value
FROM
project
WHERE
project.project_id IN (
SELECT
project_trans.project_id
FROM
project,
project_trans,
loan_item,
specimen_part,
cataloged_item
where
project_trans.transaction_id = loan_item.transaction_id AND
loan_item.collection_object_id = specimen_part.collection_object_id AND
specimen_part.derived_from_cat_item=cataloged_item.collection_object_id and
project_trans.project_id = project.project_id AND
cataloged_item.collection_object_id IN (
SELECT
cataloged_item.collection_object_id
FROM
project,
project_trans,
accn,
cataloged_item
WHERE
accn.transaction_id = cataloged_item.accn_id AND
project_trans.transaction_id = accn.transaction_id AND
project_trans.project_id = project.project_id AND
project.project_id = #project_id#
)
)
</cfquery>
<cfif len(p.funded_usd) gt 0>
<cfset f="This project was funded for $#p.funded_usd#">
<cfif len(supported_research_value.supported_research_value) gt 0>
<cfset f=f & ", and has supported projects funded for $#supported_research_value.supported_research_value#">
</cfif>
<div class="funded_usd">
#f#.
</div>
</cfif>
<div id="pubs">
<img src="/images/indicator.gif">
</div>
<div id="specUsed">
<img src="/images/indicator.gif">
</div>
<div id="specCont">
<img src="/images/indicator.gif">
</div>
<div id="projCont">
<img src="/images/indicator.gif">
</div>
<div id="projUseCont">
<!---<h2>Projects using contributed specimens</h2>--->
<img src="/images/indicator.gif">
</div>
<h2>Media</h2>
<div id="projMedia">
<img src="/images/indicator.gif">
</div>
<div id="projTaxa">
<img src="/images/indicator.gif">
</div>
</cfoutput>
<cfinclude template = "includes/_footer.cfm">