chiark / gitweb /
The Login page now includes a form to request a password reminder
[disorder] / server / cgi.c
index 21895325578242ec298bba528b8bc1c57a27ff46..5abf145f0bffc0569082f22223345d382f6134d3 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * This file is part of DisOrder.
- * Copyright (C) 2004, 2005, 2006 Richard Kettlewell
+ * Copyright (C) 2004, 2005, 2006, 2008 Richard Kettlewell
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -585,14 +585,29 @@ const char *cgi_label(const char *key) {
 
   read_options();
   if(!(label = kvp_get(labels, key))) {
-    if((label = strchr(key, '.')))
+    /* No label found */
+    if(!strncmp(key, "images.", 7)) {
+      static const char *url_static;
+      /* images.X defaults to <url.static>X.png */
+
+      if(!url_static)
+       url_static = cgi_label("url.static");
+      byte_xasprintf((char **)&label, "%s%s.png", url_static, key + 7);
+    } else if((label = strchr(key, '.')))
+      /* X.Y defaults to Y */
       ++label;
     else
+      /* otherwise default to label name */
       label = key;
   }
   return label;
 }
 
+int cgi_label_exists(const char *key) {
+  read_options();
+  return kvp_get(labels, key) ? 1 : 0;
+}
+
 char **cgi_columns(const char *name, int *ncolumns) {
   struct column *c;