package com.jeecms.core.action;
import static com.jeecms.core.Constants.ENCODING;
import static com.jeecms.core.Constants.FILE_SPT;
import static com.jeecms.core.Constants.SPT;
import java.io.File;
import java.io.FileFilter;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.io.FileUtils;
import org.apache.tools.zip.ZipEntry;
import org.apache.tools.zip.ZipFile;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
import com.jeecms.core.JeeCoreAction;
import com.jeecms.core.util.FileWrap;
import com.jeecms.core.util.UploadRule;
import com.ponyjava.common.util.ComUtils;
import com.ponyjava.common.util.Zipper;
import com.ponyjava.common.util.Zipper.FileEntry;
@SuppressWarnings("serial")
@Scope("prototype")
@Controller("core.templateAct")
public class TemplateAct extends JeeCoreAction {
private static final Logger log = LoggerFactory
.getLogger(TemplateAct.class);
public String resMain() {
return MAIN;
}
public String left() {
String path = getWeb().getTplRootReal(contextPvd.getAppRoot())
.toString().replace(SPT, FILE_SPT);
File tplFile = new File(path);
treeRoot = new FileWrap(tplFile, path, new FileFilter() {
public boolean accept(File f) {
if (f.getName().startsWith(".") || f.getName().startsWith("$")) {
return false;
} else {
return true;
}
}
});
return LEFT;
}
public String resLeft() {
String resPath = contextPvd.getAppRealPath(getWeb().getResRootBuf()
.toString());
treeRoot = new FileWrap(new File(resPath), resPath, new FileFilter() {
public boolean accept(File f) {
if (f.isDirectory() || f.getName().endsWith(".js")
|| f.getName().endsWith(".css")
|| f.getName().endsWith(".html")
|| f.getName().endsWith(".txt")) {
return true;
} else {
return false;
}
}
});
return LEFT;
}
public String right() {
return RIGHT;
}
public String list() {
String path = contextPvd.getAppRealPath(getWeb().getTplRoot().append(
relPath).toString());
File dir = new File(path);
subDir = new FileWrap(dir).getChild();
return LIST;
}
public String resList() {
String path = contextPvd.getAppRealPath(getWeb().getResRootBuf()
.append(relPath).toString());
File dir = new File(path);
subDir = new FileWrap(dir).getChild();
return LIST;
}
public String add() {
// 设置上传规则
addUploadRule();
return ADD;
}
public String resAdd() {
return ADD;
}
private boolean saveFile(String path) {
File tpl = new File(path + relPath + FILE_SPT + tplName);
try {
FileUtils.writeStringToFile(tpl, tplContent, ENCODING);
return true;
} catch (IOException e) {
log.error("写入模板失败!", e);
addActionError("写入模板失败!");
return false;
}
}
public String save() {
String path = contextPvd.getAppRealPath(getWeb().getTplRoot()
.toString());
if (saveFile(path)) {
removeUploadRule();
}
return list();
}
public String resSave() {
String path = contextPvd.getAppRealPath(getWeb().getResRootBuf()
.toString());
saveFile(path);
return resList();
}
private void editFile(String path) {
File tpl = new File(path);
tplName = tpl.getName();
parentPath = relPath.substring(0, relPath.lastIndexOf(FILE_SPT));
try {
tplContent = FileUtils.readFileToString(tpl, ENCODING);
} catch (IOException e) {
log.error("读取模板文件失败", e);
addActionError("读取模板文件失败!");
}
}
public String edit() {
String path = contextPvd.getAppRealPath(getWeb().getTplRoot().append(
relPath).toString());
editFile(path);
// 设置上传规则
addUploadRule();
return EDIT;
}
public String resEdit() {
String path = contextPvd.getAppRealPath(getWeb().getResRootBuf()
.append(relPath).toString());
editFile(path);
return EDIT;
}
private boolean updateFile(String path) {
File tpl = new File(path);
File newFile = tpl;
if (!tpl.getName().equals(tplName)) {
newFile = new File(tpl.getParent() + FILE_SPT + tplName);
tpl.renameTo(newFile);
}
try {
FileUtils.writeStringToFile(newFile, tplContent, ENCODING);
jsonRoot.put("success", true);
jsonRoot.put("msg", "保存成功");
return true;
} catch (IOException e) {
log.error("写文件失败", e);
jsonRoot.put("success", false);
jsonRoot.put("msg", "写文件失败!");
return false;
}
}
public String update() {
String path = contextPvd.getAppRealPath(getWeb().getTplRoot().append(
relPath).toString());
if (updateFile(path)) {
removeUploadRule();
}
return SUCCESS;
}
public String resUpdate() {
String path = contextPvd.getAppRealPath(getWeb().getResRootBuf()
.append(relPath).toString());
updateFile(path);
return SUCCESS;
}
private void renameFile(String path) {
File tpl = new File(path);
if (!origName.equals(tplName)) {
boolean b = tpl.renameTo(new File(tpl.getParent() + FILE_SPT
+ tplName));
if (!b) {
jsonRoot.put("success", false);
}
}
jsonRoot.put("success", true);
}
public String rename() {
String path = contextPvd.getAppRealPath(getWeb().getTplRoot().append(
relPath).append(SPT).append(origName).toString());
renameFile(path);
return SUCCESS;
}
public String resRename() {
String path = contextPvd.getAppRealPath(getWeb().getResRootBuf()
.append(relPath).append(SPT).append(origName).toString());
renameFile(path);
return SUCCESS;
}
private void deleteFile(String path) {
File tpl = new File(path);
if (FileUtils.deleteQuietly(tpl)) {
addActionError("删除成功!");
} else {
addActionError("删除失败!");
}
}
public String delete() {
String path = contextPvd.getAppRealPath(getWeb().getTplRoot().append(
relPath).append(SPT).append(tplName).toString());
deleteFile(path);
return list();
}
public String resDelete() {
String path = contextPvd.getAppRealPath(getWeb().getResRootBuf()
.append(relPath).append(SPT).append(tplName).toString());
deleteFile(path);
return resList();
}
public String createDir() {
String path = contextPvd.getAppRealPath(getWeb().getTplRoot().append(
relPath).append(SPT).append(dirName).toString());
File dir = new File(path);
dir.mkdir();
return list();
}
public String resCreateDir() {
String path = contextPvd.getAppRealPath(getWeb().getResRootBuf()
.append(relPath).append(SPT).append(dirName).toString());
File dir = new File(path);
dir.mkdir();
return resList();
}
public String resUpload() {
return "upload";
}
public String resUploadSubmit() {
String path = contextPvd.getAppRealPath(getWeb().getResRootBuf()
.append(relPath).append(SPT).toString());
if (resFile != null) {
try {
for (int i = 0; i < resFile.length; i++) {
FileUtils.copyFile(resFile[i], new File(path + FILE_SPT
+ resFileFileName[i]));
}
addActionMessage("上传成功!");
} catch (IOException e) {
addActionError("上传失败!" + e.getMessage());
}
}
return resList();
}
public String solutionEdit() {
// 数据库和目录中都有的模板套件才显示
// 数据库中模板方案
solMap = getWeb().getSolutions();
// 模板目录中模板方案
dirMap = new LinkedHashMap<String, String[]>();
String path = contextPvd.getAppRealPath(getWeb().getTplRoot()
.toString());
File[] tplFiles = new File(path).l
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
jeebbs-1.0-beta-pro.zip_beta_jeebbs (1117个子文件)
.#jdbc.properties.1.2 249B
PnEditor.js.bak 6KB
spellchecker.cfm 5KB
layout.css 13KB
fck_editor.css 8KB
fck_dialog.css 6KB
fck_internal.css 4KB
whole.css 3KB
fck_editorarea.css 3KB
font.css 2KB
set.css 2KB
front.css 2KB
fck_dialog_common.css 2KB
theme.css 2KB
theme.css 2KB
admin.css 2KB
fck_showtableborders_gecko.css 2KB
browser.css 2KB
jquery.alerts.css 1KB
spellerStyle.css 890B
fck_media.css 580B
front.css 210B
front.css 156B
jquery_validate.css 55B
Thumbs.db 54KB
Thumbs.db 43KB
Thumbs.db 36KB
Thumbs.db 34KB
Thumbs.db 28KB
Thumbs.db 23KB
Thumbs.db 22KB
Thumbs.db 4KB
t-base.dic 1.72MB
china.dic 52KB
fuzhou.dic 20KB
festival.dic 2KB
x-confucian-family-name.dic 2KB
x-unit.dic 884B
x-noise-charactor.dic 498B
x-noise-word.dic 440B
nation.dic 393B
star-domestic.dic 276B
appellation.dic 194B
company.dic 180B
administrative.dic 154B
org-foreign.dic 146B
beijing.dic 137B
x-for-combinatorics.dic 136B
language.dic 105B
name-foreign.dic 75B
contemporary-words.dic 30B
quanzhou.dic 28B
comupter-science.dic 18B
star-foreign.dic 16B
xiamen.dic 6B
org-domestic.dic 0B
america.dic 0B
africa.dic 0B
korea.dic 0B
oceania.dic 0B
taiwan.dic 0B
japan.dic 0B
europe.dic 0B
tree.ftl 6KB
table.ftl 6KB
common_tag.ftl 4KB
action_cms.ftl 4KB
action_auxiliary.ftl 3KB
action_article.ftl 3KB
style1-1_core.ftl 2KB
self_define_widget.ftl 2KB
select.ftl 2KB
button.ftl 2KB
style2-1_core.ftl 2KB
style3_core.ftl 2KB
editor.ftl 2KB
style3.ftl 1KB
style4.ftl 1KB
style5.ftl 1KB
checkboxlist.ftl 1KB
form.ftl 1KB
style1-2_core.ftl 1KB
radio.ftl 1KB
head.ftl 1KB
text.ftl 1KB
textarea.ftl 1KB
style2-3.ftl 1KB
msg_list.ftl 993B
td.ftl 989B
style1.ftl 944B
checkbox.ftl 932B
password.ftl 929B
style2-4.ftl 858B
file.ftl 804B
scripting-events.ftl 804B
table-batchoperate.ftl 755B
style1-2.ftl 678B
common-attributes.ftl 650B
nonaction_article.ftl 594B
style2.ftl 562B
共 1117 条
- 1
- 2
- 3
- 4
- 5
- 6
- 12
资源评论
JonSco
- 粉丝: 67
- 资源: 1万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 基于matlab实现串口发送接收数据 可配置端口,波特率等 发送可选择ASCII方式或HEX方式
- matlab基于BP神经网络手写字母识别(单一).zip代码9
- 基于matlab实现编写的串口调试工具,数据接收部分采用中断方式,保证了实时的数据显示
- 基于matlab实现39节点电力系统合闸角调控过程中的机组和负荷的灵敏度计算.rar
- HBase数据库性能调优
- 原生微信小程序源码 - -首字母排序选择
- 基于QT+C++开发的保卫萝卜塔防游戏+源码(毕业设计&课程设计&项目开发)
- newapp.apk
- 项目申报管理系统论文Java项目
- 8数码、α-β搜索的博弈树算法编写一字棋游戏、Fisher线性分类器、感知器算法、SVM 分类器、卷积神经网络 CNN 框架
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功