/** * Copyright (c) 2000-present Liferay, Inc. All rights reserved. * * This library is free software; you can redistribute it and/or modify it under * the terms of the GNU Lesser General Public License as published by the Free * Software Foundation; either version 2.1 of the License, or (at your option) * any later version. * * This library is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more * details. */ package com.liferay.frontend.editor.alloyeditor.link.browse.web.internal.servlet.taglib; import com.liferay.portal.kernel.servlet.taglib.BaseDynamicInclude; import com.liferay.portal.kernel.servlet.taglib.DynamicInclude; import com.liferay.portal.kernel.theme.ThemeDisplay; import com.liferay.portal.kernel.util.Portal; import com.liferay.portal.kernel.util.WebKeys; import java.io.IOException; import java.io.PrintWriter; import javax.servlet.ServletContext; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.osgi.service.component.annotations.Activate; import org.osgi.service.component.annotations.Component; import org.osgi.service.component.annotations.Reference; /** * @author Ambrín Chaudhary */ @Component(immediate = true, service = DynamicInclude.class) public class AlloyEditorLinkBrowseDynamicInclude extends BaseDynamicInclude { @Activate public void activate() { _postfix = _portal.getPathProxy(); if (_postfix.isEmpty()) { _postfix = _servletContext.getContextPath(); } else { _postfix = _postfix.concat(_servletContext.getContextPath()); } _postfix = _postfix.concat( "/js/buttons.js\" type=\"text/javascript\"></script>"); } @Override public void include( HttpServletRequest request, HttpServletResponse response, String key) throws IOException { ThemeDisplay themeDisplay = (ThemeDisplay)request.getAttribute( WebKeys.THEME_DISPLAY); PrintWriter printWriter = response.getWriter(); String content = "<script src=\"".concat(themeDisplay.getPortalURL()); printWriter.println(content.concat(_postfix)); } @Override public void register(DynamicIncludeRegistry dynamicIncludeRegistry) { dynamicIncludeRegistry.register( "com.liferay.frontend.editor.alloyeditor.web#alloyeditor#" + "additionalResources"); dynamicIncludeRegistry.register( "com.liferay.frontend.editor.alloyeditor.web#alloyeditor_bbcode#" + "additionalResources"); dynamicIncludeRegistry.register( "com.liferay.frontend.editor.alloyeditor.web#alloyeditor_creole#" + "additionalResources"); } @Reference private Portal _portal; private String _postfix; @Reference( target = "(osgi.web.symbolicname=com.liferay.frontend.editor.alloyeditor.link.browse.web)" ) private ServletContext _servletContext; }