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

📄 cmstemplatebean.java

📁 OpenCms 是一个J2EE的产品
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
                        getConfigurationValue("headnav.menus", CmsStringUtil.TRUE));
                    getProperties().put(
                        CmsTemplateNavigation.PARAM_HEADNAV_MANUAL,
                        getConfigurationValue("headnav.manual", CmsStringUtil.FALSE));
                }
                include(FOLDER_ELEMENTS + "nav_head_menus.jsp", null, m_properties);
            }
        } else {
            // include the page information
            m_properties.put(CmsTemplateBean.PARAM_URI, getRequestContext().getUri());
            include(CmsWorkplace.VFS_PATH_MODULES + MODULE_NAME + "/pages/imprint.html", "content", m_properties);
        }

        // close body and html
        out.print(getTemplateParts().includePart(elementName, "3", getLayout(), this));
    }

    /**
     * Returns the name of the website area specified in the common configuration file.<p>
     * 
     * If the name is not found, the title of the start folder is shown.<p>
     * 
     * @return the name of the website area
     */
    public String getAreaName() {

        String name = getConfigurationValue("area.name", null);
        if (name == null) {
            String startFolder = getStartFolder();
            name = property(CmsPropertyDefinition.PROPERTY_TITLE, startFolder, CmsResource.getName(startFolder));
        }
        return name;
    }

    /**
     * Returns the template configuration path in the OpenCms VFS.<p>
     * 
     * @return the template configuration path
     */
    public String getConfigPath() {

        return property(PROPERTY_CONFIGPATH, "search", "/");
    }

    /**
     * Returns the common configuration properties for the current web site area.<p>
     * 
     * @return the common configuration properties
     */
    public CmsXmlContent getConfiguration() {

        if (m_globalConfiguration == null) {
            m_globalConfiguration = getConfigurationFile(getConfigPath() + FILE_CONFIG_COMMON, getCmsObject());
        }
        return m_globalConfiguration;
    }

    /**
     * Returns the value for the specified property key name from the configuration.<p>
     * 
     * @param key the property key name to look up
     * @return the value for the specified property key name
     */
    public String getConfigurationValue(String key) {

        return getConfigurationValue(key, null);
    }

    /**
     * Returns the value for the specified property key name from the configuration.<p>
     * 
     * Returns the default value argument if the property is not found.<p>
     * 
     * @param key the property key name to look up
     * @param defaultValue a default value
     * @return the value for the specified property key name
     */
    public String getConfigurationValue(String key, String defaultValue) {

        String value = null;
        try {
            value = getConfiguration().getStringValue(null, key, getRequestContext().getLocale());
        } catch (Exception e) {
            // log error in debug mode
            if (LOG.isDebugEnabled()) {
                LOG.debug(e.getMessage(), e);
            }
        }
        if (CmsStringUtil.isEmpty(value)) {
            value = defaultValue;
        }
        return value;
    }

    /**
     * Returns the "Description" property value of the requested uri.<p>
     * 
     * @param defaultValue the default value used when the property was not found
     * @return the "Description" property value of the requested uri
     */
    public String getDescription(String defaultValue) {

        if (defaultValue == null) {
            defaultValue = "";
        }
        return property(CmsPropertyDefinition.PROPERTY_DESCRIPTION, "search", defaultValue);
    }

    /**
     * Returns the "content encoding" property value of the requested uri.<p>
     * 
     * @return the "content encoding" property value of the requested uri
     */
    public String getEncoding() {

        return property(
            CmsPropertyDefinition.PROPERTY_CONTENT_ENCODING,
            "search",
            OpenCms.getSystemInfo().getDefaultEncoding());
    }

    /**
     * Returns the file Uri of a module element to include.<p>
     * 
     * Checks the presence of an extension module and if the requested element is available.<p>
     * 
     * @param relFilePath the path of the element relative to the module folder, e.g. "elements/myelement.jsp"
     * @return the absolute uri of the module element to include
     */
    public String getExtensionModuleFileUri(String relFilePath) {

        String configModule = property(
            PROPERTY_EXTENSIONMODULE,
            CmsWorkplace.VFS_PATH_MODULES + MODULE_NAME,
            PROPERTY_VALUE_NONE);
        if (LOG.isDebugEnabled()) {
            LOG.debug(Messages.get().getBundle().key(Messages.LOG_EXT_MODULE_PROP_VALUE_1, configModule));
        }
        if (!PROPERTY_VALUE_NONE.equals(configModule)) {
            // extension module name found, check presence of file
            String fileName = CmsWorkplace.VFS_PATH_MODULES + configModule + "/" + relFilePath;
            try {
                getCmsObject().readResource(fileName);
                return fileName;
            } catch (CmsException e) {
                // file not found in extension module, use default file from template one module
                if (LOG.isDebugEnabled()) {
                    LOG.debug(Messages.get().getBundle().key(Messages.LOG_EXT_MODULE_FILE_NOT_FOUND_1, fileName));
                }
            }
        }
        return CmsWorkplace.VFS_PATH_MODULES + MODULE_NAME + "/" + relFilePath;
    }

    /**
     * Returns the URI of the editable head element or "none" if no element is specified.<p>
     * 
     * @return the URI of the editable head element or "none" if no element is specified
     */
    public String getHeadElementUri() {

        String elemUri = (String)getProperties().get(PROPERTY_HEAD_ELEMENTURI);
        if (CmsStringUtil.isEmptyOrWhitespaceOnly(elemUri)) {
            elemUri = PROPERTY_VALUE_NONE;
        }
        return elemUri;
    }

    /**
     * Returns the list of the head links.<p>
     * 
     * @return the list of head link objects
     */
    public List getHeadLinks() {

        List links = new ArrayList(10);
        // read links to display from configuration file
        String configFile = getConfigPath() + FILE_LINKS_HEAD;
        CmsXmlContent configuration = getConfigurationFile(configFile, getCmsObject());
        // this flag determines if the main link should be shown
        boolean showMainLink = true;
        if (configuration != null) {
            // configuration found, create link list
            Locale locale = getRequestContext().getLocale();
            int count = configuration.getIndexCount("Headlink", locale);
            for (int i = 1; i <= count; i++) {
                String prefix = "Headlink[" + i + "]";
                try {
                    String url = configuration.getStringValue(null, prefix + "/link.url", locale);
                    String text = configuration.getStringValue(null, prefix + "/link.text", locale);
                    String target = configuration.getStringValue(null, prefix + "/link.target", locale);
                    if (CmsStringUtil.isEmpty(url) || CmsStringUtil.isEmpty(text)) {
                        // values for link found in configuration file are not complete, stop loop
                        break;
                    }
                    if (url.startsWith("/")) {
                        // internal link
                        url = link(url);
                    }
                    CmsTemplateLink link = new CmsTemplateLink(url, text, target, i);
                    links.add(link);
                } catch (Exception e) {
                    // log error in debug mode
                    if (LOG.isDebugEnabled()) {
                        LOG.debug(e.getMessage(), e);
                    }
                }
                if (i == 10) {
                    // all 10 links were specified, do not show main link
                    showMainLink = false;
                }
            }
        }
        if (showMainLink) {
            // less than 10 links defined, main link should be shown
            String defaultLink = (String)m_properties.get(PROPERTY_HEAD_DEFAULTLINK);
            if (defaultLink != null && !PROPERTY_VALUE_NONE.equals(defaultLink)) {
                String url = defaultLink;
                String text = defaultLink;
                String target = "";
                int sepIndex = defaultLink.indexOf("|");
                try {
                    if (sepIndex != -1) {
                        url = defaultLink.substring(0, sepIndex);
                        text = defaultLink.substring(sepIndex + 1);
                        sepIndex = text.indexOf("|");
                        if (sepIndex != -1) {
                            target = text.substring(sepIndex + 1);
                            text = text.substring(0, sepIndex);
                        }
                    }
                    if (url.startsWith("/")) {
                        url = link(url);
                    }
                    // try to get localized version for found text
                    text = keyDefault(text, text);
                } catch (Exception e) {
                    // problem extracting information from property
                    if (LOG.isErrorEnabled()) {
                        LOG.error(e);
                    }
                }

                CmsTemplateLink link = new CmsTemplateLink(url, text, target, 0);
                links.add(link);
                // sort the list to show the main link first
                Collections.sort(links);
            }
        }
        return links;
    }

    /**
     * Returns the "Keywords" property value of the requested uri.<p>
     * 
     * @param defaultValue the default value used when the property was not found
     * @return the "Keywords" property value of the requested uri
     */
    public String getKeywords(String defaultValue) {

        if (defaultValue == null) {
            defaultValue = "";
        }
        return property(CmsPropertyDefinition.PROPERTY_KEYWORDS, "search", defaultValue);
    }

    /**
     * Returns the current layout to generate from the template.<p>
     * 
     * @return the current layout
     */
    public String getLayout() {

        return m_layout;
    }

    /**
     * Returns the left navigation include element uri property value.<p>
     * 
     * @return the left navigation include element uri property value
     */
    public String getLeftNavigationElementUri() {

        return property(PROPERTY_NAVLEFT_ELEMENTURI, "search", PROPERTY_VALUE_NONE);
    }

    /**
     * Returns the start folder for the navigation elements.<p>
     * 
     * @return the start folder for the navigation elements
     */
    public String getNavigationStartFolder() {

        String startFolder = getConfigurationValue("navigation.startfolder", null);
        if (startFolder == null) {
            return getStartFolder();
        } else {
            startFolder = getRequestContext().removeSiteRoot(startFolder);
        }
        return startFolder;
    }

⌨️ 快捷键说明

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