📄 cmsexplorertree.java
字号:
/*
* File : $Source: /usr/local/cvs/opencms/src/com/opencms/workplace/CmsExplorerTree.java,v $
* Date : $Date: 2003/02/02 15:59:52 $
* Version: $Revision: 1.17 $
*
* 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.core.CmsException;
import com.opencms.core.I_CmsSession;
import com.opencms.file.CmsFolder;
import com.opencms.file.CmsGroup;
import com.opencms.file.CmsObject;
import com.opencms.file.CmsResource;
import com.opencms.template.A_CmsXmlContent;
import com.opencms.util.Encoder;
import java.util.Enumeration;
import java.util.Hashtable;
import java.util.Vector;
/**
* Template class for displaying the folder tree of the OpenCms workplace.<P>
* Reads template files of the content type <code>CmsXmlWpTemplateFile</code>.
*
*
* @author Michael Emmerich
* @version $Revision: 1.17 $ $Date: 2003/02/02 15:59:52 $
*/
public class CmsExplorerTree extends CmsWorkplaceDefault implements I_CmsWpConstants {
/** Definition of the Datablock TREELINK */
private static final String C_TREELINK = "TREELINK";
/** Definition of the Datablock TREESTYLE */
private static final String C_TREESTYLE = "TREESTYLE";
/** Definition of the Datablock TREETAB */
private static final String C_TREETAB = "TREETAB";
/** Definition of the Datablock TREEENTRY */
private static final String C_TREEENTRY = "TREEENTRY";
/** Definition of the Datablock TREEFOLDER */
private static final String C_TREEFOLDER = "TREEFOLDER";
/** Definition of the Datablock TREESWITCH */
private static final String C_TREESWITCH = "TREESWITCH";
/** Definition of the Datablock TREELINE */
private static final String C_TREELINE = "TREELINE";
/** Definition of the Datablock TREEIMG_EMPTY0 */
private static final String C_TREEIMG_EMPTY0 = "TREEIMG_EMPTY0";
/** Definition of the Datablock TREEIMG_EMPTY */
private static final String C_TREEIMG_EMPTY = "TREEIMG_EMPTY";
/** Definition of the Datablock TREEIMG_FOLDEROPEN */
private static final String C_TREEIMG_FOLDEROPEN = "TREEIMG_FOLDEROPEN";
/** Definition of the Datablock TREEIMG_FOLDERCLOSE */
private static final String C_TREEIMG_FOLDERCLOSE = "TREEIMG_FOLDERCLOSE";
/** Definition of the Datablock TREEIMG_MEND */
private static final String C_TREEIMG_MEND = "TREEIMG_MEND";
/** Definition of the Datablock TREEIMG_PEND */
private static final String C_TREEIMG_PEND = "TREEIMG_PEND";
/** Definition of the Datablock TREEIMG_END */
private static final String C_TREEIMG_END = "TREEIMG_END";
/** Definition of the Datablock TREEIMG_MCROSS */
private static final String C_TREEIMG_MCROSS = "TREEIMG_MCROSS";
/** Definition of the Datablock TREEIMG_PCROSS */
private static final String C_TREEIMG_PCROSS = "TREEIMG_PCROSS";
/** Definition of the Datablock TREEIMG_CROSS */
private static final String C_TREEIMG_CROSS = "TREEIMG_CROSS";
/** Definition of the Datablock TREEIMG_VERT */
private static final String C_TREEIMG_VERT = "TREEIMG_VERT";
/** Style for files in a project. */
private static final String C_FILE_INPROJECT = "treefolder";
/** Style for files not in a project. */
private static final String C_FILE_NOTINPROJECT = "treefoldernip";
/** Definition of Treelist */
private static final String C_TREELIST = "TREELIST";
/** Definition of Treelist */
private static final String C_FILELIST = "FILELIST";
/**
* Check if this resource should be displayed in the filelist.
* @param cms The CmsObject
* @param res The resource to be checked.
* @return True or false.
* @throws CmsException if something goes wrong.
*/
private boolean checkAccess(CmsObject cms, CmsResource res) throws CmsException {
boolean access = false;
int accessflags = res.getAccessFlags();
// First check if the user may have access by one of his groups.
boolean groupAccess = false;
Enumeration allGroups = cms.getGroupsOfUser(cms.getRequestContext().currentUser().getName()).elements();
while((!groupAccess) && allGroups.hasMoreElements()) {
groupAccess = cms.readGroup(res).equals((CmsGroup)allGroups.nextElement());
}
if(((accessflags & C_ACCESS_PUBLIC_VISIBLE) > 0) || (cms.readOwner(res).equals(cms.getRequestContext().currentUser()) && (accessflags & C_ACCESS_OWNER_VISIBLE) > 0) || (groupAccess && (accessflags & C_ACCESS_GROUP_VISIBLE) > 0) || (cms.getRequestContext().currentUser().getName().equals(C_USER_ADMIN))) {
access = true;
}
if(res.getState() == C_STATE_DELETED) {
access = false;
}
return access;
}
/**
* Overwrites the getContent method of the CmsWorkplaceDefault.<br>
* Gets the content of the foldertree template and processe the data input.
* @param cms The CmsObject.
* @param templateFile The foldertree template file
* @param elementName not used
* @param parameters Parameters of the request and the template.
* @param templateSelector Selector of the template tag to be displayed.
* @return Bytearre containgine the processed data of the template.
* @throws Throws CmsException if something goes wrong.
*/
/*public byte[] getContent(CmsObject cms, String templateFile, String elementName, Hashtable parameters, String templateSelector) throws CmsException {
CmsXmlWpTemplateFile xmlTemplateDocument = new CmsXmlWpTemplateFile(cms,templateFile);
// process the selected template
return startProcessing(cms,xmlTemplateDocument,"",parameters,"template");
}*/
/**
* Creates the folder tree in the workplace explorer.
* @throws Throws CmsException if something goes wrong.
*/
public Object getTree(CmsObject cms, String tagcontent, A_CmsXmlContent doc,
Object userObj) throws CmsException {
StringBuffer output = new StringBuffer();
I_CmsSession session = cms.getRequestContext().getSession(true);
String foldername = null;
String filelist = null;
String currentFolder;
String currentFilelist;
String rootFolder;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -