public void setLookAndFeel(Theme theme, ColorScheme colorScheme) { _theme = theme; _colorScheme = colorScheme; if ((theme == null) || (colorScheme == null)) { return; } String themeStaticResourcePath = theme.getStaticResourcePath(); String cdnBaseURL = getCDNBaseURL(); setPathColorSchemeImages( cdnBaseURL + themeStaticResourcePath + colorScheme.getColorSchemeImagesPath()); String dynamicResourcesHost = getCDNDynamicResourcesHost(); if (Validator.isNull(dynamicResourcesHost)) { String portalURL = getPortalURL(); try { portalURL = PortalUtil.getPortalURL(getLayout(), this); } catch (Exception e) { _log.error(e, e); } dynamicResourcesHost = portalURL; } setPathThemeCss(dynamicResourcesHost + themeStaticResourcePath + theme.getCssPath()); setPathThemeImages(cdnBaseURL + themeStaticResourcePath + theme.getImagesPath()); setPathThemeJavaScript(cdnBaseURL + themeStaticResourcePath + theme.getJavaScriptPath()); String rootPath = theme.getRootPath(); if (rootPath.equals(StringPool.SLASH)) { setPathThemeRoot(themeStaticResourcePath); } else { setPathThemeRoot(themeStaticResourcePath + rootPath); } setPathThemeTemplates(cdnBaseURL + themeStaticResourcePath + theme.getTemplatesPath()); }
/** * Returns the content delivery network (CDN) base URL, or the current portal URL if the CDN base * URL is <code>null</code>. The CDN base URL can be configured by setting the <code>cdn.host.http * </code> or <code>cdn.host.https</code> property in a <code>portal-ext.properties</code> file. * * @return the CDN base URL, or the current portal URL if the CDN base URL is <code>null</code> */ public String getCDNBaseURL() { if (_cdnBaseURL != null) { return _cdnBaseURL; } String host = getCDNHost(); if (Validator.isNull(host)) { String portalURL = getPortalURL(); try { portalURL = PortalUtil.getPortalURL(getLayout(), this); } catch (Exception e) { _log.error(e, e); } host = portalURL; } _cdnBaseURL = host; return _cdnBaseURL; }
protected String getDetails() { ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY); ResourceBundle resourceBundle = TagResourceBundleUtil.getResourceBundle(pageContext); String details = null; if (_alt != null) { details = " alt=\"" + LanguageUtil.get(resourceBundle, _alt) + "\""; } else if (isLabel()) { details = " alt=\"\""; } else { StringBundler sb = new StringBundler(5); sb.append(" alt=\""); sb.append(LanguageUtil.get(resourceBundle, getProcessedMessage())); sb.append("\" title=\""); sb.append(LanguageUtil.get(resourceBundle, getProcessedMessage())); sb.append("\""); details = sb.toString(); } if (Validator.isNull(_src) || !themeDisplay.isThemeImagesFastLoad() || isAUIImage()) { return details; } SpriteImage spriteImage = null; String spriteFileName = null; String spriteFileURL = null; String imageFileName = StringUtil.replace(_src, "common/../", ""); if (imageFileName.contains(Http.PROTOCOL_DELIMITER)) { String portalURL = PortalUtil.getPortalURL(request); if (imageFileName.startsWith(portalURL)) { imageFileName = imageFileName.substring(portalURL.length()); } else { URL imageURL = null; try { imageURL = new URL(imageFileName); imageFileName = imageURL.getPath(); } catch (MalformedURLException murle) { } } } Theme theme = themeDisplay.getTheme(); String contextPath = theme.getContextPath(); String imagesPath = contextPath.concat(theme.getImagesPath()); if (imageFileName.startsWith(imagesPath)) { spriteImage = theme.getSpriteImage(imageFileName); if (spriteImage != null) { spriteFileName = spriteImage.getSpriteFileName(); if (BrowserSnifferUtil.isIe(request) && (BrowserSnifferUtil.getMajorVersion(request) < 7)) { spriteFileName = StringUtil.replace(spriteFileName, ".png", ".gif"); } String cdnBaseURL = themeDisplay.getCDNBaseURL(); spriteFileURL = cdnBaseURL.concat(spriteFileName); } } if (spriteImage == null) { Portlet portlet = (Portlet) request.getAttribute("liferay-portlet:icon_portlet:portlet"); if (portlet == null) { portlet = (Portlet) request.getAttribute(WebKeys.RENDER_PORTLET); } if (portlet != null) { PortletApp portletApp = portlet.getPortletApp(); spriteImage = portletApp.getSpriteImage(imageFileName); if (spriteImage != null) { spriteFileName = spriteImage.getSpriteFileName(); if (BrowserSnifferUtil.isIe(request) && (BrowserSnifferUtil.getMajorVersion(request) < 7)) { spriteFileName = StringUtil.replace(spriteFileName, ".png", ".gif"); } String cdnBaseURL = themeDisplay.getCDNBaseURL(); spriteFileURL = cdnBaseURL.concat(spriteFileName); } } } if (spriteImage != null) { String themeImagesPath = themeDisplay.getPathThemeImages(); _src = themeImagesPath.concat("/spacer.png"); StringBundler sb = new StringBundler(10); sb.append(details); sb.append(" style=\"background-image: url('"); sb.append(spriteFileURL); sb.append("'); background-position: 50% -"); sb.append(spriteImage.getOffset()); sb.append("px; background-repeat: no-repeat; height: "); sb.append(spriteImage.getHeight()); sb.append("px; width: "); sb.append(spriteImage.getWidth()); sb.append("px;\""); details = sb.toString(); } return details; }