Sling.getContent = function()

in src/main/resources/system/sling.js [146:183]


    Sling.getContent = function(path, maxlevels, filter) {
        var obj=new Object();
        if (!path)  {
            path=Sling.currentPath;
        }
        if (path.indexOf("/")==0) {
            /*
            this assumes that paths that start with a slash
            are meant to be workspace paths rather than URLs
            and therefore need some additions before they are sent
            to the server
            */
            if(maxlevels == "0" || maxlevels) {
              maxlevels = "." + maxlevels;
            } else {
              maxlevels = "";
            }
            path=Sling.baseurl + path + maxlevels + ".json";
        }
        //checking for a trailing "/*"
        if (path.indexOf("/*")>=0) return obj;
    
        // TODO for now we explicitely defeat caching on this...there must be a better way
        // but in tests IE6 tends to cache too much
        var passThroughCacheParam = "?clock=" + new Date().getTime();
        var res=Sling.httpGet(path + passThroughCacheParam + (maxlevels?"&maxlevels="+maxlevels:""));
        
        if(res.status == 200) {
            var obj=Sling.evalString(res.responseText);
            if (!filter) {
                for (var a in obj) {
                    if (a.indexOf("jcr:")==0) delete(obj[a]);
                }
            }
            return obj;
        }
        return null; 
    }