@Override
  public String getURL(PortletRequest portletRequest, PortletResponse portletResponse) {

    ThemeDisplay themeDisplay = (ThemeDisplay) portletRequest.getAttribute(WebKeys.THEME_DISPLAY);

    PortletDisplay portletDisplay = themeDisplay.getPortletDisplay();

    Portlet portlet = _portletLocalService.getPortletById(portletDisplay.getId());

    PortletURL portletURL =
        PortletURLFactoryUtil.create(
            portletRequest,
            PortletProviderUtil.getPortletId(
                DDMStructure.class.getName(), PortletProvider.Action.VIEW),
            PortletRequest.RENDER_PHASE);

    portletURL.setParameter("mvcPath", "/view.jsp");
    portletURL.setParameter("backURL", themeDisplay.getURLCurrent());
    portletURL.setParameter("groupId", String.valueOf(themeDisplay.getScopeGroupId()));
    portletURL.setParameter("refererPortletName", DLPortletKeys.DOCUMENT_LIBRARY);
    portletURL.setParameter("refererWebDAVToken", WebDAVUtil.getStorageToken(portlet));
    portletURL.setParameter("showAncestorScopes", Boolean.TRUE.toString());
    portletURL.setParameter("showManageTemplates", Boolean.FALSE.toString());

    return portletURL.toString();
  }
  protected String getWindowJS(PortletRequest portletRequest, JournalArticle article) {

    StringBundler sb = new StringBundler(13);

    sb.append("Liferay.Util.Window.getWindow({bodyCssClass: ");
    sb.append("'dialog-with-footer', destroyOnHide: true, dialog: ");
    sb.append(getDialogJS(article));
    sb.append(", id: '");

    ThemeDisplay themeDisplay = (ThemeDisplay) portletRequest.getAttribute(WebKeys.THEME_DISPLAY);

    PortletDisplay portletDisplay = themeDisplay.getPortletDisplay();

    sb.append(HtmlUtil.escape(portletDisplay.getNamespace()));
    sb.append("viewSource', namespace: '");
    sb.append(portletDisplay.getNamespace());
    sb.append("', portlet: '#p_p_id_");
    sb.append(portletDisplay.getId());
    sb.append("_', portletId: '");
    sb.append(portletDisplay.getId());
    sb.append("', title: '");
    sb.append(HtmlUtil.escapeJS(HtmlUtil.escape(article.getTitle(themeDisplay.getLocale()))));
    sb.append("'});");

    return sb.toString();
  }
  protected String getPortletResource() {
    ThemeDisplay themeDisplay = getThemeDisplay();

    PortletDisplay portletDisplay = themeDisplay.getPortletDisplay();

    return portletDisplay.getPortletResource();
  }
  @Override
  public boolean isShow(PortletRequest portletRequest) {
    ThemeDisplay themeDisplay = (ThemeDisplay) portletRequest.getAttribute(WebKeys.THEME_DISPLAY);

    PortletDisplay portletDisplay = themeDisplay.getPortletDisplay();

    return portletDisplay.isShowCloseIcon();
  }
  @Override
  public void populateConfigJSONObject(
      JSONObject jsonObject,
      Map<String, Object> inputEditorTaglibAttributes,
      ThemeDisplay themeDisplay,
      RequestBackedPortletURLFactory requestBackedPortletURLFactory) {

    JSONObject autoCompleteConfigJSONObject = JSONFactoryUtil.createJSONObject();

    autoCompleteConfigJSONObject.put("requestTemplate", "query={query}");

    JSONArray triggerJSONArray = JSONFactoryUtil.createJSONArray();

    JSONObject triggerJSONObject = JSONFactoryUtil.createJSONObject();

    triggerJSONObject.put("resultFilters", "function(query, results) {return results;}");
    triggerJSONObject.put("resultTextLocator", "title");

    PortletDisplay portletDisplay = themeDisplay.getPortletDisplay();

    ResourceURL autoCompletePageTitleURL =
        (ResourceURL) requestBackedPortletURLFactory.createResourceURL(portletDisplay.getId());

    Map<String, String> fileBrowserParams =
        (Map<String, String>)
            inputEditorTaglibAttributes.get("liferay-ui:input-editor:fileBrowserParams");

    autoCompletePageTitleURL.setParameter("nodeId", fileBrowserParams.get("nodeId"));

    autoCompletePageTitleURL.setResourceID("/wiki/autocomplete_page_title");

    String source =
        autoCompletePageTitleURL.toString()
            + "&"
            + _portal.getPortletNamespace(portletDisplay.getId());

    triggerJSONObject.put("source", source);

    triggerJSONObject.put("term", "[");
    triggerJSONObject.put("tplReplace", "<a href=\"{title}\">{title}</a>");
    triggerJSONObject.put("tplResults", "<span class=\"h5 truncate-text\">{title}</span>");

    triggerJSONArray.put(triggerJSONObject);

    autoCompleteConfigJSONObject.put("trigger", triggerJSONArray);

    jsonObject.put("autocomplete", autoCompleteConfigJSONObject);

    String extraPlugins = jsonObject.getString("extraPlugins");

    if (Validator.isNotNull(extraPlugins)) {
      extraPlugins += ",autocomplete";
    } else {
      extraPlugins = "autocomplete,ae_placeholder,ae_selectionregion,ae_uicore";
    }

    jsonObject.put("extraPlugins", extraPlugins);
  }
  @Override
  public String getURL(PortletRequest portletRequest, PortletResponse portletResponse) {

    ThemeDisplay themeDisplay = (ThemeDisplay) portletRequest.getAttribute(WebKeys.THEME_DISPLAY);

    PortletDisplay portletDisplay = themeDisplay.getPortletDisplay();

    return portletDisplay.getURLClose();
  }
  @Override
  public String getOnClick(PortletRequest portletRequest, PortletResponse portletResponse) {

    ThemeDisplay themeDisplay = (ThemeDisplay) portletRequest.getAttribute(WebKeys.THEME_DISPLAY);

    PortletDisplay portletDisplay = themeDisplay.getPortletDisplay();

    return "Liferay.Portlet.close('#p_p_id_"
        .concat(portletDisplay.getId())
        .concat("_'); return false;");
  }
Example #8
0
  public String getRSSName() {
    if (_rssName != null) {
      return _rssName;
    }

    ThemeDisplay themeDisplay = (ThemeDisplay) _request.getAttribute(WebKeys.THEME_DISPLAY);

    PortletDisplay portletDisplay = themeDisplay.getPortletDisplay();

    _rssName = _portletPreferences.getValue("rssName", portletDisplay.getTitle());

    return _rssName;
  }
Example #9
0
  public boolean isDefaultAssetPublisher() {
    if (_defaultAssetPublisher != null) {
      return _defaultAssetPublisher;
    }

    ThemeDisplay themeDisplay = (ThemeDisplay) _request.getAttribute(WebKeys.THEME_DISPLAY);

    PortletDisplay portletDisplay = themeDisplay.getPortletDisplay();

    _defaultAssetPublisher =
        AssetUtil.isDefaultAssetPublisher(
            themeDisplay.getLayout(), portletDisplay.getId(), getPortletResource());

    return _defaultAssetPublisher;
  }
  @Override
  public boolean includeIcon(HttpServletRequest request, HttpServletResponse response)
      throws IOException {

    ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY);

    PortletDisplay portletDisplay = themeDisplay.getPortletDisplay();

    request.setAttribute(
        ProductNavigationControlMenuWebKeys.PORTLET_DESCRIPTION, portletDisplay.getDescription());
    request.setAttribute(
        ProductNavigationControlMenuWebKeys.PORTLET_TITLE, portletDisplay.getTitle());

    return super.includeIcon(request, response);
  }
  public static List<BreadcrumbEntry> getPortletBreadcrumbEntries(HttpServletRequest request) {

    ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY);

    PortletDisplay portletDisplay = themeDisplay.getPortletDisplay();

    String name = WebKeys.PORTLET_BREADCRUMBS;

    List<BreadcrumbEntry> breadcrumbEntries = (List<BreadcrumbEntry>) request.getAttribute(name);

    if (Validator.isNotNull(portletDisplay.getId())
        && !portletDisplay.isFocused()
        && !Validator.equals(
            portletDisplay.getId(),
            PortletProviderUtil.getPortletId(
                BreadcrumbEntry.class.getName(), PortletProvider.Action.VIEW))) {

      name = name.concat(StringPool.UNDERLINE.concat(portletDisplay.getId()));

      List<BreadcrumbEntry> portletBreadcrumbEntries =
          (List<BreadcrumbEntry>) request.getAttribute(name);

      if (portletBreadcrumbEntries != null) {
        breadcrumbEntries = portletBreadcrumbEntries;
      }
    }

    if (breadcrumbEntries == null) {
      return Collections.emptyList();
    }

    for (int i = 0; i < breadcrumbEntries.size() - 1; i++) {
      BreadcrumbEntry portletBreadcrumbEntry = breadcrumbEntries.get(i);

      String url = portletBreadcrumbEntry.getURL();

      if (Validator.isNotNull(url) && !CookieKeys.hasSessionId(request)) {
        HttpSession session = request.getSession();

        portletBreadcrumbEntry.setURL(PortalUtil.getURLWithSessionId(url, session.getId()));
      }
    }

    return breadcrumbEntries;
  }
  @Override
  public boolean isShow(HttpServletRequest request) throws PortalException {
    ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY);

    Layout layout = themeDisplay.getLayout();

    if (!layout.isTypeControlPanel()) {
      return false;
    }

    PortletDisplay portletDisplay = themeDisplay.getPortletDisplay();

    if (portletDisplay == null) {
      return false;
    }

    return super.isShow(request);
  }
  protected JournalContentDisplayContext getJournalContentDisplayContext(
      PortletRequest portletRequest, PortletResponse portletResponse) {

    ThemeDisplay themeDisplay = (ThemeDisplay) portletRequest.getAttribute(WebKeys.THEME_DISPLAY);

    PortletDisplay portletDisplay = themeDisplay.getPortletDisplay();

    try {
      JournalContentPortletInstanceConfiguration journalContentPortletInstanceConfiguration =
          portletDisplay.getPortletInstanceConfiguration(
              JournalContentPortletInstanceConfiguration.class);

      return new JournalContentDisplayContext(
          portletRequest, portletResponse, journalContentPortletInstanceConfiguration);
    } catch (PortalException pe) {
      _log.error("Unable to create display context", pe);
    }

    return null;
  }