001    /**
002     * Copyright (c) 2000-2011 Liferay, Inc. All rights reserved.
003     *
004     * The contents of this file are subject to the terms of the Liferay Enterprise
005     * Subscription License ("License"). You may not use this file except in
006     * compliance with the License. You can obtain a copy of the License by
007     * contacting Liferay, Inc. See the License for the specific language governing
008     * permissions and limitations under the License, including but not limited to
009     * distribution rights of the Software.
010     *
011     *
012     *
013     */
014    
015    package com.liferay.taglib.portletext;
016    
017    import com.liferay.portal.kernel.servlet.taglib.FileAvailabilityUtil;
018    import com.liferay.portal.kernel.util.StringBundler;
019    import com.liferay.portal.theme.PortletDisplay;
020    import com.liferay.taglib.ui.IconTag;
021    
022    /**
023     * @author Brian Wing Shun Chan
024     * @author Shuyang Zhou
025     */
026    public class IconConfigurationTag extends IconTag {
027    
028            @Override
029            protected String getPage() {
030                    if (FileAvailabilityUtil.isAvailable(getServletContext(), _PAGE)) {
031                            return _PAGE;
032                    }
033    
034                    PortletDisplay portletDisplay =
035                            (PortletDisplay)pageContext.getAttribute("portletDisplay");
036    
037                    if (!portletDisplay.isShowConfigurationIcon()) {
038                            return null;
039                    }
040    
041                    setCssClass("portlet-configuration portlet-configuration-icon");
042                    setImage("../portlet/configuration");
043                    setMessage("configuration");
044                    setMethod("get");
045    
046                    StringBundler sb = new StringBundler(9);
047    
048                    sb.append("Liferay.Portlet.openConfiguration('#p_p_id_");
049                    sb.append(portletDisplay.getId());
050                    sb.append("_', '");
051                    sb.append(portletDisplay.getId());
052                    sb.append("', '");
053                    sb.append(portletDisplay.getURLConfiguration());
054                    sb.append("', '");
055                    sb.append(portletDisplay.getNamespace());
056                    sb.append("'); return false;");
057    
058                    setOnClick(sb.toString());
059    
060                    setToolTip(false);
061                    setUrl(portletDisplay.getURLConfiguration());
062    
063                    return super.getPage();
064            }
065    
066            private static final String _PAGE =
067                    "/html/taglib/portlet/icon_configuration/page.jsp";
068    
069    }