cmsframeset.java

来自「找了很久才找到到源代码」· Java 代码 · 共 542 行 · 第 1/2 页

JAVA
542
字号
        }

        return buildSelect(htmlAttributes, options, values, selectedIndex);
    }

    /**
     * Returns the html for the "publish project" button depending on the current users permissions and the default
     * workplace settings.<p>
     * 
     * @return the html for the "publish project" button
     */
    public String getPublishButton() {

        String publishButton = OpenCms.getWorkplaceManager().getDefaultUserSettings().getPublishButtonAppearance();
        if (CmsDefaultUserSettings.PUBLISHBUTTON_SHOW_NEVER.equals(publishButton)) {
            return "";
        }

        int buttonStyle = getSettings().getUserSettings().getWorkplaceButtonStyle();

        if (CmsDefaultUserSettings.PUBLISHBUTTON_SHOW_AUTO.equals(publishButton)) {
            if (getCms().isManagerOfProject()) {
                return button(
                    "../commons/publishproject.jsp",
                    "body",
                    "publish.png",
                    Messages.GUI_BUTTON_PUBLISH_0,
                    buttonStyle);
            } else {
                return "";
            }
        }

        if (getCms().isManagerOfProject()) {
            return (button(
                "../commons/publishproject.jsp",
                "body",
                "publish.png",
                Messages.GUI_BUTTON_PUBLISH_0,
                buttonStyle));
        } else {
            return (button(null, null, "publish_in.png", Messages.GUI_BUTTON_PUBLISH_0, buttonStyle));
        }
    }

    /**
     * Returns the html for the "publish queue" button.<p>
     * 
     * @return the html for the "publish queue" button
     */
    public String getPublishQueueButton() {

        int buttonStyle = getSettings().getUserSettings().getWorkplaceButtonStyle();
        StringBuffer js = new StringBuffer(128);
        js.append("javascript:if (parent.body.admin_content && parent.body.admin_menu) {");
        js.append("parent.body.location.href = '");
        js.append(getJsp().link("/system/workplace/views/admin/admin-fs.jsp?root=admin&path=/publishqueue"));
        js.append("';");
        js.append("} else {");
        js.append("parent.body.explorer_body.explorer_files.location.href = '");
        js.append(getJsp().link("/system/workplace/views/admin/admin-fs.jsp?root=explorer&path=/publishqueue&menu=no"));
        js.append("';");
        js.append("};");
        return button(js.toString(), null, "publish_queue.png", Messages.GUI_BUTTON_PUBLISHQUEUE_0, buttonStyle);
    }

    /**
     * Returns a html select box filled with the current users accessible sites.<p>
     * 
     * @param htmlAttributes attributes that will be inserted into the generated html 
     * @return a html select box filled with the current users accessible sites
     */
    public String getSiteSelect(String htmlAttributes) {

        List options = new ArrayList();
        List values = new ArrayList();
        int selectedIndex = 0;

        List sites = OpenCms.getSiteManager().getAvailableSites(getCms(), true);

        Iterator i = sites.iterator();
        int pos = 0;
        while (i.hasNext()) {
            CmsSite site = (CmsSite)i.next();
            values.add(site.getSiteRoot());
            options.add(site.getTitle());
            if (site.getSiteRoot().equals(getSettings().getSite())) {
                // this is the user's current site
                selectedIndex = pos;
            }
            pos++;
        }

        return buildSelect(htmlAttributes, options, values, selectedIndex);
    }

    /**
     * Returns the startup URI for display in the main body frame, this can 
     * either be the user default view, or (if set) a sepcific startup resource.<p> 
     * 
     * @return the startup URI for display in the main body frame
     */
    public String getStartupUri() {

        String result = getSettings().getViewStartup();
        if (result == null) {
            // no specific startup URI is set, use view from user settings
            result = getSettings().getViewUri();
        } else {
            // reset the startup URI, so that it is not displayed again on reload of the frameset
            getSettings().setViewStartup(null);
        }
        return CmsRequestUtil.appendParameter(result, CmsFrameset.PARAM_WP_FRAME, FRAMES[2]);
    }

    /**
     * Returns a html select box filled with the views accessible by the current user.<p>
     * 
     * @param htmlAttributes attributes that will be inserted into the generated html 
     * @return a html select box filled with the views accessible by the current user
     */
    public String getViewSelect(String htmlAttributes) {

        List options = new ArrayList();
        List values = new ArrayList();
        int selectedIndex = 0;

        // loop through the vectors and fill the result vectors
        Iterator i = OpenCms.getWorkplaceManager().getViews().iterator();
        int count = -1;
        String currentView = getSettings().getViewUri();
        if (CmsStringUtil.isNotEmpty(currentView)) {
            // remove possible parameters from current view
            int pos = currentView.indexOf('?');
            if (pos >= 0) {
                currentView = currentView.substring(0, pos);
            }
        }
        while (i.hasNext()) {
            CmsWorkplaceView view = (CmsWorkplaceView)i.next();
            if (getCms().existsResource(view.getUri(), CmsResourceFilter.ONLY_VISIBLE_NO_DELETED)) {
                count++;
                // ensure the current user has +v+r permissions on the view
                String loopLink = getJsp().link(view.getUri());
                String localizedKey = resolveMacros(view.getKey());
                options.add(localizedKey);
                values.add(loopLink);

                if (loopLink.equals(currentView)) {
                    selectedIndex = count;
                }
            }
        }

        return buildSelect(htmlAttributes, options, values, selectedIndex);
    }

    /**
     * Returns the reload URI for the OpenCms workplace.<p>
     * 
     * @return the reload URI for the OpenCms workplace
     */
    public String getWorkplaceReloadUri() {

        return getJsp().link(CmsFrameset.JSP_WORKPLACE_URI);
    }

    /**
     * Returns <code>true</code> if a reload of the main body frame is required.<p>
     * 
     * This value is modified with the select options (project, site or view) in the head frame of 
     * the Workplace. If a user changes one of these select values, the head frame is posted 
     * "against itself". The posted values will be processed by this class, causing
     * the internal Workplace settings to change. After these settings have been changed,
     * a reload of the main body frame is required in order to update it with the new values.
     * A JavaScript in the Workplace head frame will be executed in this case.<p>
     * 
     * @return <code>true</code> if a reload of the main body frame is required
     */
    public boolean isReloadRequired() {

        return m_reloadRequired;
    }

    /**
     * Returns true if the user has enabled synchronization.<p>
     * 
     * @return true if the user has enabled synchronization
     */
    public boolean isSyncEnabled() {

        CmsSynchronizeSettings syncSettings = getSettings().getUserSettings().getSynchronizeSettings();
        return (syncSettings != null) && syncSettings.isSyncEnabled();
    }

    /**
     * Indicates if the site selector should be shown in the top frame depending on the count of accessible sites.<p>
     * 
     * @return true if site selector should be shown, otherwise false
     */
    public boolean showSiteSelector() {

        if (getSettings().getUserSettings().getRestrictExplorerView()) {
            // restricted explorer view to site and folder, do not show site selector
            return false;
        }
        // count available sites
        int siteCount = OpenCms.getSiteManager().getAvailableSites(getCms(), true).size();
        return (siteCount > 1);
    }

    /**
     * @see org.opencms.workplace.CmsWorkplace#initTimeWarp(org.opencms.db.CmsUserSettings, javax.servlet.http.HttpSession)
     */
    protected void initTimeWarp(CmsUserSettings settings, HttpSession session) {

        // overriden to avoid deletion of the configured time warp: 
        // this is triggered by editors and in auto time warping a direct edit 
        // must not delete a potential auto warped request time 
    }

    /**
     * @see org.opencms.workplace.CmsWorkplace#initWorkplaceRequestValues(org.opencms.workplace.CmsWorkplaceSettings, javax.servlet.http.HttpServletRequest)
     */
    protected void initWorkplaceRequestValues(CmsWorkplaceSettings settings, HttpServletRequest request) {

        // check if a startup page has been set
        String frame = CmsRequestUtil.getNotEmptyDecodedParameter(request, CmsFrameset.PARAM_WP_FRAME);
        if ((frame == null) || (FRAMES_LIST.indexOf(frame) < 0)) {
            // illegal or no frame selected, assume the "top" frame
            frame = FRAMES[0];
        }

        if (FRAMES[0].equals(frame)) {
            // top frame requested - execute special reload actions
            topFrameReload(settings);
        }

        // check if a startup page has been set
        String startup = CmsRequestUtil.getNotEmptyDecodedParameter(request, CmsFrameset.PARAM_WP_START);
        if (startup != null) {
            m_reloadRequired = true;
            settings.setViewStartup(startup);
        }

        // check if the user requested a view change
        String view = request.getParameter(CmsFrameset.PARAM_WP_VIEW);
        if (view != null) {
            m_reloadRequired = true;
            settings.setViewUri(view);
            settings.getFrameUris().put("body", view);
        }

        m_reloadRequired = initSettings(settings, request) || m_reloadRequired;
    }

    /**
     * Performs certain clear cache actions if the top frame is reloaded.<p>
     * 
     * @param settings the current users workplace settings
     */
    protected void topFrameReload(CmsWorkplaceSettings settings) {

        // ensure to read the settings from the database
        initUserSettings(getCms(), settings, true);

        // reset the HTML list in order to force a full reload
        settings.setListObject(null);
    }
}

⌨️ 快捷键说明

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