/[libdata]/trunk/page.phtml
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Annotation of /trunk/page.phtml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 19 - (hide annotations)
Tue Jan 27 20:49:23 2004 UTC (20 years, 2 months ago) by dpavlin
File size: 11551 byte(s)
Initial revision

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

  ViewVC Help
Powered by ViewVC 1.1.26