예제 #1
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;
  }
예제 #2
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;
  }