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

📄 cmsadminmoduleadmin.java

📁 内容管理
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
                // ready; save changes in registry
                updateTheModule(cms, reg, sessionData, packetName);
                session.removeValue(C_SESSION_MODULE_ADMIN_DATA);
                templateSelector = "done";
            }
        }
        if("firstpage".equals(stepTo)) {

            // show the first page
            templateDocument.setData(C_MODULE_PACKETNAME, (String)sessionData.get(C_MODULE_PACKETNAME));
            templateDocument.setData(C_VERSION, (String)sessionData.get(C_VERSION));
            templateDocument.setData(C_MODULENAME, (String)sessionData.get(C_MODULENAME));
            templateDocument.setData(C_DESCRIPTION, (String)sessionData.get(C_DESCRIPTION));
            templateDocument.setData(C_VIEW, (String)sessionData.get(C_VIEW));
            templateDocument.setData(C_ADMINPOINT, (String)sessionData.get(C_ADMINPOINT));
            templateDocument.setData(C_MAINTENANCE, (String)sessionData.get(C_MAINTENANCE));
            templateDocument.setData(C_PUBLISHCLASS, (String)sessionData.get(C_PUBLISHCLASS));
            templateDocument.setData(C_AUTHOR, (String)sessionData.get(C_AUTHOR));
            templateDocument.setData(C_EMAIL, (String)sessionData.get(C_EMAIL));
            templateDocument.setData(C_DATE, (String)sessionData.get(C_DATE));
            
            templateDocument.setData(C_MODULE_TYPE, (String)sessionData.get(C_MODULE_TYPE));
            templateSelector = "";
        }
        if("deps".equals(stepTo)) {

            // show the dependencies
            templateDocument.setData(C_MODULE_PACKETNAME, (String)sessionData.get(C_MODULE_PACKETNAME));
            Vector deps = (Vector)sessionData.get(C_DEPENDENCY);
            String entrys = "";
            for(int i = 0;i < deps.size();i++) {
                templateDocument.setData(C_ONEDEP, (String)deps.elementAt(i));
                entrys += templateDocument.getProcessedDataValue(C_OPTIONENTRY);
            }
            templateDocument.setData(C_ALLDEPS, entrys);
            templateSelector = "dependencies";
        }
        if("props".equals(stepTo)) {

            // prepare the properties page
            templateSelector = "properties";
        }

        // Now load the template file and start the processing
        return startProcessing(cms, templateDocument, elementName, parameters, templateSelector);
    }

    /**
     * returns the String or "" if it is null.
     * Creation date: (29.10.00 16:05:38)
     * @return java.lang.String
     * @param param java.lang.String
     */
    private String getStringValue(String param) {
        if(param == null) {
            return "";
        }
        return param;
    }

    /**
     * Indicates if the results of this class are cacheable.
     *
     * @param cms CmsObject Object for accessing system resources
     * @param templateFile Filename of the template file
     * @param elementName Element name of this template in our parent template.
     * @param parameters Hashtable with all template class parameters.
     * @param templateSelector template section that should be processed.
     * @return <EM>true</EM> if cacheable, <EM>false</EM> otherwise.
     */
    public boolean isCacheable(CmsObject cms, String templateFile, String elementName, Hashtable parameters, String templateSelector) {
        return false;
    }

    /** Parse the string which holds all dependencies
     *
     * @param resources containts the full pathnames of all the resources, separated by semicolons
     * @return A vector with the same resources
     */
    private Vector parseAllDeps(String resources) {
        Vector ret = new Vector();
        if(resources != null) {
            StringTokenizer resTokenizer = new StringTokenizer(resources, ";");
            while(resTokenizer.hasMoreElements()) {
                String path = (String)resTokenizer.nextElement();
                ret.addElement(path);
            }
        }
        return ret;
    }

    /**
     * Insert the method's description here.
     * Creation date: (03.11.00 08:23:13)
     * @param param com.opencms.file.CmsObject
     * @param folder java.lang.String
     * @param newFolder java.lang.String
     */
    private void tryToCreateFolder(CmsObject cms, String folder, String newFolder) {
        try {
            cms.createResource(folder, newFolder, C_TYPE_FOLDER_NAME);
        }catch(Exception e) {
        }
    }

    /**
     * fills the data from the hashtable in the module.
     * Creation date: (30.10.00 14:22:22)
     * @return java.util.Hashtable
     * @param param java.lang.String
     */
    private void updateTheModule(CmsObject cms, I_CmsRegistry reg, Hashtable table, String module) {
        SimpleDateFormat dateFormat = new java.text.SimpleDateFormat("dd.MM.yyyy");
        String name = (String)table.get(C_MODULE_PACKETNAME);
        String modulePath = C_VFS_PATH_MODULES + name + "/";
        
        // set the module version
        String version = (String)table.get(C_VERSION);
        try {
            reg.setModuleVersion(name, version);
        } catch (CmsException e) {}
        
        try {
            reg.setModuleNiceName(name, (String)table.get(C_MODULENAME));
            reg.setModuleDescription(name, (String)table.get(C_DESCRIPTION));

            // the view
            if("".equals((String)table.get(C_VIEW))) {
                if(!"".equals(getStringValue(reg.getModuleViewName(name)))) {
                    try {
                        cms.deleteResource(modulePath + "view/");
                    }catch(Exception e) {
                    }
                    reg.deleteModuleView(name);
                }
            }else {
                if("".equals(getStringValue(reg.getModuleViewName(name)))) {
                    reg.setModuleView(name, name.replace('.', '_'), modulePath + "view/index.html");
                    tryToCreateFolder(cms, modulePath, "view");
                }
            }

            // the adminpoint
            if("".equals((String)table.get(C_ADMINPOINT))) {
                try { // does not work when folder is not empty
                    cms.deleteResource(modulePath + "administration/");
                }catch(Exception e) {
                }
            }else {
                tryToCreateFolder(cms, modulePath, "administration");
            }

            // the easy values
            reg.setModuleMaintenanceEventClass(name, (String)table.get(C_MAINTENANCE));
            reg.setModulePublishClass(name, (String)table.get(C_PUBLISHCLASS));
            reg.setModuleAuthor(name, (String)table.get(C_AUTHOR));
            reg.setModuleAuthorEmail(name, (String)table.get(C_EMAIL));

            // set the date, if the value is not correct set the current date
            String date = (String)table.get(C_DATE);
            long dateLong = 0;
            try {
                dateLong = dateFormat.parse(date).getTime();
            }catch(Exception exc) {
                dateLong = (new Date()).getTime();
            }
            reg.setModuleCreateDate(name, dateLong);

            // now the dependnecies
            Vector depNames = new Vector();
            Vector minVersion = new Vector();
            Vector maxVersion = new Vector();
            Vector stringDeps = (Vector)table.get(C_DEPENDENCY);
            for(int i = 0;i < stringDeps.size();i++) {
                String complString = (String)stringDeps.elementAt(i);
                String max = complString.substring(complString.lastIndexOf("-") + 2);
                complString = complString.substring(0, complString.lastIndexOf("-") - 1);
                String min = complString.substring(complString.lastIndexOf(":") + 1);
                depNames.addElement((complString.substring(0, complString.lastIndexOf("Version:") - 1)).trim());
                float minInt = 0;
                float maxInt = -1;
                try {
                    minInt = Float.parseFloat(min);
                }catch(Exception e) {
                }
                try {
                    if(!"*".equals(max)) {
                        maxInt = Float.parseFloat(max);
                    }
                }catch(Exception e) {
                }
                minVersion.addElement(new Float(minInt));
                maxVersion.addElement(new Float(maxInt));
            }
            reg.setModuleDependencies(name, depNames, minVersion, maxVersion);

            // last not least: the properties
            Vector paraNames = (Vector)table.get(C_SESSION_MODULE_ADMIN_PROP_NAMES);
            Vector paraDesc = (Vector)table.get(C_SESSION_MODULE_ADMIN_PROP_DESCR);
            Vector paraTyp = (Vector)table.get(C_SESSION_MODULE_ADMIN_PROP_TYP);
            Vector paraVal = (Vector)table.get(C_SESSION_MODULE_ADMIN_PROP_VAL);
            reg.setModuleParameterdef(name, paraNames, paraDesc, paraTyp, paraVal);
            
            // set the module type
            String moduleType = (String)table.get(C_MODULE_TYPE);
            if (moduleType!=null && moduleType.equals("checked")) {
                reg.setModuleType( name, CmsRegistry.C_MODULE_TYPE_SIMPLE );
            }
            else {
                reg.setModuleType( name, CmsRegistry.C_MODULE_TYPE_TRADITIONAL );
            }               
        }catch(CmsException e) {
             if(I_CmsLogChannels.C_PREPROCESSOR_IS_LOGGING && A_OpenCms.isLogging()) {
                 A_OpenCms.log(I_CmsLogChannels.C_MODULE_DEBUG,
                    "Error while module administrating: " + e.toString());
             }
        }
    }
}

⌨️ 快捷键说明

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