/[libdata]/trunk/admin/scribe.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

Contents of /trunk/admin/scribe.phtml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 73 - (show annotations)
Thu Mar 18 21:27:37 2004 UTC (20 years ago) by dpavlin
File size: 37264 byte(s)
sync trunk to HEAD of pear-db (without changes specific to PEAR which will be dropped)

1 <?php
2 // Load globals
3 require_once ("global_vars.php");
4
5 // Includes
6 require_once ($GLOBAL_ADMIN_INC."sessionClass.php");
7 require_once ($GLOBAL_ADMIN_INC."accessClass.php");
8 require_once ("db_connect.php");
9 require_once ($GLOBAL_ADMIN_INC."app_controls.php");
10 require_once ($GLOBAL_ADMIN_INC."scribe_forms.php");
11 require_once ($GLOBAL_ADMIN_INC."scribe_application.php");
12
13
14 // Page header
15 require_once ($GLOBAL_ADMIN_INC."scribe_header.phtml");
16
17
18 // Default access settings
19 $sess_time_human = "";
20 $sess_staff_account = "";
21 $sess_staff_id = 0;
22 $sess_access_level = 0;
23 $sess_access = "";
24 $sess_last_name = "";
25 $sess_first_name = "";
26
27
28 // Collect access information
29 if (isset($libsession)) {
30
31 // Fetch session information
32 $sessionClass = new sessionClass("", $libsession, "", "");
33 $accessClass = new accessClass($sessionClass);
34
35 // Load user session variables
36 $sess_time_human = $sessionClass->time_human;
37 $sess_staff_account = $sessionClass->staff_account;
38 $sess_staff_id = $accessClass->staff_id;
39 $sess_access_level = $accessClass->access_level;
40 $sess_access = $accessClass->access;
41 $sess_last_name = $accessClass->last_name;
42 $sess_first_name = $accessClass->first_name;
43
44 }
45
46
47 // Default authorization
48 $auth_page = 0;
49
50 // Create a new page: available to valid user sessions with access level >= 20 (author)
51 if ($page_id < 1 && $sess_access_level >= 20) $auth_page = 1;
52
53 // If editing an exiting page
54 else {
55 // Flag to make sure that the current user has sufficient access for this page
56 $auth_page = authPage($page_id, $sess_access_level, $sess_staff_id);
57 }
58
59 // If the cookie is set and access level is appropriate
60 if(isset($libsession) && $auth_page == 1) {
61
62 // If creating a new page
63 if ($page_id < 1 && $style_id > 0 && strlen($page_title) > 0) {
64
65 // Cleaner
66 $page_title = textInmySQL($page_title);
67
68 $sql = "INSERT INTO page (date_created, account_created, staff_coordinator, style_id, pagetype_id, page_title, display_toc, wrap_toc) VALUES ( now(), '"
69 . $sess_staff_account
70 . "',"
71 . $sess_staff_id
72 . ","
73 . $style_id
74 . ", "
75 . $pagetype_id
76 . ", '"
77 . $page_title
78 . "', 1, 0)";
79
80 xx_tryquery ($sql);
81 $page_id = xx_insert_id();
82
83 // If a coursescribe page -- write the row into the course table
84 if ($pagetype_id == 3) {
85 $sql = "INSERT INTO course (page_id, course_concat, courseheader) VALUES("
86 . $page_id
87 . ", '"
88 . $page_title
89 . "', 'Information Resources and Services for:')";
90
91 // Failed
92 xx_tryquery($sql);
93 }
94
95 }
96
97 // Continue only if we now have a valid page workspace
98 if ($page_id > 0 ) {
99
100 /***************************
101 ** Fetch Page Information **
102 ***************************/
103
104 $sql = "SELECT * FROM page p
105 LEFT JOIN course c using (page_id)
106 WHERE p.page_id = " . $page_id;
107
108 $rs = xx_tryquery($sql);
109 $row = xx_fetch_array ($rs, xx_ASSOC);
110 $page_title = $row["page_title"];
111 $pagetitle_style = $row["pagetitle_style"];
112 $style_id = $row["style_id"];
113 $pagetype_id = $row["pagetype_id"];
114 $published = $row["published"];
115 $display_urls = $row["display_urls"];
116 $display_toc = $row["display_toc"];
117 $wrap_toc = $row["wrap_toc"];
118 $display_up = $row["display_up"];
119 $up_text = $row["up_text"];
120 $date_created = $row["date_created"];
121 $date_modified = $row["date_modified"];
122 $account_created = $row["account_created"];
123 $account_modified = $row["account_modified"];
124 $staff_coordinator = $row["staff_coordinator"];
125 $page_debug = $row["page_debug"];
126 $course_id = $row["course_id"];
127
128 /*************************************************
129 ** Determine if there's anything in copy buffer **
130 *************************************************/
131 $paste_data = existsRow("pastebuffer", "paste_staff_id", $sess_staff_id);
132
133
134 /**********************************
135 ** Populate the generation array **
136 **********************************/
137
138 $genArray = array();
139 populateGenArray($genArray, $page_id);
140
141
142 /******************
143 ** Page Commands **
144 ******************/
145
146 // Page commands table
147 $page_title_display = strip_tags($page_title);
148 printf("<table width=\"95%%\" border=\"1\" cellpadding=\"4\" class=\"backLight\"><tr>\n");
149 printf("<td colspan =\"4\" class=\"cellPlain\">Page Commands: %s (ID# %d)", $page_title_display, $page_id);
150 printf("</td></tr>\n");
151
152
153 /*************************************
154 ** Row for general page information **
155 *************************************/
156 printf("<tr>\n");
157
158 // Date created
159 printf("<td>\n");
160 printf("<b>Created:</b><br> %s (%s)\n", $date_created, $account_created);
161 printf("</td>\n");
162
163 // Date modified
164 printf("<td>\n");
165 printf("<b>Modified:</b><br> %s (%s)\n", $date_modified, $account_modified);
166 printf("</td>\n");
167
168 // Publish status
169 printf("<td colspan=\"2\">\n");
170 printf("<b>Pub Status:</b> ");
171 if ($published >0) {
172 $static_url = $GLOBAL_SCRIBE_URL. "publish.phtml?page_id=" . $page_id;
173
174 printf("Published.<br>\n");
175 // Uncomment this out to provide a link to the static page
176 // printf("<b>Static URL:</b> <a href=\"%s\">%s</a><br>\n", $static_url, $static_url);
177
178 }
179 else printf("(Not published)<br>\n");
180 $dyna_url = $GLOBAL_SCRIBE_URL. "page.phtml?page_id=" . $page_id;
181 printf("<b>URL:</b> <a href=\"%s\">%s</a>\n", $dyna_url, $dyna_url);
182 printf("</td></tr>\n");
183
184 /************************************************
185 ** Row for Copy/delete/publish/preview buttons **
186 ************************************************/
187 printf("<tr>\n");
188
189 // Create clone
190 printf("<td colspan=\"1\">\n");
191 printf("<form method=\"POST\" action =\"scribe_transaction.phtml\">\n");
192 printf("<input type=\"hidden\" name =\"transaction\" value = \"pageTemplate\">\n");
193 printf("<input type=\"hidden\" name =\"page_id\" value = \"%d\">\n", $page_id);
194 printf("<input type=\"hidden\" name =\"sess_staff_account\" value = \"%d\">\n", $sess_staff_account);
195 printf("<input type=\"hidden\" name =\"sess_staff_id\" value = \"%d\">\n", $sess_staff_id);
196 printf("<input type=\"submit\" value = \"Create Clone\"></td>\n");
197 printf("</form>\n");
198
199 // Delete page
200 printf("<td colspan=\"1\">\n");
201 printf("<form method=\"POST\" action=\"scribe_transaction.phtml\" >\n");
202 printf("<input type=\"hidden\" name= \"transaction\" value= \"deletePageConfirm\">\n");
203 printf("<input type=\"hidden\" name=\"page_id\" value=\"%d\">", $page_id);
204 printf("<input type=\"submit\" value = \"Delete Page!\"></td>\n");
205 printf("</form>\n");
206
207 // Published, draw the republish button
208 if ($published > 0 ){
209
210 // Uncomment this to allow a republish option, if using static pages
211 // Republish button
212 /*
213 printf("<td><table border=\"0\"><tr><td>");
214 printf("<form method=\"POST\" action =\"scribe_transaction.phtml\">\n");
215 printf("<input type=\"hidden\" name =\"transaction\" value = \"scribePublish\">\n");
216 printf("<input type=\"hidden\" name =\"page_id\" value = \"%d\">\n", $page_id);
217 printf("<input type=\"submit\" value = \"Republish\">\n");
218 printf("</td></form>\n");
219
220 printf("<td><form method=\"POST\" action =\"scribe_transaction.phtml\">");
221 printf("<input type=\"hidden\" name =\"transaction\" value = \"scribeUnpublish\">\n");
222 printf("<input type=\"hidden\" name =\"page_id\" value = \"%d\">\n", $page_id);
223 printf("<input type=\"submit\" value = \"Unpublish\">\n");
224 printf("</td></form></tr></table>\n");
225 */
226
227 // Comment out this, if using static pages
228 printf("<td colspan=\"1\"><form method=\"POST\" action =\"scribe_transaction.phtml\">\n");
229 printf("<input type=\"hidden\" name =\"transaction\" value = \"scribeUnpublish\">\n");
230 printf("<input type=\"hidden\" name =\"page_id\" value = \"%d\">\n", $page_id);
231 printf("<input type=\"submit\" value = \"Unpublish\">\n");
232
233
234 printf("</td>\n");
235
236 // Uncomment out this, if using static pages
237 printf("</form>\n");
238
239 }
240
241 // Not published, offer publish page form
242 else {
243
244 printf("<td colspan=\"1\">\n");
245 printf("<form method=\"POST\" action =\"scribe_transaction.phtml\">\n");
246 printf("<input type=\"hidden\" name =\"transaction\" value = \"scribePublish\">\n");
247 printf("<input type=\"hidden\" name =\"page_id\" value = \"%d\">\n", $page_id);
248 printf("<input type=\"submit\" value = \"Publish\">\n");
249 printf("</td></form>\n");
250
251 }
252
253 // Offer preview link
254 printf("<td colspan=\"1\">\n");
255 printf("<a href=\"%spage.phtml?page_id=%d\">Preview</a><br>\n", $GLOBAL_SCRIBE_URL, $page_id);
256 printf("</td></tr>\n");
257
258
259 /*************************
260 ** Row for URLs, ToC, etc.
261 *************************/
262 printf("<tr>\n");
263
264 // Display urls
265 if ($display_urls < 1) {
266 printf("<td colspan =\"1\" align=\"left\">\n");
267 printf("<form method=\"POST\" action =\"scribe_transaction.phtml\">\n");
268 printf("<input type=\"hidden\" name =\"transaction\" value = \"toggleURLDisplay\">\n");
269 printf("<input type=\"hidden\" name =\"display_urls\" value = \"1\">\n");
270 printf("<input type=\"hidden\" name =\"page_id\" value = \"%d\">\n", $page_id);
271 printf("<input type=\"submit\" value = \"Show URL's in Author Mode\">\n");
272 printf("</td></form>\n");
273 }
274
275 //Turn off urls
276 else {
277 printf("<td colspan =\"1\" align=\"left\">\n");
278 printf("<form method=\"POST\" action =\"scribe_transaction.phtml\">\n");
279 printf("<input type=\"hidden\" name =\"transaction\" value = \"toggleURLDisplay\">\n");
280 printf("<input type=\"hidden\" name =\"display_urls\" value = \"0\">\n");
281 printf("<input type=\"hidden\" name =\"page_id\" value = \"%d\">\n", $page_id);
282 printf("<input type=\"submit\" value = \"Suppress URL Display\">\n");
283 printf("</td></form>\n");
284 }
285
286 // Display table of contents
287 if ($display_toc < 1) {
288 printf("<td colspan =\"1\" align=\"left\">\n");
289 printf("<form method=\"POST\" action =\"scribe_transaction.phtml\">\n");
290 printf("<input type=\"hidden\" name =\"transaction\" value = \"toggleTOCDisplay\">\n");
291 printf("<input type=\"hidden\" name =\"display_toc\" value = \"1\">\n");
292 printf("<input type=\"hidden\" name =\"page_id\" value = \"%d\">\n", $page_id);
293 printf("<input type=\"submit\" value = \"Activate ToC\">\n");
294 printf("</td></form>\n");
295 }
296
297 //Turn off table of contents
298 else {
299 printf("<td colspan =\"1\" align=\"left\">\n");
300 printf("<form method=\"POST\" action =\"scribe_transaction.phtml\">\n");
301 printf("<input type=\"hidden\" name =\"transaction\" value = \"toggleTOCDisplay\">\n");
302 printf("<input type=\"hidden\" name =\"display_toc\" value = \"0\">\n");
303 printf("<input type=\"hidden\" name =\"page_id\" value = \"%d\">\n", $page_id);
304 printf("<input type=\"submit\" value = \"Suppress ToC\">\n");
305 printf("</td></form>\n");
306 }
307
308
309 // Wrap the table of contents
310 // Don't display the ToC, so don't offer the option
311 if ($display_toc < 1) {
312 printf("<td colspan=\"1\" align=\"left\">&nbsp;</td>\n");
313 }
314
315 // ToC is displayed and wrap is off, offer toggle ON
316 else if ($wrap_toc < 1) {
317 printf("<td colspan =\"1\" align=\"left\">\n");
318 printf("<form method=\"POST\" action =\"scribe_transaction.phtml\">\n");
319 printf("<input type=\"hidden\" name =\"transaction\" value = \"toggleTOCWrap\">\n");
320 printf("<input type=\"hidden\" name =\"wrap_toc\" value = \"1\">\n");
321 printf("<input type=\"hidden\" name =\"page_id\" value = \"%d\">\n", $page_id);
322 printf("<input type=\"submit\" value = \"Wrap ToC\">\n");
323 printf("</td></form>\n");
324
325 }
326
327 // ToC is displayed and wrap is on, offer toggle OFF
328 else if ($wrap_toc >= 1) {
329 printf("<td colspan =\"1\" align=\"left\">\n");
330 printf("<form method=\"POST\" action =\"scribe_transaction.phtml\">\n");
331 printf("<input type=\"hidden\" name =\"transaction\" value = \"toggleTOCWrap\">\n");
332 printf("<input type=\"hidden\" name =\"wrap_toc\" value = \"0\">\n");
333 printf("<input type=\"hidden\" name =\"page_id\" value = \"%d\">\n", $page_id);
334 printf("<input type=\"submit\" value = \"Unwrap ToC\">\n");
335 printf("</td></form>\n");
336 }
337
338 // Dump copy buffer
339 if ($paste_data) {
340 printf("<td colspan =\"1\" align=\"left\">\n");
341 printf("<form method=\"POST\" action =\"scribe_transaction.phtml\">\n");
342 printf("<input type=\"hidden\" name =\"transaction\" value = \"deleteCopyBuffer\">\n");
343 printf("<input type=\"hidden\" name =\"paste_staff_id\" value = \"%d\">\n", $sess_staff_id);
344 printf("<input type=\"hidden\" name =\"page_id\" value = \"%d\">\n", $page_id);
345 printf("<input type=\"submit\" value = \"Clear Copy Buffer\">\n");
346 printf("</td></form>\n");
347 }
348
349 // No copy buffer present, draw a blank cell
350 else printf("<td colspan=\"1\">&nbsp;</td>\n");
351
352 printf("</tr>\n");
353
354 // Display [Return to Top] anchor
355 printf("<tr>\n");
356
357 // Set default if no previous value for [up] text
358 if (strlen($up_text) < 1) $up_text = "[Return to Top]";
359
360 // [Up] anchor display is on, offer to turn them off or edit language
361 if ($display_up == 1) {
362
363 // Turn off [up] anchors
364 printf("<td colspan=\"1\">\n");
365 printf("<form method=\"POST\" action =\"scribe_transaction.phtml\">");
366 printf("<input type=\"hidden\" name =\"transaction\" value = \"toggleUpDisplay\">\n");
367 printf("<input type=\"hidden\" name =\"display_up\" value = \"0\">\n");
368 printf("<input type=\"hidden\" name =\"page_id\" value = \"%d\">\n", $page_id);
369 printf("<input type=\"submit\" value = \"Deactivate [Up] Anchors\">\n");
370 printf("</td></form>\n");
371
372 // Change text of [up] anchors
373 printf("<td colspan=\"3\">\n");
374 printf("<form method=\"POST\" action =\"scribe_transaction.phtml\">");
375 printf("<input type=\"hidden\" name =\"transaction\" value = \"toggleUpText\">\n");
376 printf("<input type=\"hidden\" name =\"page_id\" value = \"%d\">\n", $page_id);
377 printF("<b>[Up] Anchor Text:</b> ");
378 printf("<input type=\"text\" name =\"up_text\" value = \"%s\" size = \"30\" >\n", $up_text);
379 printf("<input type=\"submit\" value = \"Save [Up] Text\">\n");
380 printf("</td></form>\n");
381 }
382
383
384 // [Up] anchor display is off, offer to activate them
385 else {
386
387 printf("<td colspan=\"4\">\n");
388 printf("<form method=\"POST\" action =\"scribe_transaction.phtml\">");
389 printf("<input type=\"hidden\" name =\"transaction\" value = \"toggleUpDisplay\">\n");
390 printf("<input type=\"hidden\" name =\"display_up\" value = \"1\">\n");
391 printf("<input type=\"hidden\" name =\"up_text\" value = \"%s\">\n", $up_text);
392 printf("<input type=\"hidden\" name =\"page_id\" value = \"%d\">\n", $page_id);
393 printf("<input type=\"submit\" value = \"Activate [Up] Anchors\">\n");
394 printf("</td></form>\n");
395 }
396
397 printf("</tr>\n");
398
399 // Change the current style
400 printf("<tr><td align=\"left\">\n");
401 printf("<form method = \"POST\" action = \"scribe_transaction.phtml\">\n");
402 printf("<input type=\"hidden\" name= \"transaction\" value= \"updateScribeStyle\">\n");
403 printf("<input type=\"hidden\" name=\"page_id\" value=\"%d\">", $page_id);
404 printf("<select name = \"style_id\">\n");
405 dropDownFieldSelected("style", "style_title", "style_id", " WHERE style_id > 0", $style_id);
406 printf("</select>\n");
407 printf("<input type = \"submit\" value = \"Apply Style\">\n");
408 printf("</td></form>\n");
409
410 // Page font format tool
411 printf("<td colspan=\"3\" align=\"left\">\n");
412 $max_indent = getMaxIndent($page_id);
413 printf("<table border=\"0\">\n");
414 printf("<tr>\n");
415 printf("<form method=\"post\" action =\"scribe_transaction.phtml\">\n");
416 printf("<input type=\"hidden\" name =\"transaction\" value = \"elementMultiFormat\">\n");
417 printf("<input type=\"hidden\" name =\"page_id\" value = \"%d\">\n", $page_id);
418 printf("<td><b>Page Font Format:</b> Indent: ");
419 printf("<select name=\"auto_indent_level\">\n");
420 for ($indent_select = 0; $indent_select <= $max_indent; $indent_select++) {
421 printf("<option value=\"%d\">Level: %d</option>\n", $indent_select, $indent_select);
422 }
423 printf("</select></td>\n");
424 printf("<td>Font: ");
425 printf("<select name=\"auto_element_size\">\n");
426 for ($element_size_select = 0; $element_size_select <= 5; $element_size_select++) {
427 printf("<option value=\"%d\">Style: %d</option>\n", $element_size_select, $element_size_select);
428 }
429 printf("</select>\n");
430 printf("<input type=\"submit\" value=\"Apply Format\">\n");
431 printf("</td></form>\n");
432 printf("</tr></table>\n");
433
434 // End of outer cell/row
435 printf("</td></tr>\n");
436
437 // Assign page staff
438 if ($cmd != "pagestaff") {
439 printf("<tr>\n");
440 printf("<td colspan=\"4\">\n");
441 printf("<form method=\"POST\" action=\"scribe.phtml?page_id=%d&cmd=pagestaff\">", $page_id);
442 printf("<input type=\"submit\" value=\"Assign Page Staff\">\n");
443 printf("</td></form>\n");
444 printf("</tr>\n");
445 }
446
447 // Close page commands table
448 printf("</table><br>\n");
449
450
451 /****************************************
452 ** Staff and Subject Assignments Menus **
453 ****************************************/
454
455
456 if ($cmd == "pagestaff") formAssignPageStaff($page_id, $staff_coordinator);
457
458
459 // Anchor to top of page
460 printf("<a name=\"top\"></a>\n");
461
462
463 /*******************************************************
464 ** Load the page's css definitions (if exists) inline **
465 *******************************************************/
466
467
468 $css_file = "";
469 $sql = "SELECT
470 s.css_file
471 FROM
472 style s,
473 page p
474 WHERE
475 p.page_id = "
476 . $page_id
477 . " AND p.style_id = s.style_id";
478 $rs = xx_tryquery($sql);
479 $row = xx_fetch_array ($rs, xx_ASSOC);
480 $css_file = $row["css_file"];
481
482 if (strlen($css_file) > 0) {
483 printf("<style type=\"text/css\">\n");
484 //include($GLOBAL_PUBLIC_URL.$css_file); pfb -- don't assume locations
485 include($css_file);
486 printf("TD {font-size: 90%%}\n");
487 printf("</style>\n");
488 }
489
490
491 /***************************
492 ** Display current Styles **
493 ***************************/
494
495 printf("<table border=\"1\" cellpadding=\"4\"><tr>\n");
496 printf("<td class=\"cellPlain\"> Current Style Key </td>\n");
497 printf("<td>\n");
498 printf("No Style | ");
499 for ($counter = 1; $counter < 6; $counter++) {
500 printf("<span class=\"S%d\">Style %d</span> ", $counter, $counter);
501 if ($counter < 5) printf("| ");
502 }
503 printf("</td></tr></table><br>\n");
504
505
506 /***************
507 ** Page Title **
508 ***************/
509
510
511 printf("<table width = \"90%%\" border =\"0\"><tr><td>");
512
513 // Special note to CourseLib authors
514 if ($pagetype_id == 3) {
515 printf("<span class=\"bigDark\">");
516 printf("Note: Course Designator (Subject) is required to publish a page. Don't include it in the course title, select it from the pick-list below. ");
517 printf("</span><br><br>\n");
518 }
519
520 if ($cmd == "editHeader") {
521 editHeader($course_id, $page_id, $page_title, $pagetype_id);
522 }
523
524 else {
525 displayHeader($page_id, $page_title, $pagetitle_style, $pagetype_id);
526 }
527
528 printf("</td></tr></table><br>");
529
530
531 /****************************************
532 ** If CourseLib, load additional forms **
533 ****************************************/
534
535
536 // Load the course forms is this is a CourseLib+/CourseScribe page
537 if ($pagetype_id == 3) {
538
539 formCourse($active, $page_id);
540 formCoursePers($active, $course_id, $page_id);
541
542 // HR
543 printf("<hr>\n");
544 }
545
546 /*********************
547 ** PageScribe forms **
548 **********************/
549 else formPageHeader($active, $page_id);
550
551
552 /******************************
553 ** Display Table of Contents **
554 ******************************/
555
556 if ($display_toc == 1) {
557 displayTOC($page_id, $wrap_toc);
558 }
559
560
561 /**************************************
562 ** Place everything in a large table **
563 **************************************/
564
565
566 printf("<center><table width= \"100%%\" border=\"0\" cellpadding=\"0\" cellspacing =\"0\"><tr><td align=\"left\">\n");
567
568
569 /***********************
570 ** Fetch All Elements **
571 ***********************/
572
573
574 $sql = "SELECT * FROM element e
575 LEFT JOIN resource r using (resource_id)
576 LEFT JOIN vendor d on r.vendor_id = d.vendor_id
577 LEFT JOIN service v on e.service_id = v.service_id
578 LEFT JOIN location l on e.location_id = l.location_id
579 LEFT JOIN staff s on e.staff_id = s.staff_id
580 LEFT JOIN subject b on e.subject_id = b.subject_id
581 WHERE page_id = " . $page_id
582 . " ORDER BY e.element_order";
583
584 $rs = xx_tryquery($sql);
585
586 // Make a copy of the result set for cursor manipulation later
587 $rscopy = $rs;
588
589 // If the previous didn't work, do this explicitly
590 // $rscopy = xx_tryquery($sql);
591
592 // Create a positional variable, may contain an element or a row of add buttons
593 $position = 1;
594
595 // Initialize the element order
596 $element_order = 1;
597
598 // Track indent levels
599 $last_indent_level = 0;
600 $indent_level = 0;
601
602 // Initialize row number
603 $row_number = 0;
604
605
606 /****************
607 ** INITIAL ADD **
608 ****************/
609
610 // Define array to hold information about each element location
611 $place_array = array(0, $element_order, $indent_level, 0, $position);
612
613 // Name every position with an anchor
614 printf("\n\n\n<a name = \"p%d\"></a>\n", $position);
615
616
617 /*********************
618 ** INITIAL ADD MODE **
619 *********************/
620
621
622 if ($position == $this_pos && strlen($cmd) > 0) {
623
624 switch ($cmd) {
625
626 case "addRes":
627 addRes($feature_id, $letter, $limitstring, $masterinfotype_id, $place_array, $page_id);
628 break;
629 case "addLoc":
630 addLoc($place_array, $page_id);
631 break;
632 case "addService":
633 addService($place_array, $servicetype_id, $page_id);
634 break;
635 case "addStaff":
636 addStaff($place_array, $page_id);
637 break;
638 case "addLabel":
639 addLabel($place_array, $page_id);
640 break;
641 case "addRQS":
642 addRQS($place_array, $page_id);
643 break;
644 case "addRQSLink":
645 addRQSLink($place_array, $page_id);
646 break;
647 default:
648 break;
649
650 } // End cmd switch
651
652 }
653
654 else {
655
656
657 /**************************
658 ** ELSE INITIAL ADD ICON **
659 **************************/
660
661
662 // Present an add icon or the add options
663 if ($opt == "add" && $this_pos == $position) {
664 // Display add selection
665 addSelection($place_array, $page_id);
666 }
667
668 else {
669 printf("<a href=\"scribe.phtml?page_id="
670 . $page_id
671 . "&opt=add"
672 . "&this_pos="
673 . $position
674 . "#p"
675 . $position
676 . "\"><img src =\"images/add.gif\" border=\"0\" alt=\"add\"></a>\n");
677
678 // Paste
679 if ($paste_data > 0)
680 printf("<a href=\"scribe_transaction.phtml?transaction=pasteElement&page_id=%d&element_order=%d&indent_level=%d&position=%d\"><img src=\"images/paste.gif\" border=\"0\" alt=\"paste\"></a>\n", $page_id, $element_order, $indent_level, $position);
681
682
683 }
684 }
685 printf("<BR>\n");
686 $position++;
687
688
689
690 // Cycle through each row of page elements
691 while ($row = xx_fetch_array ($rs, xx_ASSOC)) {
692
693 // General element information
694 $element_id = $row["element_id"];
695 $page_id = $row["page_id"];
696 $element_size = $row["element_size"];
697 $label = $row["label"];
698 $label_url = $row["label_url"];
699 $element_order = $row["element_order"];
700 $element_descr = $row["element_descr"];
701 $indent_level = $row["indent_level"];
702 $parent_id = $row["parent_id"];
703
704 // If a resource
705 $resource_id = $row["resource_id"];
706 $annotation = $row["annotation"];
707 $url = $row["url"];
708 $title = $row["title"];
709 $call_no = $row["call_no"];
710
711 $guide_url = $row["guide_url"];
712 $resource_message = $row["resource_message"];
713 $resource_status = $row["resource_status"];
714 $vendor_message = $row["vendor_message"];
715 $vendor_status = $row["vendor_status"];
716
717 // If a location
718 $location_id = $row["location_id"];
719 $location = $row["location"];
720 $location_descr = $row["location_descr"];
721 $mainURL = $row["mainURL"];
722 $mapURL = $row["mapURL"];
723 $hoursURL = $row["hoursURL"];
724
725 // If a staffperson
726 $staff_id = $row["staff_id"];
727 $last_name = $row["last_name"];
728 $first_name = $row["first_name"];
729 $staff_account = $row["staff_account"];
730 $staff_email = $row["staff_email"];
731
732 // If a service
733 $service = $row["service"];
734 $serviceDescr = $row["serviceDescr"];
735 $service_id = $row["service_id"];
736 $serviceURL = $row["serviceURL"];
737
738 // If a subject
739 $subject = $row["subject"];
740 $subject_id = $row["subject_id"];
741 $subject_descr = $row["subject_descr"];
742
743 // Define array to hold information about each element location
744 $place_array = array($element_id, $element_order, $indent_level, $parent_id, $position);
745
746 // Start the indention
747 if ($indent_level > 0) {
748 for ($spaces = 0; $spaces < $indent_level; $spaces++) {
749 printf("<ul>");
750 }
751 printf("<li>");
752 }
753
754 // Name every position with an anchor
755 printf("\n\n\n<a name = \"p%d\"></a>\n", $position);
756
757 // Build an additional TOC anchor for root-level elements
758 if ($indent_level == 0 && $display_toc == 1) printf("<a name =\"toc%d\"></a>\n", $element_id);
759
760
761 /***************
762 ** EDIT MODE? **
763 ***************/
764
765
766 if ($position == $this_pos && strlen($cmd) > 0) {
767
768 switch ($cmd) {
769 case "copyElement":
770 copyElement($place_array, $page_id, $element_id, $sess_staff_id);
771 break;
772 case "delElement":
773 delElement($place_array, $page_id, $element_id);
774 break;
775 case "editElement":
776 editElement($place_array, $page_id, $element_id);
777 break;
778 default:
779 break;
780
781 } // End cmd switch
782
783
784 } // END EDIT MODE
785
786
787 /**********************
788 ** ELSE DISPLAY MODE **
789 **********************/
790
791 else {
792
793 // Display [Return to Top] link if this item represents a new root level,
794 // the user has toggled the displaying of up anchors, and there is something to display.
795 if ($row_number > 0 && $indent_level < 1 && $display_up > 0 && strlen($up_text) > 0) {
796 printf("<span class=\"S5\">\n");
797 printf("<a href=\"scribe.phtml?page_id=%d#top\">%s</a><br><br>\n", $page_id, $up_text);
798 printf("</span>\n");
799 }
800
801 // This element is a resource, display it.
802 if ($resource_id > 0) {
803
804 // Set the span S class if specified
805 if ($element_size > 0) printf ("<span class=\"S%d\">", $element_size);
806
807 // If an URL was specified for the resource, make it linkable.
808 if (strlen($url) > 0) $title = "<a href =\"" . $url . "\">" . $title . "</a>";
809
810 // Display Resource
811 printf ("%s", $title);
812
813 // If a span class is being used, close it now
814 if ($element_size > 0) printf ("</span>\n");
815
816 }
817
818 // Or this element is a label, display it.
819 else if (strlen($label) > 0) {
820
821 // Set the span S class if specified
822 if ($element_size > 0) printf ("<span class=\"S%d\">", $element_size);
823
824 // If an URL was specified, add it.
825 if (strlen($label_url) > 0) $label = "<a href =\"" . $label_url . "\">" . $label . "</a>";
826
827 // Label
828 printf("%s", $label);
829
830 // If a span class is being used, close it now
831 if ($element_size > 0) printf ("</span>\n");
832
833 }
834
835 // Or this element is a location/library, display it.
836 else if ($location_id > 0) {
837
838 // Set the span S class if specified
839 if ($element_size > 0) printf ("<span class=\"S%d\">", $element_size);
840
841 // If an URL was available, make it linkable
842 if (strlen($mainURL) > 0) printf("<a href=\"%s\">%s</a>", $mainURL, $location);
843
844 // Display location
845 else printf("%s\n", $location);
846
847 // If a span class is being used, close it now
848 if ($element_size > 0) printf ("</span>\n");
849
850 }
851
852 // Or this element is a service, display it.
853 else if ($service_id > 0 ) {
854 // Set the span S class if specified
855 if ($element_size > 0) printf ("<span class=\"S%d\">", $element_size);
856
857 // If an URL was specified for the service, make it linkable.
858 if (strlen($serviceURL) > 0) $service = "<a href =\"" . $serviceURL . "\">" . $service . "</a>";
859
860 // Service
861 printf("%s", $service);
862
863 // If a span class is being used, close it now
864 if ($element_size > 0) printf ("</span>\n");
865 }
866
867 // Or this element is a subject, display it.
868 else if ($subject_id > 0 ) {
869 // Set the span S class if specified
870 if ($element_size > 0) printf ("<span class=\"S%d\">", $element_size);
871
872 // If an URL was specified for the service, make it linkable.
873 $subject = "<a href=\""
874 . $GLOBAL_RQS_URL
875 ."rqs.phtml?subject_id="
876 .$subject_id
877 ."\">"
878 . $subject
879 ."</a>";
880
881 // Subject
882 printf("%s", $subject);
883
884 // If a span class is being used, close it now
885 if ($element_size > 0) printf ("</span>\n");
886 }
887
888 // Or this element is a staff person, display it.
889 else if ($staff_id > 0 ) {
890
891 // Set the span S class if specified
892 if ($element_size > 0) printf ("<span class=\"S%d\">", $element_size);
893
894 $staff_name = $first_name . " " . $last_name;
895
896 // If an e-mail is available, link with mailto:
897 if (strlen($staff_email) > 0) printf("<a href=\"mailto:%s\">%s</a>", $staff_email, $staff_name);
898
899 // Display staff
900 else printf("%s", $staff_name);
901
902 // If a span class is being used, close it now
903 if ($element_size > 0) printf ("</span>\n");
904
905 }
906
907 // Space
908 printf("&nbsp;&nbsp;");
909
910 // Display edit buttons
911 editButtons($element_size, $label_text, $label_url, $place_array, $resource_id, $page_id, $element_id);
912
913 // Allow up button
914 if (sibProbeElder($genArray, $page_id, $place_array)) buttonUp($page_id, $place_array);
915
916 // Allow down button
917 if (sibProbeYounger($genArray, $page_id, $place_array)) buttonDown($page_id, $place_array);
918
919 // Handle down/alert messages
920 if ($vendor_status > 0 || $resource_status > 0) {
921
922 printf("<br><img src =\"images/chain.jpg\" alt=\"Resource Temporarily Unavailable\">\n");
923 printf("<span class=\"error\">\n");
924 if (strlen($vendor_message) > 1) printf("%s\n", $vendor_message);
925 else if (strlen($resource_message) > 1) printf("%s\n", $resource_message);
926 printf("</span>\n");
927 }
928
929 // Initialize anew for each row
930 $display_descr = "";
931 $viewable_url = "";
932
933 // Determine the display description and viewable url
934 if (strlen($element_descr) > 0) {
935 $display_descr = $element_descr;
936 if (strlen($label_url) > 0 ) $viewable_url = "URL:" . $label_url;
937 }
938 else if ($resource_id > 0) {
939 $display_descr = $annotation;
940 $viewable_url = $url;
941 }
942 else if ($location_id > 0) {
943 $display_descr = $location_descr;
944 $viewable_url = $mainURL;
945 }
946 else if ($service_id > 0) {
947 $display_descr = $serviceDescr;
948 $viewable_url = $serviceURL;
949 }
950 else if ($subject_id > 0) {
951 $display_descr = $subject_descr;
952 $viewable_url = $GLOBAL_RQS_URL."rqs.phtml?subject_id=".$subject_id;
953 }
954
955 if ($staff_id > 0) $viewable_url = $staff_email;
956
957 // Display URL if toggled and available
958 if (strlen($viewable_url) > 0 && $display_urls == 1) printf("<BR>%s<BR>\n", $viewable_url);
959
960 // Concatenate the hoursURL and mapURL if available and this is a location
961 if ($location_id > 0) {
962
963 // Flag to add a <BR> before additional location information
964 $br_flag = 0;
965
966 if (strlen($hoursURL) > 0) {
967
968 if (strlen($display_descr) > 0) {
969 $display_descr .= "<BR>\n";
970 $br_flag = 1;
971 }
972
973 $display_descr .= " &#149; <a href=\""
974 . $hoursURL
975 . "\">Hours</a>";
976 }
977 if (strlen($mapURL) > 0) {
978
979 if (strlen($display_descr) > 0 && $br_flag == 0) {
980 $display_descr .= "<BR>\n";
981 $br_flag = 1;
982 }
983
984 $display_descr .= " &#149; <a href=\""
985 . $mapURL
986 . "\">Map</a>";
987 }
988
989 }
990
991 // Concatenate callno/location information for resources
992 if ($resource_id > 0 && strlen($call_no) > 0) {
993
994 if (strlen($display_descr) > 0) $display_descr .= "<BR>";
995 $display_descr .= "&#149; Location(s): " . $call_no;
996 }
997
998 // Display description if available
999 if (strlen($display_descr) > 0) printf("<BR>%s\n", $display_descr);
1000
1001 }
1002
1003
1004 // Close the indention
1005 if ($indent_level > 0) {
1006 printf("</li>");
1007 for ($spaces = 0; $spaces < $indent_level; $spaces++) {
1008 printf("</ul>");
1009 }
1010 }
1011 else printf("<BR>\n");
1012
1013
1014 // Increment order
1015 $element_order++;
1016
1017 // Cycle back to zero indent level, allow an insert if there are no younger relatives in this branch
1018 for ($reverse_indent = $indent_level + 1; $reverse_indent >= 0; $reverse_indent--) {
1019
1020 // Redefine array to hold information about each element location
1021 $place_array = array($element_id, $element_order, $reverse_indent, $parent_id, $position);
1022
1023 // Allow indent mode only if there are no children
1024 if (!youngerProbe($page_id, $place_array, $rs)) {
1025
1026 // Increment position
1027 $position++;
1028
1029 // Redefine array to hold information about each element location
1030 $place_array = array($element_id, $element_order, $reverse_indent, $parent_id, $position);
1031
1032
1033 // Start the indention
1034 if ($reverse_indent > 0) {
1035 for ($spaces = 0; $spaces < $reverse_indent; $spaces++) {
1036 printf("<ul>");
1037 }
1038 printf("<li>");
1039 }
1040
1041 // Name every position with an anchor
1042 printf("\n\n<a name = \"p%d\"></a>\n", $position);
1043
1044 /**********************
1045 ** ADD INDENTED MODE **
1046 **********************/
1047
1048 if ($position == $this_pos && strlen($cmd) > 0) {
1049
1050 switch ($cmd) {
1051
1052 case "addRes":
1053 addRes($feature_id, $letter, $limitstring, $masterinfotype_id, $place_array, $page_id);
1054 break;
1055 case "addLoc":
1056 addLoc($place_array, $page_id);
1057 break;
1058 case "addService":
1059 addService($place_array, $servicetype_id, $page_id);
1060 break;
1061 case "addStaff":
1062 addStaff($place_array, $page_id);
1063 break;
1064 case "addLabel":
1065 addLabel($place_array, $page_id);
1066 break;
1067 case "addRQS":
1068 addRQS($place_array, $page_id);
1069 break;
1070 case "addRQSLink":
1071 addRQSLink($place_array, $page_id);
1072 break;
1073 default:
1074 break;
1075
1076 } // End cmd switch
1077
1078 }
1079 else {
1080
1081 /***************************
1082 ** ELSE INDENTED ADD ICON **
1083 ***************************/
1084
1085
1086 // Present an add icon or the add options
1087 if ($opt == "add" && $this_pos == $position) {
1088 // Display add selection
1089 addSelection($place_array, $page_id);
1090 }
1091
1092 else {
1093 printf("<a href=\"scribe.phtml?page_id="
1094 . $page_id
1095 . "&opt=add"
1096 . "&this_pos="
1097 . $position
1098 . "#p"
1099 . $position
1100 . "\"><img src =\"images/add.gif\" border=\"0\" alt=\"add\"></a>\n");
1101
1102 // Paste
1103 if ($paste_data > 0)
1104 printf("<a href=\"scribe_transaction.phtml?transaction=pasteElement&page_id=%d&element_order=%d&indent_level=%d&position=%d\"><img src=\"images/paste.gif\" border=\"0\" alt=\"paste\"></a>\n", $page_id, $element_order, $reverse_indent, $position);
1105
1106 }
1107
1108 }
1109
1110
1111 // Close the indention
1112 if ($reverse_indent > 0) {
1113 printf("</li>");
1114 for ($spaces = 0; $spaces < $reverse_indent; $spaces++) {
1115 printf("</ul>");
1116 }
1117 }
1118 else printf("<BR>\n");
1119
1120 } // no children, allow an indent add
1121 } // as many times as possible
1122
1123 // Increment position
1124 $position++;
1125
1126 // Swap indent levels
1127 $last_indent_level = $indent_level;
1128
1129 // Increment row number
1130 $row_number++;
1131
1132 } // all table rows
1133
1134
1135
1136 // Display final [Return to Top] link, regardless of current indent level, if
1137 // the user has toggled the displaying of up anchors, and there is something to display.
1138 if ($row_number > 0 && $display_up > 0 && strlen($up_text) > 0) {
1139 printf("<span class=\"S5\">\n");
1140 printf("<a href=\"scribe.phtml?page_id=%d#top\">%s</a><br><br>\n", $page_id, $up_text);
1141 printf("</span>\n");
1142 }
1143
1144
1145 /**********************
1146 ** close large table **
1147 **********************/
1148 printf("</td></tr></table></center><br><br>\n");
1149
1150
1151 // Error trapping
1152 if ($page_debug == 1) errorTrap($page_id);
1153
1154
1155 } // valid page workspace
1156
1157 printf("<br><br>\n");
1158
1159 // Display page coordinator
1160 if ($staff_coordinator > 0) {
1161 $display_page_coord = lookupStaff($staff_coordinator);
1162 $staff_email = lookupField("staff", "staff_id", $staff_coordinator, "staff_email");
1163
1164 if (strlen($display_page_coord) > 0 && strlen($staff_email) > 0) {
1165 printf("<span class=\"S5\">\n");
1166 printf("Page Coordinator: %s <a href=\"mailto:%s\">%s</a>\n", $display_page_coord, $staff_email, $staff_email);
1167 printf("</span><br>\n");
1168 }
1169 }
1170
1171
1172 // Display page URL
1173 printf("<span class=\"S5\">\n");
1174 printf("This URL: <a href=\"%sscribe.phtml?page_id=%d\">%sscribe.phtml?page_id=%d</a>\n", $GLOBAL_ADMIN_URL, $page_id, $GLOBAL_ADMIN_URL, $page_id);
1175 printf("</span>\n");
1176
1177 // If no page title supplied
1178 if (strlen($page_title) < 1) {
1179 printf("<center><br>\n");
1180 printf("No course/page title supplied. Operation cancelled.");
1181 printf("<br></center>\n");
1182
1183 adminReturn($sess_access_level);
1184 }
1185
1186 } // logged in
1187
1188 // No access
1189 else require_once ($GLOBAL_NO_ACCESS);
1190
1191
1192 // Page footer
1193 require_once ($GLOBAL_ADMIN_INC."scribe_footer.phtml");
1194 ?>
1195 </body>
1196 </html>

  ViewVC Help
Powered by ViewVC 1.1.26