📄 cmsphotoalbumbean.java
字号:
result.append(">");
result.append(title);
result.append("</td>\n</tr>\n");
}
// show the navigation if configured position is top below text
result.append(buildHtmlImageNavigation(CmsPhotoAlbumConfiguration.NAVPOS_TOP_BELOW, photoIndex, photo));
// show image row
result.append("<tr>\n\t<td>");
// create the image
result.append("<img src=\"");
StringBuffer link = new StringBuffer(256);
link.append(resourceName);
link.append(getConfiguration().getDetailImageScaler().toRequestParam());
result.append(link(link.toString()));
result.append("\" border=\"0\" width=\"");
result.append(getConfiguration().getDetailImageScaler().getWidth());
result.append("\" height=\"");
result.append(getConfiguration().getDetailImageScaler().getHeight());
result.append("\" alt=\"");
result.append(title);
result.append("\" title=\"");
result.append(title);
result.append("\">");
result.append("</td>\n</tr>\n");
// show the navigation if configured position is bottom above text
result.append(buildHtmlImageNavigation(CmsPhotoAlbumConfiguration.NAVPOS_BOTTOM_ABOVE, photoIndex, photo));
// show the image description if configured and present
if (getConfiguration().showDetailDescription()) {
String description = property(CmsPropertyDefinition.PROPERTY_DESCRIPTION, resourceName, "");
if (CmsStringUtil.isNotEmptyOrWhitespaceOnly(description)) {
result.append("<tr>\n\t<td");
result.append(getStyle().getClassDetailImageDescription());
result.append(getConfiguration().getStyleAlignAttribute(getConfiguration().getDetailAlignTitle()));
result.append(">");
result.append(description);
result.append("</td>\n</tr>\n");
}
}
// show the navigation if configured position is bottom below text
result.append(buildHtmlImageNavigation(CmsPhotoAlbumConfiguration.NAVPOS_BOTTOM_BELOW, photoIndex, photo));
result.append("</table>");
return result.toString();
}
/**
* Returns the HTML to build a thumbnail overview page of the photo album.<p>
*
* @return the HTML to build a thumbnail overview page of the photo album
*/
protected String buildHtmlViewThumbNail() {
StringBuffer result = new StringBuffer(4096);
// determine photo indizes to display and the number of thumb rows
int startIndex = (getCurrentPage() - 1) * getPhotosPerPage();
int endIndex = 0;
int rowCount = getConfiguration().getThumbRows();
if (getConfiguration().showPageNavigation()) {
// navigation is shown, calculate end index
endIndex = (getCurrentPage() * getPhotosPerPage()) - 1;
if (endIndex > (getAlbumPhotos().size() - 1)) {
endIndex = getAlbumPhotos().size() - 1;
}
} else {
// all photos on one page
endIndex = getAlbumPhotos().size() - 1;
}
int photoCount = endIndex - startIndex + 1;
rowCount = photoCount / getConfiguration().getThumbCols();
if ((photoCount % getConfiguration().getThumbCols()) > 0) {
rowCount += 1;
}
// show the photo album title
result.append(buildHtmlAlbumTitle());
result.append("<table border=\"0\"");
result.append(getStyle().getClassThumbTable());
result.append(" width=\"");
result.append(getConfiguration().getThumbCols() * getConfiguration().getThumbNailScaler().getWidth());
result.append("\">\n");
// show the navigation if configured position is top above text
result.append(buildHtmlPageNavigation(CmsPhotoAlbumConfiguration.NAVPOS_TOP_ABOVE));
// show the top text if present
result.append(buildHtmlThumbTextRow(getConfiguration().getThumbTextTop()));
// show the navigation if configured position is top below text
result.append(buildHtmlPageNavigation(CmsPhotoAlbumConfiguration.NAVPOS_TOP_BELOW));
String styleAttr = getConfiguration().getStyleAlignAttribute(getConfiguration().getThumbAlignTitle());
int photoIndex = startIndex;
for (int i = 1; i <= rowCount; i++) {
// build the table thumbnail rows
result.append("<tr>\n");
for (int k = 1; k <= getConfiguration().getThumbCols(); k++) {
// build the tumbnail table data cell
result.append("\t<td width=\"");
result.append(getConfiguration().getThumbNailScaler().getWidth());
result.append("\"");
result.append(getStyle().getClassThumbImageTitle());
result.append(styleAttr);
result.append(">");
if (photoIndex <= endIndex) {
// current photo is in list range, show it
CmsResource photo = (CmsResource)getAlbumPhotos().get(photoIndex);
String resourceName = getCmsObject().getSitePath(photo);
String title = "";
if (getConfiguration().showResourceNameAsTitle()) {
title = CmsResource.getName(resourceName);
}
title = property(CmsPropertyDefinition.PROPERTY_TITLE, resourceName, title);
title = CmsEncoder.escapeXml(title);
// create the link to the detail view
result.append("<a href=\"");
StringBuffer link = new StringBuffer(256);
link.append(getRequestContext().getUri());
link.append("?");
link.append(PARAM_ACTION).append("=").append(VALUE_ACTION_DETAIL);
link.append("&").append(PARAM_IMAGE).append("=").append(photoIndex);
result.append(link(link.toString()));
result.append("\">");
// create the scaled thumbnail
result.append("<img src=\"");
link = new StringBuffer(256);
link.append(resourceName);
link.append(getConfiguration().getThumbNailScaler().toRequestParam());
result.append(link(link.toString()));
result.append("\" border=\"0\" width=\"");
result.append(getConfiguration().getThumbNailScaler().getWidth());
result.append("\" height=\"");
result.append(getConfiguration().getThumbNailScaler().getHeight());
result.append("\" alt=\"");
result.append(title);
result.append("\" title=\"");
result.append(title);
result.append("\">");
result.append("</a>");
if (getConfiguration().showThumbTitle() && CmsStringUtil.isNotEmptyOrWhitespaceOnly(title)) {
// show title below the thumbnail
result.append("<br clear=\"all\"><span");
result.append(getStyle().getClassThumbImageTitle());
result.append(">");
result.append(title);
result.append("</span>");
}
photoIndex++;
}
result.append("</td>\n");
}
result.append("</tr>\n");
}
// show the navigation if configured position is bottom above text
result.append(buildHtmlPageNavigation(CmsPhotoAlbumConfiguration.NAVPOS_BOTTOM_ABOVE));
// show the bottom text if present
result.append(buildHtmlThumbTextRow(getConfiguration().getThumbTextBottom()));
// show the navigation if configured position is bottom below text
result.append(buildHtmlPageNavigation(CmsPhotoAlbumConfiguration.NAVPOS_BOTTOM_BELOW));
result.append("</table>");
return result.toString();
}
/**
* Determines the necessary page information to build the navigation elements for the album pages.<p>
*
* Calculates the following values and stores them in members:
* <ul>
* <li>the number of photos to display on one overview page</li>
* <li>the current thumbnail page to show</li>
* <li>the number of pages to create to show all images of the selected gallery</li>
* </ul>
*/
protected void calculatePageData() {
if (getConfiguration().showPageNavigation()) {
// show page navigation, do calculations
setPhotosPerPage(getConfiguration().getThumbCols() * getConfiguration().getThumbRows());
int pageCount = getAlbumPhotos().size() / getPhotosPerPage();
if ((getAlbumPhotos().size() % getPhotosPerPage()) != 0) {
pageCount++;
}
setPageCount(pageCount);
// determine page to show
String page = getRequest().getParameter(PARAM_PAGE);
if (CmsStringUtil.isNotEmpty(page) && getPageCount() > 1) {
int currentPage = Integer.parseInt(page);
if (currentPage > getPageCount()) {
currentPage = getPageCount();
}
setCurrentPage(currentPage);
} else {
setCurrentPage(1);
}
} else {
// no navigation shown, set to default values
setPhotosPerPage(0);
setPageCount(1);
setCurrentPage(1);
}
}
/**
* Returns if the current navigation position to check is the configured position.<p>
*
* @param currentPosition the current navigation position to check
* @return true if the current navigation position to check is the configured position, otherwise false
*/
protected boolean checkNavigationPosition(String currentPosition) {
return getConfiguration().getNavigationPosition().indexOf(currentPosition) > -1;
}
/**
* Returns non breakable spaces (<code>&nbsp;</code>) as replacement for the given replace value.<p>
*
* @param replaceValue the value to replace with spaces
* @return non breakable spaces as replacement
*/
protected String fillNavSpaces(String replaceValue) {
int centerIndex = getConfiguration().getAlignNavigation().indexOf("center");
if (centerIndex > -1 && CmsStringUtil.isNotEmpty(replaceValue)) {
int length = replaceValue.length();
StringBuffer result = new StringBuffer(6 * length);
for (int i = 0; i < length; i++) {
result.append(" ");
}
return result.toString();
}
return "";
}
/**
* Returns the configuration errors that occured.<p>
*
* @return the configuration errors that occured
*/
protected List getConfigErrors() {
return m_configErrors;
}
/**
* Sets the configuration errors that occured.<p>
*
* @param configErrors the configuration errors that occured
*/
protected void setConfigErrors(List configErrors) {
m_configErrors = configErrors;
}
/**
* Sets the current page to display for the thumbnail view.<p>
*
* @param currentPage the current page to display for the thumbnail view
*/
protected void setCurrentPage(int currentPage) {
m_currentPage = currentPage;
}
/**
* Sets the display action to determine the view to generate.<p>
*
* @param displayAction the display action to determine the view to generate
*/
protected void setDisplayAction(int displayAction) {
m_displayAction = displayAction;
}
/**
* Sets the number of pages to display for the thumbnail view.<p>
*
* @param pageCount the number of pages to display for the thumbnail view
*/
protected void setPageCount(int pageCount) {
m_pageCount = pageCount;
}
/**
* Sets the number of photos to display on a single thumbnail overview page.<p>
*
* @param photosPerPage the number of photos to display on a single thumbnail overview page
*/
protected void setPhotosPerPage(int photosPerPage) {
m_photosPerPage = photosPerPage;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -