r9416 - apps/gobi/trunk/code/Global

[email protected]
Newsgroups gmane.comp.java.helma.cvs
Message-ID <[email protected]>
Author: hannes
Date: 2008-12-12 15:06:52 +0100 (Fri, 12 Dec 2008)
New Revision: 9416

Modified:
   apps/gobi/trunk/code/Global/PageList.js
Log:
Enhance PageList.nameList() to optionally render HTML lists and links.

Details at http://dev.helma.org/trac/helma/changeset/9416

Modified: apps/gobi/trunk/code/Global/PageList.js
===================================================================
--- apps/gobi/trunk/code/Global/PageList.js	2008-12-12 00:14:47 UTC (rev 9415)
+++ apps/gobi/trunk/code/Global/PageList.js	2008-12-12 14:06:52 UTC (rev 9416)
@@ -165,7 +165,7 @@
     },
 
     /*
-     *  Render a plain list of page names.
+     *  Render a plain list of page names, optionally generating a HTML list.
      */
     nameList: function(list, param) {
         if (list.length == 0)
@@ -173,6 +173,8 @@
 
         var separator = param && param.separator || ", ";
         var type = param && param.type;
+        var listtype = param && param.listtype;
+        var link = param && param.link;
         
         var sort = param && param.sort;
         if (sort)
@@ -182,6 +184,11 @@
 
         var count = 0;
         res.push();
+
+        if (listtype) {
+            res.writeln("<" + listtype + ">");
+        }
+
         for (var i= 0; i < list.length; i++) {
             // check if we have access permission to main action
             if (!list[i].checkAccess("main")) {
@@ -190,12 +197,25 @@
             if (type && list[i]._prototype != type) {
                 continue;
             }
-            if (separator && count++ > 0) {
+            if (listtype) {
+                res.writeln("<li>");
+            } else if (separator && count++ > 0) {
                 res.write(separator);
             }
 
-            res.write(list[i].name);
+            if (link) {
+                res.write(list[i].getHtmlLink(param, {}));
+            } else {
+                res.write(list[i].name);
+            }
+
+            if (listtype) {
+                res.writeln("</li>");
+            }
         }
+        if (listtype) {
+            res.writeln("</" + listtype + ">");
+        }
         return res.pop();
     }
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.