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 * Render the left side iconbar
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)
57 StrBuf *iconbar = NULL;
65 WCC->current_iconbar = current_iconbar_menu;
66 if (WCC->IconBarSetttings == NULL)
67 WCC->IconBarSetttings = NewHash(1, NULL);
69 * The initialized values of these variables also happen to
70 * specify the default values for users who haven't customized
71 * their iconbars. These should probably be set in a master
72 * configuration somewhere.
75 if (get_preference("iconbar", &iconbar)) {
76 nTokens = StrBufNum_tokens(iconbar, ',');
77 for (i=0; i<nTokens; ++i) {
78 StrBufExtract_token(buf, iconbar, i, ',');
79 StrBufExtract_token(key, buf, 0, '=');
80 val = StrBufExtract_long(buf, 1, '=');
81 Put(WCC->IconBarSetttings,
82 ChrPtr(key), StrLength(key),
83 (void*)val, DontDeleteThis);
87 #ifdef DBG_ICONBAR_HASH
88 dbg_PrintHash(WCC->IconBarSetttings, PrintInt, NULL);
97 * \brief draw the icon bar???
99 void do_iconbar(void) {
100 int ib_displayas = IB_PICTEXT; /**< pictures and text, pictures, text */
103 ib_displayas = IconbarIsEnabled("ib_displayas", IB_PICTEXT);
106 if (IconbarIsEnabled("ib_logo", 0)) {
107 if (ib_displayas != IB_TEXTONLY) {
108 wprintf("<div class=\"logo\"> <img "
109 "src=\"image&name=hello\" alt=\" \"> "
116 /** 'Powered by Citadel' logo */
117 if (IconbarIsEnabled("ib_citadel", 1) && (ib_displayas != IB_TEXTONLY)) wprintf(
118 "<div class=\"logo_citadel\"> "
119 "<a href=\"http://www.citadel.org\" "
122 "src=\"static/citadel-logo.gif\" alt=\"%s\"></a> "
124 _("Find out more about Citadel"),
128 wprintf("<ul id=\"button\">\n");
130 wprintf("<li class=\"switch\"><a href=\"javascript:switch_to_room_list()\">");
131 wprintf(_("switch to room list"));
132 wprintf("</a></li>");
134 /** Summary page icon */
135 if (IconbarIsEnabled("ib_summary", 1)) {
136 wprintf("<li><a href=\"summary\" "
138 ">", _("Your summary page")
140 if (ib_displayas != IB_TEXTONLY) {
141 wprintf("<img alt=\"\" "
142 "src=\"static/summscreen_32x.gif\">");
144 if (ib_displayas != IB_PICONLY) {
145 wprintf(_("Summary"));
147 wprintf("</a></li>\n");
151 if (IconbarIsEnabled("ib_inbox", 1)) {
153 "<a href=\"dotgoto?room=_MAIL_\" "
156 _("Go to your email inbox")
158 if (ib_displayas != IB_TEXTONLY) {
159 wprintf("<img alt=\"\" "
160 "src=\"static/privatemess_32x.gif\">");
162 if (ib_displayas != IB_PICONLY) {
164 if (WC->new_mail != WC->remember_new_mail) {
166 if (WC->new_mail > 0) {
167 wprintf(" <b>(%d)</b>", WC->new_mail);
170 WC->remember_new_mail = WC->new_mail;
173 wprintf("</a></li>\n");
177 if (IconbarIsEnabled("ib_calendar", 1)) {
179 "<a href=\"dotgoto?room=_CALENDAR_\" "
182 _("Go to your personal calendar")
184 if (ib_displayas != IB_TEXTONLY) {
185 wprintf("<img alt=\"\" "
186 "src=\"static/calarea_32x.gif\">");
188 if (ib_displayas != IB_PICONLY) {
189 wprintf(_("Calendar"));
191 wprintf("</a></li>\n");
195 if (IconbarIsEnabled("ib_contacts", 1)) {
197 "<a href=\"dotgoto?room=_CONTACTS_\" "
200 _("Go to your personal address book")
202 if (ib_displayas != IB_TEXTONLY) {
203 wprintf("<img alt=\"\" "
204 "src=\"static/viewcontacts_32x.gif\">");
206 if (ib_displayas != IB_PICONLY) {
207 wprintf(_("Contacts"));
209 wprintf("</a></li>\n");
213 if (IconbarIsEnabled("ib_notes", 1)) {
215 "<a href=\"dotgoto?room=_NOTES_\" "
218 _("Go to your personal notes")
220 if (ib_displayas != IB_TEXTONLY) {
221 wprintf("<img alt=\"\" "
222 "src=\"static/storenotes_32x.gif\">");
224 if (ib_displayas != IB_PICONLY) {
227 wprintf("</a></li>\n");
231 if (IconbarIsEnabled("ib_tasks", 1)) {
233 "<a href=\"dotgoto?room=_TASKS_\" "
236 _("Go to your personal task list")
238 if (ib_displayas != IB_TEXTONLY) {
239 wprintf("<img alt=\"\" "
240 "src=\"static/taskmanag_32x.gif\">");
242 if (ib_displayas != IB_PICONLY) {
245 wprintf("</a></li>\n");
249 if (IconbarIsEnabled("ib_rooms", 1)) {
251 "<a href=\"knrooms\" title=\"%s\" >",
252 _("List all of your accessible rooms")
254 if (ib_displayas != IB_TEXTONLY) {
255 wprintf("<img alt=\"\" "
256 "src=\"static/chatrooms_32x.gif\">");
258 if (ib_displayas != IB_PICONLY) {
261 wprintf("</a></li>\n");
265 if (IconbarIsEnabled("ib_users", 1)) {
267 "<a href=\"do_template?template=who\" title=\"%s\" "
269 _("See who is online right now")
271 if (ib_displayas != IB_TEXTONLY) {
272 wprintf("<img alt=\"\" "
273 "src=\"static/usermanag_32x.gif\">");
275 if (ib_displayas != IB_PICONLY) {
276 wprintf(_("Who is online?"));
281 if (IconbarIsEnabled("ib_users", 0)) {
282 wprintf("<ul id=\"wholist\">");
283 wprintf("</ul></li>\n");
288 if (IconbarIsEnabled("ib_chat", 1)) {
290 "<a href=\"#\" onClick=\"window.open('chat', "
291 "'ctdl_chat_window', "
292 "'toolbar=no,location=no,directories=no,copyhistory=no,"
293 "status=no,scrollbars=yes,resizable=yes');\""
296 if (ib_displayas != IB_TEXTONLY) {
297 wprintf("<img alt=\"\" "
298 "src=\"static/citadelchat_32x.gif\">");
300 if (ib_displayas != IB_PICONLY) {
303 wprintf("</a></li>\n");
306 /** Advanced Options icon */
307 if (IconbarIsEnabled("ib_advanced", 1)) {
309 "<a href=\"do_template?template=display_main_menu\" "
312 _("Advanced Options Menu: Advanced Room commands, Account Info, and Chat")
314 if (ib_displayas != IB_TEXTONLY) {
315 wprintf("<img alt=\"\" "
316 "src=\"static/advanpage2_32x.gif\">");
318 if (ib_displayas != IB_PICONLY) {
319 wprintf(_("Advanced"));
321 wprintf("</a></li>\n");
324 if ((WC->axlevel >= 6) || (WC->is_room_aide)) {
326 "<a href=\"do_template?template=display_aide_menu\" "
329 _("Room and system administration functions")
331 if (ib_displayas != IB_TEXTONLY) {
332 wprintf("<img alt=\"\" "
333 "src=\"static/advanpage2_32x.gif\">");
335 if (ib_displayas != IB_PICONLY) {
336 wprintf(_("Administration"));
338 wprintf("</a></li>\n");
342 "<a href=\"termquit\" title=\"%s\" "
343 "onClick=\"return confirm('%s');\">",
348 if (ib_displayas != IB_TEXTONLY) {
349 wprintf("<img alt=\"\" "
350 "src=\"static/logoff_32x.gif\">");
352 if (ib_displayas != IB_PICONLY) {
353 wprintf(_("Log off"));
355 wprintf("</a></li>\n");
358 "<li class=\"switch\">"
359 "<a href=\"display_customize_iconbar\" "
363 _("Customize this menu"),
364 _("customize this menu")
369 if (IconbarIsEnabled("ib_users", 0) == 2) {
370 StrBufAppendPrintf(WC->trailing_javascript,
371 "new Ajax.PeriodicalUpdater('wholist', 'do_template?template=wholist_section', "
372 "{ method: 'get', frequency: 30 } ); \n"
379 * \brief roomtree view of the iconbar
380 * If the user has toggled the icon bar over to a room list, here's where
381 * we generate its innerHTML...
383 void do_iconbar_roomlist(void) {
386 WC->current_iconbar = current_iconbar_roomlist;
389 * The initialized values of these variables also happen to
390 * specify the default values for users who haven't customized
391 * their iconbars. These should probably be set in a master
392 * configuration somewhere.
397 ib_displayas = IconbarIsEnabled("ib_displayas", IB_PICTEXT); /* pictures and text, pictures, text */
400 if (IconbarIsEnabled("ib_logo", 0)) {
401 if (ib_displayas != IB_TEXTONLY) {
402 wprintf("<div class=\"logo\"> <img "
403 "src=\"image&name=hello\" alt=\" \"> "
409 /** 'Powered by Citadel' logo */
410 if (IconbarIsEnabled("ib_citadel", 1) && (ib_displayas != IB_TEXTONLY)) wprintf(
411 "<div class=\"logo_citadel\"> "
412 "<a href=\"http://www.citadel.org\" "
415 "src=\"static/citadel-logo.gif\" alt=\"%s\"></a> "
417 _("Find out more about Citadel"),
421 wprintf("<ul id=\"button\">\n");
423 wprintf("<li class=\"switch\"><a href=\"javascript:switch_to_menu_buttons()\">");
424 wprintf(_("switch to menu"));
425 wprintf("</a></li>");
428 "<a href=\"termquit\" title=\"%s\" "
429 "onClick=\"return confirm('%s');\">",
434 if (ib_displayas != IB_TEXTONLY) {
435 wprintf("<img alt=\"\" "
436 "src=\"static/logoff_32x.gif\">");
438 if (ib_displayas != IB_PICONLY) {
439 wprintf(_("Log off"));
441 wprintf("</a></li>\n");
445 /** embed the room list */
446 list_all_rooms_by_floor("iconbar");
453 * \brief display a customized version of the iconbar
455 void display_customize_iconbar(void) {
464 output_headers(1, 1, 2, 0, 0, 0);
465 wprintf("<div id=\"banner\">");
467 wprintf(_("Customize the icon bar"));
468 wprintf("</h1></div>\n");
470 wprintf("<div id=\"content\" class=\"service\">\n");
472 wprintf("<div class=\"fix_scrollbar_bug\">");
474 wprintf("<form method=\"post\" action=\"commit_iconbar\">\n");
475 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
477 wprintf("<table class=\"altern\" >\n");
478 wprintf("<tr><td></td><td colspan=\"2\"><b>");
479 wprintf(_("Display icons as:"));
481 ib_displayas = IconbarIsEnabled("ib_displayas",IB_PICTEXT);
482 for (i=0; i<=2; ++i) {
483 wprintf("<input type=\"radio\" name=\"ib_displayas\" value=\"%d\"", i);
484 if (ib_displayas == i) wprintf(" CHECKED");
486 if (i == IB_PICTEXT) wprintf(_("pictures and text"));
487 if (i == IB_PICONLY) wprintf(_("pictures only"));
488 if (i == IB_TEXTONLY) wprintf(_("text only"));
493 wprintf(_("Select the icons you would like to see displayed "
494 "in the 'icon bar' menu on the left side of the "
496 wprintf("</td></tr>\n");
499 val = IconbarIsEnabled("ib_logo", 0);
500 wprintf("<tr class=\"%s\"><td>"
501 "<input type=\"radio\" name=\"ib_logo\" value=\"yes\" %s> %s "
502 "<input type=\"radio\" name=\"ib_logo\" value=\"no\" %s> %s <br />"
504 "<img src=\"image&name=hello\" width=\"48\" alt=\" \">"
509 (bar ? "even" : "odd"),
510 (val ? "CHECKED" : ""),_("Yes"),
511 (!val ? "CHECKED" : ""),_("No"),
513 _("An icon describing this site")
517 val = IconbarIsEnabled("ib_summary", 1);
518 wprintf("<tr class=\"%s\"><td>"
519 "<input type=\"radio\" name=\"ib_summary\" value=\"yes\" %s> %s "
520 "<input type=\"radio\" name=\"ib_summary\" value=\"no\" %s> %s <br />"
522 "<img src=\"static/summscreen_48x.gif\" alt=\" \">"
527 (bar ? "even" : "odd"),
528 (val ? "CHECKED" : ""),_("Yes"),
529 (!val ? "CHECKED" : ""),_("No"),
531 _("Your summary page")
535 val = IconbarIsEnabled("ib_inbox", 1);
536 wprintf("<tr class=\"%s\"><td>"
537 "<input type=\"radio\" name=\"ib_inbox\" value=\"yes\" %s> %s "
538 "<input type=\"radio\" name=\"ib_inbox\" value=\"no\" %s> %s <br />"
540 "<img src=\"static/privatemess_48x.gif\" alt=\" \">"
545 (bar ? "even" : "odd"),
546 (val ? "CHECKED" : ""),_("Yes"),
547 (!val ? "CHECKED" : ""),_("No"),
549 _("A shortcut to your email Inbox")
553 val = IconbarIsEnabled("ib_contacts", 1);
554 wprintf("<tr class=\"%s\"><td>"
555 "<input type=\"radio\" name=\"ib_contacts\" value=\"yes\" %s> %s "
556 "<input type=\"radio\" name=\"ib_contacts\" value=\"no\" %s> %s <br />"
558 "<img src=\"static/viewcontacts_48x.gif\" alt=\" \">"
563 (bar ? "even" : "odd"),
564 (val ? "CHECKED" : ""),_("Yes"),
565 (!val ? "CHECKED" : ""),_("No"),
567 _("Your personal address book")
571 val = IconbarIsEnabled("ib_notes", 1);
572 wprintf("<tr class=\"%s\"><td>"
573 "<input type=\"radio\" name=\"ib_notes\" value=\"yes\" %s> %s "
574 "<input type=\"radio\" name=\"ib_notes\" value=\"no\" %s> %s <br />"
576 "<img src=\"static/storenotes_48x.gif\" alt=\" \">"
581 (bar ? "even" : "odd"),
582 (val ? "CHECKED" : ""),_("Yes"),
583 (!val ? "CHECKED" : ""),_("No"),
585 _("Your personal notes")
589 val = IconbarIsEnabled("ib_calendar", 1);
590 wprintf("<tr class=\"%s\"><td>"
591 "<input type=\"radio\" name=\"ib_calendar\" value=\"yes\" %s> %s "
592 "<input type=\"radio\" name=\"ib_calendar\" value=\"no\" %s> %s <br />"
594 "<img src=\"static/calarea_48x.gif\" alt=\" \">"
599 (bar ? "even" : "odd"),
600 (val ? "CHECKED" : ""),_("Yes"),
601 (!val ? "CHECKED" : ""),_("No"),
603 _("A shortcut to your personal calendar")
607 val = IconbarIsEnabled("ib_tasks", 1);
608 wprintf("<tr class=\"%s\"><td>"
609 "<input type=\"radio\" name=\"ib_tasks\" value=\"yes\" %s> %s "
610 "<input type=\"radio\" name=\"ib_tasks\" value=\"no\" %s> %s <br />"
612 "<img src=\"static/taskmanag_48x.gif\" alt=\" \">"
617 (bar ? "even" : "odd"),
618 (val ? "CHECKED" : ""),_("Yes"),
619 (!val ? "CHECKED" : ""),_("No"),
621 _("A shortcut to your personal task list")
625 val = IconbarIsEnabled("ib_rooms", 1);
626 wprintf("<tr class=\"%s\"><td>"
627 "<input type=\"radio\" name=\"ib_rooms\" value=\"yes\" %s> %s "
628 "<input type=\"radio\" name=\"ib_rooms\" value=\"no\" %s> %s <br />"
630 "<img src=\"static/chatrooms_48x.gif\" alt=\" \">"
635 (bar ? "even" : "odd"),
636 (val ? "CHECKED" : ""),_("Yes"),
637 (!val ? "CHECKED" : ""),_("No"),
639 _("Clicking this icon displays a list of all accessible "
640 "rooms (or folders) available.")
644 val = IconbarIsEnabled("ib_users", 1);
645 wprintf("<tr class=\"%s\"><td>"
646 "<input type=\"radio\" name=\"ib_users\" value=\"yes\" %s> %s "
647 "<input type=\"radio\" name=\"ib_users\" value=\"no\" %s> %s <br />"
648 "<input type=\"radio\" name=\"ib_users\" value=\"yeslist\" %s> %s"
650 "<img src=\"static/usermanag_48x.gif\" alt=\" \">"
655 (bar ? "even" : "odd"),
656 (val ? "CHECKED" : ""),_("Yes"),
657 (!val ? "CHECKED" : ""),_("No"),
658 ((val > 1) ? "CHECKED" : ""),_("Yes with users list"),
660 _("Clicking this icon displays a list of all users "
661 "currently logged in.")
665 val = IconbarIsEnabled("ib_chat", 1);
666 wprintf("<tr class=\"%s\"><td>"
667 "<input type=\"radio\" name=\"ib_chat\" value=\"yes\" %s> %s "
668 "<input type=\"radio\" name=\"ib_chat\" value=\"no\" %s> %s <br />"
670 "<img src=\"static/citadelchat_48x.gif\" alt=\" \">"
675 (bar ? "even" : "odd"),
676 (val ? "CHECKED" : ""),_("Yes"),
677 (!val ? "CHECKED" : ""),_("No"),
679 _("Clicking this icon enters real-time chat mode "
680 "with other users in the same room.")
685 val = IconbarIsEnabled("ib_advanced", 1);
686 wprintf("<tr class=\"%s\"><td>"
687 "<input type=\"radio\" name=\"ib_advanced\" value=\"yes\" %s> %s "
688 "<input type=\"radio\" name=\"ib_advanced\" value=\"no\" %s> %s <br />"
690 "<img src=\"static/advanpage2_48x.gif\" alt=\" \">"
695 (bar ? "even" : "odd"),
696 (val ? "CHECKED" : ""),_("Yes"),
697 (!val ? "CHECKED" : ""),_("No"),
698 _("Advanced options"),
699 _("Access to the complete menu of Citadel functions.")
704 val = IconbarIsEnabled("ib_citadel", 1);
705 wprintf("<tr class=\"%s\"><td>"
706 "<input type=\"radio\" name=\"ib_citadel\" value=\"yes\" %s> %s "
707 "<input type=\"radio\" name=\"ib_citadel\" value=\"no\" %s> %s <br />"
709 "<img border=\"0\" width=\"48\" height=\"48\" "
710 "src=\"static/citadel-logo.gif\" alt=\" \">"
715 (bar ? "even" : "odd"),
716 (val ? "CHECKED" : ""),_("Yes"),
717 (!val ? "CHECKED" : ""),_("No"),
719 _("Displays the 'Powered by Citadel' icon")
722 wprintf("</table><br />\n"
724 "<input type=\"submit\" name=\"ok_button\" value=\"%s\">"
726 "<input type=\"submit\" name=\"cancel_button\" value=\"%s\">"
732 wprintf("</form></div>\n");
737 * \brief commit the changes of an edited iconbar ????
739 void commit_iconbar(void) {
760 if (!havebstr("ok_button")) {
765 iconbar = NewStrBuf();
767 StrBufPrintf(iconbar, "ib_displayas=%d", ibstr("ib_displayas"));
768 for (i=0; i<(sizeof(boxen)/sizeof(char *)); ++i) {
770 if (!strcasecmp(BSTR(boxen[i]), "yes")) {
773 else if (!strcasecmp(BSTR(boxen[i]), "yeslist")) {
779 StrBufPrintf(buf, ",%s=%s", boxen[i], Val);
780 StrBufAppendBuf(iconbar, buf, 0);
784 set_preference("iconbar", iconbar, 1);
786 output_headers(1, 1, 2, 0, 0, 0);
787 wprintf("<div id=\"banner\">\n");
789 wprintf(_("Customize the icon bar"));
790 wprintf("</h1></div>\n");
792 wprintf("<div id=\"content\" class=\"service\">\n");
794 "<center><table border=1 bgcolor=\"#ffffff\"><tr><td>"
795 "<img src=\"static/advanpage2_48x.gif\">"
797 wprintf(_("Your icon bar has been updated. Please select any of its "
798 "choices to continue."));
799 wprintf("</td></tr></table>\n");
801 #ifdef DBG_ICONBAR_HASH
802 dbg_PrintHash(WC->IconBarSetttings, PrintInt, NULL);
807 void tmplput_iconbar(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType)
811 if ((WCC != NULL) && (WCC->logged_in)) {
812 wprintf("<div id=\"iconbar\">");
813 do_selected_iconbar();
814 /** check for instant messages (these display in a new window) */
824 WebcitAddUrlHandler(HKEY("iconbar_ajax_menu"), do_iconbar, AJAX);
825 WebcitAddUrlHandler(HKEY("iconbar_ajax_rooms"), do_iconbar_roomlist, AJAX);
826 WebcitAddUrlHandler(HKEY("display_customize_iconbar"), display_customize_iconbar, 0);
827 WebcitAddUrlHandler(HKEY("commit_iconbar"), commit_iconbar, 0);
828 RegisterNamespace("ICONBAR", 0, 0, tmplput_iconbar, 0);