Example usage for com.liferay.portal.kernel.template TemplateConstants LANG_TYPE_VM

List of usage examples for com.liferay.portal.kernel.template TemplateConstants LANG_TYPE_VM

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.template TemplateConstants LANG_TYPE_VM.

Prototype

String LANG_TYPE_VM

To view the source code for com.liferay.portal.kernel.template TemplateConstants LANG_TYPE_VM.

Click Source Link

Usage

From source file:com.liferay.content.targeting.portlet.util.PortletDisplayTemplateUtil.java

License:Open Source License

public static String renderDDMTemplate(PortletRequest portletRequest, ThemeDisplay themeDisplay,
        long ddmTemplateId, List<?> entries, Map<String, Object> contextObjects) throws Exception {

    DDMTemplate ddmTemplate = DDMTemplateLocalServiceUtil.getTemplate(ddmTemplateId);

    String language = ddmTemplate.getLanguage();

    if (language.equals(TemplateConstants.LANG_TYPE_VM)) {
        _log.error("Velocity Application Display Templates not supported");

        return null;
    }/*from www.jav  a2 s.c  om*/

    contextObjects.put(PortletDisplayTemplateConstants.TEMPLATE_ID, ddmTemplateId);
    contextObjects.put(PortletDisplayTemplateConstants.ENTRIES, entries);

    if (!entries.isEmpty()) {
        contextObjects.put(PortletDisplayTemplateConstants.ENTRY, entries.get(0));
    }

    contextObjects.putAll(_getPortletPreferences(portletRequest));

    // Compatibility with existing Application Display Templates

    Object portletJspTagLibs = contextObjects.get("PortletJspTagLibs");

    if (portletJspTagLibs != null) {
        contextObjects.put("taglibLiferayHash", portletJspTagLibs);
    }

    contextObjects.put(PortletDisplayTemplateConstants.ASSET_PUBLISHER_HELPER,
            AssetPublisherHelperUtil.getAssetPublisherHelper());

    Transformer transformer = new Transformer(PropsKeys.DYNAMIC_DATA_LISTS_ERROR_TEMPLATE, true);

    return transformer.transform(themeDisplay, contextObjects, ddmTemplate.getScript(), language);
}

From source file:com.liferay.content.targeting.service.test.util.DDMTemplateTestUtil.java

License:Open Source License

public static DDMTemplate addTemplate(long structureId) throws Exception {
    return addTemplate(structureId, TemplateConstants.LANG_TYPE_VM, getSampleTemplateXSL(),
            LocaleUtil.getSiteDefault());
}

From source file:com.liferay.content.targeting.service.test.util.DDMTemplateTestUtil.java

License:Open Source License

public static DDMTemplate addTemplate(long structureId, Locale defaultLocale) throws Exception {

    return addTemplate(structureId, TemplateConstants.LANG_TYPE_VM, getSampleTemplateXSL(), defaultLocale);
}

From source file:com.liferay.content.targeting.service.test.util.DDMTemplateTestUtil.java

License:Open Source License

public static DDMTemplate addTemplate(long groupId, long structureId) throws Exception {

    return addTemplate(groupId, structureId, TemplateConstants.LANG_TYPE_VM, getSampleTemplateXSL(),
            LocaleUtil.getSiteDefault());
}

From source file:com.liferay.content.targeting.service.test.util.DDMTemplateTestUtil.java

License:Open Source License

public static DDMTemplate addTemplate(long groupId, long structureId, Locale defaultLocale) throws Exception {

    return addTemplate(groupId, structureId, TemplateConstants.LANG_TYPE_VM, getSampleTemplateXSL(),
            defaultLocale);//from   w  ww.  j a v a 2 s .  c o  m
}

From source file:com.liferay.content.targeting.service.test.util.DDMTemplateTestUtil.java

License:Open Source License

public static DDMTemplate addTemplate(long groupId, long classNameId, long classPK) throws Exception {

    return addTemplate(groupId, classNameId, classPK, TemplateConstants.LANG_TYPE_VM, getSampleTemplateXSL(),
            LocaleUtil.getSiteDefault());
}

From source file:com.liferay.defaultwebcontent.hook.upgrade.v1_0_0.UpgradeJournal.java

License:Open Source License

protected void addJournalTemplates(long groupId, long userId, Locale locale) throws Exception {

    // Regular Article Description

    long classPK = _ddmStructureIds.get(groupId + "#" + "ARTICLE");

    Map<Locale, String> nameMap = new HashMap<Locale, String>();

    nameMap.put(locale, "Regular Article Description");

    Map<Locale, String> descriptionMap = new HashMap<Locale, String>();

    descriptionMap.put(locale, "This template only displays brief descriptions of web content");

    String script = getFileAsString("/templates/article_description.vm");

    ServiceContext serviceContext = new ServiceContext();

    serviceContext.setAddGroupPermissions(true);
    serviceContext.setAddGuestPermissions(true);

    DDMTemplateLocalServiceUtil.addTemplate(userId, groupId, PortalUtil.getClassNameId(DDMStructure.class),
            classPK, "ARTICLE-DESCRIPTION", nameMap, descriptionMap, DDMTemplateConstants.TEMPLATE_TYPE_DISPLAY,
            DDMTemplateConstants.TEMPLATE_MODE_CREATE, TemplateConstants.LANG_TYPE_VM, script, true, false,
            StringPool.BLANK, null, serviceContext);

    // Regular Article

    nameMap.put(locale, "Regular Article");

    descriptionMap.put(locale, "This is the regular article template, it handles basic article "
            + "content like, titles, main image, body, and author " + "information.");

    script = getFileAsString("/templates/regular_article.vm");

    DDMTemplateLocalServiceUtil.addTemplate(userId, groupId, PortalUtil.getClassNameId(DDMStructure.class),
            classPK, "REGULAR-ARTICLE", nameMap, descriptionMap, DDMTemplateConstants.TEMPLATE_TYPE_DISPLAY,
            DDMTemplateConstants.TEMPLATE_MODE_CREATE, TemplateConstants.LANG_TYPE_VM, script, true, false,
            StringPool.BLANK, null, serviceContext);

    // Carousel/*from w  w w .jav  a 2 s.c  o m*/

    classPK = _ddmStructureIds.get(groupId + "#" + "MULTIPLE-ITEM-CAROUSEL");

    nameMap.put(locale, "Carousel");

    descriptionMap.put(locale, "This is the carousel template that utilizes Alloy UI to display "
            + "repeatable content as a slideshow.");

    script = getFileAsString("/templates/multiple_item_carousel.vm");

    DDMTemplateLocalServiceUtil.addTemplate(userId, groupId, PortalUtil.getClassNameId(DDMStructure.class),
            classPK, "MULTIPLE-ITEM-CAROUSEL", nameMap, descriptionMap,
            DDMTemplateConstants.TEMPLATE_TYPE_DISPLAY, DDMTemplateConstants.TEMPLATE_MODE_CREATE,
            TemplateConstants.LANG_TYPE_VM, script, true, false, StringPool.BLANK, null, serviceContext);

    // Featured Items

    classPK = _ddmStructureIds.get(groupId + "#" + "MULTIPLE-ITEM");

    nameMap.put(locale, "Featured Items");

    descriptionMap.put(locale, "This is a template that utilizes the Multiple Item Structure, "
            + "and displays the data as Featured Items.");

    script = getFileAsString("/templates/multiple_item_feature.vm");

    DDMTemplateLocalServiceUtil.addTemplate(userId, groupId, PortalUtil.getClassNameId(DDMStructure.class),
            classPK, "MULTIPLE-ITEM-FEATURE", nameMap, descriptionMap,
            DDMTemplateConstants.TEMPLATE_TYPE_DISPLAY, DDMTemplateConstants.TEMPLATE_MODE_CREATE,
            TemplateConstants.LANG_TYPE_VM, script, true, false, StringPool.BLANK, null, serviceContext);
}

From source file:com.liferay.dynamic.data.mapping.internal.util.DDMTemplateHelperImpl.java

License:Open Source License

@Override
public boolean isAutocompleteEnabled(String language) {
    if (language.equals(TemplateConstants.LANG_TYPE_FTL) || language.equals(TemplateConstants.LANG_TYPE_VM)) {

        return true;
    }/* w w w . ja  va 2s . c o m*/

    return false;
}

From source file:com.liferay.dynamic.data.mapping.service.test.BaseDDMServiceTestCase.java

License:Open Source License

protected DDMTemplate addDisplayTemplate(long classNameId, long classPK, long resourceClassNameId, String name,
        String description, int status) throws Exception {

    String language = TemplateConstants.LANG_TYPE_VM;

    return addTemplate(classNameId, classPK, resourceClassNameId, StringPool.BLANK, name, description,
            DDMTemplateConstants.TEMPLATE_TYPE_DISPLAY, StringPool.BLANK, language,
            getTestTemplateScript(language), status);
}

From source file:com.liferay.dynamic.data.mapping.service.test.BaseDDMServiceTestCase.java

License:Open Source License

protected DDMTemplate addDisplayTemplate(long classNameId, long classPK, String name, int status)
        throws Exception {

    String language = TemplateConstants.LANG_TYPE_VM;

    return addTemplate(classNameId, classPK, name, DDMTemplateConstants.TEMPLATE_TYPE_DISPLAY, StringPool.BLANK,
            language, getTestTemplateScript(language), status);
}