Search in sources :

Example 1 with CmsContentAttribute

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());
    }
}
Also used : CmsContent(com.publiccms.entities.cms.CmsContent) CmsContentAttribute(com.publiccms.entities.cms.CmsContentAttribute)

Example 2 with CmsContentAttribute

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);
        }
    }
}
Also used : CmsContentAttribute(com.publiccms.entities.cms.CmsContentAttribute)

Example 3 with CmsContentAttribute

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

Example 4 with CmsContentAttribute

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;
}
Also used : CmsContentAttribute(com.publiccms.entities.cms.CmsContentAttribute)

Example 5 with CmsContentAttribute

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

Aggregations

CmsContentAttribute (com.publiccms.entities.cms.CmsContentAttribute)5 HashMap (java.util.HashMap)2 PageHandler (com.publiccms.common.handler.PageHandler)1 CmsContent (com.publiccms.entities.cms.CmsContent)1 Map (java.util.Map)1