Ejemplo n.º 1
0
 /**
  * 我的留言
  *
  * <p>如果没有登录则跳转到登陆页
  *
  * @param request
  * @param response
  * @param model
  * @return
  */
 @RequestMapping(value = "/member/myguestbook.jspx")
 public String myguestbook(
     Integer pageNo,
     Integer ctgId,
     HttpServletRequest request,
     HttpServletResponse response,
     ModelMap model) {
   CmsSite site = CmsUtils.getSite(request);
   CmsUser user = CmsUtils.getUser(request);
   FrontUtils.frontData(request, model, site);
   MemberConfig mcfg = site.getConfig().getMemberConfig();
   // 没有开启会员功能
   if (!mcfg.isMemberOn()) {
     return FrontUtils.showMessage(request, model, "member.memberClose");
   }
   if (user == null) {
     return FrontUtils.showLogin(request, model, site);
   }
   Pagination pagination =
       guestbookMng.getPage(
           site.getId(),
           ctgId,
           user.getId(),
           null,
           null,
           true,
           false,
           cpn(pageNo),
           CookieUtils.getPageSize(request));
   model.addAttribute("pagination", pagination);
   return FrontUtils.getTplPath(request, site.getSolutionPath(), TPLDIR_GUESTBOOK, GUESTBOOK_LIST);
 }
Ejemplo n.º 2
0
 /** 查看留言回复 */
 @RequestMapping(value = "/member/guestbook_replay.jspx")
 public String guestbook_replay(
     Integer id,
     String nextUrl,
     HttpServletRequest request,
     HttpServletResponse response,
     ModelMap model) {
   CmsSite site = CmsUtils.getSite(request);
   CmsUser user = CmsUtils.getUser(request);
   FrontUtils.frontData(request, model, site);
   MemberConfig mcfg = site.getConfig().getMemberConfig();
   // 没有开启会员功能
   if (!mcfg.isMemberOn()) {
     return FrontUtils.showMessage(request, model, "member.memberClose");
   }
   if (user == null) {
     return FrontUtils.showLogin(request, model, site);
   }
   CmsGuestbook guestbook = guestbookMng.findById(id);
   if (!guestbook.getMember().equals(user)) {
     WebErrors errors = WebErrors.create(request);
     errors.addErrorCode("error.noPermissionsView");
     return FrontUtils.showError(request, response, model, errors);
   }
   model.addAttribute("guestbook", guestbook);
   return FrontUtils.getTplPath(
       request, site.getSolutionPath(), TPLDIR_GUESTBOOK, GUESTBOOK_REPLAY);
 }
Ejemplo n.º 3
0
 @RequestMapping(value = "/search*.jspx", method = RequestMethod.GET)
 public String index(HttpServletRequest request, HttpServletResponse response, ModelMap model) {
   CmsSite site = CmsUtils.getSite(request);
   // 将request中所有参数保存至model中。
   model.putAll(RequestUtils.getQueryParams(request));
   FrontUtils.frontData(request, model, site);
   FrontUtils.frontPageData(request, model);
   String q = RequestUtils.getQueryParam(request, "q");
   if (q.equals("?") || q.equals("*")) {
     return FrontUtils.getTplPath(request, site.getSolutionPath(), TPLDIR_SPECIAL, SEARCH_ERROR);
   }
   if (q.startsWith("?") || q.startsWith("*")) {
     model.addAttribute("oldq", q);
     q = q.substring(1);
     // 替换关键词
     model.addAttribute("q", q);
   }
   String channelId = RequestUtils.getQueryParam(request, "channelId");
   if (StringUtils.isBlank(q) && StringUtils.isBlank(channelId)) {
     model.remove("q");
     model.remove("channelId");
     return FrontUtils.getTplPath(request, site.getSolutionPath(), TPLDIR_SPECIAL, SEARCH_INPUT);
   } else {
     return FrontUtils.getTplPath(request, site.getSolutionPath(), TPLDIR_SPECIAL, SEARCH_RESULT);
   }
 }
Ejemplo n.º 4
0
 /** 留言详细 */
 @RequestMapping(value = "/member/guestbook_detail.jspx")
 public String guestbook_detail(
     Integer id, HttpServletRequest request, HttpServletResponse response, ModelMap model) {
   CmsSite site = CmsUtils.getSite(request);
   CmsUser user = CmsUtils.getUser(request);
   FrontUtils.frontData(request, model, site);
   MemberConfig mcfg = site.getConfig().getMemberConfig();
   // 没有开启会员功能
   if (!mcfg.isMemberOn()) {
     return FrontUtils.showMessage(request, model, "member.memberClose");
   }
   if (user == null) {
     return FrontUtils.showLogin(request, model, site);
   }
   CmsGuestbook guestbook = guestbookMng.findById(id);
   model.addAttribute("guestbook", guestbook);
   return FrontUtils.getTplPath(
       request, site.getSolutionPath(), TPLDIR_GUESTBOOK, GUESTBOOK_DETAIL);
 }
Ejemplo n.º 5
0
  @SuppressWarnings("unchecked")
  public void execute(
      Environment env, Map params, TemplateModel[] loopVars, TemplateDirectiveBody body)
      throws TemplateException, IOException {
    CmsSite site = FrontUtils.getSite(env);
    Pagination page =
        contentTagMng.getPageForTag(FrontUtils.getPageNo(env), FrontUtils.getCount(params));

    Map<String, TemplateModel> paramWrap = new HashMap<String, TemplateModel>(params);
    paramWrap.put(OUT_PAGINATION, DEFAULT_WRAPPER.wrap(page));
    paramWrap.put(OUT_LIST, DEFAULT_WRAPPER.wrap(page.getList()));
    Map<String, TemplateModel> origMap = DirectiveUtils.addParamsToVariable(env, paramWrap);
    InvokeType type = DirectiveUtils.getInvokeType(params);
    String listStyle = DirectiveUtils.getString(PARAM_STYLE_LIST, params);
    if (InvokeType.sysDefined == type) {
      if (StringUtils.isBlank(listStyle)) {
        throw new ParamsRequiredException(PARAM_STYLE_LIST);
      }
      env.include(TPL_STYLE_LIST + listStyle + TPL_SUFFIX, UTF8, true);
      FrontUtils.includePagination(site, params, env);
    } else if (InvokeType.userDefined == type) {
      if (StringUtils.isBlank(listStyle)) {
        throw new ParamsRequiredException(PARAM_STYLE_LIST);
      }
      FrontUtils.includeTpl(TPL_STYLE_LIST, site, env);
      FrontUtils.includePagination(site, params, env);
    } else if (InvokeType.custom == type) {
      FrontUtils.includeTpl(TPL_NAME, site, params, env);
      FrontUtils.includePagination(site, params, env);
    } else if (InvokeType.body == type) {
      body.render(env.getOut());
      FrontUtils.includePagination(site, params, env);
    } else {
      throw new RuntimeException("invoke type not handled: " + type);
    }
    DirectiveUtils.removeParamsFromVariable(env, paramWrap, origMap);
  }