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

📄 a_cmsbackoffice.java

📁 一个cms内容管理平台
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
        //            //get undelete method and undelete content definition instance
        //            try {
        //                ((I_CmsExtendedContentDefinition) o).undelete(cms);
        //            } catch (Exception e1) {
        //                if (I_CmsLogChannels.C_PREPROCESSOR_IS_LOGGING && A_OpenCms.isLogging() ) {
        //                    A_OpenCms.log(this);
        //                }
        //                templateSelector = "undeleteerror";
        //                template.setData("undeleteerror", e1.getMessage());
        //            }
        //            //finally start the processing
        //            processResult = startProcessing(cms, template, elementName, parameters, templateSelector);
        //            return processResult;
        //        }
        //access content definition constructor by reflection
        Object o = null;
        o = getContentDefinition(cms, cdClass, contentId);
        //get undelete method and undelete content definition instance
        try {
            ((I_CmsExtendedContentDefinition)o).undelete(cms);
        } catch (Exception e) {
            templateSelector = "undeleteerror";
            template.setData("undeleteerror", e.getMessage());
        }

        //finally start the processing
        processResult = startProcessing(cms, template, elementName, parameters, templateSelector);
        return processResult;
    }

    /**
     * Gets the content of a given template file.
     * <P>
     * While processing the template file the table entry
     * <code>entryTitle<code> will be displayed in the delete dialog
     *
     * @param cms A_CmsObject Object for accessing system resources
     * @param template the template file
     * @param elementName not used here
     * @param parameters get the parameters action for the button activity
     * and id for the used content definition instance object
     * @param templateSelector template section that should be processed.
     * @return Processed content of the given template file.
     * @throws CmsException if something goes wrong
     */
    public byte[] getContentCopy(CmsObject cms, CmsXmlWpTemplateFile template, String elementName, Hashtable parameters, String templateSelector) throws CmsException {
        //return var
        byte[] processResult = null;

        // session will be created or fetched
        I_CmsSession session = CmsXmlTemplateLoader.getSession(cms.getRequestContext(), true);
        //get the class of the content definition
        Class cdClass = getContentDefinitionClass();

        //get (stored) id parameter
        String id = (String)parameters.get("id");
        if (id == null) {
            id = "";
        }
        // get value of hidden input field action
        String action = (String)parameters.get("action");

        //no button pressed, go to the default section!
        //copy dialog, displays information of the entry to be copy
        if (action == null || action.equals("")) {
            if (id != "") {
                //access content definition constructor by reflection
                Object o = getContentDefinition(cms, cdClass, new CmsUUID(id));
                // get owner and group of content definition
                String curOwner = readSaveUserName(cms, ((I_CmsExtendedContentDefinition)o).getOwner());
                String curGroup = readSaveGroupName(cms, ((I_CmsExtendedContentDefinition)o).getGroupId());

                //set template section
                templateSelector = "copy";

                //get the dialog from the language file and set it in the template
                template.setData("username", curOwner);
                template.setData("groupname", curGroup);
                template.setData("id", id);
                template.setData("setaction", "default");
            }
            // confirmation button pressed, process data!
        } else {
            //set template section
            templateSelector = "done";
            //remove marker
            session.removeValue("idcopy");
            //copy the content definition instance
            CmsUUID contentId = new CmsUUID(id);
            Object o = getContentDefinition(cms, cdClass, contentId);

            //            Integer contentId = null;
            //            Object o = null;
            //            try {
            //                contentId = Integer.valueOf(id);
            //                //access content definition constructor by reflection
            //                o = getContentDefinition(cms, cdClass, contentId);
            //            } catch (Exception e) {
            //                //access content definition constructor by reflection
            //                o = getContentDefinition(cms, cdClass, id);
            //            }

            //get copy method and copy content definition instance
            try {
                ((I_CmsExtendedContentDefinition)o).copy(cms);
            } catch (Exception e) {
                templateSelector = "copyerror";
                template.setData("copyerror", e.getMessage());
            }
        }
        //finally start the processing
        processResult = startProcessing(cms, template, elementName, parameters, templateSelector);
        return processResult;
    }

    /**
     * Gets the content of a given template file.
     * <P>
     * While processing the template file the table entry
     * <code>entryTitle<code> will be displayed in the direct publish dialog
     *
     * @param cms A_CmsObject Object for accessing system resources
     * @param template the template
     * @param elementName not used here
     * @param parameters get the parameters action for the button activity
     * and id for the used content definition instance object
     * @param templateSelector template section that should be processed.
     * @return Processed content of the given template file.
     * @throws CmsException if something goes wrong
     */
    public byte[] getContentDirectPublish(CmsObject cms, CmsXmlWpTemplateFile template, String elementName, Hashtable parameters, String templateSelector) throws CmsException {
        //return var
        byte[] processResult = null;

        //create new language file object
        CmsXmlLanguageFile lang = new CmsXmlLanguageFile(cms);

        if (cms.isAdmin() || cms.isManagerOfProject()) {
            // session will be created or fetched
            I_CmsSession session = CmsXmlTemplateLoader.getSession(cms.getRequestContext(), true);
            //get the class of the content definition
            Class cdClass = getContentDefinitionClass();

            //get (stored) id parameter
            String id = (String)parameters.get("id");
            if (id == null) {
                id = "";
            }

            // get value of hidden input field action
            String action = (String)parameters.get("action");

            //no button pressed, go to the default section!
            //publish dialog, displays the title of the entry to be published
            if (action == null || action.equals("")) {
                if (id != "") {
                    //set template section
                    templateSelector = "publish";

                    //get the dialog from the langauge file and set it in the template
                    template.setData("publishtitle", lang.getLanguageValue("messagebox.title.publishresource"));
                    template.setData("publishdialog1", lang.getLanguageValue("messagebox.message1.publishresource"));
                    template.setData("newsentry", id);
                    template.setData("publishdialog2", lang.getLanguageValue("messagebox.message4.publishresource"));
                    template.setData("setaction", "default");
                }
                // confirmation button pressed, process data!
            } else {
                //set template section
                templateSelector = "done";
                //remove marker
                session.removeValue("idsave");
                //publish the content definition instance
                CmsUUID contentId = new CmsUUID(id);
                //                Integer contentId = null;
                //                try {
                //                    contentId = Integer.valueOf(id);
                //                } catch (Exception e) {
                //                    //access content definition constructor by reflection
                //                    Object o = null;
                //                    o = getContentDefinition(cms, cdClass, id);
                //                    //get publish method and publish content definition instance
                //                    try {
                //                        ((I_CmsExtendedContentDefinition) o).publishResource(cms);
                //                    } catch (Exception e1) {
                //                        if (I_CmsLogChannels.C_PREPROCESSOR_IS_LOGGING && A_OpenCms.isLogging() ) {
                //                            A_OpenCms.log(this);
                //                        }
                //                        templateSelector = "publisherror";
                //                        template.setData("publisherror", e1.getMessage());
                //                    }
                //                    //finally start the processing
                //                    processResult = startProcessing(cms, template, elementName, parameters, templateSelector);
                //                    return processResult;
                //                }

                //access content definition constructor by reflection
                Object o = null;
                o = getContentDefinition(cms, cdClass, contentId);
                //get publish method and publish content definition instance
                try {
                    ((I_CmsExtendedContentDefinition)o).publishResource(cms);
                } catch (Exception e) {
                    templateSelector = "publisherror";
                    template.setData("publisherror", e.getMessage());
                }
            }
        } else {
            templateSelector = "publisherror";
            template.setData("publisherror", lang.getLanguageValue("error.message.publishresource") + "<br>" + lang.getLanguageValue("error.reason.publishresource"));
        }

        //finally start the processing
        processResult = startProcessing(cms, template, elementName, parameters, templateSelector);
        return processResult;
    }

    /**
     * Gets the content of a given template file.
     * <P>
     * While processing the template file the table entry
     * <code>entryTitle<code> will be displayed in the history dialog
     *
     * @param cms A_CmsObject Object for accessing system resources
     * @param template the template
     * @param elementName not used here
     * @param parameters get the parameters action for the button activity
     * and id for the used content definition instance object
     * @param templateSelector template section that should be processed.
     * @return Processed content of the given template file.
     * @throws CmsException if something goes wrong
     */
    public byte[] getContentHistory(CmsObject cms, CmsXmlWpTemplateFile template, String elementName, Hashtable parameters, String templateSelector) throws CmsException {
        //return var
        byte[] processResult = null;

        // session will be created or fetched
        I_CmsSession session = CmsXmlTemplateLoader.getSession(cms.getRequestContext(), true);
        //get the class of the content definition
        Class cdClass = getContentDefinitionClass();

        //get (stored) id parameter
        String id = (String)parameters.get("id");
        if (id == null) {
            id = "";
        }

        // get value of hidden input field action
        String action = (String)parameters.get("action");
        //no button pressed, go to the default section!
        //history dialog, displays the versions of the cd in the history
        if (action == null || action.equals("")) {
            if (id != "") {
                //set template section
                templateSelector = "history";
                //create new language file object
                CmsXmlLanguageFile lang = new CmsXmlLanguageFile(cms);
                //get the dialog from the langauge file and set it in the template
                template.setData("historytitle", lang.getLanguageValue("messagebox.title.history"));
                // build the history list
                template.setData("id", id);
                template.setData("setaction", "detail");
            } else {
                //set template section
                templateSelector = "done";
                //remove marker
                session.removeValue("idhistory");
            }
            // confirmation button pressed, process data!
        } else if (action.equalsIgnoreCase("detail")) {
            String versionId = (String)parameters.get("version");
            if (versionId != null && !"".equals(versionId)) {
                templateSelector = "historydetail";
                //access content definition constructor by reflection
                Object o = null;
                o = getContentDefinition(cms, cdClass, new CmsUUID(id));
                //get the version from history
                try {
                    I_CmsExtendedContentDefinition curVersion = (I_CmsExtendedContentDefinition) ((I_CmsExtendedContentDefinition)o).getVersionFromHistory(cms, Integer.parseInt(versionId));
                    String projectName = "";
                    String projectDescription = "";
                    String userName = "";
                    try {

⌨️ 快捷键说明

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