List of usage examples for com.liferay.portal.kernel.model Theme getThemeId
public String getThemeId();
From source file:com.liferay.application.list.taglib.display.context.logic.PanelAppContentHelper.java
License:Open Source License
public void writeContent(Writer writer) throws Exception { ThemeDisplay themeDisplay = _getThemeDisplay(); String layoutTemplateId = "max"; if (themeDisplay.isStatePopUp()) { layoutTemplateId = "pop_up"; }/*ww w .jav a 2 s . c o m*/ Theme theme = themeDisplay.getTheme(); String velocityTemplateId = theme.getThemeId() + LayoutTemplateConstants.STANDARD_SEPARATOR + layoutTemplateId; String content = LayoutTemplateLocalServiceUtil.getContent(layoutTemplateId, true, theme.getThemeId()); if (Validator.isNotNull(velocityTemplateId) && Validator.isNotNull(content)) { HttpServletRequest request = getOriginalHttpServletRequest(_request); StringBundler sb = RuntimePageUtil.getProcessedTemplate(request, _response, getPortletId(), new StringTemplateResource(velocityTemplateId, content)); if (sb != null) { sb.writeTo(writer); } } }
From source file:com.liferay.layout.admin.web.internal.exportimport.data.handler.StagedThemeStagedModelDataHandler.java
License:Open Source License
@Override public boolean validateReference(PortletDataContext portletDataContext, Element referenceElement) { boolean importThemeSettings = MapUtil.getBoolean(portletDataContext.getParameterMap(), PortletDataHandlerKeys.THEME_REFERENCE); if (!importThemeSettings) { return true; }/*from www .ja v a2s.co m*/ String classPK = referenceElement.attributeValue("class-pk"); List<Theme> themes = _themeLocalService.getThemes(portletDataContext.getCompanyId()); for (Theme theme : themes) { String themeId = theme.getThemeId(); if (themeId.equals(classPK)) { return true; } } return false; }
From source file:com.liferay.marketplace.app.manager.web.internal.portlet.MarketplaceAppManagerPortlet.java
License:Open Source License
public void updatePluginSettings(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); String[] contextNames = StringUtil.split(ParamUtil.getString(actionRequest, "contextNames")); boolean active = ParamUtil.getBoolean(actionRequest, "active"); for (String contextName : contextNames) { ServletContext servletContext = ServletContextPool.get(contextName); List<LayoutTemplate> layoutTemplates = (List<LayoutTemplate>) servletContext .getAttribute(WebKeys.PLUGIN_LAYOUT_TEMPLATES); if (layoutTemplates != null) { for (LayoutTemplate layoutTemplate : layoutTemplates) { PluginSetting pluginSetting = _pluginSettingLocalService.getPluginSetting( themeDisplay.getCompanyId(), layoutTemplate.getLayoutTemplateId(), Plugin.TYPE_LAYOUT_TEMPLATE); _pluginSettingService.updatePluginSetting(themeDisplay.getCompanyId(), layoutTemplate.getLayoutTemplateId(), Plugin.TYPE_LAYOUT_TEMPLATE, pluginSetting.getRoles(), active); }/* w ww .j av a 2 s .co m*/ } List<Portlet> portlets = (List<Portlet>) servletContext.getAttribute(WebKeys.PLUGIN_PORTLETS); if (portlets != null) { for (Portlet portlet : portlets) { _portletService.updatePortlet(themeDisplay.getCompanyId(), portlet.getPortletId(), StringPool.BLANK, active); } } List<Theme> themes = (List<Theme>) servletContext.getAttribute(WebKeys.PLUGIN_THEMES); if (themes != null) { for (Theme theme : themes) { PluginSetting pluginSetting = _pluginSettingLocalService .getPluginSetting(themeDisplay.getCompanyId(), theme.getThemeId(), Plugin.TYPE_THEME); _pluginSettingService.updatePluginSetting(themeDisplay.getCompanyId(), theme.getThemeId(), Plugin.TYPE_THEME, pluginSetting.getRoles(), active); } } } }
From source file:com.liferay.nested.portlets.web.internal.portlet.action.NestedPortletsConfigurationAction.java
License:Open Source License
protected void reorganizeNestedColumns(ActionRequest actionRequest, String portletResource, String newLayoutTemplateId, String oldLayoutTemplateId) throws PortalException { ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); Layout layout = themeDisplay.getLayout(); LayoutTypePortlet layoutTypePortlet = themeDisplay.getLayoutTypePortlet(); Theme theme = themeDisplay.getTheme(); LayoutTemplate newLayoutTemplate = _layoutTemplateLocalService.getLayoutTemplate(newLayoutTemplateId, false, theme.getThemeId()); List<String> newColumns = getColumnNames(newLayoutTemplate.getContent(), portletResource); LayoutTemplate oldLayoutTemplate = _layoutTemplateLocalService.getLayoutTemplate(oldLayoutTemplateId, false, theme.getThemeId());/*from w ww . j ava2s . c om*/ List<String> oldColumns = getColumnNames(oldLayoutTemplate.getContent(), portletResource); layoutTypePortlet.reorganizePortlets(newColumns, oldColumns); layoutTypePortlet.setStateMax(StringPool.BLANK); _layoutLocalService.updateLayout(layout.getGroupId(), layout.isPrivateLayout(), layout.getLayoutId(), layout.getTypeSettings()); }
From source file:com.liferay.nested.portlets.web.internal.portlet.NestedPortletsPortlet.java
License:Open Source License
@Override public void doView(RenderRequest renderRequest, RenderResponse renderResponse) throws IOException, PortletException { ThemeDisplay themeDisplay = (ThemeDisplay) renderRequest.getAttribute(WebKeys.THEME_DISPLAY); String layoutTemplateId = StringPool.BLANK; try {/* w ww. ja va2 s .co m*/ NestedPortletsDisplayContext nestedPortletsDisplayContext = new NestedPortletsDisplayContext( _portal.getHttpServletRequest(renderRequest)); layoutTemplateId = nestedPortletsDisplayContext.getLayoutTemplateId(); } catch (ConfigurationException ce) { if (_log.isWarnEnabled()) { _log.warn(ce, ce); } } String templateId = StringPool.BLANK; String templateContent = StringPool.BLANK; Map<String, String> columnIds = new HashMap<>(); if (Validator.isNotNull(layoutTemplateId)) { Theme theme = themeDisplay.getTheme(); LayoutTemplate layoutTemplate = _layoutTemplateLocalService.getLayoutTemplate(layoutTemplateId, false, theme.getThemeId()); String content = layoutTemplate.getContent(); Matcher processColumnMatcher = _processColumnPattern.matcher(content); while (processColumnMatcher.find()) { String columnId = processColumnMatcher.group(2); if (Validator.isNotNull(columnId)) { columnIds.put(columnId, renderResponse.getNamespace() + StringPool.UNDERLINE + columnId); } } processColumnMatcher.reset(); StringBundler sb = new StringBundler(4); sb.append(theme.getThemeId()); sb.append(LayoutTemplateConstants.CUSTOM_SEPARATOR); sb.append(renderResponse.getNamespace()); sb.append(layoutTemplateId); templateId = sb.toString(); content = processColumnMatcher.replaceAll("$1\\${$2}$3"); Matcher columnIdMatcher = _columnIdPattern.matcher(content); templateContent = columnIdMatcher.replaceAll("$1" + renderResponse.getNamespace() + "$2$3"); } checkLayout(themeDisplay.getLayout(), columnIds.values()); PortletDisplay portletDisplay = themeDisplay.getPortletDisplay(); renderRequest.setAttribute(NestedPortletsWebKeys.TEMPLATE_ID + portletDisplay.getId(), templateId); renderRequest.setAttribute(NestedPortletsWebKeys.TEMPLATE_CONTENT + portletDisplay.getId(), templateContent); Map<String, Object> vmVariables = (Map<String, Object>) renderRequest .getAttribute(WebKeys.VM_VARIABLES + portletDisplay.getId()); if (vmVariables != null) { vmVariables.putAll(columnIds); } else { renderRequest.setAttribute(WebKeys.VM_VARIABLES + portletDisplay.getId(), columnIds); } super.include(viewTemplate, renderRequest, renderResponse); }