-
Notifications
You must be signed in to change notification settings - Fork 0
/
da_catalog_index.php
208 lines (149 loc) · 7.76 KB
/
da_catalog_index.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
197
198
199
200
201
202
203
204
205
206
207
208
<!DOCTYPE html>
<?php include("../_includes/SSDA_LibraryTopPanel.php") ?>
<title>Social Science Data Archive | UCLA Library</title>
<?php include("../_includes/SSDA_LibrarySidePanel.php") ?>
<div class="panel-pane pane-bean-text-block pane-bean-ssda-schedule-appointment">
<div class="pane-content">
<div class="entity entity-bean bean-text-block clearfix">
<div class="content">
<div class="field field--name-field-text-block field--type-text-long field--label-hidden"><div class="field__items"><div class="field__item even"><p>Have questions about your research? <a href="mailto:libbie@g.ucla.edu?subject=Research%20questions">We can help?</a></p>
</div></div></div> </div>
</div>
</div>
</div>
</div>
<div class="l-region l-region--main-column">
<!-- data archive menubar - library in-house version -->
<?php
include("../_includes/SSDA_menubar_libraryInHouse.php");
//
// SSDA_menubar.php has the menu code for da_catalog, da_catalog_fielder(fielder collection) and 'archive reources'
//
?>
<!-- data archive google analytics tracking script -->
<?php include_once("../_includes/analyticstracking.php") ?>
<div class="l-region l-region--main">
<div class="panel-pane pane-node-body">
<div class="pane-content">
<div class="field field--name-body field--type-text-with-summary field--label-hidden"><div class="field__items"><div class="field__item even">
<!---------------------------------------------------------------------------------------------- -->
<!--ssda page code goes here -->
<H2 align="center">Index Terms</H2>
<table width='85%' align="center" cols=1><tr align="left"><td align="left">
These are broad terms we use to organize the collection into categories. You should also search the <a href='http://www.icpsr.umich.edu/access/index.html'>ICPSR catalog</a> where you can narrow your search and find studies more precisely. To navigate this page you may scroll the list, or click on a letter to search for terms beginning with that letter. For any questions please contact <a href='mailto:libbie@ucla.edu'>Elizabeth Stephenson.</a> </td></tr></table><br>
<A NAME="IND"></A>
<?php
//error_reporting(E_ALL);
//ini_set('display_errors', 1);
$currentHTTP = "http://data-archive.library.ucla.edu/da_catalog/";
//SSDA_menubar.php has the menu code for da_catalog, da_catalog_fielder(fielder collection) and 'archive reources'
include("../_includes/SSDA_librarydatabase.php"); //SSDA_menubar.php has the menu code for da_catalog, da_catalog_fielder(fielder collection) and 'archive reources'
// class for database connections
include "../_classes/class.Database.php";
// sql query statement
// old query did not exclude the items marked Restricted
// $query = "select title.Title, title.StudyNum, shfull.subject, Left(shfull.subject,1) AS firstLetterIndex, count(*) as titlePerSubjectCount FROM (title INNER JOIN shcode ON title.tisort = shcode.tisort) INNER JOIN shfull ON shcode.subjectcode = shfull.subjectcode group by shfull.subject ORDER BY shfull.subject";
// NEW query excludes the itmes marked Restricted
$query = "select title.Title, title.StudyNum, shfull.subject, Left(shfull.subject,1) AS firstLetterIndex, count(*) as titlePerSubjectCount FROM (title INNER JOIN shcode ON title.tisort = shcode.tisort) INNER JOIN shfull ON shcode.subjectcode = shfull.subjectcode where title.Restricted <> '*' group by shfull.subject ORDER BY shfull.subject";
// class.Database.php is the class to make PDO connections
// initialize new db connection instance
$db = new Database();
// prepare query
$db->prepareQuery($query);
// execute query
$result = $db->executeQuery();
//$result = $db->resultset(); // execute the query
if (!$result) {
die ("Could not query the database: <br />");
} // else { echo "Successfully queried the database.<br>";
// the index term list
$indexList=array();
// first letter of indext term list
$indexFirstLetterList=array();
$row_index = 0;
while ($row = $db->getRow()) {
// Non-PDO code ---------------------
$indexList[$row_index]["title"] = $row['Title'];
$indexList[$row_index]["studynum"] = $row['StudyNum'];
$indexList[$row_index]["indexTerm"] = $row['subject'];
$indexList[$row_index]["firstLetterIndex"] = $row['firstLetterIndex'];
$indexList[$row_index]["titlePerSubjectCount"] = $row['titlePerSubjectCount'];
$indexFirstLetterList[$row_index] = $row['firstLetterIndex'];
$row_index++;
}
$totalRows = count($indexFirstLetterList);
// build the first letter list
echo "<h3 align='center'>";
$indexFirstLetterList = array_unique($indexFirstLetterList);
sort($indexFirstLetterList);
foreach($indexFirstLetterList as $key => $value) {
echo "|<A HREF='#$value'> $value </A>";
//echo " | $index_letter ";
}
echo "|</h3>";
// print out the subject terms, sort by first letter
//----------------------------------------------------------------------------
//
// begin the for-loop to read through the entire array
//
//----------------------------------------------------------------------------
//echo "<tr><td>$subject</td></tr>";
//}
$totalFirstLetters = count($indexFirstLetterList);
$firstLetterPrevious = NULL;
//echo "first letter total: $totalFirstLetters<br>";
echo "<ul style='text-align: left; margin: 30; margin-left: 50;'>"; // start of the ul list
//foreach($indexFirstLetterList as $key => $firstLetter ) {
for ($row_index = 0; $row_index < $totalRows; $row_index++ ) {
$title = $indexList[$row_index]["title"];
$studynum = $indexList[$row_index]["studynum"];
$indexTerm = $indexList[$row_index]["indexTerm"];
$firstLetterIndex = $indexList[$row_index]["firstLetterIndex"];
$titlePerSubjectCount = $indexList[$row_index]["titlePerSubjectCount"];
if ($firstLetterPrevious != $firstLetterIndex ) { // ie. this is the FIREST time printing the the first Letter - echo gettype($value), "\n";
// previous unsafe code - country=$country'
echo "<h2 style='text-align: left;'><a id='$firstLetterIndex'>$firstLetterIndex</a></h2>";
echo "</ul>"; // end previous
echo "<ul style='text-align: left; margin: 30; margin-left: 50;'>"; // start new list
$firstLetterPrevious = $firstLetterIndex ; // so you can compare the previous value of $firstLetterIndex with the provious one
}
echo "<li type='disc'> <a href='";
// - if there is only 1 record then link to that record
// -- otherwise if there is more than one record, list the titles
if ($titlePerSubjectCount > 1) {
echo $currentHTTP . "da_catalog_titlesByIndexTerm.php?indexTerm=$indexTerm";
} else {
echo $currentHTTP . "da_catalog_titleRecord.php?studynumber=$studynum";
}
echo "'>$indexTerm</a></h4>";
// - decision to print titlE or titleE(S)
echo " ($titlePerSubjectCount ";
if ($titlePerSubjectCount > 1) {
echo "titles)";
} else {
echo "title)";
}
echo "";
echo "</li>";
}
//----------------------------------------------------------------------------
//
// end of the for-loop
//
//----------------------------------------------------------------------------
echo "</ul>"; // end of the ul list
// put link to return to top of page ---
echo "<a href='#top'>Return to top of the page</a>";
//----------------------------------------------------------------------------
//
// end of the for-loop
//
//----------------------------------------------------------------------------
// close the connection
// _destructor class closes connection
// close the connection
//$PDO_connection = null;
?> <!--end container -->
<!---------------------------------------------------------------------------------------------- -->
<?php include("../_includes/SSDA_LibraryBottomPanel.php") ?>
</body></html>