示例#1
0
 public static String getServerBaseUrl() {
   PortletRequestContext portletRequestContext = RequestContext.getCurrentInstance();
   String url =
       portletRequestContext.getRequest().getScheme()
           + "://"
           + portletRequestContext.getRequest().getServerName()
           + ":"
           + String.format("%s", portletRequestContext.getRequest().getServerPort())
           + "/";
   return url;
 }
示例#2
0
 /**
  * Gets and initialize variable.<br>
  *
  * @throws Exception
  */
 public UIGroovyPortlet() throws Exception {
   PortletRequestContext context =
       (PortletRequestContext) WebuiRequestContext.getCurrentInstance();
   PortletRequest prequest = context.getRequest();
   template_ = prequest.getPreferences().getValue("template", DEFAULT_TEMPLATE);
   windowId = prequest.getWindowID();
 }
示例#3
0
    @Override
    public ResultNode createData(Node node, Row row) {
      try {
        PortalRequestContext portalRequestContext = Util.getPortalRequestContext();
        PortletRequestContext portletRequestContext = WebuiRequestContext.getCurrentInstance();
        PortletRequest portletRequest = portletRequestContext.getRequest();

        StringBuffer baseURI = new StringBuffer();
        baseURI
            .append(portletRequest.getScheme())
            .append("://")
            .append(portletRequest.getServerName());
        if (portletRequest.getServerPort() != 80) {
          baseURI.append(":").append(String.format("%s", portletRequest.getServerPort()));
        }
        baseURI.append(portalRequestContext.getPortalContextPath());
        if (node.isNodeType("mop:pagelink")) {
          node = node.getParent();
        }

        if (node.isNodeType("gtn:language")) {
          node = node.getParent().getParent();
        }
        String userNaviUri =
            baseURI.toString() + "/" + PageDataCreator.getUserNavigationURI(node).toString();
        if (userNavigationUriList.contains(userNaviUri)) {
          return null;
        }
        userNavigationUriList.add(userNaviUri);
        return new ResultNode(node, row, userNaviUri);
      } catch (Exception e) {
        return null;
      }
    }
示例#4
0
 public static void savePortletPreference(
     FAQSetting setting, String emailAddNewQuestion, String emailEditResponseQuestion) {
   try {
     PortletRequestContext pcontext =
         (PortletRequestContext) WebuiRequestContext.getCurrentInstance();
     PortletPreferences portletPref = pcontext.getRequest().getPreferences();
     portletPref.setValue("display", setting.getDisplayMode());
     portletPref.setValue("orderBy", setting.getOrderBy());
     portletPref.setValue("orderType", setting.getOrderType());
     portletPref.setValue("isDiscussForum", String.valueOf(setting.getIsDiscussForum()));
     portletPref.setValue("idNameCategoryForum", setting.getIdNameCategoryForum());
     portletPref.setValue("enableAutomaticRSS", setting.isEnableAutomaticRSS() + "");
     portletPref.setValue("enableViewAvatar", setting.isEnableViewAvatar() + "");
     portletPref.setValue("enanbleVotesAndComments", setting.isEnanbleVotesAndComments() + "");
     portletPref.setValue(
         "enableAnonymousSubmitQuestion", setting.isEnableAnonymousSubmitQuestion() + "");
     portletPref.setValue("SendMailAddNewQuestion", emailAddNewQuestion);
     portletPref.setValue("SendMailEditResponseQuestion", emailEditResponseQuestion);
     portletPref.setValue("emailMoveQuestion", setting.getEmailMoveQuestion());
     portletPref.setValue(
         "isPostQuestionInRootCategory", setting.isPostQuestionInRootCategory() + "");
     portletPref.store();
   } catch (Exception e) {
     log.error("Fail to save portlet preferences: ", e);
   }
 }
示例#5
0
 public static void saveFAQPortletPreference(List<String> list, boolean useAjax) throws Exception {
   PortletRequestContext pcontext =
       (PortletRequestContext) WebuiRequestContext.getCurrentInstance();
   PortletPreferences portletPref = pcontext.getRequest().getPreferences();
   String str = list.toString();
   str = str.replace("[", "").replace("]", "").replaceAll(" ", "");
   portletPref.setValue("displayCategories", str);
   portletPref.setValue("useAjax", String.valueOf(useAjax));
   portletPref.store();
 }
示例#6
0
 public static List<String> getCategoriesIdFAQPortlet() throws Exception {
   PortletRequestContext pcontext =
       (PortletRequestContext) WebuiRequestContext.getCurrentInstance();
   PortletPreferences portletPref = pcontext.getRequest().getPreferences();
   String str = portletPref.getValue("displayCategories", "");
   List<String> list = new ArrayList<String>();
   if (!isFieldEmpty(str)) {
     list.addAll(Arrays.asList(str.split(",")));
   }
   return list;
 }
示例#7
0
 public static int getLimitUploadSize() {
   PortletRequestContext pcontext = (PortletRequestContext) RequestContext.getCurrentInstance();
   PortletPreferences portletPref = pcontext.getRequest().getPreferences();
   int limitMB;
   try {
     limitMB = Integer.parseInt(portletPref.getValue(UPLOAD_LIMIT, "").trim());
   } catch (NumberFormatException e) {
     limitMB = DEFAULT_VALUE_UPLOAD_PORTAL;
   }
   return limitMB;
 }
示例#8
0
 public static int getLimitUploadSize(boolean isAvatar) {
   PortletRequestContext pcontext =
       (PortletRequestContext) WebuiRequestContext.getCurrentInstance();
   PortletPreferences portletPref = pcontext.getRequest().getPreferences();
   int limitMB = DEFAULT_VALUE_UPLOAD_PORTAL;
   if (isAvatar) {
     limitMB = Integer.parseInt(portletPref.getValue(UPLOAD_AVATAR_SIZE, "").trim());
   } else {
     limitMB = Integer.parseInt(portletPref.getValue(UPLOAD_FILE_SIZE, "").trim());
   }
   return limitMB;
 }
示例#9
0
 public static String getEmailMoveQuestion(FAQSetting faqSetting) {
   PortletRequestContext pcontext =
       (PortletRequestContext) WebuiRequestContext.getCurrentInstance();
   PortletPreferences portletPref = pcontext.getRequest().getPreferences();
   String str = portletPref.getValue("emailMoveQuestion", "");
   if (isFieldEmpty(str)) {
     WebuiRequestContext context = WebuiRequestContext.getCurrentInstance();
     ResourceBundle res = context.getApplicationResourceBundle();
     str = res.getString("SendEmail.MoveQuetstion.Default");
   }
   faqSetting.setEmailMoveQuestion(str);
   return str;
 }
  /*
   * (non-Javadoc)
   * @see
   * org.exoplatform.webui.core.UIPortletApplication#processRender(org.exoplatform
   * .webui.application.WebuiApplication,
   * org.exoplatform.webui.application.WebuiRequestContext)
   */
  public void processRender(WebuiApplication app, WebuiRequestContext context) throws Exception {
    PortletRequestContext pContext = (PortletRequestContext) context;
    PortletMode newMode = pContext.getApplicationMode();
    PortletPreferences preferences = pContext.getRequest().getPreferences();
    Boolean sharedCache = "true".equals(preferences.getValue(ENABLE_CACHE, "true"));

    if (context.getRemoteUser() == null
        || (Utils.isLiveMode()
            && sharedCache
            && !Utils.isPortalEditMode()
            && Utils.isPortletViewMode(pContext))) {
      WCMService wcmService = getApplicationComponent(WCMService.class);
      pContext
          .getResponse()
          .setProperty(MimeResponse.EXPIRATION_CACHE, "" + wcmService.getPortletExpirationCache());
      if (log.isTraceEnabled())
        log.trace("SCV rendering : cache set to " + wcmService.getPortletExpirationCache());
    }

    if (!newMode.equals(mode)) {
      activateMode(newMode);
      mode = newMode;
    }

    Node nodeView = null;
    if (uiPresentation != null) {
      nodeView = uiPresentation.getNodeView();
      if (nodeView != null) {
        TemplateService templateService = getApplicationComponent(TemplateService.class);
        uiPresentation
            .getChild(UIPresentation.class)
            .setTemplatePath(templateService.getTemplatePath(nodeView, false));
      }
    }

    if (uiPresentation != null && uiPresentation.isContextual() && nodeView != null) {
      RenderResponse response = context.getResponse();
      Element title = response.createElement("title");
      title.setTextContent(uiPresentation.getTitle(nodeView));
      response.addProperty(MimeResponse.MARKUP_HEAD_ELEMENT, title);
    }

    if (context.getRemoteUser() != null && WCMComposer.MODE_EDIT.equals(Utils.getCurrentMode())) {
      pContext.getJavascriptManager().loadScriptResource(ResourceScope.SHARED, "content-selector");
      pContext.getJavascriptManager().loadScriptResource(ResourceScope.SHARED, "quick-edit");
    }

    setId(UISingleContentViewerPortlet.class.getSimpleName() + pContext.getWindowId());
    super.processRender(app, context);
  }
示例#11
0
 public static void getPorletPreference(FAQSetting faqSetting) {
   PortletRequestContext pcontext =
       (PortletRequestContext) WebuiRequestContext.getCurrentInstance();
   PortletPreferences portletPref = pcontext.getRequest().getPreferences();
   faqSetting.setEnableViewAvatar(
       Boolean.parseBoolean(portletPref.getValue("enableViewAvatar", "")));
   faqSetting.setEnableAutomaticRSS(
       Boolean.parseBoolean(portletPref.getValue("enableAutomaticRSS", "")));
   faqSetting.setEnanbleVotesAndComments(
       Boolean.parseBoolean(portletPref.getValue("enanbleVotesAndComments", "")));
   faqSetting.setEnableAnonymousSubmitQuestion(
       Boolean.parseBoolean(portletPref.getValue("enableAnonymousSubmitQuestion", "")));
   faqSetting.setDisplayMode(portletPref.getValue("display", ""));
   faqSetting.setOrderBy(portletPref.getValue("orderBy", ""));
   faqSetting.setOrderType(portletPref.getValue("orderType", ""));
   faqSetting.setIsDiscussForum(Boolean.parseBoolean(portletPref.getValue("isDiscussForum", "")));
   faqSetting.setIdNameCategoryForum(portletPref.getValue("idNameCategoryForum", ""));
   faqSetting.setEmailMoveQuestion(portletPref.getValue("emailMoveQuestion", ""));
   faqSetting.setPostQuestionInRootCategory(
       Boolean.parseBoolean(portletPref.getValue("isPostQuestionInRootCategory", "true")));
 }
示例#12
0
 public static void getEmailSetting(FAQSetting faqSetting, boolean isNew, boolean isSettingForm) {
   PortletRequestContext pcontext =
       (PortletRequestContext) WebuiRequestContext.getCurrentInstance();
   PortletPreferences portletPref = pcontext.getRequest().getPreferences();
   String emailContent = "";
   if (isNew) {
     emailContent = portletPref.getValue("SendMailAddNewQuestion", "");
   } else {
     if (isSettingForm) emailContent = portletPref.getValue("SendMailEditResponseQuestion", "");
   }
   WebuiRequestContext context = WebuiRequestContext.getCurrentInstance();
   ResourceBundle res = context.getApplicationResourceBundle();
   if (emailContent == null || emailContent.trim().length() < 1) {
     if (isNew) {
       emailContent = res.getString("SendEmail.AddNewQuestion.Default");
     } else {
       if (isSettingForm) emailContent = res.getString("SendEmail.EditQuestion.Default");
       else emailContent = res.getString("SendEmail.ResponseQuestion.Default");
     }
   }
   faqSetting.setEmailSettingSubject(res.getString("SendEmail.Default.Subject"));
   faqSetting.setEmailSettingContent(emailContent);
 }
示例#13
0
文件: Utils.java 项目: canhpv/ecms
 /**
  * Get all portlet preferences
  *
  * @return all portlet preferences
  */
 public static PortletPreferences getAllPortletPreferences() {
   PortletRequestContext portletRequestContext = WebuiRequestContext.getCurrentInstance();
   return portletRequestContext.getRequest().getPreferences();
 }
示例#14
0
文件: Utils.java 项目: canhpv/ecms
 /**
  * Get one portlet preference by name
  *
  * @param preferenceName the name of preference
  * @return the portlet preference's value
  */
 public static String getPortletPreference(String preferenceName) {
   PortletRequestContext portletRequestContext = WebuiRequestContext.getCurrentInstance();
   PortletPreferences preferences = portletRequestContext.getRequest().getPreferences();
   return preferences.getValue(preferenceName, null);
 }
 /**
  * Instantiates a new uI single content viewer portlet.
  *
  * @throws Exception the exception
  */
 public UISingleContentViewerPortlet() throws Exception {
   addChild(UIPopupContainer.class, null, "UIPopupContainer-" + new Date().getTime());
   PortletRequestContext portletRequestContext = WebuiRequestContext.getCurrentInstance();
   preferences = portletRequestContext.getRequest().getPreferences();
 }
示例#16
0
 public static boolean getUseAjaxFAQPortlet() {
   PortletRequestContext pcontext =
       (PortletRequestContext) WebuiRequestContext.getCurrentInstance();
   PortletPreferences portletPref = pcontext.getRequest().getPreferences();
   return Boolean.parseBoolean(portletPref.getValue("useAjax", "false"));
 }
 public void init() {
   PortletRequestContext portletRequestContext = WebuiRequestContext.getCurrentInstance();
   PortletPreferences preferences = portletRequestContext.getRequest().getPreferences();
   text = preferences.getValue(UIBasicPortlet.TEXT_PREFERENCE, null);
 }