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 Jorge Ferrer
026     * @author Shuyang Zhou
027     */
028    public class IconExportImportTag extends IconTag {
029    
030            @Override
031            protected String getPage() {
032                    if (FileAvailabilityUtil.isAvailable(servletContext, _PAGE)) {
033                            return _PAGE;
034                    }
035    
036                    PortletDisplay portletDisplay =
037                            (PortletDisplay)pageContext.getAttribute("portletDisplay");
038    
039                    if (!portletDisplay.isShowExportImportIcon()) {
040                            return null;
041                    }
042    
043                    setCssClass("portlet-export-import portlet-export-import-icon");
044                    setImage("../aui/download-alt");
045                    setMessage("export-import");
046                    setMethod("get");
047    
048                    StringBundler sb = new StringBundler(11);
049    
050                    sb.append("Liferay.Portlet.openWindow('#p_p_id_");
051                    sb.append(portletDisplay.getId());
052                    sb.append("_', '");
053                    sb.append(portletDisplay.getId());
054                    sb.append("', '");
055                    sb.append(HtmlUtil.escapeJS(portletDisplay.getURLExportImport()));
056                    sb.append("', '");
057                    sb.append(portletDisplay.getNamespace());
058                    sb.append("', '");
059                    sb.append(LanguageUtil.get(request, "export-import"));
060                    sb.append("'); return false;");
061    
062                    setOnClick(sb.toString());
063    
064                    setToolTip(false);
065                    setUrl(portletDisplay.getURLExportImport());
066    
067                    return super.getPage();
068            }
069    
070            private static final String _PAGE =
071                    "/html/taglib/portlet/icon_export_import/page.jsp";
072    
073    }