示例#1
0
  /** ** Gets the SMSoutboubdGateway for the specified name */
  public static SMSOutboundGateway GetSMSGateway(String name) {

    /* get handler */
    if (StringTools.isBlank(name)) {
      return null;
    } else {
      return SmsGatewayHandlerMap.get(name.toLowerCase());
    }
  }
示例#2
0
 /** ** Returns an OrderedMap of defined primary keys ** @return map of defined primary keys */
 public Map<DBField, Object> getKeyMap() {
   Map<DBField, Object> keyMap = new OrderedMap<DBField, Object>(); // ordered key list
   if (this.dbFactory != null) {
     DBField keyField[] = this.dbFactory.getKeyFields();
     for (int i = 0; i < keyField.length; i++) {
       String key = keyField[i].getName();
       Object val = null;
       if (this.dbRecord != null) {
         // all key values will be defined
         val = this.dbRecord.getFieldValue(key);
       } else {
         // use parent keys
         DBFactoryTree parent = this.getParentNode();
         for (; (parent != null) && (val == null); parent = parent.getParentNode()) {
           DBRecord dbr = parent.getDBRecord();
           if (dbr == null) {
             // stop at the first undefined ancestor
             break;
           } else if (dbr.hasField(key)) {
             // try getting key value from ancestor
             DBField parFld = dbr.getField(key);
             if ((parFld != null) && parFld.isPrimaryKey()) {
               // primary key fields only
               val = dbr.getFieldValue(key);
             }
           }
         }
       }
       // save key DBField and value
       if (val != null) {
         keyMap.put(keyField[i], val);
       } else {
         keyMap.put(keyField[i], null);
       }
     }
   }
   return keyMap;
 }
示例#3
0
  /** ** Add SMS Gateway support provider */
  public static void AddSMSGateway(String name, SMSOutboundGateway smsGW) {

    /* validate name */
    if (StringTools.isBlank(name)) {
      Print.logWarn("SMS Gateway name is blank");
      return;
    } else if (smsGW == null) {
      Print.logWarn("SMS Gateway handler is null");
      return;
    }

    /* initialize map? */
    if (SmsGatewayHandlerMap == null) {
      SmsGatewayHandlerMap = new HashMap<String, SMSOutboundGateway>();
    }

    /* save handler */
    SmsGatewayHandlerMap.put(name.toLowerCase(), smsGW);
    Print.logDebug("Added SMS Gateway Handler: " + name);
  }
  public static void writeMenu(
      PrintWriter out,
      RequestProperties reqState,
      String menuID,
      boolean expandableMenu,
      boolean showIcon,
      int descriptionType,
      boolean showMenuHelp)
      throws IOException {
    PrivateLabel privLabel = reqState.getPrivateLabel();
    Locale locale = reqState.getLocale();
    String parentPageName = null;
    Account account = reqState.getCurrentAccount();

    /* disable menu help if menu description is not displayed */
    boolean showInline = false;
    if (descriptionType == ExpandMenu.DESC_NONE) {
      showMenuHelp = false;
      showInline = true;
    }

    /* sub style classes */
    String topMenuID =
        !StringTools.isBlank(menuID) ? menuID : (expandableMenu ? "expandMenu" : "fixedMenu");
    String groupClass = "menuGroup";
    String leafClass = "itemLeaf";
    String leafDescClass = "itemLeafDesc";
    String helpClass = "itemLeafHelp";
    String helpPadClass = "itemLeafHelpPad";
    String leafIconClass = "itemLeafIcon";

    /* start menu */
    out.println("<ul id='" + topMenuID + "'>");

    /* iterate through menu groups */
    Map<String, MenuGroup> menuMap = privLabel.getMenuGroupMap();
    for (String mgn : menuMap.keySet()) {
      MenuGroup mg = menuMap.get(mgn);
      if (!mg.showInTopMenu()) {
        // skip this group
        // Print.logInfo("Skipping menu group: %s", mgn);
        continue;
      }

      boolean didDisplayGroup = false;
      for (WebPage wp : mg.getWebPageList(reqState)) {
        String menuName = wp.getPageName();
        String iconURI = showIcon ? wp.getMenuIconImage() : null; // may be blank/null
        String menuHelp = wp.getMenuHelp(reqState, parentPageName);
        String url = wp.encodePageURL(reqState); // , RequestProperties.TRACK_BASE_URI());

        /* skip login page */
        if (menuName.equalsIgnoreCase(Constants.PAGE_LOGIN)) {
          // omit login
          // Print.logInfo("Skipping login page: %s", menuName);
          continue;
        }

        /* skip sysAdmin pages */
        if (wp.systemAdminOnly() && !Account.isSystemAdmin(account)) {
          continue;
        }

        /* skip pages that are not ok to display */
        if (!wp.isOkToDisplay(reqState)) {
          continue;
        }

        /* menu description */
        String menuDesc = null;
        switch (descriptionType) {
          case DESC_NONE:
            menuDesc = null;
            break;
          case DESC_SHORT:
            menuDesc = wp.getNavigationDescription(reqState);
            break;
          case DESC_LONG:
          default:
            menuDesc = wp.getMenuDescription(reqState, parentPageName);
            break;
        }

        /* skip this menu item? */
        if (StringTools.isBlank(menuDesc) && StringTools.isBlank(iconURI)) {
          // Print.logWarn("Menu name has no description: %s", menuName);
          continue;
        }

        /* start menu group */
        if (!didDisplayGroup) {
          // open Menu Group
          didDisplayGroup = true;
          out.write("<li class='" + groupClass + "'>" + mg.getTitle(locale) + "\n");
          if (showInline) {
            out.write("<br><table cellpadding='0' cellspacing='0' border='0'><tr>\n");
          } else {
            out.write("<ul>\n"); // <-- start menu sub group
          }
        }

        /* menu anchor/link */
        String anchorStart = "<a";
        if (!StringTools.isBlank(menuHelp)) {
          anchorStart += " title=\"" + menuHelp + "\"";
        }
        String target =
            StringTools.blankDefault(wp.getTarget(), "_self"); // ((WebPageURL)wp).getTarget();
        if (target.startsWith("_")) {
          anchorStart += " href=\"" + url + "\"";
          anchorStart += " target=\"" + target + "\"";
        } else {
          PixelDimension pixDim = wp.getWindowDimension();
          if (pixDim != null) {
            int W = pixDim.getWidth();
            int H = pixDim.getHeight();
            anchorStart +=
                " onclick=\"javascript:openFixedWindow('"
                    + url
                    + "','"
                    + target
                    + "',"
                    + W
                    + ","
                    + H
                    + ")\"";
            anchorStart += " style=\"text-decoration: underline; color: blue; cursor: pointer;\"";
          } else {
            anchorStart += " href=\"" + url + "\"";
            anchorStart += " target=\"" + target + "\"";
          }
        }
        anchorStart += ">";

        /* inline? */
        if (showInline) {

          /* menu icon (will not be blank here) */
          out.write("<td class='" + leafIconClass + "'>");
          if (!StringTools.isBlank(iconURI)) {
            out.write(
                anchorStart + "<img class='" + leafIconClass + "' src='" + iconURI + "'/></a>");
          } else {
            out.write("&nbsp;");
          }
          out.write("</td>");

        } else {

          /* start menu list item */
          out.write("<li class='" + leafClass + "'>");

          /* special case for non-icons */
          if (StringTools.isBlank(iconURI)) {

            /* menu description/help */
            if (!StringTools.isBlank(menuDesc)) {
              out.write(
                  "<span class='" + leafDescClass + "'>" + anchorStart + menuDesc + "</a></span>");
              if (showMenuHelp && !StringTools.isBlank(menuHelp)) {
                out.write("<br>");
                out.write("<span class='" + helpPadClass + "'>" + menuHelp + "</span>");
              }
            }

          } else {
            // this section may not appear as expected on IE

            /* start table */
            out.write("<table class='" + leafClass + "' cellpadding='0' cellspacing='0'>");
            out.write("<tr>");

            /* menu icon */
            if (!StringTools.isBlank(iconURI)) {
              out.write("<td class='" + leafIconClass + "'>");
              out.write(
                  anchorStart + "<img class='" + leafIconClass + "' src='" + iconURI + "'/></a>");
              out.write("</td>");
            }

            /* menu description/help */
            if (!StringTools.isBlank(menuDesc)) {
              out.write("<td class='" + leafDescClass + "'>");
              out.write(
                  "<span class='" + leafDescClass + "'>" + anchorStart + menuDesc + "</a></span>");
              if (showMenuHelp && !StringTools.isBlank(menuHelp)) {
                out.write("<br>");
                out.write("<span class='" + helpClass + "'>" + menuHelp + "</span>");
              }
              out.write("</td>");
            }

            /* end table */
            out.write("</tr>");
            out.write("</table>");
          }

          /* end menu list item */
          out.write("</li>\n");
        }
      }

      /* end menu group */
      if (didDisplayGroup) {
        if (showInline) {
          out.write("</tr></table>\n");
        } else {
          out.write("</ul>\n");
        }
        out.write("</li>\n");
      }
    }

    /* end of menu */
    out.write("</ul>\n");

    /* init menu if expandable */
    if (expandableMenu) {
      out.write(
          "<script type=\"text/javascript\"> new ExpandMenu('" + topMenuID + "'); </script>\n");
    }
  }