r9417 - apps/gobi/trunk/code/Page

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

Modified:
   apps/gobi/trunk/code/Page/PageCore.js
Log:
Add unique option to getLinkedPages() and fix getPages() with absolute paths on root page.

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

Modified: apps/gobi/trunk/code/Page/PageCore.js
===================================================================
--- apps/gobi/trunk/code/Page/PageCore.js	2008-12-12 14:06:52 UTC (rev 9416)
+++ apps/gobi/trunk/code/Page/PageCore.js	2008-12-12 14:08:16 UTC (rev 9417)
@@ -19,6 +19,7 @@
  */
 
 app.addRepository("modules/core/String.js");
+app.addRepository("modules/core/Array.js");
 
 Page.serialId = 1;
 
@@ -242,6 +243,7 @@
  *   <li>inherit (boolean) whether to include links from parent pages</li>
  *   <li>reverse (boolean) whether to reverse the returned list</li>
  *   <li>limit (number) the maximal number of objects to return</li>
+ *   <li>unique (boolean) do not add same page more than once</li>
  *  </ul>
  */
 function getLinkedPages(type, direction, options) {
@@ -249,8 +251,9 @@
     var links = this.getLinks(type, direction, options);
     for (var i in links) {
         var page = links[i].getPage(direction);
-        if (page)
+        if (page && (!options || !options.unique || !list.contains(page))) {
             list.push(page);
+        }
     }
     return list;
 }
@@ -594,7 +597,7 @@
         return root;
 
     // paths starting with '/' are absolute
-    if (name.indexOf("/") == 0 && this != root)
+    if (name.indexOf("/") == 0)
         return root.getPage(name.substring(1), create, type);
     
     // split name at '/' chars
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.