001    /**
002     * Copyright (c) 2000-2013 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.servlet.taglib.FileAvailabilityUtil;
018    import com.liferay.portal.theme.PortletDisplay;
019    import com.liferay.taglib.ui.IconTag;
020    
021    /**
022     * @author Brian Wing Shun Chan
023     * @author Shuyang Zhou
024     */
025    public class IconHelpTag extends IconTag {
026    
027            @Override
028            protected String getPage() {
029                    if (FileAvailabilityUtil.isAvailable(servletContext, _PAGE)) {
030                            return _PAGE;
031                    }
032    
033                    PortletDisplay portletDisplay =
034                            (PortletDisplay)pageContext.getAttribute("portletDisplay");
035    
036                    if (!portletDisplay.isShowHelpIcon()) {
037                            return null;
038                    }
039    
040                    setCssClass("portlet-help portlet-help-icon");
041                    setImage("../aui/question-sign");
042                    setMessage("help");
043                    setToolTip(false);
044                    setUrl(portletDisplay.getURLHelp());
045    
046                    return super.getPage();
047            }
048    
049            private static final String _PAGE =
050                    "/html/taglib/portlet/icon_help/page.jsp";
051    
052    }