use of com.publiccms.entities.cms.CmsContentAttribute in project PublicCMS-preview by sanluan.
the class CmsContentBridge method set.
@Override
public void set(String name, Object value, Document document, LuceneOptions luceneOptions) {
CmsContent content = (CmsContent) value;
CmsContentAttribute entity = BeanComponent.getContentAttributeService().getEntity(content.getId());
if (null != entity) {
content.setDescription(content.getDescription() + entity.getText());
}
}
use of com.publiccms.entities.cms.CmsContentAttribute in project PublicCMS-preview by sanluan.
the class CmsContentAttributeService method updateAttribute.
/**
* @param contentId
* @param entity
*/
public void updateAttribute(Long contentId, CmsContentAttribute entity) {
CmsContentAttribute attribute = getEntity(contentId);
if (null != attribute) {
if (null != entity) {
update(attribute.getContentId(), entity, ignoreProperties);
} else {
delete(attribute.getContentId());
}
} else {
if (null != entity) {
entity.setContentId(contentId);
save(entity);
}
}
}
use of com.publiccms.entities.cms.CmsContentAttribute in project PublicCMS-preview by sanluan.
the class TemplateComponent method createContentFile.
/**
* 内容页面静态化
*
* @param site
* @param entity
* @param category
* @param createMultiContentPage
* @param templatePath
* @param filePath
* @param pageIndex
* @return content static file path
* @throws IOException
* @throws TemplateException
*/
public String createContentFile(SysSite site, CmsContent entity, CmsCategory category, boolean createMultiContentPage, String templatePath, String filePath, Integer pageIndex) throws IOException, TemplateException {
Map<String, Object> model = new HashMap<>();
model.put("content", entity);
model.put("category", category);
CmsContentAttribute attribute = contentAttributeService.getEntity(entity.getId());
if (null != attribute) {
Map<String, String> map = ExtendUtils.getExtendMap(attribute.getData());
map.put("text", attribute.getText());
map.put("source", attribute.getSource());
map.put("sourceUrl", attribute.getSourceUrl());
map.put("wordCount", String.valueOf(attribute.getWordCount()));
model.put("attribute", map);
} else {
model.put("attribute", attribute);
}
if (CommonUtils.empty(filePath)) {
filePath = category.getContentPath();
}
if (null != attribute && CommonUtils.notEmpty(attribute.getText())) {
String pageBreakTag = null;
if (-1 < attribute.getText().indexOf(CommonConstants.getCkeditorPageBreakTag())) {
pageBreakTag = CommonConstants.getCkeditorPageBreakTag();
} else {
pageBreakTag = CommonConstants.getUeditorPageBreakTag();
}
String[] texts = StringUtils.splitByWholeSeparator(attribute.getText(), pageBreakTag);
if (createMultiContentPage) {
for (int i = 1; i < texts.length; i++) {
PageHandler page = new PageHandler(i + 1, 1, texts.length, null);
model.put("text", texts[i]);
model.put("page", page);
createStaticFile(site, templatePath, filePath, i + 1, null, model);
}
pageIndex = 1;
}
PageHandler page = new PageHandler(pageIndex, 1, texts.length, null);
model.put("page", page);
model.put("text", texts[page.getPageIndex() - 1]);
}
return createStaticFile(site, templatePath, filePath, 1, null, model);
}
use of com.publiccms.entities.cms.CmsContentAttribute in project PublicCMS-preview by sanluan.
the class GetContentAttributeMethod method exec.
@SuppressWarnings("unchecked")
@Override
public Object exec(@SuppressWarnings("rawtypes") List arguments) throws TemplateModelException {
Long id = getLong(0, arguments);
if (CommonUtils.notEmpty(id)) {
CmsContentAttribute entity = service.getEntity(id);
if (null != entity) {
Map<String, String> map = ExtendUtils.getExtendMap(entity.getData());
map.put("text", entity.getText());
map.put("source", entity.getSource());
map.put("sourceUrl", entity.getSourceUrl());
map.put("wordCount", String.valueOf(entity.getWordCount()));
return map;
}
}
return null;
}
use of com.publiccms.entities.cms.CmsContentAttribute in project PublicCMS-preview by sanluan.
the class GetContentAttributesMethod method exec.
@SuppressWarnings("unchecked")
@Override
public Object exec(@SuppressWarnings("rawtypes") List arguments) throws TemplateModelException {
Long[] ids = getLongArray(0, arguments);
if (CommonUtils.notEmpty(ids)) {
Map<String, Map<String, String>> resultMap = new HashMap<>();
for (CmsContentAttribute entity : service.getEntitysWithoutText(ids)) {
Map<String, String> map = ExtendUtils.getExtendMap(entity.getData());
map.put("source", entity.getSource());
map.put("sourceUrl", entity.getSourceUrl());
map.put("wordCount", String.valueOf(entity.getWordCount()));
resultMap.put(String.valueOf(entity.getContentId()), map);
}
return resultMap;
}
return null;
}
Aggregations