protected String getContent(Map<String, Object> data) {
    String content = "";
    try {
      if (isLoginPage) {
        return getLoginForm(data);
      } else if (!isAuthorized) {
        return "<h3>" + ResourceBundleUtil.getMessage("ubuilder.noAuthorize") + "</h3>";
      } else if (userview.getCurrent() != null) {
        if (isQuickEditEnabled) {
          String label =
              ResourceBundleUtil.getMessage("adminBar.label.page")
                  + ": "
                  + userview.getCurrent().getPropertyString("label");
          String url =
              request.getContextPath()
                  + "/web/console/app/"
                  + userview.getParamString("appId")
                  + "/"
                  + userview.getParamString("appVersion")
                  + "/userview/builder/"
                  + userview.getPropertyString("id")
                  + "?menuId="
                  + userview.getCurrent().getPropertyString("id");
          content += "<div class=\"quickEdit\" style=\"display: none\">\n";
          content +=
              "    <a href=\""
                  + url
                  + "\" target=\"_blank\"><i class=\"icon-edit\"></i> "
                  + label
                  + "</a>\n";
          content += "</div>\n";
        }

        content += UserviewUtil.getUserviewMenuHtml(userview.getCurrent());
      } else {
        String pageNotFound = theme.handlePageNotFound(data);
        if (pageNotFound != null) {
          return pageNotFound;
        } else {
          return getDefaultTheme().handlePageNotFound(data);
        }
      }
    } catch (Exception e) {
      String errorHandle = theme.handleContentError(e, data);
      if (errorHandle != null) {
        return errorHandle;
      } else {
        return getDefaultTheme().handleContentError(e, data);
      }
    }

    return content;
  }
 protected String getMenus(Map<String, Object> data) {
   String content = "";
   String menu = theme.getMenus(data);
   if (menu == null) {
     menu = getDefaultTheme().getMenus(data);
   }
   if (isQuickEditEnabled) {
     String label =
         ResourceBundleUtil.getMessage("adminBar.label.menu")
             + ": "
             + userview.getPropertyString("name");
     String url =
         request.getContextPath()
             + "/web/console/app/"
             + userview.getParamString("appId")
             + "/"
             + userview.getParamString("appVersion")
             + "/userview/builder/"
             + userview.getPropertyString("id");
     content += "<div class=\"quickEdit\" style=\"display: none\">\n";
     content +=
         "    <a href=\""
             + url
             + "\" target=\"_blank\"><i class=\"icon-edit\"></i> "
             + label
             + "</a>\n";
     content += "</div>\n";
   }
   content += menu;
   return content;
 }
  protected String getJogetFooter() {
    String html =
        "<script type=\"text/javascript\">\n"
            + "            HelpGuide.base = \""
            + request.getContextPath()
            + "\"\n"
            + "            HelpGuide.attachTo = \"#header\";\n"
            + "            HelpGuide.key = \"help.web.userview."
            + userview.getParamString("appId")
            + "."
            + userview.getParamString("userviewId")
            + "."
            + getBodyId()
            + "\";\n"
            + "            HelpGuide.show();\n"
            + "        </script>\n";

    html += AppUtil.getSystemAlert() + "\n";

    Map<String, Object> modelMap = new HashMap<String, Object>();
    AppDefinition appDef = AppUtil.getCurrentAppDefinition();
    modelMap.put("appId", userview.getParamString("appId"));
    modelMap.put("appVersion", appDef.getVersion().toString());
    modelMap.put("userviewId", userview.getParamString("userviewId"));
    html += UserviewUtil.renderJspAsString("ubuilder/adminBar.jsp", modelMap) + "\n\n";

    if ("true".equalsIgnoreCase(userview.getParamString("isPreview"))) {
      html +=
          "<!--[if IE]><div id=\"preview-label\" class=\"ie\">"
              + ResourceBundleUtil.getMessage("fbuilder.preview")
              + "</div><![endif]-->\n"
              + "        <!--[if !IE]><!--><div id=\"preview-label\">"
              + ResourceBundleUtil.getMessage("fbuilder.preview")
              + "</div><!--<![endif]-->        \n"
              + "        <div style=\"display:none\" id=\"preview-form\">\n"
              + "            <form id=\"preview\" action=\"\" method=\"post\">\n"
              + "                <input type=\"hidden\" name=\"json\" value=\""
              + StringEscapeUtils.escapeHtml(userview.getParamString("json"))
              + "\"/>\"/>\n"
              + "            </form>\n"
              + "        </div>\n";
    }

    return html;
  }
  protected String getJogetHeader() {
    String cp = request.getContextPath();
    String bn = ResourceBundleUtil.getMessage("build.number");
    String html =
        "<link rel=\"stylesheet\" type=\"text/css\" href=\""
            + cp
            + "/wro/common.css?build="
            + bn
            + "\" />\n"
            + "<link rel=\"stylesheet\" type=\"text/css\" href=\""
            + cp
            + "/wro/userview_v5.min.css?build="
            + bn
            + "\" />\n"
            + "<script type=\"text/javascript\" src=\""
            + cp
            + "/wro/common.js?build="
            + bn
            + "\"></script>\n"
            + "<script type=\"text/javascript\">\n";

    UserSecurity us = DirectoryUtil.getUserSecurity();
    if (!(us != null && us.getAllowSessionTimeout())) {
      html +=
          "$(document).ready(function(){\n"
              + "            $('body').append('<img id=\"image_alive\" style=\"display:none;\" width=\"1\" height=\"1\" src=\""
              + cp
              + "/images/v3/clear.gif?\" alt=\"\">');\n"
              + "            window.setInterval(\"keepMeAlive('image_alive')\", 200000);\n"
              + "        });\n"
              + "        function keepMeAlive(imgName)\n"
              + "        {  \n"
              + "             myImg = document.getElementById(imgName);   \n"
              + "             if (myImg)\n"
              + "                 myImg.src = myImg.src.replace(/\\?.*$/, '?' + Math.random());   \n"
              + "        }  ";
    }

    // fix IE browser
    html +=
        "if ($.browser.msie) {\n"
            + "            $(document).on(\"keydown\", function (e) {\n"
            + "                if (e.which === 8 && !$(e.target).is(\"input:not([readonly]), textarea:not([readonly])\")) {\n"
            + "                    e.preventDefault();\n"
            + "                }\n"
            + "            });\n"
            + "        }\n";

    // userview print feature
    html +=
        "function userviewPrint(){\n"
            + "            $('head').append('<link id=\"userview_print_css\" rel=\"stylesheet\" href=\""
            + cp
            + "/wro/userview_print.min.css\" type=\"text/css\" media=\"print\"/>');\n"
            + "            setTimeout(\"do_print()\", 1000); \n"
            + "        }\n"
            + "        function do_print(){\n"
            + "            window.print();\n"
            + "            $('#userview_print_css').remove();\n"
            + "        }\n";

    if ("true".equalsIgnoreCase(userview.getParamString("isPreview"))) {
      html +=
          "$(document).ready(function(){\n$('a').click(function(){\n"
              + "        var action = $(this).attr('href');\n"
              + "if (action !== \"\" && action !== undefined && action !== \"#\"){\n"
              + "        $('#preview').attr('action', action);\n"
              + "        $('#preview').submit();\n"
              + "}\n"
              + "        return false;\n"
              + "    });\n"
              + "\n});\n";
    }

    html +=
        "UI.base = \""
            + request.getContextPath()
            + "\";\n"
            + "        UI.userview_app_id = '"
            + userview.getParamString("appId")
            + "';\n"
            + "        UI.userview_id = '"
            + userview.getPropertyString("id")
            + "';\n";

    if (alertMessage != null && !alertMessage.isEmpty()) {
      html += "alert(\"" + alertMessage + "\");\n";
    }

    html += "</script>\n";

    html +=
        "    <script>\n"
            + "        ConnectionManager.tokenName = \""
            + SecurityUtil.getCsrfTokenName()
            + "\";\n"
            + "        ConnectionManager.tokenValue = \""
            + SecurityUtil.getCsrfTokenValue(request)
            + "\";\n"
            + "        JPopup.tokenName = \""
            + SecurityUtil.getCsrfTokenName()
            + "\";\n"
            + "        JPopup.tokenValue = \""
            + SecurityUtil.getCsrfTokenValue(request)
            + "\";\n"
            + "    </script>";

    return html;
  }
  public String getHtml() {
    Map<String, Object> data = new HashMap<String, Object>();
    data.put("params", userview.getParams());
    data.put("userview", userview);
    data.put("is_login_page", isLoginPage);
    if (isLoginPage) {
      data.put("login_form_footer", DirectoryUtil.getLoginFormFooter());

      if (request.getSession() != null) {
        Throwable exception =
            (Throwable) request.getSession().getAttribute("SPRING_SECURITY_LAST_EXCEPTION");
        if (exception != null) {
          data.put("login_exception", exception.getMessage());
        }
      }
      data.put("login_error_classes", "form-errors alert alert-warning");
    }
    data.put("context_path", request.getContextPath());
    data.put("build_number", ResourceBundleUtil.getMessage("build.number"));
    String rightToLeft = WorkflowUtil.getSystemSetupValue("rightToLeft");
    data.put("right_to_left", "true".equalsIgnoreCase(rightToLeft));
    String locale = AppUtil.getAppLocale();
    data.put("locale", locale);
    data.put("embed", "true".equalsIgnoreCase(userview.getParamString("embed")));
    data.put("body_id", getBodyId());
    data.put("body_classes", getBodyClasses(rightToLeft, locale));
    data.put("base_link", request.getContextPath() + getBaseLink());
    data.put("home_page_link", request.getContextPath() + getHomePageLink());
    data.put("title", getTitle());
    data.put("hide_nav", false);
    data.put("nav_id", "navigation");
    data.put("nav_classes", "nav-collapse sidebar-nav");
    data.put("categories_container_id", "category-container");
    data.put("categories_container_classes", "nav nav-tabs nav-stacked main-menu");
    data.put("category_classes", "category");
    data.put("first_category_classes", "first");
    data.put("last_category_classes", "last");
    data.put("current_category_classes", "current-category active");
    data.put("combine_single_menu_category", false);
    data.put("menus_container_classes", "menu-container");
    data.put("menu_classes", "menu");
    data.put("first_menu_classes", "first");
    data.put("last_menu_classes", "last");
    data.put("current_menu_classes", "current active");
    data.put("main_container_id", "main");
    data.put("sidebar_id", "sidebar");
    data.put("content_id", "content");

    String username = WorkflowUtil.getCurrentUsername();
    boolean isLoggedIn = username != null && !WorkflowUserManager.ROLE_ANONYMOUS.equals(username);
    data.put("is_logged_in", isLoggedIn);
    if (isLoggedIn) {
      ExtDirectoryManager directoryManager =
          (ExtDirectoryManager) AppUtil.getApplicationContext().getBean("directoryManager");
      User user = directoryManager.getUserByUsername(username);
      data.put("username", username);
      data.put("user", user);
      data.put("logout_link", request.getContextPath() + "/j_spring_security_logout");
    } else {
      data.put("login_link", request.getContextPath() + getLoginLink());
    }

    data.put("content", getContent(data));

    String handleMenuResponse = handleMenuResponse();
    if (handleMenuResponse != null) {
      return handleMenuResponse;
    }

    data.put("metas", getMetas(data));
    data.put("joget_header", getJogetHeader());
    data.put("js_css_lib", getJsCssLib(data));
    data.put("fav_icon_link", getFavIconLink(data));
    data.put("js", getJs(data));
    data.put("css", getCss(data));
    data.put("head", getHead(data));
    if (!"true".equalsIgnoreCase(userview.getParamString("embed"))) {
      data.put("header", getHeader(data));
      if (isAuthorized) {
        data.put("menus", getMenus(data));
      }
      data.put("footer", getFooter(data));
    }
    data.put("joget_footer", getJogetFooter());
    data.put("content_container", getContentContainer(data));

    return getLayout(data);
  }