-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathindex.php
More file actions
251 lines (175 loc) · 9.53 KB
/
index.php
File metadata and controls
251 lines (175 loc) · 9.53 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
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
<?php
// variables for permitted/prohibited qualifiers (this should match up with the available qualifiers in the license module)
//permitted terms will display green checkbox
$permittedQualifier = 'Permitted';
//prohibited terms will display red x
$prohibitedQualifier = 'Prohibited';
/*
**************************************************************************************************************************
** CORAL Licensing Module Terms Tool Add-On Terms Tool Add-On v. 1.0
**
** Copyright (c) 2010 University of Notre Dame
**
** This file is part of CORAL.
**
** CORAL is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
**
** CORAL is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License along with CORAL. If not, see <http://www.gnu.org/licenses/>.
**
**************************************************************************************************************************
*/
include_once 'directory.php';
//get the passed in ISSN or ISBN
if (isset($_GET['issn'])) $issn = $_GET['issn']; else $issn='';
if (isset($_GET['isbn'])) $isbn = $_GET['isbn']; else $isbn='';
//either isbn or isn must be passed in
if (($isbn == '') && ($issn == '')){
$displayHTML = 'You must pass in either ISSN or ISBN.';
}else{
try{
//get targets from the terms tool service for this ISBN or ISSN
$termsServiceObj = new TermsService(new NamedArguments(array('issn' => $issn, 'isbn' => $isbn)));
$termsToolObj = $termsServiceObj->getTermsToolObj();
$targetsArray = array();
$targetsArray = $termsToolObj->getTargets();
if (count($targetsArray) == 0){
$displayHTML = "Sorry, no Full Text Providers are available for this ISSN/ISBN";
}else{
//if expression type ID is passed in, display the terms
if (isset($_GET['typeID'])){
$typeID = $_GET['typeID'];
$expressionType = new ExpressionType(new NamedArguments(array('primaryKey' => $typeID)));
$pageTitle = $expressionType->shortName . " License Terms";
$displayHTML = "<div class='darkShaded' style='width:664px; padding:8px; margin:0 0 7px 0;'><span class='headerText'>" . $expressionType->shortName . " Terms</span> for " . $termsToolObj->getTitle() . "</div>";
$displayHTML .= "<div style='margin-left:5px;'>";
$orderedTargetsArray = array();
$orderedTargetsArray = $expressionType->reorderTargets($targetsArray);
$targetArray = array();
foreach ($orderedTargetsArray as $i => $targetArray){
$displayHTML .= "<span class='titleText'>" . $targetArray['public_name'] . "</span><br />";
$expressionArray = array();
$expressionArray = $expressionType->getExpressionsByResource($targetArray['public_name']);
//if no expressions are defined for this resource / expression type combination
if (count($expressionArray) == '0'){
$displayHTML .= "No " . $expressionType->shortName . " terms are defined.<br /><br />";
}else{
//loop through each expression for this resource / expression type combination
foreach ($expressionArray as $expression){
//get qualifiers into an array
$qualifierArray = array();
foreach ($expression->getQualifiers as $qualifier){
$qualifierArray[] = $qualifier->shortName;
if (strtoupper($qualifier->shortName) == strtoupper($permittedQualifier)){
$qualifierImage = "<img src='images/icon_check.gif'>";
}else if (strtoupper($qualifier->shortName) == strtoupper($prohibitedQualifier)){
$qualifierImage = "<img src='images/icon_x.gif'>";
}else{
$qualifierImage = "";
}
}
//determine document effective date
$document = new Document(new NamedArguments(array('primaryKey' => $expression->documentID)));
if ((!$document->effectiveDate) || ($document->effectiveDate == '0000-00-00')){
$effectiveDate = format_date($document->getLastSignatureDate());
}else{
$effectiveDate = format_date($document->effectiveDate);;
}
$displayHTML .= "Terms as of " . format_date($expression->getLastUpdateDate) . ". ";
$displayHTML .= "The following terms apply ONLY to articles accessed via <a href='" . $targetArray['target_url'] . "' target='_blank'>" . $targetArray['public_name'] . "</a><br /><br />";
$displayHTML .= "<div style='margin:0 0 30px 20px;'>";
$displayHTML .= "<div class='shaded' style='width:630px; padding:3px;'>";
$displayHTML .= "<b>" . $expressionType->shortName . " Notes:</b> " . $qualifierImage;
//start bulletted list
$displayHTML .= "<ul>\n";
//first in the bulleted list will be the list of qualifiers, if applicable
if (count($qualifierArray) > 0){
$displayHTML .= "<li>Qualifier: " . implode(",", $qualifierArray) . "</li>\n";
}
foreach ($expression->getExpressionNotes as $expressionNote){
$displayHTML .= "<li>" . $expressionNote->note . "</li>\n";
}
$displayHTML .= "</ul>\n";
$displayHTML .= "</div>";
//only display 'show license snippet' if there's actual license document text
if ($expression->documentText){
$displayHTML .= "<br />";
$displayHTML .= "<div id='div_hide_" . $expression->expressionID . "_" . $i . "' style='width:600px;'>";
$displayHTML .= "<a href='javascript:void(0);' class='showText smallLink' value='" . $expression->expressionID . "_" . $i . "'><img src='images/arrowright.gif'></a> <a href='javascript:void(0);' class='showText' value='" . $expression->expressionID . "_" . $i . "'>view license snippet</a>";
$displayHTML .= "</div>";
$displayHTML .= "<div id='div_display_" . $expression->expressionID . "_" . $i . "' style='display:none; width:600px;'>";
$displayHTML .= "<a href='javascript:void(0);' class='hideText smallLink' value='" . $expression->expressionID . "_" . $i . "'><img src='images/arrowdown.gif'></a> <a href='javascript:void(0);' class='hideText' value='" . $expression->expressionID . "_" . $i . "'>hide license snippet</a><br />";
$displayHTML .= "<div class='shaded' style='margin-top: 5px; padding:5px 5px 5px 18px;'>From the license agreement ($effectiveDate):<br><br><i>" . nl2br($expression->documentText) . "</i></div>";
$displayHTML .= "</div>";
}
$displayHTML .= "</div>";
//end expression loop
}
//end expression count
}
//target foreach loop
}
$displayHTML .= "</div>";
//expression type ID was not passed in - find out what expression types are available for these targets and prompt
}else{
$pageTitle = "Select Expression Type";
$expressionTypeObj = new ExpressionType();
$targetArray = array();
$uniqueExpressionTypeArray = array();
foreach ($targetsArray as $i => $targetArray){
$expressionTypeArray = $expressionTypeObj->getExpressionTypesByResource($targetArray['public_name']);
//loop through each displayable expression type and add to final array
foreach ($expressionTypeArray as $expressionTypeID){
$uniqueExpressionTypeArray[] = $expressionTypeID;
}
//end target loop
}
//make sure expression type IDs are unique
$uniqueExpressionTypeArray = array_unique($uniqueExpressionTypeArray);
if (count($uniqueExpressionTypeArray) == 0){
$displayHTML = "Sorry, no available license expressions have been located in CORAL Licensing.";
}else{
$displayHTML .= "<div class='darkShaded' style='width:664px; padding:8px; margin:0 0 15px 0;'><span class='headerText'>Available Expression Types</span> for " . $termsToolObj->getTitle() . "</div>";
//loop through each distinct displayable expression type
foreach ($uniqueExpressionTypeArray as $expressionTypeID){
$expressionType = new ExpressionType(new NamedArguments(array('primaryKey' => $expressionTypeID)));
$displayHTML .= " <a href='?issn=" . $issn . "&isbn=" . $isbn . "&typeID=" . $expressionType->expressionTypeID . "'>" . $expressionType->shortName . "</a><br />";
}
$displayHTML .= "<br />";
}
}
//end target count
}
}catch(Exception $e){
$displayHTML = $e->getMessage() . " Please verify your information in the configuration.ini file and try again.";
}
//end if isbn/issn passed in
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><?php echo $pageTitle; ?></title>
<link rel="stylesheet" href="css/style.css" type="text/css" />
<script type="text/javascript" src="js/plugins/jquery.js"></script>
<script type="text/javascript" src="js/index.js"></script>
</head>
<body>
<center>
<table style='text-align:left;'>
<tr>
<td style='vertical-align:top;'>
<table style='background: white; padding:10px;'>
<tr>
<td><?php echo $displayHTML; ?></td>
</tr>
</table>
</td>
</tr>
</table>
<br />
</center>
</body>
</html>