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.ui;
016    
017    import com.liferay.portal.kernel.comment.Comment;
018    import com.liferay.portal.kernel.repository.model.FileEntry;
019    import com.liferay.portal.kernel.search.RelatedSearchResult;
020    import com.liferay.portal.kernel.util.GetterUtil;
021    import com.liferay.portal.kernel.util.HtmlUtil;
022    import com.liferay.portal.kernel.util.PropsKeys;
023    import com.liferay.portal.kernel.util.PropsUtil;
024    import com.liferay.taglib.util.IncludeTag;
025    
026    import java.util.List;
027    
028    import javax.servlet.ServletContext;
029    import javax.servlet.http.HttpServletRequest;
030    
031    /**
032     * @author Eudaldo Alonso
033     * @author Tibor Lipusz
034     */
035    public class AppViewSearchEntryTag extends IncludeTag {
036    
037            @Override
038            public int doStartTag() {
039                    return EVAL_BODY_INCLUDE;
040            }
041    
042            public void setActionJsp(String actionJsp) {
043                    _actionJsp = actionJsp;
044            }
045    
046            public void setActionJspServletContext(
047                    ServletContext actionJspServletContext) {
048    
049                    _actionJspServletContext = actionJspServletContext;
050            }
051    
052            public void setCommentRelatedSearchResults(
053                    List<RelatedSearchResult<Comment>> commentRelatedSearchResults) {
054    
055                    _commentRelatedSearchResults = commentRelatedSearchResults;
056            }
057    
058            public void setContainerName(String containerName) {
059                    _containerName = containerName;
060            }
061    
062            public void setContainerType(String containerType) {
063                    _containerType = containerType;
064            }
065    
066            public void setCssClass(String cssClass) {
067                    _cssClass = cssClass;
068            }
069    
070            public void setDescription(String description) {
071                    _description = HtmlUtil.unescape(description);
072            }
073    
074            public void setFileEntryRelatedSearchResults(
075                    List<RelatedSearchResult<FileEntry>> fileEntryRelatedSearchResults) {
076    
077                    _fileEntryRelatedSearchResults = fileEntryRelatedSearchResults;
078            }
079    
080            public void setHighlightEnabled(boolean highlightEnabled) {
081                    _highlightEnabled = highlightEnabled;
082            }
083    
084            public void setLocked(boolean locked) {
085                    _locked = locked;
086            }
087    
088            public void setQueryTerms(String[] queryTerms) {
089                    _queryTerms = queryTerms;
090            }
091    
092            public void setRowCheckerId(String rowCheckerId) {
093                    _rowCheckerId = rowCheckerId;
094            }
095    
096            public void setRowCheckerName(String rowCheckerName) {
097                    _rowCheckerName = rowCheckerName;
098            }
099    
100            public void setShowCheckbox(boolean showCheckbox) {
101                    _showCheckbox = showCheckbox;
102            }
103    
104            public void setStatus(int status) {
105                    _status = status;
106            }
107    
108            public void setThumbnailSrc(String thumbnailSrc) {
109                    _thumbnailSrc = thumbnailSrc;
110            }
111    
112            public void setTitle(String title) {
113                    _title = HtmlUtil.unescape(title);
114            }
115    
116            public void setUrl(String url) {
117                    _url = url;
118            }
119    
120            public void setVersions(List<String> versions) {
121                    _versions = versions;
122            }
123    
124            @Override
125            protected void cleanUp() {
126                    _actionJsp = null;
127                    _commentRelatedSearchResults = null;
128                    _containerName = null;
129                    _containerType = null;
130                    _cssClass = null;
131                    _description = null;
132                    _fileEntryRelatedSearchResults = null;
133                    _highlightEnabled = _HIGHLIGHT_ENABLED;
134                    _locked = false;
135                    _queryTerms = null;
136                    _rowCheckerId = null;
137                    _rowCheckerName = null;
138                    _showCheckbox = false;
139                    _status = 0;
140                    _thumbnailSrc = null;
141                    _title = null;
142                    _url = null;
143                    _versions = null;
144            }
145    
146            protected ServletContext getActionJspServletContext() {
147                    if (_actionJspServletContext != null) {
148                            return _actionJspServletContext;
149                    }
150    
151                    return servletContext;
152            }
153    
154            @Override
155            protected String getPage() {
156                    return _PAGE;
157            }
158    
159            @Override
160            protected boolean isCleanUpSetAttributes() {
161                    return _CLEAN_UP_SET_ATTRIBUTES;
162            }
163    
164            @Override
165            protected void setAttributes(HttpServletRequest request) {
166                    request.setAttribute(
167                            "liferay-ui:app-view-search-entry:actionJsp", _actionJsp);
168                    request.setAttribute(
169                            "liferay-ui:app-view-entry:actionJspServletContext",
170                            getActionJspServletContext());
171                    request.setAttribute(
172                            "liferay-ui:app-view-search-entry:commentRelatedSearchResults",
173                            _commentRelatedSearchResults);
174                    request.setAttribute(
175                            "liferay-ui:app-view-search-entry:containerName", _containerName);
176                    request.setAttribute(
177                            "liferay-ui:app-view-search-entry:containerType", _containerType);
178                    request.setAttribute(
179                            "liferay-ui:app-view-search-entry:cssClass", _cssClass);
180                    request.setAttribute(
181                            "liferay-ui:app-view-search-entry:description", _description);
182                    request.setAttribute(
183                            "liferay-ui:app-view-search-entry:fileEntryRelatedSearchResults",
184                            _fileEntryRelatedSearchResults);
185                    request.setAttribute(
186                            "liferay-ui:app-view-search-entry:highlightEnabled",
187                            _highlightEnabled);
188                    request.setAttribute(
189                            "liferay-ui:app-view-search-entry:locked", _locked);
190                    request.setAttribute(
191                            "liferay-ui:app-view-search-entry:queryTerms", _queryTerms);
192                    request.setAttribute(
193                            "liferay-ui:app-view-search-entry:rowCheckerId", _rowCheckerId);
194                    request.setAttribute(
195                            "liferay-ui:app-view-search-entry:rowCheckerName", _rowCheckerName);
196                    request.setAttribute(
197                            "liferay-ui:app-view-search-entry:showCheckbox", _showCheckbox);
198                    request.setAttribute(
199                            "liferay-ui:app-view-search-entry:status", _status);
200                    request.setAttribute(
201                            "liferay-ui:app-view-search-entry:thumbnailSrc", _thumbnailSrc);
202                    request.setAttribute("liferay-ui:app-view-search-entry:title", _title);
203                    request.setAttribute("liferay-ui:app-view-search-entry:url", _url);
204                    request.setAttribute(
205                            "liferay-ui:app-view-search-entry:versions", _versions);
206            }
207    
208            private static final boolean _CLEAN_UP_SET_ATTRIBUTES = true;
209    
210            private static final boolean _HIGHLIGHT_ENABLED = GetterUtil.getBoolean(
211                    PropsUtil.get(PropsKeys.INDEX_SEARCH_HIGHLIGHT_ENABLED));
212    
213            private static final String _PAGE =
214                    "/html/taglib/ui/app_view_search_entry/page.jsp";
215    
216            private String _actionJsp;
217            private ServletContext _actionJspServletContext;
218            private List<RelatedSearchResult<Comment>> _commentRelatedSearchResults;
219            private String _containerName;
220            private String _containerType;
221            private String _cssClass;
222            private String _description;
223            private List<RelatedSearchResult<FileEntry>> _fileEntryRelatedSearchResults;
224            private boolean _highlightEnabled = _HIGHLIGHT_ENABLED;
225            private boolean _locked;
226            private String[] _queryTerms;
227            private String _rowCheckerId;
228            private String _rowCheckerName;
229            private boolean _showCheckbox = false;
230            private int _status = 0;
231            private String _thumbnailSrc;
232            private String _title;
233            private String _url;
234            private List<String> _versions;
235    
236    }