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)) {
371 "<script type=\"text/javascript\"> "
372 " new Ajax.PeriodicalUpdater('wholist', 'do_template?template=wholist_section', { method: 'get', frequency: 30 } );"
380 * \brief roomtree view of the iconbar
381 * If the user has toggled the icon bar over to a room list, here's where
382 * we generate its innerHTML...
384 void do_iconbar_roomlist(void) {
387 WC->current_iconbar = current_iconbar_roomlist;
390 * The initialized values of these variables also happen to
391 * specify the default values for users who haven't customized
392 * their iconbars. These should probably be set in a master
393 * configuration somewhere.
398 ib_displayas = IconbarIsEnabled("ib_displayas", IB_PICTEXT); /* pictures and text, pictures, text */
401 if (IconbarIsEnabled("ib_logo", 0)) {
402 if (ib_displayas != IB_TEXTONLY) {
403 wprintf("<div class=\"logo\"> <img "
404 "src=\"image&name=hello\" alt=\" \"> "
410 /** 'Powered by Citadel' logo */
411 if (IconbarIsEnabled("ib_citadel", 1) && (ib_displayas != IB_TEXTONLY)) wprintf(
412 "<div class=\"logo_citadel\"> "
413 "<a href=\"http://www.citadel.org\" "
416 "src=\"static/citadel-logo.gif\" alt=\"%s\"></a> "
418 _("Find out more about Citadel"),
422 wprintf("<ul id=\"button\">\n");
424 wprintf("<li class=\"switch\"><a href=\"javascript:switch_to_menu_buttons()\">");
425 wprintf(_("switch to menu"));
426 wprintf("</a></li>");
429 "<a href=\"termquit\" title=\"%s\" "
430 "onClick=\"return confirm('%s');\">",
435 if (ib_displayas != IB_TEXTONLY) {
436 wprintf("<img alt=\"\" "
437 "src=\"static/logoff_32x.gif\">");
439 if (ib_displayas != IB_PICONLY) {
440 wprintf(_("Log off"));
442 wprintf("</a></li>\n");
446 /** embed the room list */
447 list_all_rooms_by_floor("iconbar");
454 * \brief display a customized version of the iconbar
456 void display_customize_iconbar(void) {
465 output_headers(1, 1, 2, 0, 0, 0);
466 wprintf("<div id=\"banner\">");
468 wprintf(_("Customize the icon bar"));
469 wprintf("</h1></div>\n");
471 wprintf("<div id=\"content\" class=\"service\">\n");
473 wprintf("<div class=\"fix_scrollbar_bug\">");
475 wprintf("<form method=\"post\" action=\"commit_iconbar\">\n");
476 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
478 wprintf("<table class=\"altern\" >\n");
479 wprintf("<tr><td></td><td colspan=\"2\"><b>");
480 wprintf(_("Display icons as:"));
482 ib_displayas = IconbarIsEnabled("ib_displayas",IB_PICTEXT);
483 for (i=0; i<=2; ++i) {
484 wprintf("<input type=\"radio\" name=\"ib_displayas\" value=\"%d\"", i);
485 if (ib_displayas == i) wprintf(" CHECKED");
487 if (i == IB_PICTEXT) wprintf(_("pictures and text"));
488 if (i == IB_PICONLY) wprintf(_("pictures only"));
489 if (i == IB_TEXTONLY) wprintf(_("text only"));
494 wprintf(_("Select the icons you would like to see displayed "
495 "in the 'icon bar' menu on the left side of the "
497 wprintf("</td></tr>\n");
500 val = IconbarIsEnabled("ib_logo", 0);
501 wprintf("<tr class=\"%s\"><td>"
502 "<input type=\"radio\" name=\"ib_logo\" value=\"yes\" %s> %s "
503 "<input type=\"radio\" name=\"ib_logo\" value=\"no\" %s> %s <br />"
505 "<img src=\"image&name=hello\" width=\"48\" alt=\" \">"
510 (bar ? "even" : "odd"),
511 (val ? "CHECKED" : ""),_("Yes"),
512 (!val ? "CHECKED" : ""),_("No"),
514 _("An icon describing this site")
518 val = IconbarIsEnabled("ib_summary", 1);
519 wprintf("<tr class=\"%s\"><td>"
520 "<input type=\"radio\" name=\"ib_summary\" value=\"yes\" %s> %s "
521 "<input type=\"radio\" name=\"ib_summary\" value=\"no\" %s> %s <br />"
523 "<img src=\"static/summscreen_48x.gif\" alt=\" \">"
528 (bar ? "even" : "odd"),
529 (val ? "CHECKED" : ""),_("Yes"),
530 (!val ? "CHECKED" : ""),_("No"),
532 _("Your summary page")
536 val = IconbarIsEnabled("ib_inbox", 1);
537 wprintf("<tr class=\"%s\"><td>"
538 "<input type=\"radio\" name=\"ib_inbox\" value=\"yes\" %s> %s "
539 "<input type=\"radio\" name=\"ib_inbox\" value=\"no\" %s> %s <br />"
541 "<img src=\"static/privatemess_48x.gif\" alt=\" \">"
546 (bar ? "even" : "odd"),
547 (val ? "CHECKED" : ""),_("Yes"),
548 (!val ? "CHECKED" : ""),_("No"),
550 _("A shortcut to your email Inbox")
554 val = IconbarIsEnabled("ib_contacts", 1);
555 wprintf("<tr class=\"%s\"><td>"
556 "<input type=\"radio\" name=\"ib_contacts\" value=\"yes\" %s> %s "
557 "<input type=\"radio\" name=\"ib_contacts\" value=\"no\" %s> %s <br />"
559 "<img src=\"static/viewcontacts_48x.gif\" alt=\" \">"
564 (bar ? "even" : "odd"),
565 (val ? "CHECKED" : ""),_("Yes"),
566 (!val ? "CHECKED" : ""),_("No"),
568 _("Your personal address book")
572 val = IconbarIsEnabled("ib_notes", 1);
573 wprintf("<tr class=\"%s\"><td>"
574 "<input type=\"radio\" name=\"ib_notes\" value=\"yes\" %s> %s "
575 "<input type=\"radio\" name=\"ib_notes\" value=\"no\" %s> %s <br />"
577 "<img src=\"static/storenotes_48x.gif\" alt=\" \">"
582 (bar ? "even" : "odd"),
583 (val ? "CHECKED" : ""),_("Yes"),
584 (!val ? "CHECKED" : ""),_("No"),
586 _("Your personal notes")
590 val = IconbarIsEnabled("ib_calendar", 1);
591 wprintf("<tr class=\"%s\"><td>"
592 "<input type=\"radio\" name=\"ib_calendar\" value=\"yes\" %s> %s "
593 "<input type=\"radio\" name=\"ib_calendar\" value=\"no\" %s> %s <br />"
595 "<img src=\"static/calarea_48x.gif\" alt=\" \">"
600 (bar ? "even" : "odd"),
601 (val ? "CHECKED" : ""),_("Yes"),
602 (!val ? "CHECKED" : ""),_("No"),
604 _("A shortcut to your personal calendar")
608 val = IconbarIsEnabled("ib_tasks", 1);
609 wprintf("<tr class=\"%s\"><td>"
610 "<input type=\"radio\" name=\"ib_tasks\" value=\"yes\" %s> %s "
611 "<input type=\"radio\" name=\"ib_tasks\" value=\"no\" %s> %s <br />"
613 "<img src=\"static/taskmanag_48x.gif\" alt=\" \">"
618 (bar ? "even" : "odd"),
619 (val ? "CHECKED" : ""),_("Yes"),
620 (!val ? "CHECKED" : ""),_("No"),
622 _("A shortcut to your personal task list")
626 val = IconbarIsEnabled("ib_rooms", 1);
627 wprintf("<tr class=\"%s\"><td>"
628 "<input type=\"radio\" name=\"ib_rooms\" value=\"yes\" %s> %s "
629 "<input type=\"radio\" name=\"ib_rooms\" value=\"no\" %s> %s <br />"
631 "<img src=\"static/chatrooms_48x.gif\" alt=\" \">"
636 (bar ? "even" : "odd"),
637 (val ? "CHECKED" : ""),_("Yes"),
638 (!val ? "CHECKED" : ""),_("No"),
640 _("Clicking this icon displays a list of all accessible "
641 "rooms (or folders) available.")
645 val = IconbarIsEnabled("ib_users", 1);
646 wprintf("<tr class=\"%s\"><td>"
647 "<input type=\"radio\" name=\"ib_users\" value=\"yes\" %s> %s "
648 "<input type=\"radio\" name=\"ib_users\" value=\"no\" %s> %s <br />"
649 "<input type=\"radio\" name=\"ib_users\" value=\"yeslist\" %s> %s"
651 "<img src=\"static/usermanag_48x.gif\" alt=\" \">"
656 (bar ? "even" : "odd"),
657 (val ? "CHECKED" : ""),_("Yes"),
658 (!val ? "CHECKED" : ""),_("No"),
659 ((val > 1) ? "CHECKED" : ""),_("Yes with users list"),
661 _("Clicking this icon displays a list of all users "
662 "currently logged in.")
666 val = IconbarIsEnabled("ib_chat", 1);
667 wprintf("<tr class=\"%s\"><td>"
668 "<input type=\"radio\" name=\"ib_chat\" value=\"yes\" %s> %s "
669 "<input type=\"radio\" name=\"ib_chat\" value=\"no\" %s> %s <br />"
671 "<img src=\"static/citadelchat_48x.gif\" alt=\" \">"
676 (bar ? "even" : "odd"),
677 (val ? "CHECKED" : ""),_("Yes"),
678 (!val ? "CHECKED" : ""),_("No"),
680 _("Clicking this icon enters real-time chat mode "
681 "with other users in the same room.")
686 val = IconbarIsEnabled("ib_advanced", 1);
687 wprintf("<tr class=\"%s\"><td>"
688 "<input type=\"radio\" name=\"ib_advanced\" value=\"yes\" %s> %s "
689 "<input type=\"radio\" name=\"ib_advanced\" value=\"no\" %s> %s <br />"
691 "<img src=\"static/advanpage2_48x.gif\" alt=\" \">"
696 (bar ? "even" : "odd"),
697 (val ? "CHECKED" : ""),_("Yes"),
698 (!val ? "CHECKED" : ""),_("No"),
699 _("Advanced options"),
700 _("Access to the complete menu of Citadel functions.")
705 val = IconbarIsEnabled("ib_citadel", 1);
706 wprintf("<tr class=\"%s\"><td>"
707 "<input type=\"radio\" name=\"ib_citadel\" value=\"yes\" %s> %s "
708 "<input type=\"radio\" name=\"ib_citadel\" value=\"no\" %s> %s <br />"
710 "<img border=\"0\" width=\"48\" height=\"48\" "
711 "src=\"static/citadel-logo.gif\" alt=\" \">"
716 (bar ? "even" : "odd"),
717 (val ? "CHECKED" : ""),_("Yes"),
718 (!val ? "CHECKED" : ""),_("No"),
720 _("Displays the 'Powered by Citadel' icon")
723 wprintf("</table><br />\n"
725 "<input type=\"submit\" name=\"ok_button\" value=\"%s\">"
727 "<input type=\"submit\" name=\"cancel_button\" value=\"%s\">"
733 wprintf("</form></div>\n");
738 * \brief commit the changes of an edited iconbar ????
740 void commit_iconbar(void) {
761 if (!havebstr("ok_button")) {
766 iconbar = NewStrBuf();
768 StrBufPrintf(iconbar, "ib_displayas=%d", ibstr("ib_displayas"));
769 for (i=0; i<(sizeof(boxen)/sizeof(char *)); ++i) {
771 if (!strcasecmp(BSTR(boxen[i]), "yes")) {
774 else if (!strcasecmp(BSTR(boxen[i]), "yeslist")) {
780 StrBufPrintf(buf, ",%s=%s", boxen[i], Val);
781 StrBufAppendBuf(iconbar, buf, 0);
785 set_preference("iconbar", iconbar, 1);
787 output_headers(1, 1, 2, 0, 0, 0);
788 wprintf("<div id=\"banner\">\n");
790 wprintf(_("Customize the icon bar"));
791 wprintf("</h1></div>\n");
793 wprintf("<div id=\"content\" class=\"service\">\n");
795 "<center><table border=1 bgcolor=\"#ffffff\"><tr><td>"
796 "<img src=\"static/advanpage2_48x.gif\">"
798 wprintf(_("Your icon bar has been updated. Please select any of its "
799 "choices to continue."));
800 wprintf("</td></tr></table>\n");
802 #ifdef DBG_ICONBAR_HASH
803 dbg_PrintHash(WC->IconBarSetttings, PrintInt, NULL);
808 void tmplput_iconbar(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType)
812 if ((WCC != NULL) && (WCC->logged_in)) {
813 wprintf("<div id=\"iconbar\">");
814 do_selected_iconbar();
815 /** check for instant messages (these display in a new window) */
825 WebcitAddUrlHandler(HKEY("iconbar_ajax_menu"), do_iconbar, AJAX);
826 WebcitAddUrlHandler(HKEY("iconbar_ajax_rooms"), do_iconbar_roomlist, AJAX);
827 WebcitAddUrlHandler(HKEY("display_customize_iconbar"), display_customize_iconbar, 0);
828 WebcitAddUrlHandler(HKEY("commit_iconbar"), commit_iconbar, 0);
829 RegisterNamespace("ICONBAR", 0, 0, tmplput_iconbar, 0);