cmsadminpicgalleries.java
来自「java 编写的程序」· Java 代码 · 共 433 行 · 第 1/2 页
JAVA
433 行
if(unzip != null) {
// try to unzip the file here ...
CmsImportFolder zip = new CmsImportFolder(
filecontent, foldername, cms, true);
if( zip.isValidZipFile() ) {
// remove the values form the session
session.removeValue(C_PARA_FILE);
session.removeValue(C_PARA_FILECONTENT);
session.removeValue(C_PARA_NEWTYPE);
session.removeValue("unzip");
// return to the filelist
try {
if((lasturl != null) && (lasturl != "")) {
cms.getRequestContext().getResponse().sendRedirect(lasturl);
}
else {
cms.getRequestContext().getResponse().sendCmsRedirect(
getConfigFile(cms).getWorkplaceActionPath() + C_WP_EXPLORER_FILELIST);
}
} catch(Exception ex) {
throw new CmsException(
"Redirect fails :" + getConfigFile(cms).getWorkplaceActionPath()
+ C_WP_EXPLORER_FILELIST, CmsException.C_UNKNOWN_EXCEPTION, ex);
}
return null;
}
} // else, zip was not valid, so continue ...
xmlTemplateDocument.setData("MIME", filename);
xmlTemplateDocument.setData("SIZE", "Not yet available");
xmlTemplateDocument.setData("FILESIZE",
new Integer(filecontent.length).toString() + " Bytes");
xmlTemplateDocument.setData("FILENAME", filename);
xmlTemplateDocument.setData("IMAGEDESCRIPTION",imagedescription);
templateSelector = "step1";
}
}
}
else {
if("2".equals(step)) {
// check if a new filename is given
if(newname != null) {
filename = newname;
}
try {
CmsFile file = cms.createFile(foldername, filename,
filecontent, C_TYPE_IMAGE_NAME);
if(title != null) {
String filepath = file.getAbsolutePath();
cms.writeProperty(filepath, C_PROPERTY_TITLE, title);
}
if(imagedescription != null) {
String filepath = file.getAbsolutePath();
cms.writeProperty(filepath, C_PROPERTY_DESCRIPTION, imagedescription);
}
}
catch(CmsException ex) {
xmlTemplateDocument.setData("details", Utils.getStackTrace(ex));
templateSelector = "error";
xmlTemplateDocument.setData("link_value", foldername);
xmlTemplateDocument.setData("lasturl", lasturl);
return startProcessing(cms, xmlTemplateDocument, elementName,
parameters, templateSelector);
}
try {
cms.getRequestContext().getResponse().sendRedirect(lasturl);
}
catch(Exception ex) {
throw new CmsException("Redirect fails :" + getConfigFile(cms).getWorkplaceActionPath() +
lasturl, CmsException.C_UNKNOWN_EXCEPTION, ex);
}
return null;
}
}
}
}
}
xmlTemplateDocument.setData("link_value", foldername);
xmlTemplateDocument.setData("lasturl", lasturl);
// Finally start the processing
return startProcessing(cms, xmlTemplateDocument, elementName, parameters,
templateSelector);
}
/**
* From interface <code>I_CmsFileListUsers</code>.
* <P>
* Fills all customized columns with the appropriate settings for the given file
* list entry. Any column filled by this method may be used in the customized template
* for the file list.
* @param cms Cms object for accessing system resources.
* @param filelist Template file containing the definitions for the file list together with
* the included customized defintions.
* @param res CmsResource Object of the current file list entry.
* @param lang Current language file.
* @exception CmsException if access to system resources failed.
* @see I_CmsFileListUsers
*/
public void getCustomizedColumnValues(CmsObject cms, CmsXmlWpTemplateFile filelistTemplate,
CmsResource res, CmsXmlLanguageFile lang) throws CmsException {
CmsXmlWpConfigFile config = this.getConfigFile(cms);
filelistTemplate.fastSetXmlData(C_FILELIST_ICON_VALUE, cms.getRequestContext().getRequest().getServletUrl() + config.getWpPicturePath()
+ "ic_file_picgallery.gif" );
filelistTemplate.setData(C_FILELIST_NAME_VALUE, res.getName());
filelistTemplate.setData(C_FILELIST_TITLE_VALUE, cms.readProperty(res.getAbsolutePath(),
C_PROPERTY_TITLE));
}
/**
* From interface <code>I_CmsFileListUsers</code>.
* <P>
* Collects all folders and files that are displayed in the file list.
* @param cms The CmsObject.
* @return A vector of folder and file objects.
* @exception Throws CmsException if something goes wrong.
*/
public Vector getFiles(CmsObject cms) throws CmsException {
Vector galleries = new Vector();
Vector folders = cms.getSubFolders(getConfigFile(cms).getPicGalleryPath());
int numFolders = folders.size();
for(int i = 0;i < numFolders;i++) {
CmsResource currFolder = (CmsResource)folders.elementAt(i);
galleries.addElement(currFolder);
}
return galleries;
}
/**
* Gets all groups for a select box
* <P>
* The given vectors <code>names</code> and <code>values</code> will
* be filled with the appropriate information to be used for building
* a select box.
*
* @param cms CmsObject Object for accessing system resources.
* @param names Vector to be filled with the appropriate values in this method.
* @param values Vector to be filled with the appropriate values in this method.
* @param parameters Hashtable containing all user parameters <em>(not used here)</em>.
* @return Index representing the current value in the vectors.
* @exception CmsException
*/
public Integer getGroups(CmsObject cms, CmsXmlLanguageFile lang, Vector names,
Vector values, Hashtable parameters) throws CmsException {
// get all groups
Vector groups = cms.getGroups();
int retValue = 0;
// fill the names and values
String prompt = lang.getDataValue("input.promptgroup");
names.addElement(prompt);
values.addElement("Aufforderung"); // without significance for the user
for(int z = 0;z < groups.size();z++) {
String name = ((CmsGroup)groups.elementAt(z)).getName();
if(! C_GROUP_GUEST.equals(name)){
names.addElement(name);
values.addElement(name);
}
}
return new Integer(retValue);
}
/**
* Indicates if the results of this class are cacheable.
*
* @param cms CmsObject Object for accessing system resources
* @param templateFile Filename of the template file
* @param elementName Element name of this template in our parent template.
* @param parameters Hashtable with all template class parameters.
* @param templateSelector template section that should be processed.
* @return <EM>true</EM> if cacheable, <EM>false</EM> otherwise.
*/
public boolean isCacheable(CmsObject cms, String templateFile, String elementName,
Hashtable parameters, String templateSelector) {
return false;
}
/**
* From interface <code>I_CmsFileListUsers</code>.
* <P>
* Used to modify the bit pattern for hiding and showing columns in
* the file list.
* @param cms Cms object for accessing system resources.
* @param prefs Old bit pattern.
* @return New modified bit pattern.
* @see I_CmsFileListUsers
*/
public int modifyDisplayedColumns(CmsObject cms, int prefs) {
prefs = ((prefs & C_FILELIST_NAME) == 0) ? prefs : (prefs - C_FILELIST_NAME);
prefs = ((prefs & C_FILELIST_TITLE) == 0) ? prefs : (prefs - C_FILELIST_TITLE);
prefs = ((prefs & C_FILELIST_TYPE) == 0) ? prefs : (prefs - C_FILELIST_TYPE);
prefs = ((prefs & C_FILELIST_SIZE) == 0) ? prefs : (prefs - C_FILELIST_SIZE);
return prefs;
}
public Object onLoad(CmsObject cms, String tagcontent, A_CmsXmlContent doc, Object userObj) throws CmsException {
Hashtable parameters = (Hashtable) userObj;
String folder = (String)parameters.get("folder");
if(folder != null) {
String servletUrl = cms.getRequestContext().getRequest().getServletUrl() + "/";
return "window.top.body.admin_content.location.href='" + servletUrl + "system/workplace/action/explorer_files.html?mode=listonly&folder=" + folder + "'";
} else {
return "";
}
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?