1 |
<?php |
2 |
// Load globals |
3 |
require_once ("global_vars.php"); |
4 |
|
5 |
|
6 |
// Includes |
7 |
require_once ("db_connect.php"); |
8 |
require_once ("public_controls.php"); |
9 |
|
10 |
|
11 |
// Continue only if we now have a valid page |
12 |
if ($page_id > 0 ) { |
13 |
|
14 |
/********************************************************** |
15 |
** 1 = stats module and redirect, 0 = direct link to URL ** |
16 |
**********************************************************/ |
17 |
$libstats = 1; |
18 |
|
19 |
|
20 |
// If stats are enabled, add a hit to the page load statistics |
21 |
if ($libstats == 1) { |
22 |
pageLoadStats($page_id); |
23 |
} |
24 |
|
25 |
|
26 |
/**************** |
27 |
** Page header ** |
28 |
****************/ |
29 |
|
30 |
$sql = "SELECT * from page, style WHERE page.style_id = style.style_id AND page_id = " . $page_id; |
31 |
|
32 |
// Debugging |
33 |
// printf("sql was: %s<BR>", $sql); |
34 |
|
35 |
$rs = mysql_tryquery($sql); |
36 |
$row = mysql_fetch_array ($rs, MYSQL_ASSOC); |
37 |
|
38 |
// Fetch data |
39 |
$pagetype_id = $row["pagetype_id"]; |
40 |
$page_title = $row["page_title"]; |
41 |
$pagetitle_style = $row["pagetitle_style"]; |
42 |
$style_id = $row["style_id"]; |
43 |
$header_file = $row["header_file"]; |
44 |
$footer_file = $row["footer_file"]; |
45 |
$css_file = $row["css_file"]; |
46 |
$staff_coordinator = $row["staff_coordinator"]; |
47 |
$display_toc = $row["display_toc"]; |
48 |
$wrap_toc = $row["wrap_toc"]; |
49 |
$display_up = $row["display_up"]; |
50 |
$up_text = $row["up_text"]; |
51 |
$pageheader = $row["pageheader"]; |
52 |
|
53 |
// This is a print-friendly version. Force display_urls = 1 |
54 |
$display_urls = 1; |
55 |
|
56 |
// Load header include |
57 |
if ($style_id > 1 && strlen($header_file) > 0) { |
58 |
|
59 |
// If using a predefined style, load its header file (not LibData staff header) |
60 |
require_once ($header_file); |
61 |
} |
62 |
else { |
63 |
|
64 |
// Default library public interface (not LibData staff header) |
65 |
require_once ("header.phtml"); |
66 |
|
67 |
// Standard header. Uncomment this if there is no default header |
68 |
/* |
69 |
printf("<html>\n"); |
70 |
printf("<head>\n"); |
71 |
printf("<title>%s</title>\n", $page_title); |
72 |
printf("<link rel=\"stylesheet\" href=\"%s\" type=\"text/css\">\n", $GLOBAL_PUBLIC_CSS); |
73 |
printf("</head>\n"); |
74 |
*/ |
75 |
|
76 |
} |
77 |
|
78 |
// Display in-line CSS if exists |
79 |
if (strlen($css_file) > 0) { |
80 |
printf("<style type=\"text/css\">\n"); |
81 |
include($css_file); |
82 |
printf("</style>\n"); |
83 |
} |
84 |
|
85 |
// Link to the default version |
86 |
printf("<a href=\"page.phtml?page_id=%d\">Link to default screen version</a><br><br>\n", $page_id); |
87 |
|
88 |
// Anchor to top of page |
89 |
printf("<a name=\"top\"></a>\n"); |
90 |
|
91 |
|
92 |
/********************************************** |
93 |
** If courseScribe Page, draw title this way ** |
94 |
**********************************************/ |
95 |
|
96 |
if ($pagetype_id == 3) { |
97 |
displayCourseHeader($page_id, $pagetitle_style); |
98 |
displayCoursePers($page_id); |
99 |
|
100 |
// Display HR |
101 |
printf("<hr><br>\n"); |
102 |
} |
103 |
|
104 |
|
105 |
/****************** |
106 |
** Anything else ** |
107 |
******************/ |
108 |
|
109 |
else { |
110 |
printf("<table><tr><td>"); |
111 |
if ($pagetitle_style > 0) printf("<span class=\"S%d\">%s</span>", $pagetitle_style, $page_title); |
112 |
else printf("%s", $page_title); |
113 |
printf("</td></tr></table><br>\n"); |
114 |
|
115 |
/**************** |
116 |
** Page Header ** |
117 |
****************/ |
118 |
|
119 |
// Available only for PageScribe type pages |
120 |
if (strlen($pageheader) > 0) printf("<br>%s<br><br>\n", $pageheader); |
121 |
} |
122 |
|
123 |
|
124 |
/****************************** |
125 |
** Display Table of Contents ** |
126 |
******************************/ |
127 |
if ($display_toc == 1) { |
128 |
displayTOC($page_id, $wrap_toc); |
129 |
} |
130 |
|
131 |
|
132 |
/************************************** |
133 |
** Place everything in a large table ** |
134 |
**************************************/ |
135 |
printf("<center><table width= \"90%%\" border=\"0\"><tr><td align=\"left\">\n"); |
136 |
|
137 |
|
138 |
/************* |
139 |
** Elements ** |
140 |
*************/ |
141 |
|
142 |
// Boolean flag for the first item |
143 |
$first = 0; |
144 |
|
145 |
$sql = "SELECT * FROM element e |
146 |
LEFT JOIN resource r using (resource_id) |
147 |
LEFT JOIN vendor d on r.vendor_id = d.vendor_id |
148 |
LEFT JOIN service v on e.service_id = v.service_id |
149 |
LEFT JOIN location l on e.location_id = l.location_id |
150 |
LEFT JOIN staff s on e.staff_id = s.staff_id |
151 |
LEFT JOIN subject b on e.subject_id = b.subject_id |
152 |
WHERE page_id = " . $page_id |
153 |
. " ORDER BY e.element_order"; |
154 |
|
155 |
$rs = mysql_tryquery($sql); |
156 |
|
157 |
while ($row = mysql_fetch_array ($rs, MYSQL_ASSOC)) { |
158 |
|
159 |
// General element information |
160 |
$element_id = $row["element_id"]; |
161 |
$page_id = $row["page_id"]; |
162 |
$element_size = $row["element_size"]; |
163 |
$element_descr = $row["element_descr"]; |
164 |
$label = $row["label"]; |
165 |
$label_url = $row["label_url"]; |
166 |
$element_order = $row["element_order"]; |
167 |
$indent_level = $row["indent_level"]; |
168 |
$parent_id = $row["parent_id"]; |
169 |
|
170 |
// If a resource |
171 |
$resource_id = $row["resource_id"]; |
172 |
$annotation = $row["annotation"]; |
173 |
$url = $row["url"]; |
174 |
$title = $row["title"]; |
175 |
$call_no = $row["call_no"]; |
176 |
|
177 |
$guide_url = $row["guide_url"]; |
178 |
$resource_message = $row["resource_message"]; |
179 |
$resource_status = $row["resource_status"]; |
180 |
$vendor_message = $row["vendor_message"]; |
181 |
$vendor_status = $row["vendor_status"]; |
182 |
|
183 |
// If a location |
184 |
$location_id = $row["location_id"]; |
185 |
$location = $row["location"]; |
186 |
$location_descr = $row["location_descr"]; |
187 |
$mainURL = $row["mainURL"]; |
188 |
$mapURL = $row["mapURL"]; |
189 |
$hoursURL = $row["hoursURL"]; |
190 |
|
191 |
// If a staffperson |
192 |
$staff_id = $row["staff_id"]; |
193 |
$last_name = $row["last_name"]; |
194 |
$first_name = $row["first_name"]; |
195 |
$staff_account = $row["staff_account"]; |
196 |
$staff_email = $row["staff_email"]; |
197 |
|
198 |
// If a service |
199 |
$service = $row["service"]; |
200 |
$serviceDescr = $row["serviceDescr"]; |
201 |
$service_id = $row["service_id"]; |
202 |
$serviceURL = $row["serviceURL"]; |
203 |
|
204 |
// If a subject |
205 |
$subject = $row["subject"]; |
206 |
$subject_id = $row["subject_id"]; |
207 |
$description = $row["description"]; |
208 |
|
209 |
// Initialize display anew for each row |
210 |
$item_display = ""; |
211 |
$item_url = ""; |
212 |
$item_descr = ""; |
213 |
|
214 |
// Build an anchor for root-level elements |
215 |
if ($indent_level == 0 && $display_toc == 1) printf("<a name =\"toc%d\"></a>\n", $element_id); |
216 |
|
217 |
|
218 |
/***************************************************** |
219 |
** Determine the element title, description and URL ** |
220 |
*****************************************************/ |
221 |
|
222 |
// Resource |
223 |
if ($resource_id > 0) { |
224 |
$item_display = $title; |
225 |
$item_descr = $annotation; |
226 |
$item_url = $url; |
227 |
} |
228 |
// Location |
229 |
else if ($location_id > 0) { |
230 |
$item_display = $location; |
231 |
$item_descr = $location_descr; |
232 |
$item_url = $mainURL; |
233 |
} |
234 |
// Service |
235 |
else if ($service_id > 0) { |
236 |
$item_display = $service; |
237 |
$item_descr = $serviceDescr; |
238 |
$item_url = $serviceURL; |
239 |
} |
240 |
// Subject |
241 |
else if ($subject_id > 0) { |
242 |
$item_display = $subject; |
243 |
$item_descr = $subject_descr; |
244 |
$item_url = $GLOBAL_RQS_URL."rqs.phtml?subject_id=".$subject_id; |
245 |
} |
246 |
// Staff |
247 |
else if ($staff_id > 0) { |
248 |
$item_display = $first_name . " " . $last_name; |
249 |
$item_url = "mailto: " . $staff_email; |
250 |
} |
251 |
|
252 |
// A "unique resource" |
253 |
if (strlen($label) > 0 ) { |
254 |
$item_url = $label_url; |
255 |
$item_display = $label; |
256 |
} |
257 |
|
258 |
// Unique descr may override an existing descr |
259 |
if (strlen($element_descr) > 0 ) { |
260 |
$item_descr = $element_descr; |
261 |
} |
262 |
|
263 |
// Concatenate the hoursURL and mapURL if available and this is a location |
264 |
if ($location_id > 0) { |
265 |
|
266 |
// Hours URL |
267 |
if (strlen($hoursURL) > 0) { |
268 |
|
269 |
if (strlen($item_descr) > 0) { |
270 |
$item_descr .= "<BR>\n"; |
271 |
} |
272 |
|
273 |
$item_descr .= " • Hours <a href=\"" |
274 |
. $hoursURL |
275 |
. "\">" |
276 |
. $hoursURL |
277 |
. "</a>"; |
278 |
} |
279 |
|
280 |
// Map URL |
281 |
if (strlen($mapURL) > 0) { |
282 |
|
283 |
if (strlen($item_descr) > 0) { |
284 |
$item_descr .= "<BR>\n"; |
285 |
} |
286 |
|
287 |
$item_descr .= " • Map <a href=\"" |
288 |
. $mapURL |
289 |
. "\">" |
290 |
. $mapURL |
291 |
. "</a>"; |
292 |
} |
293 |
|
294 |
} |
295 |
|
296 |
// Concatenate callno/location information for resources |
297 |
if ($resource_id > 0 && strlen($call_no) > 0) { |
298 |
|
299 |
if (strlen($item_descr) > 0) $item_descr .= "<BR>"; |
300 |
$item_descr .= "• Location(s): " . $call_no; |
301 |
} |
302 |
|
303 |
// Save this for print-friendly display |
304 |
$printable_url = $item_url; |
305 |
|
306 |
/************************************************************* |
307 |
** If libstats = 1 and there's an URL, send to stats module ** |
308 |
*************************************************************/ |
309 |
|
310 |
// If stats are enabled, there exists an URL, and it's not a staff mailto: |
311 |
if ($libstats == 1 && strlen($item_url) > 0 && $staff_id < 1) { |
312 |
|
313 |
// Override the normal URL with a route into the stats module |
314 |
$item_url = "link.phtml?page_id=" . $page_id . "&element_id=" . $element_id; |
315 |
} |
316 |
|
317 |
|
318 |
// Start the indention |
319 |
if ($indent_level > 0) { |
320 |
for ($spaces = 0; $spaces < $indent_level; $spaces++) { |
321 |
printf("<ul>"); |
322 |
} |
323 |
printf("<li>"); |
324 |
} |
325 |
// Else linespace |
326 |
else if ($first == 1 && $last_indent_level == 0) printf("<BR><BR>\n"); |
327 |
|
328 |
// Display Return to [Top] anchor |
329 |
if ($first == 1 && $indent_level < 1 && $display_up > 0 && strlen($up_text) > 0) { |
330 |
|
331 |
// Display [Return to Top] link if this item represents a new root level, |
332 |
// the user has toggled the displaying of up anchors, and there is something to display. |
333 |
printf("<span class=\"S5\">\n"); |
334 |
printf("<a href=\"page_print.phtml?page_id=%d#top\">%s</a>\n", $page_id, $up_text); |
335 |
printf("</span><br><br>\n"); |
336 |
} |
337 |
|
338 |
|
339 |
/************************ |
340 |
** Display the element ** |
341 |
************************/ |
342 |
|
343 |
|
344 |
// Set the span S class if specified |
345 |
if ($element_size > 0) printf ("<span class=\"S%d\">", $element_size); |
346 |
|
347 |
// Make the title linkable with the URL |
348 |
if (strlen($item_url) > 0) $item_display = "<a href =\"" . $item_url . "\">" . $item_display . "</a>\n"; |
349 |
|
350 |
// Display element |
351 |
printf ("%s", $item_display); |
352 |
|
353 |
// If a span class is being used, close it now |
354 |
if ($element_size > 0) printf ("</span>\n"); |
355 |
|
356 |
// Display URL if toggled and available |
357 |
if (strlen($printable_url) > 0 && $display_urls == 1) printf("<BR>%s\n", $printable_url); |
358 |
|
359 |
// Handle down/alert messages |
360 |
if ($vendor_status > 0 || $resource_status > 0) { |
361 |
|
362 |
printf("<br><img src =\"images/chain.jpg\" alt=\"Resource Temporarily Unavailable\">\n"); |
363 |
printf("<span class=\"error\">\n"); |
364 |
if (strlen($vendor_message) > 1) printf("%s\n", $vendor_message); |
365 |
else if (strlen($resource_message) > 1) printf("%s\n", $resource_message); |
366 |
printf("</span>\n"); |
367 |
} |
368 |
|
369 |
// Display description |
370 |
if (strlen($item_descr) > 0) printf("<BR>%s\n", $item_descr); |
371 |
|
372 |
// Close the indention |
373 |
if ($indent_level > 0) { |
374 |
printf("</li>"); |
375 |
for ($spaces = 0; $spaces < $indent_level; $spaces++) { |
376 |
printf("</ul>"); |
377 |
} |
378 |
printf("\n"); |
379 |
} |
380 |
|
381 |
// Linespace |
382 |
//else printf("<BR>\n"); |
383 |
|
384 |
// Printed first item, set to TRUE |
385 |
$first = 1; |
386 |
$last_indent_level = $indent_level; |
387 |
|
388 |
// Increment row number |
389 |
$row_number++; |
390 |
|
391 |
} // all table rows |
392 |
|
393 |
|
394 |
// Display final [Return to Top] link, regardless of current indent level, if |
395 |
// the user has toggled the displaying of up anchors, and there is something to display. |
396 |
if ($row_number > 0 && $display_up > 0 && strlen($up_text) > 0) { |
397 |
printf("<br><br><span class=\"S5\">\n"); |
398 |
printf("<a href=\"page_print.phtml?page_id=%d#top\">%s</a><br><br>\n", $page_id, $up_text); |
399 |
printf("</span>\n"); |
400 |
} |
401 |
|
402 |
|
403 |
printf("<br><br>\n"); |
404 |
|
405 |
// Display page coordinator |
406 |
if ($staff_coordinator > 0) { |
407 |
$display_page_coord = lookupStaff($staff_coordinator); |
408 |
$staff_email = lookupField("staff", "staff_id", $staff_coordinator, "staff_email"); |
409 |
|
410 |
if (strlen($display_page_coord) > 0 && strlen($staff_email) > 0) { |
411 |
printf("<span class=\"S5\">\n"); |
412 |
printf("Page Coordinator: %s <a href=\"mailto:%s\">%s</a>\n", $display_page_coord, $staff_email, $staff_email); |
413 |
printf("</span><br>\n"); |
414 |
} |
415 |
} |
416 |
|
417 |
// Display page URL |
418 |
printf("<span class=\"S5\">\n"); |
419 |
printf("This URL: <a href=\"%spage_print.phtml?page_id=%d\">%spage_print.phtml?page_id=%d</a>\n", $GLOBAL_SCRIBE_URL, $page_id, $GLOBAL_SCRIBE_URL, $page_id); |
420 |
printf("</span>\n"); |
421 |
|
422 |
/********************** |
423 |
** close large table ** |
424 |
**********************/ |
425 |
printf("</td></tr></table></center><br>\n"); |
426 |
|
427 |
} // valid page workspace |
428 |
|
429 |
|
430 |
|
431 |
// Print footer |
432 |
if ($style_id > 1 && strlen($footer_file) > 0) { |
433 |
// If using a pre-defined style, load its footer file |
434 |
require_once ($footer_file); |
435 |
} |
436 |
|
437 |
else { |
438 |
// Default public page footer |
439 |
require_once ("footer.phtml"); |
440 |
} |
441 |
?> |
442 |
|
443 |
</center> |
444 |
</body> |
445 |
</html> |