📄 cmsphotoalbumbean.java
字号:
m_configuration = configuration;
}
/**
* Sets the CSS style object that is used to format the photo album output.<p>
*
* @param style the CSS style object that is used to format the photo album output
*/
public void setStyle(CmsPhotoAlbumStyle style) {
m_style = style;
}
/**
* Adds an error to the list of configuration errors.<p>
*
* @param configError error to add to the list of configuration errors
*/
protected void addConfigError(String configError) {
m_configErrors.add(configError);
}
/**
* Returns the HTML for the photo album title.<p>
*
* @return the HTML for the photo album title
*/
protected String buildHtmlAlbumTitle() {
if (CmsStringUtil.isNotEmptyOrWhitespaceOnly(getConfiguration().getAlbumTitle())) {
// show the title
StringBuffer result = new StringBuffer(128);
result.append("<h1");
result.append(getStyle().getClassPageTitle());
result.append(">");
result.append(getConfiguration().getAlbumTitle());
result.append("</h1>\n");
return result.toString();
}
return "";
}
/**
* Writes the HTML for the configuration error output.<p>
*
* Writes the found configuration errors directly to the JSP writer.<p>
*
* @throws IOException if writing the output fails
*/
protected void buildHtmlConfigurationErrors() throws IOException {
if (!getRequestContext().currentProject().isOnlineProject() && getConfigErrors().size() > 0) {
// configuration error(s) found, show them in offline projects
getJspContext().getOut().print("<h1>");
getJspContext().getOut().print(m_messages.key(Messages.GUI_CONFIG_ERRORS_HEADLINE_0));
getJspContext().getOut().print("</h1>");
getJspContext().getOut().print("<p>");
// loop error messages
for (int i = 0; i < getConfigErrors().size(); i++) {
if (i > 0) {
getJspContext().getOut().println("<br>");
}
getJspContext().getOut().print(getConfigErrors().get(i));
}
getJspContext().getOut().print("</p>");
}
}
/**
* Returns the HTML for the image navigation on the photo album detail page.<p>
*
* @param currentNavigationPosition the current navigation position to display the navigation
* @param photoIndex the index of the photo to display
* @param photo the photo to display as CmsResource object
* @return the HTML for the image navigation on the photo album detail page
*/
protected String buildHtmlImageNavigation(String currentNavigationPosition, int photoIndex, CmsResource photo) {
if (!checkNavigationPosition(currentNavigationPosition)) {
// wrong position to insert the navigation elements, do not show navigation at this position
return "";
}
StringBuffer result = new StringBuffer(1024);
StringBuffer link = new StringBuffer(256);
result.append("<tr>\n\t<td");
result.append(getStyle().getClassNavigation());
result.append(getConfiguration().getStyleAlignAttribute(getConfiguration().getAlignNavigation()));
result.append(">");
if (photoIndex > 0) {
// build the "Back" link
result.append("<a");
result.append(getStyle().getClassLink());
result.append(" href=\"");
link.append(getRequestContext().getUri());
link.append("?");
link.append(PARAM_ACTION).append("=").append(VALUE_ACTION_DETAIL);
link.append("&");
link.append(PARAM_IMAGE).append("=").append(photoIndex - 1);
result.append(link(link.toString()));
result.append("\">");
result.append(m_messages.key(Messages.GUI_NAVIGATION_BACK_0));
result.append("</a>");
result.append(" - ");
} else {
result.append(fillNavSpaces(m_messages.key(Messages.GUI_NAVIGATION_BACK_0) + " - "));
}
// build the image index information
Object[] args = new Object[] {new Integer(photoIndex + 1), new Integer(getAlbumPhotos().size())};
result.append(m_messages.key(Messages.GUI_DETAIL_IMAGEINFO_2, args));
if (photoIndex < (getAlbumPhotos().size() - 1)) {
// build the "Next" link
result.append(" - ");
result.append("<a");
result.append(getStyle().getClassLink());
result.append(" href=\"");
link = new StringBuffer(256);
link.append(getRequestContext().getUri());
link.append("?");
link.append(PARAM_ACTION).append("=").append(VALUE_ACTION_DETAIL);
link.append("&");
link.append(PARAM_IMAGE).append("=").append(photoIndex + 1);
result.append(link(link.toString()));
result.append("\">");
result.append(m_messages.key(Messages.GUI_NAVIGATION_NEXT_0));
result.append("</a>");
} else {
result.append(fillNavSpaces(" - " + m_messages.key(Messages.GUI_NAVIGATION_NEXT_0)));
}
result.append("<br>");
// build the link to the thumbnail overview
int thumbPage = 1;
if (getConfiguration().showPageNavigation()) {
// calculate the page to show
thumbPage = (photoIndex / getPhotosPerPage()) + 1;
}
result.append("<a");
result.append(getStyle().getClassLink());
result.append(" href=\"");
link = new StringBuffer(256);
link.append(getRequestContext().getUri());
link.append("?");
link.append(PARAM_ACTION).append("=").append(VALUE_ACTION_THUMBNAIL);
link.append("&");
link.append(PARAM_PAGE).append("=").append(thumbPage);
result.append(link(link.toString()));
result.append("\">");
result.append(m_messages.key(Messages.GUI_NAVIGATION_OVERVIEW_0));
result.append("</a>");
// build the link to the original image if configured
if (getConfiguration().showDetailOriginalLink()) {
result.append(" - <a");
result.append(getStyle().getClassLink());
result.append(" href=\"");
result.append(link(getCmsObject().getSitePath(photo)));
result.append("\" target=\"originalphoto\">");
result.append(m_messages.key(Messages.GUI_NAVIGATION_ORIGINAL_0));
result.append("</a>");
}
result.append("</td>\n</tr>\n");
return result.toString();
}
/**
* Returns the HTML for the page navigation on the thumbnail overview pages.<p>
*
* @param currentNavigationPosition the current navigation position to display the navigation
* @return the HTML for the page navigation on the thumbnail overview pages
*/
protected String buildHtmlPageNavigation(String currentNavigationPosition) {
if (!checkNavigationPosition(currentNavigationPosition)) {
// wrong position to insert the navigation elements, do not show navigation at this position
return "";
}
StringBuffer result = new StringBuffer(1024);
if (getConfiguration().showPageNavigation() && getPageCount() > 1) {
// show navigation and number of pages greater than 1
result.append("<tr>\n\t<td colspan=\"");
result.append(getConfiguration().getThumbCols());
result.append("\"");
result.append(getStyle().getClassNavigation());
result.append(getConfiguration().getStyleAlignAttribute(getConfiguration().getAlignNavigation()));
result.append(">");
StringBuffer link = new StringBuffer(256);
if (getCurrentPage() > 1) {
// build the "Back" link
result.append("<a");
result.append(getStyle().getClassLink());
result.append(" href=\"");
link.append(getRequestContext().getUri());
link.append("?");
link.append(PARAM_ACTION).append("=").append(VALUE_ACTION_THUMBNAIL);
link.append("&");
link.append(PARAM_PAGE).append("=").append(getCurrentPage() - 1);
result.append(link(link.toString()));
result.append("\">");
result.append(m_messages.key(Messages.GUI_NAVIGATION_BACK_0));
result.append("</a>");
result.append(" - ");
} else {
result.append(fillNavSpaces(m_messages.key(Messages.GUI_NAVIGATION_BACK_0) + " - "));
}
// build the page index information
result.append(m_messages.key(Messages.GUI_THUMB_PAGEINFO_2, new Integer(getCurrentPage()), new Integer(
getPageCount())));
if (getCurrentPage() < getPageCount()) {
// build the "Next" link
result.append(" - ");
result.append("<a class=\"");
result.append(getStyle().getClassLink());
result.append("\" href=\"");
link = new StringBuffer(256);
link.append(getRequestContext().getUri());
link.append("?");
link.append(PARAM_ACTION).append("=").append(VALUE_ACTION_THUMBNAIL);
link.append("&");
link.append(PARAM_PAGE).append("=").append(getCurrentPage() + 1);
result.append(link(link.toString()));
result.append("\">");
result.append(m_messages.key(Messages.GUI_NAVIGATION_NEXT_0));
result.append("</a>");
} else {
result.append(fillNavSpaces(" - " + m_messages.key(Messages.GUI_NAVIGATION_NEXT_0)));
}
result.append("</td>\n</tr>\n");
}
return result.toString();
}
/**
* Returns the HTML for a text row on the thumbnail overview page of the photo album.<p>
*
* @param text the text to display in the row
* @return the HTML for a text row on the thumbnail overview page of the photo album
*/
protected String buildHtmlThumbTextRow(String text) {
if (CmsStringUtil.isNotEmptyOrWhitespaceOnly(text)) {
StringBuffer result = new StringBuffer(2048);
result.append("<tr>\n\t<td colspan=\"");
result.append(getConfiguration().getThumbCols());
result.append("\"");
result.append(getStyle().getClassThumbText());
result.append(">");
result.append(text);
result.append("</td>\n</tr>\n");
return result.toString();
}
return "";
}
/**
* Returns the HTML to build the detail view of a selected photo album image.<p>
*
* @return the HTML to build the detail view of a selected photo album image
*/
protected String buildHtmlViewDetail() {
StringBuffer result = new StringBuffer(4096);
//show the photo gallery title
result.append(buildHtmlAlbumTitle());
// get the photo index number to show
String indexParam = getRequest().getParameter(PARAM_IMAGE);
int photoIndex = 0;
if (CmsStringUtil.isNotEmpty(indexParam)) {
// check the index parameter and set it to valid value if necessary
photoIndex = Integer.parseInt(indexParam);
if (photoIndex > (getAlbumPhotos().size() - 1)) {
photoIndex = getAlbumPhotos().size() - 1;
}
}
// get the photo to show
CmsResource photo = (CmsResource)getAlbumPhotos().get(photoIndex);
String resourceName = getCmsObject().getSitePath(photo);
// determine the photo title
String title = "";
if (getConfiguration().showResourceNameAsTitle()) {
title = CmsResource.getName(resourceName);
}
title = property(CmsPropertyDefinition.PROPERTY_TITLE, resourceName, title);
title = CmsEncoder.escapeXml(title);
result.append("<table border=\"0\"");
result.append(getStyle().getClassThumbTable());
result.append(" width=\"");
result.append(getConfiguration().getDetailImageScaler().getWidth());
result.append("\">\n");
// show the navigation if configured position is top above text
result.append(buildHtmlImageNavigation(CmsPhotoAlbumConfiguration.NAVPOS_TOP_ABOVE, photoIndex, photo));
// show the image title if configured
if (getConfiguration().showDetailTitle() && CmsStringUtil.isNotEmptyOrWhitespaceOnly(title)) {
result.append("<tr>\n\t<td");
result.append(getStyle().getClassDetailImageTitle());
result.append(getConfiguration().getStyleAlignAttribute(getConfiguration().getDetailAlignTitle()));
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -