cmsadmindowngalleries.java
来自「java 编写的程序」· Java 代码 · 共 374 行 · 第 1/2 页
JAVA
374 行
}
if(filecontent != null) {
session.putValue(C_PARA_FILECONTENT, filecontent);
}
filecontent = (byte[])session.getValue(C_PARA_FILECONTENT);
if("0".equals(step)) {
templateSelector = "";
}
else {
if("1".equals(step)) {
// display the select filetype screen
if(filename != null) {
// check if the file size is 0
if(filecontent.length == 0) {
templateSelector = "error";
xmlTemplateDocument.setData("details", filename);
}
else {
xmlTemplateDocument.setData("MIME", filename);
xmlTemplateDocument.setData("SIZE", "Not yet available");
xmlTemplateDocument.setData("FILESIZE", new Integer(filecontent.length).toString() + " Bytes");
xmlTemplateDocument.setData("FILENAME", filename);
templateSelector = "step1";
}
}
}
else {
if("2".equals(step)) {
// check if a new filename is given
if(newname != null) {
filename = newname;
}
CmsFile file = cms.createFile(foldername, filename, filecontent, C_TYPE_PLAIN_NAME);
if(title != null) {
String filepath = file.getAbsolutePath();
cms.writeProperty(filepath, C_PROPERTY_TITLE, title);
}
try {
cms.getRequestContext().getResponse().sendCmsRedirect(getConfigFile(cms).getWorkplaceActionPath() + lasturl);
}
catch(Exception ex) {
throw new CmsException("Redirect fails :" + getConfigFile(cms).getWorkplaceActionPath()
+ lasturl, CmsException.C_UNKNOWN_EXCEPTION, ex);
}
}
}
}
}
}
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_download.gif");
filelistTemplate.setData(C_FILELIST_NAME_VALUE, res.getName());
String title = cms.readProperty(res.getAbsolutePath(), C_PROPERTY_TITLE);
filelistTemplate.setData(C_FILELIST_TITLE_VALUE, 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).getDownGalleryPath());
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 + -
显示快捷键?