cmsadminpicgalleries.java
来自「java 编写的程序」· Java 代码 · 共 433 行 · 第 1/2 页
JAVA
433 行
/*
* File : $Source: /usr/local/cvs/opencms/src/com/opencms/workplace/CmsAdminPicGalleries.java,v $
* Date : $Date: 2001/11/15 10:40:15 $
* Version: $Revision: 1.25 $
*
* 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.file.*;
import com.opencms.core.*;
import com.opencms.util.*;
import com.opencms.template.*;
import java.util.*;
import java.io.*;
import javax.servlet.http.*;
/**
* Template Class for administration of picture galleries
* <p>
*
* @author Mario Stanke
* @version $Revision: 1.25 $ $Date: 2001/11/15 10:40:15 $
* @see com.opencms.workplace.CmsXmlWpTemplateFile
*/
public class CmsAdminPicGalleries extends CmsWorkplaceDefault implements I_CmsConstants,I_CmsFileListUsers {
/**
* Gets the content of a defined section in a given template file and its subtemplates
* with the given parameters.
*
* @see getContent(CmsObject cms, String templateFile, String elementName, Hashtable parameters)
* @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.
*/
public byte[] getContent(CmsObject cms, String templateFile, String elementName,
Hashtable parameters, String templateSelector) throws CmsException {
I_CmsSession session = cms.getRequestContext().getSession(true);
CmsXmlWpTemplateFile xmlTemplateDocument = (CmsXmlWpTemplateFile)getOwnTemplateFile(cms,
templateFile, elementName, parameters, templateSelector);
String unzip = (String) parameters.get("unzip");
// clear session values on first load
String initial = (String)parameters.get(C_PARA_INITIAL);
if(initial != null) {
// remove all session values
session.removeValue(C_PARA_FOLDER);
session.removeValue("lasturl");
}
// getting the URL to which we need to return when we're done
String lasturl = getLastUrl(cms, parameters);
// read the parameters
String foldername = (String)parameters.get(C_PARA_FOLDER);
if(foldername != null) {
try {
CmsFolder fold = cms.readFolder(foldername);
//System.out.println(fold.getParent());
if(!(fold.getParent().equals("/pics/"))) {
foldername = "/pics/";
}
if(fold.getState() == C_STATE_DELETED) {
foldername = "/pics/";
}
} catch(CmsException exc) {
// couldn't read the folder - switch to /pics/
foldername = "/pics/";
}
parameters.put(C_PARA_FOLDER, foldername);
// need the foldername in the session in case of an exception in the dialog
session.putValue(C_PARA_FOLDER, foldername);
// maybe we have to redirect to head_1
if(foldername.equals("/pics/") && templateFile.endsWith("administration_head_picgalleries2")) {
// we are in the wrong head - use the first one
xmlTemplateDocument = (CmsXmlWpTemplateFile)getOwnTemplateFile(cms, "/system/workplace/administration/picgallery/administration_head_picgalleries1", elementName, parameters, templateSelector);
}
}
else {
foldername = (String)session.getValue(C_PARA_FOLDER);
}
String action = (String)parameters.get("action");
String newname = (String)parameters.get(C_PARA_NAME);
String title = (String)parameters.get("TITLE"); // both for gallery and upload file
String step = (String)parameters.get("step");
String imagedescription = (String)parameters.get("DESCRIPTION");
if(foldername == null) {
foldername = "";
}
if("new".equals(action)) {
String galleryname = (String)parameters.get("NAME");
String group = (String)parameters.get("GROUP");
if(galleryname != null && group != null && galleryname != "" && group != "") {
boolean read = parameters.get("READ") != null;
boolean write = parameters.get("WRITE") != null;
try {
// create the folder
// get the path from the workplace.ini
String superfolder = getConfigFile(cms).getPicGalleryPath();
CmsFolder folder = cms.createFolder(superfolder, galleryname);
if(title != null) {
cms.writeProperty(folder.getAbsolutePath(), C_PROPERTY_TITLE, title);
}
cms.chgrp(folder.getAbsolutePath(), group);
int flag = folder.getAccessFlags();
// set the access rights for 'other' users
if(read != ((flag & C_ACCESS_PUBLIC_READ) != 0)) {
flag ^= C_ACCESS_PUBLIC_READ;
}
if(write != ((flag & C_ACCESS_PUBLIC_WRITE) != 0)) {
flag ^= C_ACCESS_PUBLIC_WRITE;
}
if((flag & C_ACCESS_GROUP_READ) == 0){
flag ^= C_ACCESS_GROUP_READ;
}
if((flag & C_ACCESS_GROUP_WRITE) == 0){
flag ^= C_ACCESS_GROUP_WRITE;
}
if((flag & C_ACCESS_GROUP_VISIBLE) == 0){
flag ^= C_ACCESS_GROUP_VISIBLE;
}
if((flag & C_ACCESS_OWNER_READ ) == 0){
flag ^= C_ACCESS_OWNER_READ;
}
if((flag & C_ACCESS_OWNER_WRITE) == 0){
flag ^= C_ACCESS_OWNER_WRITE;
}
if((flag & C_ACCESS_OWNER_VISIBLE) == 0){
flag ^= C_ACCESS_OWNER_VISIBLE;
}
if((flag & C_ACCESS_PUBLIC_VISIBLE) == 0){
flag ^= C_ACCESS_PUBLIC_VISIBLE;
}
cms.chmod(folder.getAbsolutePath(), flag);
cms.unlockResource(folder.getAbsolutePath());
}
catch(CmsException ex) {
xmlTemplateDocument.setData("ERRORDETAILS", Utils.getStackTrace(ex));
templateSelector = "error";
}
}
else {
templateSelector = "datamissing";
}
}
else {
if("upload".equals(action)) {
// get filename and file content if available
String filename = null;
byte[] filecontent = new byte[0];
// get the filename
Enumeration files = cms.getRequestContext().getRequest().getFileNames();
while(files.hasMoreElements()) {
filename = (String)files.nextElement();
}
if(filename != null) {
session.putValue(C_PARA_FILE, filename);
}
filename = (String)session.getValue(C_PARA_FILE);
// get the filecontent
if(filename != null) {
filecontent = cms.getRequestContext().getRequest().getFile(filename);
}
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 {
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?