コード例 #1
0
ファイル: CmsParser.java プロジェクト: RogerFang/MCMS
 /**
  * 查找页面中分页标签中出现的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;
 }
コード例 #2
0
ファイル: CmsParser.java プロジェクト: RogerFang/MCMS
  /**
   * 解析分页列表标签
   *
   * @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;
  }
コード例 #3
0
ファイル: CmsParser.java プロジェクト: RogerFang/MCMS
  /**
   * 解析列表标签
   *
   * @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;
  }