4 * Displays and customizes the iconbar.
10 /** Values for ib_displayas */
11 #define IB_PICTEXT 0 /**< picture and text */
12 #define IB_PICONLY 1 /**< just a picture */
13 #define IB_TEXTONLY 2 /**< just text */
16 void do_iconbar(void);
17 void do_iconbar_roomlist(void);
20 * \brief draw the icon bar?????
22 void do_selected_iconbar(void) {
23 if (WC->current_iconbar == current_iconbar_roomlist) {
24 do_iconbar_roomlist();
31 void DontDeleteThis(void *Data){};
33 #define IconbarIsEnabled(a, b) IconbarIsENABLED(a, sizeof(a) - 1, b)
35 long IconbarIsENABLED(const char *key, size_t keylen, long defval)
38 if (GetHash(WC->IconBarSetttings, key, keylen,
45 #ifdef DBG_ICONBAR_HASH
47 inline const char *PrintInt(void *Prefstr)
49 snprintf(nbuf, sizeof(nbuf), "%ld", (long)Prefstr);
54 void LoadIconSettings(void)
56 struct wcsession *WCC = WC;
57 StrBuf *iconbar = NULL;
58 StrBuf *buf = NewStrBuf();;
59 StrBuf *key = NewStrBuf();
63 WCC->current_iconbar = current_iconbar_menu;
64 if (WCC->IconBarSetttings == NULL)
65 WCC->IconBarSetttings = NewHash(1, NULL);
67 * The initialized values of these variables also happen to
68 * specify the default values for users who haven't customized
69 * their iconbars. These should probably be set in a master
70 * configuration somewhere.
73 if (get_preference("iconbar", &iconbar)) {
74 nTokens = StrBufNum_tokens(iconbar, ',');
75 for (i=0; i<nTokens; ++i) {
76 StrBufExtract_token(buf, iconbar, i, ',');
77 StrBufExtract_token(key, buf, 0, '=');
78 val = StrBufExtract_long(buf, 1, '=');
79 Put(WCC->IconBarSetttings,
80 ChrPtr(key), StrLength(key),
81 (void*)val, DontDeleteThis);
85 #ifdef DBG_ICONBAR_HASH
86 dbg_PrintHash(WCC->IconBarSetttings, PrintInt, NULL);
95 * \brief draw the icon bar???
97 void do_iconbar(void) {
98 int ib_displayas = IB_PICTEXT; /**< pictures and text, pictures, text */
101 ib_displayas = IconbarIsEnabled("ib_displayas", IB_PICTEXT);
104 if (IconbarIsEnabled("ib_logo", 0)) {
105 if (ib_displayas != IB_TEXTONLY) {
106 wprintf("<div class=\"logo\"> <img "
107 "src=\"image&name=hello\" alt=\" \"> "
114 /** 'Powered by Citadel' logo */
115 if (IconbarIsEnabled("ib_citadel", 1) && (ib_displayas != IB_TEXTONLY)) wprintf(
116 "<div class=\"logo_citadel\"> "
117 "<a href=\"http://www.citadel.org\" "
120 "src=\"static/citadel-logo.gif\" alt=\"%s\"></a> "
122 _("Find out more about Citadel"),
126 wprintf("<ul id=\"button\">\n");
128 wprintf("<li class=\"switch\"><a href=\"javascript:switch_to_room_list()\">");
129 wprintf(_("switch to room list"));
130 wprintf("</a></li>");
132 /** Summary page icon */
133 if (IconbarIsEnabled("ib_summary", 1)) {
134 wprintf("<li><a href=\"summary\" "
136 ">", _("Your summary page")
138 if (ib_displayas != IB_TEXTONLY) {
139 wprintf("<img alt=\"\" "
140 "src=\"static/summscreen_32x.gif\">");
142 if (ib_displayas != IB_PICONLY) {
143 wprintf(_("Summary"));
145 wprintf("</a></li>\n");
149 if (IconbarIsEnabled("ib_inbox", 1)) {
151 "<a href=\"dotgoto?room=_MAIL_\" "
154 _("Go to your email inbox")
156 if (ib_displayas != IB_TEXTONLY) {
157 wprintf("<img alt=\"\" "
158 "src=\"static/privatemess_32x.gif\">");
160 if (ib_displayas != IB_PICONLY) {
162 if (WC->new_mail != WC->remember_new_mail) {
164 if (WC->new_mail > 0) {
165 wprintf(" <b>(%d)</b>", WC->new_mail);
168 WC->remember_new_mail = WC->new_mail;
171 wprintf("</a></li>\n");
175 if (IconbarIsEnabled("ib_calendar", 1)) {
177 "<a href=\"dotgoto?room=_CALENDAR_\" "
180 _("Go to your personal calendar")
182 if (ib_displayas != IB_TEXTONLY) {
183 wprintf("<img alt=\"\" "
184 "src=\"static/calarea_32x.gif\">");
186 if (ib_displayas != IB_PICONLY) {
187 wprintf(_("Calendar"));
189 wprintf("</a></li>\n");
193 if (IconbarIsEnabled("ib_contacts", 1)) {
195 "<a href=\"dotgoto?room=_CONTACTS_\" "
198 _("Go to your personal address book")
200 if (ib_displayas != IB_TEXTONLY) {
201 wprintf("<img alt=\"\" "
202 "src=\"static/viewcontacts_32x.gif\">");
204 if (ib_displayas != IB_PICONLY) {
205 wprintf(_("Contacts"));
207 wprintf("</a></li>\n");
211 if (IconbarIsEnabled("ib_notes", 1)) {
213 "<a href=\"dotgoto?room=_NOTES_\" "
216 _("Go to your personal notes")
218 if (ib_displayas != IB_TEXTONLY) {
219 wprintf("<img alt=\"\" "
220 "src=\"static/storenotes_32x.gif\">");
222 if (ib_displayas != IB_PICONLY) {
225 wprintf("</a></li>\n");
229 if (IconbarIsEnabled("ib_tasks", 1)) {
231 "<a href=\"dotgoto?room=_TASKS_\" "
234 _("Go to your personal task list")
236 if (ib_displayas != IB_TEXTONLY) {
237 wprintf("<img alt=\"\" "
238 "src=\"static/taskmanag_32x.gif\">");
240 if (ib_displayas != IB_PICONLY) {
243 wprintf("</a></li>\n");
247 if (IconbarIsEnabled("ib_rooms", 1)) {
249 "<a href=\"knrooms\" title=\"%s\" >",
250 _("List all of your accessible rooms")
252 if (ib_displayas != IB_TEXTONLY) {
253 wprintf("<img alt=\"\" "
254 "src=\"static/chatrooms_32x.gif\">");
256 if (ib_displayas != IB_PICONLY) {
259 wprintf("</a></li>\n");
263 if (IconbarIsEnabled("ib_users", 1)) {
265 "<a href=\"do_template?template=who\" title=\"%s\" "
267 _("See who is online right now")
269 if (ib_displayas != IB_TEXTONLY) {
270 wprintf("<img alt=\"\" "
271 "src=\"static/usermanag_32x.gif\">");
273 if (ib_displayas != IB_PICONLY) {
274 wprintf(_("Who is online?"));
279 if (IconbarIsEnabled("ib_users", 0)) {
280 wprintf("<ul id=\"wholist\">");
281 wprintf("</ul></li>\n");
286 if (IconbarIsEnabled("ib_chat", 1)) {
288 "<a href=\"#\" onClick=\"window.open('chat', "
289 "'ctdl_chat_window', "
290 "'toolbar=no,location=no,directories=no,copyhistory=no,"
291 "status=no,scrollbars=yes,resizable=yes');\""
294 if (ib_displayas != IB_TEXTONLY) {
295 wprintf("<img alt=\"\" "
296 "src=\"static/citadelchat_32x.gif\">");
298 if (ib_displayas != IB_PICONLY) {
301 wprintf("</a></li>\n");
304 /** Advanced Options icon */
305 if (IconbarIsEnabled("ib_advanced", 1)) {
307 "<a href=\"do_template?template=display_main_menu\" "
310 _("Advanced Options Menu: Advanced Room commands, Account Info, and Chat")
312 if (ib_displayas != IB_TEXTONLY) {
313 wprintf("<img alt=\"\" "
314 "src=\"static/advanpage2_32x.gif\">");
316 if (ib_displayas != IB_PICONLY) {
317 wprintf(_("Advanced"));
319 wprintf("</a></li>\n");
322 if ((WC->axlevel >= 6) || (WC->is_room_aide)) {
324 "<a href=\"do_template?template=display_aide_menu\" "
327 _("Room and system administration functions")
329 if (ib_displayas != IB_TEXTONLY) {
330 wprintf("<img alt=\"\" "
331 "src=\"static/advanpage2_32x.gif\">");
333 if (ib_displayas != IB_PICONLY) {
334 wprintf(_("Administration"));
336 wprintf("</a></li>\n");
340 "<a href=\"termquit\" title=\"%s\" "
341 "onClick=\"return confirm('%s');\">",
346 if (ib_displayas != IB_TEXTONLY) {
347 wprintf("<img alt=\"\" "
348 "src=\"static/logoff_32x.gif\">");
350 if (ib_displayas != IB_PICONLY) {
351 wprintf(_("Log off"));
353 wprintf("</a></li>\n");
356 "<li class=\"switch\">"
357 "<a href=\"display_customize_iconbar\" "
361 _("Customize this menu"),
362 _("customize this menu")
367 if (IconbarIsEnabled("ib_users", 0)) {
369 "<script type=\"text/javascript\"> "
370 " new Ajax.PeriodicalUpdater('wholist', 'do_template?template=wholist_section', { method: 'get', frequency: 30 } );"
378 * \brief roomtree view of the iconbar
379 * If the user has toggled the icon bar over to a room list, here's where
380 * we generate its innerHTML...
382 void do_iconbar_roomlist(void) {
384 WC->current_iconbar = current_iconbar_roomlist;
387 * The initialized values of these variables also happen to
388 * specify the default values for users who haven't customized
389 * their iconbars. These should probably be set in a master
390 * configuration somewhere.
396 ib_displayas = IconbarIsEnabled("ib_displayas", IB_PICTEXT); /* pictures and text, pictures, text */
399 if (IconbarIsEnabled("ib_logo", 0)) {
400 if (ib_displayas != IB_TEXTONLY) {
401 wprintf("<div class=\"logo\"> <img "
402 "src=\"image&name=hello\" alt=\" \"> "
408 /** 'Powered by Citadel' logo */
409 if (IconbarIsEnabled("ib_citadel", 1) && (ib_displayas != IB_TEXTONLY)) wprintf(
410 "<div class=\"logo_citadel\"> "
411 "<a href=\"http://www.citadel.org\" "
414 "src=\"static/citadel-logo.gif\" alt=\"%s\"></a> "
416 _("Find out more about Citadel"),
420 wprintf("<ul id=\"button\">\n");
422 wprintf("<li class=\"switch\"><a href=\"javascript:switch_to_menu_buttons()\">");
423 wprintf(_("switch to menu"));
424 wprintf("</a></li>");
427 "<a href=\"termquit\" title=\"%s\" "
428 "onClick=\"return confirm('%s');\">",
433 if (ib_displayas != IB_TEXTONLY) {
434 wprintf("<img alt=\"\" "
435 "src=\"static/logoff_32x.gif\">");
437 if (ib_displayas != IB_PICONLY) {
438 wprintf(_("Log off"));
440 wprintf("</a></li>\n");
444 /** embed the room list */
445 list_all_rooms_by_floor("iconbar");
452 * \brief display a customized version of the iconbar
454 void display_customize_iconbar(void) {
463 output_headers(1, 1, 2, 0, 0, 0);
464 wprintf("<div id=\"banner\">");
466 wprintf(_("Customize the icon bar"));
467 wprintf("</h1></div>\n");
469 wprintf("<div id=\"content\" class=\"service\">\n");
471 wprintf("<div class=\"fix_scrollbar_bug\">");
473 wprintf("<form method=\"post\" action=\"commit_iconbar\">\n");
474 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
476 wprintf("<table class=\"altern\" >\n");
477 wprintf("<tr><td></td><td colspan=\"2\"><b>");
478 wprintf(_("Display icons as:"));
480 ib_displayas = IconbarIsEnabled("ib_displayas",IB_PICTEXT);
481 for (i=0; i<=2; ++i) {
482 wprintf("<input type=\"radio\" name=\"ib_displayas\" value=\"%d\"", i);
483 if (ib_displayas == i) wprintf(" CHECKED");
485 if (i == IB_PICTEXT) wprintf(_("pictures and text"));
486 if (i == IB_PICONLY) wprintf(_("pictures only"));
487 if (i == IB_TEXTONLY) wprintf(_("text only"));
492 wprintf(_("Select the icons you would like to see displayed "
493 "in the 'icon bar' menu on the left side of the "
495 wprintf("</td></tr>\n");
498 val = IconbarIsEnabled("ib_logo", 0);
499 wprintf("<tr class=\"%s\"><td>"
500 "<input type=\"radio\" name=\"ib_logo\" value=\"yes\" %s> %s "
501 "<input type=\"radio\" name=\"ib_logo\" value=\"no\" %s> %s <br />"
503 "<img src=\"image&name=hello\" width=\"48\" alt=\" \">"
508 (bar ? "even" : "odd"),
509 (val ? "CHECKED" : ""),_("Yes"),
510 (!val ? "CHECKED" : ""),_("No"),
512 _("An icon describing this site")
516 val = IconbarIsEnabled("ib_summary", 1);
517 wprintf("<tr class=\"%s\"><td>"
518 "<input type=\"radio\" name=\"ib_summary\" value=\"yes\" %s> %s "
519 "<input type=\"radio\" name=\"ib_summary\" value=\"no\" %s> %s <br />"
521 "<img src=\"static/summscreen_48x.gif\" alt=\" \">"
526 (bar ? "even" : "odd"),
527 (val ? "CHECKED" : ""),_("Yes"),
528 (!val ? "CHECKED" : ""),_("No"),
530 _("Your summary page")
534 val = IconbarIsEnabled("ib_inbox", 1);
535 wprintf("<tr class=\"%s\"><td>"
536 "<input type=\"radio\" name=\"ib_inbox\" value=\"yes\" %s> %s "
537 "<input type=\"radio\" name=\"ib_inbox\" value=\"no\" %s> %s <br />"
539 "<img src=\"static/privatemess_48x.gif\" alt=\" \">"
544 (bar ? "even" : "odd"),
545 (val ? "CHECKED" : ""),_("Yes"),
546 (!val ? "CHECKED" : ""),_("No"),
548 _("A shortcut to your email Inbox")
552 val = IconbarIsEnabled("ib_contacts", 1);
553 wprintf("<tr class=\"%s\"><td>"
554 "<input type=\"radio\" name=\"ib_contacts\" value=\"yes\" %s> %s "
555 "<input type=\"radio\" name=\"ib_contacts\" value=\"no\" %s> %s <br />"
557 "<img src=\"static/viewcontacts_48x.gif\" alt=\" \">"
562 (bar ? "even" : "odd"),
563 (val ? "CHECKED" : ""),_("Yes"),
564 (!val ? "CHECKED" : ""),_("No"),
566 _("Your personal address book")
570 val = IconbarIsEnabled("ib_notes", 1);
571 wprintf("<tr class=\"%s\"><td>"
572 "<input type=\"radio\" name=\"ib_notes\" value=\"yes\" %s> %s "
573 "<input type=\"radio\" name=\"ib_notes\" value=\"no\" %s> %s <br />"
575 "<img src=\"static/storenotes_48x.gif\" alt=\" \">"
580 (bar ? "even" : "odd"),
581 (val ? "CHECKED" : ""),_("Yes"),
582 (!val ? "CHECKED" : ""),_("No"),
584 _("Your personal notes")
588 val = IconbarIsEnabled("ib_calendar", 1);
589 wprintf("<tr class=\"%s\"><td>"
590 "<input type=\"radio\" name=\"ib_calendar\" value=\"yes\" %s> %s "
591 "<input type=\"radio\" name=\"ib_calendar\" value=\"no\" %s> %s <br />"
593 "<img src=\"static/calarea_48x.gif\" alt=\" \">"
598 (bar ? "even" : "odd"),
599 (val ? "CHECKED" : ""),_("Yes"),
600 (!val ? "CHECKED" : ""),_("No"),
602 _("A shortcut to your personal calendar")
606 val = IconbarIsEnabled("ib_tasks", 1);
607 wprintf("<tr class=\"%s\"><td>"
608 "<input type=\"radio\" name=\"ib_tasks\" value=\"yes\" %s> %s "
609 "<input type=\"radio\" name=\"ib_tasks\" value=\"no\" %s> %s <br />"
611 "<img src=\"static/taskmanag_48x.gif\" alt=\" \">"
616 (bar ? "even" : "odd"),
617 (val ? "CHECKED" : ""),_("Yes"),
618 (!val ? "CHECKED" : ""),_("No"),
620 _("A shortcut to your personal task list")
624 val = IconbarIsEnabled("ib_rooms", 1);
625 wprintf("<tr class=\"%s\"><td>"
626 "<input type=\"radio\" name=\"ib_rooms\" value=\"yes\" %s> %s "
627 "<input type=\"radio\" name=\"ib_rooms\" value=\"no\" %s> %s <br />"
629 "<img src=\"static/chatrooms_48x.gif\" alt=\" \">"
634 (bar ? "even" : "odd"),
635 (val ? "CHECKED" : ""),_("Yes"),
636 (!val ? "CHECKED" : ""),_("No"),
638 _("Clicking this icon displays a list of all accessible "
639 "rooms (or folders) available.")
643 val = IconbarIsEnabled("ib_users", 1);
644 wprintf("<tr class=\"%s\"><td>"
645 "<input type=\"radio\" name=\"ib_users\" value=\"yes\" %s> %s "
646 "<input type=\"radio\" name=\"ib_users\" value=\"no\" %s> %s <br />"
647 "<input type=\"radio\" name=\"ib_users\" value=\"yeslist\" %s> %s"
649 "<img src=\"static/usermanag_48x.gif\" alt=\" \">"
654 (bar ? "even" : "odd"),
655 (val ? "CHECKED" : ""),_("Yes"),
656 (!val ? "CHECKED" : ""),_("No"),
657 ((val > 1) ? "CHECKED" : ""),_("Yes with users list"),
659 _("Clicking this icon displays a list of all users "
660 "currently logged in.")
664 val = IconbarIsEnabled("ib_chat", 1);
665 wprintf("<tr class=\"%s\"><td>"
666 "<input type=\"radio\" name=\"ib_chat\" value=\"yes\" %s> %s "
667 "<input type=\"radio\" name=\"ib_chat\" value=\"no\" %s> %s <br />"
669 "<img src=\"static/citadelchat_48x.gif\" alt=\" \">"
674 (bar ? "even" : "odd"),
675 (val ? "CHECKED" : ""),_("Yes"),
676 (!val ? "CHECKED" : ""),_("No"),
678 _("Clicking this icon enters real-time chat mode "
679 "with other users in the same room.")
684 val = IconbarIsEnabled("ib_advanced", 1);
685 wprintf("<tr class=\"%s\"><td>"
686 "<input type=\"radio\" name=\"ib_advanced\" value=\"yes\" %s> %s "
687 "<input type=\"radio\" name=\"ib_advanced\" value=\"no\" %s> %s <br />"
689 "<img src=\"static/advanpage2_48x.gif\" alt=\" \">"
694 (bar ? "even" : "odd"),
695 (val ? "CHECKED" : ""),_("Yes"),
696 (!val ? "CHECKED" : ""),_("No"),
697 _("Advanced options"),
698 _("Access to the complete menu of Citadel functions.")
703 val = IconbarIsEnabled("ib_citadel", 1);
704 wprintf("<tr class=\"%s\"><td>"
705 "<input type=\"radio\" name=\"ib_citadel\" value=\"yes\" %s> %s "
706 "<input type=\"radio\" name=\"ib_citadel\" value=\"no\" %s> %s <br />"
708 "<img border=\"0\" width=\"48\" height=\"48\" "
709 "src=\"static/citadel-logo.gif\" alt=\" \">"
714 (bar ? "even" : "odd"),
715 (val ? "CHECKED" : ""),_("Yes"),
716 (!val ? "CHECKED" : ""),_("No"),
718 _("Displays the 'Powered by Citadel' icon")
721 wprintf("</table><br />\n"
723 "<input type=\"submit\" name=\"ok_button\" value=\"%s\">"
725 "<input type=\"submit\" name=\"cancel_button\" value=\"%s\">"
731 wprintf("</form></div>\n");
736 * \brief commit the changes of an edited iconbar ????
738 void commit_iconbar(void) {
759 if (!havebstr("ok_button")) {
764 iconbar = NewStrBuf();
766 StrBufPrintf(iconbar, "ib_displayas=%d", ibstr("ib_displayas"));
767 for (i=0; i<(sizeof(boxen)/sizeof(char *)); ++i) {
769 if (!strcasecmp(BSTR(boxen[i]), "yes")) {
772 else if (!strcasecmp(BSTR(boxen[i]), "yeslist")) {
778 StrBufPrintf(buf, ",%s=%s", boxen[i], Val);
779 StrBufAppendBuf(iconbar, buf, 0);
783 set_preference("iconbar", iconbar, 1);
785 output_headers(1, 1, 2, 0, 0, 0);
786 wprintf("<div id=\"banner\">\n");
788 wprintf(_("Customize the icon bar"));
789 wprintf("</h1></div>\n");
791 wprintf("<div id=\"content\" class=\"service\">\n");
793 "<center><table border=1 bgcolor=\"#ffffff\"><tr><td>"
794 "<img src=\"static/advanpage2_48x.gif\">"
796 wprintf(_("Your icon bar has been updated. Please select any of its "
797 "choices to continue."));
798 wprintf("</td></tr></table>\n");
800 #ifdef DBG_ICONBAR_HASH
801 dbg_PrintHash(WC->IconBarSetttings, PrintInt, NULL);
806 void tmplput_iconbar(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType)
808 struct wcsession *WCC = WC;
810 if ((WCC != NULL) && (WCC->logged_in)) {
811 wprintf("<div id=\"iconbar\">");
812 do_selected_iconbar();
813 /** check for instant messages (these display in a new window) */
823 WebcitAddUrlHandler(HKEY("iconbar_ajax_menu"), do_iconbar, AJAX);
824 WebcitAddUrlHandler(HKEY("iconbar_ajax_rooms"), do_iconbar_roomlist, AJAX);
825 WebcitAddUrlHandler(HKEY("display_customize_iconbar"), display_customize_iconbar, 0);
826 WebcitAddUrlHandler(HKEY("commit_iconbar"), commit_iconbar, 0);
827 RegisterNamespace("ICONBAR", 0, 0, tmplput_iconbar, 0);