Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into V5
Browse files Browse the repository at this point in the history
  • Loading branch information
sanluan committed Jun 28, 2024
2 parents 3e020fd + 12f2760 commit 6166e5b
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 48 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public static final String getVersion() {
* @return revision
*/
public static final String getRevision() {
return "a";
return "b";
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ public static Map<String, String> getAttributeMap(CmsCategoryAttribute attribute
return map;
}
}

/**
* @param attribute
* @param keywordsConfig
Expand Down Expand Up @@ -209,6 +210,60 @@ public static String getExtendString(Map<String, String> map, String sitePath,
return getExtendString(map, sitePath, null, extendFieldListArrays);
}

/**
* @param map
* @param sitePath
* @param notSafeKeys
* @param searchableConsumer
* @param extendFieldList
*/
public static void decodeField(Map<String, String> map, String sitePath, List<SysExtendField> extendFieldList) {
Set<String> notSafeKeys = new HashSet<>();
notSafeKeys.addAll(map.keySet());
decodeField(map, sitePath, notSafeKeys, null, extendFieldList);
}

/**
* @param map
* @param sitePath
* @param notSafeKeys
* @param searchableConsumer
* @param extendFieldList
*/
private static void decodeField(Map<String, String> map, String sitePath, Set<String> notSafeKeys,
BiConsumer<SysExtendField, String> searchableConsumer, List<SysExtendField> extendFieldList) {
if (CommonUtils.notEmpty(extendFieldList)) {
for (SysExtendField extend : extendFieldList) {
notSafeKeys.remove(extend.getId().getCode());
String value = map.get(extend.getId().getCode());
if (null == value) {
if (null != extend.getDefaultValue()) {
map.put(extend.getId().getCode(), value);
}
} else if (null != extend.getMaxlength()) {
if (ArrayUtils.contains(Config.INPUT_TYPE_EDITORS, extend.getInputType())) {
value = HtmlUtils.cleanUnsafeHtml(
HtmlUtils.keep(new String(VerificationUtils.base64Decode(value), Constants.DEFAULT_CHARSET),
extend.getMaxlength()),
sitePath);
} else {
value = CommonUtils.keep(value, extend.getMaxlength(), null);
}
map.put(extend.getId().getCode(), value);
} else {
if (ArrayUtils.contains(Config.INPUT_TYPE_EDITORS, extend.getInputType())) {
value = HtmlUtils.cleanUnsafeHtml(
new String(VerificationUtils.base64Decode(value), Constants.DEFAULT_CHARSET), sitePath);
map.put(extend.getId().getCode(), value);
}
}
if (extend.isSearchable() && null != value) {
searchableConsumer.accept(extend, value);
}
}
}
}

/**
* @param map
* @param sitePath
Expand All @@ -223,31 +278,7 @@ public static String getExtendString(Map<String, String> map, String sitePath,
Set<String> notSafeKeys = new HashSet<>();
notSafeKeys.addAll(map.keySet());
for (List<SysExtendField> extendFieldList : extendFieldListArrays) {
if (CommonUtils.notEmpty(extendFieldList)) {
for (SysExtendField extend : extendFieldList) {
notSafeKeys.remove(extend.getId().getCode());
String value = map.get(extend.getId().getCode());
if (null == value) {
if (null != extend.getDefaultValue()) {
map.put(extend.getId().getCode(), value);
}
} else if (null != extend.getMaxlength()) {
if (ArrayUtils.contains(Config.INPUT_TYPE_EDITORS, extend.getInputType())) {
map.put(extend.getId().getCode(),
HtmlUtils.cleanUnsafeHtml(HtmlUtils.keep(value, extend.getMaxlength()), sitePath));
} else {
map.put(extend.getId().getCode(), CommonUtils.keep(value, extend.getMaxlength(), null));
}
} else {
if (ArrayUtils.contains(Config.INPUT_TYPE_EDITORS, extend.getInputType())) {
map.put(extend.getId().getCode(), HtmlUtils.cleanUnsafeHtml(value, sitePath));
}
}
if (extend.isSearchable() && null != value) {
searchableConsumer.accept(extend, value);
}
}
}
decodeField(map, sitePath, notSafeKeys, searchableConsumer, extendFieldList);
}
if (!notSafeKeys.isEmpty()) {
for (String key : notSafeKeys) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import com.publiccms.common.tools.CmsFileUtils;
import com.publiccms.common.tools.CommonUtils;
import com.publiccms.common.tools.ControllerUtils;
import com.publiccms.common.tools.ExtendUtils;
import com.publiccms.common.tools.RequestUtils;
import com.publiccms.entities.log.LogOperate;
import com.publiccms.entities.sys.SysDept;
Expand Down Expand Up @@ -96,46 +97,42 @@ public String saveMetadata(@RequestAttribute SysSite site, @SessionAttribute Sys
}
if (CommonUtils.notEmpty(path)) {
String filepath = siteComponent.getTemplateFilePath(site.getId(), path);
List<SysExtendField> extendList = null;
CmsPlaceMetadata placeMetadata = null;
CmsPageMetadata pageMetadata = null;
if ("place".equalsIgnoreCase(type)) {
placeMetadata = metadataComponent.getPlaceMetadata(filepath);
extendList = placeMetadata.getMetadataExtendList();
} else {
pageMetadata = metadataComponent.getTemplateMetadata(filepath);
extendList = pageMetadata.getExtendList();
}
ExtendUtils.decodeField(pageDate.getExtendData(), site.getSitePath(), extendList);
metadataComponent.updateTemplateData(filepath, pageDate);
logOperateService
.save(new LogOperate(site.getId(), admin.getId(), admin.getDeptId(), LogLoginService.CHANNEL_WEB_MANAGER,
"update.template.data", RequestUtils.getIpAddress(request), CommonUtils.getDate(), path));
CmsPageData olddata = metadataComponent.getTemplateData(filepath);
if (null != olddata && null != olddata.getExtendData()) {
List<SysExtendField> extendList = null;
if ("place".equalsIgnoreCase(type)) {
CmsPlaceMetadata metadata = metadataComponent.getPlaceMetadata(filepath);
extendList = metadata.getMetadataExtendList();
} else {
CmsPageMetadata metadata = metadataComponent.getTemplateMetadata(filepath);
extendList = metadata.getExtendList();
}
if (CommonUtils.notEmpty(olddata.getExtendData()) && CommonUtils.notEmpty(extendList)) {
editorHistoryService.saveHistory(site.getId(), admin.getId(),
CmsEditorHistoryService.ITEM_TYPE_METADATA_EXTEND, path, olddata.getExtendData(),
pageDate.getExtendData(), extendList);
}
editorHistoryService.saveHistory(site.getId(), admin.getId(), CmsEditorHistoryService.ITEM_TYPE_METADATA_EXTEND,
path, olddata.getExtendData(), pageDate.getExtendData(), extendList);
}
if ("place".equalsIgnoreCase(type)) {
if (path.startsWith(TemplateComponent.INCLUDE_DIRECTORY)
&& (site.isUseSsi() || CmsFileUtils.exists(siteComponent.getWebFilePath(site.getId(), path)))) {
CmsPlaceMetadata metadata = metadataComponent.getPlaceMetadata(filepath);
CmsPageData data = metadataComponent.getTemplateData(filepath);
try {
templateComponent.staticPlace(site, path.substring(TemplateComponent.INCLUDE_DIRECTORY.length()),
metadata, data);
placeMetadata, pageDate);
} catch (IOException | TemplateException e) {
log.error(e.getMessage(), e);
}
}
} else {
CmsPageMetadata metadata = metadataComponent.getTemplateMetadata(filepath);
if (site.isUseStatic() && CommonUtils.notEmpty(metadata.getPublishPath())) {
if (site.isUseStatic() && null != pageMetadata && CommonUtils.notEmpty(pageMetadata.getPublishPath())) {
String templatePath = SiteComponent.getFullTemplatePath(site.getId(), path);
CmsPageData data = metadataComponent.getTemplateData(filepath);
try {
templateComponent.createStaticFile(site, templatePath, metadata.getPublishPath(), null,
metadata.getAsMap(data), null, null);
templateComponent.createStaticFile(site, templatePath, pageMetadata.getPublishPath(), null,
pageMetadata.getAsMap(pageDate), null, null);
} catch (IOException | TemplateException e) {
log.error(e.getMessage(), e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,6 @@ private void dealAttribute(CmsContent entity, SysSite site, List<SysExtendField>
}
} else {
if (ArrayUtils.contains(Config.INPUT_TYPE_EDITORS, extendField.getInputType())) {
map.put(extendField.getId().getCode(), value);
value = HtmlUtils.removeHtmlTag(value);
}
if (CommonUtils.notEmpty(value)) {
Expand Down

0 comments on commit 6166e5b

Please sign in to comment.