use of com.publiccms.common.handler.PageHandler 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.common.handler.PageHandler in project PublicCMS-preview by sanluan.
the class SysUserTokenListDirective method execute.
@Override
public void execute(RenderHandler handler) throws IOException, Exception {
PageHandler page = service.getPage(getSite(handler).getId(), handler.getLong("userId"), handler.getString("channel"), handler.getString("orderType"), handler.getInteger("pageIndex", 1), handler.getInteger("count", 30));
handler.put("page", page).render();
}
use of com.publiccms.common.handler.PageHandler in project PublicCMS-preview by sanluan.
the class GetContentPageMethod method exec.
@SuppressWarnings("unchecked")
@Override
public Object exec(@SuppressWarnings("rawtypes") List arguments) throws TemplateModelException {
String text = getString(0, arguments);
Integer pageIndex = getInteger(1, arguments);
if (CommonUtils.notEmpty(text)) {
String pageBreakTag = null;
if (-1 < text.indexOf(CommonConstants.getCkeditorPageBreakTag())) {
pageBreakTag = CommonConstants.getCkeditorPageBreakTag();
} else {
pageBreakTag = CommonConstants.getUeditorPageBreakTag();
}
String[] texts = StringUtils.splitByWholeSeparator(text, pageBreakTag);
PageHandler page = new PageHandler(pageIndex, 1, texts.length, null);
Map<String, Object> resultMap = new HashMap<>();
resultMap.put("page", page);
resultMap.put("text", texts[page.getPageIndex() - 1]);
return resultMap;
}
return null;
}
use of com.publiccms.common.handler.PageHandler in project PublicCMS-preview by sanluan.
the class CmsCategoryModelListDirective method execute.
@Override
public void execute(RenderHandler handler) throws IOException, Exception {
PageHandler page = service.getPage(handler.getString("modelId"), handler.getInteger("categoryId"), handler.getInteger("pageIndex", 1), handler.getInteger("count"));
handler.put("page", page).render();
}
use of com.publiccms.common.handler.PageHandler in project PublicCMS-preview by sanluan.
the class CmsCategoryTypeListDirective method execute.
@Override
public void execute(RenderHandler handler) throws IOException, Exception {
PageHandler page = service.getPage(getSite(handler).getId(), handler.getInteger("pageIndex"), handler.getInteger("count"));
handler.put("page", page).render();
}
Aggregations