/[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 72 - (hide annotations)
Thu Mar 18 20:33:37 2004 UTC (17 years, 8 months ago) by dpavlin
File size: 12177 byte(s)
changes made in version 2.00

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

  ViewVC Help
Powered by ViewVC 1.1.26