示例#1
0
  /**
   * 增加模块
   *
   * @param request
   * @param response
   * @return 返回页面
   */
  @RequestMapping("/save")
  @ResponseBody
  public void save(
      @ModelAttribute ModelEntity model, HttpServletRequest request, HttpServletResponse response) {
    // 获取管理员id并赋值给模块的id
    model.setModelId(getManagerId(request));
    // 获取模块保存时间
    model.setModelDatetime(new Timestamp(System.currentTimeMillis()));
    if (!StringUtil.checkLength(model.getModelTitle(), 1, 20)) {
      this.outJson(
          response, getResString("err.length", this.getResString("modelTitle"), "2", "20"));
      return;
    }
    if (!StringUtil.checkLength(model.getModelCode(), 1, 20)) {
      this.outJson(response, getResString("err.length", this.getResString("modelCode"), "2", "20"));
      return;
    }

    // 判断图标是否为空,不为空去掉,图标地址中含有的“|”
    // 空值判断
    if (!StringUtil.isBlank(model.getModelIcon())) {
      model.setModelIcon(model.getModelIcon().replace("|", ""));
    }
    modelBiz.saveEntity(model);
    // 返回模块id到页面
    this.outJson(response, ModelCode.ROLE, true, String.valueOf(model.getModelId()));
  }
示例#2
0
  /**
   * 修改密码
   *
   * @param people 用户信息<br>
   *     <i>people参数包含字段信息参考:</i><br>
   *     peopleOldPassword 用户旧密码<br>
   *     peoplePassword 用户新密码<br>
   *     <dt><span class="strong">返回</span><br>
   *         {code:"错误编码",<br>
   *         result:"true|false",<br>
   *         resultMsg:"错误信息"<br>
   *         }
   */
  @RequestMapping(value = "/changePassword", method = RequestMethod.POST)
  @ResponseBody
  public void changePassword(
      @ModelAttribute PeopleEntity people,
      HttpServletRequest request,
      HttpServletResponse response) {
    if (StringUtil.isBlank(people.getPeoplePassword())) {
      // 用户或密码不能为空
      this.outJson(
          response,
          ModelCode.PEOPLE,
          false,
          this.getResString("err.empty", this.getResString("people.password")));
      return;
    }

    if (StringUtil.isBlank(people.getPeopleOldPassword())) {
      // 用户或密码不能为空
      this.outJson(
          response,
          ModelCode.PEOPLE,
          false,
          this.getResString("err.empty", this.getResString("people.old.password")));
      return;
    }

    // 验证新密码的长度
    if (!StringUtil.checkLength(people.getPeoplePassword(), 6, 30)) {
      this.outJson(
          response,
          ModelCode.PEOPLE,
          false,
          this.getResString("err.length", this.getResString("people.password"), "6", "20"));
      return;
    }

    // 获取用户session
    PeopleEntity _people = this.getPeopleBySession(request);
    PeopleEntity curPeople = peopleBiz.getByPeople(_people, this.getAppId(request));
    if (!curPeople.getPeoplePassword().equals(StringUtil.Md5(people.getPeopleOldPassword()))) {
      // 用户或密码不能为空
      this.outJson(
          response,
          ModelCode.PEOPLE,
          false,
          this.getResString("err.error", this.getResString("people.password")));
      return;
    }
    // 将用户输入的原始密码用MD5加密再和数据库中的进行比对
    String peoplePassWord = StringUtil.Md5(people.getPeoplePassword(), Const.UTF8);
    // 执行修改
    _people.setPeoplePassword(peoplePassWord);
    this.peopleBiz.updateEntity(_people);
    this.outJson(response, ModelCode.PEOPLE, true);
  }
示例#3
0
 public void init(Object... obj) {
   super.init(obj);
   mobilePath = "";
   column = null;
   this.curColumnId = 0;
   article = null;
   searchList = null;
   page = null;
   curPageNo = 1;
   previous = null;
   next = null;
   for (Object o : obj) {
     if (o != null) {
       if (o instanceof Map) {
         Map temp = (Map) o;
         if (StringUtil.isInteger(temp.get(CUR_COLUMNID))) {
           curColumnId = Integer.parseInt(temp.get(CUR_COLUMNID) + "");
         }
         if (temp.get(PREVIOUS) instanceof ArticleEntity) {
           previous = (ArticleEntity) temp.get(PREVIOUS);
         }
         if (temp.get(NEXT) instanceof ArticleEntity) {
           next = (ArticleEntity) temp.get(NEXT);
         }
         if (StringUtil.isInteger(temp.get(CUR_PAGE_NO))) {
           curPageNo = Integer.parseInt(temp.get(CUR_PAGE_NO) + "");
         }
         if (!StringUtil.isBlank(temp.get(LIST_LINK_PATH))) {
           listLinkPath = temp.get(LIST_LINK_PATH) + "";
         }
         if (!StringUtil.isBlank(temp.get(MOBILE))) {
           mobilePath = temp.get(MOBILE) + "";
         }
         if (temp.get(SEARCH_LIST_ARTICLE) instanceof java.util.List) {
           // 搜索时候的文章列表数据
           searchList = (List) temp.get(SEARCH_LIST_ARTICLE);
         }
       }
       if (o instanceof ColumnEntity) {
         column = (ColumnEntity) o;
         // 直接影响ms:arclist的数据,根据栏目生成的时候需要必须要进行此操作
         this.curColumnId = column.getCategoryId();
       }
       if (o instanceof ArticleEntity) { // 显示文章内容的时候必须存在
         article = (ArticleEntity) o;
       }
       if (o instanceof PageUtil) { // 显示 文章搜索的时候必须存在
         page = (PageUtil) o;
       }
     }
   }
 }
示例#4
0
  /**
   * 模块列表
   *
   * @param request
   * @param request 请求
   * @return 返回页面
   */
  @RequestMapping("/list")
  public String list(ModelMap mode, HttpServletRequest request) {
    List<BaseEntity> parentModelList = modelBiz.queryChildList(0);
    List<BaseEntity> modelList = new ArrayList<BaseEntity>();

    int modelId = 0;
    if (!StringUtil.isBlank(request.getParameter("modelId"))) {
      modelId = Integer.valueOf(request.getParameter("modelId"));
    }
    List<BaseEntity> childModelList = null;
    // 根据模块id循环遍历出其所有的上层模块
    while (modelId != 0) {
      ModelEntity model = (ModelEntity) modelBiz.getEntity(modelId);
      // 查找子模块id
      childModelList = modelBiz.queryChildList(model.getModelModelId());
      if (childModelList.size() > 1) {
        for (BaseEntity i : childModelList) {
          modelList.add(i);
        }
      } else {
        modelList.add(model);
      }
      modelId = model.getModelModelId();
    }
    if (modelList != null && modelList.size() != 0) {
      Collections.reverse(modelList);
      mode.addAttribute("modelList", modelList);
    }
    mode.addAttribute("parentModelList", parentModelList);
    return "/manager/model/model_list";
  }
示例#5
0
 /**
  * 修改模块
  *
  * @return 返回页面
  */
 @RequestMapping("/update")
 @ResponseBody
 public void update(
     @ModelAttribute ModelEntity model, HttpServletRequest request, HttpServletResponse response) {
   if (!StringUtil.checkLength(model.getModelTitle(), 2, 20)
       || !StringUtil.checkLength(model.getModelCode(), 2, 20)) {
     return;
   }
   // 判断图标是否为空,不为空去掉,图标地址中含有的“|”
   // 空值判断
   if (!StringUtil.isBlank(model.getModelIcon())) {
     model.setModelIcon(model.getModelIcon().replace("|", ""));
   }
   modelBiz.updateEntity(model);
   this.outJson(response, ModelCode.ROLE, true, String.valueOf(model.getModelId()));
 }
示例#6
0
 /**
  * 搜索的分页查询
  *
  * @param htmlContent 搜索模板内容
  * @param articleList 文章实体列表
  * @param page 分页
  * @return
  */
 public String parseSearchList() {
   // 当前列表标签中属性的集合-------------------
   Map<String, String> property = ListParser.listProperty(htmlContent, true);
   if (property == null) { // 没有找到分页标签标签
     return htmlContent;
   }
   String isPaging = property.get(ListParser.LIST_ISPAGING);
   if (isPaging != null && isPaging.equals("true")) {
     // 排序
     String order = property.get(ListParser.LIST_ORDER);
     // 取当前标签下的栏目ID
     // 从数据库取出文章列表数组
     List listArticles = searchList;
     // 当数据库中该栏目下没有该文章时不取数据
     if (listArticles != null) {
       /** 判断文章列表的orderby属性 */
       if (StringUtil.isBlank(order)) {
         order = "desc";
       }
       // 替换列表标签
       htmlContent =
           new com.mingsoft.cms.parser.impl.ListParser(
                   htmlContent,
                   listArticles,
                   this.getWebsiteUrl(),
                   property,
                   true,
                   fieldBiz,
                   contentBiz)
               .parse();
     }
   }
   return htmlContent;
 }
示例#7
0
  /**
   * 更新字段信息
   *
   * @param field 要更新的字段信息的id
   * @param response
   */
  @RequestMapping("/update")
  @ResponseBody
  public void update(
      @ModelAttribute DiyFormFieldEntity diyFormfield, HttpServletResponse response) {
    // 更新前判断数据是否合法
    if (!StringUtil.checkLength(diyFormfield.getDiyFormFieldTipsName(), 1, 20)) {
      this.outJson(
          response,
          null,
          false,
          getResString("err.length", this.getResString("fieldTipsName"), "1", "20"));
      return;
    }
    if (!StringUtil.checkLength(diyFormfield.getDiyFormFieldFieldName(), 1, 20)) {
      this.outJson(
          response,
          null,
          false,
          getResString("err.length", this.getResString("fieldFieldName"), "1", "20"));
      return;
    }

    // 获取自定义表单实体
    DiyFormEntity diyForm =
        (DiyFormEntity) diyFormBiz.getEntity(diyFormfield.getDiyFormFieldFormId());
    // 读取属性配置文件
    Map<String, String> maps = new LinkedHashMap<String, String>();
    maps = getMapByProperties("com/mingsoft/basic/resources/field_data_type");
    // 获取更改前的字段实体
    DiyFormFieldEntity oldField =
        (DiyFormFieldEntity) diyFormFieldBiz.getEntity(diyFormfield.getDiyFormFieldId());
    Map fields = new HashMap();
    // 更改前的字段名
    fields.put("fieldOldName", oldField.getDiyFormFieldFieldName());
    // 新字段名
    fields.put("fieldName", diyFormfield.getDiyFormFieldFieldName());
    // 字段的数据类型
    fields.put("fieldType", maps.get(String.valueOf(diyFormfield.getDiyFormFieldType())));
    if (diyForm == null) {
      this.outJson(response, null, false, this.getResString("err.not.exist"));
      return;
    }
    // 更新表的字段名
    diyFormFieldBiz.alterTable(diyForm.getDiyFormTableName(), fields, "modify");
    diyFormFieldBiz.updateEntity(diyFormfield);
    this.outJson(response, null, true, null);
  }
示例#8
0
  /**
   * @param diyFormfield
   * @param cmTableName
   * @param response
   */
  @RequestMapping("/{diyFormId}/save")
  @ResponseBody
  public void save(
      @ModelAttribute DiyFormFieldEntity diyFormfield,
      @PathVariable int diyFormId,
      HttpServletResponse response) {
    // 获取自定义表单实体
    DiyFormEntity diyForm = (DiyFormEntity) diyFormBiz.getEntity(diyFormId);
    if (diyForm == null) {
      this.outJson(
          response, null, false, this.getResString("err.not.exist", this.getResString("diy.form")));
      return;
    }
    // 更新前判断数据是否合法
    if (!StringUtil.checkLength(diyFormfield.getDiyFormFieldTipsName(), 1, 20)) {
      this.outJson(
          response,
          null,
          false,
          getResString("err.length", this.getResString("fieldTipsName"), "1", "20"));
      return;
    }
    if (!StringUtil.checkLength(diyFormfield.getDiyFormFieldFieldName(), 1, 20)) {
      this.outJson(
          response,
          null,
          false,
          getResString("err.length", this.getResString("fieldFieldName"), "1", "20"));
      return;
    }

    // 读取属性配置文件
    Map<String, String> maps = new LinkedHashMap<String, String>();
    maps = getMapByProperties("com/mingsoft/basic/resources/field_data_type");
    // 动态的修改表结构
    // 获取字段信息
    Map fileds = new HashMap();
    // 压入字段名
    fileds.put("fieldName", diyFormfield.getDiyFormFieldFieldName());
    // 字段的数据类型
    fileds.put("fieldType", maps.get(String.valueOf(diyFormfield.getDiyFormFieldType())));
    fileds.put("default", diyFormfield.getDiyFormFieldDefault());
    // 在表中创建字段
    diyFormFieldBiz.alterTable(diyForm.getDiyFormTableName(), fileds, "add");
    this.diyFormFieldBiz.saveEntity(diyFormfield);
    this.outJson(response, null, true, null);
  }
示例#9
0
 /**
  * 查找页面中分页标签中出现的size的值
  *
  * @param htmlContent
  * @param column
  * @param curPageNo
  * @return
  */
 public int getPageSize(AppEntity website, String htmlContent, ColumnEntity column) {
   this.app = website;
   // 页面总数,默认为1
   int pageSize = 1;
   // 当前列表标签中属性的集合-------------------
   Map<String, String> property = ListParser.listProperty(htmlContent, true);
   // 没有找到分页标签标签
   if (property == null) {
     return pageSize;
   }
   String isPaging = property.get(ListParser.LIST_ISPAGING);
   if (!StringUtil.isBlank(isPaging) && isPaging.equals("true")) {
     List<Integer> columnIds = new ArrayList<Integer>();
     if (column != null) {
       // 取出当前栏目下的子栏目Id
       if (column.getCategoryId() != 0) {
         columnIds = columnBiz.queryChildIdsByColumnId(column.getCategoryId(), app.getAppId());
         columnIds.add(column.getCategoryId());
       }
     }
     // 列表每页显示的数量
     int size = StringUtil.string2Int(property.get(ListParser.LIST_SIZE));
     // 显示文章的形式flag属性
     String flag = property.get(ListParser.LIST_FLAG);
     // 显示文章的形式noflag属性
     String noFlag = property.get(ListParser.LIST_NOFLAG);
     // 数据库中该栏目下文章的总数
     int articleCount = articleBiz.getCountByColumnId(website.getAppId(), columnIds, flag, noFlag);
     // 当用户知道的显示数量小于0或大于文章实际总数时
     if (size <= 0 || size > articleCount) {
       size = articleCount;
     }
     // 如果文章总数为0则分页数量为1
     if (size == 0) {
       pageSize = 1;
       return pageSize;
     }
     pageSize = articleCount % size >= 1 ? articleCount / size + 1 : articleCount / size;
   }
   return pageSize;
 }
示例#10
0
  /**
   * 修改手机号<br>
   * 存在两种情况:<br>
   * 1、用户手机号之间进行过绑定,就需要通过短信发送验证码操作<br>
   * 2、用户手机没有绑定,就可以随意修改
   *
   * @param people 用户信息<br>
   *     <i>people参数包含字段信息参考:</i><br>
   *     peoplePhone 用户新密码<br>
   *     peopleCode 短信验证码<br>
   *     <dt><span class="strong">返回</span><br>
   *         {code:"错误编码",<br>
   *         result:"true|false",<br>
   *         resultMsg:"错误信息"<br>
   *         }
   */
  @RequestMapping(value = "/changePhone", method = RequestMethod.POST)
  @ResponseBody
  public void changePhone(
      @ModelAttribute PeopleEntity people,
      HttpServletRequest request,
      HttpServletResponse response) {
    // 验证原始帐号密码
    int appId = this.getAppId(request);
    // 获取用户session
    PeopleEntity _people = this.getPeopleBySession(request);

    // 判断手机是否已经存在
    if (StringUtil.isBlank(people.getPeoplePhone())) {
      this.outJson(
          response,
          ModelCode.PEOPLE,
          false,
          this.getResString("err.empty", this.getResString("people.phone")));
      return;
    }

    // 如果手机号码已经绑定过就需要验证手机短信吗
    if (_people.getPeoplePhoneCheck() == PeopleEnum.PHONE_CHECK.toInt()) {
      PeopleEntity tempPeople = peopleBiz.getByPeople(people, appId);
      // 判断用户输入的验证是否正确
      if (!people.getPeopleCode().equals(tempPeople.getPeopleCode())) {
        // 返回错误信息
        this.outJson(
            response,
            ModelCode.PEOPLE_REGISTER,
            false,
            this.getResString("err.error", this.getResString("people.code")));
        return;
      }
    }
    people.setPeoplePhone(people.getPeoplePhone());
    peopleBiz.updateEntity(people);
    this.outJson(response, ModelCode.PEOPLE, true);
  }
示例#11
0
  /**
   * 解析分页列表标签
   *
   * @param htmlContent 模版内容
   * @param column 栏目编号
   * @param curPageNo 当前页码
   * @return 替换好的内容
   */
  private String parseList() {

    // 替换完分页标签后的HTML代码
    // 当前列表标签中属性的集合-------------------
    Map<String, String> property = ListParser.listProperty(htmlContent, true);
    if (property == null) { // 没有找到分页标签标签
      return htmlContent;
    }
    String isPaging = property.get(ListParser.LIST_ISPAGING);
    if (isPaging != null && isPaging.equals("true")) {
      List<Integer> columnIds = new ArrayList<Integer>();
      if (column != null) {
        this.curColumnId = column.getCategoryId();
        columnIds = columnBiz.queryChildrenCategoryIds(curColumnId, app.getAppId(), modelId);
        // 取出当前栏目下的子栏目Id
        // 列表每页显示的数量
        int size = StringUtil.string2Int(property.get(ListParser.LIST_SIZE));
        // 显示文章的形式flag属性
        String flag = property.get(ListParser.LIST_FLAG);
        // 显示文章的形式noflag属性
        String noFlag = property.get(ListParser.LIST_NOFLAG);
        // 排序
        String orderBy = property.get(ListParser.LIST_ORDERBY);
        String order = property.get(ListParser.LIST_ORDER);
        columnIds.add(curColumnId);
        // 数据库中该栏目下文章的总数
        int articleCount = articleBiz.getCountByColumnId(app.getAppId(), columnIds, flag, noFlag);
        // 如果没有指定文章每页显示数量则显示所有数量
        if (size <= 0 || size > articleCount) {
          size = articleCount;
        }
        // 当数据库中该栏目下没有该文章时不取数据
        if (articleCount != 0) {
          if (page == null) {
            page = new PageUtilHtml(curPageNo, size, articleCount, listLinkPath);
          }
          /** 判断文章列表的orderby属性 */
          if (StringUtil.isBlank(order)) {
            order = "desc";
          }
          // 从数据库取出文章列表数组
          List<ArticleEntity> listArticles =
              articleBiz.queryList(
                  this.app.getAppId(),
                  columnIds,
                  flag,
                  noFlag,
                  (page.getPageNo() * page.getPageSize()),
                  page.getPageSize(),
                  orderBy,
                  order.equals("desc") ? true : false);
          // 替换列表标签
          htmlContent =
              new com.mingsoft.cms.parser.impl.ListParser(
                      htmlContent,
                      listArticles,
                      this.getWebsiteUrl(),
                      property,
                      true,
                      fieldBiz,
                      contentBiz)
                  .parse();
        } else {
          htmlContent =
              new com.mingsoft.cms.parser.impl.ListParser(
                      htmlContent, null, this.getWebsiteUrl(), property, true, fieldBiz, contentBiz)
                  .parse();
        }
      }
    }
    return htmlContent;
  }
示例#12
0
  /**
   * 解析分类标签
   *
   * @param htmlContent  原始html内容
   * @param column
   * @param websiteUrl 网站连接地址
   * @return
   */
  private String parseChannel() {
    // 替换完文章标签后的HTML模版

    // 当只存在栏目ID时,解析相关的文章中的栏目标签
    if (column != null) {
      ColumnEntity tmp = null;
      String columnTitle = column.getCategoryTitle();
      int columnId = column.getCategoryId();
      // 解析当前栏目信息
      htmlContent = new ColumnParser(htmlContent, column, this.getWebsiteUrl()).parse();
      // 解析当前栏目id// 替换文章所在栏目标签:{ms:field.typeid/}
      ArticleTypeIdParser atId = new ArticleTypeIdParser(htmlContent, columnId + "");
      if (atId.isTop()) {
        if (column.getCategoryCategoryId() > 0) {
          tmp = (ColumnEntity) columnBiz.getEntity(column.getCategoryCategoryId());
          columnId = tmp.getCategoryId();
        }
      }
      htmlContent = new ArticleTypeIdParser(htmlContent, column.getCategoryId() + "").parse();
      // 替换文章所在栏目标签:{ms:field.typetitle/}
      ArticleTypeTitleParser attp = new ArticleTypeTitleParser(htmlContent, columnTitle);
      if (attp.isTop()) {
        if (column.getCategoryCategoryId() > 0) {
          tmp = (ColumnEntity) columnBiz.getEntity(column.getCategoryCategoryId());
          columnTitle = tmp.getCategoryTitle();
        }
      }
      attp.setNewCotent(columnTitle);
      htmlContent = attp.parse();
      // 替换文章栏目链接标签{ms:filed.typelink/}
      ArticleTypeLinkParser atlp =
          new ArticleTypeLinkParser(
              htmlContent,
              this.getWebsiteUrl()
                  + column.getColumnPath()
                  + File.separator
                  + IParserRegexConstant.HTML_INDEX);
      if (atlp.isTop()) {
        if (column.getCategoryCategoryId() > 0) { // 如果用户写分类名称标签的时候没有使用top属性,而在使用连接标签的时候使用就再次查询分类
          tmp = (ColumnEntity) columnBiz.getEntity(column.getCategoryCategoryId());
          atlp.setNewCotent(
              this.getWebsiteUrl()
                  + tmp.getColumnPath()
                  + File.separator
                  + IParserRegexConstant.HTML_INDEX);
        } else {
          atlp.setNewCotent(
              this.getWebsiteUrl()
                  + column.getColumnPath()
                  + File.separator
                  + IParserRegexConstant.HTML_INDEX);
        }
      }
      htmlContent = atlp.parse();
    }
    // //----------------------------解析栏目标签----------------------------

    // //替换完列表标签后的HTML文件
    String channel = htmlContent;

    // 查找当前模版页面拥有多少个栏目列表标签
    int strNumType = ChannelParser.channelNum(channel);

    for (int i = 0; i < strNumType; i++) {
      // 当前列表栏目中属性的集合
      Map<String, String> mapProperty = ChannelParser.channelProperty(channel);

      // 取当前标签下的栏目ID
      int tempColumnId = StringUtil.string2Int(mapProperty.get(ChannelParser.CHANNEL_TYPEID));

      if (tempColumnId == 0 && column != null) {
        tempColumnId = column.getCategoryId();
      }
      List<ColumnEntity> categoryList = null;
      // 指定要显示的栏目数量
      String size = mapProperty.get(ChannelParser.CHANNEL_TYPE_SIZE);
      Integer _size = null;
      if (!StringUtil.isBlank(size) && StringUtil.isInteger(size)) {
        if (StringUtil.string2Int(size) > 0) {
          _size = StringUtil.string2Int(size);
        }
      }
      if (tempColumnId != 0) {
        // 取出栏目的取值范围
        String type = mapProperty.get(ChannelParser.CHANNEL_TYPE);
        // 同级栏目是否显示属性
        String childType = mapProperty.get(ChannelParser.CHANNEL_TYP_SIBLING);
        // 根据范围在BIZ中取出不同的栏目信息

        // 判断用户填写的栏目属性,如果未填写那么取当前栏目的下级栏目,如果但前栏目没有下级栏目那么晚取本级栏目
        // 如果填写:son,那么取下级栏目,没有下级栏目则取本级栏目
        // 如果为:top,那么取上级栏目,如果没有上级栏目则取本级栏目
        // 如果为:level,则取本级栏目
        if (type == null) {
          categoryList = columnBiz.queryChildListByColumnId(tempColumnId, _size);
          // 当值为true表示不存在子级分类时,显示他的同级分类
          if (childType != null && childType.equals("true") && categoryList.size() <= 0) {
            categoryList = columnBiz.querySibling(tempColumnId, _size);
          }
        } else if (type.equals(ChannelParser.CHANNEL_TYPE_SON)) {
          categoryList = columnBiz.queryChildListByColumnId(tempColumnId, _size);
        } else if (type.equals(ChannelParser.CHANNEL_TYPE_TOP)) {
          categoryList = columnBiz.queryTopSiblingListByColumnId(tempColumnId, _size);
        } else if (type.equals(ChannelParser.CHANNEL_TYPE_LEVEL)) {
          categoryList = columnBiz.querySibling(tempColumnId, _size);
        }
        // 替换栏目标签
        htmlContent =
            new ChannelParser(
                    channel,
                    categoryList,
                    this.getWebsiteUrl(),
                    column != null ? column.getCategoryId() : 0,
                    mapProperty.get(ChannelParser.CHANNEL_CLASS))
                .parse();
        // 替换完栏目标签后的HTML代码
        channel = htmlContent;
      } else {
        categoryList = columnBiz.queryChild(tempColumnId, app.getAppId(), modelId, _size);
        // 替换栏目标签
        htmlContent = new ChannelParser(channel, categoryList, this.getWebsiteUrl()).parse();
        // 替换完栏目标签后的HTML代码
        channel = htmlContent;
      }
    }
    // 替换完封面标签后的TML文件
    String channelContHtml = channel;
    // 查找当前模版页面拥有多少个封面列表标签
    int channelConNum = ChannelContParser.channelContNum(channelContHtml);
    for (int i = 0; i < channelConNum; i++) {
      // 取出当前封面标签中的封面ID
      int channelTypeId = ChannelContParser.channelContTypeId(channelContHtml);
      if (channelTypeId == 0 && column != null) {
        channelTypeId = column.getCategoryId();
      }
      String channelCont = "";
      // 取出当前封面的内容
      if (channelTypeId != 0) {
        List<ArticleEntity> arctile = articleBiz.queryListByColumnId(channelTypeId);
        if (arctile != null) {
          if (arctile.size() > 0) {
            channelCont = arctile.get(arctile.size() - 1).getArticleContent();
          } else {
            channelCont = arctile.get(arctile.size()).getArticleContent();
          }
        }
      }
      // 替换封面标签
      htmlContent = new ChannelContParser(channelContHtml, channelCont).parse();
      channelContHtml = htmlContent;
    }

    return htmlContent;
  }
示例#13
0
  /**
   * 解析列表标签
   *
   * @param htmlContent 模版内容
   * @param linkColumnId 栏目编号
   * @return 替换好的内容
   */
  private String parseArclist() {
    // 查找当前模版页面拥有多少个列表标签
    int listNum = ListParser.countArcList(super.htmlContent);
    // List<String> noParserHtml = new ArrayList<String>();
    // 替换完分页标签后的HTML代码
    for (int i = 0; i < listNum; i++) {

      // 当前列表标签中属性的集合-------------------
      Map<String, String> property = ListParser.listProperty(super.htmlContent, false);
      // 取当前标签下的栏目ID
      int columnId = StringUtil.string2Int(property.get(ListParser.LIST_TYPEID));
      List<Integer> columnIds = new ArrayList<Integer>();
      // 列表每页显示的数量
      int size = StringUtil.string2Int(property.get(ListParser.LIST_SIZE));
      // 显示文章的形式flag属性
      String flag = property.get(ListParser.LIST_FLAG);
      // 显示文章的形式noflag属性
      String noFlag = property.get(ListParser.LIST_NOFLAG);
      // 排序
      String orderBy = property.get(ListParser.LIST_ORDERBY);
      String order = property.get(ListParser.LIST_ORDER);
      // 取出当前栏目下的子栏目Id
      if (columnId != 0) {
        columnIds = columnBiz.queryChildIdsByColumnId(columnId, app.getAppId());
        columnIds.add(columnId);
      } else {
        columnId = this.curColumnId;
        columnIds = columnBiz.queryChildrenCategoryIds(columnId, app.getAppId(), modelId);
      }
      // 数据库中该栏目下文章的总数
      int articleCount = articleBiz.getCountByColumnId(app.getAppId(), columnIds, flag, noFlag);

      // 如果没有指定文章每页显示数量则显示所有数量
      if (size <= 0 || size > articleCount) {
        size = articleCount;
      }
      // 当数据库中该栏目下没有该文章时不取数据
      if (articleCount != 0) {
        /** 判断文章列表的orderby属性 */
        if (StringUtil.isBlank(order)) {
          order = "desc";
        }
        // 从数据库取出文章列表数组
        List<ArticleEntity> listArticles =
            articleBiz.queryList(
                app.getAppId(),
                columnIds,
                flag,
                noFlag,
                0,
                size,
                orderBy,
                order.equals("desc") ? true : false);
        // 替换列表标签
        htmlContent =
            new com.mingsoft.cms.parser.impl.ListParser(
                    htmlContent,
                    listArticles,
                    this.getWebsiteUrl(),
                    property,
                    false,
                    fieldBiz,
                    contentBiz)
                .parse();
      } else {
        htmlContent =
            new com.mingsoft.cms.parser.impl.ListParser(
                    htmlContent, null, this.getWebsiteUrl(), property, false, fieldBiz, contentBiz)
                .parse();
      }
    }
    return htmlContent;
  }