Example #1
0
 public static Mapx initAddDialog(Mapx params) {
   String ForumID = params.getString("ForumID");
   String SiteID = params.getString("SiteID");
   params.put("Priv", ForumUtil.initPriv(ForumID, SiteID));
   params.put("BBSName", ForumUtil.getBBSName(SiteID));
   return params;
 }
Example #2
0
  private void bindData() throws Exception {
    if (this.DataSource == null) {
      throw new RuntimeException("必须在bindData方法中设定DataSource");
    }

    this.items.clear();

    this.root = new TreeItem();
    this.root.setID("_TreeRoot");
    this.root.setParentID("");
    this.root.setRoot(true);
    this.root.setText(this.rootText);
    this.root.setAction(this);
    this.root.setLevel(0);

    this.root.setAttribute("onMouseOver", this.onMouseOver);
    this.root.setAttribute("onContextMenu", this.onContextMenu);
    this.root.setAttribute("onClick", this.onClick);
    this.root.setAttribute("onMouseOut", this.onMouseOut);

    this.items.add(this.root);

    Mapx map = new Mapx();
    for (int i = 0; i < this.DataSource.getRowCount(); i++)
      map.put(
          this.DataSource.getString(i, this.IdentifierColumnName),
          this.DataSource.getString(i, this.ParentIdentifierColumnName));
    try {
      TreeItem last = null;
      for (int i = 0; i < this.DataSource.getRowCount(); i++) {
        DataRow dr = this.DataSource.getDataRow(i);
        String parentID = dr.getString(this.ParentIdentifierColumnName);
        if ((XString.isEmpty(parentID)) || (!map.containsKey(parentID))) {
          TreeItem item = new TreeItem();
          item.setData(dr);
          item.parseHtml(getItemInnerHtml(dr));
          item.setAction(this);
          item.setID(dr.getString(this.IdentifierColumnName));
          item.setParentID(parentID);
          if (this.lazyLoad) {
            item.setLevel(this.parentLevel + 1);
            item.setLevelStr((String) getParams().get("LevelStr"));
          } else {
            item.setLevel(1);
          }
          item.setParent(this.root);
          this.items.add(item);
          addChild(item);
          last = item;
        }
      }

      if (last != null) last.setLast(true);
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
Example #3
0
 public static void dg1DataBind(DataGridAction dga) {
   DataTable dt =
       new QueryBuilder(
               "select * from ZCFullText where siteid=?", ApplicationPage.getCurrentSiteID())
           .executeDataTable();
   Mapx map = new Mapx();
   map.put("Article", "文章检索");
   map.put("Image", "图片检索");
   map.put("Video", "视频检索");
   map.put("Radio", "音频检索");
   dt.decodeColumn("Type", map);
   dga.bindData(dt);
 }
Example #4
0
 public static ZDMemberSchema setPropValues(ZDMemberSchema member, Mapx map, String SiteID) {
   ZDMemberFieldSchema field = new ZDMemberFieldSchema();
   ZDMemberFieldSet set = field.query(new QueryBuilder(" where SiteID = ?", SiteID));
   for (int i = 0; i < set.size(); i++) {
     String Value = "";
     String RealField = "";
     String Code = "";
     field = new ZDMemberFieldSchema();
     field = set.get(i);
     Code = field.getCode();
     RealField = field.getRealField();
     Value = map.getString("_MC_" + Code);
     map.put(RealField, Value);
   }
   member.setValue(map);
   return member;
 }
Example #5
0
 public static void treeDataBind(TreeAction ta) {
   String SiteID = ApplicationPage.getCurrentSiteID() + "";
   DataTable dt = null;
   Mapx params = ta.getParams();
   String CatalogType = (String) params.get("Type");
   String parentLevel = (String) params.get("ParentLevel");
   String parentID = (String) params.get("ParentID");
   String rootText = "";
   if (CatalogType.equals("1")) rootText = "文档库";
   else if (CatalogType.equals("4")) rootText = "图片库";
   else if (CatalogType.equals("5")) rootText = "视频库";
   else if (CatalogType.equals("6")) rootText = "音频库";
   else if (CatalogType.equals("7")) {
     rootText = "附件库";
   }
   if (ta.isLazyLoad()) {
     QueryBuilder qb =
         new QueryBuilder(
             "select ID,ParentID,TreeLevel,Name,SingleFlag,prop1 from ZCCatalog Where Type =? and SiteID =? and TreeLevel>? and innerCode like ? order by orderflag");
     qb.add(CatalogType);
     qb.add(SiteID);
     qb.add(parentLevel);
     qb.add(CatalogUtil.getInnerCode(parentID) + "%");
     dt = qb.executeDataTable();
   } else {
     QueryBuilder qb =
         new QueryBuilder(
             "select ID,ParentID,TreeLevel,Name,SingleFlag,prop1 from ZCCatalog Where Type =? and SiteID=? and TreeLevel-1<=? order by orderflag");
     qb.add(CatalogType);
     qb.add(SiteID);
     qb.add(ta.getLevel());
     dt = qb.executeDataTable();
   }
   ta.setRootText(rootText);
   dt.setWebMode(false);
   ta.bindData(dt);
   if (CatalogType.equals("1")) {
     List items = ta.getItemList();
     for (int i = 1; i < items.size(); i++) {
       TreeItem item = (TreeItem) items.get(i);
       if ("Y".equals(item.getData().getString("SingleFlag")))
         item.setIcon("Icons/treeicon11.gif");
     }
   }
 }
Example #6
0
 public static Mapx initDialog(Mapx params) {
   String Code = params.getString("Code");
   if (XString.isEmpty(Code)) {
     params.put("VerifyType", HtmlUtil.mapxToOptions(VerifyTypeMap));
     params.put("InputType", HtmlUtil.mapxToOptions(InputTypeMap));
     params.put("IsMandatory", HtmlUtil.codeToRadios("IsMandatory", "YesOrNo", "N"));
     params.put("MaxLength", "100");
     params.put("Cols", "265");
     params.put("Rows", "90");
   } else {
     ZDMemberFieldSchema field = new ZDMemberFieldSchema();
     field.setCode(Code);
     field.setSiteID(ApplicationPage.getCurrentSiteID());
     field.fill();
     params = field.toMapx();
     params.put("VerifyType", HtmlUtil.mapxToOptions(VerifyTypeMap, field.getVerifyType()));
     params.put("InputType", HtmlUtil.mapxToOptions(InputTypeMap, field.getInputType()));
     params.put(
         "IsMandatory", HtmlUtil.codeToRadios("IsMandatory", "YesOrNo", field.getIsMandatory()));
   }
   return params;
 }
Example #7
0
 public static com.xdarkness.member.Member setPropValues(
     com.xdarkness.member.Member member, Mapx Request) {
   ZDMemberSchema m = new ZDMemberSchema();
   String siteID = "";
   m.setUserName(member.getUserName());
   if (m.fill()) siteID = m.getSiteID() + "";
   else {
     siteID = Request.getString("SiteID");
   }
   m = setPropValues(m, Request, siteID);
   member.setValue(m.toMapx());
   return member;
 }
Example #8
0
  public static Mapx init(Mapx params) {
    String ForumID = params.getString("ForumID");
    String ThemeID = params.getString("ThemeID");
    String SiteID = params.getString("SiteID");
    ZCThemeSchema theme = new ZCThemeSchema();
    theme.setID(ThemeID);
    theme.setForumID(ForumID);
    Mapx map = theme.toMapx();
    ZCForumSchema forum = new ZCForumSchema();
    forum.setID(ForumID);
    forum.fill();
    map.put("Name", forum.getName());
    map.put("AddUser", User.getUserName());
    map.put("SiteID", SiteID);
    map.put("Priv", ForumUtil.initPriv(ForumID, SiteID));
    map.put("BBSName", ForumUtil.getBBSName(SiteID));

    return map;
  }
Example #9
0
 public static Mapx initDetail(Mapx params) {
   String id = params.getString("ID");
   if (XString.isNotEmpty(id)) {
     ZCCommentSchema comment = new ZCCommentSchema();
     comment.setID(id);
     if (comment.fill()) {
       params.putAll(comment.toMapx());
       params.put(
           "VerifyFlag",
           CacheManager.getMapx("Code", "Comment.Status").get(params.get("VerifyFlag")));
       String addTimeStr = params.getString("AddTime");
       params.put("AddTime", addTimeStr.substring(0, addTimeStr.lastIndexOf(".")));
     }
   }
   return params;
 }
Example #10
0
 static {
   depolyStatus.put("0", "就绪");
   depolyStatus.put("1", "执行中");
   depolyStatus.put("2", "成功");
   depolyStatus.put("3", "失败");
 }
Example #11
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;
  }
Example #12
0
  static {
    InputTypeMap.put(Input, "文本框");
    InputTypeMap.put(Text, "多行文本框");
    InputTypeMap.put(Selecter, "下拉框");
    InputTypeMap.put(Radio, "单选框");
    InputTypeMap.put(Checkbox, "多选框");
    InputTypeMap.put(DateInput, "日期框");
    InputTypeMap.put(TimeInput, "时间框");
    InputTypeMap.put(HTMLInput, "HTML");

    STRING = "1";

    NUMBER = "2";

    INT = "3";

    EMAIL = "5";

    VerifyTypeMap = new Mapx();

    VerifyTypeMap.put(STRING, "无");
    VerifyTypeMap.put(NUMBER, "数字");
    VerifyTypeMap.put(INT, "整数");
    VerifyTypeMap.put(EMAIL, "邮箱");
  }
Example #13
0
  private static String getColumn(DataRow dr, ZDMemberSchema member, String realField) {
    String columnName = dr.getString("Name");
    String columnCode = dr.getString("Code");
    String inputType = dr.getString("InputType");
    String verifyType = dr.getString("VerifyType");
    String listOption = dr.getString("ListOption");
    String defaultValue = dr.getString("DefaultValue");
    String isMandatory = dr.getString("IsMandatory");
    String maxLength = dr.getString("MaxLength");
    String HTML = dr.getString("HTML");
    String verifyStr = "verify='" + columnName + "|";
    if ("Y".equals(isMandatory)) {
      verifyStr = verifyStr + "NotNull";
    }
    if (!STRING.equals(verifyType)) {
      if (NUMBER.equals(verifyType)) verifyStr = verifyStr + "&&Number";
      else if (INT.equals(verifyType)) verifyStr = verifyStr + "&&Int";
      else if (EMAIL.equals(verifyType)) verifyStr = verifyStr + "&&Email";
    }
    if ((XString.isNotEmpty(maxLength)) && (!"0".equals(maxLength)))
      verifyStr = verifyStr + "&&Length<" + maxLength + "'";
    else {
      verifyStr = verifyStr + "'";
    }

    if ((member != null) && (realField != null)) {
      Mapx map = member.toMapx();
      defaultValue = map.getString(realField);
      if (XString.isEmpty(defaultValue)) {
        defaultValue = "";
      }
    }

    columnCode = "_MC_" + columnCode;
    StringBuffer sb = new StringBuffer();
    sb.append("<tr><td height='25' align='right' >");
    sb.append(columnName);
    sb.append(":</td><td align='left' >");

    if (inputType.equals(Input)) {
      sb.append(
          "<input type='text' size='26' id='"
              + columnCode
              + "' name='"
              + columnCode
              + "' value='"
              + defaultValue
              + "' "
              + verifyStr
              + " />");
    }

    if (inputType.equals(Text)) {
      sb.append(
          "<textarea style='width:"
              + dr.getString("ColSize")
              + "px;height:"
              + dr.getString("RowSize")
              + "px' id='"
              + columnCode
              + "' name='"
              + columnCode
              + "' "
              + verifyStr
              + ">"
              + defaultValue
              + "</textarea>");
    }

    if (inputType.equals(Selecter)) {
      SelectTag select = new SelectTag();
      select.setId(columnCode);
      if ("Y".equals(isMandatory)) {
        select.setVerify(columnName + "|NotNull");
      }
      String[] array = listOption.split("\\n");
      sb.append(select.getHtml(HtmlUtil.arrayToOptions(array, defaultValue, true)));
    }

    if (inputType.equals(Radio)) {
      String[] array = listOption.split("\\n");
      if ((XString.isEmpty(defaultValue)) && (array.length > 0)) {
        defaultValue = array[0];
      }
      sb.append(HtmlUtil.arrayToRadios(columnCode, array, defaultValue));
    }

    if (inputType.equals(Checkbox)) {
      String[] array = listOption.split("\\n");
      defaultValue = defaultValue.replaceAll("  ", ",");
      defaultValue = defaultValue.replaceAll(" ", ",");
      defaultValue = defaultValue.replaceAll("  ", ",");
      defaultValue = defaultValue.replaceAll(" ", ",");
      defaultValue = defaultValue.replaceAll(",,", ",");
      defaultValue = defaultValue.replaceAll(",,", ",");
      defaultValue = defaultValue.replaceAll(",", ",");
      String[] checkedArray = defaultValue.split(",");
      sb.append(HtmlUtil.arrayToCheckboxes(columnCode, array, checkedArray));
    }

    if (inputType.equals(DateInput)) {
      sb.append(
          "<input name='"
              + columnCode
              + "' id='"
              + columnCode
              + "' value='"
              + defaultValue
              + "' type='text'  size='20' xtype='Date' "
              + verifyStr
              + " />");
    }

    if (inputType.equals(TimeInput)) {
      sb.append(
          "<input name='"
              + columnCode
              + "' id='"
              + columnCode
              + "' value='"
              + defaultValue
              + "' type='text' size='10' xtype='Time' "
              + verifyStr
              + " />");
    }

    if (inputType.equals(HTMLInput)) {
      sb.append(HTML);
    }
    sb.append("</td></tr>");
    return sb.toString();
  }