📄 cmstemplatebean.java
字号:
m_showHeadNavigation = !showPrintVersion()
&& Boolean.valueOf(property(PROPERTY_SHOW_HEADNAV, "search", CmsStringUtil.TRUE)).booleanValue();
}
}
/**
* Gets the localized resource string for a given message key.<p>
*
* If the key was not found in the bundle, the return value is
* <code>"??? " + keyName + " ???"</code>. This will also be returned
* if the bundle was not properly initialized first.
*
* @param keyName the key for the desired string
* @return the resource string for the given key
*
* @see CmsMessages#key(String)
*/
public String key(String keyName) {
return messages().key(keyName);
}
/**
* Returns the localized resource string for a given message key.<p>
*
* If the key was not found in the bundle, the provided default value
* is returned.<p>
*
* @param keyName the key for the desired string
* @param defaultValue the default value in case the key does not exist in the bundle
* @return the resource string for the given key it it exists, or the given default if not
*
* @see CmsMessages#keyDefault(String, String)
*/
public String keyDefault(String keyName, String defaultValue) {
return messages().keyDefault(keyName, defaultValue);
}
/**
* Returns the initialized CmsMessages object to use on the JSP template.<p>
*
* @return the initialized CmsMessages object
*/
public CmsMessages messages() {
if (m_messages == null) {
messages(MESSAGE_BUNDLE);
}
return m_messages;
}
/**
* Returns the initialized CmsMessages object to use on the JSP template.<p>
*
* @param bundleName the name of the ResourceBundle to use
* @return the initialized CmsMessages object
*/
public CmsMessages messages(String bundleName) {
if (m_messages == null) {
m_messages = new CmsMessages(bundleName, getRequestContext().getLocale());
}
return m_messages;
}
/**
* Puts the information needed to build the navigation elements to the property map.<p>
*/
public void putNavigationProperties() {
// fill property Map with necessary parameters for included navigation elements
getProperties().put(PARAM_SITE, getRequestContext().getSiteRoot());
getProperties().put(PARAM_ACCESSIBLE, "" + showAccessibleVersion());
getProperties().put(CmsTemplateNavigation.PARAM_RESPATH, getResourcePath());
getProperties().put(CmsTemplateNavigation.PARAM_STARTFOLDER, getStartFolder());
getProperties().put(CmsTemplateNavigation.PARAM_HEADNAV_FOLDER, getNavigationStartFolder());
getProperties().put(
CmsTemplateNavigation.PARAM_HEADNAV_IMAGES,
getConfigurationValue("headnav.images", CmsStringUtil.FALSE));
getProperties().put(
CmsTemplateNavigation.PARAM_HEADNAV_MANUAL,
getConfigurationValue("headnav.manual", CmsStringUtil.FALSE));
getProperties().put(
CmsTemplateNavigation.PARAM_HEADNAV_MARKCURRENT,
getConfigurationValue("headnav.markcurrent", CmsStringUtil.FALSE));
getProperties().put(
CmsTemplateNavigation.PARAM_HEADNAV_MENUDEPTH,
getConfigurationValue("headnav.menudepth", "1"));
getProperties().put(
CmsTemplateNavigation.PARAM_HEADNAV_MENUCLICK,
getConfigurationValue("headnav.menuclick", CmsStringUtil.FALSE));
getProperties().put(
CmsTemplateNavigation.PARAM_SHOWMENUS,
getConfigurationValue("headnav.menus", CmsStringUtil.TRUE));
getProperties().put(
CmsTemplateNavigation.PARAM_NAVLEFT_SHOWSELECTED,
getConfigurationValue("navleft.showselected", CmsStringUtil.FALSE));
getProperties().put(CmsTemplateNavigation.PARAM_NAVLEFT_SHOWTREE, "" + showLeftNavigation());
getProperties().put(CmsTemplateNavigation.PARAM_NAVLEFT_ELEMENTURI, getLeftNavigationElementUri());
}
/**
* Sets the current layout to generate from the template.<p>
*
* @param layout the current layout to generate
*/
public void setLayout(String layout) {
m_layout = layout;
}
/**
* Returns if the accessible version of the page should be shown.<p>
*
* @return true if the accessible version should be shown, otherwise false
*/
public boolean showAccessibleVersion() {
return m_showAccessibleVersion;
}
/**
* Returns if the head image should be shown.<p>
*
* @return true if the head image should be shown, otherwise false
*/
public boolean showHeadImage() {
return Boolean.valueOf(property(PROPERTY_SHOWHEADIMAGE, "search", CmsStringUtil.TRUE)).booleanValue();
}
/**
* Returns if the head links should be shown.<p>
*
* @return true if the head links should be shown, otherwise false
*/
public boolean showHeadLinks() {
return Boolean.valueOf(property(PROPERTY_SHOWHEADLINKS, "search", CmsStringUtil.TRUE)).booleanValue();
}
/**
* Returns if the head navigation menu should be shown.<p>
*
* @return true if the head navigation menu should be shown, otherwise false
*/
public boolean showHeadNavigation() {
return m_showHeadNavigation;
}
/**
* Returns if the left navigation menu should be shown.<p>
*
* @return true if the left navigation menu should be shown, otherwise false
*/
public boolean showLeftNavigation() {
return Boolean.valueOf(property(PROPERTY_SHOW_NAVLEFT, "search", CmsStringUtil.TRUE)).booleanValue();
}
/**
* Returns if the print version of the page should be created.<p>
*
* @return true if the print version should be created, otherwise false
*/
public boolean showPrintVersion() {
return m_showPrintVersion;
}
/**
* Returns a list of content list item objects which are needed to display lists on the side and in the center of the page.<p>
*
* @param configFile the configuration file uri from which to read the properties from
* @param displayArea the area where to build the lists (left, center or right)
* @return a list of content list items
*/
private List getContentListItems(String configFile, String displayArea) {
List result = new ArrayList();
// read all properties of configuration file
Map properties = properties(configFile);
int i = 1;
boolean cont = true;
do {
// create a list item
CmsTemplateContentListItem item = CmsTemplateContentListItem.newInstance(
getListDefaults(),
properties,
getStartFolder(),
displayArea,
i);
if (item == null) {
// no item created, stop loop
cont = false;
} else {
// add created item to result
result.add(item);
i++;
}
} while (cont);
return result;
}
/**
* Gets the default list configuration values from the workplace messages.<p>
*
* @return the default list configuration values from the workplace messages
*/
private Map getListDefaults() {
if (m_listDefaults == null) {
CmsMessages messages = OpenCms.getWorkplaceManager().getMessages(getRequestContext().getLocale());
m_listDefaults = CmsTemplateContentListItem.getDefaultValuesFromMessages(messages);
}
return m_listDefaults;
}
/**
* Includes one row of page elements.<p>
*
* Builds a row with one element spanning the row or
* with two elements in different cells depending on the
* presence of the elements.<p>
*
* @param elementLeft the name of the left element to show
* @param elementRight the name of the right element to show
* @param out the Writer to write the output to
* @throws IOException if writing the output fails
* @throws JspException if including an element fails
*/
private void includeContentRow(String elementLeft, String elementRight, JspWriter out)
throws IOException, JspException {
if (template(elementLeft + "," + elementRight, false)) {
// at least one element is present, create row (common layout only)
String elementName = FOLDER_ELEMENTS + "elements.jsp";
out.print(getTemplateParts().includePart(elementName, "column_start", getLayout(), this));
if (template(elementLeft, true)) {
// left element is present
if (template(elementRight, true)) {
// right element is present, too
out.print(getTemplateParts().includePart(elementName, "element_start_2", getLayout(), this));
} else {
// no right element
out.print(getTemplateParts().includePart(elementName, "element_start_1", getLayout(), this));
}
include(null, elementLeft, true);
out.print(getTemplateParts().includePart(elementName, "element_end", getLayout(), this));
}
if (template(elementRight, true)) {
// right element is present
if (template(elementLeft, true)) {
// left element is present, too
out.print(getTemplateParts().includePart(elementName, "element_start_2", getLayout(), this));
} else {
// no left element
out.print(getTemplateParts().includePart(elementName, "element_start_1", getLayout(), this));
}
include(null, elementRight, true);
out.print(getTemplateParts().includePart(elementName, "element_end", getLayout(), this));
}
// close row (common layout only)
out.print(getTemplateParts().includePart(elementName, "column_end", getLayout(), this));
}
}
/**
* Initializes the page layout parameters to determine which version to show.<p>
*
* It is possible to display the common version, an accessible version and
* a print version of a page.<p>
*/
private void initPageVersion() {
// check if the print version should be shown
m_showPrintVersion = Boolean.valueOf(getRequest().getParameter(PARAM_PRINT)).booleanValue();
if (!showPrintVersion()) {
// check if the accessible page layout should be used
String param = getRequest().getParameter(PARAM_ACCESSIBLE);
if (CmsStringUtil.isNotEmpty(param)) {
m_showAccessibleVersion = Boolean.valueOf(param).booleanValue();
} else {
m_showAccessibleVersion = getConfigurationValue("layout.version", PARAM_COMMON).equals(PARAM_ACCESSIBLE);
}
if (showAccessibleVersion()) {
setLayout(PARAM_ACCESSIBLE);
} else {
setLayout(PARAM_COMMON);
}
} else {
setLayout(PARAM_PRINT);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -