예제 #1
0
  public static void dg1DataBind(DataListAction dla) {
    String CatalogID = dla.getParam("CatalogID");
    String CatalogType = dla.getParam("CatalogType");
    String VerifyStatus = dla.getParam("VerifyStatus");
    QueryBuilder qb =
        new QueryBuilder(
            "select ZCComment.*,(select Name from zccatalog where zccatalog.ID=ZCComment.CatalogID) as CatalogName,");

    if (XString.isEmpty(CatalogType)) {
      CatalogType = "1";
    }
    if (XString.isEmpty(VerifyStatus)) {
      VerifyStatus = "X";
    }
    if (CatalogType.equals("1"))
      qb.append("(select Title from ZCArticle where ZCArticle.ID = ZCComment.RelaID) as Name");
    else if (CatalogType.equals("4"))
      qb.append("(select Name from ZCImage where ZCImage.ID = ZCComment.RelaID) as Name");
    else if (CatalogType.equals("5"))
      qb.append("(select Name from ZCVideo where ZCVideo.ID = ZCComment.RelaID) as Name");
    else if (CatalogType.equals("6"))
      qb.append("(select Name from ZCAudio where ZCAudio.ID = ZCComment.RelaID) as Name");
    else if (CatalogType.equals("7")) {
      qb.append("(select Name from ZCAttachment where ZCAttachment.ID = ZCComment.RelaID) as Name");
    }
    qb.append(" from ZCComment where SiteID=?", ApplicationPage.getCurrentSiteID());
    qb.append(" and CatalogType=?", CatalogType);
    if (XString.isNotEmpty(CatalogID)) {
      qb.append(" and CatalogID=?", CatalogID);
    }
    if (!VerifyStatus.equals("All")) {
      qb.append(" and VerifyFlag=?", VerifyStatus);
    }
    qb.append(" order by VerifyFlag asc, ID desc");
    dla.setTotal(qb);
    DataTable dt = qb.executePagedDataTable(dla.getPageSize(), dla.getPageIndex());
    dt.insertColumn("PreLink");
    dt.insertColumn("FlagColor");
    for (int i = 0; i < dt.getRowCount(); i++) {
      if (dt.getString(i, "CatalogType").equals("1"))
        dt.set(i, "PreLink", "../Document/Preview.jsp?ArticleID=" + dt.getString(i, "RelaID"));
      else {
        dt.set(i, "PreLink", "#;");
      }
      if (dt.getString(i, "VerifyFlag").equals("Y")) dt.set(i, "FlagColor", "#00ff00");
      else if (dt.getString(i, "VerifyFlag").equals("X")) dt.set(i, "FlagColor", "#ff7700");
      else {
        dt.set(i, "FlagColor", "#ff0000");
      }
    }
    dt.decodeColumn("VerifyFlag", CacheManager.getMapx("Code", "Comment.Status"));
    if (dt.getRowCount() == 0) {
      // dt.insertRow(null);
      dt.set(0, "ID", "0");
    }
    dla.bindData(dt);
  }
예제 #2
0
 public static String getColumnAndValue(ZDMemberSchema member) {
   DataTable dt =
       new QueryBuilder(
               "select * from ZDMemberField where SiteID = ? order by AddTime asc",
               member.getSiteID())
           .executeDataTable();
   String Columns = "";
   for (int i = 0; i < dt.getRowCount(); i++) {
     Columns = Columns + getColumn(dt.getDataRow(i), member, dt.getString(i, "RealField"));
   }
   return Columns;
 }
예제 #3
0
  public static Mapx init(Mapx params) {
    DataTable dt = null;
    dt = new QueryBuilder("select name,id from zcsite order by orderflag").executeDataTable();
    dt =
        dt.filter(
            new Filter() {
              public boolean filter(Object obj) {
                DataRow dr = (DataRow) obj;
                return Priv.getPriv(User.getUserName(), "site", dr.getString("ID"), "site_browse");
              }
            });
    if ((getCurrentSiteID() == 0L) && (dt.getRowCount() > 0)) {
      setCurrentSiteID(dt.getString(0, "ID"));
    }
    params.put("Sites", HtmlUtil.dataTableToOptions(dt, getCurrentSiteID()));
    DataTable dtsite =
        new QueryBuilder("select ID,Name from zcsite order by orderflag").executeDataTable();
    StringBuffer sitestb = new StringBuffer();
    for (int i = 0; i < dtsite.getRowCount(); i++) {
      if (dtsite.getString(i, "ID").equals(getCurrentSiteID())) {
        sitestb.append(
            "<a value=\""
                + dtsite.getString(i, "ID")
                + "\" class=\"ahover\" hidefocus href=\"javascript:void(0);\">"
                + dtsite.getString(i, "Name")
                + "</a>");
        params.put("CurrentSiteName", dtsite.getString(i, "Name"));
        params.put("CurrentSiteId", dtsite.getString(i, "ID"));
      } else {
        sitestb.append(
            "<a value=\""
                + dtsite.getString(i, "ID")
                + "\" hidefocus href=\"javascript:void(0);\">"
                + dtsite.getString(i, "Name")
                + "</a>");
      }
    }
    params.put("ZCSites", sitestb.toString());

    dt =
        new QueryBuilder(
                "select name,id from zdmenu where  visiable='Y' and parentID=0 order by OrderFlag")
            .executeDataTable();
    dt =
        dt.filter(
            new Filter() {
              public boolean filter(Object obj) {
                DataRow dr = (DataRow) obj;
                return Priv.getPriv(
                    User.getUserName(),
                    "menu",
                    ApplicationPage.getCurrentSiteID() + "-" + dr.getString("id"),
                    "menu_browse");
              }
            });
    boolean hasMenu = false;
    String template =
        "<a id='_Menu_${ID}' onclick='Application.onMainMenuClick(this);return false;' hidefocus='true'><b>${Name}</b></a>";
    String menuHtml = HtmlUtil.replaceWithDataTable(dt, template);
    if (dt.getRowCount() > 0) {
      hasMenu = true;
    }

    StringBuffer sb = new StringBuffer();

    template = "arr.push([${ID},\"${Name}\",\"${URL}\",\"${Icon}\"]);";
    sb.append("var arr;");
    for (int i = 0; i < dt.getRowCount(); i++) {
      String id = dt.getString(i, "ID");
      sb.append("arr = [];");
      DataTable dt2 =
          new QueryBuilder(
                  "select name,id,url,icon from zdmenu where visiable='Y' and parentID=? order by OrderFlag",
                  id)
              .executeDataTable();
      dt2 =
          dt2.filter(
              new Filter() {
                public boolean filter(Object obj) {
                  DataRow dr = (DataRow) obj;
                  return Priv.getPriv(
                      User.getUserName(),
                      "menu",
                      ApplicationPage.getCurrentSiteID() + "-" + dr.getString("id"),
                      "menu_browse");
                }
              });
      sb.append(HtmlUtil.replaceWithDataTable(dt2, template));
      sb.append("$('_Menu_" + id + "').ChildArray = arr;");
      if (dt2.getRowCount() > 0) {
        hasMenu = true;
      }
    }

    HtmlScript script = new HtmlScript();
    script.setInnerHTML(sb.toString());
    if (hasMenu) params.put("Menu", menuHtml + script.getOuterHtml());
    else {
      params.put("Menu", "<font color='yellow'>对不起,你没有任何菜单权限,请联系'管理员'分配菜单权限后再登陆!</font>");
    }

    DataCollection privDC = LoginPage.getAllPriv(new DataCollection());
    String priv = XString.htmlEncode(privDC.toXML().replaceAll("\\s+", " "));
    params.put("Privileges", priv);
    return params;
  }