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.ui;
016    
017    import com.liferay.portal.kernel.language.LanguageUtil;
018    import com.liferay.portal.kernel.servlet.taglib.FileAvailabilityUtil;
019    import com.liferay.portal.theme.ThemeDisplay;
020    import com.liferay.util.PwdGenerator;
021    
022    import javax.servlet.jsp.JspWriter;
023    
024    /**
025     * @author Scott Lee
026     * @author Shuyang Zhou
027     */
028    public class IconHelpTag extends IconTag {
029    
030            @Override
031            protected String getPage() {
032                    if (FileAvailabilityUtil.isAvailable(getServletContext(), _PAGE)) {
033                            return _PAGE;
034                    }
035                    else {
036                            return null;
037                    }
038            }
039    
040            @Override
041            protected int processEndTag() throws Exception {
042                    ThemeDisplay themeDisplay = (ThemeDisplay)pageContext.getAttribute(
043                            "themeDisplay");
044    
045                    JspWriter jspWriter = pageContext.getOut();
046    
047                    String id = PwdGenerator.getPassword(PwdGenerator.KEY3, 4);
048    
049                    jspWriter.write("<span class=\"taglib-icon-help\"><img alt=\"\" ");
050                    jspWriter.write("aria-labelledby=\"");
051                    jspWriter.write(id);
052                    jspWriter.write("\" ");
053                    jspWriter.write("onBlur=\"Liferay.Portal.ToolTip.hide();\" ");
054                    jspWriter.write("onFocus=\"Liferay.Portal.ToolTip.show(this);\" ");
055                    jspWriter.write("onMouseOver=\"Liferay.Portal.ToolTip.show(this);\" ");
056                    jspWriter.write("src=\"");
057                    jspWriter.write(themeDisplay.getPathThemeImages());
058                    jspWriter.write("/portlet/help.png\" tabIndex=\"0\" ");
059                    jspWriter.write("/><span ");
060                    jspWriter.write("class=\"aui-helper-hidden-accessible tooltip-text\" ");
061                    jspWriter.write("id=\"");
062                    jspWriter.write(id);
063                    jspWriter.write("\" >");
064                    jspWriter.write(LanguageUtil.get(pageContext, getMessage()));
065                    jspWriter.write("</span></span>");
066    
067                    return EVAL_PAGE;
068            }
069    
070            private static final String _PAGE = "/html/taglib/ui/icon_help/page.jsp";
071    
072    }