001    /**
002     * Copyright (c) 2000-present Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.taglib.portletext;
016    
017    import com.liferay.portal.kernel.language.LanguageUtil;
018    import com.liferay.portal.kernel.util.HtmlUtil;
019    import com.liferay.portal.kernel.util.StringBundler;
020    import com.liferay.portal.theme.PortletDisplay;
021    import com.liferay.taglib.FileAvailabilityUtil;
022    import com.liferay.taglib.ui.IconTag;
023    
024    /**
025     * @author Levente Hud??k
026     */
027    public class IconStagingTag extends IconTag {
028    
029            @Override
030            protected String getPage() {
031                    if (FileAvailabilityUtil.isAvailable(servletContext, _PAGE)) {
032                            return _PAGE;
033                    }
034    
035                    PortletDisplay portletDisplay =
036                            (PortletDisplay)pageContext.getAttribute("portletDisplay");
037    
038                    if (!portletDisplay.isShowStagingIcon()) {
039                            return null;
040                    }
041    
042                    setCssClass("portlet-export-import portlet-export-import-icon");
043                    setImage("../aui/share");
044                    setMessage("staging");
045                    setMethod("get");
046    
047                    StringBundler sb = new StringBundler(11);
048    
049                    sb.append("Liferay.Portlet.openWindow('#p_p_id_");
050                    sb.append(portletDisplay.getId());
051                    sb.append("_', '");
052                    sb.append(portletDisplay.getId());
053                    sb.append("', '");
054                    sb.append(HtmlUtil.escapeJS(portletDisplay.getURLStaging()));
055                    sb.append("', '");
056                    sb.append(portletDisplay.getNamespace());
057                    sb.append("', '");
058                    sb.append(LanguageUtil.get(request, "staging"));
059                    sb.append("'); return false;");
060    
061                    setOnClick(sb.toString());
062    
063                    setToolTip(false);
064                    setUrl(portletDisplay.getURLStaging());
065    
066                    return super.getPage();
067            }
068    
069            private static final String _PAGE =
070                    "/html/taglib/portlet/icon_staging/page.jsp";
071    
072    }