⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cmsxmlnav.java

📁 OpenCms 是一个J2EE的产品
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
                template.setData("navlink", OpenCms.getLinkManager().substituteLink(cms, currentNavLink));
            } catch (CmsException e) {
                template.setData("navlink", "#");
            }       
            
            // append the resource itself to the map
            result.append(template.getProcessedDataValue(datablock, this, userObject));
            
            // append the resource's submap, too
            if (isFolder && (currentResursionLevel + 1 <= maxRecursionLevel)) {
                String subMapNavEntryDatablock = "naventry";
                for (int j = 0; j <= currentResursionLevel; j++) {
                    subMapNavEntryDatablock += "sub";
                }
                
                // if there is no "naventrysubsub..." datablock in the template, use the "naventry" instead
                if (!template.hasData(subMapNavEntryDatablock)) {
                    subMapNavEntryDatablock = "naventry";
                }                

                StringBuffer subMap = this.buildMap(cms, doc, userObject, navLink[i], subMapNavEntryDatablock, currentResursionLevel+1, maxRecursionLevel);               
                result.append(subMap.toString());
            }
        }          
        
        return result;      
    }    
    
    /**
     * gets the navigation of folders recursive.<p>
     *
     * @param cms CmsObject Object for accessing system resources
     * @param tagcontent Unused in this special case of a user method. Can be ignored
     * @param doc Reference to the A_CmsXmlContent object of the initiating XLM document
     * @param userObject Hashtable with parameters
     * @return byte[] with the content of this subelement
     * @throws CmsException if something goes wrong
     */
    public Object getNavTree(CmsObject cms, String tagcontent, A_CmsXmlContent doc, Object userObject)
            throws CmsException {

        // template file
        CmsXmlTemplateFile template=(CmsXmlTemplateFile)doc;
        // check whether there exist entry datablock
        if (!template.hasData("naventry")) {
            return "".getBytes();
        }
        int level=1;
        int depth=0;
        int[] count={0};
        String exact="false";
        // if there is not any depth then it must not be tested in a if condition
        boolean depthIsNull=true;
        // if level is zero or null or negative then all folders recursive must
        // be showed starting from root folder unless all folders stating from
        // specified level of parent folder.
        if (!tagcontent.equals("")) {
            StringTokenizer st = new StringTokenizer(tagcontent, ",");
            String token1="", token2="", token3="";
            if (st.hasMoreTokens())
                token1=st.nextToken();
            if (st.hasMoreTokens())
                token2=st.nextToken();
            if (st.hasMoreTokens())
                token3=st.nextToken();
            // now assign tokens to real values
            if (!token3.equals(""))
                exact=token3.toLowerCase();
            if (!token2.equals("")) {
                try {
                    depth=Integer.parseInt(token2);
                } catch (NumberFormatException e) {
                    depth=0;
                    exact=token2.toLowerCase();
                    if (!exact.equals("true")) {
                        exact="false";
                    }
                }
            }
            if (!token1.equals("")) {
                try {
                    level=Integer.parseInt(token1);
                } catch (NumberFormatException e) {
                    level=1;
                    exact=token1.toLowerCase();
                    if (!exact.equals("true")) {
                        exact="false";
                    }
                }
            }
        }
        // if level is not entered or it is less than zero then folder is the root folder
        // otherwise the folder must be extracted accordeing to the entered level.
        String folder=extractFolder(cms, level, exact);
        if (folder.equals(""))
            return "".getBytes();
        if (depth>0) {
            depthIsNull=false;
        }
        // register this folder for changes
        Vector vfsDeps = new Vector();
        vfsDeps.add(cms.readFolder(folder));
        registerVariantDeps(cms, doc.getAbsoluteFilename(), null, null,
                        (Hashtable)userObject, vfsDeps, null, null);
        // get all folders in specified folder
        List resources=cms.getSubFolders(folder);
        // get all files in specified folder
        List allFile=cms.getFilesInFolder(folder);
        // get a vector of all files und folders
        ((ArrayList)resources).ensureCapacity(resources.size() + allFile.size());
        Iterator e = allFile.iterator();
        while (e.hasNext()) {
            resources.add(e.next());
        }
        // get the uri,servletpath and current folder
        String requestedUri = cms.getRequestContext().getUri();
        String currentFolder=CmsResource.getFolderPath(cms.getRequestContext().getUri());
        String servletPath = CmsXmlTemplateLoader.getRequest(cms.getRequestContext()).getServletUrl();

        String result="";
        // check whether xml data blocks are defined.
        // The main datablock is entry, it must be defined, the others will get
        // the same datablock if they don't exist.
        if (!template.hasData("navcurrent")) {
            template.setData("navcurrent", template.getData("naventry"));
        }
        if (!template.hasData("navstart")) {
            template.setData("navstart", "");
        }
        if (!template.hasData("navend")) {
            template.setData("navend", "");
        }
        result=buildNavTree(cms, template, userObject, resources, requestedUri, currentFolder, servletPath, level, depth, depthIsNull, count);
        return result.getBytes();
    }

    /**
     * gets a specified property of current folder.<p>
     *
     * @param cms A_CmsObject Object for accessing system resources
     * @param tagcontent Unused in this special case of a user method. Can be ignored
     * @param doc Reference to the A_CmsXmlContent object of the initiating XLM document
     * @param userObject Hashtable with parameters
     * @return byte[] with the content of this subelement
     * @throws CmsException if something goes wrong
     */
    public Object getPropertyCurrent(CmsObject cms, String tagcontent, A_CmsXmlContent doc, Object userObject)
        throws CmsException {
        String property="";
        // tagcontent must contain the property definition name.
        if (!tagcontent.equals("")) {
            String currentFolder=CmsResource.getFolderPath(cms.getRequestContext().getUri());
            property=cms.readProperty(currentFolder, tagcontent);
            property=(property!=null?property:"");
            // register this folder for changes
            Vector vfsDeps = new Vector();
            vfsDeps.add(cms.readFolder(currentFolder));
            registerVariantDeps(cms, doc.getAbsoluteFilename(), null, null,
                            (Hashtable)userObject, vfsDeps, null, null);
        }
        return (property.getBytes());
    }


    /**
     * Gets a specified property of specified folder starting from current folder.<p>
     *
     * @param cms A_CmsObject Object for accessing system resources
     * @param tagcontent Unused in this special case of a user method. Can be ignored
     * @param doc Reference to the A_CmsXmlContent object of the initiating XLM document
     * @param userObject Hashtable with parameters
     * @return byte[] with the content of this subelement
     * @throws CmsException if something goes wrong
     */
    public Object getPropertyParent(CmsObject cms, String tagcontent, A_CmsXmlContent doc, Object userObject)
        throws CmsException {
        int level=1;
        String property="";
        // tagcontent determines the parent folder starting from current folder and
        // the property definition name sparated by a comma.
        String exact="false";
        // tagcontent determines the folder starting from root folder.
        // if tagcontent is null, then the navigation of root folder must be showed.
        if (!tagcontent.equals("")) {
            try {
                if (tagcontent.indexOf(",")!=-1) {
                    level=Integer.parseInt(tagcontent.substring(0, tagcontent.indexOf(",")));
                    exact=tagcontent.substring(tagcontent.indexOf(",")+1).toLowerCase();
                } else {
                    level=Integer.parseInt(tagcontent);
                }
            } catch (NumberFormatException e) {
                level=1;
                exact=tagcontent.toLowerCase();
                if (!exact.equals("true")) {
                    exact="false";
                }
            }
            // level is converted to negative number, so I can use the method
            // "extractFolder" for positive and negative numbers. Negative number
            // determines the parent folder level starting from current folder and
            // positive number determines the level starting ftom root folder.
            String currentFolder=extractFolder(cms, ((-1)*level), exact);
            if (currentFolder.equals(""))
                return "".getBytes();
            property=cms.readProperty(currentFolder, tagcontent.substring(tagcontent.indexOf(",")+1));
            property=(property!=null?property:"");
            // register this folder for changes
            Vector vfsDeps = new Vector();
            vfsDeps.add(cms.readFolder(currentFolder));
            registerVariantDeps(cms, doc.getAbsoluteFilename(), null, null,
                            (Hashtable)userObject, vfsDeps, null, null);
        }
        return (property.getBytes());
    }

    /**
     * Gets a specified property of specified folder starting from root.<p>
     *
     * @param cms A_CmsObject Object for accessing system resources
     * @param tagcontent Unused in this special case of a user method. Can be ignored
     * @param doc Reference to the A_CmsXmlContent object of the initiating XLM document
     * @param userObject Hashtable with parameters
     * @return byte[] with the content of this subelement
     * @throws CmsException if something goes wrong
     */
    public Object getPropertyRoot(CmsObject cms, String tagcontent, A_CmsXmlContent doc, Object userObject)
        throws CmsException {
        int level=1;
        String property="";
        String exact="false";
        // tagcontent determines the folder starting from root folder.
        // if tagcontent is null, then the navigation of root folder must be showed.
        if (!tagcontent.equals("")) {
            try {
                if (tagcontent.indexOf(",")!=-1) {
                    level=Integer.parseInt(tagcontent.substring(0, tagcontent.indexOf(",")));
                    exact=tagcontent.substring(tagcontent.indexOf(",")+1).toLowerCase();
                } else {
                    level=Integer.parseInt(tagcontent);
                }
            } catch (NumberFormatException e) {
                level=1;
                exact=tagcontent.toLowerCase();
                if (!exact.equals("true")) {
                    exact="false";
                }
            }
            String currentFolder=extractFolder(cms, level, exact);
            if (currentFolder.equals(""))
                return "".getBytes();
            property=cms.readProperty(currentFolder, tagcontent.substring(tagcontent.indexOf(",")+1));
            property=(property!=null?property:"");
            // register this folder for changes
            Vector vfsDeps = new Vector();
            vfsDeps.add(cms.readFolder(currentFolder));
            registerVariantDeps(cms, doc.getAbsoluteFilename(), null, null,
                            (Hashtable)userObject, vfsDeps, null, null);
        }
        return (property.getBytes());
    }


    /**
     * gets a specified property of uri.<p>
     *
     * @param cms A_CmsObject Object for accessing system resources
     * @param tagcontent Unused in this special case of a user method. Can be ignored
     * @param doc Reference to the A_CmsXmlContent object of the initiating XLM document
     * @param userObject Hashtable with parameters
     * @return byte[] with the content of this subelement
     * @throws CmsException if somnething goes wrong
     */
    public Object getPropertyUri(CmsObject cms, String tagcontent, A_CmsXmlContent doc, Object userObject)
        throws CmsException {
        String p

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -