PageRenderTime 52ms CodeModel.GetById 21ms 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 | 9 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. <%@ include file="/html/portlet/message_boards/init.jsp" %>
  20. <%
  21. MBCategory category = (MBCategory)request.getAttribute(WebKeys.MESSAGE_BOARDS_CATEGORY);
  22. long categoryId = MBUtil.getCategoryId(request, category);
  23. MBCategoryDisplay categoryDisplay = (MBCategoryDisplay)request.getAttribute("view.jsp-categoryDisplay");
  24. Set<Long> categorySubscriptionClassPKs = (Set<Long>)request.getAttribute("view.jsp-categorySubscriptionClassPKs");
  25. Set<Long> threadSubscriptionClassPKs = (Set<Long>)request.getAttribute("view.jsp-threadSubscriptionClassPKs");
  26. Boolean showCategories = GetterUtil.getBoolean((String)request.getAttribute("view.jsp-viewCategory"), false);
  27. PortletURL portletURL = (PortletURL)request.getAttribute("view.jsp-portletURL");
  28. %>
  29. <c:if test="<%= showCategories %>">
  30. <liferay-ui:search-container
  31. curParam="cur1"
  32. deltaConfigurable="<%= false %>"
  33. emptyResultsMessage="there-are-no-categories"
  34. headerNames="category"
  35. iteratorURL="<%= portletURL %>"
  36. >
  37. <liferay-ui:search-container-results
  38. results="<%= MBCategoryServiceUtil.getCategories(scopeGroupId, categoryId, searchContainer.getStart(), searchContainer.getEnd()) %>"
  39. total="<%= MBCategoryServiceUtil.getCategoriesCount(scopeGroupId, categoryId) %>"
  40. />
  41. <liferay-ui:search-container-row
  42. className="com.liferay.portlet.messageboards.model.MBCategory"
  43. escapedModel="<%= true %>"
  44. keyProperty="categoryId"
  45. modelVar="curCategory"
  46. >
  47. <liferay-ui:search-container-row-parameter name="categorySubscriptionClassPKs" value="<%= categorySubscriptionClassPKs %>" />
  48. <liferay-portlet:renderURL varImpl="rowURL">
  49. <portlet:param name="struts_action" value="/message_boards/view" />
  50. <portlet:param name="mbCategoryId" value="<%= String.valueOf(curCategory.getCategoryId()) %>" />
  51. </liferay-portlet:renderURL>
  52. <%@ include file="/html/portlet/message_boards/category_columns.so-hook.jspf" %>
  53. </liferay-ui:search-container-row>
  54. <%
  55. boolean showAddCategoryButton = MBCategoryPermission.contains(permissionChecker, scopeGroupId, categoryId, ActionKeys.ADD_CATEGORY);
  56. boolean showPermissionsButton = GroupPermissionUtil.contains(permissionChecker, scopeGroupId, ActionKeys.PERMISSIONS);
  57. %>
  58. <c:if test="<%= showAddCategoryButton || showPermissionsButton %>">
  59. <aui:button-row>
  60. <c:if test="<%= showAddCategoryButton %>">
  61. <portlet:renderURL var="editCategoryURL">
  62. <portlet:param name="struts_action" value="/message_boards/edit_category" />
  63. <portlet:param name="redirect" value="<%= currentURL %>" />
  64. <portlet:param name="parentCategoryId" value="<%= String.valueOf(categoryId) %>" />
  65. </portlet:renderURL>
  66. <aui:button href='<%= editCategoryURL %>' value='<%= (category == null) ? "add-category" : "add-subcategory" %>' />
  67. </c:if>
  68. <c:if test="<%= showPermissionsButton %>">
  69. <%
  70. String modelResource = "com.liferay.portlet.messageboards";
  71. String modelResourceDescription = themeDisplay.getScopeGroupName();
  72. String resourcePrimKey = String.valueOf(scopeGroupId);
  73. if (category != null) {
  74. modelResource = MBCategory.class.getName();
  75. modelResourceDescription = category.getName();
  76. resourcePrimKey = String.valueOf(category.getCategoryId());
  77. }
  78. %>
  79. <liferay-security:permissionsURL
  80. modelResource="<%= modelResource %>"
  81. modelResourceDescription="<%= HtmlUtil.escape(modelResourceDescription) %>"
  82. resourcePrimKey="<%= resourcePrimKey %>"
  83. var="permissionsURL"
  84. />
  85. <aui:button href="<%= permissionsURL %>" value="permissions" />
  86. </c:if>
  87. </aui:button-row>
  88. </c:if>
  89. <liferay-ui:search-iterator />
  90. </liferay-ui:search-container>
  91. </c:if>
  92. <liferay-ui:search-container
  93. curParam="cur2"
  94. deltaConfigurable="<%= false %>"
  95. emptyResultsMessage="there-are-no-threads"
  96. headerNames="statistics,thread,last-post"
  97. iteratorURL="<%= portletURL %>"
  98. >
  99. <liferay-ui:search-container-results
  100. results="<%= MBThreadServiceUtil.getThreads(scopeGroupId, categoryId, WorkflowConstants.STATUS_APPROVED, searchContainer.getStart(), searchContainer.getEnd()) %>"
  101. total="<%= MBThreadServiceUtil.getThreadsCount(scopeGroupId, categoryId, WorkflowConstants.STATUS_APPROVED) %>"
  102. />
  103. <liferay-ui:search-container-row
  104. className="com.liferay.portlet.messageboards.model.MBThread"
  105. keyProperty="threadId"
  106. modelVar="thread"
  107. >
  108. <%
  109. MBMessage message = null;
  110. try {
  111. message = MBMessageLocalServiceUtil.getMessage(thread.getRootMessageId());
  112. }
  113. catch (NoSuchMessageException nsme) {
  114. _log.error("Thread requires missing root message id " + thread.getRootMessageId());
  115. continue;
  116. }
  117. message = message.toEscapedModel();
  118. row.setBold(!MBMessageFlagLocalServiceUtil.hasReadFlag(themeDisplay.getUserId(), thread));
  119. row.setObject(new Object[] {message, threadSubscriptionClassPKs});
  120. row.setRestricted(!MBMessagePermission.contains(permissionChecker, message, ActionKeys.VIEW));
  121. %>
  122. <liferay-portlet:renderURL varImpl="rowURL">
  123. <portlet:param name="struts_action" value="/message_boards/view_message" />
  124. <portlet:param name="messageId" value="<%= String.valueOf(message.getMessageId()) %>" />
  125. </liferay-portlet:renderURL>
  126. <liferay-ui:search-container-column-text
  127. cssClass="stats"
  128. name="statistics"
  129. >
  130. <%
  131. int replies = MBMessageServiceUtil.getThreadMessagesCount(scopeGroupId, categoryId, thread.getThreadId(), WorkflowConstants.STATUS_ANY) - 1;
  132. RatingsStats ratingsStats = RatingsStatsLocalServiceUtil.getStats(MBMessage.class.getName(), message.getMessageId());
  133. int ratingScore = (int)ratingsStats.getTotalScore();
  134. %>
  135. <div class="votes">
  136. <span class="count">
  137. <%= String.valueOf(ratingScore) %>
  138. </span>
  139. <span>
  140. <%= LanguageUtil.get(pageContext, "votes") %>
  141. </span>
  142. </div>
  143. <div class="status <%= (replies != 0) ? "answered" : " unanswered" %> ">
  144. <span class="count">
  145. <%= replies %>
  146. </span>
  147. <span>
  148. <%= LanguageUtil.get(pageContext, (replies != 1) ? "answers" : "answer") %>
  149. </span>
  150. </div>
  151. </liferay-ui:search-container-column-text>
  152. <liferay-ui:search-container-column-text
  153. name="thread"
  154. >
  155. <div class="result-title">
  156. <c:if test="<%= !row.isRestricted() %>">
  157. <a href="<%= rowURL %>">
  158. </c:if>
  159. <%
  160. String[] threadPriority = MBUtil.getThreadPriority(preferences, themeDisplay.getLanguageId(), thread.getPriority(), themeDisplay);
  161. %>
  162. <c:choose>
  163. <c:when test="<%= (threadPriority != null) && (thread.getPriority() > 0) %>">
  164. <img alt="<%= threadPriority[0] %>" class="thread-priority" src="<%= threadPriority[1] %>" title="<%= threadPriority[0] %>" />
  165. </c:when>
  166. <c:when test="<%= thread.isLocked() %>">
  167. <img alt="<liferay-ui:message key="thread-locked" />" class="thread-priority" src="<%= themeDisplay.getPathThemeImages() + "/common/lock.png" %>" title="<liferay-ui:message key="thread-locked" />" />
  168. </c:when>
  169. </c:choose>
  170. <%= message.getSubject() %>
  171. <c:if test="<%= !row.isRestricted() %>">
  172. </a>
  173. </c:if>
  174. </div>
  175. <div class="result-data">
  176. <span class="started-by">
  177. <liferay-ui:message key="started-by" />:
  178. <c:choose>
  179. <c:when test="<%= message.isAnonymous() %>">
  180. <liferay-ui:message key="anonymous" />
  181. </c:when>
  182. <c:otherwise>
  183. <%= HtmlUtil.escape(PortalUtil.getUserName(message.getUserId(), message.getUserName())) %>
  184. </c:otherwise>
  185. </c:choose>
  186. </span>
  187. <span class="posts">
  188. <liferay-ui:message key="posts" />:
  189. <%= thread.getMessageCount() %>
  190. </span>
  191. <span class="views">
  192. <liferay-ui:message key="views" />:
  193. <%= thread.getViewCount() %>
  194. </span>
  195. <c:if test="<%= category == null %>">
  196. <%
  197. MBCategory curCategory = null;
  198. try {
  199. curCategory = MBCategoryLocalServiceUtil.getCategory(thread.getCategoryId());
  200. }
  201. catch (NoSuchCategoryException nsce) {
  202. }
  203. %>
  204. <c:if test="<%= curCategory != null %>">
  205. <liferay-portlet:renderURL varImpl="categoryURL">
  206. <portlet:param name="struts_action" value="/message_boards/view" />
  207. <portlet:param name="mbCategoryId" value="<%= String.valueOf(curCategory.getCategoryId()) %>" />
  208. </liferay-portlet:renderURL>
  209. <span class="category">
  210. <liferay-ui:message key="category" />:
  211. <a href="<%= categoryURL %>"><%= curCategory.getName() %></a>
  212. </span>
  213. </c:if>
  214. </c:if>
  215. </div>
  216. <c:choose>
  217. <c:when test="<%= MBMessageFlagLocalServiceUtil.hasQuestionFlag(message.getMessageId()) %>">
  218. <div class="result-data">
  219. <liferay-ui:message key="not-resolved" />
  220. </div>
  221. </c:when>
  222. <c:when test="<%= MBMessageFlagLocalServiceUtil.hasAnswerFlag(message.getMessageId()) %>">
  223. <div class="result-data">
  224. <liferay-ui:message key="resolved" />
  225. </div>
  226. </c:when>
  227. </c:choose>
  228. </liferay-ui:search-container-column-text>
  229. <liferay-ui:search-container-column-text
  230. name="last-post"
  231. >
  232. <c:choose>
  233. <c:when test="<%= thread.getLastPostDate() == null %>">
  234. <liferay-ui:message key="none" />
  235. </c:when>
  236. <c:otherwise>
  237. <div class="result-title">
  238. <%
  239. String lastPostByUserName = HtmlUtil.escape(PortalUtil.getUserName(thread.getLastPostByUserId(), StringPool.BLANK));
  240. if (Validator.isNull(lastPostByUserName)) {
  241. lastPostByUserName = LanguageUtil.get(pageContext, "anonymous");
  242. }
  243. %>
  244. <%= lastPostByUserName %>
  245. </div>
  246. <div class="result-data">
  247. <%= dateFormatDateTime.format(thread.getLastPostDate()) %>
  248. </div>
  249. </c:otherwise>
  250. </c:choose>
  251. </liferay-ui:search-container-column-text>
  252. <liferay-ui:search-container-column-jsp
  253. align="right"
  254. path="/html/portlet/message_boards/message_action.jsp"
  255. />
  256. </liferay-ui:search-container-row>
  257. <c:if test="<%= category == null %>">
  258. <liferay-ui:header title="recent-posts" />
  259. </c:if>
  260. <%
  261. boolean showAddMessageButton = false;
  262. if (category != null) {
  263. showAddMessageButton = MBCategoryPermission.contains(permissionChecker, category, ActionKeys.ADD_MESSAGE);
  264. if (showAddMessageButton && !themeDisplay.isSignedIn() && !allowAnonymousPosting) {
  265. showAddMessageButton = false;
  266. }
  267. }
  268. %>
  269. <c:if test="<%= showAddMessageButton %>">
  270. <aui:button-row>
  271. <portlet:renderURL var="editMessageURL">
  272. <portlet:param name="struts_action" value="/message_boards/edit_message" />
  273. <portlet:param name="redirect" value="<%= currentURL %>" />
  274. <portlet:param name="mbCategoryId" value="<%= String.valueOf(categoryId) %>" />
  275. </portlet:renderURL>
  276. <aui:button href='<%= editMessageURL %>' value="post-new-thread" />
  277. </aui:button-row>
  278. </c:if>
  279. <liferay-ui:search-iterator />
  280. </liferay-ui:search-container>
  281. <%!
  282. private static Log _log = LogFactoryUtil.getLog("portal-web.docroot.html.portlet.message_boards.view_category_default_jsp");
  283. %>