Exemplo n.º 1
0
 /**
  * 获取ID数组,如果ID不存在则获取PATH数组。
  *
  * @param params 标签参数
  * @param siteIds 如果为null,则自动获取所有站点path
  * @return 如果不存在,则返回null。
  * @throws TemplateException
  */
 protected Integer[] getChannelIdsOrPaths(Map<String, TemplateModel> params, Integer[] siteIds)
     throws TemplateException {
   Integer[] ids = getChannelIds(params);
   if (ids != null) {
     return ids;
   }
   String[] paths = getChannelPaths(params);
   if (paths == null) {
     return null;
   }
   Set<Integer> set = new HashSet<Integer>();
   Channel channel;
   if (siteIds == null) {
     List<CmsSite> list = cmsSiteMng.getListFromCache();
     siteIds = new Integer[list.size()];
     int i = 0;
     for (CmsSite site : list) {
       siteIds[i++] = site.getId();
     }
   }
   for (Integer siteId : siteIds) {
     for (String path : paths) {
       channel = channelMng.findByPathForTag(path, siteId);
       if (channel != null) {
         set.add(channel.getId());
       }
     }
   }
   if (set.size() > 0) {
     return set.toArray(new Integer[set.size()]);
   } else {
     return null;
   }
 }
Exemplo n.º 2
0
 private WebErrors validateUpdate(Integer id, HttpServletRequest request) {
   WebErrors errors = WebErrors.create(request);
   CmsSite site = CmsUtils.getSite(request);
   if (vldExist(id, site.getId(), errors)) {
     return errors;
   }
   return errors;
 }
Exemplo n.º 3
0
 @RequestMapping("/vote_topic/v_list.do")
 public String list(Integer pageNo, HttpServletRequest request, ModelMap model) {
   CmsSite site = CmsUtils.getSite(request);
   Pagination pagination =
       manager.getPage(site.getId(), cpn(pageNo), CookieUtils.getPageSize(request));
   model.addAttribute("pagination", pagination);
   model.addAttribute("pageNo", pagination.getPageNo());
   return "vote_topic/list";
 }
Exemplo n.º 4
0
 private WebErrors validateDelete(Integer[] ids, HttpServletRequest request) {
   WebErrors errors = WebErrors.create(request);
   CmsSite site = CmsUtils.getSite(request);
   if (errors.ifEmpty(ids, "ids")) {
     return errors;
   }
   for (Integer id : ids) {
     vldExist(id, site.getId(), errors);
   }
   return errors;
 }
Exemplo n.º 5
0
 public CmsSite update(CmsSite bean, Integer uploadFtpId) {
   CmsSite entity = findById(bean.getId());
   if (uploadFtpId != null) {
     entity.setUploadFtp(ftpMng.findById(uploadFtpId));
   } else {
     entity.setUploadFtp(null);
   }
   Updater<CmsSite> updater = new Updater<CmsSite>(bean);
   entity = dao.updateByUpdater(updater);
   return entity;
 }
Exemplo n.º 6
0
 public Content update(
     Content bean,
     ContentExt ext,
     ContentTxt txt,
     String[] tagArr,
     Integer[] channelIds,
     Integer[] topicIds,
     Integer[] viewGroupIds,
     String[] attachmentPaths,
     String[] attachmentNames,
     String[] attachmentFilenames,
     String[] picPaths,
     String[] picDescs,
     Map<String, String> attr,
     Integer channelId,
     Integer typeId,
     Boolean draft,
     CmsUser user,
     boolean forMember) {
   Content entity = findById(bean.getId());
   // 执行监听器
   List<Map<String, Object>> mapList = preChange(entity);
   // 更新主表
   Updater<Content> updater = new Updater<Content>(bean);
   bean = dao.updateByUpdater(updater);
   // 审核更新处理,如果站点设置为审核退回,且当前文章审核级别大于管理员审核级别,则将文章审核级别修改成管理员的审核级别。
   Byte userStep;
   if (forMember) {
     // 会员的审核级别按0处理
     userStep = 0;
   } else {
     CmsSite site = bean.getSite();
     userStep = user.getCheckStep(site.getId());
   }
   AfterCheckEnum after = bean.getChannel().getAfterCheckEnum();
   if (after == AfterCheckEnum.BACK_UPDATE && bean.getCheckStep() > userStep) {
     bean.getContentCheck().setCheckStep(userStep);
     if (bean.getCheckStep() >= bean.getChannel().getFinalStepExtends()) {
       bean.setStatus(ContentCheck.CHECKED);
     } else {
       bean.setStatus(ContentCheck.CHECKING);
     }
   }
   // 草稿
   if (draft != null) {
     if (draft) {
       bean.setStatus(DRAFT);
     } else {
       if (bean.getStatus() == DRAFT) {
         if (bean.getCheckStep() >= bean.getChannel().getFinalStepExtends()) {
           bean.setStatus(ContentCheck.CHECKED);
         } else {
           bean.setStatus(ContentCheck.CHECKING);
         }
       }
     }
   }
   // 是否有标题图
   bean.setHasTitleImg(!StringUtils.isBlank(ext.getTitleImg()));
   // 更新栏目
   if (channelId != null) {
     bean.setChannel(channelMng.findById(channelId));
   }
   // 更新类型
   if (typeId != null) {
     bean.setType(contentTypeMng.findById(typeId));
   }
   // 更新扩展表
   contentExtMng.update(ext);
   // 更新文本表
   contentTxtMng.update(txt, bean);
   // 更新属性表
   if (attr != null) {
     Map<String, String> attrOrig = bean.getAttr();
     attrOrig.clear();
     attrOrig.putAll(attr);
   }
   // 更新副栏目表
   Set<Channel> channels = bean.getChannels();
   channels.clear();
   if (channelIds != null && channelIds.length > 0) {
     for (Integer cid : channelIds) {
       channels.add(channelMng.findById(cid));
     }
   }
   channels.add(bean.getChannel());
   // 更新专题表
   Set<CmsTopic> topics = bean.getTopics();
   topics.clear();
   if (topicIds != null && topicIds.length > 0) {
     for (Integer tid : topicIds) {
       topics.add(cmsTopicMng.findById(tid));
     }
   }
   // 更新浏览会员组
   Set<CmsGroup> groups = bean.getViewGroups();
   groups.clear();
   if (viewGroupIds != null && viewGroupIds.length > 0) {
     for (Integer gid : viewGroupIds) {
       groups.add(cmsGroupMng.findById(gid));
     }
   }
   // 更新标签
   contentTagMng.updateTags(bean.getTags(), tagArr);
   // 更新附件
   bean.getAttachments().clear();
   if (attachmentPaths != null && attachmentPaths.length > 0) {
     for (int i = 0, len = attachmentPaths.length; i < len; i++) {
       if (!StringUtils.isBlank(attachmentPaths[i])) {
         bean.addToAttachmemts(attachmentPaths[i], attachmentNames[i], attachmentFilenames[i]);
       }
     }
   }
   // 更新图片集
   bean.getPictures().clear();
   if (picPaths != null && picPaths.length > 0) {
     for (int i = 0, len = picPaths.length; i < len; i++) {
       if (!StringUtils.isBlank(picPaths[i])) {
         bean.addToPictures(picPaths[i], picDescs[i]);
       }
     }
   }
   // 执行监听器
   afterChange(bean, mapList);
   return bean;
 }
Exemplo n.º 7
0
 public Content save(
     Content bean,
     ContentExt ext,
     ContentTxt txt,
     Integer[] channelIds,
     Integer[] topicIds,
     Integer[] viewGroupIds,
     String[] tagArr,
     String[] attachmentPaths,
     String[] attachmentNames,
     String[] attachmentFilenames,
     String[] picPaths,
     String[] picDescs,
     Integer channelId,
     Integer typeId,
     Boolean draft,
     CmsUser user,
     boolean forMember) {
   bean.setChannel(channelMng.findById(channelId));
   bean.setType(contentTypeMng.findById(typeId));
   bean.setUser(user);
   Byte userStep;
   if (forMember) {
     // 会员的审核级别按0处理
     userStep = 0;
   } else {
     CmsSite site = bean.getSite();
     userStep = user.getCheckStep(site.getId());
   }
   if (draft != null && draft) {
     bean.setStatus(ContentCheck.DRAFT);
   } else {
     if (userStep >= bean.getChannel().getFinalStepExtends()) {
       bean.setStatus(ContentCheck.CHECKED);
     } else {
       bean.setStatus(ContentCheck.CHECKING);
     }
   }
   // 是否有标题图
   bean.setHasTitleImg(!StringUtils.isBlank(ext.getTitleImg()));
   bean.init();
   // 执行监听器
   preSave(bean);
   dao.save(bean);
   contentExtMng.save(ext, bean);
   contentTxtMng.save(txt, bean);
   ContentCheck check = new ContentCheck();
   check.setCheckStep(userStep);
   contentCheckMng.save(check, bean);
   contentCountMng.save(new ContentCount(), bean);
   // 保存副栏目
   if (channelIds != null && channelIds.length > 0) {
     for (Integer cid : channelIds) {
       bean.addToChannels(channelMng.findById(cid));
     }
   }
   // 主栏目也作为副栏目一并保存,方便查询,提高效率。
   bean.addToChannels(channelMng.findById(channelId));
   // 保存专题
   if (topicIds != null && topicIds.length > 0) {
     for (Integer tid : topicIds) {
       bean.addToTopics(cmsTopicMng.findById(tid));
     }
   }
   // 保存浏览会员组
   if (viewGroupIds != null && viewGroupIds.length > 0) {
     for (Integer gid : viewGroupIds) {
       bean.addToGroups(cmsGroupMng.findById(gid));
     }
   }
   // 保存标签
   List<ContentTag> tags = contentTagMng.saveTags(tagArr);
   bean.setTags(tags);
   // 保存附件
   if (attachmentPaths != null && attachmentPaths.length > 0) {
     for (int i = 0, len = attachmentPaths.length; i < len; i++) {
       if (!StringUtils.isBlank(attachmentPaths[i])) {
         bean.addToAttachmemts(attachmentPaths[i], attachmentNames[i], attachmentFilenames[i]);
       }
     }
   }
   // 保存图片集
   if (picPaths != null && picPaths.length > 0) {
     for (int i = 0, len = picPaths.length; i < len; i++) {
       if (!StringUtils.isBlank(picPaths[i])) {
         bean.addToPictures(picPaths[i], picDescs[i]);
       }
     }
   }
   // 执行监听器
   afterSave(bean);
   return bean;
 }