PageRenderTime 23ms CodeModel.GetById 19ms app.highlight 1ms RepoModel.GetById 1ms app.codeStats 0ms

/hooks/so-hook/docroot/META-INF/custom_jsps/html/portlet/message_boards/view_category_question.jsp

https://github.com/l15k4/liferay-plugins
JavaServer Pages | 352 lines | 267 code | 69 blank | 16 comment | 10 complexity | 96d266562f8a432de5fa171e6112f1b6 MD5 | raw file
  1<%--
  2/**
  3 * Copyright (c) 2000-2011 Liferay, Inc. All rights reserved.
  4 *
  5 * This file is part of Liferay Social Office. Liferay Social Office is free
  6 * software: you can redistribute it and/or modify it under the terms of the GNU
  7 * Affero General Public License as published by the Free Software Foundation,
  8 * either version 3 of the License, or (at your option) any later version.
  9 *
 10 * Liferay Social Office is distributed in the hope that it will be useful, but
 11 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License
 13 * for more details.
 14 *
 15 * You should have received a copy of the GNU General Public License along with
 16 * Liferay Social Office. If not, see http://www.gnu.org/licenses/agpl-3.0.html.
 17 */
 18--%>
 19
 20<%@ include file="/html/portlet/message_boards/init.jsp" %>
 21
 22<%
 23MBCategory category = (MBCategory)request.getAttribute(WebKeys.MESSAGE_BOARDS_CATEGORY);
 24
 25long categoryId = MBUtil.getCategoryId(request, category);
 26
 27MBCategoryDisplay categoryDisplay = (MBCategoryDisplay)request.getAttribute("view.jsp-categoryDisplay");
 28
 29Set<Long> categorySubscriptionClassPKs = (Set<Long>)request.getAttribute("view.jsp-categorySubscriptionClassPKs");
 30Set<Long> threadSubscriptionClassPKs = (Set<Long>)request.getAttribute("view.jsp-threadSubscriptionClassPKs");
 31
 32Boolean showCategories = GetterUtil.getBoolean((String)request.getAttribute("view.jsp-viewCategory"), false);
 33
 34PortletURL portletURL = (PortletURL)request.getAttribute("view.jsp-portletURL");
 35%>
 36
 37<c:if test="<%= showCategories %>">
 38	<liferay-ui:search-container
 39		curParam="cur1"
 40		deltaConfigurable="<%= false %>"
 41		emptyResultsMessage="there-are-no-categories"
 42		headerNames="category"
 43		iteratorURL="<%= portletURL %>"
 44	>
 45		<liferay-ui:search-container-results
 46			results="<%= MBCategoryServiceUtil.getCategories(scopeGroupId, categoryId, searchContainer.getStart(), searchContainer.getEnd()) %>"
 47			total="<%= MBCategoryServiceUtil.getCategoriesCount(scopeGroupId, categoryId) %>"
 48		/>
 49
 50		<liferay-ui:search-container-row
 51			className="com.liferay.portlet.messageboards.model.MBCategory"
 52			escapedModel="<%= true %>"
 53			keyProperty="categoryId"
 54			modelVar="curCategory"
 55		>
 56			<liferay-ui:search-container-row-parameter name="categorySubscriptionClassPKs" value="<%= categorySubscriptionClassPKs %>" />
 57
 58			<liferay-portlet:renderURL varImpl="rowURL">
 59				<portlet:param name="struts_action" value="/message_boards/view" />
 60				<portlet:param name="mbCategoryId" value="<%= String.valueOf(curCategory.getCategoryId()) %>" />
 61			</liferay-portlet:renderURL>
 62
 63			<%@ include file="/html/portlet/message_boards/category_columns.so-hook.jspf" %>
 64		</liferay-ui:search-container-row>
 65
 66		<%
 67		boolean showAddCategoryButton = MBCategoryPermission.contains(permissionChecker, scopeGroupId, categoryId, ActionKeys.ADD_CATEGORY);
 68		boolean showPermissionsButton = GroupPermissionUtil.contains(permissionChecker, scopeGroupId, ActionKeys.PERMISSIONS);
 69		%>
 70
 71		<c:if test="<%= showAddCategoryButton || showPermissionsButton %>">
 72			<aui:button-row>
 73				<c:if test="<%= showAddCategoryButton %>">
 74					<portlet:renderURL var="editCategoryURL">
 75						<portlet:param name="struts_action" value="/message_boards/edit_category" />
 76						<portlet:param name="redirect" value="<%= currentURL %>" />
 77						<portlet:param name="parentCategoryId" value="<%= String.valueOf(categoryId) %>" />
 78					</portlet:renderURL>
 79
 80					<aui:button href='<%= editCategoryURL %>' value='<%= (category == null) ? "add-category" : "add-subcategory" %>' />
 81				</c:if>
 82
 83				<c:if test="<%= showPermissionsButton %>">
 84
 85					<%
 86					String modelResource = "com.liferay.portlet.messageboards";
 87					String modelResourceDescription = themeDisplay.getScopeGroupName();
 88					String resourcePrimKey = String.valueOf(scopeGroupId);
 89
 90					if (category != null) {
 91						modelResource = MBCategory.class.getName();
 92						modelResourceDescription = category.getName();
 93						resourcePrimKey = String.valueOf(category.getCategoryId());
 94					}
 95					%>
 96
 97					<liferay-security:permissionsURL
 98						modelResource="<%= modelResource %>"
 99						modelResourceDescription="<%= HtmlUtil.escape(modelResourceDescription) %>"
100						resourcePrimKey="<%= resourcePrimKey %>"
101						var="permissionsURL"
102					/>
103
104					<aui:button href="<%= permissionsURL %>" value="permissions" />
105				</c:if>
106			</aui:button-row>
107		</c:if>
108
109		<liferay-ui:search-iterator />
110	</liferay-ui:search-container>
111</c:if>
112
113<liferay-ui:search-container
114	curParam="cur2"
115	deltaConfigurable="<%= false %>"
116	emptyResultsMessage="there-are-no-threads"
117	headerNames="statistics,thread,last-post"
118	iteratorURL="<%= portletURL %>"
119>
120
121	<liferay-ui:search-container-results
122		results="<%= MBThreadServiceUtil.getThreads(scopeGroupId, categoryId, WorkflowConstants.STATUS_APPROVED, searchContainer.getStart(), searchContainer.getEnd()) %>"
123		total="<%= MBThreadServiceUtil.getThreadsCount(scopeGroupId, categoryId, WorkflowConstants.STATUS_APPROVED) %>"
124	/>
125
126	<liferay-ui:search-container-row
127		className="com.liferay.portlet.messageboards.model.MBThread"
128		keyProperty="threadId"
129		modelVar="thread"
130	>
131
132		<%
133		MBMessage message = null;
134
135		try {
136			message = MBMessageLocalServiceUtil.getMessage(thread.getRootMessageId());
137		}
138		catch (NoSuchMessageException nsme) {
139			_log.error("Thread requires missing root message id " + thread.getRootMessageId());
140
141			continue;
142		}
143
144		message = message.toEscapedModel();
145
146		row.setBold(!MBMessageFlagLocalServiceUtil.hasReadFlag(themeDisplay.getUserId(), thread));
147		row.setObject(new Object[] {message, threadSubscriptionClassPKs});
148		row.setRestricted(!MBMessagePermission.contains(permissionChecker, message, ActionKeys.VIEW));
149		%>
150
151		<liferay-portlet:renderURL varImpl="rowURL">
152			<portlet:param name="struts_action" value="/message_boards/view_message" />
153			<portlet:param name="messageId" value="<%= String.valueOf(message.getMessageId()) %>" />
154		</liferay-portlet:renderURL>
155
156		<liferay-ui:search-container-column-text
157			cssClass="stats"
158			name="statistics"
159		>
160
161			<%
162			int replies = MBMessageServiceUtil.getThreadMessagesCount(scopeGroupId, categoryId, thread.getThreadId(), WorkflowConstants.STATUS_ANY) - 1;
163
164			RatingsStats ratingsStats = RatingsStatsLocalServiceUtil.getStats(MBMessage.class.getName(), message.getMessageId());
165
166			int ratingScore = (int)ratingsStats.getTotalScore();
167			%>
168
169			<div class="votes">
170				<span class="count">
171					<%= String.valueOf(ratingScore) %>
172				</span>
173
174				<span>
175					<%= LanguageUtil.get(pageContext, "votes") %>
176				</span>
177			</div>
178
179			<div class="status <%= (replies != 0) ? "answered" : " unanswered" %> ">
180				<span class="count">
181					<%= replies %>
182				</span>
183
184				<span>
185					<%= LanguageUtil.get(pageContext, (replies != 1) ? "answers" : "answer") %>
186				</span>
187			</div>
188		</liferay-ui:search-container-column-text>
189
190		<liferay-ui:search-container-column-text
191			name="thread"
192		>
193
194			<div class="result-title">
195				<c:if test="<%= !row.isRestricted() %>">
196					<a href="<%= rowURL %>">
197				</c:if>
198
199				<%
200				String[] threadPriority = MBUtil.getThreadPriority(preferences, themeDisplay.getLanguageId(), thread.getPriority(), themeDisplay);
201				%>
202
203				<c:choose>
204					<c:when test="<%= (threadPriority != null) && (thread.getPriority() > 0) %>">
205						<img alt="<%= threadPriority[0] %>" class="thread-priority" src="<%= threadPriority[1] %>" title="<%= threadPriority[0] %>" />
206					</c:when>
207					<c:when test="<%= thread.isLocked() %>">
208						<img alt="<liferay-ui:message key="thread-locked" />" class="thread-priority" src="<%= themeDisplay.getPathThemeImages() + "/common/lock.png" %>" title="<liferay-ui:message key="thread-locked" />" />
209					</c:when>
210				</c:choose>
211
212				<%= message.getSubject() %>
213
214				<c:if test="<%= !row.isRestricted() %>">
215					</a>
216				</c:if>
217			</div>
218
219			<div class="result-data">
220				<span class="started-by">
221					<liferay-ui:message key="started-by" />:
222
223					<c:choose>
224						<c:when test="<%= message.isAnonymous() %>">
225							<liferay-ui:message key="anonymous" />
226						</c:when>
227						<c:otherwise>
228							<%= HtmlUtil.escape(PortalUtil.getUserName(message.getUserId(), message.getUserName())) %>
229						</c:otherwise>
230					</c:choose>
231				</span>
232
233				<span class="posts">
234					<liferay-ui:message key="posts" />:
235
236					<%= thread.getMessageCount() %>
237				</span>
238
239				<span class="views">
240					<liferay-ui:message key="views" />:
241
242					<%= thread.getViewCount() %>
243				</span>
244
245				<c:if test="<%= category == null %>">
246
247					<%
248					MBCategory curCategory = null;
249
250					try {
251						curCategory = MBCategoryLocalServiceUtil.getCategory(thread.getCategoryId());
252					}
253					catch (NoSuchCategoryException nsce) {
254					}
255					%>
256
257					<c:if test="<%= curCategory != null %>">
258						<liferay-portlet:renderURL varImpl="categoryURL">
259							<portlet:param name="struts_action" value="/message_boards/view" />
260							<portlet:param name="mbCategoryId" value="<%= String.valueOf(curCategory.getCategoryId()) %>" />
261						</liferay-portlet:renderURL>
262
263						<span class="category">
264							<liferay-ui:message key="category" />:
265
266							<a href="<%= categoryURL %>"><%= curCategory.getName() %></a>
267						</span>
268					</c:if>
269				</c:if>
270			</div>
271
272			<c:choose>
273				<c:when test="<%= MBMessageFlagLocalServiceUtil.hasQuestionFlag(message.getMessageId()) %>">
274					<div class="result-data">
275						<liferay-ui:message key="not-resolved" />
276					</div>
277				</c:when>
278				<c:when test="<%= MBMessageFlagLocalServiceUtil.hasAnswerFlag(message.getMessageId()) %>">
279					<div class="result-data">
280						<liferay-ui:message key="resolved" />
281					</div>
282				</c:when>
283			</c:choose>
284		</liferay-ui:search-container-column-text>
285
286		<liferay-ui:search-container-column-text
287			name="last-post"
288		>
289			<c:choose>
290				<c:when test="<%= thread.getLastPostDate() == null %>">
291					<liferay-ui:message key="none" />
292				</c:when>
293				<c:otherwise>
294					<div class="result-title">
295
296						<%
297						String lastPostByUserName = HtmlUtil.escape(PortalUtil.getUserName(thread.getLastPostByUserId(), StringPool.BLANK));
298
299						if (Validator.isNull(lastPostByUserName)) {
300							lastPostByUserName = LanguageUtil.get(pageContext, "anonymous");
301						}
302						%>
303
304						<%= lastPostByUserName %>
305					</div>
306					<div class="result-data">
307						<%= dateFormatDateTime.format(thread.getLastPostDate()) %>
308					</div>
309				</c:otherwise>
310			</c:choose>
311		</liferay-ui:search-container-column-text>
312
313		<liferay-ui:search-container-column-jsp
314			align="right"
315			path="/html/portlet/message_boards/message_action.jsp"
316		/>
317	</liferay-ui:search-container-row>
318
319	<c:if test="<%= category == null %>">
320		<liferay-ui:header title="recent-posts" />
321	</c:if>
322
323	<%
324	boolean showAddMessageButton = false;
325
326	if (category != null) {
327		showAddMessageButton = MBCategoryPermission.contains(permissionChecker, category, ActionKeys.ADD_MESSAGE);
328
329		if (showAddMessageButton && !themeDisplay.isSignedIn() && !allowAnonymousPosting) {
330			showAddMessageButton = false;
331		}
332	}
333	%>
334
335	<c:if test="<%= showAddMessageButton %>">
336		<aui:button-row>
337			<portlet:renderURL var="editMessageURL">
338				<portlet:param name="struts_action" value="/message_boards/edit_message" />
339				<portlet:param name="redirect" value="<%= currentURL %>" />
340				<portlet:param name="mbCategoryId" value="<%= String.valueOf(categoryId) %>" />
341			</portlet:renderURL>
342
343			<aui:button href='<%= editMessageURL %>' value="post-new-thread" />
344		</aui:button-row>
345	</c:if>
346
347	<liferay-ui:search-iterator />
348</liferay-ui:search-container>
349
350<%!
351private static Log _log = LogFactoryUtil.getLog("portal-web.docroot.html.portlet.message_boards.view_category_default_jsp");
352%>