📄 cmsnewexplorerfilelist.java
字号:
/*
* File : $Source: /usr/local/cvs/opencms/src/com/opencms/workplace/Attic/CmsNewExplorerFileList.java,v $
* Date : $Date: 2003/03/04 17:30:10 $
* Version: $Revision: 1.61 $
*
* This library is part of OpenCms -
* the Open Source Content Mananagement System
*
* Copyright (C) 2001 The OpenCms Group
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* For further information about OpenCms, please see the
* OpenCms Website: http://www.opencms.org
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package com.opencms.workplace;
import com.opencms.boot.I_CmsLogChannels;
import com.opencms.core.A_OpenCms;
import com.opencms.core.CmsException;
import com.opencms.core.I_CmsConstants;
import com.opencms.core.I_CmsSession;
import com.opencms.file.CmsFolder;
import com.opencms.file.CmsObject;
import com.opencms.file.CmsRequestContext;
import com.opencms.file.CmsResource;
import com.opencms.file.I_CmsRegistry;
import com.opencms.flex.util.CmsMessages;
import com.opencms.launcher.I_CmsTemplateCache;
import com.opencms.template.CmsCacheDirectives;
import com.opencms.template.I_CmsDumpTemplate;
import com.opencms.template.cache.A_CmsElement;
import com.opencms.template.cache.CmsElementDump;
import com.opencms.util.Encoder;
import com.opencms.util.Utils;
import java.util.Hashtable;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.Vector;
/**
* Template class for dumping files to the output without further
* interpreting or processing.
* This can be used for plain text files or files containing graphics.
*
* @author Alexander Lucas
* @version $Revision: 1.61 $ $Date: 2003/03/04 17:30:10 $
*/
public class CmsNewExplorerFileList implements I_CmsDumpTemplate,I_CmsLogChannels,I_CmsConstants,I_CmsWpConstants {
/**
* This is the number of resources that are shown on one page.
* If a folder contains more than this we have to split the entrys
* to more than one page.
* TODO: set this in the user preferences, so that each user can select how many resources he wants to see at once
*/
private final static int C_ENTRYS_PER_PAGE = 50;
// the session key for the current page
private final static String C_SESSION_CURRENT_PAGE = "explorerFilelistCurrentPage";
/** Internal debugging flag */
public static final int DEBUG = 0;
public CmsNewExplorerFileList() {
}
/**
* gets the caching information from the current template class.
*
* @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 this class may stream it's results, <EM>false</EM> otherwise.
*/
public CmsCacheDirectives getCacheDirectives(CmsObject cms, String templateFile, String elementName, Hashtable parameters, String templateSelector) {
// First build our own cache directives.
return new CmsCacheDirectives(false);
}
/**
* Insert the method's description here.
* Creation date: (29.11.00 14:05:21)
* @return boolean
* @param cms com.opencms.file.CmsObject
* @param path java.lang.String
*/
private boolean folderExists(CmsObject cms, String path) {
try {
CmsFolder test = cms.readFolder(path);
if (test.isFile()){
return false;
}
}
catch(Exception e) {
return false;
}
return true;
}
/**
* Gets the content of a given template file.
*
* @param cms CmsObject Object for accessing system resources
* @param templateFile Filename of the template file
* @param elementName <em>not used here</em>.
* @param parameters <em>not used here</em>.
* @return Unprocessed content of the given template file.
* @throws CmsException
*/
public byte[] getContent(CmsObject cms, String templateFile, String elementName,
Hashtable parameters) throws CmsException {
if(A_OpenCms.isLogging(I_CmsLogChannels.C_OPENCMS_DEBUG) && I_CmsLogChannels.C_LOGGING && (DEBUG > 0)) {
A_OpenCms.log(C_OPENCMS_DEBUG, "[CmsDumpTemplate] Now dumping contents of file "
+ templateFile);
}
I_CmsSession session = cms.getRequestContext().getSession(true);
String lang = CmsXmlLanguageFile.getCurrentUserLanguage(cms);
CmsMessages messages = new CmsMessages("com.opencms.workplace.workplace", new Locale(lang, "", ""));
// get the right folder
String currentFolder = (String)parameters.get("folder");
if ((currentFolder != null) && (currentFolder.startsWith("vfslink:"))) {
// this is a link chck, remove the prefix
parameters.put("mode", "vfslink");
parameters.put("file", currentFolder.substring(8));
} else {
if((currentFolder != null) && (!"".equals(currentFolder)) &&
folderExists(cms, currentFolder)) {
session.putValue(C_PARA_FILELIST, currentFolder);
}else {
currentFolder = (String)session.getValue(C_PARA_FILELIST);
if((currentFolder == null) || (!folderExists(cms, currentFolder))) {
currentFolder = cms.rootFolder().getAbsolutePath();
session.putValue(C_PARA_FILELIST, currentFolder);
}
}
}
String mode = (String)parameters.get("mode");
// if the parameter mode=listonly is set, only the list will be shown
boolean listonly = "listonly".equals(mode);
// if the parameter mode=projectview is set, all changed files in that project will be shown
boolean projectView = "projectview".equals(mode);
// if the parameter mode=vfslinks is set, the links to a target file will be shown
boolean vfslinkView = "vfslink".equals(mode);
if (vfslinkView) {
String file = (String)parameters.get("file");
boolean found = true;
try {
cms.readFileHeader(file);
} catch (CmsException e) {
// file was not readable
found = false;
}
if (found) {
// file / folder exists and is readable
currentFolder = "vfslink:" + file;
} else {
// show the root folder in case of an error and reset the state
currentFolder = cms.rootFolder().getAbsolutePath();
vfslinkView = false;
parameters.remove("mode");
}
session.putValue(C_PARA_FILELIST, currentFolder);
}
if (DEBUG > 2) {
// output parameters
System.err.println("[" + System.currentTimeMillis() + "] CmsNewExplorerFileList.getContent() called");
System.err.println("templateFile=" + templateFile);
System.err.println("elementName=" + elementName);
Iterator i = parameters.keySet().iterator();
while (i.hasNext()){
String key = (String)i.next();
System.err.println("parameters: key=" + key + " value=" + parameters.get(key));
}
System.err.println();
}
boolean noKontext = "false".equals(parameters.get("kontext"));
// the flaturl to use for changing folders
String flaturl = (String) parameters.get("flaturl");
// get the checksum
String checksum = (String)parameters.get("check");
boolean newTreePlease = true;
long check = -1;
try {
check = Long.parseLong(checksum);
if(check == cms.getFileSystemFolderChanges()) {
newTreePlease = false;
}
}catch(Exception e) {
}
check = cms.getFileSystemFolderChanges();
// get the currentFolder Id
int currentFolderId;
if (! vfslinkView) {
currentFolderId = (cms.readFolder(currentFolder)).getResourceId();
} else {
currentFolderId = -1;
}
// start creating content
StringBuffer content = new StringBuffer(2048);
content.append("<html> \n<head> \n");
content.append("<META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=");
content.append(cms.getRequestContext().getEncoding());
content.append("\">\n");
content.append("<script language=JavaScript>\n");
content.append("function initialize() {\n");
if(listonly) {
content.append("top.openfolderMethod='openthisfolderflat';\n");
} else {
content.append("top.openfolderMethod='openthisfolder';\n");
}
if(projectView || vfslinkView) {
content.append("top.projectView=true;\n");
} else {
content.append("top.projectView=false;\n");
}
// show kontext
if(noKontext) {
content.append("top.showKon=false;\n");
} else {
content.append("top.showKon=true;\n");
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -