WebSiteArticleService.java 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467
  1. package space.apps.moudules.website.template.ffkjcollegered1;
  2. import apps.pojo.Article;
  3. import apps.pojo.Website;
  4. import apps.pojo.WebsiteNavigation;
  5. import java.util.ArrayList;
  6. import java.util.HashMap;
  7. import java.util.List;
  8. import java.util.Map;
  9. import space.apps.moudules.basic.util.SortOrderUtil;
  10. import space.apps.moudules.website.template.common.WebsiteArticleManager;
  11. import space.apps.moudules.website.template.common.WebsiteCommonService;
  12. import space.apps.moudules.website.template.common.WebsiteNavManager;
  13. import space.apps.moudules.website.template.common.WebsiteTmplateConstvars.navigationType;
  14. import space.apps.moudules.website.template.common.bean.NavigationMiniView;
  15. import space.apps.moudules.website.template.util.WebsiteTemplateArticleUtil;
  16. import space.apps.moudules.website.template.util.WebsiteTemplateNavUtil;
  17. import space.core.apps.common.BaseTransaction;
  18. import space.core.db.bean.base.PageBean;
  19. import space.core.db.jdbc.GeneralDBAccess;
  20. import space.core.db.jdbc.SqlCommandImpl;
  21. /**
  22. * 非繁二级网站模板-红色服务。
  23. */
  24. public class WebSiteArticleService extends BaseTransaction {
  25. private static final long serialVersionUID = 1L;
  26. private static final String SCREEN_RED_THEME_CLASS = "screen-red-theme";
  27. private static final String HOME_GROUP_NAV_IDCARD = "FFKJ_COLLEGE_HOME_GROUP";
  28. private static final String UTILITY_LINK_NAV_IDCARD = "FFKJ_COLLEGE_SCHOOL_HOME";
  29. private static final String FOOTER_INFO_NAV_IDCARD = "FFKJ_COLLEGE_FOOTER_INFO";
  30. private static final String FOOTER_LINK_NAV_IDCARD = "FFKJ_COLLEGE_FOOTER_LINKS";
  31. private static final String INITIAL_TITLE_SUFFIX = "【初始】";
  32. private static final String DEFAULT_SCHOOL_HOME_NAME = "学校首页";
  33. private static final String DEFAULT_SCHOOL_HOME_URL = "https://hxcs.feifan.net/";
  34. private static final String DEFAULT_SITE_HOME_NAME = "本站首页";
  35. private static final String DEFAULT_SITE_HOME_URL = "/";
  36. private static final String DEFAULT_FOOTER_ADDRESS = "中国 广东省广州市从化城鳌大道东772号";
  37. private static final String DEFAULT_FOOTER_OFFICE_PHONE = "校办电话:020-87868999";
  38. private static final String DEFAULT_FOOTER_ADMISSION_PHONE = "招生电话:020-87865222";
  39. private static final String DEFAULT_FOOTER_EMPLOYMENT_PHONE = "就业办:020-87868935";
  40. private static final String DEFAULT_FOOTER_COPYRIGHT_ENGLISH =
  41. "Copyright © Guangzhou Huaxia Vocational College All Rights Reserved";
  42. private static final String DEFAULT_FOOTER_BEIAN_TEXT = "粤ICP备12042111号";
  43. private static final String DEFAULT_FOOTER_BEIAN_URL = "https://beian.miit.gov.cn/";
  44. public String controller() throws Exception {
  45. GeneralDBAccess gdba = getGdbaInstance();
  46. Website website = getWebsite();
  47. setThemeAttributes(gdba, website);
  48. WebsiteNavigation nav = WebsiteNavManager.getNavigationByURI(gdba, website, getRequest().getRequestURI());
  49. if (nav != null && navigationType.CATALOG.getCode().equals(nav.getWntcode())) {
  50. setCatalogAttributes(gdba, website, nav);
  51. return "toCatalog";
  52. }
  53. return WebsiteCommonService.controller(gdba, website, 10, getRequest());
  54. }
  55. public String details() throws Exception {
  56. GeneralDBAccess gdba = getGdbaInstance();
  57. Website website = getWebsite();
  58. setThemeAttributes(gdba, website);
  59. String forward = WebsiteCommonService.details(gdba, website, getRequest());
  60. setArticleExtras(gdba, website);
  61. return forward;
  62. }
  63. public String index() throws Exception {
  64. GeneralDBAccess gdba = getGdbaInstance();
  65. Website website = getWebsite();
  66. WebsiteCommonService.selectHeadNavigation(gdba, website, getRequest());
  67. setRequestAttribute("website", website);
  68. setThemeAttributes(gdba, website);
  69. setNavView(gdba, website, "collegeHeroNmv", "FFKJ_COLLEGE_HOME_HERO", 3, true);
  70. setNavView(gdba, website, "collegeNewsNmv", "FFKJ_COLLEGE_NEWS", 5, false);
  71. setNavView(gdba, website, "collegeNoticeNmv", "FFKJ_COLLEGE_NOTICE", 4, false);
  72. setNavView(gdba, website, "collegeMajorNmv", "FFKJ_COLLEGE_MAJOR", 4, false);
  73. setHomeSectionRows(gdba, website);
  74. return DEFAULT_FORWARD;
  75. }
  76. public String search() throws Exception {
  77. GeneralDBAccess gdba = getGdbaInstance();
  78. Website website = getWebsite();
  79. String forward = WebsiteCommonService.search(gdba, website, getRequest(), 10);
  80. setThemeAttributes(gdba, website);
  81. return forward;
  82. }
  83. private void setThemeAttributes(GeneralDBAccess gdba, Website website) {
  84. setRequestAttribute("portalThemeClass", SCREEN_RED_THEME_CLASS);
  85. setRequestAttribute("portalThemeStyle", buildPortalThemeStyle(website));
  86. setUtilityLinks(gdba, website);
  87. setFooterInfo(gdba, website);
  88. setFooterLinks(gdba, website);
  89. }
  90. private String buildPortalThemeStyle(Website website) {
  91. String themeColor = getThemeColor(website);
  92. if (themeColor.length() == 0) {
  93. return "";
  94. }
  95. int[] rgb = parseHexColor(themeColor);
  96. int[] darkRgb = blendColor(rgb, new int[] { 0, 0, 0 }, 0.2);
  97. int[] brightRgb = blendColor(rgb, new int[] { 255, 255, 255 }, 0.14);
  98. String darkColor = toHexColor(darkRgb);
  99. String brightColor = toHexColor(brightRgb);
  100. return "body.screen-red-theme,.screen-red-theme{--hx-red:" + themeColor + ";--hx-red-dark:"
  101. + darkColor + ";--hx-red-bright:" + brightColor + ";--hx-red-rgb:" + toRgbText(rgb)
  102. + ";--hx-red-dark-rgb:" + toRgbText(darkRgb) + ";--hx-red-bright-rgb:"
  103. + toRgbText(brightRgb) + ";}";
  104. }
  105. private String getThemeColor(Website website) {
  106. if (website == null || website.getWhiteLogoFile() == null) {
  107. return "";
  108. }
  109. String value = website.getWhiteLogoFile().trim();
  110. if (!value.matches("#[0-9a-fA-F]{6}")) {
  111. return "";
  112. }
  113. return value.toLowerCase();
  114. }
  115. private int[] parseHexColor(String hexColor) {
  116. return new int[] { Integer.parseInt(hexColor.substring(1, 3), 16),
  117. Integer.parseInt(hexColor.substring(3, 5), 16),
  118. Integer.parseInt(hexColor.substring(5, 7), 16) };
  119. }
  120. private int[] blendColor(int[] sourceRgb, int[] targetRgb, double ratio) {
  121. int[] result = new int[3];
  122. for (int index = 0; index < result.length; index++) {
  123. result[index] = clampColor((int) Math.round(sourceRgb[index] * (1 - ratio) + targetRgb[index] * ratio));
  124. }
  125. return result;
  126. }
  127. private int clampColor(int value) {
  128. if (value < 0) {
  129. return 0;
  130. }
  131. if (value > 255) {
  132. return 255;
  133. }
  134. return value;
  135. }
  136. private String toHexColor(int[] rgb) {
  137. return "#" + toHexPart(rgb[0]) + toHexPart(rgb[1]) + toHexPart(rgb[2]);
  138. }
  139. private String toHexPart(int value) {
  140. String hex = Integer.toHexString(clampColor(value));
  141. return hex.length() == 1 ? "0" + hex : hex;
  142. }
  143. private String toRgbText(int[] rgb) {
  144. return rgb[0] + ", " + rgb[1] + ", " + rgb[2];
  145. }
  146. private void setUtilityLinks(GeneralDBAccess gdba, Website website) {
  147. String schoolHomeName = DEFAULT_SCHOOL_HOME_NAME;
  148. String schoolHomeUrl = DEFAULT_SCHOOL_HOME_URL;
  149. String siteHomeName = DEFAULT_SITE_HOME_NAME;
  150. String siteHomeUrl = DEFAULT_SITE_HOME_URL;
  151. try {
  152. setRequestAttribute("utilityLinksNmv",
  153. WebsiteNavManager.getArticleListByNavIDCard(gdba, website, UTILITY_LINK_NAV_IDCARD, 8));
  154. Map<String, Object> schoolHome = getUtilityLinkArticle(gdba, website, DEFAULT_SCHOOL_HOME_NAME);
  155. schoolHomeName = firstNotBlank(schoolHome.get("title"), schoolHomeName);
  156. schoolHomeUrl = firstNotBlank(schoolHome.get("url"), schoolHomeUrl);
  157. Map<String, Object> siteHome = getUtilityLinkArticle(gdba, website, DEFAULT_SITE_HOME_NAME);
  158. siteHomeName = firstNotBlank(siteHome.get("title"), siteHomeName);
  159. siteHomeUrl = firstNotBlank(siteHome.get("url"), siteHomeUrl);
  160. } catch (Exception e) {
  161. // 缺少隐藏栏目或文章时保持默认入口,不影响页面打开。
  162. setRequestAttribute("utilityLinksNmv", new NavigationMiniView());
  163. }
  164. setRequestAttribute("schoolHomeName", schoolHomeName);
  165. setRequestAttribute("schoolHomeUrl", schoolHomeUrl);
  166. setRequestAttribute("siteHomeName", siteHomeName);
  167. setRequestAttribute("siteHomeUrl", siteHomeUrl);
  168. }
  169. private void setFooterInfo(GeneralDBAccess gdba, Website website) {
  170. String websiteName = website == null ? "" : firstNotBlank(website.getName(), "");
  171. String footerAddress = DEFAULT_FOOTER_ADDRESS;
  172. String footerOfficePhone = DEFAULT_FOOTER_OFFICE_PHONE;
  173. String footerAdmissionPhone = DEFAULT_FOOTER_ADMISSION_PHONE;
  174. String footerEmploymentPhone = DEFAULT_FOOTER_EMPLOYMENT_PHONE;
  175. String footerOwner = "版权所有:" + websiteName;
  176. String footerLogo = "";
  177. String footerLogoAlt = websiteName;
  178. String footerCopyright = DEFAULT_FOOTER_COPYRIGHT_ENGLISH;
  179. String footerBeianText = DEFAULT_FOOTER_BEIAN_TEXT;
  180. String footerBeianUrl = DEFAULT_FOOTER_BEIAN_URL;
  181. try {
  182. NavigationMiniView footerInfoNmv = WebsiteNavManager.getArticleListByNavIDCard(gdba, website,
  183. FOOTER_INFO_NAV_IDCARD, 16);
  184. setRequestAttribute("footerInfoNmv", footerInfoNmv);
  185. Map<String, Map<String, Object>> footerInfoArticleMap = buildFooterInfoArticleMap(footerInfoNmv);
  186. footerAddress = firstNotBlank(getFooterInfoDesc(footerInfoArticleMap, "地址"), footerAddress);
  187. footerOfficePhone = firstNotBlank(getFooterInfoDesc(footerInfoArticleMap, "校办电话"), footerOfficePhone);
  188. footerAdmissionPhone = firstNotBlank(getFooterInfoDesc(footerInfoArticleMap, "招生电话"),
  189. footerAdmissionPhone);
  190. footerEmploymentPhone = firstNotBlank(getFooterInfoDesc(footerInfoArticleMap, "就业办"),
  191. footerEmploymentPhone);
  192. footerOwner = firstNotBlank(getFooterInfoDesc(footerInfoArticleMap, "版权所有"), footerOwner);
  193. footerLogo = firstNotBlank(getFooterInfoThumbnail(footerInfoArticleMap, "底部LOGO"), footerLogo);
  194. footerLogoAlt = firstNotBlank(getFooterInfoDesc(footerInfoArticleMap, "底部LOGO"), footerLogoAlt);
  195. footerCopyright = firstNotBlank(getFooterInfoDesc(footerInfoArticleMap, "版权英文"), footerCopyright);
  196. footerBeianText = firstNotBlank(getFooterInfoDesc(footerInfoArticleMap, "备案信息"), footerBeianText);
  197. footerBeianUrl = firstNotBlank(getFooterInfoUrl(footerInfoArticleMap, "备案信息"), footerBeianUrl);
  198. } catch (Exception e) {
  199. setRequestAttribute("footerInfoNmv", new NavigationMiniView());
  200. }
  201. setRequestAttribute("footerAddressText", footerAddress);
  202. setRequestAttribute("footerOfficePhoneText", footerOfficePhone);
  203. setRequestAttribute("footerAdmissionPhoneText", footerAdmissionPhone);
  204. setRequestAttribute("footerEmploymentPhoneText", footerEmploymentPhone);
  205. setRequestAttribute("footerOwnerText", footerOwner);
  206. setRequestAttribute("footerLogoUrl", footerLogo);
  207. setRequestAttribute("footerLogoAlt", footerLogoAlt);
  208. setRequestAttribute("footerCopyrightText", footerCopyright);
  209. setRequestAttribute("footerBeianText", footerBeianText);
  210. setRequestAttribute("footerBeianUrl", footerBeianUrl);
  211. }
  212. private Map<String, Map<String, Object>> buildFooterInfoArticleMap(NavigationMiniView footerInfoNmv) {
  213. Map<String, Map<String, Object>> footerInfoArticleMap = new HashMap<String, Map<String, Object>>();
  214. if (footerInfoNmv == null || footerInfoNmv.getArticleList() == null) {
  215. return footerInfoArticleMap;
  216. }
  217. for (Map<String, Object> articleMap : footerInfoNmv.getArticleList()) {
  218. if (articleMap == null || articleMap.get("title") == null) {
  219. continue;
  220. }
  221. String title = normalizeFooterInfoTitle(articleMap.get("title").toString());
  222. if (title.length() > 0 && !footerInfoArticleMap.containsKey(title)) {
  223. footerInfoArticleMap.put(title, articleMap);
  224. }
  225. }
  226. return footerInfoArticleMap;
  227. }
  228. private String normalizeFooterInfoTitle(String title) {
  229. if (title == null) {
  230. return "";
  231. }
  232. String normalizedTitle = title.trim();
  233. while (normalizedTitle.endsWith(INITIAL_TITLE_SUFFIX)) {
  234. normalizedTitle = normalizedTitle.substring(0, normalizedTitle.length() - INITIAL_TITLE_SUFFIX.length())
  235. .trim();
  236. }
  237. return normalizedTitle;
  238. }
  239. private Object getFooterInfoDesc(Map<String, Map<String, Object>> footerInfoArticleMap, String title) {
  240. return getFooterInfoField(footerInfoArticleMap, title, "desc");
  241. }
  242. private Object getFooterInfoThumbnail(Map<String, Map<String, Object>> footerInfoArticleMap, String title) {
  243. return getFooterInfoField(footerInfoArticleMap, title, "thumbnail");
  244. }
  245. private Object getFooterInfoUrl(Map<String, Map<String, Object>> footerInfoArticleMap, String title) {
  246. return getFooterInfoField(footerInfoArticleMap, title, "url");
  247. }
  248. private Object getFooterInfoField(Map<String, Map<String, Object>> footerInfoArticleMap, String title, String field) {
  249. if (footerInfoArticleMap == null || !footerInfoArticleMap.containsKey(title)) {
  250. return null;
  251. }
  252. return footerInfoArticleMap.get(title).get(field);
  253. }
  254. private void setFooterLinks(GeneralDBAccess gdba, Website website) {
  255. try {
  256. setRequestAttribute("footerLinksNmv",
  257. WebsiteNavManager.getArticleListByNavIDCard(gdba, website, FOOTER_LINK_NAV_IDCARD, 8));
  258. } catch (Exception e) {
  259. setRequestAttribute("footerLinksNmv", new NavigationMiniView());
  260. }
  261. }
  262. private Map<String, Object> getUtilityLinkArticle(GeneralDBAccess gdba, Website website, String title)
  263. throws Exception {
  264. String sql = "SELECT a.title, a.url FROM article a "
  265. + "JOIN website_navigation wn ON wn.navigationid = a.navigationid "
  266. + "WHERE a.dcode = 61 AND a.ascode = '10010' AND a.`release` = 1 "
  267. + "AND wn.dcode = 61 AND wn.wnccode = 10000 "
  268. + "AND wn.websiteid = :websiteid AND wn.idcard = :idcard "
  269. + "AND a.title = :title "
  270. + "ORDER BY " + SortOrderUtil.articleSort("a") + " LIMIT 1";
  271. SqlCommandImpl sqlCmd = new SqlCommandImpl(sql);
  272. sqlCmd.setString("websiteid", website.getWebsiteid()).setString("idcard", UTILITY_LINK_NAV_IDCARD)
  273. .setString("title", title);
  274. Map<String, Object> article = gdba.selectAsMap(sqlCmd);
  275. return article == null ? new java.util.HashMap<String, Object>() : article;
  276. }
  277. private String firstNotBlank(Object value, String fallback) {
  278. if (value == null) {
  279. return fallback;
  280. }
  281. String text = value.toString().trim();
  282. return text.length() == 0 ? fallback : text;
  283. }
  284. private void setNavView(GeneralDBAccess gdba, Website website, String attrName, String idcard, int size,
  285. boolean thumbnailOnly) throws Exception {
  286. try {
  287. NavigationMiniView nmv = thumbnailOnly
  288. ? WebsiteNavManager.getArticleThumbnailListByNavIDCard(gdba, website, idcard, size)
  289. : WebsiteNavManager.getArticleListByNavIDCard(gdba, website, idcard, size);
  290. setRequestAttribute(attrName, nmv);
  291. } catch (Exception e) {
  292. setRequestAttribute(attrName, new NavigationMiniView());
  293. }
  294. }
  295. private void setHomeSectionRows(GeneralDBAccess gdba, Website website) throws Exception {
  296. List<NavigationMiniView> sectionList = new ArrayList<NavigationMiniView>();
  297. List<Map<String, Object>> homeChildNavList = getHomeChildNavigation(gdba, website);
  298. if (homeChildNavList != null) {
  299. for (Map<String, Object> navMap : getHomeSectionNavigationList(homeChildNavList)) {
  300. if (!isDynamicHomeSection(navMap)) {
  301. continue;
  302. }
  303. try {
  304. NavigationMiniView section = buildNavigationMiniView(gdba, navMap, 5);
  305. sectionList.add(section);
  306. } catch (Exception e) {
  307. // 单个自定义栏目数据异常时跳过,避免影响首页其他栏目。
  308. }
  309. }
  310. }
  311. setRequestAttribute("collegeHomeSectionRows", groupSections(sectionList, 2));
  312. }
  313. private List<Map<String, Object>> getHomeSectionNavigationList(List<Map<String, Object>> homeChildNavList) {
  314. List<Map<String, Object>> sectionNavList = new ArrayList<Map<String, Object>>();
  315. boolean topBoundaryFound = false;
  316. for (Map<String, Object> navMap : homeChildNavList) {
  317. if (hasIDCard(navMap, UTILITY_LINK_NAV_IDCARD)) {
  318. topBoundaryFound = true;
  319. continue;
  320. }
  321. if (hasIDCard(navMap, FOOTER_LINK_NAV_IDCARD)) {
  322. if (topBoundaryFound) {
  323. break;
  324. }
  325. continue;
  326. }
  327. if (topBoundaryFound) {
  328. sectionNavList.add(navMap);
  329. }
  330. }
  331. if (topBoundaryFound) {
  332. return sectionNavList;
  333. }
  334. return homeChildNavList;
  335. }
  336. private boolean hasIDCard(Map<String, Object> navMap, String idcard) {
  337. return navMap != null && navMap.get("idcard") != null && idcard.equals(navMap.get("idcard").toString());
  338. }
  339. private List<Map<String, Object>> getHomeChildNavigation(GeneralDBAccess gdba, Website website) throws Exception {
  340. Map<String, Object> homeGroupMap = WebsiteTemplateNavUtil.getNavigationByIDCardAsMap(gdba, website,
  341. HOME_GROUP_NAV_IDCARD);
  342. if (homeGroupMap == null || homeGroupMap.get("navigationid") == null) {
  343. return null;
  344. }
  345. return WebsiteTemplateNavUtil.getWebsiteALLConcealTerminalNav(gdba, website,
  346. Long.valueOf(homeGroupMap.get("navigationid").toString()));
  347. }
  348. private boolean isDynamicHomeSection(Map<String, Object> navMap) {
  349. if (navMap == null || navMap.get("idcard") == null || navMap.get("wntcode") == null) {
  350. return false;
  351. }
  352. String idcard = navMap.get("idcard").toString();
  353. if ("FFKJ_COLLEGE_HOME_HERO".equals(idcard) || "FFKJ_COLLEGE_NEWS".equals(idcard)
  354. || "FFKJ_COLLEGE_NOTICE".equals(idcard) || "FFKJ_COLLEGE_MAJOR".equals(idcard)
  355. || UTILITY_LINK_NAV_IDCARD.equals(idcard) || FOOTER_INFO_NAV_IDCARD.equals(idcard)
  356. || FOOTER_LINK_NAV_IDCARD.equals(idcard)) {
  357. return false;
  358. }
  359. return navigationType.LIST.getCode().toString().equals(navMap.get("wntcode").toString());
  360. }
  361. private NavigationMiniView buildNavigationMiniView(GeneralDBAccess gdba, Map<String, Object> navMap, int size)
  362. throws Exception {
  363. normalizeNavigationMap(gdba, navMap);
  364. PageBean pb = new PageBean();
  365. pb.setRowCountPerPage(size);
  366. List<Map<String, Object>> articleList = WebsiteTemplateArticleUtil.getArticleList(gdba,
  367. Long.valueOf(navMap.get("navigationid").toString()), pb);
  368. return new NavigationMiniView(navMap, articleList);
  369. }
  370. private void normalizeNavigationMap(GeneralDBAccess gdba, Map<String, Object> navMap) throws Exception {
  371. if (navMap == null) {
  372. return;
  373. }
  374. if (navMap.get("href") == null) {
  375. navMap.put("href", WebsiteTemplateNavUtil.getNavigationHref(gdba, navMap));
  376. }
  377. if (navMap.get("target") == null && navMap.get("wnjtcode") != null) {
  378. navMap.put("target", WebsiteTemplateNavUtil.jumpTypeCodeToTargetValue(navMap.get("wnjtcode").toString()));
  379. }
  380. }
  381. private List<List<NavigationMiniView>> groupSections(List<NavigationMiniView> sectionList, int groupSize) {
  382. List<List<NavigationMiniView>> rows = new ArrayList<List<NavigationMiniView>>();
  383. if (sectionList == null || sectionList.size() == 0) {
  384. return rows;
  385. }
  386. for (int index = 0; index < sectionList.size(); index += groupSize) {
  387. List<NavigationMiniView> row = new ArrayList<NavigationMiniView>();
  388. for (int offset = 0; offset < groupSize && index + offset < sectionList.size(); offset++) {
  389. row.add(sectionList.get(index + offset));
  390. }
  391. rows.add(row);
  392. }
  393. return rows;
  394. }
  395. private void setArticleExtras(GeneralDBAccess gdba, Website website) throws Exception {
  396. Article article = WebsiteArticleManager.getArticleByRequest(gdba, website, getRequest());
  397. if (article != null) {
  398. setRequestAttribute("articleThumbnail", article.getThumbnail());
  399. setRequestAttribute("articleReadCount", article.getReadCount());
  400. }
  401. }
  402. private void setCatalogAttributes(GeneralDBAccess gdba, Website website, WebsiteNavigation nav) throws Exception {
  403. WebsiteCommonService.selectHeadNavigation(gdba, website, getRequest());
  404. setRequestAttribute("website", website);
  405. setRequestAttribute("navigation", nav);
  406. List<WebsiteNavigation> crumbs = WebsiteNavManager.getNavParentList(gdba, website, nav.getNavigationid());
  407. setRequestAttribute("crumbsNavList", crumbs);
  408. setRequestAttribute("crumbsNavListSize", crumbs == null ? 0 : crumbs.size() - 1);
  409. setRequestAttribute("childrenNavList", WebsiteNavManager.getChildrenNavigation(gdba, website, nav.getNavigationid()));
  410. setRequestAttribute("navMiniViewList", WebsiteNavManager.getChildrenNavigationMiniView(gdba, website, nav.getNavigationid()));
  411. if (nav.getParentNid() != null) {
  412. WebsiteNavigation parNav = WebsiteNavManager.getNavigationByID(gdba, website, nav.getParentNid());
  413. setRequestAttribute("parNavigation", parNav);
  414. setRequestAttribute("brotherNavList", WebsiteNavManager.getChildrenNavigation(gdba, website, nav.getParentNid()));
  415. }
  416. }
  417. }