1 |
dpavlin |
19 |
<?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($con, $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_query($sql, $con); |
36 |
|
|
$row = mysql_fetch_array ($rs); |
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($con, $page_id, $pagetitle_style); |
98 |
|
|
displayCoursePers($con, $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($con, $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 service v on e.service_id = v.service_id |
148 |
|
|
LEFT JOIN location l on e.location_id = l.location_id |
149 |
|
|
LEFT JOIN staff s on e.staff_id = s.staff_id |
150 |
|
|
LEFT JOIN subject b on e.subject_id = b.subject_id |
151 |
|
|
WHERE page_id = " . $page_id |
152 |
|
|
. " ORDER BY e.element_order"; |
153 |
|
|
|
154 |
|
|
$rs = mysql_query($sql, $con); |
155 |
|
|
|
156 |
|
|
while ($row = mysql_fetch_array ($rs)) { |
157 |
|
|
|
158 |
|
|
// General element information |
159 |
|
|
$element_id = $row["element_id"]; |
160 |
|
|
$page_id = $row["page_id"]; |
161 |
|
|
$element_size = $row["element_size"]; |
162 |
|
|
$element_descr = $row["element_descr"]; |
163 |
|
|
$label = $row["label"]; |
164 |
|
|
$label_url = $row["label_url"]; |
165 |
|
|
$element_order = $row["element_order"]; |
166 |
|
|
$indent_level = $row["indent_level"]; |
167 |
|
|
$parent_id = $row["parent_id"]; |
168 |
|
|
|
169 |
|
|
// If a resource |
170 |
|
|
$resource_id = $row["resource_id"]; |
171 |
|
|
$annotation = $row["annotation"]; |
172 |
|
|
$url = $row["url"]; |
173 |
|
|
$title = $row["title"]; |
174 |
|
|
$call_no = $row["call_no"]; |
175 |
|
|
|
176 |
|
|
// If a location |
177 |
|
|
$location_id = $row["location_id"]; |
178 |
|
|
$location = $row["location"]; |
179 |
|
|
$location_descr = $row["location_descr"]; |
180 |
|
|
$mainURL = $row["mainURL"]; |
181 |
|
|
$mapURL = $row["mapURL"]; |
182 |
|
|
$hoursURL = $row["hoursURL"]; |
183 |
|
|
|
184 |
|
|
// If a staffperson |
185 |
|
|
$staff_id = $row["staff_id"]; |
186 |
|
|
$last_name = $row["last_name"]; |
187 |
|
|
$first_name = $row["first_name"]; |
188 |
|
|
$staff_account = $row["staff_account"]; |
189 |
|
|
$staff_email = $row["staff_email"]; |
190 |
|
|
|
191 |
|
|
// If a service |
192 |
|
|
$service = $row["service"]; |
193 |
|
|
$serviceDescr = $row["serviceDescr"]; |
194 |
|
|
$service_id = $row["service_id"]; |
195 |
|
|
$serviceURL = $row["serviceURL"]; |
196 |
|
|
|
197 |
|
|
// If a subject |
198 |
|
|
$subject = $row["subject"]; |
199 |
|
|
$subject_id = $row["subject_id"]; |
200 |
|
|
$description = $row["description"]; |
201 |
|
|
|
202 |
|
|
// Initialize display anew for each row |
203 |
|
|
$item_display = ""; |
204 |
|
|
$item_url = ""; |
205 |
|
|
$item_descr = ""; |
206 |
|
|
|
207 |
|
|
// Build an anchor for root-level elements |
208 |
|
|
if ($indent_level == 0 && $display_toc == 1) printf("<a name =\"toc%d\"></a>\n", $element_id); |
209 |
|
|
|
210 |
|
|
|
211 |
|
|
/***************************************************** |
212 |
|
|
** Determine the element title, description and URL ** |
213 |
|
|
*****************************************************/ |
214 |
|
|
|
215 |
|
|
// Resource |
216 |
|
|
if ($resource_id > 0) { |
217 |
|
|
$item_display = $title; |
218 |
|
|
$item_descr = $annotation; |
219 |
|
|
$item_url = $url; |
220 |
|
|
} |
221 |
|
|
// Location |
222 |
|
|
else if ($location_id > 0) { |
223 |
|
|
$item_display = $location; |
224 |
|
|
$item_descr = $location_descr; |
225 |
|
|
$item_url = $mainURL; |
226 |
|
|
} |
227 |
|
|
// Service |
228 |
|
|
else if ($service_id > 0) { |
229 |
|
|
$item_display = $service; |
230 |
|
|
$item_descr = $serviceDescr; |
231 |
|
|
$item_url = $serviceURL; |
232 |
|
|
} |
233 |
|
|
// Subject |
234 |
|
|
else if ($subject_id > 0) { |
235 |
|
|
$item_display = $subject; |
236 |
|
|
$item_descr = $subject_descr; |
237 |
|
|
$item_url = $GLOBAL_RQS_URL."rqs.phtml?subject_id=".$subject_id; |
238 |
|
|
} |
239 |
|
|
// Staff |
240 |
|
|
else if ($staff_id > 0) { |
241 |
|
|
$item_display = $first_name . " " . $last_name; |
242 |
|
|
$item_url = "mailto: " . $staff_email; |
243 |
|
|
} |
244 |
|
|
|
245 |
|
|
// A "unique resource" |
246 |
|
|
if (strlen($label) > 0 ) { |
247 |
|
|
$item_url = $label_url; |
248 |
|
|
$item_display = $label; |
249 |
|
|
} |
250 |
|
|
|
251 |
|
|
// Unique descr may override an existing descr |
252 |
|
|
if (strlen($element_descr) > 0 ) { |
253 |
|
|
$item_descr = $element_descr; |
254 |
|
|
} |
255 |
|
|
|
256 |
|
|
// Concatenate the hoursURL and mapURL if available and this is a location |
257 |
|
|
if ($location_id > 0) { |
258 |
|
|
|
259 |
|
|
// Hours URL |
260 |
|
|
if (strlen($hoursURL) > 0) { |
261 |
|
|
|
262 |
|
|
if (strlen($item_descr) > 0) { |
263 |
|
|
$item_descr .= "<BR>\n"; |
264 |
|
|
} |
265 |
|
|
|
266 |
|
|
$item_descr .= " • Hours <a href=\"" |
267 |
|
|
. $hoursURL |
268 |
|
|
. "\">" |
269 |
|
|
. $hoursURL |
270 |
|
|
. "</a>"; |
271 |
|
|
} |
272 |
|
|
|
273 |
|
|
// Map URL |
274 |
|
|
if (strlen($mapURL) > 0) { |
275 |
|
|
|
276 |
|
|
if (strlen($item_descr) > 0) { |
277 |
|
|
$item_descr .= "<BR>\n"; |
278 |
|
|
} |
279 |
|
|
|
280 |
|
|
$item_descr .= " • Map <a href=\"" |
281 |
|
|
. $mapURL |
282 |
|
|
. "\">" |
283 |
|
|
. $mapURL |
284 |
|
|
. "</a>"; |
285 |
|
|
} |
286 |
|
|
|
287 |
|
|
} |
288 |
|
|
|
289 |
|
|
// Concatenate callno/location information for resources |
290 |
|
|
if ($resource_id > 0 && strlen($call_no) > 0) { |
291 |
|
|
|
292 |
|
|
if (strlen($item_descr) > 0) $item_descr .= "<BR>"; |
293 |
|
|
$item_descr .= "• Location(s): " . $call_no; |
294 |
|
|
} |
295 |
|
|
|
296 |
|
|
// Save this for print-friendly display |
297 |
|
|
$printable_url = $item_url; |
298 |
|
|
|
299 |
|
|
/************************************************************* |
300 |
|
|
** If libstats = 1 and there's an URL, send to stats module ** |
301 |
|
|
*************************************************************/ |
302 |
|
|
|
303 |
|
|
// If stats are enabled, there exists an URL, and it's not a staff mailto: |
304 |
|
|
if ($libstats == 1 && strlen($item_url) > 0 && $staff_id < 1) { |
305 |
|
|
|
306 |
|
|
// Override the normal URL with a route into the stats module |
307 |
|
|
$item_url = "link.phtml?page_id=" . $page_id . "&element_id=" . $element_id; |
308 |
|
|
} |
309 |
|
|
|
310 |
|
|
|
311 |
|
|
// Start the indention |
312 |
|
|
if ($indent_level > 0) { |
313 |
|
|
for ($spaces = 0; $spaces < $indent_level; $spaces++) { |
314 |
|
|
printf("<ul>"); |
315 |
|
|
} |
316 |
|
|
printf("<li>"); |
317 |
|
|
} |
318 |
|
|
// Else linespace |
319 |
|
|
else if ($first == 1 && $last_indent_level == 0) printf("<BR><BR>\n"); |
320 |
|
|
|
321 |
|
|
// Display Return to [Top] anchor |
322 |
|
|
if ($first == 1 && $indent_level < 1 && $display_up > 0 && strlen($up_text) > 0) { |
323 |
|
|
|
324 |
|
|
// Display [Return to Top] link if this item represents a new root level, |
325 |
|
|
// the user has toggled the displaying of up anchors, and there is something to display. |
326 |
|
|
printf("<span class=\"S5\">\n"); |
327 |
|
|
printf("<a href=\"page_print.phtml?page_id=%d#top\">%s</a>\n", $page_id, $up_text); |
328 |
|
|
printf("</span><br><br>\n"); |
329 |
|
|
} |
330 |
|
|
|
331 |
|
|
|
332 |
|
|
/************************ |
333 |
|
|
** Display the element ** |
334 |
|
|
************************/ |
335 |
|
|
|
336 |
|
|
|
337 |
|
|
// Set the span S class if specified |
338 |
|
|
if ($element_size > 0) printf ("<span class=\"S%d\">", $element_size); |
339 |
|
|
|
340 |
|
|
// Make the title linkable with the URL |
341 |
|
|
if (strlen($item_url) > 0) $item_display = "<a href =\"" . $item_url . "\">" . $item_display . "</a>\n"; |
342 |
|
|
|
343 |
|
|
// Display element |
344 |
|
|
printf ("%s", $item_display); |
345 |
|
|
|
346 |
|
|
// If a span class is being used, close it now |
347 |
|
|
if ($element_size > 0) printf ("</span>\n"); |
348 |
|
|
|
349 |
|
|
|
350 |
|
|
// Display URL if toggled and available |
351 |
|
|
if (strlen($printable_url) > 0 && $display_urls == 1) printf("<BR>%s\n", $printable_url); |
352 |
|
|
|
353 |
|
|
|
354 |
|
|
// Display description |
355 |
|
|
if (strlen($item_descr) > 0) printf("<BR>%s\n", $item_descr); |
356 |
|
|
|
357 |
|
|
// Close the indention |
358 |
|
|
if ($indent_level > 0) { |
359 |
|
|
printf("</li>"); |
360 |
|
|
for ($spaces = 0; $spaces < $indent_level; $spaces++) { |
361 |
|
|
printf("</ul>"); |
362 |
|
|
} |
363 |
|
|
printf("\n"); |
364 |
|
|
} |
365 |
|
|
|
366 |
|
|
// Linespace |
367 |
|
|
//else printf("<BR>\n"); |
368 |
|
|
|
369 |
|
|
// Printed first item, set to TRUE |
370 |
|
|
$first = 1; |
371 |
|
|
$last_indent_level = $indent_level; |
372 |
|
|
|
373 |
|
|
// Increment row number |
374 |
|
|
$row_number++; |
375 |
|
|
|
376 |
|
|
} // all table rows |
377 |
|
|
|
378 |
|
|
|
379 |
|
|
// Display final [Return to Top] link, regardless of current indent level, if |
380 |
|
|
// the user has toggled the displaying of up anchors, and there is something to display. |
381 |
|
|
if ($row_number > 0 && $display_up > 0 && strlen($up_text) > 0) { |
382 |
|
|
printf("<br><br><span class=\"S5\">\n"); |
383 |
|
|
printf("<a href=\"page_print.phtml?page_id=%d#top\">%s</a><br><br>\n", $page_id, $up_text); |
384 |
|
|
printf("</span>\n"); |
385 |
|
|
} |
386 |
|
|
|
387 |
|
|
|
388 |
|
|
printf("<br><br>\n"); |
389 |
|
|
|
390 |
|
|
// Display page coordinator |
391 |
|
|
if ($staff_coordinator > 0) { |
392 |
|
|
$display_page_coord = lookupStaff($con, $staff_coordinator); |
393 |
|
|
$staff_email = lookupField($con, "staff", "staff_id", $staff_coordinator, "staff_email"); |
394 |
|
|
|
395 |
|
|
if (strlen($display_page_coord) > 0 && strlen($staff_email) > 0) { |
396 |
|
|
printf("<span class=\"S5\">\n"); |
397 |
|
|
printf("Page Coordinator: %s <a href=\"mailto:%s\">%s</a>\n", $display_page_coord, $staff_email, $staff_email); |
398 |
|
|
printf("</span><br>\n"); |
399 |
|
|
} |
400 |
|
|
} |
401 |
|
|
|
402 |
|
|
// Display page URL |
403 |
|
|
printf("<span class=\"S5\">\n"); |
404 |
|
|
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); |
405 |
|
|
printf("</span>\n"); |
406 |
|
|
|
407 |
|
|
/********************** |
408 |
|
|
** close large table ** |
409 |
|
|
**********************/ |
410 |
|
|
printf("</td></tr></table></center><br>\n"); |
411 |
|
|
|
412 |
|
|
} // valid page workspace |
413 |
|
|
|
414 |
|
|
|
415 |
|
|
|
416 |
|
|
// Print footer |
417 |
|
|
if ($style_id > 1 && strlen($footer_file) > 0) { |
418 |
|
|
// If using a pre-defined style, load its footer file |
419 |
|
|
require_once ($footer_file); |
420 |
|
|
} |
421 |
|
|
|
422 |
|
|
else { |
423 |
|
|
// Default public page footer |
424 |
|
|
require_once ("footer.phtml"); |
425 |
|
|
} |
426 |
|
|
?> |
427 |
|
|
|
428 |
|
|
</center> |
429 |
|
|
</body> |
430 |
|
|
</html> |