Search in sources :

Example 61 with PageHandler

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);
}
Also used : PageHandler(com.publiccms.common.handler.PageHandler) HashMap(java.util.HashMap) CmsContentAttribute(com.publiccms.entities.cms.CmsContentAttribute)

Example 62 with PageHandler

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();
}
Also used : PageHandler(com.publiccms.common.handler.PageHandler)

Example 63 with PageHandler

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;
}
Also used : PageHandler(com.publiccms.common.handler.PageHandler) HashMap(java.util.HashMap)

Example 64 with PageHandler

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();
}
Also used : PageHandler(com.publiccms.common.handler.PageHandler)

Example 65 with PageHandler

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();
}
Also used : PageHandler(com.publiccms.common.handler.PageHandler)

Aggregations

PageHandler (com.publiccms.common.handler.PageHandler)65 FacetPageHandler (com.publiccms.common.handler.FacetPageHandler)3 SysSite (com.publiccms.entities.sys.SysSite)3 IOException (java.io.IOException)3 Date (java.util.Date)3 HashMap (java.util.HashMap)3 CmsContentQuery (com.publiccms.views.pojo.query.CmsContentQuery)2 CmsContentAttribute (com.publiccms.entities.cms.CmsContentAttribute)1 CmsLottery (com.publiccms.entities.cms.CmsLottery)1 LogUpload (com.publiccms.entities.log.LogUpload)1 SysCluster (com.publiccms.entities.sys.SysCluster)1 CmsCategoryQuery (com.publiccms.views.pojo.query.CmsCategoryQuery)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Map (java.util.Map)1 Scheduled (org.springframework.scheduling.annotation.Scheduled)1 ModelMap (org.springframework.ui.ModelMap)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)1