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 */
15 void DontDeleteThis(void *Data){}
17 #define IconbarIsEnabled(a, b) IconbarIsENABLED(a, sizeof(a) - 1, b)
19 long IconbarIsENABLED(const char *key, size_t keylen, long defval)
22 if (GetHash(WC->IconBarSettings, key, keylen,
29 #ifdef DBG_ICONBAR_HASH
31 inline const char *PrintInt(void *Prefstr)
33 snprintf(nbuf, sizeof(nbuf), "%ld", (long)Prefstr);
38 /** Produces a stylesheet which hides any iconbar icons the user does not want */
39 void doUserIconStylesheet(void) {
47 output_custom_content_header("text/css");
48 hprintf("Cache-Control: private\r\n");
51 pos = GetNewHashPos(WC->IconBarSettings, 0);
52 while(GetNextHashPos(WC->IconBarSettings, pos, &HKLen, &key, &Data)) {
55 && strncasecmp("ib_displayas",key,12)
56 && strncasecmp("ib_logoff", key, 9)) {
57 // Don't shoot me for this
58 wprintf("#%s { display: none !important; }\r\n",key);
59 } else if (!strncasecmp("ib_users",key, 8) && value != 2) {
60 wprintf("#online_users { display: none; !important } \r\n");
66 int ConditionalIsActiveStylesheet(StrBuf *Target, WCTemplputParams *TP) {
67 long testFor = TP->Tokens->Params[3]->lvalue;
68 int ib_displayas = IconbarIsEnabled("ib_displayas",IB_PICTEXT);
69 return (testFor == ib_displayas);
72 void LoadIconSettings(void)
75 StrBuf *iconbar = NULL;
83 if (WCC->IconBarSettings == NULL)
84 WCC->IconBarSettings = NewHash(1, NULL);
86 * The initialized values of these variables also happen to
87 * specify the default values for users who haven't customized
88 * their iconbars. These should probably be set in a master
89 * configuration somewhere.
92 if (get_preference("iconbar", &iconbar)) {
93 nTokens = StrBufNum_tokens(iconbar, ',');
94 for (i=0; i<nTokens; ++i) {
95 StrBufExtract_token(buf, iconbar, i, ',');
96 StrBufExtract_token(key, buf, 0, '=');
97 val = StrBufExtract_long(buf, 1, '=');
98 Put(WCC->IconBarSettings,
99 ChrPtr(key), StrLength(key),
100 (void*)val, DontDeleteThis);
104 #ifdef DBG_ICONBAR_HASH
105 dbg_PrintHash(WCC->IconBarSetttings, PrintInt, NULL);
113 * \brief display a customized version of the iconbar
115 void display_customize_iconbar(void) {
124 output_headers(1, 1, 2, 0, 0, 0);
125 wprintf("<div id=\"banner\">");
127 wprintf(_("Customize the icon bar"));
128 wprintf("</h1></div>\n");
130 wprintf("<div id=\"content\" class=\"service\">\n");
132 wprintf("<div class=\"fix_scrollbar_bug\">");
134 wprintf("<form method=\"post\" action=\"commit_iconbar\">\n");
135 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
137 wprintf("<table class=\"altern\" >\n");
138 wprintf("<tr><td></td><td colspan=\"2\"><b>");
139 wprintf(_("Display icons as:"));
141 ib_displayas = IconbarIsEnabled("ib_displayas",IB_PICTEXT);
142 for (i=0; i<=2; ++i) {
143 wprintf("<input type=\"radio\" name=\"ib_displayas\" value=\"%d\"", i);
144 if (ib_displayas == i) wprintf(" CHECKED");
146 if (i == IB_PICTEXT) wprintf(_("pictures and text"));
147 if (i == IB_PICONLY) wprintf(_("pictures only"));
148 if (i == IB_TEXTONLY) wprintf(_("text only"));
153 wprintf(_("Select the icons you would like to see displayed "
154 "in the 'icon bar' menu on the left side of the "
156 wprintf("</td></tr>\n");
159 val = IconbarIsEnabled("ib_logo", 0);
160 wprintf("<tr class=\"%s\"><td>"
161 "<input type=\"radio\" name=\"ib_logo\" value=\"yes\" %s> %s "
162 "<input type=\"radio\" name=\"ib_logo\" value=\"no\" %s> %s <br />"
164 "<img src=\"image&name=hello\" width=\"48\" alt=\" \">"
169 (bar ? "even" : "odd"),
170 (val ? "CHECKED" : ""),_("Yes"),
171 (!val ? "CHECKED" : ""),_("No"),
173 _("An icon describing this site")
177 val = IconbarIsEnabled("ib_summary", 1);
178 wprintf("<tr class=\"%s\"><td>"
179 "<input type=\"radio\" name=\"ib_summary\" value=\"yes\" %s> %s "
180 "<input type=\"radio\" name=\"ib_summary\" value=\"no\" %s> %s <br />"
182 "<img src=\"static/summscreen_48x.gif\" alt=\" \">"
187 (bar ? "even" : "odd"),
188 (val ? "CHECKED" : ""),_("Yes"),
189 (!val ? "CHECKED" : ""),_("No"),
191 _("Your summary page")
195 val = IconbarIsEnabled("ib_inbox", 1);
196 wprintf("<tr class=\"%s\"><td>"
197 "<input type=\"radio\" name=\"ib_inbox\" value=\"yes\" %s> %s "
198 "<input type=\"radio\" name=\"ib_inbox\" value=\"no\" %s> %s <br />"
200 "<img src=\"static/privatemess_48x.gif\" alt=\" \">"
205 (bar ? "even" : "odd"),
206 (val ? "CHECKED" : ""),_("Yes"),
207 (!val ? "CHECKED" : ""),_("No"),
209 _("A shortcut to your email Inbox")
213 val = IconbarIsEnabled("ib_contacts", 1);
214 wprintf("<tr class=\"%s\"><td>"
215 "<input type=\"radio\" name=\"ib_contacts\" value=\"yes\" %s> %s "
216 "<input type=\"radio\" name=\"ib_contacts\" value=\"no\" %s> %s <br />"
218 "<img src=\"static/viewcontacts_48x.gif\" alt=\" \">"
223 (bar ? "even" : "odd"),
224 (val ? "CHECKED" : ""),_("Yes"),
225 (!val ? "CHECKED" : ""),_("No"),
227 _("Your personal address book")
231 val = IconbarIsEnabled("ib_notes", 1);
232 wprintf("<tr class=\"%s\"><td>"
233 "<input type=\"radio\" name=\"ib_notes\" value=\"yes\" %s> %s "
234 "<input type=\"radio\" name=\"ib_notes\" value=\"no\" %s> %s <br />"
236 "<img src=\"static/storenotes_48x.gif\" alt=\" \">"
241 (bar ? "even" : "odd"),
242 (val ? "CHECKED" : ""),_("Yes"),
243 (!val ? "CHECKED" : ""),_("No"),
245 _("Your personal notes")
249 val = IconbarIsEnabled("ib_calendar", 1);
250 wprintf("<tr class=\"%s\"><td>"
251 "<input type=\"radio\" name=\"ib_calendar\" value=\"yes\" %s> %s "
252 "<input type=\"radio\" name=\"ib_calendar\" value=\"no\" %s> %s <br />"
254 "<img src=\"static/calarea_48x.gif\" alt=\" \">"
259 (bar ? "even" : "odd"),
260 (val ? "CHECKED" : ""),_("Yes"),
261 (!val ? "CHECKED" : ""),_("No"),
263 _("A shortcut to your personal calendar")
267 val = IconbarIsEnabled("ib_tasks", 1);
268 wprintf("<tr class=\"%s\"><td>"
269 "<input type=\"radio\" name=\"ib_tasks\" value=\"yes\" %s> %s "
270 "<input type=\"radio\" name=\"ib_tasks\" value=\"no\" %s> %s <br />"
272 "<img src=\"static/taskmanag_48x.gif\" alt=\" \">"
277 (bar ? "even" : "odd"),
278 (val ? "CHECKED" : ""),_("Yes"),
279 (!val ? "CHECKED" : ""),_("No"),
281 _("A shortcut to your personal task list")
285 val = IconbarIsEnabled("ib_rooms", 1);
286 wprintf("<tr class=\"%s\"><td>"
287 "<input type=\"radio\" name=\"ib_rooms\" value=\"yes\" %s> %s "
288 "<input type=\"radio\" name=\"ib_rooms\" value=\"no\" %s> %s <br />"
290 "<img src=\"static/chatrooms_48x.gif\" alt=\" \">"
295 (bar ? "even" : "odd"),
296 (val ? "CHECKED" : ""),_("Yes"),
297 (!val ? "CHECKED" : ""),_("No"),
299 _("Clicking this icon displays a list of all accessible "
300 "rooms (or folders) available.")
304 val = IconbarIsEnabled("ib_users", 1);
305 wprintf("<tr class=\"%s\"><td>"
306 "<input type=\"radio\" name=\"ib_users\" value=\"yes\" %s> %s "
307 "<input type=\"radio\" name=\"ib_users\" value=\"no\" %s> %s <br />"
308 "<input type=\"radio\" name=\"ib_users\" value=\"yeslist\" %s> %s"
310 "<img src=\"static/usermanag_48x.gif\" alt=\" \">"
315 (bar ? "even" : "odd"),
316 (val ? "CHECKED" : ""),_("Yes"),
317 (!val ? "CHECKED" : ""),_("No"),
318 ((val > 1) ? "CHECKED" : ""),_("Yes with users list"),
320 _("Clicking this icon displays a list of all users "
321 "currently logged in.")
325 val = IconbarIsEnabled("ib_chat", 1);
326 wprintf("<tr class=\"%s\"><td>"
327 "<input type=\"radio\" name=\"ib_chat\" value=\"yes\" %s> %s "
328 "<input type=\"radio\" name=\"ib_chat\" value=\"no\" %s> %s <br />"
330 "<img src=\"static/citadelchat_48x.gif\" alt=\" \">"
335 (bar ? "even" : "odd"),
336 (val ? "CHECKED" : ""),_("Yes"),
337 (!val ? "CHECKED" : ""),_("No"),
339 _("Clicking this icon enters real-time chat mode "
340 "with other users in the same room.")
345 val = IconbarIsEnabled("ib_advanced", 1);
346 wprintf("<tr class=\"%s\"><td>"
347 "<input type=\"radio\" name=\"ib_advanced\" value=\"yes\" %s> %s "
348 "<input type=\"radio\" name=\"ib_advanced\" value=\"no\" %s> %s <br />"
350 "<img src=\"static/advanpage2_48x.gif\" alt=\" \">"
355 (bar ? "even" : "odd"),
356 (val ? "CHECKED" : ""),_("Yes"),
357 (!val ? "CHECKED" : ""),_("No"),
358 _("Advanced options"),
359 _("Access to the complete menu of Citadel functions.")
364 val = IconbarIsEnabled("ib_citadel", 1);
365 wprintf("<tr class=\"%s\"><td>"
366 "<input type=\"radio\" name=\"ib_citadel\" value=\"yes\" %s> %s "
367 "<input type=\"radio\" name=\"ib_citadel\" value=\"no\" %s> %s <br />"
369 "<img border=\"0\" width=\"48\" height=\"48\" "
370 "src=\"static/citadel-logo.gif\" alt=\" \">"
375 (bar ? "even" : "odd"),
376 (val ? "CHECKED" : ""),_("Yes"),
377 (!val ? "CHECKED" : ""),_("No"),
379 _("Displays the 'Powered by Citadel' icon")
382 wprintf("</table><br />\n"
384 "<input type=\"submit\" name=\"ok_button\" value=\"%s\">"
386 "<input type=\"submit\" name=\"cancel_button\" value=\"%s\">"
392 wprintf("</form></div>\n");
397 * \brief commit the changes of an edited iconbar ????
399 void commit_iconbar(void) {
420 if (!havebstr("ok_button")) {
425 iconbar = NewStrBuf();
427 StrBufPrintf(iconbar, "ib_displayas=%d", ibstr("ib_displayas"));
428 for (i=0; i<(sizeof(boxen)/sizeof(char *)); ++i) {
430 if (!strcasecmp(BSTR(boxen[i]), "yes")) {
433 else if (!strcasecmp(BSTR(boxen[i]), "yeslist")) {
439 StrBufPrintf(buf, ",%s=%s", boxen[i], Val);
440 StrBufAppendBuf(iconbar, buf, 0);
444 set_preference("iconbar", iconbar, 1);
446 output_headers(1, 1, 2, 0, 0, 0);
448 wprintf("<div id=\"banner\">\n");
450 wprintf(_("Customize the icon bar"));
451 wprintf("</h1></div>\n");
453 wprintf("<div id=\"content\" class=\"service\">\n");
455 "<center><table border=1 bgcolor=\"#ffffff\"><tr><td>"
456 "<img src=\"static/advanpage2_48x.gif\">"
458 wprintf(_("Your icon bar has been updated. Please select any of its "
459 "choices to continue.<br/><span style=\"font-weight: bold;\">You may need to force refresh (SHIFT-F5) in order for changes to take effect</span>"));
460 wprintf("</td></tr></table>\n");
462 #ifdef DBG_ICONBAR_HASH
463 dbg_PrintHash(WC->IconBarSetttings, PrintInt, NULL);
468 void tmplput_iconbar(StrBuf *Target, WCTemplputParams *TP)
472 if ((WCC != NULL) && (WCC->logged_in)) {
473 DoTemplate(HKEY("iconbar"), NULL, &NoCtx);
481 WebcitAddUrlHandler(HKEY("user_iconbar"), doUserIconStylesheet, 0);
482 WebcitAddUrlHandler(HKEY("commit_iconbar"), commit_iconbar, 0);
483 RegisterConditional(HKEY("COND:ICONBAR:ACTIVE"), 3, ConditionalIsActiveStylesheet, CTX_NONE);
484 WebcitAddUrlHandler(HKEY("display_customize_iconbar"), display_customize_iconbar, 0);
485 RegisterNamespace("ICONBAR", 0, 0, tmplput_iconbar, 0);