Example usage for com.liferay.portal.kernel.util WebKeys THEME_DISPLAY

List of usage examples for com.liferay.portal.kernel.util WebKeys THEME_DISPLAY

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.util WebKeys THEME_DISPLAY.

Prototype

String THEME_DISPLAY

To view the source code for com.liferay.portal.kernel.util WebKeys THEME_DISPLAY.

Click Source Link

Usage

From source file:com.liferay.dynamic.data.mapping.internal.render.DDMFormFieldFreeMarkerRenderer.java

License:Open Source License

protected Map<String, Object> getFreeMarkerContext(HttpServletRequest request, HttpServletResponse response,
        String portletNamespace, String namespace, DDMFormField ddmFormField, DDMFormField parentDDMFormField,
        boolean showEmptyFieldLabel, Locale locale) {

    Map<String, Object> freeMarkerContext = new HashMap<>();

    Map<String, Object> fieldContext = getFieldContext(request, response, portletNamespace, namespace,
            ddmFormField, locale);//from  w  w  w  .j  a  v a2  s .  co m

    Map<String, Object> parentFieldContext = new HashMap<>();

    if (parentDDMFormField != null) {
        parentFieldContext = getFieldContext(request, response, portletNamespace, namespace, parentDDMFormField,
                locale);
    }

    freeMarkerContext.put("ddmPortletId", DDMPortletKeys.DYNAMIC_DATA_MAPPING);

    Editor editor = DDMFormFieldFreeMarkerRendererHelper.getEditor(request);

    freeMarkerContext.put("editorName", editor.getName());

    freeMarkerContext.put("fieldStructure", fieldContext);

    ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY);

    try {
        String itemSelectorAuthToken = AuthTokenUtil.getToken(request,
                PortalUtil.getControlPanelPlid(themeDisplay.getCompanyId()), PortletKeys.ITEM_SELECTOR);

        freeMarkerContext.put("itemSelectorAuthToken", itemSelectorAuthToken);
    } catch (PortalException pe) {
        _log.error("Unable to generate item selector auth token ", pe);
    }

    freeMarkerContext.put("namespace", namespace);
    freeMarkerContext.put("parentFieldStructure", parentFieldContext);
    freeMarkerContext.put("portletNamespace", portletNamespace);
    freeMarkerContext.put("requestedLanguageDir", LanguageUtil.get(locale, LanguageConstants.KEY_DIR));
    freeMarkerContext.put("requestedLocale", locale);
    freeMarkerContext.put("showEmptyFieldLabel", showEmptyFieldLabel);

    return freeMarkerContext;
}

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

License:Open Source License

protected List<TemplateVariableDefinition> getAutocompleteTemplateVariableDefinitions(
        HttpServletRequest request, String language) throws Exception {

    if (!isAutocompleteEnabled(language)) {
        return Collections.emptyList();
    }//from   ww w.  j a v a 2s. c  o  m

    Set<TemplateVariableDefinition> templateVariableDefinitions = new LinkedHashSet<>();

    // Declared variables

    ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY);

    DDMTemplate ddmTemplate = (DDMTemplate) request.getAttribute(DDMWebKeys.DYNAMIC_DATA_MAPPING_TEMPLATE);

    long classPK = BeanParamUtil.getLong(ddmTemplate, request, "classPK");
    long classNameId = BeanParamUtil.getLong(ddmTemplate, request, "classNameId");

    if (classPK > 0) {
        DDMStructure ddmStructure = _ddmStructureService.getStructure(classPK);

        classNameId = ddmStructure.getClassNameId();
    } else if (ddmTemplate != null) {
        classNameId = ddmTemplate.getClassNameId();
    }

    Map<String, TemplateVariableGroup> templateVariableGroups = TemplateContextHelper
            .getTemplateVariableGroups(classNameId, classPK, language, themeDisplay.getLocale());

    for (TemplateVariableGroup templateVariableGroup : templateVariableGroups.values()) {

        if (!templateVariableGroup.isAutocompleteEnabled()) {
            continue;
        }

        templateVariableDefinitions.addAll(templateVariableGroup.getTemplateVariableDefinitions());
    }

    // Other variables

    TemplateResource templateResource = new StringTemplateResource(_TEMPLATE_ID, _TEMPLATE_CONTENT);

    Template template = TemplateManagerUtil.getTemplate(language, templateResource, false);

    for (String key : template.getKeys()) {
        Object value = template.get(key);

        if (value == null) {
            continue;
        }

        TemplateVariableDefinition variableDefinition = new TemplateVariableDefinition(key, value.getClass(),
                key, (String) null);

        templateVariableDefinitions.add(variableDefinition);
    }

    return new ArrayList<>(templateVariableDefinitions);
}

From source file:com.liferay.dynamic.data.mapping.taglib.servlet.taglib.TemplateRendererTag.java

License:Open Source License

@Override
protected void setAttributes(HttpServletRequest request) {
    super.setAttributes(request);

    long displaStyleGroupId = getDisplayStyleGroupId();

    if (displaStyleGroupId == 0) {
        ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY);

        displaStyleGroupId = themeDisplay.getScopeGroupId();

        setNamespacedAttribute(request, "displayStyleGroupId", displaStyleGroupId);
    }/*from   ww w . j av a2s  .  c om*/

    _portletDisplayDDMTemplate = PortletDisplayTemplateUtil.getPortletDisplayTemplateDDMTemplate(
            displaStyleGroupId, PortalUtil.getClassNameId(getClassName()), getDisplayStyle(), true);

    setNamespacedAttribute(request, "portletDisplayDDMTemplate", _portletDisplayDDMTemplate);
}

From source file:com.liferay.dynamic.data.mapping.taglib.servlet.taglib.TemplateSelectorTag.java

License:Open Source License

@Override
public long getDisplayStyleGroupId() {
    long displayStyleGroupId = super.getDisplayStyleGroupId();

    if (displayStyleGroupId > 0) {
        return displayStyleGroupId;
    }/*from www.j av  a  2s .co m*/

    ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY);

    return themeDisplay.getScopeGroupId();
}

From source file:com.liferay.dynamic.data.mapping.type.document.library.internal.DocumentLibraryDDMFormFieldTemplateContextContributor.java

License:Open Source License

public String getFileEntryURL(HttpServletRequest request, JSONObject valueJSONObject) {

    ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY);

    FileEntry fileEntry = getFileEntry(valueJSONObject);

    if (fileEntry == null) {
        return StringPool.BLANK;
    }/*from  w  w w  . j a v  a  2 s .c o  m*/

    StringBundler sb = new StringBundler(9);

    sb.append(themeDisplay.getPathContext());
    sb.append("/documents/");
    sb.append(fileEntry.getRepositoryId());
    sb.append(StringPool.SLASH);
    sb.append(fileEntry.getFolderId());
    sb.append(StringPool.SLASH);
    sb.append(URLCodec.encodeURL(html.unescape(fileEntry.getTitle()), true));
    sb.append(StringPool.SLASH);
    sb.append(fileEntry.getUuid());

    return html.escape(sb.toString());
}

From source file:com.liferay.dynamic.data.mapping.type.document.library.internal.DocumentLibraryDDMFormFieldTemplateContextContributor.java

License:Open Source License

public String getLexiconIconsPath(HttpServletRequest request) {
    ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY);

    if (themeDisplay == null) {
        return null;
    }/*from  w w w  . j av  a  2  s. c  o  m*/

    StringBundler sb = new StringBundler(3);

    sb.append(themeDisplay.getPathThemeImages());
    sb.append("/lexicon/icons.svg");
    sb.append(StringPool.POUND);

    return sb.toString();
}

From source file:com.liferay.dynamic.data.mapping.web.internal.portlet.action.CopyStructureMVCActionCommand.java

License:Open Source License

@Override
protected String getSaveAndContinueRedirect(ActionRequest actionRequest, DDMStructure structure,
        String redirect) throws Exception {

    ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY);

    LiferayPortletURL portletURL = PortletURLFactoryUtil.create(actionRequest, themeDisplay.getPpid(),
            PortletRequest.RENDER_PHASE);

    portletURL.setParameter("mvcPath", "/copy_structure");

    long classNameId = _portal.getClassNameId(DDMStructure.class);

    portletURL.setParameter("classNameId", String.valueOf(classNameId), false);

    portletURL.setParameter("classPK", String.valueOf(structure.getStructureId()), false);
    portletURL.setParameter("copyFormTemplates", ParamUtil.getString(actionRequest, "copyFormTemplates"),
            false);//from w w  w  .  ja  va2s.  co  m
    portletURL.setParameter("copyDisplayTemplates", ParamUtil.getString(actionRequest, "copyDisplayTemplates"),
            false);
    portletURL.setWindowState(actionRequest.getWindowState());

    return portletURL.toString();
}

From source file:com.liferay.dynamic.data.mapping.web.internal.portlet.action.CopyTemplateMVCActionCommand.java

License:Open Source License

@Override
protected String getSaveAndContinueRedirect(ActionRequest actionRequest, DDMTemplate template, String redirect)
        throws Exception {

    ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY);

    LiferayPortletURL portletURL = PortletURLFactoryUtil.create(actionRequest, themeDisplay.getPpid(),
            PortletRequest.RENDER_PHASE);

    portletURL.setParameter("mvcPath", "/copy_template");
    portletURL.setParameter("templateId", String.valueOf(template.getTemplateId()), false);
    portletURL.setWindowState(actionRequest.getWindowState());

    return portletURL.toString();
}

From source file:com.liferay.dynamic.data.mapping.web.internal.portlet.action.DDMBaseMVCActionCommand.java

License:Open Source License

protected String getSaveAndContinueRedirect(ActionRequest actionRequest, DDMStructure structure,
        String redirect) throws Exception {

    ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY);

    String availableFields = ParamUtil.getString(actionRequest, "availableFields");
    String eventName = ParamUtil.getString(actionRequest, "eventName");

    LiferayPortletURL portletURL = PortletURLFactoryUtil.create(actionRequest, themeDisplay.getPpid(),
            PortletRequest.RENDER_PHASE);

    portletURL.setParameter("mvcPath", "/edit_structure.jsp");
    portletURL.setParameter("redirect", redirect, false);
    portletURL.setParameter("groupId", String.valueOf(structure.getGroupId()), false);

    long classNameId = PortalUtil.getClassNameId(DDMStructure.class);

    portletURL.setParameter("classNameId", String.valueOf(classNameId), false);

    portletURL.setParameter("classPK", String.valueOf(structure.getStructureId()), false);
    portletURL.setParameter("availableFields", availableFields, false);
    portletURL.setParameter("eventName", eventName, false);
    portletURL.setWindowState(actionRequest.getWindowState());

    return portletURL.toString();
}